Mercurial > pyntnclick
comparison gamelib/scenes/bridge.py @ 854:3577c51029f1 default tip
Remove Suspended Sentence. pyntnclick is the library we extracted from it
author | Stefano Rivera <stefano@rivera.za.net> |
---|---|
date | Sat, 21 Jun 2014 22:15:54 +0200 |
parents | f95830b58336 |
children |
comparison
equal
deleted
inserted
replaced
853:f95830b58336 | 854:3577c51029f1 |
---|---|
1 """Bridge where the final showdown with the AI occurs.""" | |
2 | |
3 import random | |
4 | |
5 from pygame.colordict import THECOLORS | |
6 from pygame.color import Color | |
7 from pygame.rect import Rect | |
8 | |
9 from pyntnclick.i18n import _ | |
10 from pyntnclick.utils import render_text | |
11 from pyntnclick.cursor import CursorSprite | |
12 from pyntnclick.state import Scene, Item, Thing, Result | |
13 from pyntnclick.scenewidgets import ( | |
14 InteractNoImage, InteractRectUnion, InteractImage, InteractAnimated, | |
15 GenericDescThing, TakeableThing, InteractText) | |
16 | |
17 from gamelib.scenes.game_constants import PLAYER_ID | |
18 from gamelib.scenes.game_widgets import Door, BaseCamera, make_jim_dialog | |
19 | |
20 | |
21 class Bridge(Scene): | |
22 | |
23 FOLDER = "bridge" | |
24 BACKGROUND = 'bridge.png' | |
25 | |
26 OFFSET = (0, -50) | |
27 | |
28 MUSIC = [ | |
29 'beep1.ogg', | |
30 'beep2.ogg', | |
31 'beep880.ogg', | |
32 'beep660.ogg', | |
33 'beep3.ogg', | |
34 'silent.ogg', | |
35 'creaking.ogg', | |
36 'silent.ogg', | |
37 ] | |
38 | |
39 INITIAL_DATA = { | |
40 'ai status': 'online', # online, looping, dead | |
41 'ai panel': 'closed', # closed, open, broken | |
42 } | |
43 | |
44 def setup(self): | |
45 self.background_playlist = None | |
46 self.add_item_factory(Superconductor) | |
47 self.add_item_factory(TapedSuperconductor) | |
48 self.add_item_factory(Stethoscope) | |
49 self.add_thing(ToMap()) | |
50 self.add_thing(MonitorCamera()) | |
51 self.add_thing(MassageChair()) | |
52 self.add_thing(MassageChairBase()) | |
53 self.add_thing(StethoscopeThing()) | |
54 self.add_thing(BridgeComputer()) | |
55 self.add_thing(LeftLights()) | |
56 self.add_thing(RightLights()) | |
57 self.add_thing(JimPanel()) | |
58 self.add_thing(StarField()) | |
59 self.add_thing(GenericDescThing('bridge.wires', 1, | |
60 _("The brightly coloured wires contrast with the drab walls."), | |
61 ((46, 4, 711, 143),))) | |
62 self.add_thing(GenericDescThing('bridge.note', 2, | |
63 _("\"Dammit JIM, I'm a doctor, not an engineer!\""), | |
64 ( | |
65 (491, 494, 194, 105), | |
66 (422, 533, 71, 66), | |
67 ))) | |
68 self.doctor = GenericDescThing('bridge.skel', 3, | |
69 _("A skeleton hangs improbably from the wires."), | |
70 ( | |
71 (632, 148, 40, 29), | |
72 (683, 176, 30, 101), | |
73 (652, 274, 45, 96), | |
74 (639, 180, 11, 95), | |
75 )) | |
76 self.add_thing(self.doctor) | |
77 | |
78 def enter(self): | |
79 pieces = [self.sound.get_music(x) for x in self.MUSIC] | |
80 self.background_playlist = self.sound.get_playlist(pieces, random=True, | |
81 repeat=True) | |
82 self.sound.change_playlist(self.background_playlist) | |
83 | |
84 def leave(self): | |
85 self.sound.change_playlist(None) | |
86 | |
87 | |
88 class ToMap(Door): | |
89 | |
90 SCENE = "bridge" | |
91 | |
92 INTERACTS = { | |
93 "door": InteractNoImage(707, 344, 84, 245), | |
94 } | |
95 | |
96 INITIAL = "door" | |
97 | |
98 | |
99 class BridgeComputer(Thing): | |
100 """The bridge computer. Gives status updates""" | |
101 | |
102 NAME = "bridge.comp" | |
103 | |
104 INTERACTS = { | |
105 'screen': InteractNoImage(338, 296, 123, 74), | |
106 } | |
107 | |
108 INITIAL = 'screen' | |
109 | |
110 def interact_without(self): | |
111 return Result(detail_view='bridge_comp_detail') | |
112 | |
113 def interact_with_titanium_leg(self, item): | |
114 return Result(_("You can't break the duraplastic screen.")) | |
115 | |
116 def interact_with_machete(self, item): | |
117 return Result(_("Scratching the screen won't help you.")) | |
118 | |
119 def get_description(self): | |
120 return _("The main bridge computer screen.") | |
121 | |
122 | |
123 class MassageChairBase(Thing): | |
124 "The captain's massage chair, contains superconductor" | |
125 | |
126 NAME = 'bridge.massagechair_base' | |
127 | |
128 INTERACTS = { | |
129 'chair': InteractNoImage(127, 518, 69, 64), | |
130 } | |
131 | |
132 INITIAL = 'chair' | |
133 | |
134 INITIAL_DATA = { | |
135 'contains_superconductor': True, | |
136 } | |
137 | |
138 def interact_without(self): | |
139 return Result(detail_view='chair_detail') | |
140 | |
141 def get_description(self): | |
142 if self.get_data('contains_superconductor'): | |
143 return _("A top of the line Massage-o-Matic Captain's Executive" | |
144 " Command Chair. It's massaging a skeleton.") | |
145 return _("The chair won't work any more, it has no power.") | |
146 | |
147 | |
148 class MassageChair(Thing): | |
149 "The captain's massage chair, contains superconductor" | |
150 | |
151 NAME = 'bridge.massagechair' | |
152 | |
153 INTERACTS = { | |
154 'chair': InteractRectUnion(( | |
155 (148, 418, 77, 68), | |
156 (69, 363, 80, 156), | |
157 (104, 514, 18, 40), | |
158 (147, 487, 106, 32), | |
159 (220, 518, 83, 49), | |
160 (196, 502, 75, 34), | |
161 (207, 534, 69, 51), | |
162 )), | |
163 } | |
164 | |
165 INITIAL = 'chair' | |
166 | |
167 def get_description(self): | |
168 base = self.game.get_current_scene().things['bridge.massagechair_base'] | |
169 return base.get_description() | |
170 | |
171 def is_interactive(self, tool=None): | |
172 return False | |
173 | |
174 | |
175 class Stethoscope(Item): | |
176 "Used for cracking safes. Found on the doctor on the chair" | |
177 | |
178 NAME = 'stethoscope' | |
179 INVENTORY_IMAGE = 'stethoscope.png' | |
180 CURSOR = CursorSprite('stethoscope.png') | |
181 | |
182 | |
183 class StethoscopeThing(TakeableThing): | |
184 "Stethoscope on the doctor" | |
185 | |
186 NAME = 'bridge.stethoscope' | |
187 | |
188 INTERACTS = { | |
189 'stethoscope': InteractImage(650, 178, 'hanging_stethoscope.png'), | |
190 } | |
191 | |
192 INITIAL = 'stethoscope' | |
193 ITEM = 'stethoscope' | |
194 | |
195 def get_description(self): | |
196 return _("A stethoscope hangs from the neck of the skeleton.") | |
197 | |
198 def interact_without(self): | |
199 self.take() | |
200 # Fill in the doctor's rect | |
201 self.scene.doctor.rect.append(self.rect) | |
202 return Result(_("You pick up the stethoscope and verify that the" | |
203 " doctor's heart has stopped. Probably a while ago.")) | |
204 | |
205 | |
206 class TapedSuperconductor(Item): | |
207 "Used for connecting high-powered parts of the ship up" | |
208 | |
209 NAME = 'taped_superconductor' | |
210 INVENTORY_IMAGE = 'superconductor_taped.png' | |
211 CURSOR = CursorSprite('superconductor_taped_cursor.png') | |
212 | |
213 | |
214 class Superconductor(Item): | |
215 "Used for connecting high-powered parts of the ship up" | |
216 | |
217 NAME = 'superconductor' | |
218 INVENTORY_IMAGE = 'superconductor_fixed.png' | |
219 CURSOR = CursorSprite('superconductor_fixed.png') | |
220 | |
221 def interact_with_duct_tape(self, item): | |
222 self.game.replace_inventory_item(self.name, 'taped_superconductor') | |
223 return Result(_("You rip off a piece of duct tape and stick it on the" | |
224 " superconductor. It almost sticks to itself, but you" | |
225 " successfully avoid disaster.")) | |
226 | |
227 | |
228 class SuperconductorThing(TakeableThing): | |
229 "Superconductor from the massage chair." | |
230 | |
231 NAME = 'bridge.superconductor' | |
232 | |
233 INTERACTS = { | |
234 'superconductor': InteractImage(158, 138, 'superconductor.png'), | |
235 } | |
236 | |
237 INITIAL = 'superconductor' | |
238 ITEM = 'superconductor' | |
239 | |
240 def interact_without(self): | |
241 self.game.scenes['bridge'].things['bridge.massagechair_base'] \ | |
242 .set_data('contains_superconductor', False) | |
243 self.take() | |
244 return (Result(_("The superconductor module unclips easily.")), | |
245 make_jim_dialog(_("Prisoner %s. That chair you've destroyed" | |
246 " was property of the ship's captain. " | |
247 "You will surely be punished.") | |
248 % PLAYER_ID, self.game)) | |
249 | |
250 | |
251 class StarField(Thing): | |
252 | |
253 NAME = 'bridge.stars' | |
254 | |
255 INTERACTS = { | |
256 #'stars' : InteractImage(190, 145, 'stars_3.png'), | |
257 'stars': InteractAnimated(190, 145, | |
258 ['stars_%d.png' % (i + 1) for i | |
259 in range(3) + range(1, 0, -1)], 30), | |
260 } | |
261 | |
262 INITIAL = 'stars' | |
263 | |
264 def is_interactive(self, tool=None): | |
265 return False | |
266 | |
267 | |
268 class BlinkingLights(Thing): | |
269 | |
270 def setup(self): | |
271 self.description = None | |
272 | |
273 def is_interactive(self, tool=None): | |
274 return False | |
275 | |
276 def leave(self): | |
277 self.description = random.choice([ | |
278 _("The lights flash in interesting patterns."), | |
279 _("The flashing lights don't mean anything to you."), | |
280 _("The console lights flash and flicker."), | |
281 ]) | |
282 | |
283 def get_description(self): | |
284 if not self.description: | |
285 self.leave() | |
286 return self.description | |
287 | |
288 | |
289 class LeftLights(BlinkingLights): | |
290 | |
291 NAME = 'bridge.lights.1' | |
292 | |
293 INTERACTS = { | |
294 "lights": InteractAnimated(176, 337, | |
295 ["bridge_lights_1_1.png", | |
296 "bridge_lights_1_2.png", | |
297 "bridge_lights_1_3.png", | |
298 "bridge_lights_1_2.png"], 5), | |
299 } | |
300 | |
301 INITIAL = 'lights' | |
302 | |
303 | |
304 class RightLights(BlinkingLights): | |
305 | |
306 NAME = 'bridge.lights.2' | |
307 | |
308 INTERACTS = { | |
309 "lights": InteractAnimated(559, 332, | |
310 ["bridge_lights_2_1.png", | |
311 "bridge_lights_2_2.png", | |
312 "bridge_lights_2_3.png", | |
313 "bridge_lights_2_2.png"], 5), | |
314 } | |
315 | |
316 INITIAL = 'lights' | |
317 | |
318 | |
319 class JimPanel(Thing): | |
320 "The panel to JIM's internals'" | |
321 | |
322 NAME = "jim_panel" | |
323 | |
324 INTERACTS = { | |
325 'closed': InteractNoImage(506, 430, 137, 47), | |
326 'open': InteractImage(500, 427, 'jim_panel_open.png'), | |
327 'broken': InteractImage(488, 412, 'jim_panel_destroyed.png'), | |
328 } | |
329 | |
330 INITIAL = 'closed' | |
331 | |
332 def get_description(self): | |
333 if self.scene.get_data('ai panel') == 'closed': | |
334 return _("The sign reads 'Warning: Authorized Techinicians Only'.") | |
335 | |
336 def select_interact(self): | |
337 status = self.scene.get_data('ai panel') | |
338 return status or self.INITIAL | |
339 | |
340 def interact_without(self): | |
341 ai_status = self.state.get_jim_state() | |
342 if ai_status == 'online': | |
343 return self.interact_default(None) | |
344 elif self.scene.get_data('ai panel') == 'closed': | |
345 return Result(_("You are unable to open the panel with your" | |
346 " bare hands.")) | |
347 elif self.scene.get_data('ai panel') == 'open': | |
348 self.scene.set_data('ai panel', 'broken') | |
349 self.state.break_ai() | |
350 self.set_interact() | |
351 return Result(_("You unplug various important-looking wires.")) | |
352 | |
353 def interact_with_machete(self, item): | |
354 ai_status = self.state.get_jim_state() | |
355 if ai_status == 'online': | |
356 return self.interact_default(item) | |
357 elif self.scene.get_data('ai panel') == 'closed': | |
358 self.scene.set_data('ai panel', 'open') | |
359 self.set_interact() | |
360 return Result(_("Using the machete, you lever the panel off.")) | |
361 elif self.scene.get_data('ai panel') == 'open': | |
362 self.scene.set_data('ai panel', 'broken') | |
363 self.state.break_ai() | |
364 self.set_interact() | |
365 return Result(_("You smash various delicate components with" | |
366 " the machete.")) | |
367 | |
368 def interact_default(self, item): | |
369 if self.state.get_jim_state() == 'online': | |
370 return (Result(_('You feel a shock from the panel.')), | |
371 make_jim_dialog(_("Prisoner %s. Please step away from the" | |
372 " panel. You are not an authorized" | |
373 " technician.") % PLAYER_ID, self.game)) | |
374 | |
375 | |
376 class ChairDetail(Scene): | |
377 | |
378 FOLDER = 'bridge' | |
379 BACKGROUND = 'chair_detail.png' | |
380 NAME = 'chair_detail' | |
381 | |
382 def setup(self): | |
383 self.add_thing(SuperconductorThing()) | |
384 | |
385 | |
386 # classes related the computer detail | |
387 | |
388 | |
389 class LogTab(Thing): | |
390 """Tab for log screen""" | |
391 | |
392 NAME = 'bridge_comp.screen' | |
393 | |
394 INTERACTS = { | |
395 'log tab': InteractText(100, 53, 94, 37, _("Logs"), | |
396 'lightgreen', 20, 'DejaVuSans-Bold.ttf', True), | |
397 } | |
398 INITIAL = 'log tab' | |
399 COMPUTER = 'bridge_comp_detail' | |
400 | |
401 def is_interactive(self, tool=None): | |
402 return self.game.detail_views[self.COMPUTER].get_data('tab') != 'log' | |
403 | |
404 def interact_without(self): | |
405 self.game.detail_views[self.COMPUTER].set_data('tab', 'log') | |
406 self.game.detail_views[self.COMPUTER].set_background() | |
407 return Result(soundfile='beep550.ogg') | |
408 | |
409 | |
410 class AlertTab(Thing): | |
411 """Tab for alert screen""" | |
412 | |
413 NAME = 'bridge_comp.alert_tab' | |
414 | |
415 INTERACTS = { | |
416 'alert tab': InteractText(12, 53, 88, 37, _("Alerts"), | |
417 'orange', 20, 'DejaVuSans-Bold.ttf', True), | |
418 } | |
419 INITIAL = 'alert tab' | |
420 COMPUTER = 'bridge_comp_detail' | |
421 | |
422 def is_interactive(self, tool=None): | |
423 return (self.game.detail_views[self.COMPUTER].get_data('tab') | |
424 != 'alert') | |
425 | |
426 def interact_without(self): | |
427 self.game.detail_views[self.COMPUTER].set_data('tab', 'alert') | |
428 self.game.detail_views[self.COMPUTER].set_background() | |
429 return Result(soundfile='beep550.ogg') | |
430 | |
431 | |
432 class NavTab(Thing): | |
433 """Tab for the Navigation screen""" | |
434 | |
435 NAME = 'bridge_comp.nav_tab' | |
436 | |
437 INTERACTS = { | |
438 'nav tab': InteractText(197, 53, 126, 37, _("Navigation"), | |
439 'darkblue', 20, 'DejaVuSans-Bold.ttf', True), | |
440 } | |
441 INITIAL = 'nav tab' | |
442 COMPUTER = 'bridge_comp_detail' | |
443 | |
444 def is_interactive(self, tool=None): | |
445 return self.game.detail_views[self.COMPUTER].get_data('tab') != 'nav' | |
446 | |
447 def interact_without(self): | |
448 self.game.detail_views[self.COMPUTER].set_data('tab', 'nav') | |
449 self.game.detail_views[self.COMPUTER].set_background() | |
450 return Result(soundfile='beep550.ogg') | |
451 | |
452 | |
453 class DestNavPageLine(Thing): | |
454 """The destination navigation lines.""" | |
455 | |
456 INITIAL = 'line' | |
457 COMPUTER = 'bridge_comp_detail' | |
458 | |
459 def __init__(self, number, rect, ai_blocked, dest): | |
460 super(DestNavPageLine, self).__init__() | |
461 self.name = 'bridge_comp.nav_line%s' % number | |
462 # set debugging higlight color for when DEBUG is on. | |
463 self._interact_hilight_color = Color(THECOLORS.keys()[number]) | |
464 r = Rect(rect) | |
465 # We dynamically generate the interact rect here. | |
466 self.interacts = {} | |
467 self.interacts['line'] = InteractText(r.x, r.y, r.w, r.h, | |
468 dest, 'darkblue', 16, 'DejaVuSans-Bold.ttf', False) | |
469 # Whether JIM blocks this | |
470 self.ai_blocked = ai_blocked | |
471 self.set_interact() | |
472 | |
473 def is_interactive(self, tool=None): | |
474 return self.game.detail_views[self.COMPUTER].get_data('tab') == 'nav' | |
475 | |
476 def interact_without(self): | |
477 if self.game.scenes['bridge'].get_data('ai status') == 'online': | |
478 return make_jim_dialog(_("You are not authorized to change the" | |
479 " destination."), self.game) | |
480 if not self.ai_blocked: | |
481 return Result(_("There's no good reason to choose to go to the" | |
482 " penal colony.")) | |
483 if self.game.scenes['bridge'].get_data('ai status') == 'looping': | |
484 return Result(_("You could change the destination, but when JIM" | |
485 " recovers, it'll just get reset.")) | |
486 if self.game.scenes['bridge'].get_data('ai status') == 'dead': | |
487 return Result(_("You change the destination."), | |
488 soundfile="beep550.ogg", end_game=True) | |
489 | |
490 | |
491 class CompUpButton(Thing): | |
492 """Up button on log screen""" | |
493 | |
494 NAME = 'bridge_comp.up_button' | |
495 | |
496 INTERACTS = { | |
497 'up': InteractNoImage(594, 82, 30, 58), | |
498 } | |
499 INITIAL = 'up' | |
500 COMPUTER = 'bridge_comp_detail' | |
501 | |
502 def is_interactive(self, tool=None): | |
503 tab = self.game.detail_views[self.COMPUTER].get_data('tab') | |
504 page = self.game.detail_views[self.COMPUTER].get_data('log page') | |
505 return tab == 'log' and page > 0 | |
506 | |
507 def interact_without(self): | |
508 page = self.game.detail_views[self.COMPUTER].get_data('log page') | |
509 self.game.detail_views[self.COMPUTER].set_data('log page', page - 1) | |
510 self.game.detail_views[self.COMPUTER].set_background() | |
511 return Result(soundfile='beep550.ogg') | |
512 | |
513 | |
514 class CompDownButton(Thing): | |
515 """Down button on log screen""" | |
516 | |
517 NAME = 'bridge_comp.down_button' | |
518 | |
519 INTERACTS = { | |
520 'down': InteractNoImage(594, 293, 30, 58), | |
521 } | |
522 INITIAL = 'down' | |
523 COMPUTER = 'bridge_comp_detail' | |
524 | |
525 def is_interactive(self, tool=None): | |
526 tab = self.game.detail_views[self.COMPUTER].get_data('tab') | |
527 page = self.game.detail_views[self.COMPUTER].get_data('log page') | |
528 max_page = self.game.detail_views[self.COMPUTER].get_data('max page') | |
529 return tab == 'log' and (page + 1) < max_page | |
530 | |
531 def interact_without(self): | |
532 page = self.game.detail_views[self.COMPUTER].get_data('log page') | |
533 self.game.detail_views[self.COMPUTER].set_data('log page', page + 1) | |
534 self.game.detail_views[self.COMPUTER].set_background() | |
535 return Result(soundfile='beep550.ogg') | |
536 | |
537 | |
538 class MonitorCamera(BaseCamera): | |
539 "A camera on the bridge" | |
540 | |
541 NAME = "bridge.camera" | |
542 | |
543 INTERACTS = { | |
544 'online': InteractImage(33, 192, 'camera_small.png'), | |
545 'dead': InteractImage(33, 192, 'camera_small_gray.png'), | |
546 'looping': InteractAnimated(33, 192, ('camera_small.png', | |
547 'camera_small_gray.png'), | |
548 15), | |
549 } | |
550 | |
551 | |
552 class BridgeCompDetail(Scene): | |
553 | |
554 FOLDER = 'bridge' | |
555 NAME = 'bridge_comp_detail' | |
556 | |
557 ALERT_BASE = 'comp_alert_base.png' | |
558 ALERTS = { | |
559 'hull breach': _("Hull breach detected: Engine Room"), | |
560 'ai looping': _("AI Status: 3D scene reconstruction failed." | |
561 " Recovery in progress"), | |
562 'ai offline': _("AI System Offline"), | |
563 'engine offline': _("Engine Offline"), | |
564 'life support': _("Life Support System: 20% operational"), | |
565 'life support partial': _("Life Support System: 40% operational"), | |
566 } | |
567 | |
568 # Point to start drawing changeable alerts | |
569 ALERT_OFFSET = (16, 100) | |
570 ALERT_SPACING = 4 | |
571 | |
572 LOG_BACKGROUND = 'comp_log_start.png' | |
573 | |
574 LOGS = [_("<Error: Log corrupted. Unable to open Log>")] | |
575 | |
576 NAVIGATION = 'bridge_nav_base.png' | |
577 | |
578 NAV_MESSAGES = { | |
579 'engine offline': [ | |
580 _("Engine Offline: Navigation Disabled")], | |
581 'life support': [ | |
582 _("Life Support Marginal."), | |
583 _("Emergency Navigation Protocol Engaged."), | |
584 '', | |
585 _("Destination locked to:"), | |
586 _("Bounty Penal Colony Space Port, New South Australia")], | |
587 } | |
588 | |
589 BACKGROUND = ALERT_BASE | |
590 | |
591 INITIAL_DATA = { | |
592 'tab': 'alert', | |
593 'log page': 0, | |
594 'max page': len(LOGS), | |
595 } | |
596 | |
597 def setup(self): | |
598 self.add_thing(LogTab()) | |
599 self.add_thing(AlertTab()) | |
600 self.add_thing(NavTab()) | |
601 #self.add_thing(CompUpButton()) | |
602 #self.add_thing(CompDownButton()) | |
603 self._scene_playlist = None | |
604 self._alert = self.get_image(self.FOLDER, self.ALERT_BASE) | |
605 self._alert_messages = {} | |
606 self._nav_messages = {} | |
607 for key, text in self.ALERTS.iteritems(): | |
608 self._alert_messages[key] = render_text(text, | |
609 'DejaVuSans-Bold.ttf', 18, 'orange', (0, 0, 0, 0), | |
610 self.resource, (600, 25), False) | |
611 self._nav_background = self.get_image(self.FOLDER, self.NAVIGATION) | |
612 #for key, name in self.NAVIGATION.iteritems(): | |
613 # self._nav_messages[key] = self.get_image(self.FOLDER, name) | |
614 self._nav_lines = [] | |
615 self._nav_lines.append(DestNavPageLine(1, (12, 99, 610, 25), False, | |
616 _("1. Bounty Penal Colony Space Port, New South Australia" | |
617 " (397 days)"))) | |
618 self._nav_lines.append(DestNavPageLine(2, (12, 135, 610, 25), True, | |
619 _("2. Hedonia Space Station (782 days)"))) | |
620 self._nav_lines.append(DestNavPageLine(3, (12, 167, 610, 25), True, | |
621 _("3. Spinosa Health Resort, Prunus Secundus (1231 days)"))) | |
622 self._nav_lines.append(DestNavPageLine(4, (12, 203, 610, 25), True, | |
623 _("4. Achene Space Port, Indica Prspinosame (1621 days)"))) | |
624 self._nav_lines.append(DestNavPageLine(5, (12, 239, 610, 25), True, | |
625 _("5. Opioid Space Port, Gelatinosa Prime (1963 days)"))) | |
626 self._log_background = self.get_image(self.FOLDER, self.LOG_BACKGROUND) | |
627 self._logs = [] | |
628 for text in self.LOGS: | |
629 log_page = self._log_background.copy() | |
630 log_page.blit(render_text(text, 'DejaVuSans-Bold.ttf', 18, | |
631 'lightgreen', (0, 0, 0, 0), self.resource, (600, 25), False), | |
632 self.ALERT_OFFSET) | |
633 self._logs.append(log_page) | |
634 | |
635 def enter(self): | |
636 self._scene_playlist = self.sound.get_current_playlist() | |
637 self.sound.change_playlist(None) | |
638 self.set_background() | |
639 | |
640 def leave(self): | |
641 self.sound.change_playlist(self._scene_playlist) | |
642 | |
643 def set_background(self): | |
644 if self.get_data('tab') == 'alert': | |
645 self._clear_navigation() | |
646 self._background = self._alert.copy() | |
647 self._draw_alerts() | |
648 elif self.get_data('tab') == 'log': | |
649 self._clear_navigation() | |
650 self._background = self._logs[self.get_data('log page')].copy() | |
651 elif self.get_data('tab') == 'nav': | |
652 self._background = self._get_nav_page() | |
653 | |
654 def _clear_navigation(self): | |
655 "Remove navigation things if necessary" | |
656 for thing in self._nav_lines: | |
657 if thing.name in self.things.keys(): | |
658 # Much fiddling to do the right thing when we reinsert it | |
659 del self.things[thing.name] | |
660 thing.scene = None | |
661 | |
662 def _draw_nav_text(self, key): | |
663 surface = self._nav_background.copy() | |
664 xpos, ypos = self.ALERT_OFFSET | |
665 for line in self.NAV_MESSAGES[key]: | |
666 text = render_text(line, 'DejaVuSans-Bold.ttf', 18, | |
667 'darkblue', (0, 0, 0, 0), self.resource, (600, 25), False) | |
668 surface.blit(text, (xpos, ypos)) | |
669 ypos = ypos + text.get_height() + self.ALERT_SPACING | |
670 return surface | |
671 | |
672 def _get_nav_page(self): | |
673 if not self.game.scenes['engine'].get_data('engine online'): | |
674 return self._draw_nav_text('engine offline') | |
675 elif (not self.game.scenes['mess'].get_data('life support status') | |
676 == 'fixed'): | |
677 return self._draw_nav_text('life support') | |
678 else: | |
679 for thing in self._nav_lines: | |
680 if thing.name not in self.things: | |
681 self.add_thing(thing) | |
682 return self._nav_background.copy() | |
683 | |
684 def _draw_alerts(self): | |
685 xpos, ypos = self.ALERT_OFFSET | |
686 self._background.blit(self._alert_messages['hull breach'], | |
687 (xpos, ypos)) | |
688 ypos += (self._alert_messages['hull breach'].get_size()[1] | |
689 + self.ALERT_SPACING) | |
690 if self.game.scenes['bridge'].get_data('ai status') == 'looping': | |
691 self._background.blit(self._alert_messages['ai looping'], | |
692 (xpos, ypos)) | |
693 ypos += (self._alert_messages['ai looping'].get_size()[1] | |
694 + self.ALERT_SPACING) | |
695 if self.game.scenes['bridge'].get_data('ai status') == 'dead': | |
696 self._background.blit(self._alert_messages['ai offline'], | |
697 (xpos, ypos)) | |
698 ypos += (self._alert_messages['ai offline'].get_size()[1] | |
699 + self.ALERT_SPACING) | |
700 if not self.game.scenes['engine'].get_data('engine online'): | |
701 self._background.blit(self._alert_messages['engine offline'], | |
702 (xpos, ypos)) | |
703 ypos += (self._alert_messages['engine offline'].get_size()[1] | |
704 + self.ALERT_SPACING) | |
705 if (self.game.scenes['mess'].get_data('life support status') | |
706 == 'broken'): | |
707 self._background.blit(self._alert_messages['life support'], | |
708 (xpos, ypos)) | |
709 ypos += (self._alert_messages['life support'].get_size()[1] | |
710 + self.ALERT_SPACING) | |
711 if (self.game.scenes['mess'].get_data('life support status') | |
712 == 'replaced'): | |
713 self._background.blit(self._alert_messages['life support partial'], | |
714 (xpos, ypos)) | |
715 ypos += (self._alert_messages['life support partial'].get_size()[1] | |
716 + self.ALERT_SPACING) | |
717 | |
718 | |
719 SCENES = [Bridge] | |
720 DETAIL_VIEWS = [ChairDetail, BridgeCompDetail] |