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.
This commit is contained in:
2026-03-15 22:37:11 +01:00
parent 9d4ff19b6e
commit 2dbe378470
5 changed files with 112 additions and 46 deletions
+18
View File
@@ -7,6 +7,8 @@ use ratatui::crossterm::event::KeyEvent;
pub fn settings_keybindings(app: &mut App, key_event: &KeyEvent) {
if let Some(action) = event_to_action(&key_event) {
match action {
// Action::Up,
// Action::Down,
Action::Quit => app.exit = true,
Action::Quit2 => app.exit = true,
Action::Esc => app.view = View::MainMenu,
@@ -14,6 +16,22 @@ pub fn settings_keybindings(app: &mut App, key_event: &KeyEvent) {
app.game_states.settings_state.show_popup =
!app.game_states.settings_state.show_popup
}
Action::Backspace => {
if app.game_states.settings_state.show_popup {
app.game_states
.settings_state
.selected_setting_new_value
.pop();
}
}
Action::WildCard(c) => {
if app.game_states.settings_state.show_popup {
app.game_states
.settings_state
.selected_setting_new_value
.push(c);
}
}
_ => (),
}
}