Making a one-liner window hide/show function for working with multiple screens

Window hiding and showing

For previous games, our quick menu/navigation was in the same screen as the dialogue box (for both ADV and NVL modes), so using the default Ren’Py window hide and window show worked well. For DMR, we have the navigation elements in a separate screen for various design reasons, so we have to manually show/hide them alongside the dialogue box. This can lead to errors with missing or multiple navigation elements. To automatically show/hide the navigation elements with the dialogue boxes, we made a wrapper for the default window hide/show and added a few extra features.

The Ren’Py Python version of window hide/show is a _window_hide() and _window_show() function, and we copied it over from source below. We also always want some sort of short pause before and after we show/hide the window, so they’ve been added to the function. the trans argument is for if we want to use some special transition outside of the default one.

def hide_adv_menu_star():
    store.at_menu = False
    renpy.with_statement(trans=None)
    renpy.hide_screen("nvl_star_intro")
    renpy.hide_screen("qmenu_pc_nvl")
    renpy.with_statement(trans=store.show_default_transition)
    renpy.with_statement(trans=None)
    return
show_default_transition = Dissolve(.35)
def wh(_pause=.8, _pause_after=.8,trans=""):
    """hide adv window"""
    if trans == "":
        trans = store.show_default_transition
    
    # pause before we hide the window
    renpy.pause(_pause)

    ### copied _window_hide code from source ###
    if not store._window:
        return

    if trans is False:
        trans = config.window_hide_transition

    if _preferences.show_empty_window and (not renpy.game.after_rollback):
        renpy.with_statement(None)
        store._window = False
        ## @ Argent Games
        renpy.hide_screen("say_star")
        hide_adv_qmenu() # if the player opened the menu, hide it
        ## /end 
        renpy.with_statement(trans)
    else:
        store._window = False
        ## @ Argent Games
        renpy.hide_screen("say_star")
        hide_adv_qmenu() # if the player opened the menu, hide it
        ## /end
    ### END COPY ###

    # pause after we hide the window
    renpy.pause(_pause_after)
    return
def ws(_pause=.8,_pause_after=.4,trans=False):
    """show adv window"""
    # pause before we show the window
    renpy.pause(_pause)

    ### copied _window_show code from source ###
    if store._window:
        return

    if trans is False:
        trans = config.window_show_transition

    if _preferences.show_empty_window and (not renpy.game.after_rollback):
        renpy.with_statement(None)
        store._window = True
        ## @ Argent Games
        if not renpy.get_screen("say_star"):
            renpy.show_screen("say_star") # show star qmenu simmultaneously
        ## /end
        renpy.with_statement(trans)
    else:
        store._window = True
        ## @ Argent Games
        if not renpy.get_screen("say_star"):
            renpy.show_screen("say_star")
        ## /end
    ### END COPY ###
    
    # pause after showing the window
    renpy.pause(_pause_after)
    return

## example use in script
scene bg town
$ws(_pause=.8,_pause_after=.2)
"Hello there"
$wh(.3)
scene bg saloon

The DMR Demo beta has been going very smoothly and is wrapping up in the next few hours. It’ll be publicly released by the end of the week, so look forward to a weekend (or post-Thanksgiving, if you are in America) game demo! You’ll get the earliest notification for its release if you are following us on Twitter and/or are in the Discord server.

Questions or Comments?

Feel free to send in any AG-related questions! Our Ask Box is always open.

Thanks so much for all of your amazing support, and stay safe out there!