Lazy init game states and extract board module

App now stores CLI arguments and an optional GameStates, initializing
the
states lazily on the first window resize. Skirmish board logic is moved
to
a new BoardState module with dedicated helpers (cells_area_helper and
updated cell size handling). Views and keybindings are updated to use
the
optional state accessors.
This commit is contained in:
2026-04-02 00:45:57 +02:00
parent c4e28255b6
commit 923af91aeb
15 changed files with 228 additions and 178 deletions
+4 -18
View File
@@ -2,17 +2,13 @@
pub struct Offset {
value: usize,
max: usize,
value_initiated: bool,
max_initiated: bool,
}
impl Offset {
pub fn new() -> Self {
pub fn new(initial_value: Option<usize>, initial_max: Option<usize>) -> Self {
Self {
value: 0,
max: 0,
value_initiated: false,
max_initiated: false,
value: initial_value.unwrap_or(0),
max: initial_max.unwrap_or(0),
}
}
@@ -20,22 +16,12 @@ impl Offset {
self.value
}
pub fn set_initial_value(&mut self, value: usize) {
if self.value_initiated {
return;
}
pub fn set_value(&mut self, value: usize) {
self.value = value;
self.value_initiated = true;
}
pub fn set_max(&mut self, max: usize) {
if self.max_initiated {
return;
}
self.max = max;
self.max_initiated = true;
}
pub fn next(&mut self) {