Page 1 of 1

Letting player show or hide quick menu in preferences. [Solved]

Posted: Sat Mar 30, 2019 1:41 pm
by sheetcakeghost
So I'm having trouble making this code work as needed.

Code: Select all

vbox:
                    style_prefix "check"
                    label _("Quick Menu")
                    textbutton _("Show") action Show("quick_menu")
                    textbutton _("Hide") action Hide("quick_menu")
From how I understand renpy (which is not very much) putting those options in should allow the player to click on either show or hide to do just that, show or hide. However it is not doing this at all. Clicking them, as far as I can tell, performs no function. In fact, when I put those options in it just hides the quick menu and never shows it.

To fix that I had to add "default show_quick_menu = True" at the beginning of my script which does show the quick menu, but then it never hides without me using "$ quick_menu = False" which is, I imagine, working as intended with "default show".

I have tried another method which also does not work for me.

Code: Select all

vbox:
                    style_prefix "check"
                    label _("Quick Menu")
                    textbutton _("Show") action Show("quickmenushow")
                    textbutton _("Hide") action Show("quickmenuhide")
Where I made custom screens which contained only one line.

Code: Select all

screen quickmenushow:
    $ quick_menu = True

screen quickmenuhide:
    $ quick_menu = False
I also tried the "show_quick_menu = Blah" variant of the code from the older renpy.

Now, this thread viewtopic.php?t=26263 talks about what I want to do, but "make it 2 buttons inside a screen with a conditional branch" confuses me a bit. I think that's what I was doing with my second failed solution? But I'm not sure.

If someone could help me out I would appreciate it. I'm sure this is a very simple thing to do, but my google-fu really failed me on finding out how to do it.

Edit: Also, yes, my quick menu does have the "if quick_menu" statement which is why I thought the Show Hide buttons would work in the first place.

Re: Letting player show or hide quick menu in preferences.

Posted: Sat Mar 30, 2019 3:13 pm
by xavimat
Renpy already has a variable to control if the quickmenu is visible or not. It's called "quick_menu" and is already "defaulted" in screens.rpy (line 271).
You only need to change that variable. You can toggle it with one button (style check) or use two buttons: On/Off (style radio)

Code: Select all

vbox:
    style_prefix "check"
    label _("Quick Menu")
    textbutton _("Show Quick Menu") action ToggleVariable("quick_menu", True, False)

Code: Select all

vbox:
    style_prefix "radio"
    label _("Quick Menu")
    textbutton _("Show") action SetVariable("quick_menu", True)
    textbutton _("Hide") action SetVariable("quick_menu", False)

Two comments to your code:
1.Show() and Hide() are used to actually show or hide a screen, in your case, putting these options in the preferences had no meaning.
2. Screens shouldn't have side effects (like assigning values to global variables) because they are predicted many times and those codes are executed on prediction.

Re: Letting player show or hide quick menu in preferences.

Posted: Sat Mar 30, 2019 5:58 pm
by sheetcakeghost
Oh! Thank you for giving me two options to pick from with one button or two. That'll be very nice for anyone else who finds my topic looking for a similar solution.

The second one was exactly what I was hoping to achieve, and thank you for the explanation too. I have a better understanding of the Show and Hide command now. I also didn't even consider looking for a quickmenu = true variable in the screen.rpy file itself, and I should have. d: That's on me.