Add returing to level scene from roach management.
authorSimon Cross <hodgestar@gmail.com>
Sat, 5 Mar 2016 14:01:24 +0000 (16:01 +0200)
committerSimon Cross <hodgestar@gmail.com>
Sat, 5 Mar 2016 14:01:24 +0000 (16:01 +0200)
koperkapel/scenes/level.py
koperkapel/scenes/roach_management.py

index ebd87e120d3575ff795df1caa253fadab796ff5d..2ab32c83087fe15d1260fac9b28ca2a7bc322300 100644 (file)
@@ -162,7 +162,7 @@ class GameLevelScene(BaseLevelScene):
         elif key == keys.Z:
             # Vehicle management
             from .roach_management import RoachesScene
-            return[ChangeSceneEvent(RoachesScene())]
+            return[ChangeSceneEvent(RoachesScene(level_scene=self))]
         if offset:
             return [MoveViewportEvent(offset)]
         return super(GameLevelScene, self).on_key_down(key, mod, unicode)
index 9a356ac918c9f8932b49e135b85abd0262fac4ea..c0e82107a93ec56ed08059e8dba3a89bbaa56b3c 100644 (file)
@@ -29,8 +29,9 @@ def inset_button(pos, d):
 class RoachesScene(Scene):
     """ Roach management scene. """
 
-    def __init__(self):
+    def __init__(self, level_scene=None):
         super().__init__()
+        self._level_scene = level_scene
         self._vehicle = None
         self._seat_pos = 0
         self._outside_roach = None
@@ -216,9 +217,11 @@ class RoachesScene(Scene):
         return events
 
     def on_key_down(self, key, mod, unicode):
-        if key == keys.ESCAPE:
-            from .menu import MenuScene
-            return [ChangeSceneEvent(MenuScene())]
+        if key in (keys.ESCAPE, keys.Z):
+            if self._level_scene is None:
+                from .menu import MenuScene
+                return [ChangeSceneEvent(MenuScene())]
+            return [ChangeSceneEvent(self._level_scene)]
 
     def on_mouse_down(self, pos, button):
         if button == mouse.LEFT: