diff --git a/cromulant/config.py b/cromulant/config.py index 251e6dc..bbc85af 100644 --- a/cromulant/config.py +++ b/cromulant/config.py @@ -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" diff --git a/cromulant/fonts/NotoEmoji-Regular.ttf b/cromulant/fonts/NotoEmoji-Regular.ttf new file mode 100644 index 0000000..0bcb2c0 Binary files /dev/null and b/cromulant/fonts/NotoEmoji-Regular.ttf differ diff --git a/cromulant/fonts/NotoSans-Regular.ttf b/cromulant/fonts/NotoSans-Regular.ttf new file mode 100644 index 0000000..fa4cff5 Binary files /dev/null and b/cromulant/fonts/NotoSans-Regular.ttf differ diff --git a/cromulant/game.py b/cromulant/game.py index 275fed6..5747158 100644 --- a/cromulant/game.py +++ b/cromulant/game.py @@ -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)) diff --git a/cromulant/window.py b/cromulant/window.py index 8dff08a..f20c8e8 100644 --- a/cromulant/window.py +++ b/cromulant/window.py @@ -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)