Mercurial > boomslang
view gamelib/scenes/game_widgets.py @ 765:2f1952748cdb i18n
merge i18n and Russian translation
author | Stefano Rivera <stefano@rivera.za.net> |
---|---|
date | Tue, 08 Mar 2011 14:37:43 +0200 |
parents | 821b322e903b |
children | 43b49f1de828 |
line wrap: on
line source
"""Generic, game specific widgets""" from gamelib.i18n import _ from gamelib.state import Thing, Result class Door(Thing): """A door somewhere""" DEST = "map" SCENE = None def __init__(self): self.NAME = self.SCENE + '.door' Thing.__init__(self) def is_interactive(self, tool=None): return True def interact_without(self): """Go to map.""" self.state.set_current_scene("map") def get_description(self): return _('An open doorway leads to the rest of the ship.') def interact_default(self, item): return self.interact_without() def make_jim_dialog(mesg, state): "Utility helper function" if state.scenes['bridge'].get_data('ai status') == 'online': return Result(mesg, style='JIM') else: return None class BaseCamera(Thing): "Base class for the camera puzzles" INITIAL = 'online' INITIAL_DATA = { 'state': 'online', } def get_description(self): status = self.state.scenes['bridge'].get_data('ai status') if status == 'online': return _("A security camera watches over the room") elif status == 'looping': return _("The security camera is currently offline but should be working soon") else: return _("The security camera is powered down") def is_interactive(self, tool=None): return self.state.scenes['bridge'].get_data('ai status') == 'online' def interact_with_escher_poster(self, item): # Order matters here, because of helper function if self.state.scenes['bridge'].get_data('ai status') == 'online': ai_response = make_jim_dialog(_("3D scene reconstruction failed. Critical error. Entering emergency shutdown."), self.state) self.state.scenes['bridge'].set_data('ai status', 'looping') return ai_response def animate(self): ai_status = self.state.scenes['bridge'].get_data('ai status') if ai_status != self.get_data('status'): self.set_data('status', ai_status) self.set_interact(ai_status) super(BaseCamera, self).animate()