From 9fcc9d31f8a27d545b7ff0ef3df6b45047d83080 Mon Sep 17 00:00:00 2001 From: Auric Vente Date: Mon, 22 Jul 2024 10:40:26 -0600 Subject: [PATCH] Mods --- cromulant/game.py | 25 ++++++++++++++++++++++--- cromulant/window.py | 8 ++++---- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/cromulant/game.py b/cromulant/game.py index 843b3a2..1c617ed 100644 --- a/cromulant/game.py +++ b/cromulant/game.py @@ -2,15 +2,18 @@ from __future__ import annotations import random -from PySide6.QtCore import Qt # type: ignore from PySide6.QtWidgets import QHBoxLayout # type: ignore from PySide6.QtWidgets import QVBoxLayout from PySide6.QtWidgets import QLabel from PySide6.QtWidgets import QWidget from PySide6.QtWidgets import QFrame -from PySide6.QtGui import QMouseEvent # type: ignore +from PySide6.QtWidgets import QMenu +from PySide6.QtGui import QCursor # type: ignore +from PySide6.QtGui import QMouseEvent from PySide6.QtGui import QPixmap -from PySide6.QtCore import QTimer +from PySide6.QtGui import QAction +from PySide6.QtCore import QTimer # type: ignore +from PySide6.QtCore import Qt from .config import Config from .utils import Utils @@ -458,3 +461,19 @@ class Game: def intro() -> None: version = Config.manifest["version"] Game.message(f"Welcome to Cromulant v{version}") + + @staticmethod + def menu() -> None: + menu = QMenu(Window.root.widget()) + update = QAction("Update") + restart = QAction("Restart") + update.triggered.connect(Game.force_update) + restart.triggered.connect(Game.restart) + menu.addAction(update) + menu.addAction(restart) + menu.exec_(QCursor.pos()) + + @staticmethod + def force_update() -> None: + Game.get_status() + Game.start_loop() diff --git a/cromulant/window.py b/cromulant/window.py index d7137fe..ff68178 100644 --- a/cromulant/window.py +++ b/cromulant/window.py @@ -223,9 +223,9 @@ class Window: root = QWidget() container = QHBoxLayout() - btn_restart = QPushButton("Restart") - btn_restart.setToolTip("Restart with a new set of ants") - btn_restart.clicked.connect(Game.restart) + btn_menu = QPushButton("Menu") + btn_menu.setToolTip("Restart with a new set of ants") + btn_menu.clicked.connect(Game.menu) Window.speed = QComboBox() tooltip = "The speed of the updates\n" @@ -254,7 +254,7 @@ class Window: Window.filter.mousePressEvent = lambda e: Window.to_top() Window.filter.keyReleaseEvent = lambda e: Filter.filter(e) - container.addWidget(btn_restart, 1) + container.addWidget(btn_menu, 1) container.addWidget(Window.speed, 1) container.addWidget(Window.mode, 1) container.addWidget(Window.filter, 1)