Refactor Units enum location and chain CellWidget setters

Move Units enum from the units module into the skirmish state module,
add a dedicated Players enum, and remove the now‑unused unit module.
Update all imports accordingly.
Adjust CellWidget's set_zoom_level and set_structure to return &mut
Self,
enabling method chaining.
This commit is contained in:
2026-04-16 22:02:15 +02:00
parent 6dc5f8605c
commit e6d87dd064
6 changed files with 18 additions and 21 deletions
+1 -1
View File
@@ -9,5 +9,5 @@ pub use main_menu::MainMenuState;
pub use perk_decks::{PerkDecks, PerkDecksState};
pub use settings::SettingsState;
pub use skills_config::SkillsConfigState;
pub use skirmish::{CellStructure, GameMode, Players, SkirmishState, ZoomLevel};
pub use skirmish::{CellStructure, GameMode, Players, SkirmishState, Units, ZoomLevel};
pub use skirmish_states::{FocusedCell, Offset};
+9 -4
View File
@@ -1,4 +1,4 @@
use crate::app::{buildings::BaseBuilding, states::skirmish_states::BoardState};
use crate::app::{buildings::BaseBuilding, states::skirmish_states::BoardState, units::MinerUnit};
use clap::ValueEnum;
#[derive(Debug, Clone, PartialEq, Eq)]
@@ -21,6 +21,12 @@ pub enum ZoomLevel {
ZoomedOut,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Players {
Player,
Enemy,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CellStructure {
Base(BaseBuilding),
@@ -29,7 +35,6 @@ pub enum CellStructure {
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Players {
Player,
Enemy,
pub enum Units {
Miner(MinerUnit),
}
+3 -2
View File
@@ -2,9 +2,10 @@ use crate::app::{
buildings::BaseBuilding,
helpers::{CellSizes, cell_size_helper, cells_area_helper},
states::{
CellStructure, FocusedCell, Offset, Players, ZoomLevel, skirmish_states::MoveFocusedCell,
CellStructure, FocusedCell, Offset, Players, Units, ZoomLevel,
skirmish_states::MoveFocusedCell,
},
units::{MinerUnit, Units},
units::MinerUnit,
widgets::CellWidget,
};
use ratatui::layout::Rect;
-2
View File
@@ -1,5 +1,3 @@
pub mod miner;
pub mod unit;
pub use miner::MinerUnit;
pub use unit::Units;
-6
View File
@@ -1,6 +0,0 @@
use crate::app::units::MinerUnit;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Units {
Miner(MinerUnit),
}
+5 -6
View File
@@ -1,7 +1,4 @@
use crate::app::{
states::{CellStructure, Players, ZoomLevel},
units::Units,
};
use crate::app::states::{CellStructure, Players, Units, ZoomLevel};
use ratatui::{
buffer::Buffer,
layout::{Alignment, Rect},
@@ -46,12 +43,14 @@ impl CellWidget {
self
}
pub fn set_zoom_level(&mut self, zoom_level: ZoomLevel) {
pub fn set_zoom_level(&mut self, zoom_level: ZoomLevel) -> &mut Self {
self.zoom_level = zoom_level;
self
}
pub fn set_structure(&mut self, sctructure: CellStructure) {
pub fn set_structure(&mut self, sctructure: CellStructure) -> &mut Self {
self.structure = sctructure;
self
}
pub fn get_marked(&self) -> bool {