-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelpPage.py
More file actions
42 lines (33 loc) · 1.33 KB
/
HelpPage.py
File metadata and controls
42 lines (33 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from textual.app import ComposeResult
from textual.containers import Horizontal, Vertical
from textual.screen import ModalScreen
from textual.widgets import Button, MarkdownViewer
HELP_TEXT = """\
# Welcome to 2024
## Game Overview
The aim of this game is to keep going as long as possible. At the start, and after
each valid move made, a vacant cell is assigned a low value. You move the cells
up, down, left, or right. Occupied cells will move into any vacant cells in that
direction. Any cells having the same value will combine into a higher value.
## Controls
Movement is made via the keyboard as per the following table:
| Keyboard | Control |
|----------------|------------|
| w / j / ⇑ | Move Up |
| s / k / ⇓ | Move Down |
| a / h / ⇓ | Move Left |
| d / l / ⇓ | Move Right |
"""
class HelpPage(ModalScreen):
"""Screen with a dialog to quit."""
CSS_PATH = "HelpPage.tcss"
def compose(self) -> ComposeResult:
with Vertical():
yield MarkdownViewer(HELP_TEXT, show_table_of_contents=False, classes="help")
with Horizontal(id="footer"):
yield Button("Close", variant="primary", id="close")
def on_button_pressed(self, event: Button.Pressed) -> None:
if event.button.id == "close":
self.dismiss()
else:
pass