From ff1763e38f5ded25a5a3b19d739757bb6d2c44ac Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Thu, 31 Dec 2015 13:12:27 -0300 Subject: [PATCH] properly implement save as from script editor, fixes #2415 --- tools/editor/editor_node.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index 4438123dffd..a948e7379f9 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -511,13 +511,21 @@ void EditorNode::save_resource_as(const Ref& p_resource) { file->set_mode(EditorFileDialog::MODE_SAVE_FILE); bool relpaths = (p_resource->has_meta("__editor_relpaths__") && p_resource->get_meta("__editor_relpaths__").operator bool()); + current_option=RESOURCE_SAVE_AS; List extensions; Ref sd = memnew( PackedScene ); ResourceSaver::get_recognized_extensions(p_resource,&extensions); file->clear_filters(); + + List preferred; for(int i=0;iis_type("Script") && extensions[i]=="tres" || extensions[i]=="res" || extensions[i]=="xml") { + //this serves no purpose and confused people + continue; + } file->add_filter("*."+extensions[i]+" ; "+extensions[i].to_upper()); + preferred.push_back(extensions[i]); } //file->set_current_path(current_path); @@ -529,11 +537,11 @@ void EditorNode::save_resource_as(const Ref& p_resource) { file->set_current_path(p_resource->get_path().replacen("."+ext,"."+extensions.front()->get())); } } - } else { + } else if (preferred.size()) { String existing; if (extensions.size()) { - existing="new_"+p_resource->get_type().to_lower()+"."+extensions.front()->get().to_lower(); + existing="new_"+p_resource->get_type().to_lower()+"."+preferred.front()->get().to_lower(); } file->set_current_path(existing);