[SOLVED] Who / Say_label Colour Override

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
SinSisters
Regular
Posts: 97
Joined: Sat Sep 20, 2014 11:07 am
Completed: The Spanish Privateer
Projects: The Spanish Privateer
Tumblr: sinsisters
itch: sinsisters
Location: Canada
Contact:

[SOLVED] Who / Say_label Colour Override

#1 Post by SinSisters »

Hi all,

I'd like to include an option for players to increase colour contrast if necessary. I'd like to be able to set all of the namebox say labels to black (and back to their individual colours again when the default option is selected!). I was able to adjust the colour contrast of the namebox and textbox using:

Code: Select all

screen say(who, what):
    style_prefix "say"
    window:
        id "window"
        if persistent.contrast == True:
            $ style.say_window = style.window_contrast
        else:
            $ style.say_window = style.window
        if who is not None:
            window:
                id "namebox"
                if persistent.contrast == True:
                    style "namebox_contrast"
                else:
                    style "namebox"
                text who:
                    id "who"
                    if (len(_history_list) == 0 ) or (len(_history_list) > 0 and _history_list[-1].who != who):
                        at trans_say_label
        text what id "what"
with some short window_contrast and namebox_contrast styles. However, it seems like the character name colour will be overridden by the colour chosen when I defined the individual characters. My best guess would be to alter "who" colour property somehow, but I'm not sure how/where "who" is defined or how I would go about altering that.

Thank you in advance!
Last edited by SinSisters on Mon Feb 15, 2021 2:17 pm, edited 1 time in total.

User avatar
KuroOneHalf
Regular
Posts: 129
Joined: Fri Apr 25, 2014 6:18 pm
Completed: Cuttlebone
Projects: Somewhere In The Shade
Deviantart: KuroOneHalf
itch: kuroonehalf
Contact:

Re: Who / Say_label Colour Override

#2 Post by KuroOneHalf »

Why not have an if statement inside "text who:"?

Code: Select all

text who:
    if persistent.contrast:
        color "#000"
ps: "if persistent.contrast == True:" is the same as just doing "if persistent.contrast:".

cheonbyeol
Regular
Posts: 37
Joined: Thu Feb 04, 2021 9:04 am
Contact:

Re: Who / Say_label Colour Override

#3 Post by cheonbyeol »

Alternate solution:
define a transform that turns your text black, and apply that to the namebox. It takes effect after the style has already been applied, so it will override the color!

Define the transform somwhere:

Code: Select all

transform blacken:
    matrixcolor TintMatrix("#000")
Modify the say screen:

Code: Select all

# ....
text who:
    id "who"
    if persistent.contrast:
        at blacken
    if (len(_history_list) == 0 ) or (len(_history_list) > 0 and _history_list[-1].who != who):
        at trans_say_label
# ....
Quick edited to fit the code with what you already have.

To answer the original question too: the who color is the color defined with the character:

Code: Select all

define c = Character("name", color="#000")
From what I gleamed of Ren'Py so far, to manipulate that, you have to manipulate the created character object, and you'd have to do that for each character, so not the easy route.

User avatar
SinSisters
Regular
Posts: 97
Joined: Sat Sep 20, 2014 11:07 am
Completed: The Spanish Privateer
Projects: The Spanish Privateer
Tumblr: sinsisters
itch: sinsisters
Location: Canada
Contact:

Re: Who / Say_label Colour Override

#4 Post by SinSisters »

Thanks for the suggestions everyone (and the T/F tip :D) but unfortunately the transform seems to also have no effect (same for color style)... I'm interested in finding out how "who" is defined exactly, as it seems like anything done within the screen properties takes a backseat to the character defined properties. However, if you've tried the transform and found it works for you, please let me know, because there might be something funny going on from my end...

EDIT:
Right now the only fix I can find is PyTom's dynamically changing method. It solves the problem with:

Code: Select all

default character_color = { "Carlota" : "#4ba3b2" }
default character_color_contrast = { "Carlota" : "#000" }
for all of the characters with non-black colours and:

Code: Select all

                text who:
                    id "who"
                    if persistent.contrast:
                        color character_color_contrast.get(who,"#ffffff")
                    else:
                        color character_color.get(who,"#ffffff")
but I would love to see a more robust solution that doesn't involve redefining all the characters!

cheonbyeol
Regular
Posts: 37
Joined: Thu Feb 04, 2021 9:04 am
Contact:

Re: Who / Say_label Colour Override

#5 Post by cheonbyeol »

OH. Now I remember, I had that issue too with the transform doing nothing. Sorry I didn't mention it before. For matrixcolor to work, you need to turn on model-based rendering (don't know much about it, but some commands need it, and otherwise it doesn't seem to cause trouble). You have to add

Code: Select all

define config.gl2 = True
somewhere in the code, I have it in options.rpy.

User avatar
zmook
Veteran
Posts: 421
Joined: Wed Aug 26, 2020 6:44 pm
Contact:

Re: Who / Say_label Colour Override

#6 Post by zmook »

It would be doable by subclassing Character, but that's definitely the hard way compared to the matrix transform, assuming it works. (I don't believe Kuroonehalf's solution works -- in my test, a Character's who_color overwrites any color specified in the `text` statement.)
colin r
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM

User avatar
SinSisters
Regular
Posts: 97
Joined: Sat Sep 20, 2014 11:07 am
Completed: The Spanish Privateer
Projects: The Spanish Privateer
Tumblr: sinsisters
itch: sinsisters
Location: Canada
Contact:

Re: Who / Say_label Colour Override

#7 Post by SinSisters »

Thanks cheonbyeol! Works like a charm :) Will be marking this as solved now.

Post Reply

Who is online

Users browsing this forum: No registered users