Mercurial > rinkhals
comparison gamelib/toolbar.py @ 472:67574723427e
Partially working (but much less crashy) multiple select support
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Wed, 25 Nov 2009 14:32:40 +0000 |
parents | 3d173ea43ad5 |
children | cab751de93cc |
comparison
equal
deleted
inserted
replaced
471:c34d53edfa12 | 472:67574723427e |
---|---|
7 import buildings | 7 import buildings |
8 import equipment | 8 import equipment |
9 import cursors | 9 import cursors |
10 import engine | 10 import engine |
11 import version | 11 import version |
12 | |
13 class RinkhalsTool(gui.Tool): | |
14 def __init__(self, group, label, value, func, **params): | |
15 gui.Tool.__init__(self, group, label, value, **params) | |
16 self.func = func | |
17 | |
18 def click(self): | |
19 gui.Tool.click(self) | |
20 if not self.func(): | |
21 # Don't hightlight if the function says so | |
22 self.group.value = None | |
12 | 23 |
13 class OpaqueLabel(gui.Label): | 24 class OpaqueLabel(gui.Label): |
14 def __init__(self, value, **params): | 25 def __init__(self, value, **params): |
15 gui.Label.__init__(self, value, **params) | 26 gui.Label.__init__(self, value, **params) |
16 if 'width' in params: | 27 if 'width' in params: |
228 | 239 |
229 def add_tool(self, text, func): | 240 def add_tool(self, text, func): |
230 label = gui.basic.Label(text) | 241 label = gui.basic.Label(text) |
231 value = self._next_tool_value | 242 value = self._next_tool_value |
232 self._next_tool_value += 1 | 243 self._next_tool_value += 1 |
233 tool = gui.Tool(self.group, label, value, width=self.rect.w, style={"padding_left": 0}) | 244 tool = RinkhalsTool(self.group, label, value, func, width=self.rect.w, |
234 tool.connect(gui.CLICK, func) | 245 style={"padding_left": 0}) |
246 #tool.connect(gui.CLICK, func) | |
235 self.tr() | 247 self.tr() |
236 self.td(tool, align=-1, colspan=2) | 248 self.td(tool, align=-1, colspan=2) |
237 return tool | 249 return tool |
238 | 250 |
239 def clear_tool(self): | 251 def clear_tool(self): |
299 self.fin_tool = self.add_tool("Finished Day", self.day_done) | 311 self.fin_tool = self.add_tool("Finished Day", self.day_done) |
300 | 312 |
301 def add_building_toolbar(self): | 313 def add_building_toolbar(self): |
302 self.gameboard.change_toolbar(BuildingToolBar(self.gameboard, | 314 self.gameboard.change_toolbar(BuildingToolBar(self.gameboard, |
303 width=self.style.width)) | 315 width=self.style.width)) |
316 self.gameboard.unselect_all() | |
304 | 317 |
305 def add_sell_toolbar(self): | 318 def add_sell_toolbar(self): |
306 self.gameboard.change_toolbar(SellToolBar(self.gameboard, | 319 self.gameboard.change_toolbar(SellToolBar(self.gameboard, |
307 width=self.style.width)) | 320 width=self.style.width)) |
308 | 321 |
309 def add_wood_toolbar(self): | 322 def add_wood_toolbar(self): |
310 self.gameboard.change_toolbar(WoodToolBar(self.gameboard, | 323 self.gameboard.change_toolbar(WoodToolBar(self.gameboard, |
311 width=self.style.width)) | 324 width=self.style.width)) |
325 self.gameboard.unselect_all() | |
312 | 326 |
313 def add_equipment_toolbar(self): | 327 def add_equipment_toolbar(self): |
314 self.gameboard.change_toolbar(EquipmentToolBar(self.gameboard, | 328 self.gameboard.change_toolbar(EquipmentToolBar(self.gameboard, |
315 width=self.style.width)) | 329 width=self.style.width)) |
316 | 330 |