diff gamelib/gameboard.py @ 320:9bf0e701a36e

Switch between 'Finished Day' and 'Fast Forward' modes
author Neil Muller <drnlmuller@gmail.com>
date Sat, 05 Sep 2009 19:26:01 +0000
parents ae5989b3ce01
children 978efd39a099
line wrap: on
line diff
--- a/gamelib/gameboard.py	Sat Sep 05 19:22:58 2009 +0000
+++ b/gamelib/gameboard.py	Sat Sep 05 19:26:01 2009 +0000
@@ -16,6 +16,7 @@
 import cursors
 import sprite_cursor
 import misc
+import engine
 
 class OpaqueLabel(gui.Label):
     def __init__(self, value, **params):
@@ -115,7 +116,7 @@
         self.add_tool("Price Reference", self.show_prices)
         self.add_spacer(20)
 
-        self.add_tool("Finished Day", self.day_done)
+        self.fin_tool = self.add_tool("Finished Day", self.day_done)
 
         self.anim_clear_tool = False # Flag to clear the tool on an anim loop
         # pgu's tool widget fiddling happens after the tool action, so calling
@@ -123,8 +124,19 @@
         # the anim loop
 
     def day_done(self):
-        import engine
-        pygame.event.post(engine.START_NIGHT)
+        if self.gameboard.day:
+            pygame.event.post(engine.START_NIGHT)
+        else:
+            self.anim_clear_tool = True
+            pygame.event.post(engine.FAST_FORWARD)
+
+    def update_fin_tool(self, day):
+        if day:
+            self.fin_tool.widget = gui.basic.Label('Finished Day')
+            self.fin_tool.resize()
+        else:
+            self.fin_tool.widget = gui.basic.Label('Fast Forward')
+            self.fin_tool.resize()
 
     def show_prices(self):
         """Popup dialog of prices"""
@@ -210,6 +222,7 @@
         tool.connect(gui.CLICK, func)
         self.tr()
         self.td(tool, align=-1, colspan=2)
+        return tool
 
     def clear_tool(self):
         self.group.value = None
@@ -386,11 +399,13 @@
         self.day, self.night = False, True
         self.tv.sun(False)
         self.reset_states()
+        self.toolbar.update_fin_tool(self.day)
 
     def start_day(self):
         self.day, self.night = True, False
         self.tv.sun(True)
         self.reset_states()
+        self.toolbar.update_fin_tool(self.day)
 
     def in_bounds(self, pos):
         """Check if a position is within the game boundaries"""