rsnaker/graphics/menus/retro_parameter_table/
customized_with_doc.rs

1use crate::graphics::menus::retro_parameter_table::generic_logic::{
2    get_default_action_input, CellValue, FooterData, GenericMenu, RowData,
3};
4use ratatui::DefaultTerminal;
5
6/// Sets up and runs the doc menu using the generic retro table
7pub fn setup_and_run_doc_table_parameters(terminal: &mut DefaultTerminal) {
8    GenericMenu::new(
9        load_doc_info_in_table(),
10        &doc_get_headers(),
11        doc_get_footer_data(),
12        None,
13    )
14    .run(get_default_action_input(), terminal);
15}
16
17/// Loads doc / rules information into table rows for display
18#[must_use]
19fn load_doc_info_in_table() -> Vec<RowData> {
20    let rows = vec![
21        RowData::new(vec![
22            CellValue::new("đŸŽ¯ Goal".to_string()),
23            CellValue::new("Eat fruits, grow, and score points.".to_string()),
24        ]),
25        RowData::new(vec![
26            CellValue::new("🍎 Fruits".to_string()),
27            CellValue::new(
28                "Different fruits give various scores and effects.\n\
29             Some can even reduce your size (and score)."
30                    .to_string(),
31            ),
32        ]),
33        RowData::new(vec![
34            CellValue::new("🏁 Speed".to_string()),
35            CellValue::new(
36                "Game speed changes difficulty and score multipliers.\n\
37             See the Speed menu for more details."
38                    .to_string(),
39            ),
40        ]),
41        RowData::new(vec![
42            CellValue::new("🎮 Movement".to_string()),
43            CellValue::new("Use ← ↕ → to control the snake.".to_string()),
44        ]),
45        RowData::new(vec![
46            CellValue::new("đŸ’Ĩ Collisions".to_string()),
47            CellValue::new("Avoid hitting yourself or your own tail.".to_string()),
48        ]),
49        RowData::new(vec![
50            CellValue::new("🌍 Walls".to_string()),
51            CellValue::new(
52                "The arena wraps around: going out on one side\n\
53             makes you appear on the opposite side."
54                    .to_string(),
55            ),
56        ]),
57        RowData::new(vec![
58            CellValue::new("â¸ī¸ Pause".to_string()),
59            CellValue::new("Press P or Space to pause / resume.".to_string()),
60        ]),
61        RowData::new(vec![
62            CellValue::new("🔁 New game".to_string()),
63            CellValue::new("Press R to start a new game.".to_string()),
64        ]),
65        RowData::new(vec![
66            CellValue::new("📋 Main menu".to_string()),
67            CellValue::new("Press M to return to the main menu.".to_string()),
68        ]),
69        RowData::new(vec![
70            CellValue::new("đŸšĒ Quit".to_string()),
71            CellValue::new("Press Q to quit at any time.".to_string()),
72        ]),
73    ];
74    rows
75}
76
77/// Returns the header labels for the doc information table
78#[must_use]
79fn doc_get_headers() -> Vec<String> {
80    vec!["📖 Topic".to_string(), "â„šī¸ Details".to_string()]
81}
82
83/// Returns footer data for the doc table
84#[must_use]
85fn doc_get_footer_data() -> Vec<FooterData> {
86    vec![
87        FooterData {
88            symbol: "Esc".into(),
89            text: "Return to home".into(),
90            value: None,
91        },
92        FooterData {
93            symbol: "↕".into(),
94            text: "Move".into(),
95            value: None,
96        },
97    ]
98}