Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions minesweeper/ui/board_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from textual.containers import Grid
from textual.message import Message
from textual.widget import Widget
from textual.widgets import Label

from minesweeper.game.state import GameState
from minesweeper.ui.widgets import CellButton
Expand All @@ -25,9 +26,9 @@ def __init__(self, status_text: str) -> None:
}

BoardView Grid {
grid-size: 10 10;
grid-columns: 5 5 5 5 5 5 5 5 5 5;
grid-rows: 3 3 3 3 3 3 3 3 3 3;
grid-size: 11 11;
grid-columns: 5 5 5 5 5 5 5 5 5;
grid-rows: 3 3 3 3 3 3 3 3 3;
grid-gutter: 0 0;
}

Expand Down Expand Up @@ -94,6 +95,15 @@ def __init__(self, status_text: str) -> None:
BoardView CellButton.-count-8 {
color: #4c566a;
}

BoardView .coord-label {
width: 5;
height: 3;
content-align: center middle;
background: transparent;
color: $foreground;
text-style: bold;
}
"""

def __init__(self, state: GameState) -> None:
Expand All @@ -102,7 +112,11 @@ def __init__(self, state: GameState) -> None:

def compose(self) -> ComposeResult:
with Grid():
yield Label(str(""), classes="coord-label")
for x in range(self.state.width):
yield Label(str(x), classes="coord-label")
for y, row in enumerate(self.state.board):
yield Label(str(y), classes="coord-label")
for x, cell in enumerate(row):
yield CellButton(x, y, cell)

Expand Down
Loading