Mods
This commit is contained in:
parent
828a6cb6d4
commit
e0c6dc3bde
|
@ -55,10 +55,15 @@ class Config:
|
|||
filter_debouncer_delay: int = 200
|
||||
default_population: int = 100
|
||||
merge_goal: int = 8
|
||||
manifest_path: Path
|
||||
manifest: dict[str, str]
|
||||
|
||||
@staticmethod
|
||||
def prepare() -> None:
|
||||
from .storage import Storage
|
||||
|
||||
Config.here = Path(__file__).parent
|
||||
Config.manifest_path = Config.here / "manifest.json"
|
||||
Config.ants_json = Path(appdirs.user_data_dir()) / "cromulant" / "ants.json"
|
||||
|
||||
if not Config.ants_json.exists():
|
||||
|
@ -83,3 +88,5 @@ class Config:
|
|||
Config.emoji_font_path = Config.here / "fonts" / "NotoEmoji-Regular.ttf"
|
||||
Config.song_path = Config.here / "audio" / "March of the Cyber Ants.mp3"
|
||||
Config.logo_path = Config.here / "img" / "logo_3.jpg"
|
||||
|
||||
Config.manifest = Storage.get_manifest()
|
||||
|
|
|
@ -40,26 +40,38 @@ class Game:
|
|||
def prepare() -> None:
|
||||
Game.fill()
|
||||
Game.info()
|
||||
Game.intro()
|
||||
|
||||
@staticmethod
|
||||
def update(ant: Ant) -> None:
|
||||
root = QWidget()
|
||||
container = QHBoxLayout()
|
||||
root.setContentsMargins(0, 0, 0, 0)
|
||||
container.setContentsMargins(0, 0, 0, 0)
|
||||
image_label = Game.get_image(ant)
|
||||
right_container = Game.make_right_container(ant)
|
||||
container.addWidget(image_label)
|
||||
container.addSpacing(Config.space_1)
|
||||
container.addWidget(right_container)
|
||||
Game.add_container(container)
|
||||
root.setLayout(container)
|
||||
Game.add_item(root)
|
||||
|
||||
@staticmethod
|
||||
def add_container(container: QHBoxLayout) -> None:
|
||||
def message(text: str) -> None:
|
||||
root = QWidget()
|
||||
root.setContentsMargins(0, 10, 0, 10)
|
||||
container = QHBoxLayout()
|
||||
container.setAlignment(Qt.AlignCenter)
|
||||
label = QLabel(text)
|
||||
container.addWidget(label)
|
||||
root.setLayout(container)
|
||||
Game.add_item(root)
|
||||
|
||||
@staticmethod
|
||||
def add_item(item: QWidget) -> None:
|
||||
from .filter import Filter
|
||||
|
||||
root = QWidget()
|
||||
root.setContentsMargins(0, 0, 0, 0)
|
||||
container.setContentsMargins(0, 0, 0, 0)
|
||||
root.setLayout(container)
|
||||
Window.view.insertWidget(0, root)
|
||||
Window.view.insertWidget(0, item)
|
||||
|
||||
while Window.view.count() > Config.max_updates:
|
||||
item = Window.view.takeAt(Window.view.count() - 1)
|
||||
|
@ -333,3 +345,8 @@ class Game:
|
|||
Game.start_loop()
|
||||
else:
|
||||
Game.toggle_song()
|
||||
|
||||
@staticmethod
|
||||
def intro() -> None:
|
||||
version = Config.manifest["version"]
|
||||
Game.message(f"🐜 🐜 Welcome to Cromulant v{version} 🐜 🐜")
|
||||
|
|
|
@ -41,3 +41,8 @@ class Storage:
|
|||
def get_countries() -> Any:
|
||||
with Config.countries_json.open() as file:
|
||||
return json.load(file)
|
||||
|
||||
@staticmethod
|
||||
def get_manifest() -> Any:
|
||||
with Config.manifest_path.open() as file:
|
||||
return json.load(file)
|
||||
|
|
Loading…
Reference in New Issue