From 9378b8c27a9b1154609a397154144202542d67d9 Mon Sep 17 00:00:00 2001 From: Auric Vente Date: Mon, 22 Jul 2024 20:27:30 -0600 Subject: [PATCH] Mods --- cromulant/config.py | 2 ++ cromulant/game.py | 41 +++++++++++++++++++++++++++-------------- cromulant/settings.py | 16 +++++++++------- cromulant/window.py | 4 ++++ 4 files changed, 42 insertions(+), 21 deletions(-) diff --git a/cromulant/config.py b/cromulant/config.py index 98690bb..15a3555 100644 --- a/cromulant/config.py +++ b/cromulant/config.py @@ -57,6 +57,8 @@ class Config: manifest_path: Path manifest: dict[str, str] separator_color: str = "rgb(120, 120, 120)" + color_on: str = "#00ff11" + color_off: str = "#ff0004" @staticmethod def prepare() -> None: diff --git a/cromulant/game.py b/cromulant/game.py index 4db0977..4ba1a69 100644 --- a/cromulant/game.py +++ b/cromulant/game.py @@ -9,6 +9,7 @@ from PySide6.QtWidgets import QLabel from PySide6.QtWidgets import QWidget from PySide6.QtWidgets import QFrame from PySide6.QtWidgets import QMenu +from PySide6.QtWidgets import QWidgetAction from PySide6.QtGui import QCursor # type: ignore from PySide6.QtGui import QMouseEvent from PySide6.QtGui import QPixmap @@ -236,7 +237,7 @@ class Game: if Settings.travel_enabled: opts.extend(Method.opts_travel()) - if Settings.thoughts_enabled: + if Settings.think_enabled: opts.extend(Method.opts_thought()) if Settings.words_enabled: @@ -441,37 +442,49 @@ class Game: enable_all = QAction("Enable All") disable_all = QAction("Disable All") + tag_on = f"On" + tag_off = f"Off" + + def make(text: str) -> QWidgetAction: + label = QLabel(text) + label.setTextFormat(Qt.RichText) + label.setContentsMargins(10, 5, 10, 5) + label.setObjectName("menu_label") + widget_action = QWidgetAction(None) + widget_action.setDefaultWidget(label) + return widget_action + if Settings.merge: - merge = QAction("Merge: On") + merge = make(f"Merge: {tag_on}") else: - merge = QAction("Merge: Off") + merge = make(f"Merge: {tag_off}") if Settings.score_enabled: - score = QAction("Score: On") + score = make(f"Score: {tag_on}") else: - score = QAction("Score: Off") + score = make(f"Score: {tag_off}") if Settings.travel_enabled: - travel = QAction("Travel: On") + travel = make(f"Travel: {tag_on}") else: - travel = QAction("Travel: Off") + travel = make(f"Travel: {tag_off}") - if Settings.thoughts_enabled: - thoughts = QAction("Thoughts: On") + if Settings.think_enabled: + think = make(f"Think: {tag_on}") else: - thoughts = QAction("Thoughts: Off") + think = make(f"Think: {tag_off}") if Settings.words_enabled: - words = QAction("Words: On") + words = make(f"Words: {tag_on}") else: - words = QAction("Words: Off") + words = make(f"Words: {tag_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) + think.triggered.connect(Settings.toggle_think_enabled) words.triggered.connect(Settings.toggle_words_enabled) enable_all.triggered.connect(Settings.enable_all) disable_all.triggered.connect(Settings.disable_all) @@ -482,7 +495,7 @@ class Game: menu.addAction(merge) menu.addAction(score) menu.addAction(travel) - menu.addAction(thoughts) + menu.addAction(think) menu.addAction(words) menu.addSeparator() menu.addAction(enable_all) diff --git a/cromulant/settings.py b/cromulant/settings.py index bd54fbe..1e22bfb 100644 --- a/cromulant/settings.py +++ b/cromulant/settings.py @@ -11,7 +11,7 @@ class Settings: score_enabled: bool travel_enabled: bool - thoughts_enabled: bool + think_enabled: bool words_enabled: bool @staticmethod @@ -24,7 +24,7 @@ class Settings: 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.think_enabled = settings.get("think_enabled", True) Settings.words_enabled = settings.get("words_enabled", True) Settings.merge = settings.get("merge", True) @@ -36,7 +36,7 @@ class Settings: "merge": Settings.merge, "score_enabled": Settings.score_enabled, "travel_enabled": Settings.travel_enabled, - "thoughts_enabled": Settings.thoughts_enabled, + "think_enabled": Settings.think_enabled, "words_enabled": Settings.words_enabled, } @@ -63,8 +63,8 @@ class Settings: Settings.save() @staticmethod - def toggle_thoughts_enabled() -> None: - Settings.thoughts_enabled = not Settings.thoughts_enabled + def toggle_think_enabled() -> None: + Settings.think_enabled = not Settings.think_enabled Settings.save() @staticmethod @@ -74,16 +74,18 @@ class Settings: @staticmethod def enable_all() -> None: + Settings.merge = True Settings.score_enabled = True Settings.travel_enabled = True - Settings.thoughts_enabled = True + Settings.think_enabled = True Settings.words_enabled = True Settings.save() @staticmethod def disable_all() -> None: + Settings.merge = False Settings.score_enabled = False Settings.travel_enabled = False - Settings.thoughts_enabled = False + Settings.think_enabled = False Settings.words_enabled = False Settings.save() diff --git a/cromulant/window.py b/cromulant/window.py index a4e92ae..8559b1f 100644 --- a/cromulant/window.py +++ b/cromulant/window.py @@ -213,6 +213,10 @@ class Window: background-color: {Config.separator_color}; }} + QLabel#menu_label:hover {{ + background-color: {Config.alt_hover_background_color}; + }} + """.strip() Window.app.setStyleSheet(style)