Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add autocompletion for a few EditorInterface methods #86893

Merged

Conversation

Mickeon
Copy link
Contributor

@Mickeon Mickeon commented Jan 6, 2024

Related to #86753, #86747, #86758, #86764, #86777, and #86798

This PR adds autocompletion for get_editor_viewport_3d and set_main_screen_editor.

This originally started with the intention of adding autocompleted results to way more of these, but I had to ditch the idea for now. A lot of the remaining ones require file paths, and it would be nice to find good method to use everywhere, without iterating over entire folders every time.

I originally copied and pasted the implementation in SceneTree for change_scene_to_file, but the way this is is done is EXTREMELY inefficient and would lead to plenty of duplicated code.

void SceneTree::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const {
if (p_function == "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();
}
}

@Mickeon Mickeon force-pushed the autocomplete-editor-interface branch 2 times, most recently from 4eb7ccc to acebec6 Compare January 6, 2024 17:29
@AThousandShips AThousandShips added this to the 4.3 milestone Jan 6, 2024
@Mickeon Mickeon force-pushed the autocomplete-editor-interface branch from acebec6 to db10ce3 Compare January 6, 2024 18:19
Copy link
Member

@AThousandShips AThousandShips left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@akien-mga akien-mga merged commit edcea4a into godotengine:master Jan 8, 2024
15 checks passed
@Mickeon Mickeon deleted the autocomplete-editor-interface branch January 8, 2024 11:14
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants