Mercurial > rinkhals
comparison 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 |
comparison
equal
deleted
inserted
replaced
319:61f6233bcf0f | 320:9bf0e701a36e |
---|---|
14 import equipment | 14 import equipment |
15 import sound | 15 import sound |
16 import cursors | 16 import cursors |
17 import sprite_cursor | 17 import sprite_cursor |
18 import misc | 18 import misc |
19 import engine | |
19 | 20 |
20 class OpaqueLabel(gui.Label): | 21 class OpaqueLabel(gui.Label): |
21 def __init__(self, value, **params): | 22 def __init__(self, value, **params): |
22 gui.Label.__init__(self, value, **params) | 23 gui.Label.__init__(self, value, **params) |
23 if 'width' in params: | 24 if 'width' in params: |
113 | 114 |
114 self.add_spacer(10) | 115 self.add_spacer(10) |
115 self.add_tool("Price Reference", self.show_prices) | 116 self.add_tool("Price Reference", self.show_prices) |
116 self.add_spacer(20) | 117 self.add_spacer(20) |
117 | 118 |
118 self.add_tool("Finished Day", self.day_done) | 119 self.fin_tool = self.add_tool("Finished Day", self.day_done) |
119 | 120 |
120 self.anim_clear_tool = False # Flag to clear the tool on an anim loop | 121 self.anim_clear_tool = False # Flag to clear the tool on an anim loop |
121 # pgu's tool widget fiddling happens after the tool action, so calling | 122 # pgu's tool widget fiddling happens after the tool action, so calling |
122 # clear_tool in the tool's action doesn't work, so we punt it to | 123 # clear_tool in the tool's action doesn't work, so we punt it to |
123 # the anim loop | 124 # the anim loop |
124 | 125 |
125 def day_done(self): | 126 def day_done(self): |
126 import engine | 127 if self.gameboard.day: |
127 pygame.event.post(engine.START_NIGHT) | 128 pygame.event.post(engine.START_NIGHT) |
129 else: | |
130 self.anim_clear_tool = True | |
131 pygame.event.post(engine.FAST_FORWARD) | |
132 | |
133 def update_fin_tool(self, day): | |
134 if day: | |
135 self.fin_tool.widget = gui.basic.Label('Finished Day') | |
136 self.fin_tool.resize() | |
137 else: | |
138 self.fin_tool.widget = gui.basic.Label('Fast Forward') | |
139 self.fin_tool.resize() | |
128 | 140 |
129 def show_prices(self): | 141 def show_prices(self): |
130 """Popup dialog of prices""" | 142 """Popup dialog of prices""" |
131 def make_box(text): | 143 def make_box(text): |
132 style = { | 144 style = { |
208 self._next_tool_value += 1 | 220 self._next_tool_value += 1 |
209 tool = gui.Tool(self.group, label, value, width=self.rect.w, style={"padding_left": 0}) | 221 tool = gui.Tool(self.group, label, value, width=self.rect.w, style={"padding_left": 0}) |
210 tool.connect(gui.CLICK, func) | 222 tool.connect(gui.CLICK, func) |
211 self.tr() | 223 self.tr() |
212 self.td(tool, align=-1, colspan=2) | 224 self.td(tool, align=-1, colspan=2) |
225 return tool | |
213 | 226 |
214 def clear_tool(self): | 227 def clear_tool(self): |
215 self.group.value = None | 228 self.group.value = None |
216 for item in self.group.widgets: | 229 for item in self.group.widgets: |
217 item.pcls = "" | 230 item.pcls = "" |
384 | 397 |
385 def start_night(self): | 398 def start_night(self): |
386 self.day, self.night = False, True | 399 self.day, self.night = False, True |
387 self.tv.sun(False) | 400 self.tv.sun(False) |
388 self.reset_states() | 401 self.reset_states() |
402 self.toolbar.update_fin_tool(self.day) | |
389 | 403 |
390 def start_day(self): | 404 def start_day(self): |
391 self.day, self.night = True, False | 405 self.day, self.night = True, False |
392 self.tv.sun(True) | 406 self.tv.sun(True) |
393 self.reset_states() | 407 self.reset_states() |
408 self.toolbar.update_fin_tool(self.day) | |
394 | 409 |
395 def in_bounds(self, pos): | 410 def in_bounds(self, pos): |
396 """Check if a position is within the game boundaries""" | 411 """Check if a position is within the game boundaries""" |
397 if pos.x < 0 or pos.y < 0: | 412 if pos.x < 0 or pos.y < 0: |
398 return False | 413 return False |