Mercurial > rinkhals
diff gamelib/mainmenu.py @ 6:c0abad23a055
Add start, quit and toggle fullscreen buttons to menu.
author | Simon Cross <hodgestar@gmail.com> |
---|---|
date | Sun, 30 Aug 2009 13:25:04 +0000 |
parents | 67b79658b047 |
children | 99c4f2226314 |
line wrap: on
line diff
--- a/gamelib/mainmenu.py Sun Aug 30 13:04:24 2009 +0000 +++ b/gamelib/mainmenu.py Sun Aug 30 13:25:04 2009 +0000 @@ -5,26 +5,35 @@ import constants class MainMenu(gui.Table): - def __init__(self,**params): - gui.Table.__init__(self,**params) + def __init__(self, **params): + gui.Table.__init__(self, **params) - def fullscreen_changed(btn): + def fullscreen_toggled(): pygame.display.toggle_fullscreen() - fg = (255,255,255) + def quit_pressed(): + pygame.event.post(pygame.event.Event(pygame.QUIT)) + + def start_pressed(): + pygame.event.post(pygame.event.Event(pygame.USEREVENT, event="<Our Start Event Class>")) - self.tr() - self.td(gui.Label(constants.NAME, color=fg), colspan=2) + 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) self.tr() - self.td(gui.Label("Start", color=fg), align=1) - - btn = gui.Switch(value=False,name='fullscreen') - btn.connect(gui.CHANGE, fullscreen_changed, btn) + self.td(gui.Label(constants.NAME, color=constants.FG_COLOR), colspan=2) self.tr() - self.td(gui.Label("Full Screen: ",color=fg),align=1) - self.td(btn) + self.td(start_button, align=0) self.tr() - self.td(gui.Label("Quit", color=fg), align=1) + self.td(fullscreen_toggle, align=0) + + self.tr() + self.td(quit_button, align=0)