Mercurial > pyntnclick
diff gamelib/state.py @ 65:cab924519037
Move some description management from widget to state object
author | Neil Muller <neil@dip.sun.ac.za> |
---|---|
date | Mon, 23 Aug 2010 19:45:07 +0200 |
parents | 3087be3463e0 |
children | 158a13a48d48 |
line wrap: on
line diff
--- a/gamelib/state.py Mon Aug 23 19:07:35 2010 +0200 +++ b/gamelib/state.py Mon Aug 23 19:45:07 2010 +0200 @@ -36,6 +36,7 @@ self.inventory = [] # Result of the most recent action self.msg = None + self.description = None # current scene self.current_scene = None @@ -68,9 +69,16 @@ def clear_message(self): self.msg = None - def get_description(self, pos): - """Get the description associated with current mouse position""" - return self.current_scene.get_description(pos) + # FIXME: sort out how state.interact and description updating should work + + def check_for_new_description(self, pos): + """Check if the current mouse position causes a new description""" + old_desc = self.description + self.description = self.current_scene.check_description(pos) + return old_desc != self.description + + def get_description(self): + return self.description def message(self, msg): self.msg = msg @@ -136,7 +144,7 @@ self.draw_background(surface) self.draw_things(surface) - def get_description(self, pos): + def check_description(self, pos): desc = None for thing in self.things.itervalues(): # Last thing in the list that matches wins