diff options
Diffstat (limited to 'scene')
-rw-r--r-- | scene/gui/text_edit.cpp | 3 | ||||
-rw-r--r-- | scene/main/scene_tree.cpp | 33 | ||||
-rw-r--r-- | scene/main/scene_tree.h | 1 |
3 files changed, 37 insertions, 0 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 736e546ed8..0464cc1ac8 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -5365,6 +5365,9 @@ bool TextEdit::search(const String &p_key, uint32_t p_search_flags, int p_from_l break; } pos_from = last_pos - p_key.length(); + if (pos_from < 0) { + break; + } } } else { while ((last_pos = (p_search_flags & SEARCH_MATCH_CASE) ? text_line.find(p_key, pos_from) : text_line.findn(p_key, pos_from)) != -1) { diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index 617a703855..6c89016ea3 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -33,6 +33,7 @@ #include "core/io/marshalls.h" #include "core/io/resource_loader.h" #include "core/message_queue.h" +#include "core/os/dir_access.h" #include "core/os/keyboard.h" #include "core/os/os.h" #include "core/print_string.h" @@ -1953,6 +1954,38 @@ bool SceneTree::is_using_font_oversampling() const { return use_font_oversampling; } +void SceneTree::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const { + + if (p_function == "change_scene") { + DirAccessRef dir_access = DirAccess::create(DirAccess::ACCESS_RESOURCES); + List<String> directories; + directories.push_back(dir_access->get_current_dir()); + + while (!directories.empty()) { + dir_access->change_dir(directories.back()->get()); + directories.pop_back(); + + dir_access->list_dir_begin(); + String filename = dir_access->get_next(); + + while (filename != "") { + if (filename == "." || filename == "..") { + filename = dir_access->get_next(); + continue; + } + + if (dir_access->dir_exists(filename)) { + directories.push_back(dir_access->get_current_dir().plus_file(filename)); + } else if (filename.ends_with(".tscn") || filename.ends_with(".scn")) { + r_options->push_back("\"" + dir_access->get_current_dir().plus_file(filename) + "\""); + } + + filename = dir_access->get_next(); + } + } + } +} + SceneTree::SceneTree() { if (singleton == NULL) singleton = this; diff --git a/scene/main/scene_tree.h b/scene/main/scene_tree.h index 42a87545a6..d387886d61 100644 --- a/scene/main/scene_tree.h +++ b/scene/main/scene_tree.h @@ -408,6 +408,7 @@ public: void drop_files(const Vector<String> &p_files, int p_from_screen = 0); void global_menu_action(const Variant &p_id, const Variant &p_meta); + void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const; //network API |