from abc import abstractmethod from level.selection.ScreenManager import ScreenManager from physics.SpriteManager import SpriteManager, DrawLayers from physics.TickData import TickData from sprite.SpritesheetManager import SpritesheetManager from ui_elements import CoordinateTransform from ui_elements.TextLabel import TextLabel from ui_elements.ClickEvent import ClickEvent class MainMenuScreenManager(ScreenManager): def __init__(self, sprite_manager: SpriteManager, spritesheet_manager: SpritesheetManager, main_loop): super().__init__(sprite_manager, spritesheet_manager, main_loop) def go_to_menu(self, click): if click.is_click_down(ClickEvent.CLICK_LEFT): self.main_loop.select_level_selection() def go_to_options_screen(self, click): if click.is_click_down(ClickEvent.CLICK_LEFT): self.main_loop.select_options() def initialize(self): size = CoordinateTransform.transform_screen_to_world(self.main_loop.window_size, self.main_loop.screen_transform) self.create_button("START", size[0] * 0.495, size[1] * 0.772, 38) self.create_button("SCREEN SIZE", 640, 430, 20) def create_button(self, name: str, x_position, y_position, font_size): label = TextLabel(name, x_position, y_position, font_size, alignment="center") label.bounding_box_margin = (10, 18) self.add_element(DrawLayers.UI, label) label.position_scale.scale = (1, 1) if name == "START": label.add_click_listener(lambda click: self.go_to_menu(click)) elif name == "SCREEN SIZE": label.add_click_listener(lambda click: self.go_to_options_screen(click)) def destroy(self): super().destroy()