From e2f5d1c8f6e18805625eb57f680e667d46e06ac1 Mon Sep 17 00:00:00 2001 From: Auric Vente Date: Thu, 25 Jul 2024 10:59:52 -0600 Subject: [PATCH] Mods --- cromulant/config.py | 2 +- cromulant/filter.py | 15 +++++++++++++-- cromulant/game.py | 15 +++++++++++++++ cromulant/window.py | 11 ++++++++--- 4 files changed, 37 insertions(+), 6 deletions(-) diff --git a/cromulant/config.py b/cromulant/config.py index 868b62f..b8e0054 100644 --- a/cromulant/config.py +++ b/cromulant/config.py @@ -48,7 +48,7 @@ class Config: message_box_button_hover_text_color: str = "white" scrollbar_handle_color: str = "rgb(69, 69, 69)" input_background_color: str = "rgb(111, 111, 111)" - input_text_color: str = "rgb(18, 18, 18)" + input_text_color: str = "black" input_border_color: str = "rgb(120, 120, 120)" input_caret_color: str = "rgb(18, 18, 18)" settings_json: Path diff --git a/cromulant/filter.py b/cromulant/filter.py index ab82bb7..3313b62 100644 --- a/cromulant/filter.py +++ b/cromulant/filter.py @@ -22,6 +22,16 @@ class Filter: def get_value() -> str: return str(Window.filter.text()).lower().strip() + @staticmethod + def set_value(value: str) -> None: + Window.filter.setText(value) + Filter.do_filter() + + @staticmethod + def clear() -> None: + Window.filter.clear() + Filter.do_filter() + @staticmethod def filter(event: QKeyEvent | None = None) -> None: Filter.debouncer.stop() @@ -29,11 +39,12 @@ class Filter: @staticmethod def do_filter() -> None: + Filter.debouncer.stop() value = Filter.get_value() for i in range(Window.view.count()): item = Window.view.itemAt(i) - text = Filter.get_filter_text(item) + text = Filter.get_text(item) hide = True for txt in text: @@ -47,7 +58,7 @@ class Filter: item.widget().show() @staticmethod - def get_filter_text(item: QWidget) -> list[str]: + def get_text(item: QWidget) -> list[str]: text = [] layout = item.widget().layout() diff --git a/cromulant/game.py b/cromulant/game.py index c6fe667..d806a8a 100644 --- a/cromulant/game.py +++ b/cromulant/game.py @@ -569,3 +569,18 @@ class Game: @staticmethod def change_speed(speed: str) -> None: Window.speed.setCurrentText(speed.capitalize()) + + @staticmethod + def filter_top() -> None: + from .filter import Filter + + value = Filter.get_value() + ant = Ants.top + + if not ant: + return + + if value == ant.name.lower(): + Filter.clear() + else: + Filter.set_value(ant.name) diff --git a/cromulant/window.py b/cromulant/window.py index 1f9613a..0e28d66 100644 --- a/cromulant/window.py +++ b/cromulant/window.py @@ -258,7 +258,7 @@ class Window: container = QHBoxLayout() btn_menu = SpecialButton("Menu") - btn_menu.setToolTip("The main menu\nMiddle Click to force an update") + btn_menu.setToolTip("The main menu\nMiddle Click: Force an update") btn_menu.clicked.connect(Game.menu) btn_menu.middleClicked.connect(Game.force_update) @@ -359,12 +359,17 @@ class Window: @staticmethod def add_footer() -> None: + from .game import Game + root = QWidget() root.setContentsMargins(0, 0, 0, 0) container = QHBoxLayout() - Window.info = QPushButton("---") - Window.info.setToolTip("Click to scroll to the bottom or top") + Window.info = SpecialButton("---") + Window.info.setToolTip( + "Click to scroll to the bottom or top\nMiddle Click: Filter Top" + ) Window.info.clicked.connect(Window.toggle_scroll) + Window.info.middleClicked.connect(Game.filter_top) Window.info.setMinimumSize(35, 35) container.addWidget(Window.info) root.setLayout(container)