diff --git a/editor/src/asset/inspector/mod.rs b/editor/src/asset/inspector/mod.rs index 1c0fff7cd..ba2c9ed6e 100644 --- a/editor/src/asset/inspector/mod.rs +++ b/editor/src/asset/inspector/mod.rs @@ -141,6 +141,7 @@ impl AssetInspector { generate_property_string_values: true, filter: Default::default(), name_column_width: 150.0, + base_path: Default::default(), }); ui.send_message(InspectorMessage::context( self.inspector, @@ -183,6 +184,7 @@ impl AssetInspector { 0, true, Default::default(), + Default::default(), ) .unwrap(); }); diff --git a/editor/src/export/mod.rs b/editor/src/export/mod.rs index 35ed2fb27..0809aeff2 100644 --- a/editor/src/export/mod.rs +++ b/editor/src/export/mod.rs @@ -413,6 +413,7 @@ impl ExportWindow { generate_property_string_values: true, filter: Default::default(), name_column_width: 150.0, + base_path: Default::default(), }); inspector = InspectorBuilder::new(WidgetBuilder::new()) @@ -663,9 +664,14 @@ impl ExportWindow { pub fn sync_to_model(&self, ui: &mut UserInterface) { if let Some(inspector) = ui.try_get_of_type::(self.inspector) { let ctx = inspector.context().clone(); - if let Err(sync_errors) = - ctx.sync(&self.export_options, ui, 0, true, Default::default()) - { + if let Err(sync_errors) = ctx.sync( + &self.export_options, + ui, + 0, + true, + Default::default(), + Default::default(), + ) { for error in sync_errors { Log::err(format!("Failed to sync property. Reason: {error:?}")) } diff --git a/editor/src/interaction/terrain.rs b/editor/src/interaction/terrain.rs index fd9c50846..230c60fc2 100644 --- a/editor/src/interaction/terrain.rs +++ b/editor/src/interaction/terrain.rs @@ -650,6 +650,7 @@ impl BrushPanel { generate_property_string_values: true, filter: Default::default(), name_column_width: 150.0, + base_path: Default::default(), }); let inspector; @@ -677,7 +678,7 @@ impl BrushPanel { .context() .clone(); - if let Err(e) = ctx.sync(brush, ui, 0, true, Default::default()) { + if let Err(e) = ctx.sync(brush, ui, 0, true, Default::default(), Default::default()) { Log::writeln( MessageKind::Error, format!("Failed to sync BrushPanel's inspector. Reason: {e:?}"), diff --git a/editor/src/light.rs b/editor/src/light.rs index 6c47031e6..b2660ffd8 100644 --- a/editor/src/light.rs +++ b/editor/src/light.rs @@ -255,6 +255,7 @@ impl LightPanel { generate_property_string_values: true, filter: Default::default(), name_column_width: 150.0, + base_path: Default::default(), })) .build(ctx); inspector diff --git a/editor/src/plugins/absm/parameter.rs b/editor/src/plugins/absm/parameter.rs index ec2c2e48c..20cb0528f 100644 --- a/editor/src/plugins/absm/parameter.rs +++ b/editor/src/plugins/absm/parameter.rs @@ -105,6 +105,7 @@ impl ParameterPanel { generate_property_string_values: true, filter: Default::default(), name_column_width: 150.0, + base_path: Default::default(), }) }) .unwrap_or_default(); @@ -132,7 +133,14 @@ impl ParameterPanel { .context() .clone(); - if let Err(sync_errors) = ctx.sync(parameters, ui, 0, true, Default::default()) { + if let Err(sync_errors) = ctx.sync( + parameters, + ui, + 0, + true, + Default::default(), + Default::default(), + ) { for error in sync_errors { Log::err(format!("Failed to sync property. Reason: {error:?}")) } diff --git a/editor/src/plugins/inspector/editors/script.rs b/editor/src/plugins/inspector/editors/script.rs index 6407c433e..6579a760d 100644 --- a/editor/src/plugins/inspector/editors/script.rs +++ b/editor/src/plugins/inspector/editors/script.rs @@ -257,6 +257,7 @@ impl ScriptPropertyEditorBuilder { generate_property_string_values, filter, name_column_width, + base_path: Default::default(), }) }); @@ -484,6 +485,7 @@ impl PropertyEditorDefinition for ScriptPropertyEditorDefinition { generate_property_string_values: ctx.generate_property_string_values, filter: ctx.filter, name_column_width: ctx.name_column_width, + base_path: Default::default(), }) }) .unwrap_or_default(); @@ -508,6 +510,7 @@ impl PropertyEditorDefinition for ScriptPropertyEditorDefinition { layer_index + 1, ctx.generate_property_string_values, ctx.filter, + ctx.base_path.clone(), ) { Err(InspectorError::Group(e)) } else { diff --git a/editor/src/plugins/inspector/mod.rs b/editor/src/plugins/inspector/mod.rs index 2fd53e415..03bcf2cee 100644 --- a/editor/src/plugins/inspector/mod.rs +++ b/editor/src/plugins/inspector/mod.rs @@ -283,7 +283,7 @@ impl InspectorPlugin { .context() .clone(); - ctx.sync(obj, ui, 0, true, Default::default()) + ctx.sync(obj, ui, 0, true, Default::default(), Default::default()) } fn change_context( @@ -312,6 +312,7 @@ impl InspectorPlugin { generate_property_string_values: true, filter: Default::default(), name_column_width: 150.0, + base_path: Default::default(), }); ui.send_message(InspectorMessage::context( diff --git a/editor/src/plugins/ragdoll.rs b/editor/src/plugins/ragdoll.rs index f85487d4b..150cfe4d8 100644 --- a/editor/src/plugins/ragdoll.rs +++ b/editor/src/plugins/ragdoll.rs @@ -1064,6 +1064,7 @@ impl RagdollWizard { generate_property_string_values: true, filter: Default::default(), name_column_width: 150.0, + base_path: Default::default(), })) .build(ctx); inspector @@ -1219,7 +1220,14 @@ impl RagdollWizard { .context() .clone(); - if let Err(sync_errors) = ctx.sync(&self.preset, ui, 0, true, Default::default()) { + if let Err(sync_errors) = ctx.sync( + &self.preset, + ui, + 0, + true, + Default::default(), + Default::default(), + ) { for error in sync_errors { Log::err(format!("Failed to sync property. Reason: {error:?}")) } diff --git a/editor/src/plugins/settings.rs b/editor/src/plugins/settings.rs index f5ea9934b..36cdc520c 100644 --- a/editor/src/plugins/settings.rs +++ b/editor/src/plugins/settings.rs @@ -267,6 +267,7 @@ impl SettingsWindow { generate_property_string_values: true, filter: Default::default(), name_column_width: 150.0, + base_path: Default::default(), }); let groups = context diff --git a/editor/src/scene/settings/mod.rs b/editor/src/scene/settings/mod.rs index 6c9344c03..45558fe00 100644 --- a/editor/src/scene/settings/mod.rs +++ b/editor/src/scene/settings/mod.rs @@ -161,6 +161,7 @@ impl SceneSettingsWindow { pass }), name_column_width: 150.0, + base_path: Default::default(), }); ui.send_message(InspectorMessage::context( diff --git a/fyrox-ui/src/inspector/editors/array.rs b/fyrox-ui/src/inspector/editors/array.rs index a8ea2c2d2..8c248d7ce 100644 --- a/fyrox-ui/src/inspector/editors/array.rs +++ b/fyrox-ui/src/inspector/editors/array.rs @@ -127,6 +127,7 @@ fn create_items<'a, 'b, T, I>( generate_property_string_values: bool, filter: PropertyFilter, name_column_width: f32, + base_path: String, ) -> Result, InspectorError> where T: Reflect, @@ -171,6 +172,7 @@ where generate_property_string_values, filter: filter.clone(), name_column_width, + base_path: format!("{base_path}[{index}]"), })?; if let PropertyEditorInstance::Simple { editor } = editor { @@ -250,6 +252,7 @@ where property_info: &FieldRef<'a, '_>, sync_flag: u64, name_column_width: f32, + base_path: String, ) -> Result, InspectorError> { let definition_container = self .definition_container @@ -268,6 +271,7 @@ where self.generate_property_string_values, self.filter, name_column_width, + base_path, )? } else { Vec::new() @@ -350,6 +354,7 @@ where ctx.property_info, ctx.sync_flag, ctx.name_column_width, + ctx.base_path.clone(), )?; editor }, @@ -375,6 +380,7 @@ where definition_container, environment, name_column_width, + base_path, } = ctx; let instance_ref = if let Some(instance) = ui.node(instance).cast::() { @@ -431,6 +437,7 @@ where generate_property_string_values, filter: filter.clone(), name_column_width, + base_path: format!("{base_path}[{index}]"), })? { ui.send_message(message.with_flags(ctx.sync_flag)) diff --git a/fyrox-ui/src/inspector/editors/collection.rs b/fyrox-ui/src/inspector/editors/collection.rs index bc6a0b8d7..a545af2c8 100644 --- a/fyrox-ui/src/inspector/editors/collection.rs +++ b/fyrox-ui/src/inspector/editors/collection.rs @@ -239,6 +239,7 @@ fn create_items<'a, 'b, T, I>( filter: PropertyFilter, immutable_collection: bool, name_column_width: f32, + base_path: String, ) -> Result, InspectorError> where T: CollectionItem, @@ -281,6 +282,7 @@ where generate_property_string_values, filter: filter.clone(), name_column_width, + base_path: format!("{base_path}[{index}]"), })?; if let PropertyEditorInstance::Simple { editor } = editor { @@ -386,6 +388,7 @@ where property_info: &FieldRef<'a, '_>, sync_flag: u64, name_column_width: f32, + base_path: String, ) -> Result, InspectorError> { let definition_container = self .definition_container @@ -405,6 +408,7 @@ where self.filter, self.immutable_collection, name_column_width, + base_path, )? } else { Vec::new() @@ -510,6 +514,7 @@ where ctx.property_info, ctx.sync_flag, ctx.name_column_width, + ctx.base_path.clone(), )?; editor }, @@ -535,6 +540,7 @@ where generate_property_string_values, filter, name_column_width, + base_path, } = ctx; let instance_ref = if let Some(instance) = ui.node(instance).cast::>() { @@ -561,6 +567,7 @@ where filter, property_info.immutable_collection, name_column_width, + base_path, )?; Ok(Some(CollectionEditorMessage::items( @@ -611,6 +618,7 @@ where generate_property_string_values, filter: filter.clone(), name_column_width, + base_path: format!("{base_path}[{index}]"), })? { ui.send_message(message.with_flags(ctx.sync_flag)) diff --git a/fyrox-ui/src/inspector/editors/enumeration.rs b/fyrox-ui/src/inspector/editors/enumeration.rs index d31583b1f..c1c6c5d2f 100644 --- a/fyrox-ui/src/inspector/editors/enumeration.rs +++ b/fyrox-ui/src/inspector/editors/enumeration.rs @@ -107,6 +107,9 @@ pub struct EnumPropertyEditor { #[visit(skip)] #[reflect(hidden)] pub name_column_width: f32, + #[visit(skip)] + #[reflect(hidden)] + pub base_path: String, } impl Debug for EnumPropertyEditor { @@ -129,6 +132,7 @@ impl Clone for EnumPropertyEditor { generate_property_string_values: self.generate_property_string_values, filter: self.filter.clone(), name_column_width: self.name_column_width, + base_path: self.base_path.clone(), } } } @@ -181,6 +185,7 @@ impl Control for EnumPropertyEditor { generate_property_string_values: self.generate_property_string_values, filter: self.filter.clone(), name_column_width: self.name_column_width, + base_path: self.base_path.clone(), }); ui.send_message(InspectorMessage::context( @@ -296,6 +301,7 @@ impl EnumPropertyEditorBuilder { definition: &EnumPropertyEditorDefinition, value: &T, name_column_width: f32, + base_path: String, ) -> Handle { let definition_container = self .definition_container @@ -311,6 +317,7 @@ impl EnumPropertyEditorBuilder { generate_property_string_values: self.generate_property_string_values, filter: self.filter.clone(), name_column_width, + base_path: base_path.clone(), }); let inspector = InspectorBuilder::new(WidgetBuilder::new()) @@ -333,6 +340,7 @@ impl EnumPropertyEditorBuilder { generate_property_string_values: self.generate_property_string_values, filter: self.filter, name_column_width, + base_path, }; ctx.add_node(UiNode::new(editor)) @@ -459,7 +467,13 @@ where .with_sync_flag(ctx.sync_flag) .with_generate_property_string_values(ctx.generate_property_string_values) .with_filter(ctx.filter) - .build(ctx.build_context, self, value, ctx.name_column_width); + .build( + ctx.build_context, + self, + value, + ctx.name_column_width, + ctx.base_path.clone(), + ); editor }, ctx.name_column_width, @@ -518,6 +532,7 @@ where generate_property_string_values: ctx.generate_property_string_values, filter: ctx.filter, name_column_width: ctx.name_column_width, + base_path: ctx.base_path.clone(), }); Ok(Some(InspectorMessage::context( @@ -541,6 +556,7 @@ where layer_index + 1, ctx.generate_property_string_values, ctx.filter, + ctx.base_path.clone(), ) { Err(InspectorError::Group(e)) } else { diff --git a/fyrox-ui/src/inspector/editors/inherit.rs b/fyrox-ui/src/inspector/editors/inherit.rs index 148b292b7..118ca04b2 100644 --- a/fyrox-ui/src/inspector/editors/inherit.rs +++ b/fyrox-ui/src/inspector/editors/inherit.rs @@ -263,6 +263,7 @@ where generate_property_string_values: ctx.generate_property_string_values, filter: ctx.filter, name_column_width: ctx.name_column_width, + base_path: ctx.base_path.clone(), })?; let wrapper = InheritablePropertyEditorBuilder::new(WidgetBuilder::new()) @@ -353,6 +354,7 @@ where generate_property_string_values: ctx.generate_property_string_values, filter: ctx.filter, name_column_width: ctx.name_column_width, + base_path: ctx.base_path.clone(), }); } diff --git a/fyrox-ui/src/inspector/editors/inspectable.rs b/fyrox-ui/src/inspector/editors/inspectable.rs index 7b8e5196a..ad48b88f8 100644 --- a/fyrox-ui/src/inspector/editors/inspectable.rs +++ b/fyrox-ui/src/inspector/editors/inspectable.rs @@ -99,6 +99,7 @@ where generate_property_string_values: ctx.generate_property_string_values, filter: ctx.filter, name_column_width: ctx.name_column_width, + base_path: ctx.base_path.clone(), }); let editor; @@ -144,6 +145,7 @@ where ctx.layer_index + 1, ctx.generate_property_string_values, ctx.filter, + ctx.base_path.clone(), ) { error_group.extend(e) } diff --git a/fyrox-ui/src/inspector/editors/mod.rs b/fyrox-ui/src/inspector/editors/mod.rs index ea41cb58d..be8d4e090 100644 --- a/fyrox-ui/src/inspector/editors/mod.rs +++ b/fyrox-ui/src/inspector/editors/mod.rs @@ -179,6 +179,7 @@ pub struct PropertyEditorBuildContext<'a, 'b, 'c, 'd> { pub filter: PropertyFilter, /// Width of the property name column. pub name_column_width: f32, + pub base_path: String, } /// This structure is passed to [PropertyEditorDefinition::create_message] in order to generate a message that will @@ -218,6 +219,7 @@ pub struct PropertyEditorMessageContext<'a, 'b, 'c> { pub filter: PropertyFilter, /// Width of the property name column. pub name_column_width: f32, + pub base_path: String, } /// The details relevant to translating a message from an editor widget into diff --git a/fyrox-ui/src/inspector/editors/refcell.rs b/fyrox-ui/src/inspector/editors/refcell.rs index e55570d68..27535aaeb 100644 --- a/fyrox-ui/src/inspector/editors/refcell.rs +++ b/fyrox-ui/src/inspector/editors/refcell.rs @@ -114,6 +114,7 @@ where generate_property_string_values: ctx.generate_property_string_values, filter: ctx.filter, name_column_width: ctx.name_column_width, + base_path: ctx.base_path.clone(), }) } else { Err(InspectorError::Custom("No editor!".to_string())) @@ -163,6 +164,7 @@ where generate_property_string_values: ctx.generate_property_string_values, filter: ctx.filter, name_column_width: ctx.name_column_width, + base_path: ctx.base_path.clone(), }); } diff --git a/fyrox-ui/src/inspector/editors/style.rs b/fyrox-ui/src/inspector/editors/style.rs index cd4efd9e9..596696b15 100644 --- a/fyrox-ui/src/inspector/editors/style.rs +++ b/fyrox-ui/src/inspector/editors/style.rs @@ -255,6 +255,7 @@ where generate_property_string_values: ctx.generate_property_string_values, filter: ctx.filter, name_column_width: ctx.name_column_width, + base_path: ctx.base_path.clone(), })?; let wrapper = StyledPropertyEditorBuilder::new(WidgetBuilder::new()) @@ -332,6 +333,7 @@ where generate_property_string_values: ctx.generate_property_string_values, filter: ctx.filter, name_column_width: ctx.name_column_width, + base_path: ctx.base_path.clone(), }); } diff --git a/fyrox-ui/src/inspector/mod.rs b/fyrox-ui/src/inspector/mod.rs index 1eb68367e..f9e03e1fa 100644 --- a/fyrox-ui/src/inspector/mod.rs +++ b/fyrox-ui/src/inspector/mod.rs @@ -470,7 +470,8 @@ pub trait InspectorEnvironment: Any + Send + Sync { /// layer_index: 0, /// generate_property_string_values: true, /// filter: Default::default(), -/// name_column_width: 150.0 +/// name_column_width: 150.0, +/// base_path: Default::default(), /// }); /// /// InspectorBuilder::new(WidgetBuilder::new()) @@ -556,6 +557,7 @@ pub struct ContextEntry { /// Storing the handle here allows us to which editor the user is indicating if the mouse is over the area /// surrounding the editor instead of the editor itself. pub property_container: Handle, + pub property_path: String, } impl PartialEq for ContextEntry { @@ -825,6 +827,7 @@ pub struct InspectorContextArgs<'a, 'b, 'c> { pub generate_property_string_values: bool, pub filter: PropertyFilter, pub name_column_width: f32, + pub base_path: String, } impl InspectorContext { @@ -855,6 +858,7 @@ impl InspectorContext { generate_property_string_values, filter, name_column_width, + base_path, } = context; let mut entries = Vec::new(); @@ -882,6 +886,14 @@ impl InspectorContext { .definitions() .get(&info.value.type_id()) { + let property_path = if base_path.is_empty() { + info.name.to_string() + } else { + format!("{}.{}", base_path, info.name) + }; + + dbg!(&property_path); + let editor = match definition.property_editor.create_instance( PropertyEditorBuildContext { build_context: ctx, @@ -893,6 +905,7 @@ impl InspectorContext { generate_property_string_values, filter: filter.clone(), name_column_width, + base_path: property_path.clone(), }, ) { Ok(instance) => { @@ -921,6 +934,7 @@ impl InspectorContext { property_tag: info.tag.to_string(), property_debug_output: field_text.clone(), property_container: container, + property_path, }); if info.read_only { @@ -1030,6 +1044,7 @@ impl InspectorContext { layer_index: usize, generate_property_string_values: bool, filter: PropertyFilter, + base_path: String, ) -> Result<(), Vec> { if object_type_id(object) != self.object_type_id { return Err(vec![InspectorError::OutOfSync]); @@ -1060,6 +1075,7 @@ impl InspectorContext { generate_property_string_values, filter: filter.clone(), name_column_width: self.name_column_width, + base_path: base_path.clone(), }; match constructor.property_editor.create_message(ctx) { diff --git a/project-manager/src/settings.rs b/project-manager/src/settings.rs index 4e2a4f55a..24e41e4d4 100644 --- a/project-manager/src/settings.rs +++ b/project-manager/src/settings.rs @@ -233,6 +233,7 @@ impl SettingsWindow { generate_property_string_values: true, filter: Default::default(), name_column_width: 170.0, + base_path: Default::default(), }); let inspector = InspectorBuilder::new(WidgetBuilder::new()) .with_context(context) @@ -288,7 +289,14 @@ impl SettingsWindow { .context() .clone(); - Log::verify(ctx.sync(&**settings, ui, 0, true, Default::default())); + Log::verify(ctx.sync( + &**settings, + ui, + 0, + true, + Default::default(), + Default::default(), + )); } }