Easiest way to change textbox colour? [SOLVED]

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
AsHLeX
Veteran
Posts: 489
Joined: Wed Dec 25, 2013 1:09 pm
Completed: Starlight Dreamers, Mysterious Melody, Town of Memories, Marked, To Fly, The Change, Him From The Past, A Forgotten Memory
Projects: Cafe Mysteria
Location: Malaysia
Contact:

Easiest way to change textbox colour? [SOLVED]

#1 Post by AsHLeX » Thu Dec 05, 2019 6:14 am

Hi everyone! Thanks in advance for taking the time to read this!
As the title says, I've been trying to figure out the best way to change the textbox colour from red to grayscale for use in certain scenes.
So what I did was define a new grayscale image via:

Code: Select all

image textbox gray = im.MatrixColor(
    "gui/textbox.png",
    im.matrix.desaturate() * im.matrix.tint(1.0, 1.0, 1.0))
And then... I've tried the following but they all seem to have problems:

OPTION 1:
Defining a new textbox via:

Code: Select all

init:
    $ narrator = Character(None, window_background="textbox gray", window_height=278, window_xalign=0.5, window_yalign=1.0)
But I can't seem to get the textbox to be in the right position (image reference below):
screenshot0001.png
it keeps sticking in the lower left corner
'
OPTION 2:
Tried defining a grayscaletext variable as false and then inserting this line of code into the style window:

Code: Select all

style window:
    xalign 0.5
    xfill True
    yalign gui.textbox_yalign
    ysize gui.textbox_height

    if grayscaletext:
        background Image("textbox gray", xalign=0.5, yalign=1.0) 
    else: 
        background Image("gui/textbox.png", xalign=0.5, yalign=1.0)
This just brings up an error, so I guess we can't use variables in styles?

OPTION 3:
I tried inserting the grayscaletext variable into screen say but that just turned into a mess and I was having the textbox appearing and disappearing at random times:

Code: Select all

screen say(who, what):
    style_prefix "say"

    window:
        id "window"

        if who is not None:

            window:
                id "namebox"
                style "namebox"
                text who id "who"
                
        else:
            if graytext:
                background Image("textbox gray", xalign=0.5, yalign=1.0)
            else:
                background Image("gui/textbox.png", xalign=0.5, yalign=1.0)

        text what id "what"
(Uploaded my .rpy files for reference if anyone needs them)

I'm at my wits end, would really really appreciate help! :( :(
Thanks again!
Attachments
script.rpy
(11.88 KiB) Downloaded 3 times
screens.rpy
(43.26 KiB) Downloaded 3 times
options.rpy
(7.13 KiB) Downloaded 3 times
gui.rpy
(15.74 KiB) Downloaded 3 times
Last edited by AsHLeX on Fri Dec 06, 2019 10:22 pm, edited 1 time in total.
Image

User avatar
deltadidirac
Regular
Posts: 115
Joined: Fri Nov 30, 2018 5:00 am
Projects: Slip Over Time
Tumblr: deltadidirac
Deviantart: Deltadidirac67
Location: Europe
Contact:

Re: Easiest way to change textbox colour?

#2 Post by deltadidirac » Thu Dec 05, 2019 12:44 pm

AsHLeX wrote:
Thu Dec 05, 2019 6:14 am
Hi everyone! Thanks in advance for taking the time to read this!
As the title says, I've been trying to figure out the best way to change the textbox colour from red to grayscale for use in certain scenes.
So what I did was define a new grayscale image via:

Code: Select all

image textbox gray = im.MatrixColor(
    "gui/textbox.png",
    im.matrix.desaturate() * im.matrix.tint(1.0, 1.0, 1.0))
And then... I've tried the following but they all seem to have problems:

OPTION 1:
Defining a new textbox via:

Code: Select all

init:
    $ narrator = Character(None, window_background="textbox gray", window_height=278, window_xalign=0.5, window_yalign=1.0)
But I can't seem to get the textbox to be in the right position (image reference below):
screenshot0001.png
'
OPTION 2:
Tried defining a grayscaletext variable as false and then inserting this line of code into the style window:

Code: Select all

style window:
    xalign 0.5
    xfill True
    yalign gui.textbox_yalign
    ysize gui.textbox_height

    if grayscaletext:
        background Image("textbox gray", xalign=0.5, yalign=1.0) 
    else: 
        background Image("gui/textbox.png", xalign=0.5, yalign=1.0)
This just brings up an error, so I guess we can't use variables in styles?

OPTION 3:
I tried inserting the grayscaletext variable into screen say but that just turned into a mess and I was having the textbox appearing and disappearing at random times:

Code: Select all

screen say(who, what):
    style_prefix "say"

    window:
        id "window"

        if who is not None:

            window:
                id "namebox"
                style "namebox"
                text who id "who"
                
        else:
            if graytext:
                background Image("textbox gray", xalign=0.5, yalign=1.0)
            else:
                background Image("gui/textbox.png", xalign=0.5, yalign=1.0)

        text what id "what"
(Uploaded my .rpy files for reference if anyone needs them)

I'm at my wits end, would really really appreciate help! :( :(
Thanks again!
Hi
if you want change the textbox in some dialogues (e.g. during the "narration" ) you must have first of all different images for each textbox you want to use....

in my game I use 3 textbox : the default one, and 2 others for the narration.
1) first, I create the 3 different images (the "default", "nar2", and "nar3")
2) I added and defined it in the correct folder ( in image folder in this case so I must write also the extension .png)
3) I defined the new narration characters as is:

Code: Select all

define n1 = Character(window_background="nar2.png", window_xpos=0.57, window_ypos=0.85, what_xpos= 0.15, what_ypos=0.5, what_size=22, what_font="TektonPro-BoldExt.otf") 
define n2 = Character(window_background="nar3.png", window_xpos=0.57, window_ypos=0.2, what_xpos= 0.15, what_ypos=0.5, what_size=22, what_font="TektonPro-BoldExt.otf")


As you can see in the definition at I start directly with "window_background.....", there is no name, so you will see only the textbox without a "name-box", only the dialogue.
You can copy my script and after adapt to yuor needs, for all it's run right.

see you

User avatar
AsHLeX
Veteran
Posts: 489
Joined: Wed Dec 25, 2013 1:09 pm
Completed: Starlight Dreamers, Mysterious Melody, Town of Memories, Marked, To Fly, The Change, Him From The Past, A Forgotten Memory
Projects: Cafe Mysteria
Location: Malaysia
Contact:

Re: Easiest way to change textbox colour?

#3 Post by AsHLeX » Fri Dec 06, 2019 7:27 am

Thank you so much, deltadidirac! That solved it! :D
Image

User avatar
deltadidirac
Regular
Posts: 115
Joined: Fri Nov 30, 2018 5:00 am
Projects: Slip Over Time
Tumblr: deltadidirac
Deviantart: Deltadidirac67
Location: Europe
Contact:

Re: Easiest way to change textbox colour?

#4 Post by deltadidirac » Fri Dec 06, 2019 9:38 am

My pleasure,
happy for you

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], renardjap