Files
war-in-tunnels/src/app/keybindings/main_menu.rs
T
GarandPLG 0577697059 Replace settings module with skirmish mode
Removed the settings UI and its keybinding logic, added a skirmish view
and corresponding keybindings, simplified the SettingsState to hold
skirmish configuration, updated module exports, and changed the CLI
default map height from 25 to 21. Also fixed the main menu selection
limit.
2026-03-17 14:28:46 +01:00

35 lines
1.1 KiB
Rust

use crate::app::{
App, View,
keybindings::{Action, event_to_action},
};
use ratatui::crossterm::event::KeyEvent;
pub fn main_menu_keybindings(app: &mut App, event: &KeyEvent) {
if let Some(action) = event_to_action(&event) {
match action {
Action::Quit => app.exit = true,
Action::Quit2 => app.exit = true,
Action::Up => {
app.states.main_menu.selected_view =
app.states.main_menu.selected_view.saturating_sub(1).max(1);
}
Action::Down => {
app.states.main_menu.selected_view =
app.states.main_menu.selected_view.saturating_add(1).min(3);
}
Action::Space => {
let selected_view: usize = app.states.main_menu.selected_view;
if selected_view == 1 {
app.view = View::Skirmish;
} else if selected_view == 2 {
app.view = View::PerkDecks;
} else if selected_view == 3 {
app.view = View::SkillsConfig;
}
}
_ => (),
}
}
}