add next steps for level menu

main
Mike 2023-03-28 10:13:03 +02:00
parent 4c66ff4a10
commit 417c28bd60
3 changed files with 14 additions and 5 deletions

View File

@ -18,7 +18,7 @@ from ui_elements.KeyManager import KeyManager
from ui_elements.LevelMenu import LevelMenu
from ui_elements.TextLabel import TextLabel
what_to_run = 'level'
what_to_run = 'menu'
def apply_frame_rate(number: float):
@ -77,8 +77,8 @@ if what_to_run == 'menu':
if event.type == pygame.QUIT:
pygame.quit()
quit()
elif event.type == pygame.MOUSEBUTTONDOWN:
generated_level.load_level(parsed_levels_manager.levels[0])
# elif event.type == pygame.MOUSEBUTTONDOWN:
# generated_level.load_level(parsed_levels_manager.levels[0])
screen.fill((0, 0, 0))
# level_menu.draw(screen, screen_transform)

View File

@ -1,4 +1,9 @@
import copy
import pygame
from level.Level import Level
from ui_elements.ClickEvent import ClickEvent
from ui_elements.TextLabel import TextLabel
@ -24,7 +29,7 @@ class LevelMenu:
text_label = TextLabel(level.name, current_text_label_x, current_text_label_y, 60)
text_label.position_scale.scale = (0.5, 0.5)
# text_label = TextLabel(self.extract_level(level.name), current_text_label_x, current_text_label_y, 35)
text_label.add_click_listener(lambda: self.level_select_listener(level))
text_label.add_click_listener(lambda click_event: self.handle_level_text_label_click(click_event, level))
self.level_text_labels.append(text_label)
if (index + 1) % self.column_count == 0:
@ -33,5 +38,9 @@ class LevelMenu:
else:
current_text_label_x += self.width / self.column_count
def handle_level_text_label_click(self, click_event: ClickEvent, level: Level):
if click_event.event.type == pygame.MOUSEBUTTONUP:
self.level_select_listener(level)
def extract_level(self):
return self

View File

@ -29,7 +29,7 @@ class UiElement:
def click(self, click_event):
for listener in self.click_listeners:
listener(self, click_event)
listener(click_event)
@abc.abstractmethod
def tick(self, tick_data: TickData):