changeset 436:6e1ad25a7db5

Hook up engine room computer console.
author Simon Cross <hodgestar+bzr@gmail.com>
date Sat, 28 Aug 2010 23:55:12 +0200
parents 19aff54b2e73
children cfcab3796410
files Resources/images/engine/ec_cryo_leaking.png Resources/images/engine/ec_cryo_reservoir_empty.png Resources/images/engine/ec_cryo_super_malfunction.png Resources/images/engine/engine_comp_detail.png gamelib/scenes/engine.py sources/art/engine_computer_detail.xcf
diffstat 6 files changed, 69 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
Binary file Resources/images/engine/ec_cryo_leaking.png has changed
Binary file Resources/images/engine/ec_cryo_reservoir_empty.png has changed
Binary file Resources/images/engine/ec_cryo_super_malfunction.png has changed
Binary file Resources/images/engine/engine_comp_detail.png has changed
--- a/gamelib/scenes/engine.py	Sat Aug 28 23:48:50 2010 +0200
+++ b/gamelib/scenes/engine.py	Sat Aug 28 23:55:12 2010 +0200
@@ -1,5 +1,6 @@
 """Engine room where things need to be repaired."""
 
+from albow.resource import get_image
 from gamelib.cursor import CursorSprite
 from gamelib.state import Scene, Item, Thing, Result
 from gamelib.scenes.scene_widgets import (Door, InteractText, InteractNoImage,
@@ -34,6 +35,7 @@
         self.add_thing(DangerSign())
         self.add_thing(Stars())
         self.add_thing(CrackedPipe())
+        self.add_thing(ComputerConsole())
         self.add_thing(ToMap())
         self.add_thing(GenericDescThing('engine.body', 1,
             "Dead. Those cans must have been past their sell-by date.",
@@ -48,12 +50,6 @@
                 (513, 330, 58, 50),
             )
         ))
-        self.add_thing(GenericDescThing('engine.computer_console', 3,
-            "A computer console. It seems dead.",
-            (
-                (293, 287, 39, 36),
-            )
-        ))
         self.add_thing(GenericDescThing('engine.superconductors', 4,
             "Superconductors. The engines must be power hogs.",
             (
@@ -63,7 +59,7 @@
             )
         ))
         self.add_thing(GenericDescThing('engine.floor_hole', 5,
-            "A gaping hole in the floor of the room. I'm guessing that's why there's a vacuum in here.",
+            "A gaping hole in the floor of the room. You're guessing that's why there's a vacuum in here.",
             (
                 (257, 493, 141, 55),
                 (301, 450, 95, 45),
@@ -457,6 +453,10 @@
     def is_interactive(self):
         return False
 
+    def get_description(self):
+        return "A gaping hole in the floor of the room. You're guessing" \
+            " that's why there's a vacuum in here."
+
 
 class CrackedPipe(Thing):
     NAME = "engine.cracked_pipe"
@@ -490,6 +490,67 @@
                           "creak, sealing it.")
 
 
+class ComputerConsole(Thing):
+    NAME = "engine.computer_console"
+
+    INTERACTS = {
+        'console': InteractNoImage(293, 287, 39, 36),
+    }
+
+    INITIAL = 'console'
+
+    def interact_without(self):
+        return Result(detail_view='engine_comp_detail')
+
+    def get_description(self):
+        return "A computer console. It's alarmingly close to the engine."
+
+
+class EngineCompDetail(Scene):
+
+    FOLDER = "engine"
+    BACKGROUND = "engine_comp_detail.png"
+    NAME = "engine_comp_detail"
+
+    SIZE = (640, 400)
+
+    ALERTS = {
+            'cryo leaking' : 'ec_cryo_leaking.png',
+            'cryo empty' : 'ec_cryo_reservoir_empty.png',
+            'super malfunction' : 'ec_cryo_super_malfunction.png',
+            }
+
+    # Point to start drawing changeable alerts
+    ALERT_OFFSET = (16, 100)
+    ALERT_SPACING = 4
+
+    def __init__(self, state):
+        super(EngineCompDetail, self).__init__(state)
+
+        self._alert_messages = {}
+        for key, name in self.ALERTS.iteritems():
+            self._alert_messages[key] = get_image(self.FOLDER, name)
+
+    def _draw_alerts(self, surface):
+        xpos, ypos = self.ALERT_OFFSET
+        if not self.state.scenes['engine'].things['engine.cracked_pipe'].get_data('fixed'):
+            image = self._alert_messages['cryo leaking']
+            surface.blit(image, (xpos, ypos))
+            ypos += image.get_size()[1] + self.ALERT_SPACING
+        if not self.state.scenes['engine'].things['engine.cryo_containers'].get_data('filled'):
+            image = self._alert_messages['cryo empty']
+            surface.blit(image, (xpos, ypos))
+            ypos += image.get_size()[1] + self.ALERT_SPACING
+        if not self.state.scenes['engine'].things['engine.superconductor'].get_data('working'):
+            image = self._alert_messages['super malfunction']
+            surface.blit(image, (xpos, ypos))
+            ypos += image.get_size()[1] + self.ALERT_SPACING
+
+    def draw_things(self, surface):
+        self._draw_alerts(surface)
+        super(EngineCompDetail, self).draw_things(surface)
+
+
 class ToMap(Door):
 
     SCENE = "engine"
@@ -505,3 +566,4 @@
 
 
 SCENES = [Engine]
+DETAIL_VIEWS = [EngineCompDetail]
Binary file sources/art/engine_computer_detail.xcf has changed