changeset 517:26f9b4d10e3e

Remove mouse motion logic from GameState.
author Jeremy Thurgood <firxen@gmail.com>
date Tue, 07 Sep 2010 13:45:07 +0200
parents ac2b19f05253
children 3e91c82c2240
files gamelib/gamescreen.py gamelib/state.py
diffstat 2 files changed, 5 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/gamelib/gamescreen.py	Tue Sep 07 13:37:00 2010 +0200
+++ b/gamelib/gamescreen.py	Tue Sep 07 13:45:07 2010 +0200
@@ -10,7 +10,7 @@
 from pygame.color import Color
 from pygame.locals import BLEND_ADD
 
-from constants import SCREEN, BUTTON_SIZE, SCENE_SIZE
+from constants import SCREEN, BUTTON_SIZE, SCENE_SIZE, LEAVE
 from cursor import CursorWidget
 from state import initial_state, handle_result
 from widgets import (MessageDialog, BoomButton, HandButton, PopupMenu,
@@ -70,7 +70,7 @@
         self.state.draw(surface, self.screen)
 
     def draw(self, surface):
-        if self.state.previous_scene and self.state.do_check == constants.LEAVE:
+        if self.state.previous_scene and self.state.do_check == LEAVE:
             # We still need to handle leave events, so still display the scene
             self.state.previous_scene.draw(surface, self)
         else:
@@ -103,7 +103,8 @@
 
     def _mouse_move(self, pos):
         self.state.highlight_override = False
-        self.state.mouse_move(pos)
+        self.state.current_scene.mouse_move(pos)
+        self.state.old_pos = pos
 
     def show_message(self, message, style=None):
         # Display the message as a modal dialog
@@ -181,7 +182,7 @@
 
     def _mouse_move(self, pos):
         self.state.highlight_override = False
-        self.state.mouse_move_detail(self.global_to_local(pos))
+        self.state.current_detail.mouse_move(self.global_to_local(pos))
 
     def show_message(self, message, style=None):
         self.parent.show_message(message, style)
--- a/gamelib/state.py	Tue Sep 07 13:37:00 2010 +0200
+++ b/gamelib/state.py	Tue Sep 07 13:45:07 2010 +0200
@@ -208,18 +208,10 @@
             return self.current_scene.enter()
         raise RuntimeError('invalid do_check value %s' % self.do_check)
 
-    def mouse_move(self, pos):
-        self.current_scene.mouse_move(pos)
-        # So we can do sensible things on enter and leave
-        self.old_pos = pos
-
     def set_do_enter_leave(self):
         """Flag that we need to run the enter loop"""
         self.do_check = constants.LEAVE
 
-    def mouse_move_detail(self, pos):
-        self.current_detail.mouse_move(pos)
-
 
 class StatefulGizmo(object):