summaryrefslogtreecommitdiff
path: root/editor/inspector_dock.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/inspector_dock.cpp')
-rw-r--r--editor/inspector_dock.cpp50
1 files changed, 27 insertions, 23 deletions
diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp
index 4bd1d7e83e..4cd8976e80 100644
--- a/editor/inspector_dock.cpp
+++ b/editor/inspector_dock.cpp
@@ -35,6 +35,7 @@
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/editor_undo_redo_manager.h"
+#include "editor/filesystem_dock.h"
#include "editor/plugins/script_editor_plugin.h"
InspectorDock *InspectorDock::singleton = nullptr;
@@ -86,6 +87,11 @@ void InspectorDock::_menu_option_confirm(int p_option, bool p_confirmed) {
case RESOURCE_EDIT_CLIPBOARD: {
_paste_resource();
} break;
+ case RESOURCE_SHOW_IN_FILESYSTEM: {
+ Ref<Resource> current_res = _get_current_resource();
+ ERR_FAIL_COND(current_res.is_null());
+ FileSystemDock::get_singleton()->navigate_to_path(current_res->get_path());
+ } break;
case OBJECT_REQUEST_HELP: {
if (current) {
@@ -142,10 +148,11 @@ void InspectorDock::_menu_option_confirm(int p_option, bool p_confirmed) {
ti->set_text(0, bool(EDITOR_GET("interface/inspector/capitalize_properties")) ? propname.capitalize() : propname);
}
+ unique_resources_label->set_text(TTR("The following resources will be duplicated and embedded within this resource/object."));
unique_resources_confirmation->popup_centered();
} else {
- unique_resources_confirmation->set_text(TTR("This object has no resources."));
current_option = -1;
+ unique_resources_label->set_text(TTR("This object has no resources."));
unique_resources_confirmation->popup_centered();
}
} else {
@@ -256,12 +263,8 @@ void InspectorDock::_resource_file_selected(String p_file) {
}
void InspectorDock::_save_resource(bool save_as) {
- ObjectID current_id = EditorNode::get_singleton()->get_editor_selection_history()->get_current();
- Object *current_obj = current_id.is_valid() ? ObjectDB::get_instance(current_id) : nullptr;
-
- ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj));
-
- Ref<Resource> current_res = Ref<Resource>(Object::cast_to<Resource>(current_obj));
+ Ref<Resource> current_res = _get_current_resource();
+ ERR_FAIL_COND(current_res.is_null());
if (save_as) {
EditorNode::get_singleton()->save_resource_as(current_res);
@@ -271,24 +274,15 @@ void InspectorDock::_save_resource(bool save_as) {
}
void InspectorDock::_unref_resource() {
- ObjectID current_id = EditorNode::get_singleton()->get_editor_selection_history()->get_current();
- Object *current_obj = current_id.is_valid() ? ObjectDB::get_instance(current_id) : nullptr;
-
- ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj));
-
- Ref<Resource> current_res = Ref<Resource>(Object::cast_to<Resource>(current_obj));
+ Ref<Resource> current_res = _get_current_resource();
+ ERR_FAIL_COND(current_res.is_null());
current_res->set_path("");
EditorNode::get_singleton()->edit_current();
}
void InspectorDock::_copy_resource() {
- ObjectID current_id = EditorNode::get_singleton()->get_editor_selection_history()->get_current();
- Object *current_obj = current_id.is_valid() ? ObjectDB::get_instance(current_id) : nullptr;
-
- ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj));
-
- Ref<Resource> current_res = Ref<Resource>(Object::cast_to<Resource>(current_obj));
-
+ Ref<Resource> current_res = _get_current_resource();
+ ERR_FAIL_COND(current_res.is_null());
EditorSettings::get_singleton()->set_resource_clipboard(current_res);
}
@@ -303,6 +297,16 @@ void InspectorDock::_prepare_resource_extra_popup() {
Ref<Resource> r = EditorSettings::get_singleton()->get_resource_clipboard();
PopupMenu *popup = resource_extra_button->get_popup();
popup->set_item_disabled(popup->get_item_index(RESOURCE_EDIT_CLIPBOARD), r.is_null());
+
+ Ref<Resource> current_res = _get_current_resource();
+ ERR_FAIL_COND(current_res.is_null());
+ popup->set_item_disabled(popup->get_item_index(RESOURCE_SHOW_IN_FILESYSTEM), current_res->is_built_in());
+}
+
+Ref<Resource> InspectorDock::_get_current_resource() const {
+ ObjectID current_id = EditorNode::get_singleton()->get_editor_selection_history()->get_current();
+ Object *current_obj = current_id.is_valid() ? ObjectDB::get_instance(current_id) : nullptr;
+ return Ref<Resource>(Object::cast_to<Resource>(current_obj));
}
void InspectorDock::_prepare_history() {
@@ -661,6 +665,7 @@ InspectorDock::InspectorDock(EditorData &p_editor_data) {
resource_extra_button->get_popup()->add_icon_shortcut(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons")), ED_SHORTCUT("property_editor/copy_resource", TTR("Copy Resource")), RESOURCE_COPY);
resource_extra_button->get_popup()->set_item_disabled(1, true);
resource_extra_button->get_popup()->add_separator();
+ resource_extra_button->get_popup()->add_shortcut(ED_SHORTCUT("property_editor/show_in_filesystem", TTR("Show in FileSystem")), RESOURCE_SHOW_IN_FILESYSTEM);
resource_extra_button->get_popup()->add_shortcut(ED_SHORTCUT("property_editor/unref_resource", TTR("Make Resource Built-In")), RESOURCE_MAKE_BUILT_IN);
resource_extra_button->get_popup()->set_item_disabled(3, true);
resource_extra_button->get_popup()->connect("id_pressed", callable_mp(this, &InspectorDock::_menu_option));
@@ -734,9 +739,8 @@ InspectorDock::InspectorDock(EditorData &p_editor_data) {
VBoxContainer *container = memnew(VBoxContainer);
unique_resources_confirmation->add_child(container);
- Label *top_label = memnew(Label);
- top_label->set_text(TTR("The following resources will be duplicated and embedded within this resource/object."));
- container->add_child(top_label);
+ unique_resources_label = memnew(Label);
+ container->add_child(unique_resources_label);
unique_resources_list_tree = memnew(Tree);
unique_resources_list_tree->set_hide_root(true);