Mercurial > boomslang
comparison gamelib/scenes/game_widgets.py @ 852:f95830b58336
Merge pyntnclick
author | Stefano Rivera <stefano@rivera.za.net> |
---|---|
date | Sat, 21 Jun 2014 22:04:35 +0200 |
parents | bdebe693453f |
children |
comparison
equal
deleted
inserted
replaced
546:ad4d6ffd25d7 | 852:f95830b58336 |
---|---|
1 """Generic, game specific widgets""" | 1 """Generic, game specific widgets""" |
2 | 2 |
3 | 3 |
4 from gamelib.state import Thing, Result | 4 from pyntnclick.i18n import _ |
5 from pyntnclick.state import Thing, Result | |
6 | |
7 from gamelib.custom_widgets import JimLabel | |
5 | 8 |
6 | 9 |
7 class Door(Thing): | 10 class Door(Thing): |
8 """A door somewhere""" | 11 """A door somewhere""" |
9 | 12 |
17 def is_interactive(self, tool=None): | 20 def is_interactive(self, tool=None): |
18 return True | 21 return True |
19 | 22 |
20 def interact_without(self): | 23 def interact_without(self): |
21 """Go to map.""" | 24 """Go to map.""" |
22 self.state.set_current_scene("map") | 25 self.game.change_scene("map") |
23 | 26 |
24 def get_description(self): | 27 def get_description(self): |
25 return 'An open doorway leads to the rest of the ship.' | 28 return _('An open doorway leads to the rest of the ship.') |
26 | 29 |
27 def interact_default(self, item): | 30 def interact_default(self, item): |
28 return self.interact_without() | 31 return self.interact_without() |
29 | 32 |
30 | 33 |
31 def make_jim_dialog(mesg, state): | 34 def make_jim_dialog(mesg, game): |
32 "Utility helper function" | 35 "Utility helper function" |
33 if state.scenes['bridge'].get_data('ai status') == 'online': | 36 if game.data.get_jim_state() == 'online': |
34 return Result(mesg, style='JIM') | 37 return Result(widget=JimLabel(game.gd, mesg)) |
35 else: | 38 else: |
36 return None | 39 return None |
40 | |
41 | |
42 def make_sentence_dialog(prisoner, game): | |
43 return make_jim_dialog( | |
44 _("Prisoner %(id)s, your total sentence is now %(sen)d years.") % { | |
45 "id": prisoner, 'sen': game.data.get_total_sentence()}, game) | |
37 | 46 |
38 | 47 |
39 class BaseCamera(Thing): | 48 class BaseCamera(Thing): |
40 "Base class for the camera puzzles" | 49 "Base class for the camera puzzles" |
41 | 50 |
43 INITIAL_DATA = { | 52 INITIAL_DATA = { |
44 'state': 'online', | 53 'state': 'online', |
45 } | 54 } |
46 | 55 |
47 def get_description(self): | 56 def get_description(self): |
48 status = self.state.scenes['bridge'].get_data('ai status') | 57 status = self.state.get_jim_state() |
49 if status == 'online': | 58 if status == 'online': |
50 return "A security camera watches over the room" | 59 return _("A security camera watches over the room") |
51 elif status == 'looping': | 60 elif status == 'looping': |
52 return "The security camera is currently offline but should be" \ | 61 return _("The security camera is currently offline but should be" |
53 " working soon" | 62 " working soon") |
54 else: | 63 else: |
55 return "The security camera is powered down" | 64 return _("The security camera is powered down") |
56 | 65 |
57 def is_interactive(self, tool=None): | 66 def is_interactive(self, tool=None): |
58 return self.state.scenes['bridge'].get_data('ai status') == 'online' | 67 return self.state.get_jim_state() == 'online' |
59 | 68 |
60 def interact_with_escher_poster(self, item): | 69 def interact_with_escher_poster(self, item): |
61 # Order matters here, because of helper function | 70 # Order matters here, because of helper function |
62 if self.state.scenes['bridge'].get_data('ai status') == 'online': | 71 if self.state.get_jim_state() == 'online': |
63 ai_response = make_jim_dialog("3D scene reconstruction failed." | 72 ai_response = make_jim_dialog(_("3D scene reconstruction failed." |
64 " Critical error. Entering emergency shutdown.", | 73 " Critical error." |
65 self.state) | 74 " Entering emergency shutdown."), |
66 self.state.scenes['bridge'].set_data('ai status', 'looping') | 75 self.game) |
76 self.game.data.loop_ai() | |
67 return ai_response | 77 return ai_response |
68 | 78 |
79 def select_interact(self): | |
80 if 'bridge' not in self.state: | |
81 # We aren't completely set up yet | |
82 return self.INITIAL | |
83 return self.state.get_jim_state() | |
84 | |
69 def animate(self): | 85 def animate(self): |
70 ai_status = self.state.scenes['bridge'].get_data('ai status') | 86 ai_status = self.state.get_jim_state() |
71 if ai_status != self.get_data('status'): | 87 if ai_status != self.get_data('status'): |
72 self.set_data('status', ai_status) | 88 self.set_data('status', ai_status) |
73 self.set_interact(ai_status) | 89 self.set_interact() |
74 super(BaseCamera, self).animate() | 90 super(BaseCamera, self).animate() |