[SOLVED] Matching the history screen text color with the dialogue in textbox

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
ohprocrastinator
Newbie
Posts: 22
Joined: Thu May 23, 2013 8:44 am
Contact:

[SOLVED] Matching the history screen text color with the dialogue in textbox

#1 Post by ohprocrastinator »

Hi!

I've been dabbling in Ren'py again after a few years and the new UI is confusing me a bit, and I have no experience with Python at all so any help would be appreciated!

I have a custom colored text for a certain character and thought, in this case the grey text is the character's inner thoughts. I use what_color to set the text color when defining the character.
1.png
1.png (125.67 KiB) Viewed 27845 times

Code: Select all

define nt = Character("Nicol", image="nicol", what_color="#727C80")
And the teal text below acts as the narration. I use style.say_thought to set the color in gui script
3.png
3.png (127.07 KiB) Viewed 27845 times

Code: Select all

style say_thought:
    color "#198293"
    xpos gui.dialogue_xpos
    xsize gui.dialogue_width
    ypos gui.dialogue_ypos
    line_spacing 5
However, in the history screen, these texts are displayed with default gui color, like the normal dialogue.
5.png
5.png (125.18 KiB) Viewed 27845 times
4.png
(517.51 KiB) Not downloaded yet
I wonder if there's a way to match the dialogue text color in the history with the ones in the textbox? I assume it's in the history screen, but I'm not sure where to start. Here's what my history screen code looks like:

Code: Select all

screen history():

    tag menu

    if main_menu:
        add gui.main_menu_background
    else:
        add gui.game_menu_background

    modal True

    zorder 200

    style_prefix "confirm"

    add "gui/overlay/confirm.png"

    ## Avoid predicting this screen, as it can be very large.
    predict False

    frame:
        style_prefix "history"
        
        background "UI_history.png"
        top_padding 380
        right_padding 350
        bottom_padding 150
        vpgrid:
            yinitial 1.0
            cols 1
            draggable True
            mousewheel True
            scrollbars "vertical"
            vbox:
                for h in _history_list:

                    window:

                        ## This lays things out properly if history_height is None.
                        has fixed:
                            yfit True
 
                        if h.who:

                            label h.who:
                                style "history_name"
                                substitute False

                                ## Take the color of the who text from the Character, if
                                ## set.
                                if "color" in h.who_args:
                                    text_color h.who_args["color"]

                        $ what = renpy.filter_text_tags(h.what, allow=gui.history_allow_tags)
                        text what:
                            substitute False

                if not _history_list:
                    label _("The dialogue history is empty.")

    imagebutton:
        xpos 0.825
        ypos 0.695
        idle "UI_button_back.png"
        hover "UI_button_back_hover.png"
        action Return()

## This determines what tags are allowed to be displayed on the history screen.

define gui.history_allow_tags = { "alt", "noalt", "rt", "rb", "art" }


style history_window is empty

style history_name is gui_label
style history_name_text is gui_label_text
style history_text is gui_text

style history_label is gui_label
style history_label_text is gui_label_text

style history_window:
    xfill True
    ysize gui.history_height

style history_name:
    xpos gui.history_name_xpos
    xanchor gui.history_name_xalign
    ypos gui.history_name_ypos
    xsize gui.history_name_width

style history_name_text:
    min_width gui.history_name_width
    textalign gui.history_name_xalign

style history_text:
    xpos gui.history_text_xpos
    ypos gui.history_text_ypos
    xanchor gui.history_text_xalign
    xsize gui.history_text_width
    min_width gui.history_text_width
    textalign gui.history_text_xalign
    layout ("subtitle" if gui.history_text_xalign else "tex")
    line_spacing 5

style history_label:
    xfill True

style history_label_text:
    xalign 0.5
Thanks so much in advance!
Last edited by ohprocrastinator on Fri Jan 05, 2024 8:26 pm, edited 1 time in total.

User avatar
m_from_space
Miko-Class Veteran
Posts: 975
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Matching the history screen text color with the dialogue in textbox

#2 Post by m_from_space »

ohprocrastinator wrote: Thu Jan 04, 2024 9:34 am I wonder if there's a way to match the dialogue text color in the history with the ones in the textbox? I assume it's in the history screen, but I'm not sure where to start.
I mean the history screen even uses a comment on how it uses the color of the name of the character. It should be easy to just do the same with the dialogue text.

Here look:

Code: Select all

screen history():

    tag menu

                                ## Take the color of the who text from the Character, if
                                ## set.
                                if "color" in h.who_args:
                                    text_color h.who_args["color"]
So you just have to do this:

Code: Select all


                        text what:
                            substitute False
                            if "color" h.what_args:
                                color h.what_args["color"]


Post Reply

Who is online

Users browsing this forum: Google [Bot], wizard_jpg