Show unit task queue and mark in side panel

Add `get_tasks` to the `Unit` trait and implement it for `MinerUnit`,
`Units` enum and `Option<Units>`.  Use the new method in `base_text` to
display a “Tasks Queue” line.

Refactor task assignment in `BoardState` to a chained call.

Update the skirmish view and `SidePanelWidget` to pass a flag indicating
whether the displayed unit is the currently marked one, and highlight
the
unit name accordingly.
This commit is contained in:
2026-05-17 11:00:06 +02:00
parent a7d8823bf2
commit e4728aab5d
6 changed files with 41 additions and 5 deletions
+15 -2
View File
@@ -17,14 +17,21 @@ pub struct SidePanelWidget<'a> {
coords: (usize, usize),
structure: &'a Structures,
unit: &'a Option<Units>,
is_unit_marked: bool,
}
impl<'a> SidePanelWidget<'a> {
pub fn new(coords: (usize, usize), structure: &'a Structures, unit: &'a Option<Units>) -> Self {
pub fn new(
coords: (usize, usize),
structure: &'a Structures,
unit: &'a Option<Units>,
is_unit_marked: bool,
) -> Self {
Self {
coords,
structure,
unit,
is_unit_marked,
}
}
@@ -86,9 +93,15 @@ impl Widget for SidePanelWidget<'_> {
.render(structure_area, buf);
if self.unit.is_unit() {
let mut unit_name: String = self.unit.get_name().to_string();
if self.is_unit_marked {
unit_name = format!("> {} <", unit_name);
}
Paragraph::new(self.unit.text())
.alignment(Alignment::Left)
.block(self.get_inner_block(self.unit.get_name().to_string(), Color::Green))
.block(self.get_inner_block(unit_name, Color::Green))
.render(unit_area, buf);
}
}