comparison gamelib/gameboard.py @ 487:a5dc09881aa1

rationalised when tools are reset; e.g. you can trade wood without losing selection / move tool. Default toolbar shows correct tool when reloaded (select/move only; other tools reset)
author Adrianna Pińska <adrianna.pinska@gmail.com>
date Wed, 25 Nov 2009 21:58:29 +0000
parents 6f0385ebcb4f
children a9f6c32c8ea9
comparison
equal deleted inserted replaced
486:8897a436a8cb 487:a5dc09881aa1
101 self.max_foxes = level.max_foxes 101 self.max_foxes = level.max_foxes
102 self.calculate_wood_groat_exchange_rate() 102 self.calculate_wood_groat_exchange_rate()
103 103
104 self.selected_tool = None 104 self.selected_tool = None
105 self.sprite_cursor = None 105 self.sprite_cursor = None
106 self.selected_chickens = []
106 self.chickens = set() 107 self.chickens = set()
107 self.foxes = set() 108 self.foxes = set()
108 self.buildings = set() 109 self.buildings = set()
109 self._pos_cache = AnimalPositionCache(self) 110 self._pos_cache = AnimalPositionCache(self)
110 self.cash = 0 111 self.cash = 0
126 for tn in equipment.EQUIP_MAP: 127 for tn in equipment.EQUIP_MAP:
127 cdata[tn] = (self.add_start_chickens, tn) 128 cdata[tn] = (self.add_start_chickens, tn)
128 129
129 self.tv.run_codes(cdata, (0,0,width,height)) 130 self.tv.run_codes(cdata, (0,0,width,height))
130 131
131 self.selected_chickens = []
132
133 def get_top_widget(self): 132 def get_top_widget(self):
134 return self.top_widget 133 return self.top_widget
135 134
136 def create_display(self): 135 def create_display(self):
137 width, height = self.disp.rect.w, self.disp.rect.h 136 width, height = self.disp.rect.w, self.disp.rect.h
265 return 264 return
266 if e.button == 3: # Right button 265 if e.button == 3: # Right button
267 if self.selected_tool == constants.TOOL_PLACE_ANIMALS: 266 if self.selected_tool == constants.TOOL_PLACE_ANIMALS:
268 self.set_selected_tool(constants.TOOL_SELECT_CHICKENS, cursors.cursors["select"]) 267 self.set_selected_tool(constants.TOOL_SELECT_CHICKENS, cursors.cursors["select"])
269 if self.toolbar.IS_DEFAULT: 268 if self.toolbar.IS_DEFAULT:
270 self.toolbar._select_tool.group.value = self.toolbar._select_tool.value 269 self.toolbar.toggle_select_on()
271 self.toolbar._move_tool.pcls = ""
272 self.toolbar._select_tool.pcls = "down"
273 elif self.selected_tool == constants.TOOL_SELECT_CHICKENS: 270 elif self.selected_tool == constants.TOOL_SELECT_CHICKENS:
274 self.set_selected_tool(constants.TOOL_PLACE_ANIMALS, cursors.cursors["chicken"]) 271 self.set_selected_tool(constants.TOOL_PLACE_ANIMALS, cursors.cursors["chicken"])
275 if self.toolbar.IS_DEFAULT: 272 if self.toolbar.IS_DEFAULT:
276 self.toolbar._move_tool.group.value = self.toolbar._move_tool.value 273 self.toolbar.toggle_move_on()
277 self.toolbar._select_tool.pcls = ""
278 self.toolbar._move_tool.pcls = "down"
279 return 274 return
280 elif e.button != 1: # Left button 275 elif e.button != 1: # Left button
281 return 276 return
282 mods = pygame.key.get_mods() 277 mods = pygame.key.get_mods()
283 if self.selected_tool == constants.TOOL_SELL_CHICKEN: 278 if self.selected_tool == constants.TOOL_SELL_CHICKEN: