Textbutton display getting stuck

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
orian34
Newbie
Posts: 14
Joined: Tue Aug 24, 2021 3:42 am
Github: orian34
itch: orian34
Discord: orian34
Contact:

Textbutton display getting stuck

#1 Post by orian34 »

I've been building a chapter select/jump screen, and I've hit a strange issue.
The features all work fine, but somehow the display of the textbuttons gets stuck weirdly. It switches around after I click on one, and only seem to appear when the setting is on Jump.
textbbug.png
textb.png
It doesn't prevent the buttons from working, but it's an annoying glitch which I have no idea why it happens.

This is the code of the screen itself.

Code: Select all

screen chapters:
    tag menu

    add "black"
    vbox:
        style_prefix "radio"
        xalign 0.02
        yalign 0.01
        label _("Read Mode")
        textbutton _("Replay") action SetVariable('read_mode', False)
        textbutton _("Jump") action SetVariable('read_mode', True)
    hbox:
        style_prefix "radio"
        xalign 0.5
        yalign 0.03
        spacing 30
        textbutton _("Act 1") action SetVariable('route_mode', 0)
        if persistent.read_chapters['C1'] > 0:
            textbutton _("Act 2") action SetVariable('route_mode', 1)
        if persistent.read_chapters['P1'] > 0:
            textbutton _("Act 3") action SetVariable('route_mode', 2)
        if persistent.read_chapters['S1'] > 0:
            textbutton _("Act 4") action SetVariable('route_mode', 3)

    if persistent.read_chapters['A1'] > 0:
        if route_mode == 0:
            if read_mode:
                textbutton "Gone" xpos 0.15 ypos 0.15 action [SetVariable('read_current', 0),Start("game")]
            else:
                textbutton "Gone" xpos 0.15 ypos 0.15 action Replay("A1")
        elif route_mode == 1:
            if read_mode:
                textbutton "Found" xpos 0.15 ypos 0.15 action Start("game")
            else:
                textbutton "Found" xpos 0.15 ypos 0.15 action Replay("A1")
#        elif:

    if persistent.read_chapters['X1'] > 0:
        if route_mode == 0:
            if read_mode:
                textbutton "Opening" xpos 0.15 ypos 0.19 action [SetVariable('read_current', 1),Start("game")]
            else:
                textbutton "Opening" xpos 0.15 ypos 0.19 action Replay("X1")

    if persistent.read_chapters['A2'] > 0:
        if route_mode == 0:
            if read_mode:
                textbutton "Hello" xpos 0.15 ypos 0.23 action [SetVariable('read_current', 2),Start("game")]
            else:
                textbutton "Hello" xpos 0.15 ypos 0.23 action Replay("A2")

    if persistent.read_chapters['A3'] > 0:
        if route_mode == 0:
            if read_mode:
                textbutton "It" xpos 0.15 ypos 0.27 action [SetVariable('read_current', 3),Start("game")]
            else:
                textbutton "It" xpos 0.15 ypos 0.27 action Replay("A3")

    if persistent.read_chapters['A3A1'] > 0:
        if route_mode == 0:
            if read_mode:
                textbutton "No" xpos 0.15 ypos 0.31 action [SetVariable('read_current', 4),SetDict(Alexandria, 'A3', 1),Start("game")]
            else:
                textbutton "No" xpos 0.15 ypos 0.31 action Replay("A3A1")

    if persistent.read_chapters['A3B1'] > 0:
        if route_mode == 0:
            if read_mode:
                textbutton "Lost" xpos 0.15 ypos 0.35 action [SetVariable('read_current', 4),SetDict(Alexandria, 'A3', 2),Start("game")]
            else:
                textbutton "Lost" xpos 0.15 ypos 0.35 action Replay("A3B1")

    if persistent.read_chapters['A4'] > 0:
        if route_mode == 0:
            if read_mode:
                textbutton "Fine" xpos 0.15 ypos 0.39 action [SetVariable('read_current', 5),Start("game")]
            else:
                textbutton "Fine" xpos 0.15 ypos 0.39 action Replay("A4")

    textbutton "Return" xalign 0.5 yalign 0.98 action Return()
    textbutton "Reset" xalign 0.98 yalign 0.98 action Jump("total_reset")
If anyone is able to understand why it happens, and I can manage to fix it, I'd be grateful.

rayminator
Miko-Class Veteran
Posts: 793
Joined: Fri Feb 09, 2018 12:05 am
Location: Canada
Contact:

Re: Textbutton display getting stuck

#2 Post by rayminator »

use Hide("chapters") to the textbuttons that doesn't require the screen chapters

User avatar
orian34
Newbie
Posts: 14
Joined: Tue Aug 24, 2021 3:42 am
Github: orian34
itch: orian34
Discord: orian34
Contact:

Re: Textbutton display getting stuck

#3 Post by orian34 »

rayminator wrote: Wed Jan 26, 2022 5:26 pm use Hide("chapters") to the textbuttons that doesn't require the screen chapters
I'm not sure I understand, those all need the screen chapters. Or do you mean other buttons?

User avatar
orian34
Newbie
Posts: 14
Joined: Tue Aug 24, 2021 3:42 am
Github: orian34
itch: orian34
Discord: orian34
Contact:

Re: Textbutton display getting stuck

#4 Post by orian34 »

In the end, I managed to find out why it was happening. It was caused by renpy automatically highlighting buttons if they set a variable to a value, and that variable is already set to the value.
Probably used for the on/off buttons and such.

I solved it by adding "selected False" for the buttons, overriding it.

Post Reply

Who is online

Users browsing this forum: Andredron, Google [Bot]