diff options
| author | Valentin Popov <valentin@popov.link> | 2026-12-02 13:16:58 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-12-02 13:16:58 +0300 |
| commit | 787279a1f514fbbaf09ca9dd6e5015bdce36635b (patch) | |
| tree | 6adce388ed0fe42fe1e95dc2af536ce584015107 /crates/fparkan-assets/src | |
| parent | ad31192ab5d8c5f2b0d2d44b787d04c29cb49dc8 (diff) | |
| download | fparkan-787279a1f514fbbaf09ca9dd6e5015bdce36635b.tar.xz fparkan-787279a1f514fbbaf09ca9dd6e5015bdce36635b.zip | |
feat(ui): control a warbot from the strategic card
Diffstat (limited to 'crates/fparkan-assets/src')
| -rw-r--r-- | crates/fparkan-assets/src/strategic_roster.rs | 28 |
1 files changed, 28 insertions, 0 deletions
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<ListHit> { 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<CardLine<'_>>], + manual_control_enabled: bool, orders: Option<([&str; 6], Option<RosterOrder>)>, ) -> Result<RgbaImage, String> { 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; @@ -291,6 +310,15 @@ mod tests { } #[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); assert_eq!(durability_fill(0), None); |
