Files
war-in-tunnels/src/app/game_states.rs
T
GarandPLG 2dbe378470 Add text input handling to settings popup
Introduce a `selected_setting_new_value` field in `SettingsState` and
initialize it.
Add `Backspace` and `WildCard(char)` actions with an `Input` group, and
corresponding keybindings.
Update `event_to_action` to map wildcard characters to
`Action::WildCard`.
Handle backspace and character input in `settings_keybindings` to edit
the new field.
Display the edited value in the settings popup and include the new
actions in the UI.
2026-03-15 22:37:11 +01:00

78 lines
2.0 KiB
Rust

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct GameStates {
pub main_menu_state: MainMenuState,
pub skirmish_state: SkirmishState,
pub perk_decks_state: PerkDecksState,
pub skills_config_state: SkillsConfigState,
pub settings_state: SettingsState,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct MainMenuState {
pub id: usize,
pub name: &'static str,
pub selected_view: usize,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct SkirmishState {
pub id: usize,
pub name: &'static str,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct PerkDecksState {
pub id: usize,
pub name: &'static str,
pub selected_perk_deck: usize,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct SkillsConfigState {
pub id: usize,
pub name: &'static str,
pub selected_skill: usize,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct SettingsState {
pub id: usize,
pub name: &'static str,
pub selected_setting: usize,
pub show_popup: bool,
pub selected_setting_new_value: String,
}
impl GameStates {
pub fn new() -> Self {
Self {
main_menu_state: MainMenuState {
id: 0,
name: "Main Menu",
selected_view: 1,
},
skirmish_state: SkirmishState {
id: 1,
name: "Skirmish",
},
perk_decks_state: PerkDecksState {
id: 2,
name: "Perk Decks",
selected_perk_deck: 0,
},
skills_config_state: SkillsConfigState {
id: 3,
name: "Skills Config",
selected_skill: 0,
},
settings_state: SettingsState {
id: 4,
name: "Settings",
selected_setting: 0,
show_popup: false,
selected_setting_new_value: String::new(),
},
}
}
}