Extra menu buttons glitch (SOLVED)

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
Quinn-G
Newbie
Posts: 11
Joined: Mon Jul 04, 2016 1:40 pm
Projects: Blazing Skies
Deviantart: Quinn-G
Contact:

Extra menu buttons glitch (SOLVED)

#1 Post by Quinn-G » Mon Jul 04, 2016 2:46 pm

Hi all! I finally decided to join the forums today and hope I'm not too much of a noobish hassle for more seasoned coders.

Long story short, I've taken on the challenge to singlehandedly write, illustrate AND program my own visual novel. Thanks in no small part to the tutorials on the Ren'Py handbook tumblr and various bits of knowledge I found browsing these very threads, I've managed to put together a functional and decent-looking menu interface (mostly using imagebuttons).
pythonw 2016-07-04 19-45-07-76.png
The main menu.
The reason I'm calling out to the community now is that I've encountered a small, albeit annoying pebble during development. See, I have an extra menu where the player will find 1) a Gallery containing all unlocked CGs with character-specific sub-sections; 2) a Lore section containing complementary information on the game's story and universe; and 3) a Music section for all unlocked musical tracks.
pythonw 2016-07-04 19-44-38-94.png
The extra menu.
pythonw 2016-07-04 19-44-44-56.png
What the gallery looks like for now.
The issue is found in the Gallery section. Toggling the different buttons to display their (for now, unexisting) contents works fine, but if I leave the extra menu to either go to the load/save or settings menu or return to the main menu, the five character buttons remain displayed.
pythonw 2016-07-04 19-44-59-22.png
The glitch.
Here is the code for the Extra menu I put together in screens.rpy (the different variables are declared in a separate file I named init.rpy in the /game folder):

Code: Select all

screen extra:
    tag menu
    add "GUI/extra/bg_extra.png"
    
# TOP BUTTONS

#__________________________________________G A L L E R Y
    if show_gallery == False:

        imagebutton:
            idle "GUI/extra/gallery_idle.png"
            hover "GUI/extra/gallery_hover.png"
            xpos 522 ypos 50
            action If(show_gallery, true=(Hide("gallery")), false=(Show("gallery"))),ToggleVariable("show_gallery",true_value=True, false_value=False),SetVariable("show_lore",False),SetVariable("show_music",False)
            hover_sound "sounds/hover.ogg" activate_sound "sounds/click.ogg"

    if show_gallery == True:

        add "GUI/extra/cg_window.png" xpos 100 ypos 150
        imagebutton:
            idle "GUI/extra/gallery_selected_idle.png"
            hover "GUI/extra/gallery_selected_hover.png"
            xpos 522 ypos 50
            action If(show_gallery, true=(Hide("gallery")), false=(Show("gallery"))),ToggleVariable("show_gallery",true_value=True, false_value=False)
            hover_sound "sounds/hover.ogg" activate_sound "sounds/click.ogg"

#__________________________________________L O R E
    if show_lore == False:

        imagebutton:
            idle "GUI/extra/lore_idle.png"
            hover "GUI/extra/lore_hover.png"
            xpos 800 ypos 50
            action If(show_lore, true=(Hide("lore")), false=(Show("lore"))),ToggleVariable("show_lore",true_value=True, false_value=False),SetVariable("show_gallery",False),SetVariable("show_music",False)
            hover_sound "sounds/hover.ogg" activate_sound "sounds/click.ogg"
 
    if show_lore == True:

        imagebutton:
            idle "GUI/extra/lore_selected_idle.png"
            hover "GUI/extra/lore_selected_hover.png"
            xpos 800 ypos 50
            action If(show_lore, true=(Hide("lore")), false=(Show("lore"))),ToggleVariable("show_lore",true_value=True, false_value=False)
            hover_sound "sounds/hover.ogg" activate_sound "sounds/click.ogg"

#__________________________________________M U S I C
    if show_music == False:

        imagebutton:
            idle "GUI/extra/music_idle.png"
            hover "GUI/extra/music_hover.png"
            xpos 1078 ypos 50
            action If(show_music, true=(Hide("music")), false=(Show("music"))),ToggleVariable("show_music",true_value=True, false_value=False),SetVariable("show_gallery",False),SetVariable("show_lore",False)
            hover_sound "sounds/hover.ogg" activate_sound "sounds/click.ogg"

    if show_music == True:

        imagebutton:
            idle "GUI/extra/music_selected_idle.png"
            hover "GUI/extra/music_selected_hover.png"
            xpos 1078 ypos 50
            action If(show_music, true=(Hide("music")), false=(Show("music"))),ToggleVariable("show_music",true_value=True, false_value=False)
            hover_sound "sounds/hover.ogg" activate_sound "sounds/click.ogg"

    use navigation

#CHARACTER CG BUTTONS

screen gallery:
    tag page

#__________________________________________C O M M O N
    if show_common == False:

        imagebutton:
            idle "GUI/extra/cg_common_idle.png"
            hover "GUI/extra/cg_common_hover.png"
            xpos 100 ypos 150
            action ToggleVariable("show_common",true_value=True, false_value=False),SetVariable("show_blaze",False),SetVariable("show_mizuha",False),SetVariable("show_yuuki",False),SetVariable("show_sinclair",False)
            hover_sound "sounds/hover.ogg" activate_sound "sounds/click.ogg"

    if show_common == True:

        imagebutton:
            idle "GUI/extra/cg_common_selected_idle.png"
            hover "GUI/extra/cg_common_selected_hover.png"
            xpos 100 ypos 150
            action ToggleVariable("show_common",true_value=True, false_value=False)
            hover_sound "sounds/hover.ogg" activate_sound "sounds/click.ogg"

#__________________________________________B L A Z E
    if show_blaze == False:

        imagebutton:
            idle "GUI/extra/cg_blaze_idle.png"
            hover "GUI/extra/cg_blaze_hover.png"
            xpos 319 ypos 150
            action ToggleVariable("show_blaze",true_value=True, false_value=False),SetVariable("show_common",False),SetVariable("show_mizuha",False),SetVariable("show_yuuki",False),SetVariable("show_sinclair",False)
            hover_sound "sounds/hover.ogg" activate_sound "sounds/click.ogg"

    if show_blaze == True:

        imagebutton:
            idle "GUI/extra/cg_blaze_selected_idle.png"
            hover "GUI/extra/cg_blaze_selected_hover.png"
            xpos 319 ypos 150
            action ToggleVariable("show_blaze",true_value=True, false_value=False)
            hover_sound "sounds/hover.ogg" activate_sound "sounds/click.ogg"

#__________________________________________M I Z U H A
    if show_mizuha == False:

        imagebutton:
            idle "GUI/extra/cg_mizuha_idle.png"
            hover "GUI/extra/cg_mizuha_hover.png"
            xpos 538 ypos 150
            action ToggleVariable("show_mizuha",true_value=True, false_value=False),SetVariable("show_common",False),SetVariable("show_blaze",False),SetVariable("show_yuuki",False),SetVariable("show_sinclair",False)
            hover_sound "sounds/hover.ogg" activate_sound "sounds/click.ogg"

    if show_mizuha == True:

        imagebutton:
            idle "GUI/extra/cg_mizuha_selected_idle.png"
            hover "GUI/extra/cg_mizuha_selected_hover.png"
            xpos 538 ypos 150
            action ToggleVariable("show_mizuha",true_value=True, false_value=False)
            hover_sound "sounds/hover.ogg" activate_sound "sounds/click.ogg"

#__________________________________________Y U U K I
    if show_yuuki == False:

        imagebutton:
            idle "GUI/extra/cg_yuuki_idle.png"
            hover "GUI/extra/cg_yuuki_hover.png"
            xpos 757 ypos 150
            action ToggleVariable("show_yuuki",true_value=True, false_value=False),SetVariable("show_common",False),SetVariable("show_blaze",False),SetVariable("show_mizuha",False),SetVariable("show_sinclair",False)
            hover_sound "sounds/hover.ogg" activate_sound "sounds/click.ogg"

    if show_yuuki == True:
  
        imagebutton:
            idle "GUI/extra/cg_yuuki_selected_idle.png"
            hover "GUI/extra/cg_yuuki_selected_hover.png"
            xpos 757 ypos 150
            action ToggleVariable("show_yuuki",true_value=True, false_value=False)
            hover_sound "sounds/hover.ogg" activate_sound "sounds/click.ogg"

#__________________________________________S I N C L A I R
    if show_sinclair == False:

        imagebutton:
            idle "GUI/extra/cg_sinclair_idle.png"
            hover "GUI/extra/cg_sinclair_hover.png"
            xpos 976 ypos 150
            action ToggleVariable("show_sinclair",true_value=True, false_value=False),SetVariable("show_common",False),SetVariable("show_blaze",False),SetVariable("show_mizuha",False),SetVariable("show_yuuki",False)
            hover_sound "sounds/hover.ogg" activate_sound "sounds/click.ogg"

    if show_sinclair == True:

        imagebutton:
            idle "GUI/extra/cg_sinclair_selected_idle.png"
            hover "GUI/extra/cg_sinclair_selected_hover.png"
            xpos 976 ypos 150
            action ToggleVariable("show_sinclair",true_value=True, false_value=False)
            hover_sound "sounds/hover.ogg" activate_sound "sounds/click.ogg"

screen common:
    tag page

screen blaze:
    tag page

screen mizuha:
    tag page

screen yuuki:
    tag page

screen sinclair:
    tag page

screen lore:
    tag page

screen music:
    tag page
Why don't those five buttons disappear when I switch to a different menu, and yet the three top buttons from the extra menu do? I found that toggling "Gallery" off before switching to another menu sort of fixes the issue, but it would be much better to hide the buttons whenever the player leaves the extra menu.

Thanks in advance for any replies, and of course, you have my permission to bash me on the side of the head hard if the source of the problem is an obvious one. :lol:
Last edited by Quinn-G on Tue Jul 05, 2016 3:14 am, edited 1 time in total.

User avatar
namastaii
Eileen-Class Veteran
Posts: 1348
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Extra menu buttons glitch

#2 Post by namastaii » Mon Jul 04, 2016 2:55 pm

I could be wrong because I just skimmed over your code but I'm guessing you're going to need to reset those variables back to false. The ones that show them in the first place. With the button(s) you use to 'exit' that part, you need to set those variables to false because they are only showing because the variable is true right? Or are those the actual CG pictures that have those variables? I'm not exactly sure how to read your code XD

what brings up those buttons in the first place? are they their own screen or do they show up under a conditional? If they show up from a different screen, when exiting that screen you're going to need to hide it.

User avatar
Quinn-G
Newbie
Posts: 11
Joined: Mon Jul 04, 2016 1:40 pm
Projects: Blazing Skies
Deviantart: Quinn-G
Contact:

Re: Extra menu buttons glitch

#3 Post by Quinn-G » Mon Jul 04, 2016 4:18 pm

namastaii wrote:I could be wrong because I just skimmed over your code but I'm guessing you're going to need to reset those variables back to false. The ones that show them in the first place. With the button(s) you use to 'exit' that part, you need to set those variables to false because they are only showing because the variable is true right? Or are those the actual CG pictures that have those variables? I'm not exactly sure how to read your code XD

what brings up those buttons in the first place? are they their own screen or do they show up under a conditional? If they show up from a different screen, when exiting that screen you're going to need to hide it.
Whoa, fast reply! :D There are no CGs or character-specific galleries to speak of yet, so that's not what's causing the issue. And I haven't the slightest clue what a conditional is, so I doubt I used that. XD

However, I think I sort of see what you're getting at with resetting the variables to False. There must be something in my code that causes Ren'Py to think these variables are still set to True when the player leaves the extra menu.

If it helps, this is what the init.rpy file I mentioned contains:

Code: Select all

init -5 python:
    show_gallery = False
    show_lore = False
    show_music = False
    show_common = False
    show_blaze = False
    show_mizuha = False
    show_yuuki = False
    show_sinclair = False
Perhaps it should also be in screens.rpy and not in a separate file?

User avatar
namastaii
Eileen-Class Veteran
Posts: 1348
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Extra menu buttons glitch

#4 Post by namastaii » Mon Jul 04, 2016 4:43 pm

Okay let me start over so I can understand better XD

these buttons are under the gallery. When you clicked the gallery button, it turns show_gallery to true right? If so, then you just need to have your other buttons (that exit from the gallery screen) also take on an action that does show_gallery=False.

I'm pretty sure that variable is just still true. The init where you define them is just the first time around. they just need to be told over and over that they are true and false etc. If this is the problem, all it takes is some debugging and figuring out where to tell it to turn to false again and such.

maybe when you click on settings, you add show_gallery=False, etc

User avatar
Quinn-G
Newbie
Posts: 11
Joined: Mon Jul 04, 2016 1:40 pm
Projects: Blazing Skies
Deviantart: Quinn-G
Contact:

Re: Extra menu buttons glitch

#5 Post by Quinn-G » Mon Jul 04, 2016 6:48 pm

Eureka! =D

Following your advice, I fought a little with my navigation menu code:

Code: Select all

screen navigation:
    imagebutton:
        auto "GUI/main_%s.png"
        hover_sound "sounds/hover.ogg"
        xpos 850 ypos 740 focus_mask True
        action MainMenu()

    imagebutton:
        auto "GUI/save_%s.png"
        hover_sound "sounds/hover.ogg" activate_sound "sounds/click.ogg"
        xpos 574 ypos 740 focus_mask True
        action ShowMenu('save')
    imagebutton:
        auto "GUI/load_%s.png"
        hover_sound "sounds/hover.ogg" activate_sound "sounds/click.ogg"
        xpos 574 ypos 840 focus_mask True 
        action ShowMenu('load')

    imagebutton:
        auto "GUI/settings_%s.png"
        hover_sound "sounds/hover.ogg" activate_sound "sounds/click.ogg"
        xpos 1025 ypos 740 focus_mask True
        action ShowMenu('settings')

    imagebutton:
        auto "GUI/extra_%s.png"
        hover_sound "sounds/hover.ogg" activate_sound "sounds/click.ogg"
        xpos 1025 ypos 840 focus_mask True
        action ShowMenu('extra')

    imagebutton:
        auto "GUI/return_%s.png"
        hover_sound "sounds/hover.ogg" activate_sound "sounds/return.ogg"
        xpos 800 ypos 940 focus_mask True
        action Return()
...added this line of code at the end of each action (except for the main menu imagebutton, since it's not necessary):

Code: Select all

, If(show_gallery, true=(SetVariable("show_gallery", False))),Hide("gallery"), If(show_lore, true=(SetVariable("show_lore", False))),Hide("lore"), If(show_music, true=(SetVariable("show_music", False))),Hide("music")
...and ended up with this:

Code: Select all

screen navigation:
    imagebutton:
        auto "GUI/main_%s.png"
        hover_sound "sounds/hover.ogg"
        xpos 850 ypos 740 focus_mask True
        action MainMenu()

    imagebutton:
        auto "GUI/save_%s.png"
        hover_sound "sounds/hover.ogg" activate_sound "sounds/click.ogg"
        xpos 574 ypos 740 focus_mask True
        action ShowMenu('save'), If(show_gallery, true=(SetVariable("show_gallery", False))),Hide("gallery"), If(show_lore, true=(SetVariable("show_lore", False))),Hide("lore"), If(show_music, true=(SetVariable("show_music", False))),Hide("music")

    imagebutton:
        auto "GUI/load_%s.png"
        hover_sound "sounds/hover.ogg" activate_sound "sounds/click.ogg"
        xpos 574 ypos 840 focus_mask True 
        action ShowMenu('load'), If(show_gallery, true=(SetVariable("show_gallery", False))),Hide("gallery"), If(show_lore, true=(SetVariable("show_lore", False))),Hide("lore"), If(show_music, true=(SetVariable("show_music", False))),Hide("music")

    imagebutton:
        auto "GUI/settings_%s.png"
        hover_sound "sounds/hover.ogg" activate_sound "sounds/click.ogg"
        xpos 1025 ypos 740 focus_mask True
        action ShowMenu('settings'), If(show_gallery, true=(SetVariable("show_gallery", False))),Hide("gallery"), If(show_lore, true=(SetVariable("show_lore", False))),Hide("lore"), If(show_music, true=(SetVariable("show_music", False))),Hide("music")

    imagebutton:
        auto "GUI/extra_%s.png"
        hover_sound "sounds/hover.ogg" activate_sound "sounds/click.ogg"
        xpos 1025 ypos 840 focus_mask True
        action ShowMenu('extra'), If(show_gallery, true=(SetVariable("show_gallery", False))),Hide("gallery"), If(show_lore, true=(SetVariable("show_lore", False))),Hide("lore"), If(show_music, true=(SetVariable("show_music", False))),Hide("music")

    imagebutton:
        auto "GUI/return_%s.png"
        hover_sound "sounds/hover.ogg" activate_sound "sounds/return.ogg"
        xpos 800 ypos 940 focus_mask True
        action Return(), If(show_gallery, true=(SetVariable("show_gallery", False))),Hide("gallery"), If(show_lore, true=(SetVariable("show_lore", False))),Hide("lore"), If(show_music, true=(SetVariable("show_music", False))),Hide("music")
The buttons now disappear! =D https://youtu.be/VbxgYlcNxE8?t=13m58s

Your little tip gave me a little nudge in the right direction and it made all the difference! =D I'll be sure to put your name in the end credits. ^^

Thanks a lot and good night ! (it's 0:48 here in Belgium :P)

User avatar
namastaii
Eileen-Class Veteran
Posts: 1348
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Extra menu buttons glitch

#6 Post by namastaii » Mon Jul 04, 2016 7:38 pm

Sweet I'm glad to help :)

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], hell_oh_world