Mercurial > boomslang
comparison gamelib/scenes/bridge.py @ 840:f5f998fb698f pyntnclick
More textification
author | Neil Muller <neil@dip.sun.ac.za> |
---|---|
date | Wed, 30 Jan 2013 13:39:21 +0200 |
parents | e81facd05e00 |
children | 985e5fbb61f1 |
comparison
equal
deleted
inserted
replaced
839:99e1e67f3916 | 840:f5f998fb698f |
---|---|
5 from pygame.colordict import THECOLORS | 5 from pygame.colordict import THECOLORS |
6 from pygame.color import Color | 6 from pygame.color import Color |
7 from pygame.rect import Rect | 7 from pygame.rect import Rect |
8 | 8 |
9 from pyntnclick.i18n import _ | 9 from pyntnclick.i18n import _ |
10 from pyntnclick.utils import render_text | |
10 from pyntnclick.cursor import CursorSprite | 11 from pyntnclick.cursor import CursorSprite |
11 from pyntnclick.state import Scene, Item, Thing, Result | 12 from pyntnclick.state import Scene, Item, Thing, Result |
12 from pyntnclick.scenewidgets import ( | 13 from pyntnclick.scenewidgets import ( |
13 InteractNoImage, InteractRectUnion, InteractImage, InteractAnimated, | 14 InteractNoImage, InteractRectUnion, InteractImage, InteractAnimated, |
14 GenericDescThing, TakeableThing, InteractText) | 15 GenericDescThing, TakeableThing, InteractText) |
389 """Tab for log screen""" | 390 """Tab for log screen""" |
390 | 391 |
391 NAME = 'bridge_comp.screen' | 392 NAME = 'bridge_comp.screen' |
392 | 393 |
393 INTERACTS = { | 394 INTERACTS = { |
394 'log tab': InteractNoImage(100, 53, 94, 37), | 395 'log tab': InteractText(100, 53, 94, 37, _("Logs"), |
396 'lightgreen', 20, 'DejaVuSans-Bold.ttf', True), | |
395 } | 397 } |
396 INITIAL = 'log tab' | 398 INITIAL = 'log tab' |
397 COMPUTER = 'bridge_comp_detail' | 399 COMPUTER = 'bridge_comp_detail' |
398 | 400 |
399 def is_interactive(self, tool=None): | 401 def is_interactive(self, tool=None): |
409 """Tab for alert screen""" | 411 """Tab for alert screen""" |
410 | 412 |
411 NAME = 'bridge_comp.alert_tab' | 413 NAME = 'bridge_comp.alert_tab' |
412 | 414 |
413 INTERACTS = { | 415 INTERACTS = { |
414 'alert tab': InteractNoImage(12, 53, 88, 37), | 416 'alert tab': InteractText(12, 53, 88, 37, _("Alerts"), |
417 'orange', 20, 'DejaVuSans-Bold.ttf', True), | |
415 } | 418 } |
416 INITIAL = 'alert tab' | 419 INITIAL = 'alert tab' |
417 COMPUTER = 'bridge_comp_detail' | 420 COMPUTER = 'bridge_comp_detail' |
418 | 421 |
419 def is_interactive(self, tool=None): | 422 def is_interactive(self, tool=None): |
430 """Tab for the Navigation screen""" | 433 """Tab for the Navigation screen""" |
431 | 434 |
432 NAME = 'bridge_comp.nav_tab' | 435 NAME = 'bridge_comp.nav_tab' |
433 | 436 |
434 INTERACTS = { | 437 INTERACTS = { |
435 'nav tab': InteractNoImage(197, 53, 126, 37), | 438 'nav tab': InteractText(197, 53, 126, 37, _("Navigation"), |
439 'darkblue', 20, 'DejaVuSans-Bold.ttf', True), | |
436 } | 440 } |
437 INITIAL = 'nav tab' | 441 INITIAL = 'nav tab' |
438 COMPUTER = 'bridge_comp_detail' | 442 COMPUTER = 'bridge_comp_detail' |
439 | 443 |
440 def is_interactive(self, tool=None): | 444 def is_interactive(self, tool=None): |
550 FOLDER = 'bridge' | 554 FOLDER = 'bridge' |
551 NAME = 'bridge_comp_detail' | 555 NAME = 'bridge_comp_detail' |
552 | 556 |
553 ALERT_BASE = 'comp_alert_base.png' | 557 ALERT_BASE = 'comp_alert_base.png' |
554 ALERTS = { | 558 ALERTS = { |
555 'ai looping': 'comp_alert_ai_looping.png', | 559 'hull breach': _("Hull breach detected: Engine Room"), |
556 'ai offline': 'comp_alert_ai_offline.png', | 560 'ai looping': _("AI Status: 3D scene reconstruction failed." |
557 'engine offline': 'comp_alert_engine_offline.png', | 561 " Recovery in progress"), |
558 'life support': 'comp_alert_life_support.png', | 562 'ai offline': _("AI System Offline"), |
559 'life support partial': 'comp_alert_life_support_partial.png', | 563 'engine offline': _("Engine Offline"), |
564 'life support': _("Life Support System: 20% operational"), | |
565 'life support partial': _("Life Support System: 40% operational"), | |
560 } | 566 } |
561 | 567 |
562 # Point to start drawing changeable alerts | 568 # Point to start drawing changeable alerts |
563 ALERT_OFFSET = (16, 140) | 569 ALERT_OFFSET = (16, 100) |
564 ALERT_SPACING = 4 | 570 ALERT_SPACING = 4 |
565 | 571 |
566 LOGS = ['comp_log_start.png', 'comp_log_1.png', | 572 LOGS = ['comp_log_start.png', 'comp_log_1.png', |
567 'comp_log_end.png'] | 573 'comp_log_end.png'] |
568 | 574 |
569 NAVIGATION = { | 575 NAVIGATION = 'bridge_nav_base.png' |
576 | |
577 NAV_MESSAGES = { | |
570 'engine offline': 'bridge_nav_engine.png', | 578 'engine offline': 'bridge_nav_engine.png', |
571 'life support': 'bridge_nav_life_support.png', | 579 'life support': 'bridge_nav_life_support.png', |
572 'final': 'bridge_nav_dest.png', | |
573 } | 580 } |
574 | 581 |
575 BACKGROUND = ALERT_BASE | 582 BACKGROUND = ALERT_BASE |
576 | 583 |
577 INITIAL_DATA = { | 584 INITIAL_DATA = { |
588 #self.add_thing(CompDownButton()) | 595 #self.add_thing(CompDownButton()) |
589 self._scene_playlist = None | 596 self._scene_playlist = None |
590 self._alert = self.get_image(self.FOLDER, self.ALERT_BASE) | 597 self._alert = self.get_image(self.FOLDER, self.ALERT_BASE) |
591 self._alert_messages = {} | 598 self._alert_messages = {} |
592 self._nav_messages = {} | 599 self._nav_messages = {} |
593 for key, name in self.ALERTS.iteritems(): | 600 for key, text in self.ALERTS.iteritems(): |
594 self._alert_messages[key] = self.get_image(self.FOLDER, name) | 601 self._alert_messages[key] = render_text(text, 'DejaVuSans-Bold.ttf', |
595 for key, name in self.NAVIGATION.iteritems(): | 602 18, 'orange', (0, 0, 0, 0), self.resource, (600, 25), False) |
596 self._nav_messages[key] = self.get_image(self.FOLDER, name) | 603 self._nav_background = self.get_image(self.FOLDER, self.NAVIGATION) |
604 #for key, name in self.NAVIGATION.iteritems(): | |
605 # self._nav_messages[key] = self.get_image(self.FOLDER, name) | |
597 self._nav_lines = [] | 606 self._nav_lines = [] |
598 self._nav_lines.append(DestNavPageLine(1, (12, 99, 610, 25), False, | 607 self._nav_lines.append(DestNavPageLine(1, (12, 99, 610, 25), False, |
599 _("1. Bounty Penal Colony Space Port, New South Australia" | 608 _("1. Bounty Penal Colony Space Port, New South Australia" |
600 " (397 days)"))) | 609 " (397 days)"))) |
601 self._nav_lines.append(DestNavPageLine(2, (12, 135, 610, 25), True, | 610 self._nav_lines.append(DestNavPageLine(2, (12, 135, 610, 25), True, |
617 self.sound.change_playlist(self._scene_playlist) | 626 self.sound.change_playlist(self._scene_playlist) |
618 | 627 |
619 def set_background(self): | 628 def set_background(self): |
620 if self.get_data('tab') == 'alert': | 629 if self.get_data('tab') == 'alert': |
621 self._clear_navigation() | 630 self._clear_navigation() |
622 self._background = self._alert | 631 self._background = self._alert.copy() |
632 self._draw_alerts() | |
623 elif self.get_data('tab') == 'log': | 633 elif self.get_data('tab') == 'log': |
624 self._clear_navigation() | 634 self._clear_navigation() |
625 self._background = self._logs[self.get_data('log page')] | 635 self._background = self._logs[self.get_data('log page')].copy() |
636 self._draw_log() | |
626 elif self.get_data('tab') == 'nav': | 637 elif self.get_data('tab') == 'nav': |
627 self._background = self._get_nav_page() | 638 self._background = self._get_nav_page() |
639 | |
640 def _draw_log(self): | |
641 """Add the log contents to the page""" | |
642 pass | |
628 | 643 |
629 def _clear_navigation(self): | 644 def _clear_navigation(self): |
630 "Remove navigation things if necessary" | 645 "Remove navigation things if necessary" |
631 for thing in self._nav_lines: | 646 for thing in self._nav_lines: |
632 if thing.name in self.things.keys(): | 647 if thing.name in self.things.keys(): |
634 del self.things[thing.name] | 649 del self.things[thing.name] |
635 thing.scene = None | 650 thing.scene = None |
636 | 651 |
637 def _get_nav_page(self): | 652 def _get_nav_page(self): |
638 if not self.game.scenes['engine'].get_data('engine online'): | 653 if not self.game.scenes['engine'].get_data('engine online'): |
639 return self._nav_messages['engine offline'] | 654 return self._nav_background.copy() |
640 elif (not self.game.scenes['mess'].get_data('life support status') | 655 elif (not self.game.scenes['mess'].get_data('life support status') |
641 == 'fixed'): | 656 == 'fixed'): |
642 return self._nav_messages['life support'] | 657 return self._nav_background.copy() |
643 else: | 658 else: |
644 for thing in self._nav_lines: | 659 for thing in self._nav_lines: |
645 if thing.name not in self.things: | 660 if thing.name not in self.things: |
646 self.add_thing(thing) | 661 self.add_thing(thing) |
647 return self._nav_messages['final'] | 662 return self._nav_background.copy() |
648 | 663 |
649 def _draw_alerts(self, surface): | 664 def _draw_alerts(self): |
650 xpos, ypos = self.ALERT_OFFSET | 665 xpos, ypos = self.ALERT_OFFSET |
666 self._background.blit(self._alert_messages['hull breach'], | |
667 (xpos, ypos)) | |
668 ypos += (self._alert_messages['hull breach'].get_size()[1] | |
669 + self.ALERT_SPACING) | |
651 if self.game.scenes['bridge'].get_data('ai status') == 'looping': | 670 if self.game.scenes['bridge'].get_data('ai status') == 'looping': |
652 surface.blit(self._alert_messages['ai looping'], (xpos, ypos)) | 671 self._background.blit(self._alert_messages['ai looping'], |
672 (xpos, ypos)) | |
653 ypos += (self._alert_messages['ai looping'].get_size()[1] | 673 ypos += (self._alert_messages['ai looping'].get_size()[1] |
654 + self.ALERT_SPACING) | 674 + self.ALERT_SPACING) |
655 if self.game.scenes['bridge'].get_data('ai status') == 'dead': | 675 if self.game.scenes['bridge'].get_data('ai status') == 'dead': |
656 surface.blit(self._alert_messages['ai offline'], (xpos, ypos)) | 676 self._background.blit(self._alert_messages['ai offline'], |
677 (xpos, ypos)) | |
657 ypos += (self._alert_messages['ai offline'].get_size()[1] | 678 ypos += (self._alert_messages['ai offline'].get_size()[1] |
658 + self.ALERT_SPACING) | 679 + self.ALERT_SPACING) |
659 if not self.game.scenes['engine'].get_data('engine online'): | 680 if not self.game.scenes['engine'].get_data('engine online'): |
660 surface.blit(self._alert_messages['engine offline'], (xpos, ypos)) | 681 self._background.blit(self._alert_messages['engine offline'], (xpos, ypos)) |
661 ypos += (self._alert_messages['engine offline'].get_size()[1] | 682 ypos += (self._alert_messages['engine offline'].get_size()[1] |
662 + self.ALERT_SPACING) | 683 + self.ALERT_SPACING) |
663 if (self.game.scenes['mess'].get_data('life support status') | 684 if (self.game.scenes['mess'].get_data('life support status') |
664 == 'broken'): | 685 == 'broken'): |
665 surface.blit(self._alert_messages['life support'], (xpos, ypos)) | 686 self._background.blit(self._alert_messages['life support'], |
687 (xpos, ypos)) | |
666 ypos += (self._alert_messages['life support'].get_size()[1] | 688 ypos += (self._alert_messages['life support'].get_size()[1] |
667 + self.ALERT_SPACING) | 689 + self.ALERT_SPACING) |
668 if (self.game.scenes['mess'].get_data('life support status') | 690 if (self.game.scenes['mess'].get_data('life support status') |
669 == 'replaced'): | 691 == 'replaced'): |
670 surface.blit(self._alert_messages['life support partial'], | 692 self._background.blit(self._alert_messages['life support partial'], |
671 (xpos, ypos)) | 693 (xpos, ypos)) |
672 ypos += (self._alert_messages['life support partial'].get_size()[1] | 694 ypos += (self._alert_messages['life support partial'].get_size()[1] |
673 + self.ALERT_SPACING) | 695 + self.ALERT_SPACING) |
674 | 696 |
675 def draw_things(self, surface): | |
676 if self.get_data('tab') == 'alert': | |
677 self._draw_alerts(surface) | |
678 super(BridgeCompDetail, self).draw_things(surface) | |
679 | |
680 | 697 |
681 SCENES = [Bridge] | 698 SCENES = [Bridge] |
682 DETAIL_VIEWS = [ChairDetail, BridgeCompDetail] | 699 DETAIL_VIEWS = [ChairDetail, BridgeCompDetail] |