diff options
Diffstat (limited to 'editor/inspector_dock.cpp')
-rw-r--r-- | editor/inspector_dock.cpp | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp index 04ddf3552b..a559f05785 100644 --- a/editor/inspector_dock.cpp +++ b/editor/inspector_dock.cpp @@ -204,11 +204,24 @@ void InspectorDock::_load_resource(const String &p_type) { load_resource_dialog->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper()); } + const Vector<String> textfile_ext = ((String)(EditorSettings::get_singleton()->get("docks/filesystem/textfile_extensions"))).split(",", false); + for (int i = 0; i < textfile_ext.size(); i++) { + load_resource_dialog->add_filter("*." + textfile_ext[i] + " ; " + textfile_ext[i].to_upper()); + } + load_resource_dialog->popup_file_dialog(); } void InspectorDock::_resource_file_selected(String p_file) { - RES res = ResourceLoader::load(p_file); + RES res; + if (ResourceLoader::exists(p_file, "")) { + res = ResourceLoader::load(p_file); + } else { + const Vector<String> textfile_ext = ((String)(EditorSettings::get_singleton()->get("docks/filesystem/textfile_extensions"))).split(",", false); + if (textfile_ext.has(p_file.get_extension())) { + res = ScriptEditor::get_singleton()->open_file(p_file); + } + } if (res.is_null()) { warning_dialog->set_text(TTR("Failed to load resource.")); @@ -469,18 +482,19 @@ void InspectorDock::update(Object *p_object) { const bool is_object = p_object != nullptr; const bool is_resource = is_object && p_object->is_class("Resource"); + const bool is_text_file = is_object && p_object->is_class("TextFile"); const bool is_node = is_object && p_object->is_class("Node"); - object_menu->set_disabled(!is_object); - search->set_editable(is_object); - resource_save_button->set_disabled(!is_resource); - open_docs_button->set_disabled(!is_resource && !is_node); + object_menu->set_disabled(!is_object || is_text_file); + search->set_editable(is_object && !is_text_file); + resource_save_button->set_disabled(!is_resource || is_text_file); + open_docs_button->set_disabled(is_text_file || (!is_resource && !is_node)); PopupMenu *resource_extra_popup = resource_extra_button->get_popup(); - resource_extra_popup->set_item_disabled(resource_extra_popup->get_item_index(RESOURCE_COPY), !is_resource); - resource_extra_popup->set_item_disabled(resource_extra_popup->get_item_index(RESOURCE_MAKE_BUILT_IN), !is_resource); + resource_extra_popup->set_item_disabled(resource_extra_popup->get_item_index(RESOURCE_COPY), !is_resource || is_text_file); + resource_extra_popup->set_item_disabled(resource_extra_popup->get_item_index(RESOURCE_MAKE_BUILT_IN), !is_resource || is_text_file); - if (!is_object) { + if (!is_object || is_text_file) { warning->hide(); editor_path->clear_path(); return; |