From 8e11cede8106e36aa1b91400318cff353c157986 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 2 Dec 2026 05:53:53 +0400 Subject: feat(ui): open and transfer recent factory designs --- crates/fparkan-assets/src/factory_projects.rs | 33 ++++++++++++++++++++------- 1 file changed, 25 insertions(+), 8 deletions(-) (limited to 'crates/fparkan-assets/src/factory_projects.rs') diff --git a/crates/fparkan-assets/src/factory_projects.rs b/crates/fparkan-assets/src/factory_projects.rs index 94973b22..ca77137a 100644 --- a/crates/fparkan-assets/src/factory_projects.rs +++ b/crates/fparkan-assets/src/factory_projects.rs @@ -16,6 +16,7 @@ pub const ORIGIN: [u32; 2] = [50, 122]; // A transparent texel on each side keeps repeat sampling from bleeding buttons across the quad. pub const EXTENT: [u32; 2] = [328, 48]; const BUILD: [u32; 4] = [277, 28, 327, 47]; +const CONSTRUCTOR: [u32; 4] = [20, 28, 70, 47]; /// A command selected with the pointer. #[derive(Clone, Copy, Debug, PartialEq, Eq)] @@ -24,6 +25,8 @@ pub enum FactoryProjectAction { Select(usize), /// Queue the selected project at this factory. Build, + /// Open the active factory's model designer. + Designer, } /// Original button frames, icons and game font for the project controls. @@ -32,13 +35,14 @@ pub struct FactoryProjectImages { project: RgbaImage, build_frame: RgbaImage, build_icon: RgbaImage, + constructor_icon: RgbaImage, font: BitmapFont, } impl FactoryProjectImages { /// Resolves factory sprites and text through the installed game's catalogs. pub fn load(vfs: &dyn Vfs) -> Result { - let [idle, pressed, project, build_icon] = load_ui_sprites( + let [idle, pressed, project, build_icon, constructor_icon] = load_ui_sprites( vfs, "ui/hq.cfg", [ @@ -46,6 +50,7 @@ impl FactoryProjectImages { "short_button_frame_on", "project_icon", "build_icon", + "constructor_icon", ], )?; let [build_frame] = load_ui_sprites(vfs, "ui/compaund.cfg", ["ccres_long_button_normal"])?; @@ -53,6 +58,7 @@ impl FactoryProjectImages { frames: [idle, pressed], project, build_icon, + constructor_icon, build_frame, font: load_layout_font(vfs)?, }) @@ -65,6 +71,7 @@ impl FactoryProjectImages { selected: usize, pressed: Option, name: &str, + designer_available: bool, ) -> Result { let mut image = RgbaImage { width: EXTENT[0], @@ -92,18 +99,25 @@ impl FactoryProjectImages { }, ); } - copy_sprite(&mut image, &self.build_frame, BUILD, [false; 2], [255; 3]); - let [left, top, _, _] = BUILD; + self.paint_button(&mut image, BUILD, &self.build_icon); + if designer_available { + self.paint_button(&mut image, CONSTRUCTOR, &self.constructor_icon); + } + let label = self.font.centered_line(name, 150, 16)?; + copy_sprite(&mut image, &label, [125, 17, 275, 33], [false; 2], [255; 3]); + Ok(image) + } + + fn paint_button(&self, image: &mut RgbaImage, rect: [u32; 4], icon: &RgbaImage) { + copy_sprite(image, &self.build_frame, rect, [false; 2], [255; 3]); + let [left, top, _, _] = rect; copy_sprite( - &mut image, - &self.build_icon, + image, + icon, [left + 10, top + 2, left + 40, top + 17], [false; 2], [240; 3], ); - let label = self.font.centered_line(name, 150, 16)?; - copy_sprite(&mut image, &label, [1, 22, 151, 38], [false; 2], [255; 3]); - Ok(image) } } @@ -118,6 +132,9 @@ pub fn hit_test(position: [f32; 2], count: usize) -> Option