# HG changeset patch # User Simon Cross # Date 1251638704 0 # Node ID c0abad23a0559ab6b62720e367978fe3270bab42 # Parent 67b79658b04766a4407f2e10c4a54c9648b27c27 Add start, quit and toggle fullscreen buttons to menu. diff -r 67b79658b047 -r c0abad23a055 gamelib/constants.py --- a/gamelib/constants.py Sun Aug 30 13:04:24 2009 +0000 +++ b/gamelib/constants.py Sun Aug 30 13:25:04 2009 +0000 @@ -1,12 +1,17 @@ """Operation Fox Assault constants.""" +# Project metadata + NAME = "Operation Fox Assault" -SCREEN = (800, 600) - AUTHORS = [ ("Adrianna Pinska", "adrianna.pinska@gmail.com"), ("Jeremy Thurgood", ""), ("Neil Muller", ""), ("Simon Cross", "hodgestar+rinkhals@gmail.com"), ] + +# GUI constants + +SCREEN = (800, 600) +FG_COLOR = (255, 255, 255) diff -r 67b79658b047 -r c0abad23a055 gamelib/main.py --- a/gamelib/main.py Sun Aug 30 13:04:24 2009 +0000 +++ b/gamelib/main.py Sun Aug 30 13:25:04 2009 +0000 @@ -8,7 +8,7 @@ import pygame from pgu import gui -from pygame.locals import SWSURFACE, QUIT, KEYDOWN, K_ESCAPE +from pygame.locals import SWSURFACE, QUIT, KEYDOWN, K_ESCAPE, USEREVENT from mainmenu import MainMenu import constants @@ -23,6 +23,8 @@ done = True elif e.type is KEYDOWN and e.key == K_ESCAPE: done = True + elif e.type is USEREVENT: + print e.event else: app.event(e) diff -r 67b79658b047 -r c0abad23a055 gamelib/mainmenu.py --- 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="")) - 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)