From 787279a1f514fbbaf09ca9dd6e5015bdce36635b Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 2 Dec 2026 14:16:58 +0400 Subject: feat(ui): control a warbot from the strategic card --- crates/fparkan-assets/src/strategic_roster.rs | 28 +++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'crates/fparkan-assets/src') diff --git a/crates/fparkan-assets/src/strategic_roster.rs b/crates/fparkan-assets/src/strategic_roster.rs index 1cd870a6..86d54b0d 100644 --- a/crates/fparkan-assets/src/strategic_roster.rs +++ b/crates/fparkan-assets/src/strategic_roster.rs @@ -28,6 +28,7 @@ const TEXT_LEFT: u32 = 10 + 19 * 2 + 5 + 10; #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum ListHit { Close, + ManualControl, Row(usize), } @@ -41,6 +42,10 @@ pub fn hit_test([x, y]: [f32; 2], row_count: usize) -> Option { if x >= CLOSE_LEFT as f32 && y < 20.0 { return Some(ListHit::Close); } + // iron3d+0x85c70 expands the icon rectangle by two logical pixels. + if row_count != 0 && (10.0..29.0).contains(&x) && (89.0..108.0).contains(&y) { + return Some(ListHit::ManualControl); + } let y = (y as u32).checked_sub(ROW_TOP)?; let row = (y / ROW_PITCH) as usize; (row < row_count && y % ROW_PITCH < ROW_HEIGHT).then_some(ListHit::Row(row)) @@ -77,6 +82,7 @@ pub struct RosterImages { end: RgbaImage, class_icon: RgbaImage, chassis_icons: [RgbaImage; 4], + manual_control: [RgbaImage; 2], orders: OrderImages, } @@ -164,6 +170,11 @@ impl RosterImages { end, class_icon: icon(49, 110)?, chassis_icons: [icon(97, 94)?, icon(49, 94)?, icon(65, 94)?, icon(81, 94)?], + manual_control: load_ui_sprites( + vfs, + "ui/hq.cfg", + ["short_button_frame_off", "buildscreen_hq_icon"], + )?, orders: OrderImages::load(vfs)?, }) } @@ -173,6 +184,7 @@ impl RosterImages { &self, rows: &[Row<'_>], card: &[Option>], + manual_control_enabled: bool, orders: Option<([&str; 6], Option)>, ) -> Result { let mut panel = self.background.clone(); @@ -182,6 +194,13 @@ impl RosterImages { let name = self.font.centered_line(row.label, width as u16, 16)?; stamp(&mut panel, &name, [49, 25, 49 + width, 41], [255, 255, 0]); warbot_card::paint(&self.font, &mut panel, card)?; + let tint = if manual_control_enabled { + [255; 3] + } else { + [128; 3] + }; + stamp(&mut panel, &self.manual_control[0], [9, 88, 30, 109], tint); + stamp(&mut panel, &self.manual_control[1], [12, 91, 27, 106], tint); } for (index, row) in rows.iter().take(19).enumerate() { let y = ROW_TOP + index as u32 * ROW_PITCH; @@ -290,6 +309,15 @@ mod tests { assert_eq!(hit_test([200.0, 480.0], 20), None); } + #[test] + fn manual_control_uses_the_enlarged_native_hit_box() { + assert_eq!(hit_test([61.0, 89.0], 3), Some(ListHit::ManualControl)); + assert_eq!(hit_test([79.0, 107.0], 3), Some(ListHit::ManualControl)); + assert_eq!(hit_test([80.0, 107.0], 3), None); + assert_eq!(hit_test([61.0, 108.0], 3), None); + assert_eq!(hit_test([61.0, 89.0], 0), None); + } + #[test] fn original_durability_colours_follow_the_rounded_health_percentage() { let durability_fill = |percent| super::durability_fill(percent, TEXT_WIDTH); -- cgit v1.2.3