Page 1 of 1

Menu behavior... Multiple nav buttons showing selected?

Posted: Fri May 09, 2014 8:22 am
by saguaro
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)

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

Posted: Fri May 09, 2014 8:44 am
by Asceai
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.

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

Posted: Fri May 09, 2014 4:13 pm
by saguaro
Okay, I get it now. Thanks for the explanation, that is useful to know. (And thank you for the kind words, I appreciate it.)