示例#1
0
def add_buttons(window: Window, updater: FireMapUpdater,
                plot_manager: PlotManager) -> None:
    """Add the necessary buttons to the window, such as
    the animation control buttons"""

    window.add_button(pygame.Rect((68 + 100, 440), (150, 50)), "Play",
                      lambda: start_map_animation(updater, plot_manager))
    window.add_button(pygame.Rect((375, 440), (150, 50)), "Pause",
                      lambda: stop_map_animation(updater, plot_manager))
    window.add_button(pygame.Rect((683 - 100, 440), (150, 50)), "Restart",
                      lambda: restart_map_animation(updater, plot_manager))

    window.add_button(pygame.Rect((75, 620), (120, 50)), "View Map",
                      lambda: plot_manager.set_plot("none"))

    window.add_button(pygame.Rect((225, 620), (120, 50)), "View Plot 1",
                      lambda: plot_manager.set_plot("canada_vs_carbon"))

    window.add_button(pygame.Rect((375, 620), (120, 50)), "View Plot 2",
                      lambda: plot_manager.set_plot("america_vs_carbon"))

    window.add_button(pygame.Rect((525, 620), (120, 50)), "View Plot 3",
                      lambda: plot_manager.set_plot("canada_vs_temp"))

    window.add_button(pygame.Rect((675, 620), (120, 50)), "View Plot 4",
                      lambda: plot_manager.set_plot("america_vs_temp"))
示例#2
0
    def add_ui(self, w: window.Window, g: ReversiGame, results: List,
               colour_to_player: Dict) -> None:
        """
        Add some UI to the window, such as buttons, and more.
        """

        w.add_text(label="text-score-black-label",
                   text="BLACK:",
                   position=(20, 675))
        w.add_text(label="text-score-white-label",
                   text="WHITE:",
                   position=(502, 675))
        w.add_text(label="text-score-black-amount",
                   text="0",
                   position=(113, 675))
        w.add_text(label="text-score-white-amount",
                   text="0",
                   position=(593, 675))

        w.add_button(rect=pygame.Rect(725, 30, 150, 40),
                     label="button-pause-game",
                     text="Pause Game",
                     function=lambda: self.button_pause_game(w))

        w.add_text(label="text-choose-players",
                   text="Choose Players",
                   position=(720, 100))
        w.add_dropdown(
            options_list=["Human vs. AI", "AI vs. Human", 'AI vs. AI'],
            starting_option="Human vs. AI",
            rect=pygame.Rect(725, 130, 150, 50),
            label="dropdown-player",
            function=self.dropdown_select_player(g))

        w.add_text(label="text-choose-ai",
                   text="Choose AI types",
                   position=(720, 250))
        w.add_text(label="text-choose-ai-black",
                   text="Black AI",
                   position=(705, 280),
                   large_font=False)
        w.add_text(label="text-choose-ai-white",
                   text="White AI",
                   position=(840, 280),
                   large_font=False)

        w.add_dropdown(options_list=[
            "Random Moves", "Minimax 2", 'Minimax 3', 'Minimax 4', 'Minimax 6'
        ],
                       starting_option="Minimax 2",
                       rect=pygame.Rect(675, 300, 125, 40),
                       label="dropdown-ai-black",
                       function=self.dropdown_select_ai(1, colour_to_player))

        w.add_dropdown(options_list=[
            "Random Moves", "Minimax 2", 'Minimax 3', 'Minimax 4', 'Minimax 6'
        ],
                       starting_option="Minimax 2",
                       rect=pygame.Rect(810, 300, 125, 40),
                       label="dropdown-ai-white",
                       function=self.dropdown_select_ai(-1, colour_to_player))

        w.add_text(label="text-choose-board-size",
                   text="Choose Board Size",
                   position=(700, 450))
        w.add_dropdown(options_list=["8x8", '12x12', '16x16', '24x24'],
                       starting_option="8x8",
                       rect=pygame.Rect(725, 480, 150, 40),
                       label="dropdown-board-size",
                       function=self.dropdown_select_board_size(
                           g, colour_to_player))

        w.add_button(rect=pygame.Rect(675, 610, 125, 40),
                     label="button-show-stats",
                     text="View Stats",
                     function=lambda: plot_game_statistics(
                         g, results, 'black', colour_to_player[1],
                         colour_to_player[-1]))

        w.add_button(rect=pygame.Rect(810, 610, 125, 40),
                     label="button-clear-stats",
                     text="Clear Stats",
                     function=lambda: self.clear_results(results, w))

        w.add_text(label="text-games-stored",
                   text="Games Stored: 0",
                   position=(715, 665))

        w.add_text(
            label="text-credits",
            text="Anatoly Zavyalov, Baker Jackson, Elliot Schrider, Rachel Kim",
            position=(20, 2),
            large_font=False)
示例#3
0
from window import Window
import config, importlib, traceback

lang = importlib.import_module("lang." + config.lang)

window = Window(
    "Likide " + config.version + " (python: " + config.py_version + ")",
    "1080x720")
window.create_button(window.EDITOR, text=lang.test_lang)
window.add_button(window.EDITOR, 0)

if __name__ == "__main__":
    window.mainloop()