Mods
This commit is contained in:
parent
959efe2d8e
commit
ade8f9486c
|
@ -65,6 +65,7 @@ class Ants:
|
|||
from .game import Game
|
||||
|
||||
if len(Ants.ants) >= Config.max_ants:
|
||||
Window.alert("Max ants reached\nTerminate some to hatch new ones")
|
||||
return
|
||||
|
||||
now = Utils.now()
|
||||
|
@ -152,12 +153,20 @@ class Ants:
|
|||
@staticmethod
|
||||
def get_ants() -> None:
|
||||
objs = Storage.get_ants()
|
||||
changed = False
|
||||
|
||||
if len(objs) > Config.max_ants:
|
||||
objs = objs[: Config.max_ants]
|
||||
changed = True
|
||||
|
||||
for obj in objs:
|
||||
ant = Ant()
|
||||
ant.from_dict(obj)
|
||||
Ants.ants.append(ant)
|
||||
|
||||
if changed:
|
||||
Ants.save()
|
||||
|
||||
@staticmethod
|
||||
def most_hits() -> Ant | None:
|
||||
if not len(Ants.ants):
|
||||
|
|
|
@ -9,7 +9,7 @@ class Config:
|
|||
title: str = "Cromulant"
|
||||
width: int = 900
|
||||
height: int = 900
|
||||
max_ants: int = 100
|
||||
max_ants: int = 10
|
||||
here: Path
|
||||
ants_json: Path
|
||||
icon_path: Path
|
||||
|
@ -42,6 +42,13 @@ class Config:
|
|||
context_menu_text_color: str = "white"
|
||||
context_menu_hover_background_color: str = "rgb(36, 36, 36)"
|
||||
context_menu_hover_text_color: str = "white"
|
||||
message_box_background_color: str = "rgb(22, 22, 22)"
|
||||
message_box_text_color: str = "white"
|
||||
message_box_label_text_color: str = "white"
|
||||
message_box_button_background_color: str = "rgb(44, 44, 44)"
|
||||
message_box_button_text_color: str = "white"
|
||||
message_box_button_hover_background_color: str = "rgb(66, 66, 66)"
|
||||
message_box_button_hover_text_color: str = "white"
|
||||
|
||||
@staticmethod
|
||||
def prepare() -> None:
|
||||
|
|
|
@ -71,7 +71,11 @@ class Window:
|
|||
Window.root.setAlignment(Qt.AlignTop)
|
||||
Window.window.setCentralWidget(central_widget)
|
||||
Window.window.setWindowIcon(QIcon(str(Config.icon_path)))
|
||||
Window.root.setContentsMargins(0, 0, 0, 0)
|
||||
Window.set_style()
|
||||
|
||||
@staticmethod
|
||||
def set_style() -> None:
|
||||
font_id = QFontDatabase.addApplicationFont(str(Config.font_path))
|
||||
emoji_font_id = QFontDatabase.addApplicationFont(str(Config.emoji_font_path))
|
||||
|
||||
|
@ -97,11 +101,30 @@ class Window:
|
|||
background-color: {Config.context_menu_hover_background_color};
|
||||
color: {Config.context_menu_hover_text_color};
|
||||
}}
|
||||
|
||||
QMessageBox {{
|
||||
background-color: {Config.message_box_background_color};
|
||||
color: {Config.message_box_text_color};
|
||||
}}
|
||||
|
||||
QMessageBox QLabel {{
|
||||
background-color: {Config.message_box_background_color};
|
||||
color: {Config.message_box_label_text_color};
|
||||
}}
|
||||
|
||||
QMessageBox QPushButton {{
|
||||
background-color: {Config.message_box_button_background_color};
|
||||
color: {Config.message_box_button_text_color};
|
||||
}}
|
||||
|
||||
QMessageBox QPushButton:hover {{
|
||||
background-color: {Config.message_box_button_hover_background_color};
|
||||
color: {Config.message_box_button_hover_text_color};
|
||||
}}
|
||||
""".strip()
|
||||
|
||||
Window.app.setStyleSheet(style)
|
||||
Window.app.setFont(Window.font)
|
||||
Window.root.setContentsMargins(0, 0, 0, 0)
|
||||
|
||||
@staticmethod
|
||||
def add_buttons() -> None:
|
||||
|
@ -245,3 +268,12 @@ class Window:
|
|||
@staticmethod
|
||||
def stop_audio() -> None:
|
||||
Window.player.stop()
|
||||
|
||||
@staticmethod
|
||||
def alert(message: str) -> None:
|
||||
msg_box = QMessageBox()
|
||||
msg_box.setIcon(QMessageBox.Information)
|
||||
msg_box.setText(message)
|
||||
msg_box.setWindowTitle("Information")
|
||||
msg_box.setStandardButtons(QMessageBox.Ok)
|
||||
msg_box.exec()
|
Loading…
Reference in New Issue