Skip to content

Commit 287dd6c

Browse files
committed
hide "revert" button for inheritable properties when no parent object
- having this button visible for new objects without a parent prefab is very confusing, it also did nothing so it was even more confusing
1 parent 0dc0e24 commit 287dd6c

File tree

30 files changed

+118
-26
lines changed

30 files changed

+118
-26
lines changed

editor/src/asset/selection.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,19 +153,19 @@ impl SelectionContainer for AssetSelection {
153153
&self,
154154
_controller: &dyn SceneController,
155155
_scenes: &SceneContainer,
156-
callback: &mut dyn FnMut(&dyn Reflect),
156+
callback: &mut dyn FnMut(&dyn Reflect, bool),
157157
) {
158158
if let Some(resource) = self.resources.first() {
159159
if let Some(options) = resource.import_options.as_ref() {
160160
let options = options.borrow();
161-
callback(&**options as &dyn Reflect)
161+
callback(&**options as &dyn Reflect, false)
162162
} else if let Ok(resource) =
163163
block_on(self.resource_manager.request_untyped(&resource.path))
164164
{
165165
if !self.resource_manager.is_built_in_resource(&resource) {
166166
let guard = resource.0.lock();
167167
if let Some(data) = guard.state.data_ref() {
168-
callback(&*data.0 as &dyn Reflect)
168+
callback(&*data.0 as &dyn Reflect, false)
169169
}
170170
}
171171
}

editor/src/audio/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl SelectionContainer for AudioBusSelection {
8383
&self,
8484
controller: &dyn SceneController,
8585
scenes: &SceneContainer,
86-
callback: &mut dyn FnMut(&dyn Reflect),
86+
callback: &mut dyn FnMut(&dyn Reflect, bool),
8787
) {
8888
let game_scene = some_or_return!(controller.downcast_ref::<GameScene>());
8989
let scene = &scenes[game_scene.scene];
@@ -93,7 +93,7 @@ impl SelectionContainer for AudioBusSelection {
9393
.first()
9494
.and_then(|handle| state.bus_graph_ref().try_get_bus_ref(*handle))
9595
{
96-
(callback)(effect as &dyn Reflect);
96+
(callback)(effect as &dyn Reflect, false);
9797
}
9898
}
9999

editor/src/export/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ impl ExportWindow {
414414
filter: Default::default(),
415415
name_column_width: 150.0,
416416
base_path: Default::default(),
417+
has_parent_object: false,
417418
});
418419

419420
inspector = InspectorBuilder::new(WidgetBuilder::new())

editor/src/interaction/navmesh/selection.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,12 @@ impl SelectionContainer for NavmeshSelection {
6161
&self,
6262
controller: &dyn SceneController,
6363
scenes: &SceneContainer,
64-
callback: &mut dyn FnMut(&dyn Reflect),
64+
callback: &mut dyn FnMut(&dyn Reflect, bool),
6565
) {
6666
let game_scene = some_or_return!(controller.downcast_ref::<GameScene>());
6767
let scene = &scenes[game_scene.scene];
68-
(callback)(scene.graph.try_get(self.navmesh_node).unwrap() as &dyn Reflect);
68+
let node = scene.graph.try_get(self.navmesh_node).unwrap();
69+
(callback)(node as &dyn Reflect, node.has_inheritance_parent());
6970
}
7071

7172
fn on_property_changed(

editor/src/interaction/terrain.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,7 @@ impl BrushPanel {
651651
filter: Default::default(),
652652
name_column_width: 150.0,
653653
base_path: Default::default(),
654+
has_parent_object: false,
654655
});
655656

656657
let inspector;

editor/src/light.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ impl LightPanel {
251251
filter: Default::default(),
252252
name_column_width: 150.0,
253253
base_path: Default::default(),
254+
has_parent_object: false,
254255
}))
255256
.build(ctx);
256257
inspector

editor/src/plugins/absm/parameter.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ impl ParameterPanel {
106106
filter: Default::default(),
107107
name_column_width: 150.0,
108108
base_path: Default::default(),
109+
has_parent_object: false,
109110
})
110111
})
111112
.unwrap_or_default();

editor/src/plugins/absm/selection.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,21 +164,21 @@ impl<N: Reflect> SelectionContainer for AbsmSelection<N> {
164164
&self,
165165
controller: &dyn SceneController,
166166
scenes: &SceneContainer,
167-
callback: &mut dyn FnMut(&dyn Reflect),
167+
callback: &mut dyn FnMut(&dyn Reflect, bool),
168168
) {
169169
if let Some(machine) = get_machine_ref(controller, self.absm_node_handle, scenes) {
170170
if let Some(first) = self.entities.first() {
171171
if let Some(layer_index) = self.layer {
172172
if let Some(layer) = machine.layers().get(layer_index) {
173173
match first {
174174
SelectedEntity::Transition(transition) => {
175-
(callback)(&layer.transitions()[*transition] as &dyn Reflect)
175+
(callback)(&layer.transitions()[*transition] as &dyn Reflect, false)
176176
}
177177
SelectedEntity::State(state) => {
178-
(callback)(&layer.states()[*state] as &dyn Reflect)
178+
(callback)(&layer.states()[*state] as &dyn Reflect, false)
179179
}
180180
SelectedEntity::PoseNode(pose) => {
181-
(callback)(&layer.nodes()[*pose] as &dyn Reflect)
181+
(callback)(&layer.nodes()[*pose] as &dyn Reflect, false)
182182
}
183183
};
184184
}

editor/src/plugins/animation/selection.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ where
125125
&self,
126126
controller: &dyn SceneController,
127127
scenes: &SceneContainer,
128-
callback: &mut dyn FnMut(&dyn Reflect),
128+
callback: &mut dyn FnMut(&dyn Reflect, bool),
129129
) {
130130
if let Some(container) = get_animations_container(self.animation_player, controller, scenes)
131131
{
@@ -134,7 +134,7 @@ where
134134
self.entities.first()
135135
{
136136
if let Some(signal) = animation.signals().iter().find(|s| s.id == *id) {
137-
(callback)(signal as &dyn Reflect);
137+
(callback)(signal as &dyn Reflect, false);
138138
}
139139
}
140140
}

editor/src/plugins/inspector/editors/script.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ impl ScriptPropertyEditorBuilder {
244244
script: &Option<Script>,
245245
definition_container: Arc<PropertyEditorDefinitionContainer>,
246246
name_column_width: f32,
247+
has_parent_object: bool,
247248
ctx: &mut BuildContext,
248249
) -> Handle<UiNode> {
249250
let context = script.as_ref().map(|script| {
@@ -258,6 +259,7 @@ impl ScriptPropertyEditorBuilder {
258259
filter,
259260
name_column_width,
260261
base_path: Default::default(),
262+
has_parent_object,
261263
})
262264
});
263265

@@ -393,6 +395,7 @@ impl PropertyEditorDefinition for ScriptPropertyEditorDefinition {
393395
value,
394396
ctx.definition_container.clone(),
395397
ctx.name_column_width,
398+
ctx.has_parent_object,
396399
ctx.build_context,
397400
);
398401
editor
@@ -486,6 +489,7 @@ impl PropertyEditorDefinition for ScriptPropertyEditorDefinition {
486489
filter: ctx.filter,
487490
name_column_width: ctx.name_column_width,
488491
base_path: Default::default(),
492+
has_parent_object: ctx.has_parent_object,
489493
})
490494
})
491495
.unwrap_or_default();

0 commit comments

Comments
 (0)