self.__title_text = text
        self.__title_pos = ((self.size[0] - text.get_width()) // 2,
                            self.title_y_off)

    def __init_level_list(self):
        xs = [x['name'] for x in self.__level_info]
        self.__level_info = {a: b for a, b in zip(xs, self.__level_info)}
        drop_down = pygame_gui.elements.UIDropDownMenu(xs, xs[0],
                                                       self.level_list_rect,
                                                       self.gui_manager,
                                                       'expanded')
        self.register_gui_event_handler('ui_drop_down_menu_changed', drop_down,
                                        self.__list_event_handle)

    def __list_event_handle(self, event):
        level_name = event.text
        self.page_manager.replace(
            game_page.GamePage(self.page_manager,
                               self.__level_info[level_name]['map'],
                               level_name))

    def draw(self, window_surface):
        window_surface.blit(self.__background, (0, 0))
        window_surface.blit(self.__title_text, self.__title_pos)


if __name__ == '__main__':
    pm = PageManager(common.WIN_SIZE, 'level page')
    pm.push(LevelPage(pm))
    pm.run()
Exemple #2
0
        # setting button
        self.__setting_btn = pygame_gui.elements.UIButton(
            btn_rect[1], "设置", self.gui_manager)
        self.register_gui_event_handler(
            'ui_button_pressed',
            self.__setting_btn,
            lambda e: print('setting'))
        # map editor button
        self.__map_editor_btn = pygame_gui.elements.UIButton(
            btn_rect[2], "地图编辑", self.gui_manager)
        self.register_gui_event_handler(
            'ui_button_pressed',
            self.__map_editor_btn,
            lambda e: self.page_manager.push(EditorPage(self.page_manager)))
        # quit button
        self.__quit_btn = pygame_gui.elements.UIButton(
            btn_rect[3], "退出", self.gui_manager)
        self.register_gui_event_handler('ui_button_pressed',
                                        self.__quit_btn,
                                        lambda e: self.page_manager.pop())

    def draw(self, window_surface):
        window_surface.blit(self.__background, (0, 0))
        window_surface.blit(self.__title_text, self.__title_pos)


if __name__ == '__main__':
    page_manager = PageManager((808, 700), 'Hello')
    page_manager.push(StartPage(page_manager))
    page_manager.run()
            elif key in ("n"):
                # Move to next performer in the list
                next_performer = self.setlist.next()
                self.setlist.start(next_performer)
                self.update()
                return None
            elif key in ("a"):
                # Add a new performer
                ui = suggestion_ui.SuggestionUI(self.manager.pop_callback(self.signup), 
                    self.manager)
                self.manager.push(ui)
            else:
                return parent(size, key)

        return keypress

if __name__ == "__main__":
    # Create some example performers
    setlist = SetList()

    # for performer in [data.performer.Performer(name="Dominic Rout", email="", mobile = "213123123"),
    #     data.performer.Performer(name="Al G", email="*****@*****.**", mobile = "1234123412312"),
    #     data.performer.Performer(name="Al P", email="*****@*****.**", mobile = "12341231123412312")]:
    #     setlist.signup(performer)

    manager = PageManager()
    ui = SetListMenuUI(setlist, manager)
    manager.push(ui)
    ui.update_loop(manager.loop) 
    manager.run()
Exemple #4
0
                "name": "down",
                "object_id": "down_toolbox",
                "texture": "tools/down.png",
                "number": toolbox_num[1],
                "position": []
            },
            {
                "name": "left",
                "object_id": "left_toolbox",
                "texture": "tools/left.png",
                "number": toolbox_num[2],
                "position": []
            },
            {
                "name": "right",
                "object_id": "right_toolbox",
                "texture": "tools/right.png",
                "number": toolbox_num[3],
                "position": []
            },
        ]

        filename = 'config/%s.json' % map_name
        save_json(filename, map_now)


if __name__ == '__main__':
    pm1 = PageManager(common.WIN_SIZE, 'hello')
    pm1.push(EditorPage(pm1))
    pm1.run()