From 0e3ff44e339e83cc26196e9fcd20193dbd65a46c Mon Sep 17 00:00:00 2001 From: Simon Cross Date: Sat, 5 Mar 2016 16:01:24 +0200 Subject: [PATCH] Add returing to level scene from roach management. --- koperkapel/scenes/level.py | 2 +- koperkapel/scenes/roach_management.py | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/koperkapel/scenes/level.py b/koperkapel/scenes/level.py index ebd87e1..2ab32c8 100644 --- a/koperkapel/scenes/level.py +++ b/koperkapel/scenes/level.py @@ -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) diff --git a/koperkapel/scenes/roach_management.py b/koperkapel/scenes/roach_management.py index 9a356ac..c0e8210 100644 --- a/koperkapel/scenes/roach_management.py +++ b/koperkapel/scenes/roach_management.py @@ -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: -- 2.34.1