From 35fa81882745881af0bc91970de49237a8ba036c Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Sun, 2 Mar 2025 14:28:22 -0500 Subject: [PATCH] Move structs to their own files --- paramacro/src/lib.rs | 3 +- src/build_data.rs | 8 +- src/da_assemble_id_data.rs | 35 ++++ src/da_customize_asset_id.rs | 35 ++++ src/da_humanoid_coloring_data.rs | 38 ++++ src/da_humanoid_figure_data.rs | 20 ++ src/da_load_option.rs | 8 + src/da_machine_coloring_data.rs | 32 +++ src/da_module_color.rs | 17 ++ src/da_module_item_data.rs | 8 + src/da_trigger_data.rs | 14 ++ src/da_tuning_data.rs | 8 + src/da_tuning_point_data.rs | 11 ++ src/datetime.rs | 23 +++ src/lib.rs | 16 ++ src/primary_asset_id.rs | 1 - src/primary_asset_type.rs | 1 - src/quat.rs | 27 +++ src/save_slot_info.rs | 20 ++ src/struct_property.rs | 23 ++- src/structs.rs | 325 ------------------------------- src/transform.rs | 14 ++ src/vector.rs | 25 +++ 23 files changed, 373 insertions(+), 339 deletions(-) create mode 100644 src/da_assemble_id_data.rs create mode 100644 src/da_customize_asset_id.rs create mode 100644 src/da_humanoid_coloring_data.rs create mode 100644 src/da_humanoid_figure_data.rs create mode 100644 src/da_load_option.rs create mode 100644 src/da_machine_coloring_data.rs create mode 100644 src/da_module_color.rs create mode 100644 src/da_module_item_data.rs create mode 100644 src/da_trigger_data.rs create mode 100644 src/da_tuning_data.rs create mode 100644 src/da_tuning_point_data.rs create mode 100644 src/datetime.rs create mode 100644 src/quat.rs create mode 100644 src/save_slot_info.rs create mode 100644 src/transform.rs create mode 100644 src/vector.rs diff --git a/paramacro/src/lib.rs b/paramacro/src/lib.rs index d1be77b..30e1671 100644 --- a/paramacro/src/lib.rs +++ b/paramacro/src/lib.rs @@ -71,7 +71,7 @@ pub fn serialized_struct(_metadata: TokenStream, input: TokenStream) let id = &input.ident; let output = quote! { - #[binrw] + #[binrw::binrw] #input #[automatically_derived] @@ -99,7 +99,6 @@ pub fn serialized_field(attr: TokenStream, input: TokenStream) -> TokenStream { let input2 = parse_macro_input!(input as Item); let output = quote! { - #[binrw] #input2 }; diff --git a/src/build_data.rs b/src/build_data.rs index 9b7f764..bf02db4 100644 --- a/src/build_data.rs +++ b/src/build_data.rs @@ -1,9 +1,9 @@ +use crate::da_assemble_id_data::DAAssembleIdDataStruct; +use crate::da_customize_asset_id::DACustomizeAssetIdDataStruct; +use crate::da_trigger_data::DATriggerDataStruct; +use crate::da_tuning_data::DATuningDataStruct; use crate::str_property::StrProperty; use crate::structs::PropertyBase; -use crate::structs::{ - DAAssembleIdDataStruct, DACustomizeAssetIdDataStruct, DATriggerDataStruct, DATuningDataStruct, -}; -use binrw::binrw; use std::fmt::Debug; #[paramacro::serialized_struct("DABuildData")] diff --git a/src/da_assemble_id_data.rs b/src/da_assemble_id_data.rs new file mode 100644 index 0000000..7823c51 --- /dev/null +++ b/src/da_assemble_id_data.rs @@ -0,0 +1,35 @@ +use crate::{da_machine_coloring_data::DAMachineColoringDataStruct, guid::Guid}; + +#[paramacro::serialized_struct("DAAssembleIdData")] +#[derive(Debug)] +pub struct DAAssembleIdDataStruct { + #[paramacro::serialized_field = "Hanger"] + pub hanger: Guid, + + #[paramacro::serialized_field = "Headset"] + pub headset: Guid, + + #[paramacro::serialized_field = "Mobility"] + pub mobility: Guid, + + #[paramacro::serialized_field = "Thruster"] + pub thruster: Guid, + + #[paramacro::serialized_field = "Utility"] + pub utility: Guid, + + #[paramacro::serialized_field = "PrimaryFrontWeapon"] + pub primary_front_weapon: Guid, + + #[paramacro::serialized_field = "SecondaryFrontWeapon"] + pub secondary_front_weapon: Guid, + + #[paramacro::serialized_field = "LeftRearWeapon"] + pub left_rear_weapon: Guid, + + #[paramacro::serialized_field = "RightRearWeapon"] + pub right_rear_weapon: Guid, + + #[paramacro::serialized_field = "ColoringData"] + pub coloring_data: DAMachineColoringDataStruct, +} diff --git a/src/da_customize_asset_id.rs b/src/da_customize_asset_id.rs new file mode 100644 index 0000000..4a445d9 --- /dev/null +++ b/src/da_customize_asset_id.rs @@ -0,0 +1,35 @@ +use crate::{ + bool_property::BoolProperty, da_humanoid_coloring_data::DAHumanoidColoringDataStruct, + da_humanoid_figure_data::DAHumanoidFigureData, primary_asset_id::PrimaryAssetIdStruct, +}; + +#[paramacro::serialized_struct("DACustomizeAssetIdData")] +#[derive(Debug)] +pub struct DACustomizeAssetIdDataStruct { + #[paramacro::serialized_field = "Body"] + pub body: PrimaryAssetIdStruct, + + #[paramacro::serialized_field = "Face"] + pub face: PrimaryAssetIdStruct, + + #[paramacro::serialized_field = "FrontHair"] + pub front_hair: PrimaryAssetIdStruct, + + #[paramacro::serialized_field = "BackHair"] + pub back_hair: PrimaryAssetIdStruct, + + #[paramacro::serialized_field = "ColoringData"] + pub coloring_data: DAHumanoidColoringDataStruct, + + #[paramacro::serialized_field = "FigureData"] + pub figure_data: DAHumanoidFigureData, + + #[paramacro::serialized_field = "bInverseFaceMesh"] + pub inverse_face_mesh: BoolProperty, + + #[paramacro::serialized_field = "bInverseFrontHairMesh"] + pub inverse_front_hair_mesh: BoolProperty, + + #[paramacro::serialized_field = "bInverseBackHairMesh"] + pub inverse_back_hair_mesh: BoolProperty, +} diff --git a/src/da_humanoid_coloring_data.rs b/src/da_humanoid_coloring_data.rs new file mode 100644 index 0000000..d87ca61 --- /dev/null +++ b/src/da_humanoid_coloring_data.rs @@ -0,0 +1,38 @@ +use crate::linear_color::LinearColorStruct; + +#[paramacro::serialized_struct("DAHumanoidColoringData")] +#[derive(Debug)] +pub struct DAHumanoidColoringDataStruct { + #[paramacro::serialized_field = "Skin"] + pub skin: LinearColorStruct, + + #[paramacro::serialized_field = "HairBase"] + pub hair_base: LinearColorStruct, + + #[paramacro::serialized_field = "HairGradation"] + pub hair_gradation: LinearColorStruct, + + #[paramacro::serialized_field = "HairHighlight"] + pub hair_highlight: LinearColorStruct, + + #[paramacro::serialized_field = "HeadOption"] + pub head_option: LinearColorStruct, + + #[paramacro::serialized_field = "EyeL"] + pub eye_l: LinearColorStruct, + + #[paramacro::serialized_field = "EyeR"] + pub eye_r: LinearColorStruct, + + #[paramacro::serialized_field = "BodyMain"] + pub body_main: LinearColorStruct, + + #[paramacro::serialized_field = "BodySub1"] + pub body_sub1: LinearColorStruct, + + #[paramacro::serialized_field = "BodySub2"] + pub body_sub2: LinearColorStruct, + + #[paramacro::serialized_field = "BodySub3"] + pub body_sub3: LinearColorStruct, +} diff --git a/src/da_humanoid_figure_data.rs b/src/da_humanoid_figure_data.rs new file mode 100644 index 0000000..97dca61 --- /dev/null +++ b/src/da_humanoid_figure_data.rs @@ -0,0 +1,20 @@ +use crate::float_property::FloatProperty; + +#[paramacro::serialized_struct("DAHumanoidFigureData")] +#[derive(Debug)] +pub struct DAHumanoidFigureData { + #[paramacro::serialized_field = "BustUp"] + pub bust_up: FloatProperty, + + #[paramacro::serialized_field = "FatUp"] + pub fat_up: FloatProperty, + + #[paramacro::serialized_field = "ArmUp"] + pub arm_up: FloatProperty, + + #[paramacro::serialized_field = "LegUp"] + pub leg_up: FloatProperty, + + #[paramacro::serialized_field = "WaistUp"] + pub waist_up: FloatProperty, +} diff --git a/src/da_load_option.rs b/src/da_load_option.rs new file mode 100644 index 0000000..cecc7d9 --- /dev/null +++ b/src/da_load_option.rs @@ -0,0 +1,8 @@ +use crate::int_property::IntProperty; + +#[paramacro::serialized_struct("DALoadOption")] +#[derive(Debug)] +pub struct DALoadOptionStruct { + #[paramacro::serialized_field = "LoadTypes"] + pub load_types: IntProperty, +} diff --git a/src/da_machine_coloring_data.rs b/src/da_machine_coloring_data.rs new file mode 100644 index 0000000..49339be --- /dev/null +++ b/src/da_machine_coloring_data.rs @@ -0,0 +1,32 @@ +use crate::da_module_color::DAModuleColorStruct; + +#[paramacro::serialized_struct("DAMachineColoringData")] +#[derive(Debug)] +pub struct DAMachineColoringDataStruct { + #[paramacro::serialized_field = "Hanger"] + pub hanger: DAModuleColorStruct, + + #[paramacro::serialized_field = "Headset"] + pub headset: DAModuleColorStruct, + + #[paramacro::serialized_field = "Mobility"] + pub mobility: DAModuleColorStruct, + + #[paramacro::serialized_field = "Thruster"] + pub thruster: DAModuleColorStruct, + + #[paramacro::serialized_field = "Utility"] + pub utility: DAModuleColorStruct, + + #[paramacro::serialized_field = "PrimaryFrontWeapon"] + pub primary_front_weapon: DAModuleColorStruct, + + #[paramacro::serialized_field = "SecondaryFrontWeapon"] + pub secondary_front_weapon: DAModuleColorStruct, + + #[paramacro::serialized_field = "LeftRearWeapon"] + pub left_rear_weapon: DAModuleColorStruct, + + #[paramacro::serialized_field = "RightRearWeapon"] + pub right_rear_weapon: DAModuleColorStruct, +} diff --git a/src/da_module_color.rs b/src/da_module_color.rs new file mode 100644 index 0000000..3da6c1d --- /dev/null +++ b/src/da_module_color.rs @@ -0,0 +1,17 @@ +use crate::linear_color::LinearColorStruct; + +#[paramacro::serialized_struct("DAModuleColor")] +#[derive(Debug)] +pub struct DAModuleColorStruct { + #[paramacro::serialized_field = "Main"] + pub main: LinearColorStruct, + + #[paramacro::serialized_field = "Sub"] + pub sub: LinearColorStruct, + + #[paramacro::serialized_field = "Inner"] + pub inner: LinearColorStruct, + + #[paramacro::serialized_field = "Glow"] + pub glow: LinearColorStruct, +} diff --git a/src/da_module_item_data.rs b/src/da_module_item_data.rs new file mode 100644 index 0000000..4b8ef23 --- /dev/null +++ b/src/da_module_item_data.rs @@ -0,0 +1,8 @@ +use crate::int_property::IntProperty; + +#[paramacro::serialized_struct("DAModuleItemData")] +#[derive(Debug)] +pub struct DAModuleItemDataStruct { + #[paramacro::serialized_field = "ModuleLevel"] + pub module_level: IntProperty, +} diff --git a/src/da_trigger_data.rs b/src/da_trigger_data.rs new file mode 100644 index 0000000..1cbd636 --- /dev/null +++ b/src/da_trigger_data.rs @@ -0,0 +1,14 @@ +use crate::enum_property::EnumProperty; + +#[paramacro::serialized_struct("DATriggerData")] +#[derive(Debug)] +pub struct DATriggerDataStruct { + #[paramacro::serialized_field = "A"] + pub a: EnumProperty, + + #[paramacro::serialized_field = "B"] + pub b: EnumProperty, + + #[paramacro::serialized_field = "C"] + pub c: EnumProperty, +} diff --git a/src/da_tuning_data.rs b/src/da_tuning_data.rs new file mode 100644 index 0000000..69ff2b3 --- /dev/null +++ b/src/da_tuning_data.rs @@ -0,0 +1,8 @@ +use crate::map_property::MapProperty; + +#[paramacro::serialized_struct("DATuningData")] +#[derive(Debug)] +pub struct DATuningDataStruct { + #[paramacro::serialized_field = "GrantedTuningPointList"] + pub granted_tuning_point_list: MapProperty, +} diff --git a/src/da_tuning_point_data.rs b/src/da_tuning_point_data.rs new file mode 100644 index 0000000..e564cb1 --- /dev/null +++ b/src/da_tuning_point_data.rs @@ -0,0 +1,11 @@ +use crate::int_property::IntProperty; + +#[paramacro::serialized_struct("DATuningPointData")] +#[derive(Debug)] +pub struct DATuningPointData { + #[paramacro::serialized_field = "TuningPoint"] + tuning_point: IntProperty, + + #[paramacro::serialized_field = "MaxTuningPoint"] + max_tuning_point: IntProperty, +} diff --git a/src/datetime.rs b/src/datetime.rs new file mode 100644 index 0000000..1590dd8 --- /dev/null +++ b/src/datetime.rs @@ -0,0 +1,23 @@ +use binrw::binrw; + +use crate::structs::PropertyBase; + +#[binrw] +#[derive(Debug)] +pub struct DateTimeStruct { + pub unk: [u8; 8], +} + +impl PropertyBase for DateTimeStruct { + fn type_name() -> &'static str { + "StructProperty" + } + + fn struct_name() -> Option<&'static str> { + Some("DateTime") + } + + fn size_in_bytes(&self) -> u32 { + 8 + } +} diff --git a/src/lib.rs b/src/lib.rs index 7d17ad3..904af04 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,6 +2,18 @@ pub mod array_property; pub mod bool_property; mod build_data; mod common; +mod da_assemble_id_data; +mod da_customize_asset_id; +mod da_humanoid_coloring_data; +mod da_humanoid_figure_data; +mod da_load_option; +mod da_machine_coloring_data; +mod da_module_color; +mod da_module_item_data; +mod da_trigger_data; +mod da_tuning_data; +mod da_tuning_point_data; +mod datetime; mod enum_property; pub mod float_property; mod guid; @@ -11,10 +23,14 @@ pub mod map_property; mod name_property; mod primary_asset_id; mod primary_asset_type; +mod quat; +mod save_slot_info; pub mod set_property; pub mod str_property; pub mod struct_property; mod structs; +mod transform; +mod vector; use binrw::helpers::until_eof; use std::fs::write; diff --git a/src/primary_asset_id.rs b/src/primary_asset_id.rs index 42bddaf..d5c86b5 100644 --- a/src/primary_asset_id.rs +++ b/src/primary_asset_id.rs @@ -1,5 +1,4 @@ use crate::{name_property::NameProperty, primary_asset_type::PrimaryAssetTypeStruct}; -use binrw::binrw; #[paramacro::serialized_struct("PrimaryAssetId")] #[derive(Debug)] diff --git a/src/primary_asset_type.rs b/src/primary_asset_type.rs index 706ee43..6c841f6 100644 --- a/src/primary_asset_type.rs +++ b/src/primary_asset_type.rs @@ -1,5 +1,4 @@ use crate::name_property::NameProperty; -use binrw::binrw; #[paramacro::serialized_struct("PrimaryAssetType")] #[derive(Debug)] diff --git a/src/quat.rs b/src/quat.rs new file mode 100644 index 0000000..6811b5c --- /dev/null +++ b/src/quat.rs @@ -0,0 +1,27 @@ +use binrw::binrw; + +use crate::structs::PropertyBase; + +#[binrw] +#[derive(Debug)] +pub struct QuatStruct { + // TODO: check if w is actually in front or in the back, this is a guess + pub w: f32, + pub x: f32, + pub y: f32, + pub z: f32, +} + +impl PropertyBase for QuatStruct { + fn type_name() -> &'static str { + "StructProperty" + } + + fn struct_name() -> Option<&'static str> { + Some("Quat") + } + + fn size_in_bytes(&self) -> u32 { + 16 + } +} diff --git a/src/save_slot_info.rs b/src/save_slot_info.rs new file mode 100644 index 0000000..b3c4ddd --- /dev/null +++ b/src/save_slot_info.rs @@ -0,0 +1,20 @@ +use crate::{ + array_property::ArrayProperty, datetime::DateTimeStruct, name_property::NameProperty, + str_property::StrProperty, +}; + +#[paramacro::serialized_struct("SaveSlotInfo")] +#[derive(Debug)] +pub struct SaveSlotInfoStruct { + #[paramacro::serialized_field = "Name"] + pub name: StrProperty, + + #[paramacro::serialized_field = "Timestamp"] + pub timestamp: DateTimeStruct, + + #[paramacro::serialized_field = "Level"] + pub level: NameProperty, + + #[paramacro::serialized_field = "Players"] + pub players: ArrayProperty, +} diff --git a/src/struct_property.rs b/src/struct_property.rs index 4b331e5..b5f0690 100644 --- a/src/struct_property.rs +++ b/src/struct_property.rs @@ -1,15 +1,26 @@ use crate::build_data::DABuildDataStruct; use crate::common::{read_string_with_length, write_string_with_length}; +use crate::da_assemble_id_data::DAAssembleIdDataStruct; +use crate::da_customize_asset_id::DACustomizeAssetIdDataStruct; +use crate::da_humanoid_coloring_data::DAHumanoidColoringDataStruct; +use crate::da_humanoid_figure_data::DAHumanoidFigureData; +use crate::da_load_option::DALoadOptionStruct; +use crate::da_machine_coloring_data::DAMachineColoringDataStruct; +use crate::da_module_color::DAModuleColorStruct; +use crate::da_module_item_data::DAModuleItemDataStruct; +use crate::da_trigger_data::DATriggerDataStruct; +use crate::da_tuning_data::DATuningDataStruct; +use crate::da_tuning_point_data::DATuningPointData; +use crate::datetime::DateTimeStruct; use crate::guid::Guid; use crate::linear_color::LinearColorStruct; use crate::primary_asset_id::PrimaryAssetIdStruct; use crate::primary_asset_type::PrimaryAssetTypeStruct; -use crate::structs::{ - DAAssembleIdDataStruct, DACustomizeAssetIdDataStruct, DAHumanoidColoringDataStruct, - DAHumanoidFigureData, DALoadOptionStruct, DAMachineColoringDataStruct, DAModuleColorStruct, - DAModuleItemDataStruct, DATriggerDataStruct, DATuningDataStruct, DATuningPointData, - DateTimeStruct, PropertyBase, QuatStruct, SaveSlotInfoStruct, TransformStruct, VectorStruct, -}; +use crate::quat::QuatStruct; +use crate::save_slot_info::SaveSlotInfoStruct; +use crate::structs::PropertyBase; +use crate::transform::TransformStruct; +use crate::vector::VectorStruct; use binrw::binrw; #[binrw] diff --git a/src/structs.rs b/src/structs.rs index 2c65cf8..b0e5d21 100644 --- a/src/structs.rs +++ b/src/structs.rs @@ -1,49 +1,8 @@ use crate::Property; -use crate::array_property::ArrayProperty; -use crate::bool_property::BoolProperty; -use crate::build_data::DABuildDataStruct; use crate::common::{read_string_with_length, write_string_with_length}; -use crate::enum_property::EnumProperty; -use crate::float_property::FloatProperty; -use crate::guid::Guid; -use crate::int_property::IntProperty; -use crate::linear_color::LinearColorStruct; -use crate::map_property::MapProperty; -use crate::name_property::NameProperty; -use crate::primary_asset_id::PrimaryAssetIdStruct; -use crate::str_property::StrProperty; use binrw::{BinRead, BinResult, BinWrite, binrw}; use std::fmt::Debug; -#[binrw] -#[derive(Debug)] -pub struct DateTimeStruct { - pub unk: [u8; 8], -} - -#[paramacro::serialized_struct("DALoadOption")] -#[derive(Debug)] -pub struct DALoadOptionStruct { - #[paramacro::serialized_field = "LoadTypes"] - pub load_types: IntProperty, -} - -#[paramacro::serialized_struct("SaveSlotInfo")] -#[derive(Debug)] -pub struct SaveSlotInfoStruct { - #[paramacro::serialized_field = "Name"] - pub name: StrProperty, - - #[paramacro::serialized_field = "Timestamp"] - pub timestamp: DateTimeStruct, - - #[paramacro::serialized_field = "Level"] - pub level: NameProperty, - - #[paramacro::serialized_field = "Players"] - pub players: ArrayProperty, -} - #[binrw] #[derive(Debug)] pub struct GenericProperty { @@ -61,248 +20,6 @@ pub struct GenericProperty { pub key: Option>, } -#[paramacro::serialized_struct("DAModuleItemData")] -#[derive(Debug)] -pub struct DAModuleItemDataStruct { - #[paramacro::serialized_field = "ModuleLevel"] - pub module_level: IntProperty, -} - -#[paramacro::serialized_struct("DAAssembleIdData")] -#[derive(Debug)] -pub struct DAAssembleIdDataStruct { - #[paramacro::serialized_field = "Hanger"] - pub hanger: Guid, - - #[paramacro::serialized_field = "Headset"] - pub headset: Guid, - - #[paramacro::serialized_field = "Mobility"] - pub mobility: Guid, - - #[paramacro::serialized_field = "Thruster"] - pub thruster: Guid, - - #[paramacro::serialized_field = "Utility"] - pub utility: Guid, - - #[paramacro::serialized_field = "PrimaryFrontWeapon"] - pub primary_front_weapon: Guid, - - #[paramacro::serialized_field = "SecondaryFrontWeapon"] - pub secondary_front_weapon: Guid, - - #[paramacro::serialized_field = "LeftRearWeapon"] - pub left_rear_weapon: Guid, - - #[paramacro::serialized_field = "RightRearWeapon"] - pub right_rear_weapon: Guid, - - #[paramacro::serialized_field = "ColoringData"] - pub coloring_data: DAMachineColoringDataStruct, -} - -#[paramacro::serialized_struct("DAMachineColoringData")] -#[derive(Debug)] -pub struct DAMachineColoringDataStruct { - #[paramacro::serialized_field = "Hanger"] - pub hanger: DAModuleColorStruct, - - #[paramacro::serialized_field = "Headset"] - pub headset: DAModuleColorStruct, - - #[paramacro::serialized_field = "Mobility"] - pub mobility: DAModuleColorStruct, - - #[paramacro::serialized_field = "Thruster"] - pub thruster: DAModuleColorStruct, - - #[paramacro::serialized_field = "Utility"] - pub utility: DAModuleColorStruct, - - #[paramacro::serialized_field = "PrimaryFrontWeapon"] - pub primary_front_weapon: DAModuleColorStruct, - - #[paramacro::serialized_field = "SecondaryFrontWeapon"] - pub secondary_front_weapon: DAModuleColorStruct, - - #[paramacro::serialized_field = "LeftRearWeapon"] - pub left_rear_weapon: DAModuleColorStruct, - - #[paramacro::serialized_field = "RightRearWeapon"] - pub right_rear_weapon: DAModuleColorStruct, -} - -#[paramacro::serialized_struct("DAHumanoidColoringData")] -#[derive(Debug)] -pub struct DAHumanoidColoringDataStruct { - #[paramacro::serialized_field = "Skin"] - pub skin: LinearColorStruct, - - #[paramacro::serialized_field = "HairBase"] - pub hair_base: LinearColorStruct, - - #[paramacro::serialized_field = "HairGradation"] - pub hair_gradation: LinearColorStruct, - - #[paramacro::serialized_field = "HairHighlight"] - pub hair_highlight: LinearColorStruct, - - #[paramacro::serialized_field = "HeadOption"] - pub head_option: LinearColorStruct, - - #[paramacro::serialized_field = "EyeL"] - pub eye_l: LinearColorStruct, - - #[paramacro::serialized_field = "EyeR"] - pub eye_r: LinearColorStruct, - - #[paramacro::serialized_field = "BodyMain"] - pub body_main: LinearColorStruct, - - #[paramacro::serialized_field = "BodySub1"] - pub body_sub1: LinearColorStruct, - - #[paramacro::serialized_field = "BodySub2"] - pub body_sub2: LinearColorStruct, - - #[paramacro::serialized_field = "BodySub3"] - pub body_sub3: LinearColorStruct, -} - -#[paramacro::serialized_struct("DAModuleColor")] -#[derive(Debug)] -pub struct DAModuleColorStruct { - #[paramacro::serialized_field = "Main"] - pub main: LinearColorStruct, - - #[paramacro::serialized_field = "Sub"] - pub sub: LinearColorStruct, - - #[paramacro::serialized_field = "Inner"] - pub inner: LinearColorStruct, - - #[paramacro::serialized_field = "Glow"] - pub glow: LinearColorStruct, -} - -#[paramacro::serialized_struct("DATriggerData")] -#[derive(Debug)] -pub struct DATriggerDataStruct { - #[paramacro::serialized_field = "A"] - pub a: EnumProperty, - - #[paramacro::serialized_field = "B"] - pub b: EnumProperty, - - #[paramacro::serialized_field = "C"] - pub c: EnumProperty, -} - -#[paramacro::serialized_struct("DACustomizeAssetIdData")] -#[derive(Debug)] -pub struct DACustomizeAssetIdDataStruct { - #[paramacro::serialized_field = "Body"] - pub body: PrimaryAssetIdStruct, - - #[paramacro::serialized_field = "Face"] - pub face: PrimaryAssetIdStruct, - - #[paramacro::serialized_field = "FrontHair"] - pub front_hair: PrimaryAssetIdStruct, - - #[paramacro::serialized_field = "BackHair"] - pub back_hair: PrimaryAssetIdStruct, - - #[paramacro::serialized_field = "ColoringData"] - pub coloring_data: DAHumanoidColoringDataStruct, - - #[paramacro::serialized_field = "FigureData"] - pub figure_data: DAHumanoidFigureData, - - #[paramacro::serialized_field = "bInverseFaceMesh"] - pub inverse_face_mesh: BoolProperty, - - #[paramacro::serialized_field = "bInverseFrontHairMesh"] - pub inverse_front_hair_mesh: BoolProperty, - - #[paramacro::serialized_field = "bInverseBackHairMesh"] - pub inverse_back_hair_mesh: BoolProperty, -} - -#[paramacro::serialized_struct("DAHumanoidFigureData")] -#[derive(Debug)] -pub struct DAHumanoidFigureData { - #[paramacro::serialized_field = "BustUp"] - pub bust_up: FloatProperty, - - #[paramacro::serialized_field = "FatUp"] - pub fat_up: FloatProperty, - - #[paramacro::serialized_field = "ArmUp"] - pub arm_up: FloatProperty, - - #[paramacro::serialized_field = "LegUp"] - pub leg_up: FloatProperty, - - #[paramacro::serialized_field = "WaistUp"] - pub waist_up: FloatProperty, -} - -#[paramacro::serialized_struct("DATuningData")] -#[derive(Debug)] -pub struct DATuningDataStruct { - #[paramacro::serialized_field = "GrantedTuningPointList"] - pub granted_tuning_point_list: MapProperty, -} - -#[binrw] -#[derive(Debug)] -pub struct SavedBuildData { - pub build_data: DABuildDataStruct, -} - -#[paramacro::serialized_struct("DATuningPointData")] -#[derive(Debug)] -pub struct DATuningPointData { - #[paramacro::serialized_field = "TuningPoint"] - tuning_point: IntProperty, - - #[paramacro::serialized_field = "MaxTuningPoint"] - max_tuning_point: IntProperty, -} - -#[paramacro::serialized_struct("Transform")] -#[derive(Debug)] -pub struct TransformStruct { - #[paramacro::serialized_field = "Rotation"] - rotation: QuatStruct, - - #[paramacro::serialized_field = "Translation"] - translation: VectorStruct, - - #[paramacro::serialized_field = "Scale3D"] - scale: VectorStruct, -} - -#[binrw] -#[derive(Debug)] -pub struct QuatStruct { - // TODO: check if w is actually in front or in the back, this is a guess - pub w: f32, - pub x: f32, - pub y: f32, - pub z: f32, -} - -#[binrw] -#[derive(Debug)] -pub struct VectorStruct { - pub x: f32, - pub y: f32, - pub z: f32, -} - #[binrw] #[derive(Debug)] pub struct StructFieldPrelude { @@ -356,48 +73,6 @@ pub(crate) trait PropertyBase { } } -impl PropertyBase for DateTimeStruct { - fn type_name() -> &'static str { - "StructProperty" - } - - fn struct_name() -> Option<&'static str> { - Some("DateTime") - } - - fn size_in_bytes(&self) -> u32 { - 8 - } -} - -impl PropertyBase for VectorStruct { - fn type_name() -> &'static str { - "StructProperty" - } - - fn struct_name() -> Option<&'static str> { - Some("Vector") - } - - fn size_in_bytes(&self) -> u32 { - 16 - } -} - -impl PropertyBase for QuatStruct { - fn type_name() -> &'static str { - "StructProperty" - } - - fn struct_name() -> Option<&'static str> { - Some("Quat") - } - - fn size_in_bytes(&self) -> u32 { - 16 - } -} - #[binrw::writer(writer, endian)] pub(crate) fn write_struct_field = ()> + Debug>( structure: &T, diff --git a/src/transform.rs b/src/transform.rs new file mode 100644 index 0000000..bb0bb1a --- /dev/null +++ b/src/transform.rs @@ -0,0 +1,14 @@ +use crate::{quat::QuatStruct, vector::VectorStruct}; + +#[paramacro::serialized_struct("Transform")] +#[derive(Debug)] +pub struct TransformStruct { + #[paramacro::serialized_field = "Rotation"] + rotation: QuatStruct, + + #[paramacro::serialized_field = "Translation"] + translation: VectorStruct, + + #[paramacro::serialized_field = "Scale3D"] + scale: VectorStruct, +} diff --git a/src/vector.rs b/src/vector.rs new file mode 100644 index 0000000..e203e87 --- /dev/null +++ b/src/vector.rs @@ -0,0 +1,25 @@ +use binrw::binrw; + +use crate::structs::PropertyBase; + +#[binrw] +#[derive(Debug)] +pub struct VectorStruct { + pub x: f32, + pub y: f32, + pub z: f32, +} + +impl PropertyBase for VectorStruct { + fn type_name() -> &'static str { + "StructProperty" + } + + fn struct_name() -> Option<&'static str> { + Some("Vector") + } + + fn size_in_bytes(&self) -> u32 { + 16 + } +}