This commit is contained in:
Auric Vente 2024-07-22 19:38:10 -06:00
parent 9fcc9d31f8
commit 2b9eb8a4fd
4 changed files with 26 additions and 6 deletions

View File

@ -270,8 +270,10 @@ class Game:
else: else:
return return
if Game.merge_charge < Config.merge_goal:
Game.merge_charge += 1 Game.merge_charge += 1
if Settings.merge:
if Game.merge_charge >= Config.merge_goal: if Game.merge_charge >= Config.merge_goal:
nums.insert(0, Method.merge) nums.insert(0, Method.merge)
weights.insert(0, 1) weights.insert(0, 1)
@ -467,10 +469,19 @@ class Game:
menu = QMenu(Window.root.widget()) menu = QMenu(Window.root.widget())
update = QAction("Update") update = QAction("Update")
restart = QAction("Restart") restart = QAction("Restart")
if Settings.merge:
merge = QAction("Merge: On")
else:
merge = QAction("Merge: Off")
update.triggered.connect(Game.force_update) update.triggered.connect(Game.force_update)
restart.triggered.connect(Game.restart) restart.triggered.connect(Game.restart)
merge.triggered.connect(Settings.toggle_merge)
menu.addAction(update) menu.addAction(update)
menu.addAction(restart) menu.addAction(restart)
menu.addAction(merge)
menu.exec_(QCursor.pos()) menu.exec_(QCursor.pos())
@staticmethod @staticmethod

View File

@ -1,5 +1,5 @@
{ {
"version": "1.2.0", "version": "1.4.0",
"title": "Cromulant", "title": "Cromulant",
"program": "cromulant", "program": "cromulant",
"author": "madprops", "author": "madprops",

View File

@ -7,6 +7,7 @@ from .storage import Storage
class Settings: class Settings:
speed: str speed: str
mode: str mode: str
merge: bool
@staticmethod @staticmethod
def prepare() -> None: def prepare() -> None:
@ -20,11 +21,14 @@ class Settings:
mode = Settings.mode.capitalize() mode = Settings.mode.capitalize()
Window.mode.setCurrentText(mode) Window.mode.setCurrentText(mode)
Settings.merge = settings.get("merge", True)
@staticmethod @staticmethod
def save() -> None: def save() -> None:
settings = { settings = {
"speed": Settings.speed, "speed": Settings.speed,
"mode": Settings.mode, "mode": Settings.mode,
"merge": Settings.merge,
} }
Storage.save_settings(settings) Storage.save_settings(settings)
@ -38,3 +42,8 @@ class Settings:
def set_mode(mode: str) -> None: def set_mode(mode: str) -> None:
Settings.mode = mode Settings.mode = mode
Settings.save() Settings.save()
@staticmethod
def toggle_merge() -> None:
Settings.merge = not Settings.merge
Settings.save()

View File

@ -224,7 +224,7 @@ class Window:
container = QHBoxLayout() container = QHBoxLayout()
btn_menu = QPushButton("Menu") btn_menu = QPushButton("Menu")
btn_menu.setToolTip("Restart with a new set of ants") btn_menu.setToolTip("The main menu")
btn_menu.clicked.connect(Game.menu) btn_menu.clicked.connect(Game.menu)
Window.speed = QComboBox() Window.speed = QComboBox()