from level.Level import Level from ui_elements.TextLabel import TextLabel class LevelMenu: def __init__(self, levels: [Level], x_pos: int, y_pos: int, width: float, height: float, column_count: 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.width = width self.height = height self.column_count = column_count 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): 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)) self.level_text_labels.append(text_label) if (index + 1) % self.column_count == 0: current_text_label_y += self.height / (len(self.levels) / self.column_count) current_text_label_x = self.x_pos else: current_text_label_x += self.width / self.column_count def extract_level(self): return self