Fixed level selection

main
Skyball2000 2023-03-29 15:01:46 +02:00
parent e3927524c7
commit ebfa89e374
2 changed files with 53 additions and 4 deletions

View File

@ -77,9 +77,58 @@ class LevelSelectionScreenManager(ScreenManager):
label.set_text('') label.set_text('')
label.click_listeners = [] label.click_listeners = []
for id, level in enumerate(self.levels_by_theme[self.selected_theme]): levels = self.levels_by_theme[self.selected_theme]
self.level_labels[id].set_text(level.name)
self.level_labels[id].add_click_listener(lambda click: self.select_level(click, level)) if len(levels) > 0:
self.level_labels[0].set_text(levels[0].name)
self.level_labels[0].add_click_listener(
lambda click: self.select_level(click, levels[0])
)
if len(levels) > 1:
self.level_labels[1].set_text(levels[1].name)
self.level_labels[1].add_click_listener(
lambda click: self.select_level(click, levels[1])
)
if len(levels) > 2:
self.level_labels[2].set_text(levels[2].name)
self.level_labels[2].add_click_listener(
lambda click: self.select_level(click, levels[2])
)
if len(levels) > 3:
self.level_labels[3].set_text(levels[3].name)
self.level_labels[3].add_click_listener(
lambda click: self.select_level(click, levels[3])
)
if len(levels) > 4:
self.level_labels[4].set_text(levels[4].name)
self.level_labels[4].add_click_listener(
lambda click: self.select_level(click, levels[4])
)
if len(levels) > 5:
self.level_labels[5].set_text(levels[5].name)
self.level_labels[5].add_click_listener(
lambda click: self.select_level(click, levels[5])
)
if len(levels) > 6:
self.level_labels[6].set_text(levels[6].name)
self.level_labels[6].add_click_listener(
lambda click: self.select_level(click, levels[6])
)
if len(levels) > 7:
self.level_labels[7].set_text(levels[7].name)
self.level_labels[7].add_click_listener(
lambda click: self.select_level(click, levels[7])
)
if len(levels) > 8:
self.level_labels[8].set_text(levels[8].name)
self.level_labels[8].add_click_listener(
lambda click: self.select_level(click, levels[8])
)
if len(levels) > 9:
self.level_labels[9].set_text(levels[9].name)
self.level_labels[9].add_click_listener(
lambda click: self.select_level(click, levels[9])
)
def destroy(self): def destroy(self):
super().destroy() super().destroy()

View File

@ -138,7 +138,7 @@ class MainLoop:
for event in pygame_events: for event in pygame_events:
if event.type == pygame.QUIT: if event.type == pygame.QUIT:
pygame.quit() pygame.quit()
quit() exit()
self.screen.fill((0, 0, 0)) self.screen.fill((0, 0, 0))