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

+26 -3
View File
@@ -1,10 +1,11 @@
use crate::app::states::skirmish_states::BoardState;
use crate::app::states::skirmish_states::{BoardState, Players, tasks::Task, units::Unit};
use crate::app::widgets::CellWidget;
use ratatui::{
buffer::Buffer,
layout::{Constraint, Layout, Rect},
widgets::Widget,
};
use std::rc::Rc;
use std::{collections::HashSet, rc::Rc};
pub struct BoardWidget<'a> {
state: &'a BoardState,
@@ -18,6 +19,18 @@ impl<'a> BoardWidget<'a> {
impl Widget for BoardWidget<'_> {
fn render(self, area: Rect, buf: &mut Buffer) {
let mut queued_path: HashSet<(usize, usize)> = HashSet::new();
for row in &self.state.cells {
for cell in row {
if let Some(unit) = cell.get_ref_option_unit()
&& unit.get_owner() == Players::Player
{
for task in unit.get_ref_tasks() {
queued_path.extend(task.get_path().iter().copied());
}
}
}
}
let horizontal: Rc<[Rect]> =
Layout::horizontal(vec![
Constraint::Length(self.state.cell_width as u16);
@@ -38,7 +51,17 @@ impl Widget for BoardWidget<'_> {
.cells
.get(row_idx + self.state.vertical_offset.get_value())
.and_then(|rows| rows.get(col_idx + self.state.horizontal_offset.get_value()))
.map(|cell| cell.clone().render(*cell_area, buf));
.map(|cell: &CellWidget| -> () {
let mut cell: CellWidget = cell.clone();
let coords: (usize, usize) = (
row_idx + self.state.vertical_offset.get_value(),
col_idx + self.state.horizontal_offset.get_value(),
);
if queued_path.contains(&coords) {
cell.set_marked(true);
}
cell.render(*cell_area, buf);
});
}
}
}