documentation indexreference manualfunction index

ui.jumpsoutofcontext

Function: ui.jumpsoutofcontext (label):

This function returns a function that, when called, exits the current context, and in the parent context jumps to the named label. It's intended to be used as the clicked argument to a button.

Example

init:
    python:
        # The contents of the main menu.
        config.main_menu = [
            ( u"Start Game", "start", 'True'),
            ( u"Continue Game", ui.jumps("_load_screen"), 'True' ),
            ( u"Preferences", ui.jumps("_prefs_screen"), 'True' ),
            ( u"Quit",  ui.jumps("_quit"), 'True' ),
            ]

# This is the default main menu, which we get if the user hasn't
# defined his own, or if that function calls this explicitly.
label _library_main_menu:
    python hide:
        ui.keymap(toggle_fullscreen = renpy.toggle_fullscreen)

        ui.window(style='mm_root')
        ui.fixed()

        if config.main_menu_positions:
            ui.fixed()
        else:
            ui.window(style='mm_menu_frame')
            ui.vbox(style='mm_menu_frame_vbox')

        for text, clicked, enabled in config.main_menu:

            # if the clicked argument in config.main_menu is just a
            # string (for a label), like the start game entry in the
            # default config.main_menu, replace it with a
            # ui.jumpsoutofcontext call to the label
            if isinstance(clicked, basestring):
                clicked = ui.jumpsoutofcontext(clicked)

            if config.main_menu_positions:
                kwargs = config.main_menu_positions.get(text, { })
            else:
                kwargs = { }

            if not eval(enabled):
                clicked = None
                disabled = True
            else:
                disabled = False

            _button_factory(text, "mm", clicked=clicked, disabled=disabled, properties=kwargs)

        ui.close()
        ui.close()

        store._result = ui.interact(suppress_overlay = True,
                                    suppress_underlay = True,
                                    mouse="mainmenu")

    # Computed jump to the appropriate label.
    jump _main_menu



documentation indexreference manualfunction index