diff options
author | lupoDharkael <izhe@hotmail.es> | 2020-12-13 02:37:23 +0100 |
---|---|---|
committer | lupoDharkael <izhe@hotmail.es> | 2021-03-13 22:09:17 +0100 |
commit | f2e906496b403452dd83b04f512cc53eb6dc7e4f (patch) | |
tree | 777bdf05a7ce73891cbb084bfcba0f99bc5f2407 | |
parent | 0762484473c1330c5d524d5cc3644d5e2b2e557c (diff) |
Save resource: implement extension priority
give .res less priority and .tres more priority as preferred
extensions.
-rw-r--r-- | editor/editor_node.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 66c54c4267..b142468f5a 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -996,13 +996,23 @@ void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String file->clear_filters(); List<String> preferred; - for (int i = 0; i < extensions.size(); i++) { - if (p_resource->is_class("Script") && (extensions[i] == "tres" || extensions[i] == "res" || extensions[i] == "xml")) { + for (List<String>::Element *E = extensions.front(); E; E = E->next()) { + if (p_resource->is_class("Script") && (E->get() == "tres" || E->get() == "res")) { //this serves no purpose and confused people continue; } - file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper()); - preferred.push_back(extensions[i]); + file->add_filter("*." + E->get() + " ; " + E->get().to_upper()); + preferred.push_back(E->get()); + } + // Lowest priority extension + List<String>::Element *res_element = preferred.find("res"); + if (res_element) { + preferred.move_to_back(res_element); + } + // Highest priority extension + List<String>::Element *tres_element = preferred.find("tres"); + if (tres_element) { + preferred.move_to_front(tres_element); } if (p_at_path != String()) { |