This commit is contained in:
Auric Vente 2024-07-19 04:03:56 -06:00
parent c19d429228
commit e71a91d328
5 changed files with 31 additions and 9 deletions

View File

@ -28,6 +28,8 @@ class Config:
hatch_burst: int = 3
font_size: int = 20
info_separator: str = " - "
font_path: Path
emoji_font_path: Path
@staticmethod
def prepare() -> None:
@ -43,3 +45,5 @@ class Config:
Config.hatched_image_path = Config.here / "img" / "icon_7.jpg"
Config.terminated_image_path = Config.here / "img" / "icon_6.jpg"
Config.names_json = Config.here / "data" / "names.json"
Config.font_path = Config.here / "fonts" / "NotoSans-Regular.ttf"
Config.emoji_font_path = Config.here / "fonts" / "NotoEmoji-Regular.ttf"

Binary file not shown.

Binary file not shown.

View File

@ -119,14 +119,14 @@ class Game:
status = ""
if num == 1:
ant.hits += 1
status = f"Took a hit ({ant.hits} total)"
elif num == 2:
ant.triumph += 1
status = f"Scored a triumph ({ant.triumph} total)"
status = f"😀 Scored a triumph ({ant.triumph} total)"
elif num == 2:
ant.hits += 1
status = f"🎃 Took a hit ({ant.hits} total)"
elif (num == 3) and (num_ants > 1):
other = Ants.get_other(ant)
status = f"Is thinking about {other.name}"
status = f"🫠 Is thinking about {other.name}"
elif num == 4:
status = s.simple_sentence()
elif num == 5:
@ -188,7 +188,7 @@ class Game:
if triumph:
text.append(f"Triumph:{nb}{triumph.name}")
if hits and (hits.name != triumph.name):
if hits and (triumph and (hits.name != triumph.name)):
text.append(f"Hits:{nb}{hits.name}")
Window.info.setText(Config.info_separator.join(text))

View File

@ -16,7 +16,8 @@ from PySide6.QtWidgets import QComboBox
from PySide6.QtWidgets import QLayout
from PySide6.QtWidgets import QSizePolicy
from PySide6.QtWidgets import QMessageBox
from PySide6.QtGui import QMouseEvent # type: ignore
from PySide6.QtGui import QFontDatabase # type: ignore
from PySide6.QtGui import QMouseEvent
from PySide6.QtGui import QIcon
from PySide6.QtCore import Qt # type: ignore
from PySide6.QtCore import Signal
@ -43,6 +44,8 @@ class Window:
speed: QComboBox
scroll_area: QScrollArea
info: SpecialButton
font: str
emoji_font: str
@staticmethod
def prepare() -> None:
@ -64,9 +67,24 @@ class Window:
Window.window.setCentralWidget(central_widget)
Window.window.setWindowIcon(QIcon(str(Config.icon_path)))
style = f"QWidget {{ background-color: {Config.background_color}; \
color: {Config.text_color}; font-size: {Config.font_size}px}}"
font_id = QFontDatabase.addApplicationFont(str(Config.font_path))
emoji_font_id = QFontDatabase.addApplicationFont(str(Config.emoji_font_path))
if font_id != -1:
Window.font = QFontDatabase.applicationFontFamilies(font_id)[0]
if emoji_font_id != -1:
Window.emoji_font = QFontDatabase.applicationFontFamilies(emoji_font_id)[0]
style = f"""
QWidget {{
background-color: {Config.background_color};
color: {Config.text_color};
font-size: {Config.font_size}px;
}}
""".strip()
Window.app.setFont(Window.font)
Window.root.setContentsMargins(0, 0, 0, 0)
Window.app.setStyleSheet(style)