From 6e835a482011bcac62bded02c09f13e3c933992c Mon Sep 17 00:00:00 2001 From: Sl3dge78 <45926471+Sl3dge78@users.noreply.github.com> Date: Fri, 19 Jun 2020 01:22:36 +0200 Subject: [PATCH] Autofilled path gets set properly on animation subresources (cherry picked from commit d731f43794d13ff9866561090011ad94655f8a24) --- .../plugins/animation_player_editor_plugin.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index 5e69ce4e69d..994bc8bb6fd 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -405,27 +405,25 @@ void AnimationPlayerEditor::_animation_save_as(const Ref &p_resource) file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper()); } + String path; //file->set_current_path(current_path); if (p_resource->get_path() != "") { - file->set_current_path(p_resource->get_path()); + path = p_resource->get_path(); if (extensions.size()) { - String ext = p_resource->get_path().get_extension().to_lower(); - if (extensions.find(ext) == NULL) { - file->set_current_path(p_resource->get_path().replacen("." + ext, "." + extensions.front()->get())); + if (extensions.find(p_resource->get_path().get_extension().to_lower()) == NULL) { + path = p_resource->get_path().get_base_dir() + p_resource->get_name() + "." + extensions.front()->get(); } } } else { - - String existing; if (extensions.size()) { if (p_resource->get_name() != "") { - existing = p_resource->get_name() + "." + extensions.front()->get().to_lower(); + path = p_resource->get_name() + "." + extensions.front()->get().to_lower(); } else { - existing = "new_" + p_resource->get_class().to_lower() + "." + extensions.front()->get().to_lower(); + path = "new_" + p_resource->get_class().to_lower() + "." + extensions.front()->get().to_lower(); } } - file->set_current_path(existing); } + file->set_current_path(path); file->popup_centered_ratio(); file->set_title(TTR("Save Resource As...")); current_option = RESOURCE_SAVE;