diff --git a/Cargo.toml b/Cargo.toml index b8f591b..0c7ecac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,11 +4,11 @@ authors = ["spuds"] repository = "https://github.com/bananaturtlesandwich/stove" description = "an editor for cooked unreal engine 4 map files" readme = "README.md" -version = "0.9.1" +version = "0.9.2" edition = "2021" [dependencies] -unreal_asset = { git = "https://github.com/astrotechies/unrealmodding", package = "unreal_asset", rev = "b1d5553" } +unreal_asset = { git = "https://github.com/astrotechies/unrealmodding", package = "unreal_asset", rev = "91054ff" } unpak = { version = "1.0", features = ["asset-paths"] } glam = { version = "0.23", features = ["fast-math"] } miniquad = "0.3" diff --git a/src/actor/ui.rs b/src/actor/ui.rs index 927dfb0..112b20c 100644 --- a/src/actor/ui.rs +++ b/src/actor/ui.rs @@ -1,6 +1,9 @@ use unreal_asset::{ exports::{Export, ExportBaseTrait, ExportNormalTrait}, - properties::{array_property::ArrayProperty, Property, PropertyDataTrait}, + properties::{ + array_property::ArrayProperty, soft_path_property::SoftObjectPathPropertyValue, Property, + PropertyDataTrait, + }, types::fname::{FName, ToSerializedName}, Asset, }; @@ -98,11 +101,22 @@ macro_rules! show_sampler { macro_rules! show_path { ($ui:ident, $val:expr) => { - fname_edit( - $ui, - &mut $val.asset_path_name.get_or_insert(FName::from_slice("")), - ) | text_edit($ui, $val.sub_path.get_or_insert(String::new())) - | text_edit($ui, $val.path.get_or_insert(String::new())) + match &mut $val.value { + SoftObjectPathPropertyValue::Old(path) => { + text_edit($ui, path.get_or_insert_with(|| String::new())) + } + SoftObjectPathPropertyValue::New(path) => { + text_edit( + $ui, + path.sub_path_string.get_or_insert_with(|| String::new()), + ) | fname_edit( + $ui, + path.asset_path + .package_name + .get_or_insert_with(|| FName::from_slice("")), + ) | fname_edit($ui, &mut path.asset_path.asset_name) + } + } }; } @@ -186,32 +200,39 @@ fn show_property(ui: &mut egui::Ui, prop: &mut Property) { drag(ui, byte) } unreal_asset::properties::int_property::BytePropertyValue::FName(name) => { - fname_edit(ui, byte.enum_type.get_or_insert(FName::from_slice(""))) - | fname_edit(ui, name) + fname_edit( + ui, + byte.enum_type.get_or_insert_with(|| FName::from_slice("")), + ) | fname_edit(ui, name) } }, Property::DoubleProperty(double) => drag(ui, &mut double.value.0), Property::NameProperty(name) => fname_edit(ui, &mut name.value), Property::StrProperty(str) => { - text_edit(ui, str.value.get_or_insert(String::new())) + text_edit(ui, str.value.get_or_insert_with(|| String::new())) } Property::TextProperty(txt) => text_edit( ui, - txt.culture_invariant_string.get_or_insert(String::new()), + txt.culture_invariant_string + .get_or_insert_with(|| String::new()), ), Property::ObjectProperty(obj) => ui.link(obj.value.index.to_string()), Property::AssetObjectProperty(obj) => { - text_edit(ui, obj.value.get_or_insert(String::new())) + text_edit(ui, obj.value.get_or_insert_with(|| String::new())) } Property::SoftObjectProperty(obj) => { - text_edit(ui, obj.value.sub_path_string.get_or_insert(String::new())) - | fname_edit(ui, &mut obj.value.asset_path.asset_name) + text_edit( + ui, + obj.value + .sub_path_string + .get_or_insert_with(|| String::new()), + ) | fname_edit(ui, &mut obj.value.asset_path.asset_name) | fname_edit( ui, obj.value .asset_path .package_name - .get_or_insert(FName::from_slice("")), + .get_or_insert_with(|| FName::from_slice("")), ) } Property::IntPointProperty(point) => { @@ -333,7 +354,7 @@ fn show_property(ui: &mut egui::Ui, prop: &mut Property) { .response }), Property::EnumProperty(enm) => { - fname_edit(ui, enm.value.get_or_insert(FName::from_slice(""))) + fname_edit(ui, enm.value.get_or_insert_with(|| FName::from_slice(""))) } // Property::UnknownProperty(unknown) => todo!(), _ => ui.link("unimplemented"), diff --git a/src/asset.rs b/src/asset.rs index d87c045..abca838 100644 --- a/src/asset.rs +++ b/src/asset.rs @@ -8,6 +8,7 @@ pub fn open(file: impl AsRef, version: EngineVersion) -> Result Result<(), unreal_asset::error::Error> { include_bytes!("A02_Outside_Castle.uexp").as_slice(), )), EngineVersion::VER_UE4_25, + None, )?)?; Ok(()) } diff --git a/src/lib.rs b/src/lib.rs index d789558..a0bea2e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -337,6 +337,7 @@ impl Stove { std::io::Cursor::new(mesh), pak.get(&bulk).ok().map(std::io::Cursor::new), self.version(), + None ) else { continue; };