diff gamelib/mainmenu.py @ 389:463802281182

Add basic level support (level choosing needs work)
author Neil Muller <drnlmuller@gmail.com>
date Thu, 29 Oct 2009 20:55:37 +0000
parents 79fe97f8e8f5
children 1e24eedbf40f
line wrap: on
line diff
--- a/gamelib/mainmenu.py	Thu Oct 29 20:54:32 2009 +0000
+++ b/gamelib/mainmenu.py	Thu Oct 29 20:55:37 2009 +0000
@@ -6,9 +6,9 @@
 import engine
 import imagecache
 
-def make_main_menu():
+def make_main_menu(level):
     """Create a main menu"""
-    main_menu = MainMenu()
+    main_menu = MainMenu(level)
 
     c = MenuContainer(align=0, valign=0)
     c.add(main_menu, 0, 0)
@@ -26,7 +26,7 @@
         return self.widgets[0].mode
 
 class MainMenu(gui.Table):
-    def __init__(self, **params):
+    def __init__(self, level, **params):
         gui.Table.__init__(self, **params)
         self.mode = None
 
@@ -36,10 +36,12 @@
         def quit_pressed():
             pygame.event.post(engine.QUIT)
 
-        def start_game(mode):
-            self.mode = mode
+        def start_game():
             pygame.event.post(engine.START_DAY)
 
+        def choose_level():
+            print 'Needs to be implemented. Specify the level name as a parameter'
+
         def help_pressed():
             pygame.event.post(engine.GO_HELP_SCREEN)
 
@@ -50,12 +52,16 @@
             "align": 0,
             "style": style,
         }
- 
-        for mode in constants.TURN_LIMITS:
-            button = gui.Button(mode)
-            button.connect(gui.CLICK, start_game, mode)
-            self.tr()
-            self.td(button, **td_kwargs)
+
+        change_button = gui.Button('Choose level')
+        change_button.connect(gui.CLICK, choose_level)
+        self.tr()
+        self.td(change_button, **td_kwargs)
+
+        start_button = gui.Button(level.level_name)
+        start_button.connect(gui.CLICK, start_game)
+        self.tr()
+        self.td(start_button, **td_kwargs)
 
         quit_button = gui.Button("Quit")
         quit_button.connect(gui.CLICK, quit_pressed)