Mercurial > pyntnclick
comparison gamelib/gamescreen.py @ 517:26f9b4d10e3e
Remove mouse motion logic from GameState.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Tue, 07 Sep 2010 13:45:07 +0200 |
parents | fda2b3a2f2e9 |
children | 8f3c82c685a4 |
comparison
equal
deleted
inserted
replaced
516:ac2b19f05253 | 517:26f9b4d10e3e |
---|---|
8 from albow.screen import Screen | 8 from albow.screen import Screen |
9 from pygame import Rect, mouse | 9 from pygame import Rect, mouse |
10 from pygame.color import Color | 10 from pygame.color import Color |
11 from pygame.locals import BLEND_ADD | 11 from pygame.locals import BLEND_ADD |
12 | 12 |
13 from constants import SCREEN, BUTTON_SIZE, SCENE_SIZE | 13 from constants import SCREEN, BUTTON_SIZE, SCENE_SIZE, LEAVE |
14 from cursor import CursorWidget | 14 from cursor import CursorWidget |
15 from state import initial_state, handle_result | 15 from state import initial_state, handle_result |
16 from widgets import (MessageDialog, BoomButton, HandButton, PopupMenu, | 16 from widgets import (MessageDialog, BoomButton, HandButton, PopupMenu, |
17 PopupMenuButton) | 17 PopupMenuButton) |
18 | 18 |
68 | 68 |
69 def draw(self, surface): | 69 def draw(self, surface): |
70 self.state.draw(surface, self.screen) | 70 self.state.draw(surface, self.screen) |
71 | 71 |
72 def draw(self, surface): | 72 def draw(self, surface): |
73 if self.state.previous_scene and self.state.do_check == constants.LEAVE: | 73 if self.state.previous_scene and self.state.do_check == LEAVE: |
74 # We still need to handle leave events, so still display the scene | 74 # We still need to handle leave events, so still display the scene |
75 self.state.previous_scene.draw(surface, self) | 75 self.state.previous_scene.draw(surface, self) |
76 else: | 76 else: |
77 self.state.current_scene.draw(surface, self) | 77 self.state.current_scene.draw(surface, self) |
78 | 78 |
101 if not self.subwidgets: | 101 if not self.subwidgets: |
102 self._mouse_move(event.pos) | 102 self._mouse_move(event.pos) |
103 | 103 |
104 def _mouse_move(self, pos): | 104 def _mouse_move(self, pos): |
105 self.state.highlight_override = False | 105 self.state.highlight_override = False |
106 self.state.mouse_move(pos) | 106 self.state.current_scene.mouse_move(pos) |
107 self.state.old_pos = pos | |
107 | 108 |
108 def show_message(self, message, style=None): | 109 def show_message(self, message, style=None): |
109 # Display the message as a modal dialog | 110 # Display the message as a modal dialog |
110 MessageDialog(self.screen, message, 60, style=style).present() | 111 MessageDialog(self.screen, message, 60, style=style).present() |
111 # queue a redraw to show updated state | 112 # queue a redraw to show updated state |
179 def mouse_move(self, event): | 180 def mouse_move(self, event): |
180 self._mouse_move(event.pos) | 181 self._mouse_move(event.pos) |
181 | 182 |
182 def _mouse_move(self, pos): | 183 def _mouse_move(self, pos): |
183 self.state.highlight_override = False | 184 self.state.highlight_override = False |
184 self.state.mouse_move_detail(self.global_to_local(pos)) | 185 self.state.current_detail.mouse_move(self.global_to_local(pos)) |
185 | 186 |
186 def show_message(self, message, style=None): | 187 def show_message(self, message, style=None): |
187 self.parent.show_message(message, style) | 188 self.parent.show_message(message, style) |
188 self.invalidate() | 189 self.invalidate() |
189 | 190 |