diff options
| author | Valentin Popov <valentin@popov.link> | 2026-12-02 05:09:14 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-12-02 05:09:14 +0300 |
| commit | 0ad190894afd8e9592ef182e36e16ee7a61483f6 (patch) | |
| tree | e9aacd5995bcad2024bee939d629f186c2667ef9 /crates/fparkan-assets | |
| parent | 8e11cede8106e36aa1b91400318cff353c157986 (diff) | |
| download | fparkan-0ad190894afd8e9592ef182e36e16ee7a61483f6.tar.xz fparkan-0ad190894afd8e9592ef182e36e16ee7a61483f6.zip | |
feat(ui): render assembled warbots in the designer
Diffstat (limited to 'crates/fparkan-assets')
| -rw-r--r-- | crates/fparkan-assets/src/designer_screen.rs | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/crates/fparkan-assets/src/designer_screen.rs b/crates/fparkan-assets/src/designer_screen.rs index fea9eef9..58af85c8 100644 --- a/crates/fparkan-assets/src/designer_screen.rs +++ b/crates/fparkan-assets/src/designer_screen.rs @@ -16,6 +16,8 @@ const SEND: [u32; 4] = [194, 437, 229, 480]; const EXIT: [u32; 4] = [405, 437, 446, 480]; /// Extent of the designer's original font profile. pub const EXTENT: [u32; 2] = [800, 600]; +/// Native inset used to frame the assembled robot, in 640×480 coordinates. +pub const MODEL_VIEWPORT: [f32; 4] = [195.0, 10.0, 445.0, 300.0]; /// Number of part rows in the project viewport. pub const PART_ROWS: usize = 18; @@ -89,8 +91,8 @@ impl DesignerScreen { }) } - /// Paints the active project and every installed mount in Unit DAT order. - pub fn paint(&self, view: DesignerPicture<'_>) -> Result<RgbaImage, String> { + /// Paints the opaque panes that sit behind the rotating model. + pub fn paint_background(&self) -> RgbaImage { let [width, height] = EXTENT; let mut image = RgbaImage { width, @@ -102,7 +104,20 @@ impl DesignerScreen { } self.frame .paint(&mut image, [185, 2, 455, 480], [0, 48, 0, 255]); - self.text(&mut image, &self.labels.title, [194, 10, 446, 26], [255; 3])?; + self.frame + .paint(&mut image, [462, 2, 637, 265], [0, 48, 0, 255]); + image + } + + /// Paints project actions over the model and part descriptions in Unit DAT order. + pub fn paint(&self, view: DesignerPicture<'_>) -> Result<RgbaImage, String> { + let [width, height] = EXTENT; + let mut image = RgbaImage { + width, + height, + rgba8: vec![0; (width * height * 4) as usize], + }; + self.text(&mut image, &self.labels.title, [469, 10, 630, 26], [255; 3])?; self.text( &mut image, &self.labels.recent, @@ -119,7 +134,7 @@ impl DesignerScreen { sprite(&mut image, &self.recent, recent_slot(index), tint); } if let Some((_, name, records)) = view.project { - self.text(&mut image, name, [194, 27, 446, 42], [255, 255, 100])?; + self.text(&mut image, name, [469, 27, 630, 42], [255, 255, 100])?; self.paint_parts(&mut image, records, view.first_part)?; sprite(&mut image, &self.send_frame, SEND, [255; 3]); sprite(&mut image, &self.send, [201, 450, 225, 474], [255; 3]); @@ -162,9 +177,9 @@ impl DesignerScreen { if width == 0 { continue; } - let left = scale(196 + depth[first + row].min(8) * 7); + let left = scale(471 + depth[first + row].min(8) * 6); let top = scale(46 + 10 * row as u32); - let width = width.min((scale(446) - left) as u16); + let width = width.min((scale(630) - left) as u16); let glyphs = self.font.centered_line_bytes(text, width, glyph_height)?; copy_sprite( image, |
