generated from GarandPLG/rust-flake-template
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:
@@ -30,6 +30,8 @@ fn main_menu_layout(area: Rect) -> [Rect; 2] {
|
||||
}
|
||||
|
||||
pub fn main_menu_view(app: &App, area: Rect, buf: &mut Buffer) {
|
||||
let Some(states) = app.states() else { return };
|
||||
|
||||
let [main_menu_area, keybindings_area] = main_menu_layout(area);
|
||||
|
||||
Block::new()
|
||||
@@ -70,7 +72,7 @@ pub fn main_menu_view(app: &App, area: Rect, buf: &mut Buffer) {
|
||||
.map(|(i, view)| {
|
||||
let view_string: String = main_menu_option_helper(format!("{:?}", view));
|
||||
|
||||
let styled: Line<'_> = if app.states.main_menu.selected_view == i {
|
||||
let styled: Line<'_> = if states.main_menu.selected_view == i {
|
||||
Line::from_iter(["> ".cyan(), view_string.yellow()]).yellow()
|
||||
} else {
|
||||
Line::from(format!(" {view_string}")).white()
|
||||
|
||||
Reference in New Issue
Block a user