Changing the GUI mid game?

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
Posts: 2
Joined: Sun Dec 10, 2017 2:53 pm

Changing the GUI mid game?

#1 Post by sammamish1 » Sun Dec 10, 2017 3:00 pm

Is there a way to change elements of the GUI in game, whether that's in between scenes or even during dialogue? For example, if I wanted the text box or font size to be different if that narrator were to change, could I do that? I try simple code like this for testing purposes:

$ gui.text_size = 30 # The default size is 22

When this line is run, nothing actually changes. I understand that gui.text_size if defined at the beginning, meaning it should probably be a constant value. So is there a way to change that? Are styles the best course of action here? I'm not too sure. Any answers would be very appreciated.

User avatar
Miko-Class Veteran
Posts: 615
Joined: Mon Oct 03, 2011 7:27 pm
Completed: Simple as Snow, Lady Luck's Due,
Projects: Aether Skies, Of the Waterfall
Tumblr: casting-dreams
itch: castingdreams
Location: USA

Re: Changing the GUI mid game?

#2 Post by wyverngem » Sun Dec 10, 2017 10:49 pm

You can do something like this: ... preference

You define styles

Code: Select all

init python:
    renpy.register_style_preference("text", "basic", style.say_dialogue, "font", "font/Almendra-Regular.ttf")
    #Other's Font
    renpy.register_style_preference("text", "dyslexic", style.say_dialogue, "font", "font/verdana.ttf")
After define them you would use $ renpy.set_style_preference(preference, alternative) to set it up.
Otherwise you could use it in a button too:

Code: Select all

                    textbutton "Default":
                        hovered tt.Action("Sets the game font to the default style.")
                        action StylePreference("text", "basic") text_font "font/Almendra-Regular.ttf"
                        alt "Default Font"
                    textbutton "Alternative":
                        hovered tt.Action("A font that was chosen to be easier to read for those with dyslexia.")
                        action StylePreference("text", "dyslexic") text_font "font/verdana.ttf"
                        alt "Alternative Font"

Post Reply

Who is online

Users browsing this forum: Google [Bot]