Mods
This commit is contained in:
parent
3d8ff1f167
commit
b96a3f3057
|
@ -52,6 +52,7 @@ class Config:
|
|||
settings_json: Path
|
||||
countries_json: Path
|
||||
filter_width: int = 150
|
||||
filter_debouncer_delay: int = 200
|
||||
|
||||
@staticmethod
|
||||
def prepare() -> None:
|
||||
|
|
|
@ -2,17 +2,33 @@ from __future__ import annotations
|
|||
|
||||
from PySide6.QtWidgets import QWidget # type: ignore
|
||||
from PySide6.QtGui import QKeyEvent # type: ignore
|
||||
from PySide6.QtCore import QTimer
|
||||
|
||||
from .config import Config
|
||||
from .window import Window
|
||||
|
||||
|
||||
class Filter:
|
||||
debouncer: QTimer
|
||||
|
||||
@staticmethod
|
||||
def prepare() -> None:
|
||||
Filter.debouncer = QTimer()
|
||||
Filter.debouncer.setSingleShot(True)
|
||||
Filter.debouncer.setInterval(Config.filter_debouncer_delay)
|
||||
Filter.debouncer.timeout.connect(Filter.do_filter)
|
||||
|
||||
@staticmethod
|
||||
def get_value() -> str:
|
||||
return str(Window.filter.text()).lower().strip()
|
||||
|
||||
@staticmethod
|
||||
def filter(event: QKeyEvent | None = None) -> None:
|
||||
Filter.debouncer.stop()
|
||||
Filter.debouncer.start()
|
||||
|
||||
@staticmethod
|
||||
def do_filter() -> None:
|
||||
value = Filter.get_value()
|
||||
|
||||
for i in range(Window.view.count()):
|
||||
|
|
|
@ -273,7 +273,7 @@ class Game:
|
|||
|
||||
@staticmethod
|
||||
def restart() -> None:
|
||||
opts = ["25", "50", "100", "200", "300", "400", "500"]
|
||||
opts = ["25", "50", "100", "200", "300"]
|
||||
opts = [f"{opt} ants" for opt in opts]
|
||||
size = Window.prompt_combobox("Size of the population", opts, 2)
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ from .ants import Ants
|
|||
from .window import Window
|
||||
from .game import Game
|
||||
from .settings import Settings
|
||||
from .filter import Filter
|
||||
|
||||
|
||||
def main() -> None:
|
||||
|
@ -14,6 +15,7 @@ def main() -> None:
|
|||
Window.prepare()
|
||||
Ants.prepare()
|
||||
Settings.prepare()
|
||||
Filter.prepare()
|
||||
Game.prepare()
|
||||
Game.start_loop()
|
||||
Window.start()
|
||||
|
|
Loading…
Reference in New Issue