This commit is contained in:
Auric Vente 2024-07-25 10:59:52 -06:00
parent 2ddf25b069
commit e2f5d1c8f6
4 changed files with 37 additions and 6 deletions

View File

@ -48,7 +48,7 @@ class Config:
message_box_button_hover_text_color: str = "white" message_box_button_hover_text_color: str = "white"
scrollbar_handle_color: str = "rgb(69, 69, 69)" scrollbar_handle_color: str = "rgb(69, 69, 69)"
input_background_color: str = "rgb(111, 111, 111)" 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_border_color: str = "rgb(120, 120, 120)"
input_caret_color: str = "rgb(18, 18, 18)" input_caret_color: str = "rgb(18, 18, 18)"
settings_json: Path settings_json: Path

View File

@ -22,6 +22,16 @@ class Filter:
def get_value() -> str: def get_value() -> str:
return str(Window.filter.text()).lower().strip() 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 @staticmethod
def filter(event: QKeyEvent | None = None) -> None: def filter(event: QKeyEvent | None = None) -> None:
Filter.debouncer.stop() Filter.debouncer.stop()
@ -29,11 +39,12 @@ class Filter:
@staticmethod @staticmethod
def do_filter() -> None: def do_filter() -> None:
Filter.debouncer.stop()
value = Filter.get_value() value = Filter.get_value()
for i in range(Window.view.count()): for i in range(Window.view.count()):
item = Window.view.itemAt(i) item = Window.view.itemAt(i)
text = Filter.get_filter_text(item) text = Filter.get_text(item)
hide = True hide = True
for txt in text: for txt in text:
@ -47,7 +58,7 @@ class Filter:
item.widget().show() item.widget().show()
@staticmethod @staticmethod
def get_filter_text(item: QWidget) -> list[str]: def get_text(item: QWidget) -> list[str]:
text = [] text = []
layout = item.widget().layout() layout = item.widget().layout()

View File

@ -569,3 +569,18 @@ class Game:
@staticmethod @staticmethod
def change_speed(speed: str) -> None: def change_speed(speed: str) -> None:
Window.speed.setCurrentText(speed.capitalize()) 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)

View File

@ -258,7 +258,7 @@ class Window:
container = QHBoxLayout() container = QHBoxLayout()
btn_menu = SpecialButton("Menu") 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.clicked.connect(Game.menu)
btn_menu.middleClicked.connect(Game.force_update) btn_menu.middleClicked.connect(Game.force_update)
@ -359,12 +359,17 @@ class Window:
@staticmethod @staticmethod
def add_footer() -> None: def add_footer() -> None:
from .game import Game
root = QWidget() root = QWidget()
root.setContentsMargins(0, 0, 0, 0) root.setContentsMargins(0, 0, 0, 0)
container = QHBoxLayout() container = QHBoxLayout()
Window.info = QPushButton("---") Window.info = SpecialButton("---")
Window.info.setToolTip("Click to scroll to the bottom or top") Window.info.setToolTip(
"Click to scroll to the bottom or top\nMiddle Click: Filter Top"
)
Window.info.clicked.connect(Window.toggle_scroll) Window.info.clicked.connect(Window.toggle_scroll)
Window.info.middleClicked.connect(Game.filter_top)
Window.info.setMinimumSize(35, 35) Window.info.setMinimumSize(35, 35)
container.addWidget(Window.info) container.addWidget(Window.info)
root.setLayout(container) root.setLayout(container)