Add tab navigation for building and recruitment UI
Nix package / build (push) Successful in 7m59s
Linux package builds (test) / linux (push) Successful in 2m29s
Linux package builds (test) / aur (push) Successful in 7m18s
Rust checks / check (push) Successful in 3m21s

- Add selection indices and option lists to SkirmishState.
- Implement `cycle_popup_option` and expose Left/Right actions in
  keybindings.
- Introduce `cancel_focused_tasks` in BoardState for Delete handling.
- CellWidget now displays recruitment progress on Base structures.
- Update README and documentation to describe new tabs and arrow
  navigation.
- Adjust test counts and add extensive task‑cancellation tests.
This commit is contained in:
GarandPLG committed 2026-10-23 17:53:46 +02:00
1 parent 6c1141a711
commit 110d4c411a
16 files changed
+546 -48

No files matched your search

+34 -2
View File
@@ -77,7 +77,7 @@ fn building_view_has_its_own_help_and_does_not_build_on_invalid_tile() -> () {
assert!(app.states_ref().unwrap().skirmish.building_view);
assert_eq!(
available_skirmish_actions(&app.states_ref().unwrap().skirmish),
[Action::Building, Action::Esc, Action::Quit2]
[Action::Building, Action::Left, Action::Right, Action::Quit2]
);
press(&mut app, KeyCode::Left, KeyModifiers::NONE);
press(&mut app, KeyCode::Enter, KeyModifiers::NONE);
@@ -99,7 +99,11 @@ fn building_view_has_its_own_help_and_does_not_build_on_invalid_tile() -> () {
assert!(text.contains("Construction unavailable"));
assert!(text.contains("Close buildings"));
assert!(!text.contains("Marking cells"));
assert!(!text.contains("Esc -"));
press(&mut app, KeyCode::Esc, KeyModifiers::NONE);
assert!(app.states_ref().unwrap().skirmish.building_view);
assert_eq!(app.view, View::Skirmish);
press(&mut app, KeyCode::Char('b'), KeyModifiers::NONE);
assert!(!app.states_ref().unwrap().skirmish.building_view);
assert_eq!(app.view, View::Skirmish);
for row in &app.states_ref().unwrap().skirmish.board.cells {
@@ -183,7 +187,7 @@ fn construction_and_recruitment_popups_render_semantic_text_colors() -> () {
.unwrap();
let cells: &[Cell] = &terminal.backend().buffer().content;
for (text, color) in [
(name, Color::Yellow),
(name, Color::LightMagenta),
("Cost:", Color::Yellow),
(status, status_color),
] {
@@ -203,3 +207,31 @@ fn construction_and_recruitment_popups_render_semantic_text_colors() -> () {
}
}
}
#[test]
fn popup_tabs_cycle_without_moving_map_or_changing_queues() -> () {
for key in ['b', 'r'] {
let mut app: App = app();
if key == 'r' {
press(&mut app, KeyCode::Left, KeyModifiers::NONE);
}
let before: war_in_tunnels::app::states::skirmish_states::BoardState =
app.states_ref().unwrap().skirmish.board.clone();
press(&mut app, KeyCode::Char(key), KeyModifiers::NONE);
for code in [KeyCode::Left, KeyCode::Right, KeyCode::Right, KeyCode::Left] {
press(&mut app, code, KeyModifiers::NONE);
let state: &war_in_tunnels::app::states::SkirmishState =
&app.states_ref().unwrap().skirmish;
assert_eq!(state.board, before);
assert_eq!(state.selected_building, 0);
assert_eq!(state.selected_recruit, 0);
assert!(available_skirmish_actions(state).contains(&Action::Left));
assert!(available_skirmish_actions(state).contains(&Action::Right));
}
press(&mut app, KeyCode::Esc, KeyModifiers::NONE);
assert_eq!(app.view, View::Skirmish);
press(&mut app, KeyCode::Char(key), KeyModifiers::NONE);
assert!(!app.states_ref().unwrap().skirmish.building_view);
assert!(!app.states_ref().unwrap().skirmish.recruitment_view);
}
}