comparison gamelib/gamescreen.py @ 139:a5972444ad1e

Improve cursor state handling, disable highlights on modal dialogs
author Stefano Rivera <stefano@rivera.za.net>
date Tue, 24 Aug 2010 22:02:22 +0200
parents 17411b984dc2
children 29ba5456e8b3
comparison
equal deleted inserted replaced
138:0fe0a91c4296 139:a5972444ad1e
77 def mouse_move(self, event): 77 def mouse_move(self, event):
78 if not self.subwidgets: 78 if not self.subwidgets:
79 self.state.mouse_move(event.pos) 79 self.state.mouse_move(event.pos)
80 80
81 def show_message(self, message): 81 def show_message(self, message):
82 self.parent.cursor_highlight(False)
82 # Display the message as a modal dialog 83 # Display the message as a modal dialog
83 MessageDialog(message, 60).present() 84 MessageDialog(message, 60).present()
84 # queue a redraw to show updated state 85 # queue a redraw to show updated state
85 self.invalidate() 86 self.invalidate()
87 # The cursor could have gone anywhere
88 self.state.current_scene.mouse_move(self.state.tool, mouse.get_pos())
86 89
87 def show_detail(self, detail): 90 def show_detail(self, detail):
88 w, h = self.state.set_current_detail(detail) 91 w, h = self.state.set_current_detail(detail)
89 self.detail.set_image_rect(Rect(0, 0, w, h)) 92 self.detail.set_image_rect(Rect(0, 0, w, h))
90 self.add_centered(self.detail) 93 self.add_centered(self.detail)
94 self.parent.cursor_highlight(False)
91 95
92 96
93 class DetailWindow(Widget): 97 class DetailWindow(Widget):
94 def __init__(self, state): 98 def __init__(self, state):
95 Widget.__init__(self) 99 Widget.__init__(self)
169 # PopMenu, which is annoying. 173 # PopMenu, which is annoying.
170 def hide_cmd(self): 174 def hide_cmd(self):
171 # This option does nothing, but the method needs to exist for albow 175 # This option does nothing, but the method needs to exist for albow
172 return 176 return
173 177
178 def enter_screen(self):
179 CursorWidget.enter_screen(self)
180
181 def leave_screen(self):
182 CursorWidget.leave_screen(self)
183
174 def main_menu_cmd(self): 184 def main_menu_cmd(self):
175 mouse.set_visible(1)
176 self.shell.show_screen(self.shell.menu_screen) 185 self.shell.show_screen(self.shell.menu_screen)
177 186
178 def quit_cmd(self): 187 def quit_cmd(self):
179 self.shell.quit() 188 self.shell.quit()
180 189
183 self.inventory.unselect() 192 self.inventory.unselect()
184 193
185 def begin_frame(self): 194 def begin_frame(self):
186 if self.running: 195 if self.running:
187 self.state_widget.animate() 196 self.state_widget.animate()
197
198 def mouse_delta(self, event):
199 CursorWidget.mouse_delta(self, event)
200 if not self.state_widget.rect.collidepoint(event.pos):
201 self.cursor_highlight(False)