This commit is contained in:
Auric Vente 2024-07-22 10:40:26 -06:00
parent bc928dc8d6
commit 9fcc9d31f8
2 changed files with 26 additions and 7 deletions

View File

@ -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()

View File

@ -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)