diff options
author | Micky <micheledevita2@gmail.com> | 2024-01-15 00:48:06 +0100 |
---|---|---|
committer | Micky <micheledevita2@gmail.com> | 2024-03-01 15:12:52 +0100 |
commit | 7b3e1a5bde17eb058eba1ab70000b4474fa0aa8f (patch) | |
tree | 244ced4465db036cfb89afbdf0d0e53be59064f2 /scene/main/scene_tree.cpp | |
parent | 8e951fd0a92c551f260c3272039181be32121a32 (diff) | |
download | redot-engine-7b3e1a5bde17eb058eba1ab70000b4474fa0aa8f.tar.gz |
Optimize SceneTree's `change_scene_to_file` autocompletion
Diffstat (limited to 'scene/main/scene_tree.cpp')
-rw-r--r-- | scene/main/scene_tree.cpp | 49 |
1 files changed, 10 insertions, 39 deletions
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index ac6ff30de0..cb16f425b5 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -1693,45 +1693,16 @@ void SceneTree::add_idle_callback(IdleCallback p_callback) { #ifdef TOOLS_ENABLED void SceneTree::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const { const String pf = p_function; - if (pf == "change_scene_to_file") { - Ref<DirAccess> dir_access = DirAccess::create(DirAccess::ACCESS_RESOURCES); - List<String> directories; - directories.push_back(dir_access->get_current_dir()); - - while (!directories.is_empty()) { - dir_access->change_dir(directories.back()->get()); - directories.pop_back(); - - dir_access->list_dir_begin(); - String filename = dir_access->get_next(); - - while (!filename.is_empty()) { - if (filename == "." || filename == "..") { - filename = dir_access->get_next(); - continue; - } - - if (dir_access->dir_exists(filename)) { - directories.push_back(dir_access->get_current_dir().path_join(filename)); - } else if (filename.ends_with(".tscn") || filename.ends_with(".scn")) { - r_options->push_back("\"" + dir_access->get_current_dir().path_join(filename) + "\""); - } - - filename = dir_access->get_next(); - } - } - } else { - bool add_options = false; - if (p_idx == 0) { - add_options = pf == "get_nodes_in_group" || pf == "has_group" || pf == "get_first_node_in_group" || pf == "set_group" || pf == "notify_group" || pf == "call_group" || pf == "add_to_group"; - } else if (p_idx == 1) { - add_options = pf == "set_group_flags" || pf == "call_group_flags" || pf == "notify_group_flags"; - } - if (add_options) { - HashMap<StringName, String> global_groups = ProjectSettings::get_singleton()->get_global_groups_list(); - for (const KeyValue<StringName, String> &E : global_groups) { - r_options->push_back(E.key.operator String().quote()); - } + bool add_options = false; + if (p_idx == 0) { + add_options = pf == "get_nodes_in_group" || pf == "has_group" || pf == "get_first_node_in_group" || pf == "set_group" || pf == "notify_group" || pf == "call_group" || pf == "add_to_group"; + } else if (p_idx == 1) { + add_options = pf == "set_group_flags" || pf == "call_group_flags" || pf == "notify_group_flags"; + } + if (add_options) { + HashMap<StringName, String> global_groups = ProjectSettings::get_singleton()->get_global_groups_list(); + for (const KeyValue<StringName, String> &E : global_groups) { + r_options->push_back(E.key.operator String().quote()); } } MainLoop::get_argument_options(p_function, p_idx, r_options); |