[Solved] Rollback Say Window UI Different

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: 94
Joined: Sat Sep 20, 2014 11:07 am
Projects: The Spanish Privateer
Tumblr: thespanishprivateer
itch: sinsisters
Location: Ottawa, Canada
Contact:

[Solved] Rollback Say Window UI Different

#1 Post by SinSisters » Sun Mar 21, 2021 11:20 pm

Hi everyone,

We have an option in our game to allow players to select a different textbox frame for higher contrast if desired. It's defined in this manner:

Code: Select all

screen say(who, what):
    style_prefix "say"
    window:
        id "window"
        if persistent.contrast:
            $ style.say_window = style.window_contrast
        else:
            $ style.say_window = style.window
        if who is not None:
            window:
                id "namebox"
                if persistent.contrast:
                    style "namebox_contrast"
                else:
                    style "namebox"

Code: Select all

init python:
    config.character_id_prefixes.append('namebox')
style window is default
style say_label is default
style say_dialogue is default
style say_thought is say_dialogue

style namebox is default
style namebox_label is say_label

style window:
    xalign 0.5
    xfill True
    yalign gui.textbox_yalign
    ysize gui.textbox_height
    background Image("gui/textbox.png", xalign=0.5, yalign=1.0)

style window_contrast is window:
    background Image("gui/textbox_contrast.png", xalign=0.5, yalign=1.0)

style namebox:
    xpos gui.name_xpos
    xanchor gui.name_xalign
    xsize gui.namebox_width
    ypos gui.name_ypos
    ysize gui.namebox_height
    background Frame("gui/namebox.png", gui.namebox_borders, tile=gui.namebox_tile, xalign=gui.name_xalign)
    padding gui.namebox_borders.padding

style namebox_contrast is namebox:
    background Frame("gui/namebox_contrast.png", gui.namebox_borders, tile=gui.namebox_tile, xalign=gui.name_xalign)
The namebox/say window toggle on and off as required, however, Rollback displays differently. The namebox will be displayed correctly (contrast if contrast, etc) but the say window textbox displays the opposite background frame. When using PgUp OR PgDn, the textbox displays high contrast if default is selected and vice versa. It goes back to normal if I click to read normally.

I can't find any extensive documentation on how the rollback function works, so I'm not sure where I'm going wrong—or why the namebox displays correctly but the textbox doesn't. Thank you in advance for any help you can provide.
Last edited by SinSisters on Mon Mar 22, 2021 8:13 pm, edited 1 time in total.

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

Re: Rollback Say Window UI Different

#2 Post by zmook » Mon Mar 22, 2021 12:29 am

Setting values inside your screens looks questionable, though I'm not sure that it's wrong. Screen code can be executed at any time for prediction purposes, whether the screen is currently visible or not. In this case it seems like there might not be any harm to *constantly* reassigning $ style.say_window = style.window_contrast, but I don't entirely know how rollback works, either.

Anyway, there is a facility for StylePreferences that seems designed for exactly what you want to do.
https://www.renpy.org/doc/html/style.ht ... preference

The docs are… possibly adequate? If you need an example, let us know.
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: 94
Joined: Sat Sep 20, 2014 11:07 am
Projects: The Spanish Privateer
Tumblr: thespanishprivateer
itch: sinsisters
Location: Ottawa, Canada
Contact:

Re: Rollback Say Window UI Different

#3 Post by SinSisters » Mon Mar 22, 2021 8:13 pm

Brilliant! This is exactly what I needed (works with rollback whew). Whenever I'm coding, I always ask myself "is there an easier/more efficient way to do this"? And without a doubt, the answer is always yes... I just don't always know how! Thank you so much!

Post Reply

Who is online

Users browsing this forum: Bing [Bot], GetOutOfMyLab