From ecdfb65aa787dedd5186827105d404c377d31519 Mon Sep 17 00:00:00 2001 From: Relintai Date: Tue, 8 Mar 2022 18:12:11 +0100 Subject: [PATCH] Implement selecting the edited resource on clicking it's button in the world generator addon's EditorResourceWidget. --- game/addons/world_generator/ui/ResourcePropertyList.gd | 1 + .../world_generator/widgets/EditorResourceWidget.gd | 9 ++++++--- .../world_generator/widgets/EditorResourceWidget.tscn | 3 --- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/game/addons/world_generator/ui/ResourcePropertyList.gd b/game/addons/world_generator/ui/ResourcePropertyList.gd index 6d6dbbcf..33deaaaf 100644 --- a/game/addons/world_generator/ui/ResourcePropertyList.gd +++ b/game/addons/world_generator/ui/ResourcePropertyList.gd @@ -53,6 +53,7 @@ func add_slot_resource(getter : String, setter : String, slot_name : String, res bc.add_child(l) var r : Control = EditorResourceWidget.instance() + r.set_plugin(_plugin) r.set_resource_type(resource_type) r.set_resource(_edited_resource.call(getter)) r.set_h_size_flags(SIZE_EXPAND_FILL) diff --git a/game/addons/world_generator/widgets/EditorResourceWidget.gd b/game/addons/world_generator/widgets/EditorResourceWidget.gd index 5c3039ba..a73924e9 100644 --- a/game/addons/world_generator/widgets/EditorResourceWidget.gd +++ b/game/addons/world_generator/widgets/EditorResourceWidget.gd @@ -3,6 +3,7 @@ extends HBoxContainer var _resource_type : String = "Resource" var _resource : Resource = null +var _plugin : EditorPlugin = null signal on_resource_changed(new_res) @@ -41,9 +42,8 @@ func on_clear_button_pressed() -> void: set_resource(null) func on_resource_button_pressed() -> void: - if _resource: - #todo - pass + if _resource && _plugin: + _plugin.get_editor_interface().inspect_object(_resource) #examples #{files:[res://modules/planets/test_planet/test_world.tres], from:@@4176:[Tree:9070], type:files} @@ -75,3 +75,6 @@ func get_drag_data_fw(position, from_control): d["type"] = "resource" return d + +func set_plugin(plugin : EditorPlugin) -> void: + _plugin = plugin diff --git a/game/addons/world_generator/widgets/EditorResourceWidget.tscn b/game/addons/world_generator/widgets/EditorResourceWidget.tscn index 5f5052b5..f5f3bfef 100644 --- a/game/addons/world_generator/widgets/EditorResourceWidget.tscn +++ b/game/addons/world_generator/widgets/EditorResourceWidget.tscn @@ -6,9 +6,6 @@ margin_right = 376.0 margin_bottom = 40.0 script = ExtResource( 1 ) -__meta__ = { -"_edit_use_anchors_": false -} [node name="ResourceButton" type="Button" parent="."] margin_right = 342.0