# HG changeset patch # User Neil Muller # Date 1252100972 0 # Node ID 07b361ebd87f8ca4ef3fef7f0a4485e5fd544fe0 # Parent b999abd5993b50039c7dd5af7012b47eff245d5f Ensure we clean up highlights, etc. diff -r b999abd5993b -r 07b361ebd87f gamelib/engine.py --- a/gamelib/engine.py Fri Sep 04 21:35:40 2009 +0000 +++ b/gamelib/engine.py Fri Sep 04 21:49:32 2009 +0000 @@ -120,7 +120,7 @@ if events_equal(e, START_NIGHT): return NightState(self.game) elif e.type is KEYDOWN and e.key == K_ESCAPE: - self.game.gameboard.set_cursor() + self.game.gameboard.reset_states() return GameOver(self.game) elif e.type is ANIM_ID: self.game.gameboard.run_animations() @@ -148,7 +148,7 @@ """Add some foxes to the farm""" sound.stop_background_music() self.game.gameboard.tv.sun(False) - self.game.gameboard.set_cursor() + self.game.gameboard.reset_states() sound.play_sound("nightfall.ogg") # Add a timer to the event queue diff -r b999abd5993b -r 07b361ebd87f gamelib/gameboard.py --- a/gamelib/gameboard.py Fri Sep 04 21:35:40 2009 +0000 +++ b/gamelib/gameboard.py Fri Sep 04 21:49:32 2009 +0000 @@ -249,6 +249,9 @@ def set_selected_tool(self, tool, cursor): self.selected_tool = tool + if self.animal_to_place: + # Clear any highlights + self.animal_to_place.unequip_by_name("spotlight") self.select_animal_to_place(None) sprite_curs = None if buildings.is_building(tool): @@ -266,7 +269,12 @@ if sprite_curs: self.sprite_cursor = sprite_curs self.tv.sprites.append(self.sprite_cursor) - + + def reset_states(self): + """Clear current states (highlights, etc.)""" + if self.animal_to_place: + self.animal_to_place.unequip_by_name("spotlight") + self.set_cursor() def update_sprite_cursor(self, e): tile_pos = self.tv.screen_to_tile(e.pos)