Mercurial > rinkhals
comparison gamelib/toolbar.py @ 573:ffdaac5d6cf8
Select is the default tool.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Sat, 28 Nov 2009 20:29:33 +0000 |
parents | 40eee9e1246c |
children | 2a913d34c95a |
comparison
equal
deleted
inserted
replaced
572:40eee9e1246c | 573:ffdaac5d6cf8 |
---|---|
271 def __init__(self, gameboard, **params): | 271 def __init__(self, gameboard, **params): |
272 BaseToolBar.__init__(self, gameboard, **params) | 272 BaseToolBar.__init__(self, gameboard, **params) |
273 self.group = gui.Group(name='default_toolbar', value=None) | 273 self.group = gui.Group(name='default_toolbar', value=None) |
274 self.make_toolbar() | 274 self.make_toolbar() |
275 | 275 |
276 def toggle_move(self): | |
277 if self.gameboard.selected_tool == constants.TOOL_PLACE_ANIMALS: | |
278 self.gameboard.set_selected_tool(None, None) | |
279 return False | |
280 else: | |
281 self.gameboard.set_selected_tool(constants.TOOL_PLACE_ANIMALS, cursors.cursors['chicken']) | |
282 return True | |
283 | |
276 def make_toolbar(self): | 284 def make_toolbar(self): |
277 self._select_tool = self.add_tool_button("Select / Move", constants.TOOL_SELECT_CHICKENS, | 285 self._move_tool = self.add_tool("Move", self.toggle_move) |
278 None, cursors.cursors['select']) | |
279 | 286 |
280 self.add_spacer(5) | 287 self.add_spacer(5) |
281 | 288 |
282 self.add_tool('Equip chickens', self.add_equipment_toolbar) | 289 self.add_tool('Equip chickens', self.add_equipment_toolbar) |
283 | 290 |
311 ## Dear pgu, is there a better way to get the current height? | 318 ## Dear pgu, is there a better way to get the current height? |
312 #_cur_width, cur_height = self.resize() | 319 #_cur_width, cur_height = self.resize() |
313 #self.add_spacer(570-cur_height) | 320 #self.add_spacer(570-cur_height) |
314 self.fin_tool = self.add_tool("Finished Day", self.day_done) | 321 self.fin_tool = self.add_tool("Finished Day", self.day_done) |
315 | 322 |
316 if self.gameboard.selected_tool in [constants.TOOL_PLACE_ANIMALS, constants.TOOL_SELECT_CHICKENS]: | 323 if self.gameboard.selected_tool == constants.TOOL_PLACE_ANIMALS: |
317 self.highlight_move_select_button() | 324 self.highlight_move_button() |
318 | 325 |
319 def highlight_move_select_button(self): | 326 def unhighlight_move_button(self): |
320 self._select_tool.group.value = self._select_tool.value | 327 self._move_tool.group.value = None |
321 self._select_tool.pcls = "down" | 328 self._move_tool.pcls = "up" |
329 | |
330 def highlight_move_button(self): | |
331 self._move_tool.group.value = self._move_tool.value | |
332 self._move_tool.pcls = "down" | |
322 | 333 |
323 def add_building_toolbar(self): | 334 def add_building_toolbar(self): |
324 self.gameboard.change_toolbar(BuildingToolBar(self.gameboard, | 335 self.gameboard.change_toolbar(BuildingToolBar(self.gameboard, |
325 width=self.style.width)) | 336 width=self.style.width)) |
326 | 337 |