How do I make a button that opens up the quick menu?

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
DeletedUser160413

How do I make a button that opens up the quick menu?

#1 Post by DeletedUser160413 »

I would like to have a button on the top-right of the game screen that basically works like a drop box and shows all the options like save and quick load etc. The hotspot for the button is (654, 126, 107, 40) on a 600x800 resolution screen. In the beginning I want only the button to be visible but when you click it, it will show the other options (just like a menu with submenus). Also I want it to be hidden whenever the "submenu" is up and visible when the submenu is hidden.

Example:

Image

Kinsman
Regular
Posts: 130
Joined: Sun Jul 26, 2009 7:07 pm
Location: Fredericton, NB, Canada
Contact:

Re: How do I make a button that opens up the quick menu?

#2 Post by Kinsman »

The best way to do it is to use two screens: one for the button, and one for the menu. Clicking on the button would hide itself and show the menu; clicking on a menu selection would hide itself and show the button, along with whatever other function the menu did.

When setting the 'action' field of a button in the screen code, you can set multiple actions using an array.
(i.e. action [Hide("this"),Show("that")] )
Flash To Ren'Py Exporter
See the Cookbook thread

Crazy Li
Regular
Posts: 113
Joined: Fri Jan 03, 2014 3:35 pm
Contact:

Re: How do I make a button that opens up the quick menu?

#3 Post by Crazy Li »

In Ren'py, "quick menu" normally refers to the options that are on the text box in-game that you can click any time dialog is being displayed. This sounds more like you want something akin to the navigational menu to appear. What you could do is in screens.rpy, copy your Navigation menu as a basis, but rename it to something else and fiddle with the options and position of it to suit your needs. Then the button itself would have: action ShowMenu("yourmenu")

You can also use a hide on the button as well as Kinsman said. Of course, also as said, the button probably needs to be its own screen if hidden. The other alternative is to make the menu literally cover the button when called so that you just can't see it for that reason.

A third option, if you don't mind the menu/button being hidden when other menus are called is to tag them both as menu so the button automatically goes away when this (or any other) menu is called.

DeletedUser160413

Re: How do I make a button that opens up the quick menu?

#4 Post by DeletedUser160413 »

Crazy Li wrote:In Ren'py, "quick menu" normally refers to the options that are on the text box in-game that you can click any time dialog is being displayed. This sounds more like you want something akin to the navigational menu to appear. What you could do is in screens.rpy, copy your Navigation menu as a basis, but rename it to something else and fiddle with the options and position of it to suit your needs. Then the button itself would have: action ShowMenu("yourmenu")

You can also use a hide on the button as well as Kinsman said. Of course, also as said, the button probably needs to be its own screen if hidden. The other alternative is to make the menu literally cover the button when called so that you just can't see it for that reason.

A third option, if you don't mind the menu/button being hidden when other menus are called is to tag them both as menu so the button automatically goes away when this (or any other) menu is called.
Thank you both so much for all the information! Unfortunately I'm not doing any progress on this :( Will you please take a look at my code?

Code: Select all

##############################################################################
# Quick Menu

screen options:

    # The background of the game menu.
    window:
        style "gm_root"

    # The various buttons.
    vbox:
        xpos 550
        ypos 150
        spacing 0

        imagebutton auto "ui/load_%s.png" action ShowMenu("options")

    
#
# A screen that's included by the default say screen, and adds quick access to
# several useful functions.
screen quick_menu:
    

    # Add an in-game quick menu.
    hbox:
        style_group "quick_menu"
         background None
         xpadding 0
         ypadding 0
    
        imagemap:
            ground "ui/optionsground.png"
            idle "ui/optionsground.png"
            hover "ui/optionsidle.png"
            selected_idle "ui/optionshover.png"
            
            #hotspot (737, 5, 63, 62)
                
            hotspot (654, 103, 107, 40) action ShowMenu('save')
            hotspot (654, 144, 107, 40) action [ShowMenu("load")]
            hotspot (654, 191, 107, 40) action Skip()
            hotspot (654, 239, 107, 40) action Preference("auto-forward", "toggle")
            hotspot (654, 281, 107, 40) action ShowMenu('preferences')
            #hotspot (654, 126, 107, 40) action 

        
init -2 python:
    style.file_picker_frame = Style(style.menu_frame)

    style.file_picker_nav_button = Style(style.small_button)
    style.file_picker_nav_button_text = Style(style.small_button_text)

    style.file_picker_button = Style(style.large_button)
    style.file_picker_text = Style(style.large_button_text)
    config.thumbnail_width = 350
    config.thumbnail_height = 250
    
    style.gm_nav_button.size_group = "gm_nav"

    
    # Set a default value for the auto-forward time, and note that AFM is
    # turned off by default.
    config.default_afm_time = 10
    config.default_afm_enable = False

Crazy Li
Regular
Posts: 113
Joined: Fri Jan 03, 2014 3:35 pm
Contact:

Re: How do I make a button that opens up the quick menu?

#5 Post by Crazy Li »

I can look at your code, but it would help if you actually told us what the problem was so I can know what to look for.

Is it just not showing when you click the button?

Just making wild guesses, here are some problems I see:

1. Your quick menu isn't tagged as a menu. If you don't want it to function as one, that's fine. Just letting you know.
2. The quick menu by default is supposed to show on the say window. If you're re-purposing it, you may want to make sure your Say window doesn't use quick_menu or that will make it always show when there's dialog.
3. Your options screen is showing itself. There's no way "quick_menu" will ever show with that code. Try

Code: Select all

action ShowMenu("quick_menu")
assuming that is the screen you want to pop up on click.

DeletedUser160413

Re: How do I make a button that opens up the quick menu?

#6 Post by DeletedUser160413 »

Crazy Li wrote:I can look at your code, but it would help if you actually told us what the problem was so I can know what to look for.

Is it just not showing when you click the button?

Just making wild guesses, here are some problems I see:

1. Your quick menu isn't tagged as a menu. If you don't want it to function as one, that's fine. Just letting you know.
2. The quick menu by default is supposed to show on the say window. If you're re-purposing it, you may want to make sure your Say window doesn't use quick_menu or that will make it always show when there's dialog.
3. Your options screen is showing itself. There's no way "quick_menu" will ever show with that code. Try

Code: Select all

action ShowMenu("quick_menu")
assuming that is the screen you want to pop up on click.
Well the problems are basically that options isn't clickable and that quick menu is showing. I don't know what to do with this code or how to turn things around...

1. How do I tag it as menu? I'm so sorry for all my questions, it's just that I'm new to this but I'm doing my best to learn everything I have to know.

2. This must be the say window right:

Code: Select all

    # The background of the game menu.
    window:
What exactly am I supposed to write there? When I look it up online I only find style "gm_root"

3. Yes, I changed it to quick_menu. Thank you. But right now the quick menu is still visible. Do I have to change the imagemaps around or are they correct?

Thank you so much for everything!

Crazy Li
Regular
Posts: 113
Joined: Fri Jan 03, 2014 3:35 pm
Contact:

Re: How do I make a button that opens up the quick menu?

#7 Post by Crazy Li »

muniiam wrote:
Crazy Li wrote:I can look at your code, but it would help if you actually told us what the problem was so I can know what to look for.

Is it just not showing when you click the button?

Just making wild guesses, here are some problems I see:

1. Your quick menu isn't tagged as a menu. If you don't want it to function as one, that's fine. Just letting you know.
2. The quick menu by default is supposed to show on the say window. If you're re-purposing it, you may want to make sure your Say window doesn't use quick_menu or that will make it always show when there's dialog.
3. Your options screen is showing itself. There's no way "quick_menu" will ever show with that code. Try

Code: Select all

action ShowMenu("quick_menu")
assuming that is the screen you want to pop up on click.
Well the problems are basically that options isn't clickable and that quick menu is showing. I don't know what to do with this code or how to turn things around...

1. How do I tag it as menu? I'm so sorry for all my questions, it's just that I'm new to this but I'm doing my best to learn everything I have to know.

2. This must be the say window right:

Code: Select all

    # The background of the game menu.
    window:
What exactly am I supposed to write there? When I look it up online I only find style "gm_root"

3. Yes, I changed it to quick_menu. Thank you. But right now the quick menu is still visible. Do I have to change the imagemaps around or are they correct?

Thank you so much for everything!
To tag a screen as a menu, add:

Code: Select all

tag menu
You can look at other screens (like preferences for example) to see how it's used already.

The Say window is a screen that is VERY clearly marked in the original screens.rpy.

Code: Select all

##############################################################################
# Say
#
# Screen that's used to display adv-mode dialogue.
# http://www.renpy.org/doc/html/screen_special.html#say
screen say:

    # Defaults for side_image and two_window
    default side_image = None
    default two_window = True

    # Decide if we want to use the one-window or two-window varaint.
    if not two_window:

        # The one window variant.        
        window:
            id "window"

            has vbox:
                style "say_vbox"

            if who:
                text who id "who"

            text what id "what"

    else:

        # The two window variant.
        vbox:
            style "say_two_window_vbox"

            if who:            
                window:
                    style "say_who_window"

                    text who:
                        id "who"
                        
            window:
                id "window"

                has vbox:
                    style "say_vbox"

                text what id "what"
              
    # If there's a side image, display it above the text.
    if side_image:
        add side_image
    else:
        add SideImage() xalign 0.0 yalign 1.0

    # Use the quick menu.
    use quick_menu
See that last line there? "use quick_menu" comment that out.

DeletedUser160413

Re: How do I make a button that opens up the quick menu?

#8 Post by DeletedUser160413 »

Yes, I did everything you just mentioned! You know what, after doing this for a couple of hours I just feel like giving up because its literally not working at all... Right now the button that I want to be clickable is not showing and neither is the quick menu. I don't know what to do :x I've looked through almost every quick menu question here on lemmasoft and the tutorials and founnd nothing that can help me with my problem...

Crazy Li
Regular
Posts: 113
Joined: Fri Jan 03, 2014 3:35 pm
Contact:

Re: How do I make a button that opens up the quick menu?

#9 Post by Crazy Li »

You never said the button itself wasn't showing. You need to code it to display on the screen in some fashion. There are a number of ways you can do this, but one of the easier ways might be to add

Code: Select all

use options
to the end of that Say window code I mentioned last post and that should tell the game to at least have it show any time there's dialog. If you need it to show in other cases as well, you're going to need a different (or just additional ways) to force it to display.

Things don't magically just show up on their own, though. You need to tell the game what to do in order for it to actually do it.

EDIT: and if it still doesn't show up after doing what I said, you should double-check to make sure wherever you're positioning it is actually a spot that's on screen. xpos and ypos don't use pixels. They range from 0 to 1 with 0 being the left/top of the screen and 1 being the bottom/right. It might be best to use something like xpos 1, ypos 0 to start with and adjust from there.

I don't want to sound mean, but it's only not working because you're not doing it right. This could probably be fixed sooner if I just entirely re-wrote your code for you and gave that to you (which is probably what most people do to answer questions), but my style is usually just to tell people how stuff works as a teaching method so they can learn how and why rather than just copying and pasting without any real understanding of what the fix was.

If you want me to just throw working code at you instead, let me know.

DeletedUser160413

Re: How do I make a button that opens up the quick menu?

#10 Post by DeletedUser160413 »

Crazy Li wrote:You never said the button itself wasn't showing. You need to code it to display on the screen in some fashion. There are a number of ways you can do this, but one of the easier ways might be to add

Code: Select all

use options
to the end of that Say window code I mentioned last post and that should tell the game to at least have it show any time there's dialog. If you need it to show in other cases as well, you're going to need a different (or just additional ways) to force it to display.

Things don't magically just show up on their own, though. You need to tell the game what to do in order for it to actually do it.

EDIT: and if it still doesn't show up after doing what I said, you should double-check to make sure wherever you're positioning it is actually a spot that's on screen. xpos and ypos don't use pixels. They range from 0 to 1 with 0 being the left/top of the screen and 1 being the bottom/right. It might be best to use something like xpos 1, ypos 0 to start with and adjust from there.

I don't want to sound mean, but it's only not working because you're not doing it right. This could probably be fixed sooner if I just entirely re-wrote your code for you and gave that to you (which is probably what most people do to answer questions), but my style is usually just to tell people how stuff works as a teaching method so they can learn how and why rather than just copying and pasting without any real understanding of what the fix was.

If you want me to just throw working code at you instead, let me know.

Yaaaaaay I finally made it work :D In the Nvl window there was the same code as there was in the say window so I changed that code to options. I also had to tweak the code for the options screen. Thank you so much for everything!!! :'DDD
Last edited by DeletedUser160413 on Sun Jan 19, 2014 2:43 pm, edited 1 time in total.

Crazy Li
Regular
Posts: 113
Joined: Fri Jan 03, 2014 3:35 pm
Contact:

Re: How do I make a button that opens up the quick menu?

#11 Post by Crazy Li »

Oh yeah... I keep forgetting that the NVL window also tries to include the quick menu. I already disabled that in my project because I re-positioned the quick menu to the top of the text box (like most VN's I've seen do), so it looks stupid now while in NVL mode.

Post Reply

Who is online

Users browsing this forum: BBN_VN, Bing [Bot], decocloud, Google [Bot]