Mercurial > rinkhals
comparison gamelib/gameboard.py @ 213:07b361ebd87f
Ensure we clean up highlights, etc.
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Fri, 04 Sep 2009 21:49:32 +0000 |
parents | b999abd5993b |
children | 85a5299caf4a |
comparison
equal
deleted
inserted
replaced
212:b999abd5993b | 213:07b361ebd87f |
---|---|
247 def loop(self): | 247 def loop(self): |
248 self.tv.loop() | 248 self.tv.loop() |
249 | 249 |
250 def set_selected_tool(self, tool, cursor): | 250 def set_selected_tool(self, tool, cursor): |
251 self.selected_tool = tool | 251 self.selected_tool = tool |
252 if self.animal_to_place: | |
253 # Clear any highlights | |
254 self.animal_to_place.unequip_by_name("spotlight") | |
252 self.select_animal_to_place(None) | 255 self.select_animal_to_place(None) |
253 sprite_curs = None | 256 sprite_curs = None |
254 if buildings.is_building(tool): | 257 if buildings.is_building(tool): |
255 sprite_curs = sprite_cursor.SpriteCursor(tool.IMAGE, self.tv) | 258 sprite_curs = sprite_cursor.SpriteCursor(tool.IMAGE, self.tv) |
256 self.set_cursor(cursor, sprite_curs) | 259 self.set_cursor(cursor, sprite_curs) |
264 self.tv.sprites.remove(self.sprite_cursor) | 267 self.tv.sprites.remove(self.sprite_cursor) |
265 self.sprite_cursor = None | 268 self.sprite_cursor = None |
266 if sprite_curs: | 269 if sprite_curs: |
267 self.sprite_cursor = sprite_curs | 270 self.sprite_cursor = sprite_curs |
268 self.tv.sprites.append(self.sprite_cursor) | 271 self.tv.sprites.append(self.sprite_cursor) |
269 | 272 |
273 def reset_states(self): | |
274 """Clear current states (highlights, etc.)""" | |
275 if self.animal_to_place: | |
276 self.animal_to_place.unequip_by_name("spotlight") | |
277 self.set_cursor() | |
270 | 278 |
271 def update_sprite_cursor(self, e): | 279 def update_sprite_cursor(self, e): |
272 tile_pos = self.tv.screen_to_tile(e.pos) | 280 tile_pos = self.tv.screen_to_tile(e.pos) |
273 self.sprite_cursor.set_pos(tile_pos) | 281 self.sprite_cursor.set_pos(tile_pos) |
274 | 282 |