diff --git a/esm/esm.py b/esm/esm.py deleted file mode 100644 index 2f94528..0000000 --- a/esm/esm.py +++ /dev/null @@ -1,36 +0,0 @@ -# eSports Manager - free and open source eSports Management game -# Copyright (C) 2020-2024 Pedrenrique G. Guimarães -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -from .core.esmcore import ESMCore -from .ui.guicontroller import GUIController - - -class ESMController: - """ - This class is the Game controller. It initializes the game's modules and game settings. - - This class should also communicate with the UI. - """ - - def __init__(self): - self.core = ESMCore() - self.view = GUIController(self.core) - - @property - def settings(self): - return self.core.settings - - def app(self) -> None: - self.view.start() diff --git a/esm/ui/__init__.py b/esm/ui/__init__.py deleted file mode 100644 index 502cea9..0000000 --- a/esm/ui/__init__.py +++ /dev/null @@ -1,18 +0,0 @@ -# eSports Manager - free and open source eSports Management game -# Copyright (C) 2020-2024 Pedrenrique G. Guimarães -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -from .gui import GUI -from .gui_components import * -from .guicontroller import GUIController diff --git a/esm/ui/controllers/__init__.py b/esm/ui/controllers/__init__.py deleted file mode 100644 index 79d9a56..0000000 --- a/esm/ui/controllers/__init__.py +++ /dev/null @@ -1,28 +0,0 @@ -# eSports Manager - free and open source eSports Management game -# Copyright (C) 2020-2024 Pedrenrique G. Guimarães -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -from .debug_championship_cont import DebugChampionshipController -from .debug_cont import DebugController -from .debugmatch_cont import DebugMatchController -from .game.game_dashboard_cont import GameDashboardController -from .loadgame_cont import LoadGameController -from .mainscreen_cont import MainScreenController -from .match_tester_cont import MatchTesterController -from .newgame_cont import NewGameController -from .picksbans_cont import PicksBansController -from .pickteam_cont import PickTeamController -from .settings_cont import SettingsController -from .teamselect_cont import TeamSelectController diff --git a/esm/ui/controllers/controllerinterface.py b/esm/ui/controllers/controllerinterface.py deleted file mode 100644 index 06e5ad3..0000000 --- a/esm/ui/controllers/controllerinterface.py +++ /dev/null @@ -1,23 +0,0 @@ -# eSports Manager - free and open source eSports Management game -# Copyright (C) 2020-2024 Pedrenrique G. Guimarães -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -from abc import ABC, abstractmethod - - -class IController(ABC): - @abstractmethod - def update(self, *args, **kwargs): - pass diff --git a/esm/ui/controllers/debug_championship_cont.py b/esm/ui/controllers/debug_championship_cont.py deleted file mode 100644 index 9725f33..0000000 --- a/esm/ui/controllers/debug_championship_cont.py +++ /dev/null @@ -1,154 +0,0 @@ -# eSports Manager - free and open source eSports Management game -# Copyright (C) 2020-2024 Pedrenrique G. Guimarães -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -import threading -import uuid -from typing import Optional - -from esm.core.esmcore import ESMCore -from esm.core.esports.moba.championship import Championship -from esm.core.esports.moba.mobateam import MobaTeam -from esm.ui.igamecontroller import IGameController -from esm.ui.layouts.debug_championship import DebugChampionshipLayout - -from .controllerinterface import IController - - -class DebugChampionshipController(IController): - def __init__(self, controller: IGameController, core: ESMCore): - self.core = core - self.controller = controller - self.layout = DebugChampionshipLayout() - self.championship = None - self.teams: Optional[list[MobaTeam]] = None - self.match_details = [] - self.championship_details = [] - self.championship_thread = None - - def initialize_random_championship(self): - if self.teams is None: - self.core.check_files() - self.teams = self.core.db.load_moba_teams() - self.championship = Championship("Debug", uuid.uuid4(), "Debug", self.teams) - self.championship.schedule_matches() - self.get_default_championship_details() - self.get_default_match_details() - self.update_data_in_matches_table() - self.update_data_in_championship_table() - - def reset_details(self): - self.championship_details = [ - ["TEAM1NAME12345678901213154879", "000", "00", "00", "000"] - ] - self.match_details = [ - ["TEAM1NAME12345678901213154879", "TEAM1NAME12345678901213154879", "None"] - ] - - def get_default_championship_details(self): - self.championship_details = [ - [team.name, team.get_team_overall(), 0, 0, 0] for team in self.teams - ] - - def get_default_match_details(self): - self.match_details = [ - [match.team1.team.name, match.team2.team.name, "None"] - for match in self.championship.matches - ] - - def assign_win_and_loss_in_championship_table(self, match): - for detail in self.championship_details: - if detail[0] in [match.team1.team.name, match.team2.team.name]: - if detail[0] == match.victorious_team.name: - detail[2] += 1 - detail[4] += 3 - else: - detail[3] += 1 - - def get_winning_team(self, live_match): - for detail in self.match_details: - if ( - live_match.team1.name == detail[0] - and live_match.team2.name == detail[1] - ): - if live_match.victorious_team.name == detail[0]: - detail[2] = detail[0] - elif live_match.victorious_team.name == detail[1]: - detail[2] = detail[1] - else: - detail[2] = "None" - - def play_championship(self): - for live_match in self.championship.matches: - for team in live_match.game.teams: - team.get_players_default_lanes() - live_match.picks_and_bans() - live_match.simulation() - self.get_winning_team(live_match) - self.assign_win_and_loss_in_championship_table(live_match) - - for team in live_match.game.teams: - team.reset_values() - - def reset_championship(self): - self.championship.reset_championship() - self.get_default_championship_details() - self.get_default_match_details() - - def update_data_in_championship_table(self): - self.championship_details.sort(key=lambda x: x[4], reverse=True) - self.controller.update_element_on_screen( - "debug_championship_table", values=self.championship_details - ) - - def update_data_in_matches_table(self): - self.controller.update_element_on_screen( - "debug_matches_table", values=self.match_details - ) - - def update(self, event, values, make_screen): - if self.controller.get_gui_element("debug_championship_screen").visible is True: - if self.championship is None: - self.initialize_random_championship() - - self.update_data_in_championship_table() - self.update_data_in_matches_table() - - if event == "debug_startchampionship_btn": - self.reset_championship() - try: - self.championship_thread = threading.Thread( - target=self.play_championship, daemon=True - ) - self.championship_thread.start() - self.controller.update_element_on_screen( - "debug_startchampionship_btn", disabled=True - ) - except RuntimeError as e: - self.controller.print_error(e) - - if ( - self.championship_thread is not None - and not self.championship_thread.is_alive() - ): - self.controller.update_element_on_screen( - "debug_startchampionship_btn", disabled=False - ) - - # Click the Cancel button - if event == "debug_championshipcancel_btn": - self.reset_details() - make_screen("debug_championship_screen", "main_screen") - else: - self.championship = None diff --git a/esm/ui/controllers/debug_cont.py b/esm/ui/controllers/debug_cont.py deleted file mode 100644 index 312d636..0000000 --- a/esm/ui/controllers/debug_cont.py +++ /dev/null @@ -1,43 +0,0 @@ -# eSports Manager - free and open source eSports Management game -# Copyright (C) 2020-2024 Pedrenrique G. Guimarães -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -from esm.ui.layouts.debug import DebugLayout - -from .controllerinterface import IController - - -class DebugController(IController): - def __init__(self): - self.layout = DebugLayout() - - def update(self, event, values, make_screen): - if event == "debug_pickteam_btn": - make_screen("debug_game_mode_screen", "debug_pickteam_screen") - - elif event == "debug_cancelmain_btn": - make_screen("debug_game_mode_screen", "main_screen") - - elif event == "debug_championship_btn": - make_screen("debug_game_mode_screen", "debug_championship_screen") - - elif event == "debug_picksbans_btn": - make_screen("debug_game_mode_screen", "debug_picks_bans_screen") - - elif event == "debug_match_btn": - make_screen("debug_game_mode_screen", "debug_match_screen") - - elif event == "debug_matchtester_btn": - make_screen("debug_game_mode_screen", "match_tester_screen") diff --git a/esm/ui/controllers/debugmatch_cont.py b/esm/ui/controllers/debugmatch_cont.py deleted file mode 100644 index 60af4f8..0000000 --- a/esm/ui/controllers/debugmatch_cont.py +++ /dev/null @@ -1,208 +0,0 @@ -# eSports Manager - free and open source eSports Management game -# Copyright (C) 2020-2024 Pedrenrique G. Guimarães -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -from queue import Queue - -from esm.core.esmcore import ESMCore -from esm.core.esports.moba.modules.match_manager import MatchManager -from esm.ui.igamecontroller import IGameController -from esm.ui.layouts.debugmatch import DebugMatchLayout - -from .controllerinterface import IController - - -class DebugMatchController(IController): - def __init__(self, controller: IGameController, core: ESMCore): - self.controller = controller - self.core = core - self.layout = DebugMatchLayout() - self.queue = Queue() - self.match_sim = MatchManager() - self.buttons_disabled = False - - def start_match(self): - self.controller.update_element_on_screen( - "debug_match_output", value="", append=False - ) - self.match_sim.is_game_running = True - self.reset_match() - self.match_sim.current_game.is_match_over = False - self.start_match_sim_thread() - - def get_queue_messages_and_update(self): - if not self.queue.empty(): - message = self.queue.get(block=False) - self.controller.update_element_on_screen( - "debug_match_output", value=message, append=True - ) - - def get_team_data(self): - if self.match_sim.current_game is None: - return None - players = [ - list(team.roster) for team in self.match_sim.current_live_game.game.teams - ] - - data = [] - for team in players: - team_data = [ - [ - player.lane.name, - player.nick_name, - player.kills, - player.deaths, - player.assists, - player.champion_id, - int(player.get_player_total_skill()), - ] - for player in team - ] - data.append(team_data) - - return data - - def reset_match(self): - self.match_sim.reset_game(self.queue) - self.match_sim.reset_team_values() - data = self.get_team_data() - self.update_debug_match_info(data) - - def update_debug_match_info(self, data): - current_game = self.match_sim.current_live_game - win_prob = current_game.game.team1.win_prob * 100 - self.controller.update_element_on_screen("debug_team1table", values=data[0]) - self.controller.update_element_on_screen("debug_team2table", values=data[1]) - self.controller.update_element_on_screen( - "debug_team1skill", value=current_game.game.team1.total_skill - ) - self.controller.update_element_on_screen( - "debug_team2skill", value=current_game.game.team2.total_skill - ) - self.controller.update_element_on_screen( - "debug_team1winprob", value=current_game.game.team1.win_prob - ) - self.controller.update_element_on_screen( - "debug_team2winprob", value=current_game.game.team2.win_prob - ) - self.controller.update_progress_bar("debug_winprob", win_prob) - self.controller.update_element_on_screen( - "debug_match_current_time", value=current_game.game_time - ) - self.controller.update_element_on_screen( - "debug_team1towers", value=current_game.game.team1.towers - ) - self.controller.update_element_on_screen( - "debug_team2towers", value=current_game.game.team2.towers - ) - self.controller.update_element_on_screen( - "debug_team1inhibs", value=current_game.game.team1.inhibitors - ) - self.controller.update_element_on_screen( - "debug_team2inhibs", value=current_game.game.team2.inhibitors - ) - self.controller.update_element_on_screen( - "debug_team1name", value=current_game.game.team1.name - ) - self.controller.update_element_on_screen( - "debug_team2name", value=current_game.game.team2.name - ) - - def enable_debug_buttons(self): - self._change_button_status(False) - - def disable_debug_buttons(self): - self._change_button_status(True) - self.buttons_disabled = True - - def _change_button_status(self, disabled): - self.controller.update_element_on_screen( - "debug_startmatch_btn", disabled=disabled - ) - self.controller.update_element_on_screen( - "debug_newteams_btn", disabled=disabled - ) - self.controller.update_element_on_screen( - "debug_resetmatch_btn", disabled=disabled - ) - - def start_match_sim_thread(self) -> None: - if e := self.match_sim.run_game(): - self.controller.print_error(e) - - def update_match_sim_values(self, values): - if ( - self.match_sim.current_live_game is not None - and self.match_sim.current_live_game.is_match_over - and not self.match_sim.game_thread.is_alive() - ): - self.match_sim.is_game_running = False - - if self.match_sim.current_live_game is not None: - self.match_sim.current_live_game.simulate = bool( - values["debug_simulate_checkbox"] - ) - self.update_debug_match_info(self.get_team_data()) - - def check_disabled_buttons(self): - if self.match_sim.is_game_running and not self.buttons_disabled: - self.disable_debug_buttons() - else: - self.enable_debug_buttons() - - def get_new_teams(self): - self.core.check_files() - teams = self.core.db.load_moba_teams() - self.match_sim.initialize_random_debug_game(teams) - self.update_debug_match_info(self.get_team_data()) - - def cancel_match(self, make_screen): - if self.match_sim.is_game_running: - self.match_sim.current_live_game.is_match_over = True - self.match_sim = MatchManager() - make_screen("debug_match_screen", "main_screen") - - def update(self, event, values, make_screen): - if not self.controller.get_gui_element("debug_match_screen").visible: - self.match_sim = MatchManager() - self.queue = Queue() - else: - self.check_disabled_buttons() - - self.match_sim.check_game_running_thread() - - if self.match_sim.current_game is None: - self.get_new_teams() - - self.get_queue_messages_and_update() - - # Click the Start Match button - if event == "debug_startmatch_btn": - self.start_match() - - # Click the Cancel button - if event == "debug_cancel_btn": - self.cancel_match(make_screen) - - # Click the New Teams button - elif event == "debug_newteams_btn": - self.get_new_teams() - - # Click the Reset Match button - elif event == "debug_resetmatch_btn": - self.reset_match() - - # Check if the match is running to update values on the fly - if self.match_sim.is_game_running: - self.update_match_sim_values(values) diff --git a/esm/ui/controllers/game/__init__.py b/esm/ui/controllers/game/__init__.py deleted file mode 100644 index 2b03435..0000000 --- a/esm/ui/controllers/game/__init__.py +++ /dev/null @@ -1,17 +0,0 @@ -# eSports Manager - free and open source eSports Management game -# Copyright (C) 2020-2024 Pedrenrique G. Guimarães -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -from .game_dashboard_cont import GameDashboardController diff --git a/esm/ui/controllers/game/game_dashboard_cont.py b/esm/ui/controllers/game/game_dashboard_cont.py deleted file mode 100644 index bd14e6e..0000000 --- a/esm/ui/controllers/game/game_dashboard_cont.py +++ /dev/null @@ -1,35 +0,0 @@ -# eSports Manager - free and open source eSports Management game -# Copyright (C) 2020-2024 Pedrenrique G. Guimarães -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -from typing import Optional - -from esm.core.esmcore import ESMCore -from esm.core.esports.moba.mobateam import MobaTeam -from esm.ui.controllers.controllerinterface import IController -from esm.ui.igamecontroller import IGameController -from esm.ui.layouts.game.game_dashboard import GameDashboardLayout - - -class GameDashboardController(IController): - def __init__(self, controller: IGameController, core: ESMCore): - self.controller = controller - self.core = core - self.layout = GameDashboardLayout() - self.team_name: Optional[MobaTeam] = None - # TODO: rewrite this class - - def update(self, event, values, make_screen): - pass diff --git a/esm/ui/controllers/loadgame_cont.py b/esm/ui/controllers/loadgame_cont.py deleted file mode 100644 index 6983f90..0000000 --- a/esm/ui/controllers/loadgame_cont.py +++ /dev/null @@ -1,74 +0,0 @@ -# eSports Manager - free and open source eSports Management game -# Copyright (C) 2020-2024 Pedrenrique G. Guimarães -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -import os - -from esm.core.esmcore import ESMCore -from esm.core.save_load.load_game import LoadGame -from esm.ui.igamecontroller import IGameController -from esm.ui.layouts.loadgame import LoadGameLayout - -from .controllerinterface import IController - - -class LoadGameController(IController): - def __init__(self, controller: IGameController, core: ESMCore): - self.controller = controller - self.core = core - self.layout = LoadGameLayout() - self.load_game: LoadGame = LoadGame(self.core.settings.save_file_dir) - self.load_files = None - self.filename = None - self.default_value = ["No save games encountered"] - - def get_save_files(self): - self.load_files = self.load_game.get_load_game_files(".cbor") - if not self.load_files: - self.load_files = self.default_value - - def update(self, event, values, make_screen): - if self.controller.get_gui_element("load_game_screen").visible: - if self.load_files is None: - self.get_save_files() - - if event == "load_game_cancel_btn": - make_screen("load_game_screen", "main_screen") - - if self.load_files: - self.controller.update_element_on_screen( - "load_game_listbox", values=self.load_files - ) - else: - self.controller.update_element_on_screen( - "load_game_listbox", values=self.default_value - ) - - if event == "load_game_listbox": - self.filename = values["load_game_listbox"][0] - - if event == "load_game_btn": - if self.filename not in [[], self.default_value, None]: - filename = os.path.join( - self.core.settings.save_file_dir, self.filename - ) - self.core.game_session.load_game(filename) - make_screen("load_game_screen", "game_dashboard_screen") - else: - self.controller.get_gui_information_window( - "Select a file", "Select a save game file" - ) - else: - self.load_files = None - self.filename = None diff --git a/esm/ui/controllers/mainscreen_cont.py b/esm/ui/controllers/mainscreen_cont.py deleted file mode 100644 index 702f855..0000000 --- a/esm/ui/controllers/mainscreen_cont.py +++ /dev/null @@ -1,37 +0,0 @@ -# eSports Manager - free and open source eSports Management game -# Copyright (C) 2020-2024 Pedrenrique G. Guimarães -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -from esm.ui.layouts.mainscreen import MainScreenLayout - -from .controllerinterface import IController - - -class MainScreenController(IController): - def __init__(self): - self.layout = MainScreenLayout() - - def update(self, event, values, make_screen): - if event == "main_debug_btn": - make_screen("main_screen", "debug_game_mode_screen") - - elif event == "main_newgame_btn": - make_screen("main_screen", "new_game_screen") - - elif event == "main_loadgame_btn": - make_screen("main_screen", "load_game_screen") - - elif event == "main_settings_btn": - make_screen("main_screen", "settings_screen") diff --git a/esm/ui/controllers/match_tester_cont.py b/esm/ui/controllers/match_tester_cont.py deleted file mode 100644 index c69203b..0000000 --- a/esm/ui/controllers/match_tester_cont.py +++ /dev/null @@ -1,177 +0,0 @@ -# eSports Manager - free and open source eSports Management game -# Copyright (C) 2020-2024 Pedrenrique G. Guimarães -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -import threading -from typing import Union - -from esm.core.esmcore import ESMCore -from esm.core.esports.moba.match_tester import MatchTester -from esm.core.esports.moba.modules.match_manager import MatchLive, MatchManager -from esm.ui.controllers.controllerinterface import IController -from esm.ui.igamecontroller import IGameController -from esm.ui.layouts.match_tester import MatchTesterLayout - - -class MatchTesterController(IController): - def __init__(self, controller: IGameController, core: ESMCore): - self.controller = controller - self.core = core - self.layout = MatchTesterLayout() - self.game_initializer = MatchManager() - self._amount_test_matches = 1000 - self.match_tester = None - self.match_tester_thread = None - - @property - def current_match(self) -> MatchLive: - return self.game_initializer.current_live_game - - @current_match.setter - def current_match(self, game: MatchLive): - self.game_initializer.current_game = game.game - self.game_initializer.current_live_game = MatchLive - - @property - def amount_test_matches(self) -> int: - return self._amount_test_matches - - @amount_test_matches.setter - def amount_test_matches(self, amount) -> None: - self._amount_test_matches = amount - - def initialize_random_debug_game(self, picksbans=True): - self.core.check_files() - teams = self.core.db.load_moba_teams() - self.game_initializer.initialize_random_debug_game(teams, picksbans=picksbans) - - def start_match_tester_thread(self): - """ - Starts a thread to run the match tester task. - """ - try: - self.match_tester_thread = threading.Thread( - target=self.start_match_tester, daemon=True - ) - self.match_tester_thread.start() - self.disable_match_tester_buttons() - except RuntimeError as e: - self.controller.print_error(e) - - def reset_match_tester(self): - """ - Reset the match tester function - """ - if self.match_tester is not None: - self.match_tester.reset_values() - - def start_match_tester(self): - """ - Starts running the match tester task. - """ - self.match_tester = MatchTester(self.amount_test_matches, self.current_match) - self.match_tester.running_test = True - self.match_tester.run_match_test() - self.enable_match_tester_buttons() - - def enable_match_tester_buttons(self): - """ - Tells the GUI we are done with match testing, and we can enable the layout buttons again - """ - self.controller.write_event_value("MATCH TESTER", "MATCH TESTER DONE") - self.controller.update_element_on_screen( - "match_tester_startmatch_btn", disabled=False - ) - self.controller.update_element_on_screen( - "match_tester_newteams_btn", disabled=False - ) - - def disable_match_tester_buttons(self): - """ - Tells the GUI match tester has started, and we should disable the layout buttons - """ - self.controller.update_element_on_screen( - "match_tester_startmatch_btn", disabled=True - ) - self.controller.update_element_on_screen( - "match_tester_newteams_btn", disabled=True - ) - - def get_team_data(self) -> Union[list, None]: - if self.current_match is None: - return None - - players = [list(team.roster) for team in self.current_match.game.teams] - - data = [] - for team in players: - team_data = [ - [ - player.lane.name, - player.nick_name, - player.champion_id, - int(player.get_player_total_skill()), - ] - for player in team - ] - data.append(team_data) - - return data - - def update_match_tester_match_info(self, data): - self.controller.update_element_on_screen( - "match_tester_team1table", values=data[0] - ) - self.controller.update_element_on_screen( - "match_tester_team2table", values=data[1] - ) - self.controller.update_element_on_screen( - "match_tester_team1skill", value=self.current_match.game.team1.total_skill - ) - self.controller.update_element_on_screen( - "match_tester_team2skill", value=self.current_match.game.team2.total_skill - ) - self.controller.update_element_on_screen( - "match_tester_team1name", value=self.current_match.game.team1.name - ) - self.controller.update_element_on_screen( - "match_tester_team2name", value=self.current_match.game.team2.name - ) - - def update(self, event, values, make_screen): - if self.controller.get_gui_element("match_tester_screen").visible: - if not self.game_initializer.current_live_game: - self.initialize_random_debug_game() - self.game_initializer.current_live_game.simulate = False - self.game_initializer.current_live_game.show_commentary = False - self.update_match_tester_match_info(self.get_team_data()) - - # Click the Start Match button - if event == "match_tester_startmatch_btn": - self.amount_test_matches = int(values["match_tester_amount_of_matches"]) - self.reset_match_tester() - self.start_match_tester_thread() - - # Click the Cancel button - if event == "match_tester_cancel_btn": - if self.match_tester is not None and self.match_tester.running_test: - self.match_tester.running_test = False - make_screen("match_tester_screen", "main_screen") - - elif event == "match_tester_newteams_btn": - self.initialize_random_debug_game() - self.update_match_tester_match_info(self.get_team_data()) - else: - self.match_tester = None - self.match_tester_thread = None diff --git a/esm/ui/controllers/newgame_cont.py b/esm/ui/controllers/newgame_cont.py deleted file mode 100644 index 45745e4..0000000 --- a/esm/ui/controllers/newgame_cont.py +++ /dev/null @@ -1,76 +0,0 @@ -# eSports Manager - free and open source eSports Management game -# Copyright (C) 2020-2024 Pedrenrique G. Guimarães -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -from esm.core.esmcore import ESMCore -from esm.core.utils import get_nations, load_list_from_file -from esm.ui.igamecontroller import IGameController -from esm.ui.layouts.newgame import NewGameLayout - -from .controllerinterface import IController - - -class NewGameController(IController): - def __init__(self, controller: IGameController, core: ESMCore): - self.core = core - self.controller = controller - self.layout = NewGameLayout() - self.nationalities = None - - def load_nationalities(self): - if self.nationalities is None: - names = load_list_from_file(self.core.settings.names_file) - self.nationalities = get_nations(names) - self.controller.get_gui_element("create_manager_nationality").update( - values=self.nationalities - ) - - def update(self, event, values, make_screen): - if self.controller.get_gui_element("new_game_screen").visible: - self.load_nationalities() - - if event == "ng_cancel_btn": - make_screen("new_game_screen", "main_screen") - - elif event == "ng_next_btn": - if len(values["ng_gamename_input"]) > 20: - self.controller.get_gui_information_window( - "Game name not allowed! It must be a maximum of 20 characters long!", - "Game name not allowed!", - ) - elif len(values["create_manager_name"]) > 50: - self.controller.get_gui_information_window( - "Manager name not allowed! Manager name must be a maximum of 50 characters long!", - "Manager name not allowed!", - ) - elif len(values["create_manager_nickname"]) > 20: - self.controller.get_gui_information_window( - "Manager nickname not allowed! Manager nickname must be a maximum of 20 characters long!", - "Manager nickname not allowed!", - ) - elif ( - values["ng_gamename_input"] != "" - and values["create_manager_name"] != "" - and values["create_manager_nickname"] != "" - and values["create_manager_display_calendar"] != "" - ): - if values["new_game_checkbox"]: - self.core.db.generate_moba_files() - - make_screen("new_game_screen", "team_select_screen") - else: - self.controller.get_gui_information_window( - "You must fill all the fields before proceeding!", - "Fill all the fields!", - ) diff --git a/esm/ui/controllers/picksbans_cont.py b/esm/ui/controllers/picksbans_cont.py deleted file mode 100644 index d33c6c6..0000000 --- a/esm/ui/controllers/picksbans_cont.py +++ /dev/null @@ -1,170 +0,0 @@ -# eSports Manager - free and open source eSports Management game -# Copyright (C) 2020-2024 Pedrenrique G. Guimarães -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -import gc -import threading -from queue import Queue - -from esm.core.esmcore import ESMCore -from esm.core.esports.moba.modules.match_manager import MatchManager -from esm.ui.igamecontroller import IGameController -from esm.ui.layouts.picksbans import PicksBansLayout - -from .controllerinterface import IController - - -class PicksBansController(IController): - def __init__(self, controller: IGameController, core: ESMCore): - self.controller = controller - self.core = core - self.game_initializer = MatchManager() - self.layout = PicksBansLayout() - self.queue = Queue() - self.current_match = None - self.pick_ban_thread = None - self.team1 = None - self.team2 = None - self.ch_list = None - self.champion_table_data = None - self.team1_bans = None - self.team2_bans = None - - @staticmethod - def get_players(team): - return [ - [ - player.lane.name, - player.nick_name, - player.skill, - player.champion_id, - int(player.get_player_total_skill()), - ] - for player in team - ] - - def get_champions(self): - player = None - picks_bans = self.current_match.picks_bans - - if picks_bans.bans_turn == -1: - if self.current_match.picks_bans.picks_order: - player = picks_bans.picks_order[0] - - self.champion_table_data = [ - [ - champion, - champion.skill, - ( - int(player.get_projected_champion_skill(champion)) - if player is not None - else 0 - ), - champion.status, - ] - for champion in self.ch_list - ] - else: - self.champion_table_data = [ - [champion, champion.skill, champion.skill, champion.status] - for champion in self.ch_list - ] - - self.champion_table_data.sort(key=lambda x: x[2], reverse=True) - return self.champion_table_data - - @staticmethod - def get_bans(bans): - return [ban.name for ban in bans] - - def update_elements(self): - pick_ban = self.current_match.picks_bans - self.controller.update_element_on_screen( - "pickban_team1_label", value=self.team1.name - ) - self.controller.update_element_on_screen( - "pickban_team2_label", value=self.team2.name - ) - self.controller.update_element_on_screen( - "pickban_team1_table", values=self.get_players(self.team1.roster) - ) - self.controller.update_element_on_screen( - "pickban_team2_table", values=self.get_players(self.team2.roster) - ) - self.controller.update_element_on_screen( - "pickban_team1_bans", value=self.get_bans(self.team1_bans) - ) - self.controller.update_element_on_screen( - "pickban_team2_bans", value=self.get_bans(self.team2_bans) - ) - self.controller.update_element_on_screen( - "pickban_champion_table", values=self.get_champions() - ) - if pick_ban.bans_turn != -1: - self.controller.update_element_on_screen("pickban_pick_btn", text="Ban") - else: - self.controller.update_element_on_screen("pickban_pick_btn", text="Pick") - - def get_elements(self): - self.team1 = self.current_match.game.team1 - self.team2 = self.current_match.game.team2 - self.ch_list = self.current_match.picks_bans.champion_list - self.team1_bans = self.current_match.game.team1.bans - self.team2_bans = self.current_match.game.team2.bans - - def update(self, event, values, make_screen): - if not self.controller.get_gui_element("debug_picks_bans_screen").visible: - return - - if self.current_match is None: - self.core.check_files() - teams = self.core.db.load_moba_teams() - self.current_match = self.game_initializer.initialize_random_debug_game( - teams, picks_bans_queue=self.queue - ) - self.current_match.game.team1.is_players_team = True - try: - self.pick_ban_thread = threading.Thread( - target=self.current_match.picks_and_bans, daemon=True - ) - self.pick_ban_thread.start() - except RuntimeError as e: - self.controller.print_error(e) - self.get_elements() - self.update_elements() - - if event == "pickban_cancel_btn": - # This will terminate the pick_ban_thread - self.current_match.picks_bans.num_picks = 10 - self.current_match = None - self.pick_ban_thread = None - self.queue = Queue() - - # Get rid of the rest of the objects that are not being used - gc.collect() - make_screen("debug_picks_bans_screen", "debug_game_mode_screen") - - if event == "pickban_pick_btn": - if values["pickban_champion_table"]: - champion = self.champion_table_data[ - values["pickban_champion_table"][0] - ][0] - if champion.status == "Not picked": - self.queue.put(champion) - - self.update_elements() - - if self.pick_ban_thread is not None and not self.pick_ban_thread.is_alive(): - self.update_elements() - self.pick_ban_thread = None diff --git a/esm/ui/controllers/pickteam_cont.py b/esm/ui/controllers/pickteam_cont.py deleted file mode 100644 index 4768b3c..0000000 --- a/esm/ui/controllers/pickteam_cont.py +++ /dev/null @@ -1,28 +0,0 @@ -# eSports Manager - free and open source eSports Management game -# Copyright (C) 2020-2024 Pedrenrique G. Guimarães -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -from esm.ui.layouts.pickteam import PickTeamLayout - -from .controllerinterface import IController - - -class PickTeamController(IController): - def __init__(self): - self.layout = PickTeamLayout() - - def update(self, event, values, make_screen): - if event == "debug_cancelteam_btn": - make_screen("debug_pickteam_screen", "debug_game_mode_screen") diff --git a/esm/ui/controllers/settings_cont.py b/esm/ui/controllers/settings_cont.py deleted file mode 100644 index e9d432a..0000000 --- a/esm/ui/controllers/settings_cont.py +++ /dev/null @@ -1,131 +0,0 @@ -# eSports Manager - free and open source eSports Management game -# Copyright (C) 2020-2024 Pedrenrique G. Guimarães -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -from esm.core.esmcore import ESMCore -from esm.ui.igamecontroller import IGameController -from esm.ui.layouts.settings import SettingsLayout - -from .controllerinterface import IController - - -class SettingsController(IController): - def __init__(self, controller: IGameController, core: ESMCore): - self.controller = controller - self.layout = SettingsLayout() - self.core = core - self.loaded_data = False - - @property - def amount_players(self) -> int: - return self.core.settings.amount_players - - @amount_players.setter - def amount_players(self, amount): - self.core.settings.amount_players = amount - - def generate_all_data(self) -> None: - self.core.db.generate_moba_files() - - def update_inputs(self): - self.controller.update_element_on_screen( - "settings_root_dir", value=self.core.settings.root_dir - ) - self.controller.update_element_on_screen( - "settings_fontsize_input", value=self.core.settings.font_scale - ) - self.controller.update_element_on_screen( - "settings_enable_autosave", value=self.core.settings.enable_auto_save - ) - self.controller.update_element_on_screen( - "settings_res_dir", value=self.core.settings.res_dir - ) - self.controller.update_element_on_screen( - "settings_db_dir", value=self.core.settings.db_dir - ) - self.controller.update_element_on_screen( - "settings_saves_dir", value=self.core.settings.save_file_dir - ) - self.controller.update_element_on_screen( - "settings_ch_file", value=self.core.settings.champions_file - ) - self.controller.update_element_on_screen( - "settings_pl_file", value=self.core.settings.players_file - ) - self.controller.update_element_on_screen( - "settings_t_file", value=self.core.settings.teams_file - ) - - def update_settings_data( - self, - font_size: str, - root_dir: str, - res_dir: str, - db_dir: str, - save_file_dir: str, - champions_file: str, - players_file: str, - teams_file: str, - ): - if font_size != "": - self.core.settings.font_scale = font_size - if root_dir != "": - self.core.settings.root_dir = root_dir - if res_dir != "": - self.core.settings.res_dir = res_dir - if db_dir != "": - self.core.settings.db_dir = db_dir - if save_file_dir != "": - self.core.settings.save_file_dir = save_file_dir - if champions_file != "": - self.core.settings.champions_file = champions_file - if players_file != "": - self.core.settings.players_file = players_file - if teams_file != "": - self.core.settings.teams_file = teams_file - self.update_inputs() - - def update(self, event, values, make_screen): - if not self.controller.get_gui_element("settings_screen").visible: - self.loaded_data = False - else: - if not self.loaded_data: - self.update_inputs() - self.loaded_data = True - - if event == "settings_cancel_btn": - make_screen("settings_screen", "main_screen") - - if event == "settings_enable_autosave": - self.core.settings.enable_auto_save = True - self.update_inputs() - - if event == "settings_apply_btn": - self.update_settings_data( - values["settings_fontsize_input"], - values["settings_root_dir"], - values["settings_res_dir"], - values["settings_db_dir"], - values["settings_saves_dir"], - values["settings_ch_file"], - values["settings_pl_file"], - values["settings_t_file"], - ) - self.core.settings.create_config_file() - self.update_inputs() - - elif event == "settings_generate_btn": - self.core.db.generate_moba_files() - self.update_inputs() diff --git a/esm/ui/controllers/teamselect_cont.py b/esm/ui/controllers/teamselect_cont.py deleted file mode 100644 index 6b3e618..0000000 --- a/esm/ui/controllers/teamselect_cont.py +++ /dev/null @@ -1,109 +0,0 @@ -# eSports Manager - free and open source eSports Management game -# Copyright (C) 2020-2024 Pedrenrique G. Guimarães -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -from esm.core.esmcore import ESMCore -from esm.core.esports.manager import Manager -from esm.ui.igamecontroller import IGameController -from esm.ui.layouts.teamselect import TeamSelectLayout - -from .controllerinterface import IController - - -class TeamSelectControllerError(Exception): - pass - - -class TeamSelectController(IController): - def __init__(self, controller: IGameController, core: ESMCore): - self.controller = controller - self.core = core - self.layout = TeamSelectLayout() - self.teams = None - - def get_teams(self): - try: - self.core.check_files() - except FileNotFoundError: - self.teams = self.core.db.load_moba_teams() - - def get_team_list(self): - return [[team.name, team.get_team_overall()] for team in self.teams.teams] - - def get_player_list(self, team): - data = [] - if not self.teams.teams: - return [" ", "Select your team", " "] - - for player in self.teams.teams[team[0]].roster: - player.get_default_lane() - data.append([player.lane.name, player.nick_name, player.skill]) - - return data - - def select_team(self, values, make_screen): - if values["teamselect_team_table"]: - team_index = values["teamselect_team_table"][0] - manager = Manager( - values["create_manager_name"], - values["create_manager_display_calendar"], - self.teams.teams[team_index], - True, - 50, - ) - self.teams.teams[team_index].is_players_team = True - # Probably here we should delete the old window and create a new one with new layouts - # self.create_game_manager( - # manager, - # values["ng_gamename_input"], - # values["new_game_esport"], - # values["new_game_season"], - # values["ng_gamename_input"], - # ) - make_screen("team_select_screen", "game_dashboard_screen") - else: - self.controller.get_gui_information_window( - "You must select a team before proceeding!", title="Select a team!" - ) - - def cancel_teamselect(self, make_screen): - self.teams = None - make_screen("team_select_screen", "new_game_screen") - - def update_teams(self, values): - if self.teams is None: - self.get_teams() - self.controller.update_element_on_screen( - "teamselect_team_table", values=self.get_team_list() - ) - - if values["teamselect_team_table"]: - self.controller.update_element_on_screen( - "teamselect_players_table", - values=self.get_player_list(values["teamselect_team_table"]), - ) - - def update(self, event, values, make_screen): - if self.controller.get_gui_element("team_select_screen").visible: - self.update_teams(values) - - # Click the Cancel button - if event == "teamselect_cancel_btn": - self.cancel_teamselect(make_screen) - - if event == "teamselect_select_btn": - self.select_team(values, make_screen) - else: - self.teams = None diff --git a/esm/ui/gui.py b/esm/ui/gui.py deleted file mode 100644 index 1138327..0000000 --- a/esm/ui/gui.py +++ /dev/null @@ -1,101 +0,0 @@ -# eSports Manager - free and open source eSports Management game -# Copyright (C) 2020-2024 Pedrenrique G. Guimarães -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -import base64 -import os -import traceback - -from esm.definitions import RES_DIR -from esm.ui.gui_components import * - - -class GUI: - """ - The GUI class creates the GUI window and stores references to each layout in the game. Here - are all the implementation details from PySimpleGUI, and the code in each layout is also very - specific to the GUI we are currently using. - """ - - def __init__(self, controllers): - self.icon = os.path.join(RES_DIR, "images", "logo", "esportsmanagertrophy.png") - self.layouts = [] - self.get_layouts(controllers) - self.window = self._create_window() - - def _encode_icon(self) -> bytes: - """ - Encodes the icon used for the window title. This is the default icon for the window and the - game on the desktop. - """ - with open(self.icon, "rb") as fp: - encoded_icon = base64.b64encode(fp.read()) - - return encoded_icon - - def _create_window(self) -> sg.Window: - """ - Creates the main Window using PySimpleGUI, and assigns the eSM icon to it. - It uses the _get_layouts() function to get a list of layouts used in this software. - :return: the window PySimpleGUI object - """ - encoded_icon = self._encode_icon() - - window = sg.Window( - "eSports Manager", - element_justification="center", - layout=self._get_cols(), - icon=encoded_icon, - resizable=True, - finalize=True, - ) - sg.set_options(dpi_awareness=True) - - return window - - def get_layouts(self, controllers): - """ - Gets GUI layouts from the controller classes. - """ - self.layouts = [controller.layout for controller in controllers] - - def _get_cols(self) -> list: - """ - Gets all the layouts and makes them all invisible, except for the main screen one. - This function gets called in the beginning of the game's execution. - :return: - """ - cols = [layout.col for layout in self.layouts] - - return [[sg.Pane(cols, relief=sg.RELIEF_FLAT, show_handle=False)]] - - @staticmethod - def error_message(e) -> None: - tb = traceback.format_exc() - sg.Print("The following error happened:", e, tb) - sg.popup_error("The following error occurred:", e, tb) - - @staticmethod - def confirmation_window(*args, **kwargs): - return sg.popup_ok_cancel(*args, **kwargs) - - @staticmethod - def information_window(*args, **kwargs): - sg.popup_ok(*args, **kwargs) - - -def init_theme(): - create_look_and_feel() - sg.theme("EsmTheme") diff --git a/esm/ui/gui_components.py b/esm/ui/gui_components.py deleted file mode 100644 index 9e793c2..0000000 --- a/esm/ui/gui_components.py +++ /dev/null @@ -1,315 +0,0 @@ -# eSports Manager - free and open source eSports Management game -# Copyright (C) 2020-2024 Pedrenrique G. Guimarães -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -""" -This file wraps the PySimpleGUI components in functions to use them throughout the project. -That way I can make the GUI elements uniform and work like GUI components. -""" - -import PySimpleGUI as sg - -default_font = "Arial" -bold_font = f"{default_font} Bold" -default_font_size = "12" -increased_font_size = "16" - - -def create_look_and_feel(): - sg.LOOK_AND_FEEL_TABLE["EsmTheme"] = { - "BACKGROUND": "#FFFFFF", - "TEXT": "#000000", - "INPUT": "#FFFFFF", - "TEXT_INPUT": "#000000", - "SCROLL": "#4FC3F7", - "BUTTON": ("white", "#4FC3F7"), - "PROGRESS": ("#4FC3F7", "#ff4a4a"), - "BORDER": 0, - "SLIDER_DEPTH": 0, - "PROGRESS_DEPTH": 0, - } - - -def esm_button( - text="", font=(default_font, "14"), key=None, pad=None, size=(None, None) -): - return sg.Button( - text, - font=font, - key=key, - enable_events=True, - button_color=("white", "#4FC3F7"), - size=size, - pad=pad, - border_width=0, - ) - - -def esm_output(size=(80, 12), font=(default_font, default_font_size), stdout=True): - return sg.Output(size=size, font=font, echo_stdout_stderr=stdout) - - -def esm_title_text( - text="", - auto_size=True, - font=(bold_font, increased_font_size), - key=None, - size=(None, 1), - pad=(300, 1), - justification="center", -): - return sg.Text( - text, - auto_size_text=auto_size, - key=key, - size=size, - font=font, - pad=pad, - justification=justification, - ) - - -def esm_form_text( - text="", - font=(default_font, default_font_size), - auto_size_text=True, - size=(None, 1), - key=None, - pad=None, - justification="center", -): - return sg.Text( - text, - key=key, - auto_size_text=auto_size_text, - size=size, - font=font, - pad=pad, - justification=justification, - ) - - -def esm_input_text( - text="", - font=(default_font, default_font_size), - border_width=1, - key=None, - pad=None, - size=(35, 1), - enable_events=True, -): - return sg.InputText( - text, - font=font, - background_color="white", - key=key, - pad=pad, - size=size, - border_width=border_width, - enable_events=enable_events, - ) - - -def esm_input_combo( - values=None, - default_value=None, - font=(default_font, default_font_size), - key=None, - pad=None, - readonly=True, - size=(33, 1), - enable_events=True, -): - return sg.InputCombo( - values=values, - default_value=default_value, - font=font, - background_color="white", - key=key, - pad=pad, - readonly=readonly, - size=size, - enable_events=enable_events, - ) - - -def esm_listbox( - values=None, - font=(default_font, default_font_size), - default_values=None, - select_mode=sg.LISTBOX_SELECT_MODE_SINGLE, - key=None, - pad=None, - size=(30, 10), - enable_events=False, - highlight_background_color="#4FC3F7", - highlight_text_color="white", -): - if default_values is None: - default_values = [] - return sg.Listbox( - values=values, - default_values=default_values, - background_color="white", - enable_events=enable_events, - select_mode=select_mode, - font=font, - key=key, - pad=pad, - size=size, - highlight_background_color=highlight_background_color, - highlight_text_color=highlight_text_color, - ) - - -def esm_table( - values, - key=None, - headings=None, - auto_size_columns=True, - justification="left", - num_rows=6, - display_row_numbers=False, - font=(default_font, default_font_size), - enable_events=True, - row_colors=None, - size=(None, None), -): - return sg.Table( - values=values, - key=key, - headings=headings, - justification=justification, - auto_size_columns=auto_size_columns, - num_rows=num_rows, - enable_events=enable_events, - display_row_numbers=display_row_numbers, - font=font, - row_colors=row_colors, - size=size, - ) - - -def esm_calendar_button( - button_text="Calendar", - target=(555666777, -1), - close_when_date_chosen=True, - default_date_m_d_y=(1, 1, 1995), - size=(None, None), - font=(default_font, default_font_size), - auto_size_button=None, - border_width=0, - title="Choose date of birth", - enable_events=True, - key=None, - format_calendar="%m/%d/%Y", - month_names=None, - no_titlebar=True, -): - return sg.CalendarButton( - button_text, - target=target, - title=title, - close_when_date_chosen=close_when_date_chosen, - default_date_m_d_y=default_date_m_d_y, - font=font, - border_width=border_width, - size=size, - auto_size_button=auto_size_button, - enable_events=enable_events, - key=key, - format=format_calendar, - month_names=month_names, - no_titlebar=no_titlebar, - ) - - -def esm_checkbox( - text, - default=True, - font=(default_font, default_font_size), - key=None, - enable_events=True, - visible=True, -): - return sg.Checkbox( - text=text, - default=default, - font=font, - key=key, - enable_events=enable_events, - visible=visible, - ) - - -def esm_radio( - text, - group_id, - default=True, - font=(default_font, default_font_size), - key=None, - enable_events=True, - visible=True, -): - return sg.Radio( - text=text, - group_id=group_id, - default=default, - font=font, - key=key, - enable_events=enable_events, - visible=visible, - ) - - -def esm_multiline( - default_text="", - enter_submits=False, - disabled=False, - size=(80, 12), - autoscroll=True, - border_width=1, - enable_events=True, - key=None, - write_only=False, - font=(default_font, default_font_size), - auto_refresh=True, - do_not_clear=True, - reroute_stdout=False, - reroute_stderr=False, - reroute_cprint=False, - echo_stdout_stderr=False, - justification="left", - visible=True, -): - return sg.Multiline( - default_text=default_text, - enter_submits=enter_submits, - disabled=disabled, - size=size, - font=font, - autoscroll=autoscroll, - enable_events=enable_events, - key=key, - border_width=border_width, - auto_refresh=auto_refresh, - do_not_clear=do_not_clear, - write_only=write_only, - reroute_stdout=reroute_stdout, - reroute_stderr=reroute_stderr, - reroute_cprint=reroute_cprint, - echo_stdout_stderr=echo_stdout_stderr, - justification=justification, - visible=visible, - ) diff --git a/esm/ui/guicontroller.py b/esm/ui/guicontroller.py deleted file mode 100644 index 27d5b78..0000000 --- a/esm/ui/guicontroller.py +++ /dev/null @@ -1,102 +0,0 @@ -# eSports Manager - free and open source eSports Management game -# Copyright (C) 2020-2024 Pedrenrique G. Guimarães -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -from ..core.esmcore import ESMCore -from ..definitions import DEBUG -from .controllers import * -from .gui import GUI, init_theme -from .gui_components import sg -from .igamecontroller import IGameController - - -class GUIController(IGameController): - """ - This class is an abstraction layer over the GUI. It should provide functions that interact - with the GUI, but do not expose any details about the GUI itself. - """ - - def __init__(self, core: ESMCore): - init_theme() - self.controllers = [] - self.__initialize_controllers(core) - self.gui = GUI(self.controllers) - - def __initialize_controllers(self, core: ESMCore): - self.controllers = [ - MainScreenController(), - NewGameController(self, core), - LoadGameController(self, core), - SettingsController(self, core), - GameDashboardController(self, core), - ] - - # Debug controllers - if DEBUG: - self.controllers.append(DebugController()) - self.controllers.append(DebugMatchController(self, core)) - self.controllers.append(DebugChampionshipController(self, core)) - self.controllers.append(TeamSelectController(self, core)) - self.controllers.append(PicksBansController(self, core)) - self.controllers.append(PickTeamController()) - self.controllers.append(MatchTesterController(self, core)) - - def print_error(self, e): - self.gui.error_message(e) - - def make_screen_visible(self, inv_screen, vis_screen): - self.gui.window[inv_screen].update(visible=False) - self.gui.window[vis_screen].update(visible=True) - - def update_element_on_screen(self, element, **kwargs): - self.gui.window[element].update(**kwargs) - - def get_gui_element(self, element): - return self.gui.window[element] - - def write_event_value(self, first_message, second_message): - self.gui.window.write_event_value(first_message, second_message) - - def update_progress_bar(self, key, value): - self.gui.window[key].update_bar(value) - - def get_gui_information_window(self, *args, **kwargs): - self.gui.information_window(*args, **kwargs) - - def get_gui_confirmation_window(self, *args, **kwargs): - return self.gui.confirmation_window(*args, **kwargs) - - def update(self, *args, **kwargs) -> None: - """ - Event handling for each layout - """ - for controller in self.controllers: - controller.update(*args, **kwargs) - - def start(self): - """ - App loop - """ - while True: - event, values = self.gui.window.read(timeout=500) - - if event in [sg.WINDOW_CLOSED, "main_exit_btn"]: - break - - # Goes through each layout and runs their update method (event handling) - self.update( - event, - values, - self.make_screen_visible, - ) diff --git a/esm/ui/igamecontroller.py b/esm/ui/igamecontroller.py deleted file mode 100644 index b957cfc..0000000 --- a/esm/ui/igamecontroller.py +++ /dev/null @@ -1,58 +0,0 @@ -# eSports Manager - free and open source eSports Management game -# Copyright (C) 2020-2024 Pedrenrique G. Guimarães -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -from abc import ABC, abstractmethod - - -class IGameController(ABC): - @abstractmethod - def get_gui_element(self, element): - pass - - @abstractmethod - def make_screen_visible(self, inv_screen, vis_screen): - pass - - @abstractmethod - def update_element_on_screen(self, element, **kwargs): - pass - - @abstractmethod - def write_event_value(self, firs_message, second_message): - pass - - @abstractmethod - def update_progress_bar(self, key, value): - pass - - @abstractmethod - def get_gui_information_window(self, *args, **kwargs): - pass - - @abstractmethod - def get_gui_confirmation_window(self, *args, **kwargs): - pass - - @abstractmethod - def print_error(self, e): - pass - - @abstractmethod - def start(self): - pass - - @abstractmethod - def update(self): - pass diff --git a/esm/ui/layouts/__init__.py b/esm/ui/layouts/__init__.py deleted file mode 100644 index 9c28c32..0000000 --- a/esm/ui/layouts/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# eSports Manager - free and open source eSports Management game -# Copyright (C) 2020-2024 Pedrenrique G. Guimarães -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -__all__ = [ - "debug", - "debugmatch", - "debug_championship", - "newgame", - "loadgame", - "pickteam", - "picksbans", - "mainscreen", - "settings", - "match_tester", - "teamselect", -] diff --git a/esm/ui/layouts/debug.py b/esm/ui/layouts/debug.py deleted file mode 100644 index 73b8cfc..0000000 --- a/esm/ui/layouts/debug.py +++ /dev/null @@ -1,92 +0,0 @@ -# eSports Manager - free and open source eSports Management game -# Copyright (C) 2020-2024 Pedrenrique G. Guimarães -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -from ..gui_components import * -from .layoutinterface import ILayout - - -class DebugLayout(ILayout): - def __init__(self): - self.lay = self.layout() - self.col = self.column() - - def column(self) -> sg.Column: - return sg.Column( - self.lay, - key="debug_game_mode_screen", - visible=False, - element_justification="center", - ) - - def layout(self) -> list: - """ - Defines the Debug Game Mode screen. This screen shows the Debug game options. - """ - - button_pad = (0, 10) - button_size = (20, 2) - - return [ - [esm_title_text("Choose your debug mode")], - [ - esm_button( - "Debug Match", - key="debug_match_btn", - pad=button_pad, - size=button_size, - ) - ], - [ - esm_button( - "Debug Pick Team", - key="debug_pickteam_btn", - pad=button_pad, - size=button_size, - ) - ], - [ - esm_button( - "Debug Picks Bans", - key="debug_picksbans_btn", - pad=button_pad, - size=button_size, - ) - ], - [ - esm_button( - "Debug Championship", - key="debug_championship_btn", - pad=button_pad, - size=button_size, - ) - ], - [ - esm_button( - "Match Tester", - key="debug_matchtester_btn", - pad=button_pad, - size=button_size, - ) - ], - [ - esm_button( - "Cancel", - key="debug_cancelmain_btn", - pad=button_pad, - size=button_size, - ) - ], - ] diff --git a/esm/ui/layouts/debug_championship.py b/esm/ui/layouts/debug_championship.py deleted file mode 100644 index 00c9b23..0000000 --- a/esm/ui/layouts/debug_championship.py +++ /dev/null @@ -1,89 +0,0 @@ -# eSports Manager - free and open source eSports Management game -# Copyright (C) 2020-2024 Pedrenrique G. Guimarães -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -from ..gui_components import * -from .layoutinterface import ILayout - - -class DebugChampionshipLayout(ILayout): - def __init__(self): - self.lay = self.layout() - self.col = self.column() - - def column(self) -> sg.Column: - return sg.Column( - self.lay, - key="debug_championship_screen", - visible=False, - element_justification="center", - ) - - def layout(self) -> list: - headings_championship_table = [ - "Team Name", - "Skill", - "Wins", - "Losses", - "Points", - ] - - headings_matches = [ - "Blue Team", - "Red Team", - "Winning Team", - ] - - championship_table_column = [ - [esm_form_text("Debug Championhsip")], - [ - esm_table( - [["TEAM1NAME123456789", "000", "00", "00", "0000"]], - num_rows=20, - display_row_numbers=True, - headings=headings_championship_table, - key="debug_championship_table", - ), - ], - ] - - matches_column = [ - [ - esm_form_text("Matches", key="debug_championship_matches"), - ], - [ - esm_table( - [["TEAM1NAME123456789", "TEAM2NAME123456789", "00"]], - num_rows=20, - display_row_numbers=True, - headings=headings_matches, - key="debug_matches_table", - ), - ], - ] - - return [ - [esm_title_text("Debug Championship")], - [ - sg.Column( - layout=championship_table_column, element_justification="center" - ), - sg.Column(layout=matches_column, element_justification="center"), - ], - [ - esm_button("Start Championship", key="debug_startchampionship_btn"), - esm_button("Cancel", key="debug_championshipcancel_btn"), - ], - ] diff --git a/esm/ui/layouts/debugmatch.py b/esm/ui/layouts/debugmatch.py deleted file mode 100644 index 57ee8ff..0000000 --- a/esm/ui/layouts/debugmatch.py +++ /dev/null @@ -1,108 +0,0 @@ -# eSports Manager - free and open source eSports Management game -# Copyright (C) 2020-2024 Pedrenrique G. Guimarães -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -from ..gui_components import * -from .layoutinterface import ILayout - - -class DebugMatchLayout(ILayout): - def __init__(self): - self.lay = self.layout() - self.col = self.column() - - def column(self) -> sg.Column: - return sg.Column( - self.lay, - key="debug_match_screen", - visible=False, - element_justification="center", - ) - - def layout(self) -> list: - headings = [ - "Lane", - "Player Name", - "Kills", - "Deaths", - "Assists", - "Champion", - "Skill", - ] - - team1_column = [ - [ - esm_form_text("Team1DebugMatch", key="debug_team1name"), - esm_form_text("0000", key="debug_team1skill"), - ], - [esm_form_text("0.0000", key="debug_team1winprob")], - [esm_table(headings, headings=headings, key="debug_team1table")], - [ - esm_form_text("Towers: "), - esm_form_text("Top tower: 3", key="debug_team1_top_tower"), - esm_form_text("Mid tower: 3", key="debug_team1_mid_tower"), - esm_form_text("Bot tower: 3", key="debug_team1_bot_tower"), - esm_form_text("Base tower: 3", key="debug_team1_base_tower"), - ], - [ - esm_form_text("Inhibitors: "), - esm_form_text("Top inhib: 1", key="debug_team1_top_inhib"), - esm_form_text("Mid inhib: 1", key="debug_team1_mid_inhib"), - esm_form_text("Bot inhib: 1", key="debug_team1_bot_inhib"), - ], - ] - - team2_column = [ - [ - esm_form_text("Team2DebugMatch", key="debug_team2name"), - esm_form_text("0000", key="debug_team2skill"), - ], - [esm_form_text("0.0000", key="debug_team2winprob")], - [esm_table(headings, headings=headings, key="debug_team2table")], - [ - esm_form_text("Towers: "), - esm_form_text("Top tower: 3", key="debug_team2_top_tower"), - esm_form_text("Mid tower: 3", key="debug_team2_mid_tower"), - esm_form_text("Bot tower: 3", key="debug_team2_bot_tower"), - esm_form_text("Base tower: 3", key="debug_team2_base_tower"), - ], - [ - esm_form_text("Inhibitors: "), - esm_form_text("Top inhib: 1", key="debug_team2_top_inhib"), - esm_form_text("Mid inhib: 1", key="debug_team2_mid_inhib"), - esm_form_text("Bot inhib: 1", key="debug_team2_bot_inhib"), - ], - ] - - return [ - [esm_title_text("Debug Match")], - [ - sg.Column(layout=team1_column, element_justification="center"), - sg.Column(layout=team2_column, element_justification="center"), - ], - [sg.ProgressBar(100, size=(80, 20), border_width=0, key="debug_winprob")], - [ - esm_form_text("Current match time: "), - esm_form_text("500.00", key="debug_match_current_time"), - ], - [esm_multiline(key="debug_match_output", do_not_clear=True)], - [esm_checkbox("Simulate step-by-step", key="debug_simulate_checkbox")], - [ - esm_button("Start Match", key="debug_startmatch_btn"), - esm_button("New Teams", key="debug_newteams_btn"), - esm_button("Reset Match", key="debug_resetmatch_btn"), - esm_button("Cancel", key="debug_cancel_btn"), - ], - ] diff --git a/esm/ui/layouts/game/__init__.py b/esm/ui/layouts/game/__init__.py deleted file mode 100644 index b0c66ef..0000000 --- a/esm/ui/layouts/game/__init__.py +++ /dev/null @@ -1,17 +0,0 @@ -# eSports Manager - free and open source eSports Management game -# Copyright (C) 2020-2024 Pedrenrique G. Guimarães -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -__all__ = ["game_dashboard"] diff --git a/esm/ui/layouts/game/game_dashboard.py b/esm/ui/layouts/game/game_dashboard.py deleted file mode 100644 index d348ca1..0000000 --- a/esm/ui/layouts/game/game_dashboard.py +++ /dev/null @@ -1,177 +0,0 @@ -# eSports Manager - free and open source eSports Management game -# Copyright (C) 2020-2024 Pedrenrique G. Guimarães -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -from esm.ui.gui_components import * -from esm.ui.layouts.layoutinterface import ILayout - - -class GameDashboardLayout(ILayout): - def __init__(self): - self.lay = self.layout() - self.col = self.column() - - def column(self) -> sg.Column: - return sg.Column( - self.lay, - key="game_dashboard_screen", - visible=False, - justification="left", - element_justification="left", - ) - - def layout(self) -> list: - """ - Defines the main game dashboard screen. - """ - tab_home = [ - [esm_form_text("Next match details:", font=(bold_font, default_font_size))], - [ - esm_form_text("Team"), - esm_form_text( - "TEAMNAME123456789101112131415", key="game_dashboard_oppteamname" - ), - ], - [ - esm_table( - values=[["LANE", "PLAYERNAME1234567891011121314151617", "1515"]], - headings=["Lane", "Nickname", "Skill"], - key="game_dashboard_oppteamroster", - size=(100, 30), - ) - ], - [ - esm_form_text("Avg skill level: ", font=(bold_font, default_font_size)), - esm_form_text("100", key="game_dashboard_oppteamskill_lvl"), - ], - ] - - team_roster_table = [ - [esm_form_text("Team roster:", font=(bold_font, default_font_size))], - [ - esm_table( - values=[["LANE", "PLAYERNAME1234567891011121314151617", "1515"]], - headings=["Lane", "Nickname", "Skill"], - key="game_dashboard_roster", - ) - ], - ] - - player_champion_data = [ - [esm_form_text("Player details:", font=(bold_font, default_font_size))], - [ - esm_table( - values=[["No player selected", "00"]], - headings=["Champion Name", "Skill"], - key="game_dashboard_player_details", - ) - ], - ] - - tab_roster = [ - [esm_title_text("ROSTER\n", justification="center")], - [sg.Column(team_roster_table), sg.Column(player_champion_data)], - ] - - tab_championship = [ - [esm_title_text("CHAMPIONSHIP\n", justification="center")], - [ - esm_table( - values=[ - [ - "100", - "TEAMNAME12345678910111213141517181920", - "00", - "00", - "00", - ] - ], - headings=[ - "Position", - "Team Name", - "Victories", - "Defeats", - "Points", - ], - key="game_dashboard_championship", - size=(100, 30), - ), - ], - ] - - tab_scheduled_matches = [ - [esm_title_text("SCHEDULED MATCHES\n", justification="center")], - [ - esm_table( - values=[ - [ - "2020/01/01", - "TEAMNAME12345678910111213141517181920", - "TEAMNAME12345678910111213141517181920", - ] - ], - headings=["Date", "Team 1", "Team 2"], - size=(100, 300), - ) - ], - ] - - tab_game_details = [ - [esm_title_text("CHAMPIONS\n", justification="center")], - [ - esm_table( - values=[["CHAMPION_NAME123456789101112", "100"]], - headings=["Champion Name", "Skill"], - key="game_dashboard_championstable", - size=(100, 30), - ) - ], - ] - - return [ - [ - esm_title_text( - "TEAMNAME1234567891011121314151617181920\n", - key="game_dashboard_teamname", - ) - ], - [ - esm_form_text("Manager: ", font=(bold_font, default_font_size)), - esm_form_text("Managername12345678", key="game_dashboard_managername"), - ], - [ - esm_form_text("Current day: ", font=(bold_font, default_font_size)), - esm_form_text("2020/01/01", key="game_dashboard_current_day"), - ], - [ - sg.TabGroup( - [ - [ - sg.Tab("Home", tab_home), - sg.Tab("Roster", tab_roster), - sg.Tab("Scheduled Matches", tab_scheduled_matches), - sg.Tab("Championship Standings", tab_championship), - sg.Tab("Champions", tab_game_details), - ] - ], - border_width=0, - font=(default_font, default_font_size), - ) - ], - [ - esm_button("Next match", size=(15, 2), pad=(None, 80)), - esm_button("Save game", key="game_dashboard_save"), - ], - ] diff --git a/esm/ui/layouts/layoutinterface.py b/esm/ui/layouts/layoutinterface.py deleted file mode 100644 index 876c3a4..0000000 --- a/esm/ui/layouts/layoutinterface.py +++ /dev/null @@ -1,27 +0,0 @@ -# eSports Manager - free and open source eSports Management game -# Copyright (C) 2020-2024 Pedrenrique G. Guimarães -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -from abc import ABC, abstractmethod - - -class ILayout(ABC): - @abstractmethod - def column(self): - pass - - @abstractmethod - def layout(self): - pass diff --git a/esm/ui/layouts/loadgame.py b/esm/ui/layouts/loadgame.py deleted file mode 100644 index 868b256..0000000 --- a/esm/ui/layouts/loadgame.py +++ /dev/null @@ -1,56 +0,0 @@ -# eSports Manager - free and open source eSports Management game -# Copyright (C) 2020-2024 Pedrenrique G. Guimarães -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -from ..gui_components import * -from .layoutinterface import ILayout - - -class LoadGameLayout(ILayout): - def __init__(self): - self.lay = self.layout() - self.col = self.column() - - def column(self) -> sg.Column: - return sg.Column( - self.lay, - key="load_game_screen", - visible=False, - element_justification="center", - ) - - def layout(self): - saved_games = [ - "No save games encountered", - ] - - size_btn = (10, 1) - - return [ - [esm_title_text("Load Game")], - [esm_form_text("Saved Games:")], - [ - esm_listbox( - saved_games, - size=(50, 20), - key="load_game_listbox", - enable_events=True, - ) - ], - [ - esm_button("Load Game", key="load_game_btn", size=size_btn), - esm_button("Cancel", key="load_game_cancel_btn", size=size_btn), - ], - ] diff --git a/esm/ui/layouts/mainscreen.py b/esm/ui/layouts/mainscreen.py deleted file mode 100644 index afa5e90..0000000 --- a/esm/ui/layouts/mainscreen.py +++ /dev/null @@ -1,80 +0,0 @@ -# eSports Manager - free and open source eSports Management game -# Copyright (C) 2020-2024 Pedrenrique G. Guimarães -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -import os - -from esm.definitions import DEBUG, RES_DIR - -from ..gui_components import * -from .layoutinterface import ILayout - - -class MainScreenLayout(ILayout): - def __init__(self): - self.lay = self.layout() - self.col = self.column() - - def column(self) -> sg.Column: - return sg.Column(self.lay, key="main_screen", element_justification="center") - - def layout(self) -> list: - """ - Defines the main screen. This screen shows the initial options to play a new game, load game, - use the Database Editor, or exit the game. - """ - logo_path = os.path.join(RES_DIR, "images", "logo", "esportsmanager.png") - - button_pad = (0, 10) - button_size = (20, 2) - - if DEBUG: - debug_button = [ - esm_button( - "Debug Game Mode", - key="main_debug_btn", - pad=button_pad, - size=button_size, - ) - ] - else: - debug_button = [] - - return [ - [sg.Image(logo_path, pad=(50, 0))], - debug_button, - [ - esm_button( - "New Game", key="main_newgame_btn", pad=button_pad, size=button_size - ) - ], - [ - esm_button( - "Load Game", - key="main_loadgame_btn", - pad=button_pad, - size=button_size, - ) - ], - [ - esm_button( - "Settings", - key="main_settings_btn", - pad=button_pad, - size=button_size, - ) - ], - [esm_button("Exit", key="main_exit_btn", pad=button_pad, size=button_size)], - ] diff --git a/esm/ui/layouts/match_tester.py b/esm/ui/layouts/match_tester.py deleted file mode 100644 index fecc54b..0000000 --- a/esm/ui/layouts/match_tester.py +++ /dev/null @@ -1,75 +0,0 @@ -# eSports Manager - free and open source eSports Management game -# Copyright (C) 2020-2024 Pedrenrique G. Guimarães -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -from ..gui_components import * -from .layoutinterface import ILayout - - -class MatchTesterLayout(ILayout): - def __init__(self): - self.lay = self.layout() - self.col = self.column() - - def column(self) -> sg.Column: - return sg.Column( - self.lay, - key="match_tester_screen", - visible=False, - element_justification="center", - ) - - def layout(self) -> list: - headings = [ - "Lane", - "Player Name", - "Champion", - "Skill", - ] - - team1_column = [ - [ - esm_form_text("Team1DebugMatch", key="match_tester_team1name"), - esm_form_text("0000", key="match_tester_team1skill"), - ], - [esm_table(headings, headings=headings, key="match_tester_team1table")], - ] - - team2_column = [ - [ - esm_form_text("Team2DebugMatch", key="match_tester_team2name"), - esm_form_text("0000", key="match_tester_team2skill"), - ], - [esm_table(headings, headings=headings, key="match_tester_team2table")], - ] - - return [ - [esm_title_text("Match Tester")], - [esm_form_text("Match tester provides a way to test matches efficiently!")], - [ - esm_form_text("Amount of matches: "), - esm_input_text("1000", key="match_tester_amount_of_matches"), - ], - [ - sg.Column(layout=team1_column, element_justification="center"), - sg.Column(layout=team2_column, element_justification="center"), - ], - [esm_output()], - [ - esm_button("Start Test", key="match_tester_startmatch_btn"), - esm_button("New Teams", key="match_tester_newteams_btn"), - esm_button("Cancel", key="match_tester_cancel_btn"), - ], - ] diff --git a/esm/ui/layouts/newgame.py b/esm/ui/layouts/newgame.py deleted file mode 100644 index 2e621f3..0000000 --- a/esm/ui/layouts/newgame.py +++ /dev/null @@ -1,90 +0,0 @@ -# eSports Manager - free and open source eSports Management game -# Copyright (C) 2020-2024 Pedrenrique G. Guimarães -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -from ..gui_components import * -from .layoutinterface import ILayout - - -class NewGameLayout(ILayout): - def __init__(self): - self.lay = self.layout() - self.col = self.column() - - def column(self) -> sg.Column: - return sg.Column( - self.lay, - key="new_game_screen", - visible=False, - element_justification="center", - ) - - def layout(self) -> list: - """ - Defines the new game screen. - """ - - label_pad = (0, 5) - esports = ["MOBA"] - seasons = ["2020"] - nationalities = ["Placeholder"] - - labels = [ - [esm_form_text("Save game name: ", pad=label_pad)], - [esm_form_text("Name: ", pad=label_pad)], - [esm_form_text("Nickname: ", pad=label_pad)], - [esm_form_text("Birthday: ", pad=label_pad)], - [esm_form_text("Nationality: ", pad=label_pad)], - [esm_form_text("Starting season: ", pad=label_pad)], - [esm_form_text("eSport: ", pad=label_pad)], - [esm_form_text("Database option: ", pad=label_pad)], - ] - - inputs = [ - [esm_input_text("Game1", key="ng_gamename_input")], - [esm_input_text("John", key="create_manager_name")], - [esm_input_text("Doe", key="create_manager_nickname")], - [ - esm_input_text("", key="create_manager_display_calendar", size=(23, 1)), - esm_calendar_button( - "Choose date", - size=(10, 1), - key="create_manager_calendar", - format_calendar="%Y/%m/%d", - ), - ], - [ - esm_input_combo( - nationalities, - default_value=nationalities[0], - key="create_manager_nationality", - ) - ], - [esm_input_combo(seasons, default_value=seasons[0], key="new_game_season")], - [esm_input_combo(esports, default_value=esports[0], key="new_game_esport")], - [esm_checkbox("Generate new database", key="new_game_checkbox")], - ] - - return [ - [esm_title_text("New Game\n")], - [ - sg.Column(labels, element_justification="right"), - sg.Column(inputs, element_justification="left"), - ], - [ - esm_button("Next", key="ng_next_btn"), - esm_button("Cancel", key="ng_cancel_btn"), - ], - ] diff --git a/esm/ui/layouts/picksbans.py b/esm/ui/layouts/picksbans.py deleted file mode 100644 index 2e034a0..0000000 --- a/esm/ui/layouts/picksbans.py +++ /dev/null @@ -1,97 +0,0 @@ -# eSports Manager - free and open source eSports Management game -# Copyright (C) 2020-2024 Pedrenrique G. Guimarães -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -from ..gui_components import * -from .layoutinterface import ILayout - - -class PicksBansLayout(ILayout): - def __init__(self): - self.lay = self.layout() - self.col = self.column() - - def column(self) -> sg.Column: - return sg.Column( - self.lay, - key="debug_picks_bans_screen", - visible=False, - element_justification="center", - ) - - def layout(self) -> list: - team_headings = ["Lane", "Nickname", "Skill", "Champion", "Ch. Skill"] - - champion_headings = ["Name", "Skill", "Pl. Skill", "Status"] - - values = [ - "LANE", - "PLAYERNICKNAME123456", - "0000", - "CHAMPIONNAME", - "0000", - ] - - col_team1 = [ - [ - esm_form_text("Team1WholeName", key="pickban_team1_label"), - esm_form_text("(Your team)"), - ], - [ - esm_table( - values=[values], - headings=team_headings, - key="pickban_team1_table", - num_rows=5, - enable_events=True, - ) - ], - [esm_form_text("Bans:")], - [esm_multiline(key="pickban_team1_bans", size=(60, 3))], - [esm_form_text("Team2WholeName", key="pickban_team2_label")], - [ - esm_table( - values=[values], - headings=team_headings, - key="pickban_team2_table", - num_rows=5, - enable_events=True, - ) - ], - [esm_form_text("Bans:")], - [esm_multiline(key="pickban_team2_bans", size=(60, 3))], - ] - - col_champion = [ - [esm_form_text("Champions")], - [ - esm_table( - values=[["CHAMPIONWHOLENAME", "0000", "0000", "Not picked"]], - headings=champion_headings, - key="pickban_champion_table", - num_rows=30, - enable_events=True, - ) - ], - ] - - return [ - [esm_title_text("Picks and Bans")], - [sg.Column(col_team1), sg.Column(col_champion)], - [ - esm_button("Pick", key="pickban_pick_btn"), - esm_button("Cancel", key="pickban_cancel_btn"), - ], - ] diff --git a/esm/ui/layouts/pickteam.py b/esm/ui/layouts/pickteam.py deleted file mode 100644 index 675e78c..0000000 --- a/esm/ui/layouts/pickteam.py +++ /dev/null @@ -1,72 +0,0 @@ -# eSports Manager - free and open source eSports Management game -# Copyright (C) 2020-2024 Pedrenrique G. Guimarães -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -from ..gui_components import * -from .layoutinterface import ILayout - - -class PickTeamLayout(ILayout): - def __init__(self): - self.lay = self.layout() - self.col = self.column() - - def column(self) -> sg.Column: - return sg.Column( - self.lay, - key="debug_pickteam_screen", - visible=False, - element_justification="center", - ) - - def layout(self) -> list: - team_headings = ["Team Name", "Skill"] - player_headings = ["Lane", "Nickname", "Nationality", "Skill"] - - team_list_frame = [ - [esm_form_text("Team:")], - [ - esm_table( - values=[["", ""]], - key="debug_pick_team_table", - headings=team_headings, - enable_events=True, - ) - ], - ] - - player_list_frame = [ - [esm_form_text("Players:")], - [ - esm_table( - values=[["", "Select a team", "", ""]], - key="debug_pick_player_table", - headings=player_headings, - enable_events=True, - ) - ], - ] - - return [ - [esm_title_text("Pick your team")], - [ - sg.Column(team_list_frame, element_justification="center"), - sg.Column(player_list_frame, element_justification="center"), - ], - [ - esm_button("Confirm", key="debug_confirmteam_btn"), - esm_button("Cancel", key="debug_cancelteam_btn"), - ], - ] diff --git a/esm/ui/layouts/settings.py b/esm/ui/layouts/settings.py deleted file mode 100644 index aff52cd..0000000 --- a/esm/ui/layouts/settings.py +++ /dev/null @@ -1,173 +0,0 @@ -# eSports Manager - free and open source eSports Management game -# Copyright (C) 2020-2024 Pedrenrique G. Guimarães -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -from ..gui_components import * -from .layoutinterface import ILayout - - -class SettingsLayout(ILayout): - def __init__(self): - self.lay = self.layout() - self.col = self.column() - - def column(self) -> sg.Column: - return sg.Column( - self.lay, - key="settings_screen", - visible=False, - element_justification="center", - ) - - def layout(self) -> list: - size_elements = (45, 2) - - languages = ["English", "Portuguese"] - - label_pad = (0, 7) - labels_file_pad = (0, 9) - controls_file_pad = (6, 8) - labels_inputs = [ - [esm_form_text("Language:", pad=label_pad)], - [esm_form_text("Font scale:", pad=label_pad)], - ] - - labels_files = [ - [esm_form_text("Root directory:", pad=labels_file_pad)], - [esm_form_text("Resources directory:", pad=labels_file_pad)], - [esm_form_text("Database directory:", pad=labels_file_pad)], - [esm_form_text("Saves directory:", pad=labels_file_pad)], - [esm_form_text("Champions file:", pad=labels_file_pad)], - [esm_form_text("Players file:", pad=labels_file_pad)], - [esm_form_text("Teams file:", pad=labels_file_pad)], - ] - - controls = [ - # TODO: Replace with supported i18n - [ - esm_input_combo( - languages, - default_value=languages[0], - size=size_elements, - key="settings_languages_inpcombo", - ) - ], - [ - esm_input_text( - "1", size=size_elements, key="settings_fontsize_input", pad=(3, 5) - ) - ], - [ - esm_checkbox( - "Enable autosave: ", default=True, key="settings_enable_autosave" - ) - ], - ] - - controls_files = [ - [ - esm_input_text( - "", - size=size_elements, - key="settings_root_dir", - pad=controls_file_pad, - ), - sg.FileBrowse( - target="settings_root_dir", font=(default_font, default_font_size) - ), - ], - [ - esm_input_text( - "", - size=size_elements, - key="settings_res_dir", - pad=controls_file_pad, - ), - sg.FileBrowse( - target="settings_res_dir", font=(default_font, default_font_size) - ), - ], - [ - esm_input_text( - "", size=size_elements, key="settings_db_dir", pad=controls_file_pad - ), - sg.FileBrowse( - target="settings_db_dir", font=(default_font, default_font_size) - ), - ], - [ - esm_input_text( - "", - size=size_elements, - key="settings_saves_dir", - pad=controls_file_pad, - ), - sg.FileBrowse( - target="settings_saves_dir", font=(default_font, default_font_size) - ), - ], - [ - esm_input_text( - "", - size=size_elements, - key="settings_ch_file", - pad=controls_file_pad, - ), - sg.FileBrowse( - target="settings_ch_file", font=(default_font, default_font_size) - ), - ], - [ - esm_input_text( - "", - size=size_elements, - key="settings_pl_file", - pad=controls_file_pad, - ), - sg.FileBrowse( - target="settings_pl_file", font=(default_font, default_font_size) - ), - ], - [ - esm_input_text( - "", size=size_elements, key="settings_t_file", pad=controls_file_pad - ), - sg.FileBrowse( - target="settings_t_file", font=(default_font, default_font_size) - ), - ], - ] - - return [ - [esm_title_text("Settings")], - [ - sg.Column(labels_inputs, element_justification="right"), - sg.Column(controls, element_justification="left"), - ], - [ - esm_form_text( - "Warning: Generating players will replace the current champions, players and teams file!" - ) - ], - [ - sg.Column(labels_files, element_justification="right"), - sg.Column(controls_files, element_justification="left"), - ], - [esm_form_text("", pad=(0, 80))], - [ - esm_button("Apply", key="settings_apply_btn"), - esm_button("Cancel", key="settings_cancel_btn"), - ], - ] diff --git a/esm/ui/layouts/teamselect.py b/esm/ui/layouts/teamselect.py deleted file mode 100644 index b22f7a9..0000000 --- a/esm/ui/layouts/teamselect.py +++ /dev/null @@ -1,85 +0,0 @@ -# eSports Manager - free and open source eSports Management game -# Copyright (C) 2020-2024 Pedrenrique G. Guimarães -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -from ..gui_components import * -from .layoutinterface import ILayout - - -class TeamSelectLayout(ILayout): - def __init__(self): - self.lay = self.layout() - self.col = self.column() - - def column(self) -> sg.Column: - return sg.Column( - self.lay, - key="team_select_screen", - visible=False, - element_justification="center", - ) - - def layout(self) -> list: - headings_teams = ["Name", "Overall"] - - headings_players = ["Lane", "Nick name", "Skill"] - - value = [[" ", " "]] - - team_table = [ - [esm_form_text("Teams", size=16)], - [ - esm_table( - values=value, - display_row_numbers=True, - num_rows=20, - headings=headings_teams, - key="teamselect_team_table", - enable_events=True, - ), - ], - ] - - player_table = [ - [esm_form_text("Players", size=16)], - [ - esm_table( - values=[[" ", "Select your team", " "]], - num_rows=20, - headings=headings_players, - key="teamselect_players_table", - enable_events=True, - ), - ], - ] - - return [ - [esm_title_text("Select your team\n")], - [esm_form_text("")], # line break - # TODO: IMPLEMENT REGIONS COMBO BOX - # [esm_input_combo(values=regions, key="teamselect_regions_combo")], - [ - sg.Column( - team_table, justification="center", element_justification="center" - ), - sg.Column( - player_table, justification="center", element_justification="center" - ), - ], - [ - esm_button("Select", key="teamselect_select_btn"), - esm_button("Cancel", key="teamselect_cancel_btn"), - ], - ] diff --git a/run.py b/run.py deleted file mode 100644 index 9df3aa8..0000000 --- a/run.py +++ /dev/null @@ -1,19 +0,0 @@ -# eSports Manager - free and open source eSports Management game -# Copyright (C) 2020-2024 Pedrenrique G. Guimarães -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -from esm.esm import ESMController - -esm = ESMController() -esm.app()