view gamelib/mainmenu.py @ 80:ad9d1bc7ef0c

Kill foxes that don't reach safety
author Neil Muller <drnlmuller@gmail.com>
date Tue, 01 Sep 2009 11:21:43 +0000
parents 5d58a5b13731
children 69fd96eafde8
line wrap: on
line source

"""Main menu."""

from pgu import gui
import pygame
import constants
import engine

class MainMenu(gui.Table):
    def __init__(self, **params):
        gui.Table.__init__(self, **params)

        def fullscreen_toggled():
            pygame.display.toggle_fullscreen()

        def quit_pressed():
            pygame.event.post(engine.QUIT)

        def start_pressed():
            pygame.event.post(engine.START_DAY)

        start_button = gui.Button("Start")
        start_button.connect(gui.CLICK, start_pressed)

        quit_button = gui.Button("Quit")
        quit_button.connect(gui.CLICK, quit_pressed)

        fullscreen_toggle = gui.Button("Toggle Fullscreen")
        fullscreen_toggle.connect(gui.CLICK, fullscreen_toggled)

        style = {
            "padding_bottom": 15,
        }
        td_kwargs = {
            "align": 0,
            "style": style,
        }

        self.tr()
        self.td(gui.Label(constants.NAME, color=constants.FG_COLOR), **td_kwargs)

        self.tr()
        self.td(start_button, **td_kwargs)

        self.tr()
        self.td(fullscreen_toggle, **td_kwargs)

        self.tr()
        self.td(quit_button, **td_kwargs)