2023-03-29 10:45:48 +02:00
|
|
|
from abc import abstractmethod
|
|
|
|
|
|
|
|
from level.selection.ScreenManager import ScreenManager
|
2023-03-29 14:59:37 +02:00
|
|
|
from physics.SpriteManager import SpriteManager, DrawLayers
|
|
|
|
from physics.TickData import TickData
|
2023-03-29 10:45:48 +02:00
|
|
|
from sprite.SpritesheetManager import SpritesheetManager
|
2023-03-29 14:59:37 +02:00
|
|
|
from ui_elements import CoordinateTransform
|
|
|
|
from ui_elements.TextLabel import TextLabel
|
|
|
|
from ui_elements.ClickEvent import ClickEvent
|
2023-03-29 10:45:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
class MainMenuScreenManager(ScreenManager):
|
2023-03-29 14:59:37 +02:00
|
|
|
def __init__(self, sprite_manager: SpriteManager, spritesheet_manager: SpritesheetManager, main_loop):
|
2023-03-29 10:45:48 +02:00
|
|
|
super().__init__(sprite_manager, spritesheet_manager, main_loop)
|
|
|
|
|
2023-03-29 14:59:37 +02:00
|
|
|
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):
|
2023-03-29 15:59:51 +02:00
|
|
|
if click.is_click_down(ClickEvent.CLICK_LEFT):
|
|
|
|
self.main_loop.select_options()
|
2023-03-29 14:59:37 +02:00
|
|
|
|
2023-03-29 10:45:48 +02:00
|
|
|
def initialize(self):
|
2023-03-29 14:59:37 +02:00
|
|
|
size = CoordinateTransform.transform_screen_to_world(self.main_loop.window_size, self.main_loop.screen_transform)
|
|
|
|
|
2023-03-29 17:34:18 +02:00
|
|
|
self.create_button("START", size[0] * 0.495, size[1] * 0.772, 38)
|
2023-03-29 17:52:46 +02:00
|
|
|
self.create_button("SCREEN SIZE", 640, 430, 20)
|
2023-03-29 14:59:37 +02:00
|
|
|
|
2023-03-29 15:59:51 +02:00
|
|
|
def create_button(self, name: str, x_position, y_position, font_size):
|
|
|
|
label = TextLabel(name, x_position, y_position, font_size, alignment="center")
|
2023-03-29 14:59:37 +02:00
|
|
|
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))
|
2023-03-29 15:59:51 +02:00
|
|
|
elif name == "SCREEN SIZE":
|
2023-03-29 14:59:37 +02:00
|
|
|
label.add_click_listener(lambda click: self.go_to_options_screen(click))
|
2023-03-29 10:45:48 +02:00
|
|
|
|
|
|
|
def destroy(self):
|
|
|
|
super().destroy()
|