Mercurial > rinkhals
comparison gamelib/gameboard.py @ 480:312120a99181
right-click now toggles select and move tool
author | Adrianna Pińska <adrianna.pinska@gmail.com> |
---|---|
date | Wed, 25 Nov 2009 19:50:40 +0000 |
parents | 1689b43ed8be |
children | fac63919a972 |
comparison
equal
deleted
inserted
replaced
479:1689b43ed8be | 480:312120a99181 |
---|---|
178 if not self.day: | 178 if not self.day: |
179 return False | 179 return False |
180 if self.apply_tool_to_selected(tool): | 180 if self.apply_tool_to_selected(tool): |
181 return False # Using the tool on selected chickens is immediate | 181 return False # Using the tool on selected chickens is immediate |
182 self.selected_tool = tool | 182 self.selected_tool = tool |
183 if tool in [None, constants.TOOL_SELL_BUILDING, | |
184 constants.TOOL_REPAIR_BUILDING]: | |
185 # FIXME - this special casing is sucky | |
186 self.unselect_all() | |
187 sprite_curs = None | 183 sprite_curs = None |
188 if buildings.is_building(tool): | 184 if buildings.is_building(tool): |
189 sprite_curs = sprite_cursor.SpriteCursor(tool.IMAGE, self.tv, tool.BUY_PRICE) | 185 sprite_curs = sprite_cursor.SpriteCursor(tool.IMAGE, self.tv, tool.BUY_PRICE) |
190 elif equipment.is_equipment(tool): | 186 elif equipment.is_equipment(tool): |
191 sprite_curs = sprite_cursor.SpriteCursor(tool.CHICKEN_IMAGE_FILE, self.tv) | 187 sprite_curs = sprite_cursor.SpriteCursor(tool.CHICKEN_IMAGE_FILE, self.tv) |
266 | 262 |
267 def use_tool(self, e): | 263 def use_tool(self, e): |
268 if not self.day: | 264 if not self.day: |
269 return | 265 return |
270 if e.button == 3: # Right button | 266 if e.button == 3: # Right button |
271 self.set_selected_tool(None, None) | 267 #self.set_selected_tool(None, None) |
272 self.toolbar.clear_tool() | 268 #self.toolbar.clear_tool() |
273 elif e.button == 2: # Middle button | 269 if self.selected_tool == constants.TOOL_PLACE_ANIMALS: |
274 self.unselect_all() | 270 self.set_selected_tool(constants.TOOL_SELECT_CHICKENS, cursors.cursors["select"]) |
271 elif self.selected_tool == constants.TOOL_SELECT_CHICKENS: | |
272 self.set_selected_tool(constants.TOOL_PLACE_ANIMALS, cursors.cursors["chicken"]) | |
273 return | |
275 elif e.button != 1: # Left button | 274 elif e.button != 1: # Left button |
276 return | 275 return |
277 mods = pygame.key.get_mods() | 276 mods = pygame.key.get_mods() |
278 if self.selected_tool == constants.TOOL_SELL_CHICKEN: | 277 if self.selected_tool == constants.TOOL_SELL_CHICKEN: |
279 self.sell_chicken(self.tv.screen_to_tile(e.pos)) | 278 self.sell_chicken(self.tv.screen_to_tile(e.pos)) |