From 05da53f0344416a5f14211a73f1f48d72c88b954 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 2 Dec 2026 14:38:56 +0400 Subject: feat(ui): drive a strategic warbot with an automatic gunner --- crates/fparkan-assets/src/strategic_roster.rs | 34 +++++++++++++++++++++------ 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'crates/fparkan-assets') diff --git a/crates/fparkan-assets/src/strategic_roster.rs b/crates/fparkan-assets/src/strategic_roster.rs index 86d54b0d..15ccf018 100644 --- a/crates/fparkan-assets/src/strategic_roster.rs +++ b/crates/fparkan-assets/src/strategic_roster.rs @@ -29,6 +29,7 @@ const TEXT_LEFT: u32 = 10 + 19 * 2 + 5 + 10; pub enum ListHit { Close, ManualControl, + AutoGunner, Row(usize), } @@ -46,6 +47,9 @@ pub fn hit_test([x, y]: [f32; 2], row_count: usize) -> Option { if row_count != 0 && (10.0..29.0).contains(&x) && (89.0..108.0).contains(&y) { return Some(ListHit::ManualControl); } + if row_count != 0 && (34.0..53.0).contains(&x) && (89.0..108.0).contains(&y) { + return Some(ListHit::AutoGunner); + } 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)) @@ -82,7 +86,7 @@ pub struct RosterImages { end: RgbaImage, class_icon: RgbaImage, chassis_icons: [RgbaImage; 4], - manual_control: [RgbaImage; 2], + cockpit_controls: [RgbaImage; 3], orders: OrderImages, } @@ -170,10 +174,14 @@ 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( + cockpit_controls: load_ui_sprites( vfs, "ui/hq.cfg", - ["short_button_frame_off", "buildscreen_hq_icon"], + [ + "short_button_frame_off", + "buildscreen_hq_icon", + "botscreen_autogunner_icon", + ], )?, orders: OrderImages::load(vfs)?, }) @@ -184,7 +192,7 @@ impl RosterImages { &self, rows: &[Row<'_>], card: &[Option>], - manual_control_enabled: bool, + cockpit_controls_enabled: bool, orders: Option<([&str; 6], Option)>, ) -> Result { let mut panel = self.background.clone(); @@ -194,13 +202,16 @@ 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 { + let tint = if cockpit_controls_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); + let [frame, manual, gunner] = &self.cockpit_controls; + stamp(&mut panel, frame, [9, 88, 30, 109], tint); + stamp(&mut panel, manual, [12, 91, 27, 106], tint); + stamp(&mut panel, frame, [33, 88, 54, 109], tint); + stamp(&mut panel, gunner, [36, 91, 51, 106], tint); } for (index, row) in rows.iter().take(19).enumerate() { let y = ROW_TOP + index as u32 * ROW_PITCH; @@ -318,6 +329,15 @@ mod tests { assert_eq!(hit_test([61.0, 89.0], 0), None); } + #[test] + fn auto_gunner_uses_its_own_native_hit_box() { + assert_eq!(hit_test([84.0, 89.0], 3), None); + assert_eq!(hit_test([85.0, 89.0], 3), Some(ListHit::AutoGunner)); + assert_eq!(hit_test([103.0, 107.0], 3), Some(ListHit::AutoGunner)); + assert_eq!(hit_test([104.0, 107.0], 3), None); + assert_eq!(hit_test([85.0, 108.0], 3), 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