feat: modules moved and engine moved to submodule

This commit is contained in:
Jan van der Weide 2025-04-12 18:40:44 +02:00
parent dfb5e645cd
commit c33d2130cc
5136 changed files with 225275 additions and 64485 deletions

View file

@ -49,6 +49,10 @@
#include "scene/gui/texture_rect.h"
#include "scene/resources/image_texture.h"
const char *ProjectList::SIGNAL_LIST_CHANGED = "list_changed";
const char *ProjectList::SIGNAL_SELECTION_CHANGED = "selection_changed";
const char *ProjectList::SIGNAL_PROJECT_ASK_OPEN = "project_ask_open";
void ProjectListItemControl::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_THEME_CHANGED: {
@ -68,21 +72,60 @@ void ProjectListItemControl::_notification(int p_what) {
project_unsupported_features->set_texture(get_editor_theme_icon(SNAME("NodeWarning")));
favorite_button->set_texture_normal(get_editor_theme_icon(SNAME("Favorites")));
if (project_is_missing) {
explore_button->set_button_icon(get_editor_theme_icon(SNAME("FileBroken")));
#if !defined(ANDROID_ENABLED) && !defined(WEB_ENABLED)
} else {
explore_button->set_button_icon(get_editor_theme_icon(SNAME("Load")));
#endif
}
} break;
case NOTIFICATION_MOUSE_ENTER: {
is_hovering = true;
queue_redraw();
queue_accessibility_update();
} break;
case NOTIFICATION_MOUSE_EXIT: {
is_hovering = false;
queue_redraw();
queue_accessibility_update();
} break;
case NOTIFICATION_ACCESSIBILITY_UPDATE: {
RID ae = get_accessibility_element();
ERR_FAIL_COND(ae.is_null());
DisplayServer::get_singleton()->accessibility_update_set_role(ae, DisplayServer::AccessibilityRole::ROLE_LIST_BOX_OPTION);
DisplayServer::get_singleton()->accessibility_update_set_name(ae, TTR("Project") + " " + project_title->get_text());
DisplayServer::get_singleton()->accessibility_update_set_value(ae, project_title->get_text());
DisplayServer::get_singleton()->accessibility_update_add_action(ae, DisplayServer::AccessibilityAction::ACTION_CLICK, callable_mp(this, &ProjectListItemControl::_accessibility_action_open));
DisplayServer::get_singleton()->accessibility_update_add_action(ae, DisplayServer::AccessibilityAction::ACTION_SCROLL_INTO_VIEW, callable_mp(this, &ProjectListItemControl::_accessibility_action_scroll_into_view));
DisplayServer::get_singleton()->accessibility_update_add_action(ae, DisplayServer::AccessibilityAction::ACTION_FOCUS, callable_mp(this, &ProjectListItemControl::_accessibility_action_focus));
DisplayServer::get_singleton()->accessibility_update_add_action(ae, DisplayServer::AccessibilityAction::ACTION_BLUR, callable_mp(this, &ProjectListItemControl::_accessibility_action_blur));
ProjectList *pl = get_list();
if (pl) {
DisplayServer::get_singleton()->accessibility_update_set_list_item_index(ae, pl->get_index(this));
}
DisplayServer::get_singleton()->accessibility_update_set_list_item_level(ae, 0);
DisplayServer::get_singleton()->accessibility_update_set_list_item_selected(ae, is_selected);
} break;
case NOTIFICATION_FOCUS_ENTER: {
ProjectList *pl = get_list();
if (pl) {
int idx = pl->get_index(this);
if (idx >= 0) {
pl->ensure_project_visible(idx);
pl->select_project(idx);
pl->emit_signal(SNAME(ProjectList::SIGNAL_SELECTION_CHANGED));
}
}
} break;
case NOTIFICATION_DRAW: {
@ -98,6 +141,53 @@ void ProjectListItemControl::_notification(int p_what) {
}
}
ProjectList *ProjectListItemControl::get_list() const {
if (!is_inside_tree()) {
return nullptr;
}
ProjectList *pl = Object::cast_to<ProjectList>(get_parent()->get_parent());
return pl;
}
void ProjectListItemControl::_accessibility_action_scroll_into_view(const Variant &p_data) {
ProjectList *pl = get_list();
if (pl) {
int idx = pl->get_index(this);
if (idx >= 0) {
pl->ensure_project_visible(idx);
}
}
}
void ProjectListItemControl::_accessibility_action_open(const Variant &p_data) {
ProjectList *pl = get_list();
if (pl && !pl->project_opening_initiated) {
pl->emit_signal(SNAME(ProjectList::SIGNAL_PROJECT_ASK_OPEN));
}
}
void ProjectListItemControl::_accessibility_action_focus(const Variant &p_data) {
ProjectList *pl = get_list();
if (pl) {
int idx = pl->get_index(this);
if (idx >= 0) {
pl->ensure_project_visible(idx);
pl->select_project(idx);
}
}
}
void ProjectListItemControl::_accessibility_action_blur(const Variant &p_data) {
ProjectList *pl = get_list();
if (pl) {
int idx = pl->get_index(this);
if (idx >= 0) {
pl->ensure_project_visible(idx);
pl->deselect_project(idx);
}
}
}
void ProjectListItemControl::_favorite_button_pressed() {
emit_signal(SNAME("favorite_pressed"));
}
@ -108,10 +198,14 @@ void ProjectListItemControl::_explore_button_pressed() {
void ProjectListItemControl::set_project_title(const String &p_title) {
project_title->set_text(p_title);
project_title->set_accessibility_name(TTRC("Project Name"));
queue_accessibility_update();
}
void ProjectListItemControl::set_project_path(const String &p_path) {
project_path->set_text(p_path);
project_path->set_accessibility_name(TTRC("Project Path"));
queue_accessibility_update();
}
void ProjectListItemControl::set_tags(const PackedStringArray &p_tags, ProjectList *p_parent_list) {
@ -153,7 +247,7 @@ void ProjectListItemControl::set_unsupported_features(PackedStringArray p_featur
project_version_major = project_version_split[0].to_int();
project_version_minor = project_version_split[1].to_int();
}
if (VERSION_MAJOR != project_version_major || VERSION_MINOR <= project_version_minor) {
if (GODOT_VERSION_MAJOR != project_version_major || GODOT_VERSION_MINOR <= project_version_minor) {
// Don't show a warning if the project was last edited in a previous minor version.
tooltip_text += TTR("This project was last edited in a different Godot version: ") + p_features[i] + "\n";
}
@ -169,6 +263,8 @@ void ProjectListItemControl::set_unsupported_features(PackedStringArray p_featur
return;
}
project_version->set_tooltip_text(tooltip_text);
project_unsupported_features->set_focus_mode(FOCUS_ACCESSIBILITY);
project_unsupported_features->set_accessibility_name(tooltip_text);
project_unsupported_features->set_tooltip_text(tooltip_text);
project_unsupported_features->show();
} else {
@ -183,6 +279,7 @@ bool ProjectListItemControl::should_load_project_icon() const {
void ProjectListItemControl::set_selected(bool p_selected) {
is_selected = p_selected;
queue_redraw();
queue_accessibility_update();
}
void ProjectListItemControl::set_is_favorite(bool p_favorite) {
@ -190,9 +287,6 @@ void ProjectListItemControl::set_is_favorite(bool p_favorite) {
}
void ProjectListItemControl::set_is_missing(bool p_missing) {
if (project_is_missing == p_missing) {
return;
}
project_is_missing = p_missing;
if (project_is_missing) {
@ -201,10 +295,8 @@ void ProjectListItemControl::set_is_missing(bool p_missing) {
explore_button->set_button_icon(get_editor_theme_icon(SNAME("FileBroken")));
explore_button->set_tooltip_text(TTR("Error: Project is missing on the filesystem."));
} else {
project_icon->set_modulate(Color(1, 1, 1, 1.0));
explore_button->set_button_icon(get_editor_theme_icon(SNAME("Load")));
#if !defined(ANDROID_ENABLED) && !defined(WEB_ENABLED)
explore_button->set_button_icon(get_editor_theme_icon(SNAME("Load")));
explore_button->set_tooltip_text(TTR("Show in File Manager"));
#else
// Opening the system file manager is not supported on the Android and web editors.
@ -238,6 +330,8 @@ ProjectListItemControl::ProjectListItemControl() {
favorite_button = memnew(TextureButton);
favorite_button->set_name("FavoriteButton");
favorite_button->set_tooltip_text(TTR("Add to favorites"));
favorite_button->set_accessibility_name(TTRC("Add to favorites"));
// This makes the project's "hover" style display correctly when hovering the favorite icon.
favorite_button->set_mouse_filter(MOUSE_FILTER_PASS);
favorite_box->add_child(favorite_button);
@ -285,6 +379,8 @@ ProjectListItemControl::ProjectListItemControl() {
explore_button = memnew(Button);
explore_button->set_name("ExploreButton");
explore_button->set_tooltip_text(TTR("Open in file manager"));
explore_button->set_accessibility_name(TTRC("Open in file manager"));
explore_button->set_flat(true);
path_hb->add_child(explore_button);
explore_button->connect(SceneStringName(pressed), callable_mp(this, &ProjectListItemControl::_explore_button_pressed));
@ -345,10 +441,6 @@ struct ProjectListComparator {
}
};
const char *ProjectList::SIGNAL_LIST_CHANGED = "list_changed";
const char *ProjectList::SIGNAL_SELECTION_CHANGED = "selection_changed";
const char *ProjectList::SIGNAL_PROJECT_ASK_OPEN = "project_ask_open";
// Helpers.
bool ProjectList::project_feature_looks_like_version(const String &p_feature) {
@ -378,6 +470,15 @@ void ProjectList::_notification(int p_what) {
}
}
} break;
case NOTIFICATION_ACCESSIBILITY_UPDATE: {
RID ae = get_accessibility_element();
ERR_FAIL_COND(ae.is_null());
DisplayServer::get_singleton()->accessibility_update_set_role(ae, DisplayServer::AccessibilityRole::ROLE_LIST_BOX);
DisplayServer::get_singleton()->accessibility_update_set_list_item_count(ae, _projects.size());
DisplayServer::get_singleton()->accessibility_update_set_flag(ae, DisplayServer::AccessibilityFlags::FLAG_MULTISELECTABLE, false);
}
}
}
@ -446,7 +547,7 @@ void ProjectList::_migrate_config() {
String path = EDITOR_GET(property_key);
print_line("Migrating legacy project '" + path + "'.");
String favoriteKey = "favorite_projects/" + property_key.get_slice("/", 1);
String favoriteKey = "favorite_projects/" + property_key.get_slicec('/', 1);
bool favorite = EditorSettings::get_singleton()->has_setting(favoriteKey);
add_project(path, favorite);
if (favorite) {
@ -637,6 +738,7 @@ void ProjectList::update_project_list() {
set_v_scroll(0);
emit_signal(SNAME(SIGNAL_LIST_CHANGED));
queue_accessibility_update();
}
void ProjectList::sort_projects() {
@ -653,7 +755,7 @@ void ProjectList::sort_projects() {
PackedStringArray remaining;
for (const String &part : search_parts) {
if (part.begins_with("tag:")) {
tags.push_back(part.get_slice(":", 1));
tags.push_back(part.get_slicec(':', 1));
} else {
remaining.append(part);
}
@ -701,6 +803,7 @@ void ProjectList::sort_projects() {
// Rewind the coroutine because order of projects changed
_update_icons_async();
update_dock_menu();
queue_accessibility_update();
}
int ProjectList::get_project_count() const {
@ -791,6 +894,7 @@ void ProjectList::add_project(const String &dir_path, bool favorite) {
if (!_config.has_section(dir_path)) {
_config.set_value(dir_path, "favorite", favorite);
}
queue_accessibility_update();
}
void ProjectList::set_project_version(const String &p_project_path, int p_version) {
@ -850,6 +954,15 @@ int ProjectList::refresh_project(const String &dir_path) {
return index;
}
int ProjectList::get_index(const ProjectListItemControl *p_control) const {
for (int i = 0; i < _projects.size(); ++i) {
if (_projects[i].control == p_control) {
return i;
}
}
return -1;
}
void ProjectList::ensure_project_visible(int p_index) {
const Item &item = _projects[p_index];
ensure_control_visible(item.control);
@ -917,6 +1030,7 @@ void ProjectList::_remove_project(int p_index, bool p_update_config) {
// Not actually saving the file, in case you are doing more changes to settings
}
queue_accessibility_update();
update_dock_menu();
}
@ -998,18 +1112,21 @@ void ProjectList::_clear_project_selection() {
for (int i = 0; i < previous_selected_items.size(); ++i) {
previous_selected_items[i].control->set_selected(false);
}
queue_accessibility_update();
}
void ProjectList::_select_project_nocheck(int p_index) {
Item &item = _projects.write[p_index];
_selected_project_paths.insert(item.path);
item.control->set_selected(true);
queue_accessibility_update();
}
void ProjectList::_deselect_project_nocheck(int p_index) {
Item &item = _projects.write[p_index];
_selected_project_paths.erase(item.path);
item.control->set_selected(false);
queue_accessibility_update();
}
inline void _sort_project_range(int &a, int &b) {
@ -1035,6 +1152,10 @@ void ProjectList::select_project(int p_index) {
_select_project_nocheck(p_index);
}
void ProjectList::deselect_project(int p_index) {
_deselect_project_nocheck(p_index);
}
void ProjectList::select_first_visible_project() {
_clear_project_selection();
@ -1048,7 +1169,7 @@ void ProjectList::select_first_visible_project() {
Vector<ProjectList::Item> ProjectList::get_selected_projects() const {
Vector<Item> items;
if (_selected_project_paths.size() == 0) {
if (_selected_project_paths.is_empty()) {
return items;
}
items.resize(_selected_project_paths.size());
@ -1069,7 +1190,7 @@ const HashSet<String> &ProjectList::get_selected_project_keys() const {
}
int ProjectList::get_single_selected_index() const {
if (_selected_project_paths.size() == 0) {
if (_selected_project_paths.is_empty()) {
// Default selection
return 0;
}
@ -1090,7 +1211,7 @@ int ProjectList::get_single_selected_index() const {
}
void ProjectList::erase_selected_projects(bool p_delete_project_contents) {
if (_selected_project_paths.size() == 0) {
if (_selected_project_paths.is_empty()) {
return;
}