Mercurial > boomslang
comparison pyntnclick/gamescreen.py @ 678:36d7f7e9650e pyntnclick
Modal magic. (And yes, it is quite magical.)
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Sun, 12 Feb 2012 21:47:06 +0200 |
parents | a8c42709a689 |
children | fa168b5e2624 |
comparison
equal
deleted
inserted
replaced
677:a8c42709a689 | 678:36d7f7e9650e |
---|---|
8 from pygame.locals import MOUSEBUTTONDOWN, MOUSEMOTION, KEYDOWN, K_ESCAPE | 8 from pygame.locals import MOUSEBUTTONDOWN, MOUSEMOTION, KEYDOWN, K_ESCAPE |
9 | 9 |
10 from pyntnclick.cursor import CursorScreen | 10 from pyntnclick.cursor import CursorScreen |
11 from pyntnclick.engine import Screen | 11 from pyntnclick.engine import Screen |
12 from pyntnclick.state import handle_result | 12 from pyntnclick.state import handle_result |
13 from pyntnclick.widgets.base import Container | 13 from pyntnclick.widgets.base import Container, ModalStackContainer |
14 from pyntnclick.widgets.text import TextButton | 14 from pyntnclick.widgets.text import TextButton, LabelWidget |
15 from pyntnclick.widgets.imagebutton import ImageButtonWidget | 15 from pyntnclick.widgets.imagebutton import ImageButtonWidget |
16 | 16 |
17 # XXX: Need a way to get at the constants. | 17 # XXX: Need a way to get at the constants. |
18 from pyntnclick.constants import GameConstants | 18 from pyntnclick.constants import GameConstants |
19 constants = GameConstants() | 19 constants = GameConstants() |
200 self.game.current_scene.mouse_move(event.pos) | 200 self.game.current_scene.mouse_move(event.pos) |
201 self.game.old_pos = event.pos | 201 self.game.old_pos = event.pos |
202 | 202 |
203 def show_message(self, message, style=None): | 203 def show_message(self, message, style=None): |
204 # Display the message as a modal dialog | 204 # Display the message as a modal dialog |
205 # self.screen.modal_magic.add(LabelWidget((50, 50), self.gd, message)) | |
205 print message | 206 print message |
206 # XXX: MessageDialog(self.screen, message, 60, style=style).present() | 207 # XXX: MessageDialog(self.screen, message, 60, style=style).present() |
207 # queue a redraw to show updated state | 208 # queue a redraw to show updated state |
208 # XXX: self.invalidate() | 209 # XXX: self.invalidate() |
209 # The cursor could have gone anywhere | 210 # The cursor could have gone anywhere |
357 elif event_name == 'inventory': | 358 elif event_name == 'inventory': |
358 self.inventory.update_slots() | 359 self.inventory.update_slots() |
359 | 360 |
360 def start_game(self): | 361 def start_game(self): |
361 self._clear_all() | 362 self._clear_all() |
363 self.modal_magic = self.container.add( | |
364 ModalStackContainer(self.container.rect.copy(), self.gd)) | |
365 self.inner_container = self.modal_magic.add( | |
366 Container(self.container.rect.copy(), self.gd)) | |
362 toolbar_height = self.gd.constants.button_size | 367 toolbar_height = self.gd.constants.button_size |
363 rect = Rect(0, 0, self.surface_size[0], | 368 rect = Rect(0, 0, self.surface_size[0], |
364 self.surface_size[1] - toolbar_height) | 369 self.surface_size[1] - toolbar_height) |
365 self.game = self.create_initial_state() | 370 self.game = self.create_initial_state() |
366 self.state_widget = StateWidget(rect, self.gd, self) | 371 self.state_widget = StateWidget(rect, self.gd, self) |
367 self.container.add(self.state_widget) | 372 self.inner_container.add(self.state_widget) |
368 | 373 |
369 self.toolbar = ToolBar((0, rect.height), self.gd, self) | 374 self.toolbar = ToolBar((0, rect.height), self.gd, self) |
370 self.inventory = self.toolbar.inventory | 375 self.inventory = self.toolbar.inventory |
371 self.container.add(self.toolbar) | 376 self.inner_container.add(self.toolbar) |
372 | 377 |
373 self.gd.running = True | 378 self.gd.running = True |
374 | 379 |
375 def animate(self): | 380 def animate(self): |
376 """Animate the state widget""" | 381 """Animate the state widget""" |