from level.Level import Level from ui_elements.TextLabel import TextLabel class LevelMenu: def __init__(self, levels: [Level], x_pos: int, y_pos: int): self.levels = levels self.x_pos = x_pos self.y_pos = y_pos self.level_select_listener = lambda selected_level: None self.level_text_labels = [] self.create_level_text_labels() def create_level_text_labels(self): current_text_label_x = self.x_pos current_text_label_y = self.y_pos for index, level in enumerate(self.levels): # name=extraxt_level(level.name) text_label = TextLabel(level.name, current_text_label_x, current_text_label_y, 35) text_label.add_click_listener(lambda: self.level_select_listener(level)) if (index + 1) % 3 == 0: current_text_label_y += text_label.current_height + text_label.current_height / 4 current_text_label_x = self.x_pos else: current_text_label_x += text_label.current_width + text_label.current_width / 3 self.level_text_labels.append(text_label) if current_text_label_x % 10 != 0: current_text_label_x = current_text_label_x + current_text_label_x % 10 # menu_labels.append(text_label) def extract_level(name): return name