Menu behavior... Multiple nav buttons showing selected?

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
saguaro
Miko-Class Veteran
Posts: 555
Joined: Sun Feb 12, 2012 9:17 am
Completed: Locked-In, Sunrise, The Censor
Projects: ?
Organization: Lucky Special Games
Tumblr: saguarofoo
itch: saguarofoo
Location: USA
Contact:

Menu behavior... Multiple nav buttons showing selected?

#1 Post by saguaro » Fri May 09, 2014 8:22 am

I was able to set up my game menus so that if the player clicks from load > save, or save < load, a dissolve transition is used, otherwise a slide transition is used.

But I noticed something a little weird about the selected menu button behavior. For it to work, I have to have a set variables action for all buttons, and each jump_to string must be different. If I set both scenes and prefs as "other," for example, both buttons will show selected until I click save or load.
screenshot0022.png
The jump_to variable is only used to toggle between frames on the save/load screens. So I have no idea why I need to use different strings under scenes and prefs because they are never referenced, but I do.

As I said, this menu works with the navigation code below but I was hoping someone might be able to explain the behavior? I'm a little rusty but this doesn't make sense to me.

Code: Select all

    frame:
        background Frame("images/textbox.png",5,5)
        style_group "mmenu"
        xalign 0.5
        at drop_down
        hbox:       
            spacing 75
            null width 50
            if not current_screen=="mm":
                textbutton ("Return") action [SetVariable("jump_to","ret"), Return()]
            else:
                textbutton ("Start ") action [SetVariable("jump_to","start"), Start()]
            #if main_menu:
            textbutton ("Scenes") action [SetVariable("jump_to", "scenes"), ShowMenu("scenes")]       
            textbutton ("Options") action [SetVariable("jump_to", "prefs"), ShowMenu("preferences")]
            if not main_menu: 
                if current_screen == "load" or current_screen == "save":
                    textbutton ("Save") action [SetVariable("jump_to","save"), ShowMenu("save")] 
                else:    
                    textbutton ("Save") action [SetVariable("jump_to", "save"), ShowMenu("save")]
            if main_menu:
                textbutton ("Load") action [SetVariable("jump_to", "load2"), ShowMenu("load")]
            else:
                if current_screen == "load" or current_screen == "save":
                    textbutton ("Load") action [SetVariable("jump_to","load"), ShowMenu("load")]            
                else:                
                    textbutton ("Load") action [SetVariable("jump_to", "load"), ShowMenu("load")]
            if not main_menu:
                textbutton ("Main") action MainMenu()   
            textbutton ("Quit") action Quit(confirm=True)

User avatar
Asceai
Eileen-Class Veteran
Posts: 1258
Joined: Fri Sep 21, 2007 7:13 am
Projects: a battle engine
Contact:

Re: Menu behavior... Multiple nav buttons showing selected?

#2 Post by Asceai » Fri May 09, 2014 8:44 am

Basically, a button is selected if its action returns that it is selected. If a list is supplied as an action, if any of the actions in it register as selected, the action counts as selected. This is something every action has a different way of determining, and it's the same with the 'insensitive' state (except, I believe, _every_ action has to return insensitive for a button to be marked insensitive)

In the case of SetVariable("x", y), that action is selected if "x" is already equal to y, so you've sort of got a hackish way of ensuring that a particular button is registered as 'selected' under given circumstances.
I give more information in this post.

You can create your own action class if you want absolute control over the selected and insensitive states. More information on doing that is available here. Otherwise, with some knowledge now of what makes a button selected might be enough to allow you to get the outcome you want with the predefined actions.

EDIT: Also that is a beautiful preferences screen.

User avatar
saguaro
Miko-Class Veteran
Posts: 555
Joined: Sun Feb 12, 2012 9:17 am
Completed: Locked-In, Sunrise, The Censor
Projects: ?
Organization: Lucky Special Games
Tumblr: saguarofoo
itch: saguarofoo
Location: USA
Contact:

Re: Menu behavior... Multiple nav buttons showing selected?

#3 Post by saguaro » Fri May 09, 2014 4:13 pm

Okay, I get it now. Thanks for the explanation, that is useful to know. (And thank you for the kind words, I appreciate it.)

Post Reply

Who is online

Users browsing this forum: No registered users