From d65916fc4e6fbbf6c70870ebde1212608da0ead2 Mon Sep 17 00:00:00 2001 From: Auric Vente Date: Mon, 22 Jul 2024 19:53:12 -0600 Subject: [PATCH] Mods --- cromulant/config.py | 1 + cromulant/game.py | 46 ++++++++++++++++++++++++++-------- cromulant/settings.py | 58 ++++++++++++++++++++++++++++++++++++------- cromulant/window.py | 18 +++----------- 4 files changed, 90 insertions(+), 33 deletions(-) diff --git a/cromulant/config.py b/cromulant/config.py index 0b9edee..98690bb 100644 --- a/cromulant/config.py +++ b/cromulant/config.py @@ -56,6 +56,7 @@ class Config: merge_goal: int = 10 manifest_path: Path manifest: dict[str, str] + separator_color: str = "rgb(120, 120, 120)" @staticmethod def prepare() -> None: diff --git a/cromulant/game.py b/cromulant/game.py index a663283..1b5dbdc 100644 --- a/cromulant/game.py +++ b/cromulant/game.py @@ -367,16 +367,6 @@ class Game: Settings.set_speed(speed) Game.start_loop() - @staticmethod - def update_mode() -> None: - mode = Window.mode.currentText().lower() - - if mode == Settings.mode: - return - - Settings.set_mode(mode) - Game.start_loop() - @staticmethod def info() -> None: text = [] @@ -469,19 +459,55 @@ class Game: menu = QMenu(Window.root.widget()) update = QAction("Update") restart = QAction("Restart") + enable_all = QAction("Enable All") + disable_all = QAction("Disable All") if Settings.merge: merge = QAction("Merge: On") else: merge = QAction("Merge: Off") + if Settings.score_enabled: + score = QAction("Score: On") + else: + score = QAction("Score: Off") + + if Settings.travel_enabled: + travel = QAction("Travel: On") + else: + travel = QAction("Travel: Off") + + if Settings.thoughts_enabled: + thoughts = QAction("Thoughts: On") + else: + thoughts = QAction("Thoughts: Off") + + if Settings.words_enabled: + words = QAction("Words: On") + else: + words = QAction("Words: Off") + update.triggered.connect(Game.force_update) restart.triggered.connect(Game.restart) merge.triggered.connect(Settings.toggle_merge) + score.triggered.connect(Settings.toggle_score_enabled) + travel.triggered.connect(Settings.toggle_travel_enabled) + thoughts.triggered.connect(Settings.toggle_thoughts_enabled) + words.triggered.connect(Settings.toggle_words_enabled) + enable_all.triggered.connect(Settings.enable_all) + disable_all.triggered.connect(Settings.disable_all) menu.addAction(update) menu.addAction(restart) + menu.addSeparator() menu.addAction(merge) + menu.addAction(score) + menu.addAction(travel) + menu.addAction(thoughts) + menu.addAction(words) + menu.addSeparator() + menu.addAction(enable_all) + menu.addAction(disable_all) menu.exec_(QCursor.pos()) @staticmethod diff --git a/cromulant/settings.py b/cromulant/settings.py index dd87574..9838baa 100644 --- a/cromulant/settings.py +++ b/cromulant/settings.py @@ -9,6 +9,11 @@ class Settings: mode: str merge: bool + score_enabled: bool + travel_enabled: bool + thoughts_enabled: bool + words_enabled: bool + @staticmethod def prepare() -> None: settings = Storage.get_settings() @@ -17,9 +22,10 @@ class Settings: speed = Settings.speed.capitalize() Window.speed.setCurrentText(speed) - Settings.mode = settings.get("mode", "all") - mode = Settings.mode.capitalize() - Window.mode.setCurrentText(mode) + Settings.score_enabled = settings.get("score_enabled", True) + Settings.travel_enabled = settings.get("travel_enabled", True) + Settings.thoughts_enabled = settings.get("thoughts_enabled", True) + Settings.words_enabled = settings.get("words_enabled", True) Settings.merge = settings.get("merge", True) @@ -27,8 +33,11 @@ class Settings: def save() -> None: settings = { "speed": Settings.speed, - "mode": Settings.mode, "merge": Settings.merge, + "score_enabled": Settings.score_enabled, + "travel_enabled": Settings.travel_enabled, + "thoughts_enabled": Settings.thoughts_enabled, + "words_enabled": Settings.words_enabled, } Storage.save_settings(settings) @@ -38,12 +47,43 @@ class Settings: Settings.speed = speed Settings.save() - @staticmethod - def set_mode(mode: str) -> None: - Settings.mode = mode - Settings.save() - @staticmethod def toggle_merge() -> None: Settings.merge = not Settings.merge Settings.save() + + @staticmethod + def toggle_score_enabled() -> None: + Settings.score_enabled = not Settings.score_enabled + Settings.save() + + @staticmethod + def toggle_travel_enabled() -> None: + Settings.travel_enabled = not Settings.travel_enabled + Settings.save() + + @staticmethod + def toggle_thoughts_enabled() -> None: + Settings.thoughts_enabled = not Settings.thoughts_enabled + Settings.save() + + @staticmethod + def toggle_words_enabled() -> None: + Settings.words_enabled = not Settings.words_enabled + Settings.save() + + @staticmethod + def enable_all() -> None: + Settings.score_enabled = True + Settings.travel_enabled = True + Settings.thoughts_enabled = True + Settings.words_enabled = True + Settings.save() + + @staticmethod + def disable_all() -> None: + Settings.score_enabled = False + Settings.travel_enabled = False + Settings.thoughts_enabled = False + Settings.words_enabled = False + Settings.save() \ No newline at end of file diff --git a/cromulant/window.py b/cromulant/window.py index 3206671..a4e92ae 100644 --- a/cromulant/window.py +++ b/cromulant/window.py @@ -87,7 +87,6 @@ class Window: player: QMediaPlayer audio: QAudioOutput filter: QLineEdit - mode: QComboBox @staticmethod def prepare() -> None: @@ -210,6 +209,10 @@ class Window: color: white; }} + QMenu::separator {{ + background-color: {Config.separator_color}; + }} + """.strip() Window.app.setStyleSheet(style) @@ -237,18 +240,6 @@ class Window: Window.speed.setCurrentIndex(1) Window.speed.currentIndexChanged.connect(Game.update_speed) - Window.mode = QComboBox() - tooltip = "The type of updates\n" - tooltip += "All: All kind of updates\n" - tooltip += "Score: Only triumph and hit updates\n" - tooltip += "Travel: Only travel updates\n" - tooltip += "Thought: Only thought updates\n" - tooltip += "Words: Only sentences" - Window.mode.setToolTip(tooltip) - Window.mode.addItems(["All", "Score", "Travel", "Thought", "Words"]) - Window.mode.setCurrentIndex(1) - Window.mode.currentIndexChanged.connect(Game.update_mode) - Window.filter = FilterLineEdit() Window.filter.setPlaceholderText("Filter") Window.filter.mousePressEvent = lambda e: Window.to_top() @@ -256,7 +247,6 @@ class Window: container.addWidget(btn_menu, 1) container.addWidget(Window.speed, 1) - container.addWidget(Window.mode, 1) container.addWidget(Window.filter, 1) root.setLayout(container)