How can I make the quick-menu remain visible while hovered?

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
Chococo
Newbie
Posts: 5
Joined: Sun Aug 04, 2019 3:49 pm
Contact:

How can I make the quick-menu remain visible while hovered?

#1 Post by Chococo »

Hi everyone.

I have a quick menu which appears when the mouse hovers over the bottom section of the screen and disappears when the mouse exits this area. The code is as follows:

mousearea:
area (0,450, 640, 30)
hovered Show("quick_menu")
unhovered Hide("quick_menu")


This works great, however, when any of the QMenu buttons are clicked, the menu instantly hides itself again. This gets annoying when I want to press 'back' multiple times.

How can I have the menu disappear only when the mouse leaves the area, and not when a button is clicked?

Any suggestion will be greatly appreciated.

User avatar
Amethysts
Regular
Posts: 41
Joined: Thu Aug 23, 2018 1:17 pm
Projects: Coalescence
Skype: amethysts-studio
itch: amethysts
Contact:

Re: How can I make the quick-menu remain visible while hovered?

#2 Post by Amethysts »

In your menu screen write this:

Code: Select all

screen your_menu:
  zorder 120
The number will decide on which height will be your screen ! Do it everytime you have several screens displayed :) Games are often like an onion, with a lot of layers, so you have to do it quite often :)

User avatar
Chococo
Newbie
Posts: 5
Joined: Sun Aug 04, 2019 3:49 pm
Contact:

Re: How can I make the quick-menu remain visible while hovered?

#3 Post by Chococo »

This is a really nice addition, though it doesn't stop the quick menu from hiding when 'back' is clicked.

User avatar
hell_oh_world
Miko-Class Veteran
Posts: 777
Joined: Fri Jul 12, 2019 5:21 am
Contact:

Re: How can I make the quick-menu remain visible while hovered?

#4 Post by hell_oh_world »

Chococo wrote: Sun Aug 18, 2019 8:46 am This is a really nice addition, though it doesn't stop the quick menu from hiding when 'back' is clicked.

The "back" you are referring to is a button right?

Maybe I have a better workaround. You'll gonna do all of this inside the quick_menu screen in screens.rpy.

Create a local variable first inside the quick_menu screen

Code: Select all

screen quick_menu:
    default quick_menu_is_visible = False
Then still inside on the quick_menu screen, create a mousearea

Code: Select all

mousearea:
    anchor (0.5, 1.0)
    pos (0.5, 1.0) # Aligns the mousearea right to the bottom where the default quick menu is positioned
    xfill True # Makes the mousearea's width the width of the entire screen
    ysize 100 # Height of the mousearea
    hovered SetScreenVariable("quick_menu_is_visible", True)
    unhovered SetScreenVariable("quick_menu_is_visible", False)
    
Then on the quick_menu itself use a showif statement. Note: Quick Menu is positioned horizontally so I assumed there's an hbox on the screen:

Code: Select all

showif quick_menu_is_visible:
    hbox:
        // The quick menu buttons go here
Hope this helps.

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
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: How can I make the quick-menu remain visible while hovered?

#5 Post by namastaii »

You should probably have it set up like this (obviously put whatever area numbers you need, this was just for my testing purposes)

Code: Select all

screen quick_menu():

    ## Ensure this appears on top of other screens.
    zorder 100

    mousearea:
        area (0,1000, 1000, 100)
        hovered SetVariable("quick_menu", True)
        unhovered SetVariable("quick_menu", False)

    if quick_menu:

        hbox:
            style_prefix "quick"

            xalign 0.5
            yalign 1.0

            textbutton _("Back") action Rollback()
            textbutton _("History") action ShowMenu('history')
            textbutton _("Skip") action Skip() alternate Skip(fast=True, confirm=True)
            textbutton _("Auto") action Preference("auto-forward", "toggle")
            textbutton _("Save") action ShowMenu('save')
            textbutton _("Q.Save") action QuickSave()
            textbutton _("Q.Load") action QuickLoad()
            textbutton _("Prefs") action ShowMenu('preferences')
and change this variable (found in screens):

Code: Select all

default quick_menu = False

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: How can I make the quick-menu remain visible while hovered?

#6 Post by Per K Grok »

Chococo wrote: Sun Aug 18, 2019 6:24 am
-----

This works great, however, when any of the QMenu buttons are clicked, the menu instantly hides itself again. This gets annoying when I want to press 'back' multiple times.

How can I have the menu disappear only when the mouse leaves the area, and not when a button is clicked?

Any suggestion will be greatly appreciated.

You will probably have to go a different way to solve this problem. Instead of a a mousearea, let's keep checking for the mouse pointers y position and use that to determine if the menu is shown. More of a brute force solution than a mousearea, but that might be what it takes to solve this problem. Mousarea only checks when you are entering or exiting the area, which usually is enough, but probably not for the particular problem you have here.

So in the screen quick_menu(), add this after the zorder line and replacing the 'if quick_menu:'-line

Code: Select all


    timer 0.1 action SetVariable("QM", renpy.get_mouse_pos()[1]) repeat True   # sets QM to the mouse y-pos every 0.1 second

    if QM>450:  


You also will need a default QM-line

Code: Select all


default QM = 0
You can place that where you have the style definitions after the screen.

User avatar
Chococo
Newbie
Posts: 5
Joined: Sun Aug 04, 2019 3:49 pm
Contact:

Re: How can I make the quick-menu remain visible while hovered?

#7 Post by Chococo »

I changed the mousearea statement from

Code: Select all

mousearea:
    area (0,450, 640, 30)
    hovered Show("quick_menu", transition=dissolve)
    unhovered Hide("quick_menu", transition=dissolve)
to

Code: Select all

mousearea:
    area (0,1000, 1000, 100)
    hovered SetVariable("quick_menu", True)
    unhovered SetVariable("quick_menu", False)
Which fixed the problem. However, this removes the dissolve transition.

Is there any way to trigger a transition for the hbox inside screen quick_menu(): ?

I tried defining the hbox as another screen, then calling it inside a 'Show' inside the [if quick_menu:], though that wouldn't work.

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
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: How can I make the quick-menu remain visible while hovered?

#8 Post by namastaii »

I asked someone on Discord and they showed me how they have theirs set up. They created a transform (which you could change the events inside to dissolve instead of this)

Code: Select all

transform quick_menu_appear:
    on show:
        alpha 0.0 yalign 1.1
        easein 1.0 alpha 1.0 yalign 1.0

    on hide:
        alpha 1.0 yalign 1.0
        easein 1.0 alpha 0.0 yalign 1.1
and then in the quick_menu screen

Code: Select all

screen quick_menu():
    mousearea:
        area (blah blah blah)
        hovered SetVariable("quick_menu", True)
        unhovered SetVariable("quick_menu", False)
    ## Ensure this appears on top of other screens.
    zorder 100

    showif quick_menu:
        hbox at quick_menu_appear:
            style_prefix "quick"

            xalign 0.5
            yalign 1.0

            textbutton _("Back") action Rollback()
            textbutton _("History") action ShowMenu('history')
            textbutton _("Skip") action Skip() alternate Skip(fast=True, confirm=True)
            textbutton _("Auto") action Preference("auto-forward", "toggle")
            textbutton _("Save") action ShowMenu('save')
            textbutton _("Q.Save") action QuickSave()
            textbutton _("Q.Load") action QuickLoad()
            textbutton _("Prefs") action ShowMenu('preferences')
the things changed were
showif quick_menu:
hbox at quick_menu_appear:

User avatar
hell_oh_world
Miko-Class Veteran
Posts: 777
Joined: Fri Jul 12, 2019 5:21 am
Contact:

Re: How can I make the quick-menu remain visible while hovered?

#9 Post by hell_oh_world »

Chococo wrote: Mon Aug 26, 2019 1:36 pm I changed the mousearea statement from

Code: Select all

mousearea:
    area (0,450, 640, 30)
    hovered Show("quick_menu", transition=dissolve)
    unhovered Hide("quick_menu", transition=dissolve)
to

Code: Select all

mousearea:
    area (0,1000, 1000, 100)
    hovered SetVariable("quick_menu", True)
    unhovered SetVariable("quick_menu", False)
Which fixed the problem. However, this removes the dissolve transition.

Is there any way to trigger a transition for the hbox inside screen quick_menu(): ?

I tried defining the hbox as another screen, then calling it inside a 'Show' inside the [if quick_menu:], though that wouldn't work.
You should add another action for the transition...

Code: Select all


mousearea:
    area (0,1000, 1000, 100)
    hovered [SetVariable("quick_menu", True), With(dissolve)]
    unhovered [SetVariable("quick_menu", False), With(dissolve)]
    

Post Reply

Who is online

Users browsing this forum: Ocelot