From d32f2700ffd8ca01af0077d9e8dcff10079bc776 Mon Sep 17 00:00:00 2001 From: willnationsdev Date: Tue, 26 Apr 2022 00:55:51 -0500 Subject: Script-class-aware Inspector & related controls. --- editor/editor_resource_picker.cpp | 146 ++++++++++++++++++++++++-------------- editor/editor_resource_picker.h | 1 + 2 files changed, 92 insertions(+), 55 deletions(-) (limited to 'editor') diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp index 84cb085551..de8259c25c 100644 --- a/editor/editor_resource_picker.cpp +++ b/editor/editor_resource_picker.cpp @@ -53,6 +53,7 @@ void EditorResourcePicker::_update_resource() { if (edited_resource.is_valid() && edited_resource->get_path().is_resource_file()) { resource_path = edited_resource->get_path() + "\n"; } + String class_name = _get_resource_type(edited_resource); if (preview_rect) { preview_rect->set_texture(Ref()); @@ -64,16 +65,20 @@ void EditorResourcePicker::_update_resource() { assign_button->set_text(TTR("")); assign_button->set_tooltip_text(""); } else { - assign_button->set_icon(EditorNode::get_singleton()->get_object_icon(edited_resource.operator->(), "Object")); + assign_button->set_icon(EditorNode::get_singleton()->get_object_icon(edited_resource.operator->(), SNAME("Object"))); if (!edited_resource->get_name().is_empty()) { assign_button->set_text(edited_resource->get_name()); } else if (edited_resource->get_path().is_resource_file()) { assign_button->set_text(edited_resource->get_path().get_file()); } else { - assign_button->set_text(edited_resource->get_class()); + assign_button->set_text(class_name); } - assign_button->set_tooltip_text(resource_path + TTR("Type:") + " " + edited_resource->get_class()); + + if (edited_resource->get_path().is_resource_file()) { + resource_path = edited_resource->get_path() + "\n"; + } + assign_button->set_tooltip_text(resource_path + TTR("Type:") + " " + class_name); // Preview will override the above, so called at the end. EditorResourcePreview::get_singleton()->queue_edited_resource_preview(edited_resource, this, "_update_resource_preview", edited_resource->get_instance_id()); @@ -134,16 +139,29 @@ void EditorResourcePicker::_file_selected(const String &p_path) { if (!base_type.is_empty()) { bool any_type_matches = false; + String res_type = loaded_resource->get_class(); + Ref