diff --git a/project/level/selection/LevelScreenManager.py b/project/level/selection/LevelScreenManager.py index f8ef26a..86248cf 100644 --- a/project/level/selection/LevelScreenManager.py +++ b/project/level/selection/LevelScreenManager.py @@ -5,10 +5,11 @@ import pygame.time from level.Level import Level from level.elements.LoadedLevel import LoadedLevel from level.selection.ScreenManager import ScreenManager -from physics.SpriteManager import SpriteManager +from physics.SpriteManager import SpriteManager, DrawLayers from physics.TickData import TickData from sprite.SpritesheetManager import SpritesheetManager from ui_elements.KeyManager import KeyManager +from ui_elements.TextLabel import TextLabel class LevelScreenManager(ScreenManager): @@ -21,6 +22,11 @@ class LevelScreenManager(ScreenManager): self.loaded_level.level_screen_manager = self self.loaded_level.load_level(self.level) + self.back_button = TextLabel('BACK [ESC]', 635, 460, font_size=30) + self.back_button.position_scale.scale = (0.5, 0.5) + self.add_element(DrawLayers.UI, self.back_button) + self.back_button.add_click_listener(lambda click: self.back_to_level_selection()) + def initialize(self): pass @@ -30,8 +36,11 @@ class LevelScreenManager(ScreenManager): def tick(self, tick_data: TickData): if tick_data.key_manager.is_keymap_down(KeyManager.KEY_ESCAPE): - self.main_loop.select_level_selection(self.level.theme) - pygame.time.delay(200) + self.back_to_level_selection() + pygame.time.delay(250) + + def back_to_level_selection(self): + self.main_loop.select_level_selection(self.level.theme) def player_death(self): self.main_loop.player_death(self.level) diff --git a/project/level/selection/LevelSelectionScreenManager.py b/project/level/selection/LevelSelectionScreenManager.py index 0c069c2..a7818cd 100644 --- a/project/level/selection/LevelSelectionScreenManager.py +++ b/project/level/selection/LevelSelectionScreenManager.py @@ -64,6 +64,11 @@ class LevelSelectionScreenManager(ScreenManager): self.theme_label.position_scale.scale = (0.5, 0.5) self.add_element(DrawLayers.UI, self.theme_label) + self.back_button = TextLabel('BACK [ESC]', 610, 430, font_size=30) + self.back_button.position_scale.scale = (0.5, 0.5) + self.add_element(DrawLayers.UI, self.back_button) + self.back_button.add_click_listener(lambda click: self.main_loop.select_main_menu()) + for i in range(0, LABEL_COUNT): label = TextLabel(str(i), OFFSET[0] + 30, OFFSET[1] + 60 + i * 50, font_size=65) label.position_scale.scale = (0.5, 0.5) diff --git a/project/level/selection/OptionsScreenManager.py b/project/level/selection/OptionsScreenManager.py index 2f4b5f3..c0579e5 100644 --- a/project/level/selection/OptionsScreenManager.py +++ b/project/level/selection/OptionsScreenManager.py @@ -18,6 +18,11 @@ class OptionsScreenManager(ScreenManager): label.position_scale.scale = (1, 1) self.create_button(name, label) + self.back_button = TextLabel('BACK [ESC]', 610, 430, font_size=30) + self.back_button.position_scale.scale = (0.5, 0.5) + self.add_element(DrawLayers.UI, self.back_button) + self.back_button.add_click_listener(lambda click: self.main_loop.select_main_menu()) + def create_button(self, name: str, label: TextLabel): if name == "SMALL": label.add_click_listener(lambda click: self.make_small_screen(click))