# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
# See LICENSE.txt for license details.

init -1170 python hide:

    config.old_names['Quit'] = 'Quit Game'

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

    # If not None, this is used to fix the positions of the
    # things in the main menu.
    config.main_menu_positions = None

    # Styles used in this file.

# 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.add(renpy.Keymap(toggle_fullscreen = renpy.toggle_fullscreen))

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

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

        for i, (text, clicked, enabled) in enumerate(config.main_menu):

            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)

        if not config.main_menu_positions:
            ui.close()

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

    jump _main_menu
