comparison gamelib/scenes/bridge.py @ 478:a9925aaf5f61 1.0.1

i18n and Russian translation
author Stefano Rivera <stefano@rivera.za.net>
date Tue, 08 Mar 2011 12:29:14 +0200
parents c72946d3a59a
children 2f1952748cdb
comparison
equal deleted inserted replaced
477:51055400a9a8 478:a9925aaf5f61
16 from gamelib.scenes.game_constants import PLAYER_ID 16 from gamelib.scenes.game_constants import PLAYER_ID
17 from gamelib.scenes.scene_widgets import (Door, InteractText, InteractNoImage, 17 from gamelib.scenes.scene_widgets import (Door, InteractText, InteractNoImage,
18 InteractRectUnion, InteractImage, 18 InteractRectUnion, InteractImage,
19 InteractAnimated, GenericDescThing, 19 InteractAnimated, GenericDescThing,
20 BaseCamera, make_jim_dialog) 20 BaseCamera, make_jim_dialog)
21 from gamelib.i18n import _
21 22
22 23
23 class Bridge(Scene): 24 class Bridge(Scene):
24 25
25 FOLDER = "bridge" 26 FOLDER = "bridge"
57 self.add_thing(LeftLights()) 58 self.add_thing(LeftLights())
58 self.add_thing(RightLights()) 59 self.add_thing(RightLights())
59 self.add_thing(JimPanel()) 60 self.add_thing(JimPanel())
60 self.add_thing(StarField()) 61 self.add_thing(StarField())
61 self.add_thing(GenericDescThing('bridge.wires', 1, 62 self.add_thing(GenericDescThing('bridge.wires', 1,
62 "The brightly coloured wires contrast with the drab walls.", 63 _("The brightly coloured wires contrast with the drab walls."),
63 ((46, 4, 711, 143),))) 64 ((46, 4, 711, 143),)))
64 self.add_thing(GenericDescThing('bridge.note', 2, 65 self.add_thing(GenericDescThing('bridge.note', 2,
65 "\"Dammit JIM, I'm a doctor, not an engineer!\"", 66 _("\"Dammit JIM, I'm a doctor, not an engineer!\""),
66 ( 67 (
67 (491, 494, 194, 105), 68 (491, 494, 194, 105),
68 (422, 533, 71, 66), 69 (422, 533, 71, 66),
69 ))) 70 )))
70 self.doctor = GenericDescThing('bridge.skel', 3, 71 self.doctor = GenericDescThing('bridge.skel', 3,
71 "A skeleton hangs improbably from the wires.", 72 _("A skeleton hangs improbably from the wires."),
72 ( 73 (
73 (632, 148, 40, 29), 74 (632, 148, 40, 29),
74 (683, 176, 30, 101), 75 (683, 176, 30, 101),
75 (652, 274, 45, 96), 76 (652, 274, 45, 96),
76 (639, 180, 11, 95), 77 (639, 180, 11, 95),
111 112
112 def interact_without(self): 113 def interact_without(self):
113 return Result(detail_view='bridge_comp_detail') 114 return Result(detail_view='bridge_comp_detail')
114 115
115 def interact_with_titanium_leg(self, item): 116 def interact_with_titanium_leg(self, item):
116 return Result("You can't break the duraplastic screen.") 117 return Result(_("You can't break the duraplastic screen."))
117 118
118 def interact_with_machete(self, item): 119 def interact_with_machete(self, item):
119 return Result("Scratching the screen won't help you.") 120 return Result(_("Scratching the screen won't help you."))
120 121
121 def get_description(self): 122 def get_description(self):
122 return "The main bridge computer screen." 123 return _("The main bridge computer screen.")
123 124
124 125
125 class MassageChairBase(Thing): 126 class MassageChairBase(Thing):
126 "The captain's massage chair, contains superconductor" 127 "The captain's massage chair, contains superconductor"
127 128
140 def interact_without(self): 141 def interact_without(self):
141 return Result(detail_view='chair_detail') 142 return Result(detail_view='chair_detail')
142 143
143 def get_description(self): 144 def get_description(self):
144 if self.get_data('contains_superconductor'): 145 if self.get_data('contains_superconductor'):
145 return "A top of the line Massage-o-Matic Captain's Executive Command Chair. " \ 146 return _("A top of the line Massage-o-Matic Captain's Executive Command Chair. " \
146 "It's massaging a skeleton." 147 "It's massaging a skeleton.")
147 return "The chair won't work any more, it has no power." 148 return _("The chair won't work any more, it has no power.")
148 149
149 150
150 class MassageChair(Thing): 151 class MassageChair(Thing):
151 "The captain's massage chair, contains superconductor" 152 "The captain's massage chair, contains superconductor"
152 153
191 } 192 }
192 193
193 INITIAL = 'stethoscope' 194 INITIAL = 'stethoscope'
194 195
195 def get_description(self): 196 def get_description(self):
196 return "A stethoscope hangs from the neck of the skeleton." 197 return _("A stethoscope hangs from the neck of the skeleton.")
197 198
198 def interact_without(self): 199 def interact_without(self):
199 self.state.add_inventory_item('stethoscope') 200 self.state.add_inventory_item('stethoscope')
200 self.scene.remove_thing(self) 201 self.scene.remove_thing(self)
201 # Fill in the doctor's rect 202 # Fill in the doctor's rect
202 self.scene.doctor.rect.append(self.rect) 203 self.scene.doctor.rect.append(self.rect)
203 return Result("You pick up the stethoscope and verify that the doctor's " 204 return Result(_("You pick up the stethoscope and verify that the doctor's "
204 "heart has stopped. Probably a while ago.") 205 "heart has stopped. Probably a while ago."))
205 206
206 207
207 class TapedSuperconductor(Item): 208 class TapedSuperconductor(Item):
208 "Used for connecting high-powered parts of the ship up" 209 "Used for connecting high-powered parts of the ship up"
209 210
219 220
220 def interact_with_duct_tape(self, item, state): 221 def interact_with_duct_tape(self, item, state):
221 taped_superconductor = TapedSuperconductor('taped_superconductor') 222 taped_superconductor = TapedSuperconductor('taped_superconductor')
222 state.add_item(taped_superconductor) 223 state.add_item(taped_superconductor)
223 state.replace_inventory_item(self.name, taped_superconductor.name) 224 state.replace_inventory_item(self.name, taped_superconductor.name)
224 return Result("You rip off a piece of duct tape and stick it on the superconductor. " 225 return Result(_("You rip off a piece of duct tape and stick it on the superconductor. "
225 "It almost sticks to itself, but you successfully avoid disaster.") 226 "It almost sticks to itself, but you successfully avoid disaster."))
226 227
227 228
228 class SuperconductorThing(Thing): 229 class SuperconductorThing(Thing):
229 "Superconductor from the massage chair." 230 "Superconductor from the massage chair."
230 231
239 def interact_without(self): 240 def interact_without(self):
240 self.state.add_inventory_item('superconductor') 241 self.state.add_inventory_item('superconductor')
241 self.state.current_scene.things['bridge.massagechair_base'] \ 242 self.state.current_scene.things['bridge.massagechair_base'] \
242 .set_data('contains_superconductor', False) 243 .set_data('contains_superconductor', False)
243 self.scene.remove_thing(self) 244 self.scene.remove_thing(self)
244 return (Result("The superconductor module unclips easily."), 245 return (Result(_("The superconductor module unclips easily.")),
245 make_jim_dialog(("Prisoner %s. That chair you've destroyed was " 246 make_jim_dialog(_("Prisoner %s. That chair you've destroyed was "
246 "property of the ship's captain. " 247 "property of the ship's captain. "
247 "You will surely be punished." 248 "You will surely be punished."
248 ) % PLAYER_ID, self.state)) 249 ) % PLAYER_ID, self.state))
249 250
250 class StarField(Thing): 251 class StarField(Thing):
272 def is_interactive(self): 273 def is_interactive(self):
273 return False 274 return False
274 275
275 def leave(self): 276 def leave(self):
276 self.description = random.choice([ 277 self.description = random.choice([
277 "The lights flash in interesting patterns.", 278 _("The lights flash in interesting patterns."),
278 "The flashing lights don't mean anything to you.", 279 _("The flashing lights don't mean anything to you."),
279 "The console lights flash and flicker.", 280 _("The console lights flash and flicker."),
280 ]) 281 ])
281 282
282 def get_description(self): 283 def get_description(self):
283 if not self.description: 284 if not self.description:
284 self.leave() 285 self.leave()
317 318
318 INITIAL = 'closed' 319 INITIAL = 'closed'
319 320
320 def get_description(self): 321 def get_description(self):
321 if self.scene.get_data('ai panel') == 'closed': 322 if self.scene.get_data('ai panel') == 'closed':
322 return "The sign reads 'Warning: Authorized Techinicians Only'." 323 return _("The sign reads 'Warning: Authorized Techinicians Only'.")
323 324
324 def interact_without(self): 325 def interact_without(self):
325 if self.scene.get_data('ai status') == 'online': 326 if self.scene.get_data('ai status') == 'online':
326 return self.interact_default(None) 327 return self.interact_default(None)
327 elif self.scene.get_data('ai panel') == 'closed': 328 elif self.scene.get_data('ai panel') == 'closed':
328 return Result("You are unable to open the panel with your bare hands.") 329 return Result(_("You are unable to open the panel with your bare hands."))
329 elif self.scene.get_data('ai panel') == 'open': 330 elif self.scene.get_data('ai panel') == 'open':
330 self.scene.set_data('ai panel', 'broken') 331 self.scene.set_data('ai panel', 'broken')
331 self.scene.set_data('ai status', 'dead') 332 self.scene.set_data('ai status', 'dead')
332 self.set_interact('broken') 333 self.set_interact('broken')
333 return Result("You unplug various important-looking wires.") 334 return Result(_("You unplug various important-looking wires."))
334 335
335 336
336 def interact_with_machete(self, item): 337 def interact_with_machete(self, item):
337 if self.scene.get_data('ai status') == 'online': 338 if self.scene.get_data('ai status') == 'online':
338 return self.interact_default(item) 339 return self.interact_default(item)
339 elif self.scene.get_data('ai panel') == 'closed': 340 elif self.scene.get_data('ai panel') == 'closed':
340 self.scene.set_data('ai panel', 'open') 341 self.scene.set_data('ai panel', 'open')
341 self.set_interact('open') 342 self.set_interact('open')
342 return Result("Using the machete, you lever the panel off.") 343 return Result(_("Using the machete, you lever the panel off."))
343 elif self.scene.get_data('ai panel') == 'open': 344 elif self.scene.get_data('ai panel') == 'open':
344 self.scene.set_data('ai panel', 'broken') 345 self.scene.set_data('ai panel', 'broken')
345 self.scene.set_data('ai status', 'dead') 346 self.scene.set_data('ai status', 'dead')
346 self.set_interact('broken') 347 self.set_interact('broken')
347 return Result("You smash various delicate components with the machete.") 348 return Result(_("You smash various delicate components with the machete."))
348 349
349 def interact_default(self, item): 350 def interact_default(self, item):
350 if self.scene.get_data('ai status') == 'online': 351 if self.scene.get_data('ai status') == 'online':
351 return (Result('You feel a shock from the panel.'), 352 return (Result(_('You feel a shock from the panel.')),
352 make_jim_dialog("Prisoner %s. Please step away from the panel. " 353 make_jim_dialog(_("Prisoner %s. Please step away from the panel. "
353 "You are not an authorized technician." % PLAYER_ID, self.state)) 354 "You are not an authorized technician.") % PLAYER_ID, self.state))
354 355
355 class ChairDetail(Scene): 356 class ChairDetail(Scene):
356 357
357 FOLDER = 'bridge' 358 FOLDER = 'bridge'
358 BACKGROUND = 'chair_detail.png' 359 BACKGROUND = 'chair_detail.png'
447 def is_interactive(self): 448 def is_interactive(self):
448 return self.state.detail_views[self.COMPUTER].get_data('tab') == 'nav' 449 return self.state.detail_views[self.COMPUTER].get_data('tab') == 'nav'
449 450
450 def interact_without(self): 451 def interact_without(self):
451 if self.state.scenes['bridge'].get_data('ai status') == 'online': 452 if self.state.scenes['bridge'].get_data('ai status') == 'online':
452 return make_jim_dialog("You are not authorized to change the destination.", self.state) 453 return make_jim_dialog(_("You are not authorized to change the destination."), self.state)
453 if not self.ai_blocked: 454 if not self.ai_blocked:
454 return Result("There's no good reason to choose to go to the penal colony.") 455 return Result(_("There's no good reason to choose to go to the penal colony."))
455 if self.state.scenes['bridge'].get_data('ai status') == 'looping': 456 if self.state.scenes['bridge'].get_data('ai status') == 'looping':
456 return Result("You could change the destination, but when JIM recovers, it'll just get reset.") 457 return Result(_("You could change the destination, but when JIM recovers, it'll just get reset."))
457 if self.state.scenes['bridge'].get_data('ai status') == 'dead': 458 if self.state.scenes['bridge'].get_data('ai status') == 'dead':
458 return Result("You change the destination.", soundfile="beep550.ogg", end_game=True) 459 return Result(_("You change the destination."), soundfile="beep550.ogg", end_game=True)
459 460
460 class CompUpButton(Thing): 461 class CompUpButton(Thing):
461 """Up button on log screen""" 462 """Up button on log screen"""
462 463
463 NAME = 'bridge_comp.up_button' 464 NAME = 'bridge_comp.up_button'