# HG changeset patch # User Jeremy Thurgood # Date 1282672150 -7200 # Node ID 0530547a131f10fa25c68fa480a08b0d85ccc314 # Parent 686bb74a52f8a1806fb4a72bf3e9ef45403731bd Better map handling, detail_view stuff in Result. diff -r 686bb74a52f8 -r 0530547a131f gamelib/gamescreen.py --- a/gamelib/gamescreen.py Tue Aug 24 19:22:01 2010 +0200 +++ b/gamelib/gamescreen.py Tue Aug 24 19:49:10 2010 +0200 @@ -15,7 +15,7 @@ from hand import HandButton from popupmenu import PopupMenu, PopupMenuButton from state import initial_state, Item - +from widgets import MessageDialog class InventoryView(PaletteView): @@ -78,6 +78,12 @@ if not self.subwidgets: self.state.mouse_move(event.pos) + def show_message(self, message): + # Display the message as a modal dialog + MessageDialog(message, 60).present() + # queue a redraw to show updated state + self.invalidate() + def show_detail(self, detail): w, h = self.state.set_current_detail(detail) self.detail.set_image_rect(Rect(0, 0, w, h)) diff -r 686bb74a52f8 -r 0530547a131f gamelib/scenes/cryo.py --- a/gamelib/scenes/cryo.py Tue Aug 24 19:22:01 2010 +0200 +++ b/gamelib/scenes/cryo.py Tue Aug 24 19:49:10 2010 +0200 @@ -49,8 +49,11 @@ NAME = "cryo.unit.1" INTERACTS = { - "unit": InteractRectUnion(((520, 430, 80, 50), (550, 470, 90, 60), - (600, 510, 60, 40))) + "unit": InteractRectUnion(( + (520, 430, 80, 50), + (550, 470, 90, 60), + (600, 510, 60, 40), + )) } INITIAL = "unit" diff -r 686bb74a52f8 -r 0530547a131f gamelib/scenes/map.py --- a/gamelib/scenes/map.py Tue Aug 24 19:22:01 2010 +0200 +++ b/gamelib/scenes/map.py Tue Aug 24 19:49:10 2010 +0200 @@ -40,8 +40,13 @@ def interact_without(self): """Go to destination.""" if self.DEST in self.state.scenes: - self.state.set_current_scene(self.DEST) - return Result("You head for the %s." % self.DEST) + if self.state.scenes[self.DEST].get_data('accessible'): + self.state.set_current_scene(self.DEST) + return Result() + else: + return Result("You can't go there right now.") + else: + return Result("You *could* go there, but it doesn't actually exist.") def check_dest(self): if self.DEST in self.state.scenes: diff -r 686bb74a52f8 -r 0530547a131f gamelib/state.py --- a/gamelib/state.py Tue Aug 24 19:22:01 2010 +0200 +++ b/gamelib/state.py Tue Aug 24 19:49:10 2010 +0200 @@ -2,7 +2,7 @@ from albow.resource import get_image from albow.utils import frame_rect -from widgets import BoomLabel, MessageDialog +from widgets import BoomLabel from pygame.locals import BLEND_ADD from pygame.rect import Rect from pygame.surface import Surface @@ -16,22 +16,21 @@ class Result(object): """Result of interacting with a thing""" - def __init__(self, message=None, soundfile=None): + def __init__(self, message=None, soundfile=None, detail_view=None): self.message = message self.sound = None if soundfile: self.sound = get_sound(soundfile) + self.detail_view = detail_view - def process(self, scene): + def process(self, scene_widget): """Helper function to do the right thing with a result object""" if self.sound: self.sound.play() if self.message: - # Display the message as a modal dialog - MessageDialog(self.message, 60).present() - # queue a redraw to show updated state - scene.invalidate() - + scene_widget.show_message(self.message) + if self.detail_view: + scene_widget.show_detail(self.detail_view) def initial_state(screen): """Load the initial state.""" @@ -491,7 +490,7 @@ return None def is_interactive(self): - return True + return self.current_interact is not None def enter(self, item): """Called when the cursor enters the Thing."""