Settings screen always uses True setting instead of default setting

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
kostek00
Regular
Posts: 131
Joined: Wed Mar 28, 2018 5:54 pm
Contact:

Settings screen always uses True setting instead of default setting

#1 Post by kostek00 »

I made settings screen with custom options. They control things like outline, shadow, justify and few more. For some reason game always uses "True" for style preferences which are "text_outline", "text_shadow" and "text_justify". For everything else settings works as they should.

This is is how i register styles preferences:

Code: Select all

init -2 python:
        # Outline
        renpy.register_style_preference("text_outline", True, style.say_dialogue, "outlines", [(1, (0, 0, 0, 255), 0, 0)])
        renpy.register_style_preference("text_outline", False, style.say_dialogue, "outlines", [(0, (0, 0, 0, 0), 0, 0)])

        # Shadow
        renpy.register_style_preference("text_shadow", True, style.say_dialogue, "drop_shadow", [(2, 2)])
        renpy.register_style_preference("text_shadow", False, style.say_dialogue, "drop_shadow", [(0, 0)])

        # Justification
        renpy.register_style_preference("text_justify", True, style.say_dialogue, "justify", True)
        renpy.register_style_preference("text_justify", False, style.say_dialogue, "justify", False)
Those are my settings:

Code: Select all

default persistent.textbox_transparency = 0.9
default text_outline = False
default text_shadow = False
default text_justify = False
default text_sfx = True


screen settings_disable:
    modal True

    timer 2 action Hide("settings_disable")


screen settings(fromPause=False,fromMain=False):

    tag menu
    modal True
    key "game_menu" action Return()

    python:
        xy = renpy.get_physical_size()

    if not fromPause:
        add gui.mm_background

    fixed:
        if fromPause == False:
            at gui_no_fade_inout
        else:
            at gui_fade_out
        add "gui_overlay"

        use exit_button_noAnim

        add "gui/log_decor_top.png" at gui_overlaydecor_top_noAnim

        frame:
            background None
            xsize 1200
            at gui_overlaydecor_bottom_noAnim

            add "gui/settings_decor_bottom.png":
                alpha 0.3

            text "SETTINGS":
                style "gui_overlay_title"

        viewport id "vp":
            mousewheel True
            draggable True
            xsize 1200 xalign 0.5
            ysize 860 yalign 0.49
            yinitial 0.0

            vbox:
                xsize 1130
                spacing 30

                vbox:
                    xsize 1130
                    ypos 10
                    spacing 7

                    hbox:
                        ysize 60
                        xalign 0.0
                        spacing 50

                        text "Onomatopeias" style "settings_header"

                        hbox:
                            spacing 30

                            button:
                                xsize 150 ysize 60
                                at gui_buttonfade_noAnim

                                hovered Play("system",guisfx_button_hover)
                                action [Play("system",guisfx_button_click),
                                        SetVariable("text_sfx", True)]

                                add "gui/settings_show_idle.png"
                                text "SHOW" style "settings_button_text"

                            button:
                                xsize 125 ysize 60
                                at gui_buttonfade_noAnim

                                hovered Play("system",guisfx_button_hover)
                                action [Play("system",guisfx_button_click),
                                        SetVariable("text_sfx", False)]

                                add "gui/settings_hide_idle.png"
                                text "HIDE" style "settings_button_text"


                    hbox:
                        ysize 60
                        xalign 0.0
                        spacing 50

                        text "Text Outline" style "settings_header"

                        hbox:
                            spacing 30

                            button:
                                xsize 150 ysize 60
                                at gui_buttonfade_noAnim

                                hovered Play("system",guisfx_button_hover)
                                action [Play("system",guisfx_button_click),
                                        StylePreference("text_outline", True)]

                                add "gui/settings_show_idle.png"
                                text "SHOW" style "settings_button_text"

                            button:
                                xsize 125 ysize 60
                                at gui_buttonfade_noAnim

                                hovered Play("system",guisfx_button_hover)
                                action [Play("system",guisfx_button_click),
                                        StylePreference("text_outline", False)]

                                add "gui/settings_hide_idle.png"
                                text "HIDE" style "settings_button_text"


                    hbox:
                        ysize 60
                        xalign 0.0
                        spacing 50

                        text "Text Shadow" style "settings_header"

                        hbox:
                            spacing 30

                            button:
                                xsize 150 ysize 60
                                at gui_buttonfade_noAnim

                                hovered Play("system",guisfx_button_hover)
                                action [Play("system",guisfx_button_click),
                                        StylePreference("text_shadow", True)]

                                add "gui/settings_show_idle.png"
                                text "SHOW" style "settings_button_text"

                            button:
                                xsize 125 ysize 60
                                at gui_buttonfade_noAnim

                                hovered Play("system",guisfx_button_hover)
                                action [Play("system",guisfx_button_click),
                                        StylePreference("text_shadow", False)]

                                add "gui/settings_hide_idle.png"
                                text "HIDE" style "settings_button_text"


                    hbox:
                        ysize 60
                        xalign 0.0
                        spacing 50

                        text "Text Justify" style "settings_header"

                        hbox:
                            spacing 30

                            button:
                                xsize 95 ysize 60
                                at gui_buttonfade_noAnim

                                hovered Play("system",guisfx_button_hover)
                                action [Play("system",guisfx_button_click),
                                        StylePreference("text_justify", True)]

                                add "gui/settings_on_idle.png"
                                text "ON" style "settings_button_text"

                            button:
                                xsize 110 ysize 60
                                at gui_buttonfade_noAnim

                                hovered Play("system",guisfx_button_hover)
                                action [Play("system",guisfx_button_click),
                                        StylePreference("text_justify", False)]

                                add "gui/settings_off_idle.png"
                                text "OFF" style "settings_button_text"


                vbox:
                    xsize 1130 ysize 200
                    spacing 40
                    yoffset 20

                    vbox:
                        xsize 1130
                        xalign 0.5 ysize 70
                        text "Textbox Transparency" style "settings_header" xalign 0.5

                        hbox:
                            xsize 1130 xalign 0.5
                            spacing 13

                            text "TRANSPARENT":
                                xsize 85 xalign 1.0
                                style "caption_med"
                                kerning gui.advname_font_kerning

                            bar:
                                hovered Play("system",guisfx_button_hover)
                                value FieldValue(persistent, "textbox_transparency", range=0.5, offset=0.5)
                                base_bar "gui/settings_text_bar.png"
                                thumb "gui/settings_text_thumb.png"

                                xsize 862 ysize 22
                                xalign 0.5 yoffset 3
                                at gui_buttonfade_noAnim

                            text "SOLID":
                                xsize 85 xalign 0.0 xoffset 4
                                style "caption_med"
                                kerning gui.advname_font_kerning

User avatar
Matalla
Veteran
Posts: 202
Joined: Wed Mar 06, 2019 6:22 pm
Completed: Max Power and the Egyptian Beetle Case, The Candidate, The Last Hope, El cajón del viejo escritorio, Clementina y la luna roja, Caught in Orbit, Dirty Business Ep 0, Medianoche de nuevo, The Lost Smile
itch: matalla-interactive
Location: Spain
Contact:

Re: Settings screen always uses True setting instead of default setting

#2 Post by Matalla »

I use this system to change the textbox, although it's a little different and I don't fully understand the method, I can suggest a couple of things to try.

First, I think the first element in the registering style should be the element affected, in this case "text", and not "text_outline".

For the second I use a custom string, not a boolean (probably should work too with a boolean, but if the first step doesn't solve the issue, it's worth a try). So I'd change the True/False for something like "outlines_on"/"outlines_off".

Code: Select all

renpy.register_style_preference("text", "outlines_on", style.say_dialogue, "outlines", [(1, (0, 0, 0, 255), 0, 0)])
Then for calling the change use ("text", "outlines_on"). I use it with python, which would be somethink like this:

Code: Select all

renpy.set_style_preference ("text", "outlines_on")
But, assuming the syntax in the action code is right, would be the same.
Comunidad Ren'Py en español (Discord)
Honest Critique

User avatar
kostek00
Regular
Posts: 131
Joined: Wed Mar 28, 2018 5:54 pm
Contact:

Re: Settings screen always uses True setting instead of default setting

#3 Post by kostek00 »

You are thinking about it in wrong way. I will try explain it. You don't register here style but style preference and that's big difference.

Code: Select all

renpy.register_style_preference(preference, alternative, style, property, value)
First element is not element affected. "Preference" is name of style preference not style, think of it as variable. What will happen if you assign everything to one variable name? You will be able to use only one of those option at a time because they are assigned to the same variable.
Second element you can call "state". Whether you use boolen (True/False) or string it doesn't matter because button that calls this uses state you assign to it.

Just in case I changed it to string but it still don't use default settings.

User avatar
Matalla
Veteran
Posts: 202
Joined: Wed Mar 06, 2019 6:22 pm
Completed: Max Power and the Egyptian Beetle Case, The Candidate, The Last Hope, El cajón del viejo escritorio, Clementina y la luna roja, Caught in Orbit, Dirty Business Ep 0, Medianoche de nuevo, The Lost Smile
itch: matalla-interactive
Location: Spain
Contact:

Re: Settings screen always uses True setting instead of default setting

#4 Post by Matalla »

Maybe I'm thinking the wrong way, although it's a wildly optimistic assumption on your part. Actually, I'm keeping the thinking to a minimum. I just know that this two pieces of code work:

Code: Select all

init python:
   
    renpy.register_style_preference ("window", "dbli", style.window, "xpos", 250)
    renpy.register_style_preference ("window", "dbli", style.window, "background", Image("gui/textboxes/dbli_textbox.png", xalign=0.5, yalign=1.0))
    renpy.register_style_preference ("text", "dbli", style.say_dialogue, "xpos", 535)

    renpy.register_style_preference ("window", "dbri", style.window, "xpos", 825)
    renpy.register_style_preference ("window", "dbri", style.window, "background", Image("gui/textboxes/dbri_textbox.png", xalign=0.5, yalign=1.0))
    renpy.register_style_preference ("text", "dbri", style.say_dialogue, "xpos", 542)

Code: Select all

init python:

def checkballoon(event, interact=True, **kwargs):
        if not interact:
            return

        if event == "begin":
            
            if balloon == "dbli":
                renpy.set_style_preference ("window", "dbli")
                renpy.set_style_preference ("text", "dbli")
            elif balloon == "dbri":
                renpy.set_style_preference ("window", "dbri")
                renpy.set_style_preference ("text", "dbri")
Comunidad Ren'Py en español (Discord)
Honest Critique

User avatar
kostek00
Regular
Posts: 131
Joined: Wed Mar 28, 2018 5:54 pm
Contact:

Re: Settings screen always uses True setting instead of default setting

#5 Post by kostek00 »

They work as you think because you have condition to select one of them. if you would remove condition you would see that only last (I think) one would be used.

In your case affeted elements by those style preferences are "style.window" and "style.say_dialogue".

User avatar
Matalla
Veteran
Posts: 202
Joined: Wed Mar 06, 2019 6:22 pm
Completed: Max Power and the Egyptian Beetle Case, The Candidate, The Last Hope, El cajón del viejo escritorio, Clementina y la luna roja, Caught in Orbit, Dirty Business Ep 0, Medianoche de nuevo, The Lost Smile
itch: matalla-interactive
Location: Spain
Contact:

Re: Settings screen always uses True setting instead of default setting

#6 Post by Matalla »

kostek00 wrote: Sun Apr 14, 2019 4:25 pm They work as you think because you have condition to select one of them. if you would remove condition you would see that only last (I think) one would be used.
The condition just apply the registered preference (when this condition is true, do this). It's just like pressing a button (when this button is clicked, do this). I don't see the diference. In one case, you use an action; in the other, a statement. But is the same thing. At one point I actually did it with an action with on "show" in the say screen, but changed the method finally for other reasons not related with this. But the styles changed as intended. I'm pretty sure that is not the reason because my code works and yours doesn't, must be something else.

It could be as you say, and it would be the same if I use "abracadabra" instead of "window". Anyway, this is all I could do: offering some working code similar enough to what you're trying to do. As I said, I don't fully understand how it works. I'm sorry it wasn't what you need.
Comunidad Ren'Py en español (Discord)
Honest Critique

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Andredron, Google [Bot]