Ignore:
Timestamp:
Aug 30, 2009, 1:25:04 PM (11 years ago)
Author:
Simon Cross <hodgestar@…>
Branch:
default
Convert:
svn:b4e93282-eac8-4b8b-b765-0f5d36de2b68@7
Message:

Add start, quit and toggle fullscreen buttons to menu.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gamelib/mainmenu.py

    r5 r6  
    66
    77class MainMenu(gui.Table):
    8     def __init__(self,**params):
    9         gui.Table.__init__(self,**params)
     8    def __init__(self, **params):
     9        gui.Table.__init__(self, **params)
    1010
    11         def fullscreen_changed(btn):
     11        def fullscreen_toggled():
    1212            pygame.display.toggle_fullscreen()
    1313
    14         fg = (255,255,255)
     14        def quit_pressed():
     15            pygame.event.post(pygame.event.Event(pygame.QUIT))
     16
     17        def start_pressed():
     18            pygame.event.post(pygame.event.Event(pygame.USEREVENT, event="<Our Start Event Class>"))
     19
     20        start_button = gui.Button("Start")
     21        start_button.connect(gui.CLICK, start_pressed)
     22
     23        quit_button = gui.Button("Quit")
     24        quit_button.connect(gui.CLICK, quit_pressed)
     25
     26        fullscreen_toggle = gui.Button("Toggle Fullscreen")
     27        fullscreen_toggle.connect(gui.CLICK, fullscreen_toggled)
    1528
    1629        self.tr()
    17         self.td(gui.Label(constants.NAME, color=fg), colspan=2)
     30        self.td(gui.Label(constants.NAME, color=constants.FG_COLOR), colspan=2)
    1831
    1932        self.tr()
    20         self.td(gui.Label("Start", color=fg), align=1)
    21 
    22         btn = gui.Switch(value=False,name='fullscreen')
    23         btn.connect(gui.CHANGE, fullscreen_changed, btn)
     33        self.td(start_button, align=0)
    2434
    2535        self.tr()
    26         self.td(gui.Label("Full Screen: ",color=fg),align=1)
    27         self.td(btn)
     36        self.td(fullscreen_toggle, align=0)
    2837
    2938        self.tr()
    30         self.td(gui.Label("Quit", color=fg), align=1)
     39        self.td(quit_button, align=0)
Note: See TracChangeset for help on using the changeset viewer.