From 4f1aec1bee27a399d7b51a35c498a28e7def6a95 Mon Sep 17 00:00:00 2001 From: Auric Vente Date: Fri, 19 Jul 2024 20:30:37 -0600 Subject: [PATCH] Mods --- cromulant/config.py | 6 +++--- cromulant/utils.py | 14 ++++++++++++++ cromulant/window.py | 7 ++++++- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/cromulant/config.py b/cromulant/config.py index 3307e26..db529e4 100644 --- a/cromulant/config.py +++ b/cromulant/config.py @@ -22,9 +22,9 @@ class Config: image_size: int = 80 space_1: int = 20 max_messages: int = 200 - loop_delay_fast: int = 3_000 - loop_delay_normal: int = 60_000 - loop_delay_slow: int = 120_000 + loop_delay_fast: int = 1000 * 5 + loop_delay_normal: int = 1000 * 60 * 1 + loop_delay_slow: int = 1000 * 60 * 5 hatch_burst: int = 3 font_size: int = 20 info_separator: str = " - " diff --git a/cromulant/utils.py b/cromulant/utils.py index 4571184..e2a15f6 100644 --- a/cromulant/utils.py +++ b/cromulant/utils.py @@ -115,3 +115,17 @@ class Utils: dt_object = datetime.fromtimestamp(timestamp) hour = dt_object.strftime("%I").lstrip("0") return dt_object.strftime(f"%b %d %Y - {hour}:%M %p") + + @staticmethod + def get_seconds(msecs: int) -> str: + seconds = msecs // 1000 + + if seconds < 60: + return f"{seconds} seconds" + + minutes = seconds // 60 + + if minutes == 1: + return "1 minute" + + return f"{minutes} minutes" diff --git a/cromulant/window.py b/cromulant/window.py index 86d0dd7..faf9130 100644 --- a/cromulant/window.py +++ b/cromulant/window.py @@ -26,6 +26,7 @@ from PySide6.QtMultimedia import QMediaPlayer # type: ignore from PySide6.QtMultimedia import QAudioOutput from .config import Config +from .utils import Utils class SpecialButton(QPushButton): # type: ignore @@ -149,7 +150,11 @@ class Window: btn_terminate.middleClicked.connect(lambda: Ants.terminate_all()) Window.speed = QComboBox() - Window.speed.setToolTip("Change the speed of the updates") + tooltip = "Change the speed of the loop\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)}" + Window.speed.setToolTip(tooltip) Window.speed.addItems(["Fast", "Normal", "Slow"]) Window.speed.setCurrentIndex(1) Window.speed.currentIndexChanged.connect(Game.update_speed)