From 750abdff390d8340d23043999fde618afbc3d5a1 Mon Sep 17 00:00:00 2001 From: Auric Vente Date: Fri, 26 Jul 2024 19:43:55 -0600 Subject: [PATCH] Mods --- cromulant/args.py | 6 ++++++ cromulant/argspec.py | 18 ++++++++++++++++++ cromulant/config.py | 6 +++--- cromulant/game.py | 10 ++++++---- cromulant/manifest.json | 2 +- cromulant/utils.py | 14 ++++++++------ cromulant/window.py | 13 ++++++++++--- 7 files changed, 52 insertions(+), 17 deletions(-) diff --git a/cromulant/args.py b/cromulant/args.py index 40f48b4..57dfe41 100644 --- a/cromulant/args.py +++ b/cromulant/args.py @@ -21,6 +21,9 @@ class Args: program: str = "" speed: str = "" clean: bool = False + fast_minutes: float = 0.0 + normal_minutes: float = 0.0 + slow_minutes: float = 0.0 @staticmethod def prepare() -> None: @@ -47,6 +50,9 @@ class Args: "program", "speed", "clean", + "fast_minutes", + "normal_minutes", + "slow_minutes", ] for n_item in normals: diff --git a/cromulant/argspec.py b/cromulant/argspec.py index 35ec4fe..710f246 100644 --- a/cromulant/argspec.py +++ b/cromulant/argspec.py @@ -142,3 +142,21 @@ class ArgSpec: action="store_true", info="Start with clean ants data", ) + + ArgSpec.add_argument( + "fast_minutes", + type=float, + info="The number of minutes between fast updates", + ) + + ArgSpec.add_argument( + "normal_minutes", + type=float, + info="The number of minutes between normal updates", + ) + + ArgSpec.add_argument( + "slow_minutes", + type=float, + info="The number of minutes between slow updates", + ) diff --git a/cromulant/config.py b/cromulant/config.py index b8e0054..82fb826 100644 --- a/cromulant/config.py +++ b/cromulant/config.py @@ -24,9 +24,9 @@ class Config: image_size: int = 80 space_1: int = 18 max_updates: int = 300 - loop_delay_fast: int = 1000 * 5 - loop_delay_normal: int = 1000 * 60 * 1 - loop_delay_slow: int = 1000 * 60 * 5 + fast_minutes: float = (1 / 60) * 5 # 5 seconds + normal_minutes: float = 1 + slow_minutes: float = 5 font_size: int = 20 info_separator: str = " - " font_path: Path diff --git a/cromulant/game.py b/cromulant/game.py index 5937b89..cd81ccf 100644 --- a/cromulant/game.py +++ b/cromulant/game.py @@ -348,17 +348,19 @@ class Game: speed = Settings.speed if speed == "fast": - delay = Config.loop_delay_fast + minutes = Args.fast_minutes or Config.fast_minutes elif speed == "normal": - delay = Config.loop_delay_normal + minutes = Args.normal_minutes or Config.normal_minutes elif speed == "slow": - delay = Config.loop_delay_slow + minutes = Args.slow_minutes or Config.slow_minutes else: return Game.timer = QTimer() Game.timer.timeout.connect(Game.get_status) - Game.timer.start(delay) + + msecs = minutes * 60 * 1000 + Game.timer.start(msecs) @staticmethod def update_speed() -> None: diff --git a/cromulant/manifest.json b/cromulant/manifest.json index 98ec037..1c5ebe4 100644 --- a/cromulant/manifest.json +++ b/cromulant/manifest.json @@ -1,5 +1,5 @@ { - "version": "2.1.0", + "version": "2.2.0", "title": "Cromulant", "program": "cromulant", "author": "madprops", diff --git a/cromulant/utils.py b/cromulant/utils.py index f49e666..d5528a2 100644 --- a/cromulant/utils.py +++ b/cromulant/utils.py @@ -141,18 +141,20 @@ class Utils: return dt_object.strftime(f"%b %d %Y - {hour}:%M %p") @staticmethod - def get_seconds(msecs: int) -> str: - seconds = msecs // 1000 + def get_timeword(minutes: float) -> str: + if minutes < 1: + seconds = round(minutes * 60) - if seconds < 60: - return f"{seconds} seconds" + if seconds == 1: + return "1 second" - minutes = seconds // 60 + if seconds < 60: + return f"{seconds} seconds" if minutes == 1: return "1 minute" - return f"{minutes} minutes" + return f"{round(minutes)} minutes" @staticmethod def random_country(ignore: list[str]) -> str: diff --git a/cromulant/window.py b/cromulant/window.py index 027eb34..7d25525 100644 --- a/cromulant/window.py +++ b/cromulant/window.py @@ -272,9 +272,16 @@ class Window: Window.speed = SpecialComboBox() tooltip = "The speed of the updates\n" - tooltip += f"Fast: {Utils.get_seconds(Config.loop_delay_fast)}\n" - tooltip += f"Normal: {Utils.get_seconds(Config.loop_delay_normal)}\n" - tooltip += f"Slow: {Utils.get_seconds(Config.loop_delay_slow)}\n" + + fast = Args.fast_minutes or Config.fast_minutes + tooltip += f"Fast: {Utils.get_timeword(fast)}\n" + + normal = Args.normal_minutes or Config.normal_minutes + tooltip += f"Normal: {Utils.get_timeword(normal)}\n" + + slow = Args.slow_minutes or Config.slow_minutes + tooltip += f"Slow: {Utils.get_timeword(slow)}\n" + tooltip += "Middle Click: Slow" Window.speed.setToolTip(tooltip) Window.speed.addItems(["Fast", "Normal", "Slow", "Paused"])