rsnaker/graphics/menus/retro_parameter_table/
customized_with_fruits.rs1use crate::graphics::menus::retro_parameter_table::generic_logic::{
2 get_default_action_input, CellValue, FooterData, GenericMenu, RowData,
3};
4use crate::graphics::sprites::fruit::FRUITS_SCORES_PROBABILITIES;
5use ratatui::DefaultTerminal;
6
7pub fn setup_and_run_fruits_table_parameters(terminal: &mut DefaultTerminal) {
8 GenericMenu::new(
12 load_fruits_info_in_table(),
13 &fruits_get_headers(),
14 fruits_get_footer_data(),
15 None,
16 )
17 .run(get_default_action_input(), terminal);
18}
19#[must_use]
22fn load_fruits_info_in_table() -> Vec<RowData> {
23 let mut rows = vec![];
24
25 for (fruit, score, probability, size_effect) in FRUITS_SCORES_PROBABILITIES {
26 rows.push(RowData::new(vec![
27 CellValue::new((*fruit).to_string()),
28 CellValue::new(format!("{score}")),
29 CellValue::new(format!("{probability}%")),
30 CellValue::new(size_effect.to_string()),
31 ]));
32 }
33
34 rows
35}
36
37#[must_use]
39fn fruits_get_headers() -> Vec<String> {
40 vec![
41 "🍎 Fruit".to_string(),
42 "🎯 Score x Speed Modifier".to_string(),
43 "🎲 Chance".to_string(),
44 "📏 Snake Size Effect".to_string(),
45 ]
46}
47
48#[must_use]
50fn fruits_get_footer_data() -> Vec<FooterData> {
51 vec![
52 FooterData {
53 symbol: "Esc".into(),
54 text: "Return to home".into(),
55 value: None,
56 },
57 FooterData {
58 symbol: "↕".into(),
59 text: "Move".into(),
60 value: None,
61 },
62 ]
63}