Add side panel and refactor title helpers

Introduce a `side_panel` flag throughout the skirmish state, board
creation,
and cell area calculation to enable a detachable side panel. Refactor
the
title helper to own its strings and use a static separator, updating the
single‑title helper accordingly. Add a new `SidePanelWidget` and expose
the
`skirmish_main_area_layout` helper. Extend keybindings with `Tab` and
`ShiftTab` actions under a new `Opener` group. Update structures and
units
to implement a `get_name` method and adjust related traits and imports.
This commit is contained in:
2026-04-24 11:41:09 +02:00
parent 06a439ff88
commit cf843057c3
23 changed files with 302 additions and 123 deletions
@@ -19,4 +19,8 @@ impl Unit for MinerUnit {
fn get_tag(&self) -> char {
'M'
}
fn get_name(&self) -> &'static str {
"Miner"
}
}
+1 -1
View File
@@ -4,4 +4,4 @@ mod units_trait;
pub use miner::MinerUnit;
pub use units_enum::Units;
pub use units_trait::{OptionalUnit, Unit};
pub use units_trait::Unit;
@@ -1,20 +1,43 @@
use crate::app::states::skirmish_states::units::{MinerUnit, OptionalUnit, Unit};
use crate::app::states::{
Players,
skirmish_states::units::{MinerUnit, Unit},
};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Units {
Miner(MinerUnit),
}
impl Units {
pub fn get_tag(&self) -> char {
impl Unit for Units {
fn get_tag(&self) -> char {
match self {
Units::Miner(m) => m.get_tag(),
Self::Miner(m) => m.get_tag(),
}
}
fn get_name(&self) -> &'static str {
match self {
Self::Miner(m) => m.get_name(),
}
}
fn get_owner(&self) -> Players {
match self {
Self::Miner(m) => m.get_owner(),
}
}
}
impl OptionalUnit for Option<Units> {
fn try_get_tag(&self) -> char {
impl Unit for Option<Units> {
fn get_tag(&self) -> char {
self.map_or(' ', |u| u.get_tag())
}
fn get_name(&self) -> &'static str {
self.map_or("", |u| u.get_name())
}
fn get_owner(&self) -> Players {
self.map_or(Players::Enemy, |u| u.get_owner())
}
}
@@ -3,8 +3,5 @@ use crate::app::states::Players;
pub trait Unit {
fn get_owner(&self) -> Players;
fn get_tag(&self) -> char;
}
pub trait OptionalUnit {
fn try_get_tag(&self) -> char;
fn get_name(&self) -> &'static str;
}