Skip to content

Commit 76abafc

Browse files
feat(ui): add closed game message display
Replace the 'hide board' behavior with a 'GAME CLOSED' message displayed in the same space. This provides better visual feedback to users when the game is closed. - Add new constants for closed message text and color - Create new build_closed_message function that displays large text - Update close_game and sync_board_state to show message instead of hiding board
1 parent 41c30d8 commit 76abafc

File tree

4 files changed

+50
-5
lines changed

4 files changed

+50
-5
lines changed

src/config/constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
HEADER_TEXT = "COMMIT !BINGO"
77
HEADER_TEXT_COLOR = "#0CB2B3"
88
CLOSED_HEADER_TEXT = "Bingo Is Closed"
9+
CLOSED_MESSAGE_TEXT = "GAME CLOSED"
10+
CLOSED_MESSAGE_COLOR = "#FF7f33"
911

1012
# Free space settings
1113
FREE_SPACE_TEXT = "FREE MEAT"

src/core/game_logic.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ def generate_new_board(phrases):
255255

256256
def close_game():
257257
"""
258-
Close the game - hide the board and update the header text.
258+
Close the game - show closed message instead of the board and update the header text.
259259
This function is called when the close button is clicked.
260260
"""
261261
global is_game_closed, header_label
@@ -266,9 +266,14 @@ def close_game():
266266
header_label.set_text(CLOSED_HEADER_TEXT)
267267
header_label.update()
268268

269-
# Hide all board views (both home and stream)
269+
# Show closed message in board containers
270+
from src.config.constants import CLOSED_MESSAGE_COLOR, CLOSED_MESSAGE_TEXT
271+
from src.ui.board_builder import build_closed_message
272+
273+
# Replace board with closed message in all views
270274
for view_key, (container, tile_buttons_local) in board_views.items():
271-
container.style("display: none;")
275+
container.clear()
276+
build_closed_message(container)
272277
container.update()
273278

274279
# Modify the controls row to only show the New Board button

src/ui/board_builder.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@
99
BOARD_TILE_FONT_STYLE,
1010
BOARD_TILE_FONT_WEIGHT,
1111
CARD_CLASSES,
12+
CLOSED_MESSAGE_COLOR,
13+
CLOSED_MESSAGE_TEXT,
1214
FREE_SPACE_TEXT,
1315
FREE_SPACE_TEXT_COLOR,
1416
GRID_CLASSES,
1517
GRID_CONTAINER_CLASS,
18+
HEADER_FONT_FAMILY,
1619
LABEL_CLASSES,
1720
LABEL_SMALL_CLASSES,
1821
TILE_CLICKED_BG_COLOR,
@@ -23,6 +26,38 @@
2326
from src.utils.text_processing import get_line_style_for_lines, split_phrase_into_lines
2427

2528

29+
def build_closed_message(parent):
30+
"""
31+
Build a message indicating the game is closed, to be displayed in place of the board.
32+
33+
Args:
34+
parent: The parent UI element to build the message in
35+
"""
36+
import logging
37+
38+
with parent:
39+
with ui.element("div").classes(GRID_CONTAINER_CLASS):
40+
with ui.element("div").classes(
41+
"flex justify-center items-center h-full w-full"
42+
):
43+
ui.label(CLOSED_MESSAGE_TEXT).classes("text-center fit-header").style(
44+
f"font-family: {HEADER_FONT_FAMILY}; color: {CLOSED_MESSAGE_COLOR}; font-size: 6rem;"
45+
)
46+
47+
# Run JavaScript to ensure text is resized properly
48+
try:
49+
js_code = """
50+
setTimeout(function() {
51+
if (typeof fitty !== 'undefined') {
52+
fitty('.fit-header', { multiLine: true, minSize: 10, maxSize: 2000 });
53+
}
54+
}, 50);
55+
"""
56+
ui.run_javascript(js_code)
57+
except Exception as e:
58+
logging.debug(f"JavaScript execution failed: {e}")
59+
60+
2661
def build_board(parent, tile_buttons_dict: dict, on_tile_click, board, clicked_tiles):
2762
"""
2863
Build the common Bingo board in the given parent element.

src/ui/sync.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@ def sync_board_state():
2424
header_label.set_text(CLOSED_HEADER_TEXT)
2525
header_label.update()
2626

27-
# Hide all board views
27+
# Show closed message in all board views
28+
from src.ui.board_builder import build_closed_message
29+
2830
for view_key, (container, _) in board_views.items():
29-
container.style("display: none;")
31+
container.clear()
32+
build_closed_message(container)
3033
container.update()
3134

3235
# Make sure controls row is showing only the Start New Game button

0 commit comments

Comments
 (0)