From 0e1317235e7db3fa1b20dac2a4f12565a31e8cd0 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 2 Dec 2026 09:52:38 +0400 Subject: feat(ui): enter strategic view from a command post --- crates/fparkan-assets/src/strategy_toolbar.rs | 32 +++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'crates/fparkan-assets') diff --git a/crates/fparkan-assets/src/strategy_toolbar.rs b/crates/fparkan-assets/src/strategy_toolbar.rs index 5e4d04a8..4c49e7f0 100644 --- a/crates/fparkan-assets/src/strategy_toolbar.rs +++ b/crates/fparkan-assets/src/strategy_toolbar.rs @@ -16,6 +16,30 @@ const LOCK_GLYPH_OFFSET: [u32; 2] = [18, 7]; // iron3d+0x9bf49 sets the ordinary enabled glyph to ARGB ff80ff80. const ENABLED_GLYPH: [u8; 3] = [128, 255, 128]; +/// Actions available immediately upon entering strategic mode. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum ToolbarAction { + /// Return to the hero in the suit. + Hero, + /// Toggle the satellite map. + Map, +} + +/// Tests the native button bounds in the original 640×480 screen space. +#[must_use] +pub fn command_button_at([x, y]: [f32; 2]) -> Option { + if !(0.0..EXTENT[0] as f32).contains(&x.round_ties_even()) { + return None; + } + let y = y.round_ties_even(); + [(0, ToolbarAction::Hero), (10, ToolbarAction::Map)] + .into_iter() + .find_map(|(index, action)| { + let top = BUTTON_TOPS[index] as f32; + (top..top + 29.0).contains(&y).then_some(action) + }) +} + /// Composes the fully expanded toolbar in its resting state. pub fn load_expanded_toolbar(vfs: &dyn Vfs) -> Result { let [head, separator, button, lock, lock_icon, glyphs @ ..] = load_ui_sprites( @@ -85,6 +109,14 @@ mod tests { use super::*; use fparkan_vfs::DirectoryVfs; + #[test] + fn command_buttons_use_their_original_row_bounds() { + assert_eq!(command_button_at([16.0, 12.0]), Some(ToolbarAction::Hero)); + assert_eq!(command_button_at([45.0, 427.0]), Some(ToolbarAction::Map)); + assert_eq!(command_button_at([46.0, 400.0]), None); + assert_eq!(command_button_at([25.0, 428.0]), None); + } + #[test] #[ignore = "requires licensed corpus"] fn expanded_toolbar_loads_the_native_buttons_in_order() { -- cgit v1.2.3