summaryrefslogtreecommitdiff
path: root/tools/editor
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2015-12-31 13:12:27 -0300
committerJuan Linietsky <reduzio@gmail.com>2015-12-31 13:12:27 -0300
commitff1763e38f5ded25a5a3b19d739757bb6d2c44ac (patch)
tree64c7f91d94ba301b16ac527021590a6478e12f58 /tools/editor
parent1e65c3c7019be69526c71aa09175010ba4a8e09f (diff)
properly implement save as from script editor, fixes #2415
Diffstat (limited to 'tools/editor')
-rw-r--r--tools/editor/editor_node.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp
index 4438123dff..a948e7379f 100644
--- a/tools/editor/editor_node.cpp
+++ b/tools/editor/editor_node.cpp
@@ -511,13 +511,21 @@ void EditorNode::save_resource_as(const Ref<Resource>& 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<String> extensions;
Ref<PackedScene> sd = memnew( PackedScene );
ResourceSaver::get_recognized_extensions(p_resource,&extensions);
file->clear_filters();
+
+ List<String> preferred;
for(int i=0;i<extensions.size();i++) {
+ if (p_resource->is_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<Resource>& 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);