[Solved]modal True doesn't seem to make a difference

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
Imperf3kt
Lemma-Class Veteran
Posts: 3792
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

[Solved]modal True doesn't seem to make a difference

#1 Post by Imperf3kt »

I have a screen that layers over another screen. In this screen, I have places my navigation options, but I can still interact with buttons below this screen. Any idea why?

Code: Select all

init offset = -1
    
screen navi_drop():
    modal True
    zorder 999
    
    style_prefix "navi_drop"
    
    frame:
        vbox:            
        
            grid 1 7:
                spacing 35
            
                imagebutton alt "close" hover "gui/button/menu.png" idle "gui/button/menu.png" action Quit(confirm=True)
                imagebutton alt "return" hover "gui/button/return.png" idle "gui/button/return.png" focus_mask True action Return()
                imagebutton alt "save" hover "gui/button/save.png" idle "gui/button/save.png" focus_mask True action ShowMenu("save")
                imagebutton alt "load" hover "gui/button/load.png" idle "gui/button/load.png" focus_mask True action ShowMenu("load")
                imagebutton alt "options" hover "gui/button/options.png" idle "gui/button/options.png" focus_mask True action ShowMenu("preferences")
                imagebutton alt "credits" hover "gui/button/credits.png" idle "gui/button/credits.png" focus_mask True action ShowMenu("creds")
                imagebutton alt "about" hover "gui/button/about.png" idle "gui/button/about.png" focus_mask True action ShowMenu("about")

style navi_drop_frame:
    background Frame(gui.navi_drop_background, gui.navi_drop_frame_borders, tile=gui.frame_tile)
    padding gui.navi_drop_frame_borders.padding
    xpos gui.navi_drop_menu_xpos
    ypos gui.navi_drop_menu_ypos
This screen appears when a user clicks a button on a different screen (or it will, once I finish making the screen.)
It is meant to look a bit like this after being clicked.
screenshot0006.png
And when a user clicks the topmost button, it will close the screen (for now it exits the game completely as I haven't worked out how to hide screens yet)

The issue is, the game allows me to still save or load the files beneath this screen and I cannot understand why.

E: Because I was adding the screen as a child of the screen it was added to.
The solution was to "use" a screen with a button that calls the navigation drop down instead.

Many thanks to philat for pointing me in the right direction.

Here's the solution:

Code: Select all

screen navi():
    vbox xpos 29 ypos 40:
        imagebutton alt "close" hover "gui/button/menu.png" idle "gui/button/menu.png" action Show("navi_drop")

Code: Select all

screen save():

    tag menu
    add gui.save_menu_background
    use navi

    use file_slots(_("Save"))

Code: Select all

init offset = -1
    
screen navi_drop():
    modal True
    zorder 50
    
    style_prefix "navi_drop"
    imagebutton alt "close" hover "gui/button/menu.png" idle "gui/button/menu.png" xpos 29 ypos 40 action Hide("navi_drop")
    frame:
        has vbox
        
        grid 1 6:
            spacing 35
            
            imagebutton alt "return" hover "gui/button/return.png" idle "gui/button/return.png" focus_mask True action Return()
            imagebutton alt "save" hover "gui/button/save.png" idle "gui/button/save.png" focus_mask True action ShowMenu("save"), Hide("navi_drop")
            imagebutton alt "load" hover "gui/button/load.png" idle "gui/button/load.png" focus_mask True action ShowMenu("load"), Hide("navi_drop")
            imagebutton alt "options" hover "gui/button/options.png" idle "gui/button/options.png" focus_mask True action ShowMenu("preferences"), Hide("navi_drop")
            imagebutton alt "credits" hover "gui/button/credits.png" idle "gui/button/credits.png" focus_mask True action ShowMenu("creds"), Hide("navi_drop")
            imagebutton alt "about" hover "gui/button/about.png" idle "gui/button/about.png" focus_mask True action ShowMenu("about"), Hide("navi_drop")
            

style navi_drop_frame:
    background Frame(gui.navi_drop_background, gui.navi_drop_frame_borders, tile=gui.frame_tile)
    padding gui.navi_drop_frame_borders.padding
    xpos gui.navi_drop_menu_xpos
    ypos gui.navi_drop_menu_ypos
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

Post Reply

Who is online

Users browsing this forum: No registered users