diff options
| author | Valentin Popov <valentin@popov.link> | 2026-12-02 06:24:01 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-12-02 06:24:01 +0300 |
| commit | b0c3a064c29c2bf97981f45806696c2dd0d4dd90 (patch) | |
| tree | a677357a8519520a49cd4ccad3daa9cfde68d28e /apps/fparkan-game/src/designer_projects.rs | |
| parent | 7b3a106ff7a376b95b3bb9e52d3186ebe1a9bcaa (diff) | |
| download | fparkan-b0c3a064c29c2bf97981f45806696c2dd0d4dd90.tar.xz fparkan-b0c3a064c29c2bf97981f45806696c2dd0d4dd90.zip | |
feat(ui): preview new warbot geometry during a mission
On stock Field Camp, open a compatible Unit DAT created after start, resize the preview, switch to a resident project, reopen the new project, and return to the mission with Vulkan validation clean. The factory reserve for new geometry is still prepared at mission load.
Diffstat (limited to 'apps/fparkan-game/src/designer_projects.rs')
| -rw-r--r-- | apps/fparkan-game/src/designer_projects.rs | 53 |
1 files changed, 42 insertions, 11 deletions
diff --git a/apps/fparkan-game/src/designer_projects.rs b/apps/fparkan-game/src/designer_projects.rs index 1a485fee..a5d3ddf3 100644 --- a/apps/fparkan-game/src/designer_projects.rs +++ b/apps/fparkan-game/src/designer_projects.rs @@ -1,18 +1,35 @@ //! The original designer's named Unit DAT files under the game root. +use fparkan_prototype::UnitDat; use fparkan_runtime::{ - is_saved_factory_project_name, restore_factory_design, Engine, FactoryPartChange, - StartingCockpit, + inspect_saved_factory_project, is_saved_factory_project_name, restore_factory_design, Engine, + FactoryPartChange, StartingCockpit, }; -use std::{fs, io, io::Write, path::Path}; +use fparkan_world::ObjectHandle; +use std::{fs, io, io::Write, path::Path, sync::Arc}; pub(super) const NAME_LIMIT: usize = 16; pub(super) struct SavedProject { pub(super) name: String, - pub(super) choice: Option<usize>, - pub(super) scheme: usize, - pub(super) changes: Vec<FactoryPartChange>, + pub(super) layout: SavedLayout, +} + +pub(super) enum SavedLayout { + Factory { + choice: Option<usize>, + scheme: usize, + changes: Vec<FactoryPartChange>, + }, + Preview { + project: UnitDat, + bytes: Arc<[u8]>, + }, +} + +pub(super) struct PreparedProjectModel { + pub(super) project: UnitDat, + pub(super) geometry: super::designer_geometry::DesignerGeometry, } pub(super) enum ProjectDialog { @@ -65,6 +82,7 @@ pub(super) fn browse_projects( directory: &Path, engine: &Engine, cockpit: StartingCockpit, + plant: Option<ObjectHandle>, choices: &[(usize, usize)], prepared: &[usize], ) -> io::Result<Vec<SavedProject>> { @@ -89,17 +107,30 @@ pub(super) fn browse_projects( .iter() .map(|&(_, scheme)| scheme) .chain(prepared.iter().copied()); - if let Some((scheme, changes)) = restore_factory_design(engine, cockpit, schemes, &bytes) { + let layout = if let Some((scheme, changes)) = + restore_factory_design(engine, cockpit, schemes, &bytes) + { let choice = choices .iter() .find_map(|&(choice, index)| (index == scheme).then_some(choice)); - projects.push(SavedProject { - name: name.to_owned(), + SavedLayout::Factory { choice, scheme, changes, - }); - } + } + } else if let Some(project) = inspect_saved_factory_project(engine, cockpit, plant, &bytes) + { + SavedLayout::Preview { + project, + bytes: bytes.into(), + } + } else { + continue; + }; + projects.push(SavedProject { + name: name.to_owned(), + layout, + }); } projects.sort_by(|left, right| left.name.to_lowercase().cmp(&right.name.to_lowercase())); Ok(projects) |
