예제 #1
0
파일: buttons.py 프로젝트: gcali/crucipixel
def main():
    main_window = MainWindow(title="Grid buttons")
    root = Root()
    root.set_main_window(main_window)
    root.set_min_size(100, 100)

    grid_buttons = OrderedButtons([["Save", "Edit"], ["Load"]])

    def action():
        grid_buttons.next_visible(0)
    grid_buttons.set_action(0, 0, click_left_button_wrapper(action))
    grid_buttons.set_action(0, 1, click_left_button_wrapper(action))

    root.set_child(SetAlignment(SetAlignment(grid_buttons, Alignment.RIGHT), Alignment.VERTICAL_CENTER))

    main_window.start_main()
예제 #2
0
파일: main.py 프로젝트: gcali/crucipixel
 def load_model(index: int) -> None:
     model = models[index]
     core_crucipixel = core.Crucipixel(model)
     puzzle_screen = PuzzleScreen(min_size=(500, 500))
     puzzle_screen.translate(.5, .5)
     puzzle_screen.start_all(core_crucipixel)
     puzzle_screen.set_quit_button_callback(click_left_button_wrapper(create_new_game(root)))
     root.set_child(puzzle_screen)
예제 #3
0
파일: main.py 프로젝트: gcali/crucipixel
    def new_game() -> None:
        models = sorted(storage.get_models(), key=lambda m: (len(m.scheme.rows) * len(m.scheme.cols)))
        chooser = ChooserTable([scheme_to_entry(model.scheme)
                                for model in models])
        chooser.set_contents_callback(create_load_model(root, models))
        chooser.set_back_callback(click_left_button_wrapper(create_main_menu(root)))

        chooser.translate(50, 50)
        root.set_child(chooser)
예제 #4
0
    def start_all(self, crucipixel: core.Crucipixel):
        self.start_crucipixel(crucipixel)
        self.start_zoom()
        self.start_selector()
        # self.start_navigator()
        self.start_buttons()
        self.buttons.on_save_action = click_left_button_wrapper(lambda: self.crucipixel.save())
        self.buttons.on_load_action = click_left_button_wrapper(lambda: self.crucipixel.load())
        self.buttons.on_undo_action = click_left_button_wrapper(lambda: self.crucipixel.undo())

        def create_lambda(index):
            return lambda button: self.crucipixel.handle_selector(index, button)

        for i in range(3):
            self.selector.set_click_action(
                i,
                create_lambda(i)
            )

        overlay = TextOverlay("PUZZLE SOLVED")

        def overlay_action():
            overlay.visible = False
        overlay.on_click_action = overlay_action
        self.add(overlay, top=-10)

        def update_win_status(is_won: bool):
            if is_won:
                overlay.visible = True
                self.grid.visible = True
                self.crucipixel.visible = False
                self.crucipixel.grid.victory_screen = True
                self.buttons.set_edit()
            else:
                self.grid.visible = False
                self.crucipixel.visible = True
                self.crucipixel.grid.victory_screen = False
                overlay.visible = False
                self.buttons.set_undo()
        update_win_status(crucipixel.is_won)
        self.buttons.on_edit_action = click_left_button_wrapper(lambda: update_win_status(False))

        crucipixel.on_won_change_callbacks_list.append(update_win_status)
예제 #5
0
def main():
    main_window = MainWindow(title="Grid buttons")
    root = Root()
    root.set_main_window(main_window)
    root.set_min_size(100, 100)

    grid_buttons = OrderedButtons([["Save", "Edit"], ["Load"]])

    def action():
        grid_buttons.next_visible(0)

    grid_buttons.set_action(0, 0, click_left_button_wrapper(action))
    grid_buttons.set_action(0, 1, click_left_button_wrapper(action))

    root.set_child(
        SetAlignment(SetAlignment(grid_buttons, Alignment.RIGHT),
                     Alignment.VERTICAL_CENTER))

    main_window.start_main()
예제 #6
0
파일: main.py 프로젝트: gcali/crucipixel
    def main_menu() -> None:
        main_menu = BetterMainMenu(
            "Crucipixel GTK",
            [
                "New game",
                "Create level",
                "Help",
                "Exit"
            ], [
                click_left_button_wrapper(lambda: print("New game!")),
                click_left_button_wrapper(lambda: print("Create level!")),
                click_left_button_wrapper(lambda: print("Help")),
                click_left_button_wrapper(lambda: Gtk.main_quit())
            ])
        main_menu.set_callback(0, click_left_button_wrapper(create_new_game(root)))
        main_menu.set_callback(1, click_left_button_wrapper(create_editor_input(root)))
        main_menu.set_callback(2, click_left_button_wrapper(create_help_screen(root)))

        root.set_child(main_menu)
예제 #7
0
파일: input.py 프로젝트: gcali/crucipixel
 def set_create_action(self, action: Callable[[core.CrucipixelEditor],
                                              None]):
     self.__create_button.on_click_action = click_left_button_wrapper(
         lambda: action(
             core.CrucipixelEditor(self.rows, self.cols, self.hard, self.
                                   title)))
예제 #8
0
파일: input.py 프로젝트: gcali/crucipixel
 def set_back_action(self, action: Callable[[], None]):
     self.__back_button.on_click_action = click_left_button_wrapper(action)
예제 #9
0
 def set_quit_action(self, action: Callable[[], None]):
     self.set_action(2, 0, click_left_button_wrapper(action))
예제 #10
0
 def set_back_action(self, action: Callable[[], None]):
     self.__back_button.on_click_action = click_left_button_wrapper(action)
예제 #11
0
파일: input.py 프로젝트: gcali/crucipixel
 def set_create_action(self, action: Callable[[core.CrucipixelEditor], None]):
     self.__create_button.on_click_action = click_left_button_wrapper(
         lambda: action(core.CrucipixelEditor(self.rows, self.cols, self.hard, self.title))
     )