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

@ -43,14 +43,87 @@
#include "scene/resources/packed_scene.h"
#include "viewport.h"
#include <stdint.h>
int Node::orphan_node_count = 0;
thread_local Node *Node::current_process_thread_group = nullptr;
void Node::_notification(int p_notification) {
switch (p_notification) {
case NOTIFICATION_ACCESSIBILITY_INVALIDATE: {
if (data.accessibility_element.is_valid()) {
DisplayServer::get_singleton()->accessibility_free_element(data.accessibility_element);
data.accessibility_element = RID();
}
} break;
case NOTIFICATION_ACCESSIBILITY_UPDATE: {
RID ae = get_accessibility_element();
ERR_FAIL_COND(ae.is_null());
// Base info.
if (data.parent) {
String container_info = data.parent->get_accessibility_container_name(this);
DisplayServer::get_singleton()->accessibility_update_set_name(ae, container_info.is_empty() ? get_accessibility_name() : get_accessibility_name() + " " + container_info);
} else {
DisplayServer::get_singleton()->accessibility_update_set_name(ae, get_accessibility_name());
}
DisplayServer::get_singleton()->accessibility_update_set_description(ae, get_accessibility_description());
DisplayServer::get_singleton()->accessibility_update_set_live(ae, get_accessibility_live());
// Related nodes.
for (int i = 0; i < data.accessibility_controls_nodes.size(); i++) {
const NodePath &np = data.accessibility_controls_nodes[i];
if (!np.is_empty()) {
Node *n = get_node(np);
if (n && !n->is_part_of_edited_scene()) {
DisplayServer::get_singleton()->accessibility_update_add_related_controls(ae, n->get_accessibility_element());
}
}
}
for (int i = 0; i < data.accessibility_described_by_nodes.size(); i++) {
const NodePath &np = data.accessibility_described_by_nodes[i];
if (!np.is_empty()) {
Node *n = get_node(np);
if (n && !n->is_part_of_edited_scene()) {
DisplayServer::get_singleton()->accessibility_update_add_related_described_by(ae, n->get_accessibility_element());
}
}
}
for (int i = 0; i < data.accessibility_labeled_by_nodes.size(); i++) {
const NodePath &np = data.accessibility_labeled_by_nodes[i];
if (!np.is_empty()) {
Node *n = get_node(np);
if (n && !n->is_part_of_edited_scene()) {
DisplayServer::get_singleton()->accessibility_update_add_related_labeled_by(ae, n->get_accessibility_element());
}
}
}
for (int i = 0; i < data.accessibility_flow_to_nodes.size(); i++) {
const NodePath &np = data.accessibility_flow_to_nodes[i];
if (!np.is_empty()) {
Node *n = get_node(np);
if (n && !n->is_part_of_edited_scene()) {
DisplayServer::get_singleton()->accessibility_update_add_related_flow_to(ae, n->get_accessibility_element());
}
}
}
// Node children.
if (!accessibility_override_tree_hierarchy()) {
for (int i = 0; i < get_child_count(); i++) {
Node *child_node = get_child(i);
Window *child_wnd = Object::cast_to<Window>(child_node);
if (child_wnd && !child_wnd->is_embedded()) {
continue;
}
if (child_node->is_part_of_edited_scene()) {
continue;
}
DisplayServer::get_singleton()->accessibility_update_add_child(ae, child_node->get_accessibility_element());
}
}
} break;
case NOTIFICATION_PROCESS: {
GDVIRTUAL_CALL(_process, get_process_delta_time());
} break;
@ -63,6 +136,16 @@ void Node::_notification(int p_notification) {
ERR_FAIL_NULL(get_viewport());
ERR_FAIL_NULL(get_tree());
if (get_tree()->is_accessibility_supported() && !is_part_of_edited_scene()) {
get_tree()->_accessibility_force_update();
get_tree()->_accessibility_notify_change(this);
if (data.parent) {
get_tree()->_accessibility_notify_change(data.parent);
} else {
get_tree()->_accessibility_notify_change(get_window()); // Root node.
}
}
// Update process mode.
if (data.process_mode == PROCESS_MODE_INHERIT) {
if (data.parent) {
@ -153,6 +236,19 @@ void Node::_notification(int p_notification) {
ERR_FAIL_NULL(get_viewport());
ERR_FAIL_NULL(get_tree());
if (get_tree()->is_accessibility_supported() && !is_part_of_edited_scene()) {
if (data.accessibility_element.is_valid()) {
DisplayServer::get_singleton()->accessibility_free_element(data.accessibility_element);
data.accessibility_element = RID();
}
get_tree()->_accessibility_notify_change(this, true);
if (data.parent) {
get_tree()->_accessibility_notify_change(data.parent);
} else {
get_tree()->_accessibility_notify_change(get_window()); // Root node.
}
}
get_tree()->nodes_in_tree_count--;
orphan_node_count++;
@ -227,10 +323,6 @@ void Node::_notification(int p_notification) {
GDVIRTUAL_CALL(_ready);
} break;
case NOTIFICATION_POSTINITIALIZE: {
data.in_constructor = false;
} break;
case NOTIFICATION_PREDELETE: {
if (data.inside_tree && !Thread::is_main_thread()) {
cancel_free();
@ -1378,7 +1470,95 @@ void Node::_propagate_translation_domain_dirty() {
child->_propagate_translation_domain_dirty();
}
}
notification(NOTIFICATION_TRANSLATION_CHANGED);
if (is_inside_tree() && data.auto_translate_mode != AUTO_TRANSLATE_MODE_DISABLED) {
notification(NOTIFICATION_TRANSLATION_CHANGED);
}
}
void Node::set_accessibility_name(const String &p_name) {
ERR_THREAD_GUARD
if (data.accessibility_name != p_name) {
data.accessibility_name = p_name;
queue_accessibility_update();
update_configuration_warnings();
}
}
String Node::get_accessibility_name() const {
return atr(data.accessibility_name);
}
void Node::set_accessibility_description(const String &p_description) {
ERR_THREAD_GUARD
if (data.accessibility_description != p_description) {
data.accessibility_description = p_description;
queue_accessibility_update();
}
}
String Node::get_accessibility_description() const {
return atr(data.accessibility_description);
}
void Node::set_accessibility_live(DisplayServer::AccessibilityLiveMode p_mode) {
ERR_THREAD_GUARD
if (data.accessibility_live != p_mode) {
data.accessibility_live = p_mode;
queue_accessibility_update();
}
}
DisplayServer::AccessibilityLiveMode Node::get_accessibility_live() const {
return data.accessibility_live;
}
void Node::set_accessibility_controls_nodes(const TypedArray<NodePath> &p_node_path) {
ERR_THREAD_GUARD
if (data.accessibility_controls_nodes != p_node_path) {
data.accessibility_controls_nodes = p_node_path;
queue_accessibility_update();
}
}
TypedArray<NodePath> Node::get_accessibility_controls_nodes() const {
return data.accessibility_controls_nodes;
}
void Node::set_accessibility_described_by_nodes(const TypedArray<NodePath> &p_node_path) {
ERR_THREAD_GUARD
if (data.accessibility_described_by_nodes != p_node_path) {
data.accessibility_described_by_nodes = p_node_path;
queue_accessibility_update();
}
}
TypedArray<NodePath> Node::get_accessibility_described_by_nodes() const {
return data.accessibility_described_by_nodes;
}
void Node::set_accessibility_labeled_by_nodes(const TypedArray<NodePath> &p_node_path) {
ERR_THREAD_GUARD
if (data.accessibility_labeled_by_nodes != p_node_path) {
data.accessibility_labeled_by_nodes = p_node_path;
queue_accessibility_update();
}
}
TypedArray<NodePath> Node::get_accessibility_labeled_by_nodes() const {
return data.accessibility_labeled_by_nodes;
}
void Node::set_accessibility_flow_to_nodes(const TypedArray<NodePath> &p_node_path) {
ERR_THREAD_GUARD
if (data.accessibility_flow_to_nodes != p_node_path) {
data.accessibility_flow_to_nodes = p_node_path;
queue_accessibility_update();
}
}
TypedArray<NodePath> Node::get_accessibility_flow_to_nodes() const {
return data.accessibility_flow_to_nodes;
}
StringName Node::get_name() const {
@ -1461,6 +1641,8 @@ String Node::adjust_name_casing(const String &p_name) {
return p_name.to_camel_case();
case NAME_CASING_SNAKE_CASE:
return p_name.to_snake_case();
case NAME_CASING_KEBAB_CASE:
return p_name.to_kebab_case();
}
return p_name;
}
@ -1637,8 +1819,6 @@ void Node::_add_child_nocheck(Node *p_child, const StringName &p_name, InternalM
}
/* Notify */
//recognize children created in this node constructor
p_child->data.parent_owned = data.in_constructor;
add_child_notify(p_child);
notification(NOTIFICATION_CHILD_ORDER_CHANGED);
emit_signal(SNAME("child_order_changed"));
@ -1698,7 +1878,6 @@ void Node::remove_child(Node *p_child) {
data.blocked++;
p_child->_set_tree(nullptr);
//}
remove_child_notify(p_child);
p_child->notification(NOTIFICATION_UNPARENTED);
@ -1957,6 +2136,7 @@ void Node::reparent(Node *p_parent, bool p_keep_global_transform) {
ERR_THREAD_GUARD
ERR_FAIL_NULL(p_parent);
ERR_FAIL_NULL_MSG(data.parent, "Node needs a parent to be reparented.");
ERR_FAIL_COND_MSG(p_parent == this, vformat("Can't reparent '%s' to itself.", p_parent->get_name()));
if (p_parent == data.parent) {
return;
@ -2683,11 +2863,11 @@ bool Node::is_part_of_edited_scene() const {
void Node::get_storable_properties(HashSet<StringName> &r_storable_properties) const {
ERR_THREAD_GUARD
List<PropertyInfo> pi;
get_property_list(&pi);
for (List<PropertyInfo>::Element *E = pi.front(); E; E = E->next()) {
if ((E->get().usage & PROPERTY_USAGE_STORAGE)) {
r_storable_properties.insert(E->get().name);
List<PropertyInfo> property_list;
get_property_list(&property_list);
for (const PropertyInfo &pi : property_list) {
if ((pi.usage & PROPERTY_USAGE_STORAGE)) {
r_storable_properties.insert(pi.name);
}
}
}
@ -2792,12 +2972,8 @@ Node *Node::_duplicate(int p_flags, HashMap<const Node *, Node *> *r_duplimap) c
instance_roots.push_back(this);
for (List<const Node *>::Element *N = node_tree.front(); N; N = N->next()) {
for (int i = 0; i < N->get()->get_child_count(); ++i) {
Node *descendant = N->get()->get_child(i);
if (!descendant->get_owner()) {
continue; // Internal nodes or nodes added by scripts.
}
for (int i = 0; i < N->get()->get_child_count(false); ++i) {
Node *descendant = N->get()->get_child(i, false);
// Skip nodes not really belonging to the instantiated hierarchy; they'll be processed normally later
// but remember non-instantiated nodes that are hidden below instantiated ones
@ -2841,10 +3017,7 @@ Node *Node::_duplicate(int p_flags, HashMap<const Node *, Node *> *r_duplimap) c
}
}
for (int i = 0; i < get_child_count(); i++) {
if (get_child(i)->data.parent_owned) {
continue;
}
for (int i = 0; i < get_child_count(false); i++) {
if (instantiated && get_child(i)->data.owner == this) {
continue; //part of instance
}
@ -3038,10 +3211,10 @@ void Node::_duplicate_properties(const Node *p_root, const Node *p_original, Nod
}
}
for (int i = 0; i < p_original->get_child_count(); i++) {
Node *copy_child = p_copy->get_child(i);
for (int i = 0; i < p_original->get_child_count(false); i++) {
Node *copy_child = p_copy->get_child(i, false);
ERR_FAIL_NULL_MSG(copy_child, "Child node disappeared while duplicating.");
_duplicate_properties(p_root, p_original->get_child(i), copy_child, p_flags);
_duplicate_properties(p_root, p_original->get_child(i, false), copy_child, p_flags);
}
}
@ -3072,7 +3245,11 @@ void Node::_duplicate_signals(const Node *p_original, Node *p_copy) const {
if (!target) {
continue;
}
NodePath ptarget = p_original->get_path_to(target);
if (ptarget.is_empty()) {
continue;
}
Node *copytarget = target;
@ -3158,8 +3335,8 @@ void Node::replace_by(Node *p_node, bool p_keep_groups) {
while (get_child_count()) {
Node *child = get_child(0);
remove_child(child);
if (!child->is_owned_by_parent()) {
// add the custom children to the p_node
if (!child->is_internal()) {
// Add the custom children to the p_node.
Node *child_owner = child->get_owner() == this ? p_node : child->get_owner();
child->set_owner(nullptr);
p_node->add_child(child);
@ -3413,6 +3590,18 @@ void Node::clear_internal_tree_resource_paths() {
}
}
PackedStringArray Node::get_accessibility_configuration_warnings() const {
ERR_THREAD_GUARD_V(PackedStringArray());
PackedStringArray ret;
Vector<String> warnings;
if (GDVIRTUAL_CALL(_get_accessibility_configuration_warnings, warnings)) {
ret.append_array(warnings);
}
return ret;
}
PackedStringArray Node::get_configuration_warnings() const {
ERR_THREAD_GUARD_V(PackedStringArray());
PackedStringArray ret;
@ -3437,10 +3626,6 @@ void Node::update_configuration_warnings() {
#endif
}
bool Node::is_owned_by_parent() const {
return data.parent_owned;
}
void Node::set_display_folded(bool p_folded) {
ERR_THREAD_GUARD
data.display_folded = p_folded;
@ -3568,11 +3753,13 @@ void Node::call_deferred_thread_groupp(const StringName &p_method, const Variant
SceneTree::ProcessGroup *pg = (SceneTree::ProcessGroup *)data.process_group;
pg->call_queue.push_callp(this, p_method, p_args, p_argcount, p_show_error);
}
void Node::set_deferred_thread_group(const StringName &p_property, const Variant &p_value) {
ERR_FAIL_COND(!is_inside_tree());
SceneTree::ProcessGroup *pg = (SceneTree::ProcessGroup *)data.process_group;
pg->call_queue.push_set(this, p_property, p_value);
}
void Node::notify_deferred_thread_group(int p_notification) {
ERR_FAIL_COND(!is_inside_tree());
SceneTree::ProcessGroup *pg = (SceneTree::ProcessGroup *)data.process_group;
@ -3590,6 +3777,7 @@ void Node::call_thread_safep(const StringName &p_method, const Variant **p_args,
call_deferred_thread_groupp(p_method, p_args, p_argcount, p_show_error);
}
}
void Node::set_thread_safe(const StringName &p_property, const Variant &p_value) {
if (is_accessible_from_caller_thread()) {
set(p_property, p_value);
@ -3597,6 +3785,7 @@ void Node::set_thread_safe(const StringName &p_property, const Variant &p_value)
set_deferred_thread_group(p_property, p_value);
}
}
void Node::notify_thread_safe(int p_notification) {
if (is_accessible_from_caller_thread()) {
notification(p_notification);
@ -3605,9 +3794,45 @@ void Node::notify_thread_safe(int p_notification) {
}
}
RID Node::get_focused_accessibility_element() const {
RID id;
if (GDVIRTUAL_CALL(_get_focused_accessibility_element, id)) {
return id;
} else {
return get_accessibility_element();
}
}
String Node::get_accessibility_container_name(const Node *p_node) const {
String ret;
if (GDVIRTUAL_CALL(_get_accessibility_container_name, p_node, ret)) {
} else if (data.parent) {
ret = data.parent->get_accessibility_container_name(this);
}
return ret;
}
void Node::queue_accessibility_update() {
if (is_inside_tree() && !is_part_of_edited_scene()) {
get_tree()->_accessibility_notify_change(this);
}
}
RID Node::get_accessibility_element() const {
if (is_part_of_edited_scene()) {
return RID();
}
if (unlikely(data.accessibility_element.is_null())) {
if (get_window() && get_window()->get_window_id() != DisplayServer::INVALID_WINDOW_ID) {
data.accessibility_element = DisplayServer::get_singleton()->accessibility_create_element(get_window()->get_window_id(), DisplayServer::ROLE_CONTAINER);
}
}
return data.accessibility_element;
}
void Node::_bind_methods() {
GLOBAL_DEF(PropertyInfo(Variant::INT, "editor/naming/node_name_num_separator", PROPERTY_HINT_ENUM, "None,Space,Underscore,Dash"), 0);
GLOBAL_DEF(PropertyInfo(Variant::INT, "editor/naming/node_name_casing", PROPERTY_HINT_ENUM, "PascalCase,camelCase,snake_case"), NAME_CASING_PASCAL_CASE);
GLOBAL_DEF(PropertyInfo(Variant::INT, "editor/naming/node_name_casing", PROPERTY_HINT_ENUM, "PascalCase,camelCase,snake_case,kebab-case"), NAME_CASING_PASCAL_CASE);
ClassDB::bind_static_method("Node", D_METHOD("print_orphan_nodes"), &Node::print_orphan_nodes);
ClassDB::bind_method(D_METHOD("add_sibling", "sibling", "force_readable_name"), &Node::add_sibling, DEFVAL(false));
@ -3683,6 +3908,24 @@ void Node::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_process_thread_group_order", "order"), &Node::set_process_thread_group_order);
ClassDB::bind_method(D_METHOD("get_process_thread_group_order"), &Node::get_process_thread_group_order);
ClassDB::bind_method(D_METHOD("set_accessibility_name", "name"), &Node::set_accessibility_name);
ClassDB::bind_method(D_METHOD("get_accessibility_name"), &Node::get_accessibility_name);
ClassDB::bind_method(D_METHOD("set_accessibility_description", "description"), &Node::set_accessibility_description);
ClassDB::bind_method(D_METHOD("get_accessibility_description"), &Node::get_accessibility_description);
ClassDB::bind_method(D_METHOD("set_accessibility_live", "mode"), &Node::set_accessibility_live);
ClassDB::bind_method(D_METHOD("get_accessibility_live"), &Node::get_accessibility_live);
ClassDB::bind_method(D_METHOD("set_accessibility_controls_nodes", "node_path"), &Node::set_accessibility_controls_nodes);
ClassDB::bind_method(D_METHOD("get_accessibility_controls_nodes"), &Node::get_accessibility_controls_nodes);
ClassDB::bind_method(D_METHOD("set_accessibility_described_by_nodes", "node_path"), &Node::set_accessibility_described_by_nodes);
ClassDB::bind_method(D_METHOD("get_accessibility_described_by_nodes"), &Node::get_accessibility_described_by_nodes);
ClassDB::bind_method(D_METHOD("set_accessibility_labeled_by_nodes", "node_path"), &Node::set_accessibility_labeled_by_nodes);
ClassDB::bind_method(D_METHOD("get_accessibility_labeled_by_nodes"), &Node::get_accessibility_labeled_by_nodes);
ClassDB::bind_method(D_METHOD("set_accessibility_flow_to_nodes", "node_path"), &Node::set_accessibility_flow_to_nodes);
ClassDB::bind_method(D_METHOD("get_accessibility_flow_to_nodes"), &Node::get_accessibility_flow_to_nodes);
ClassDB::bind_method(D_METHOD("queue_accessibility_update"), &Node::queue_accessibility_update);
ClassDB::bind_method(D_METHOD("get_accessibility_element"), &Node::get_accessibility_element);
ClassDB::bind_method(D_METHOD("set_display_folded", "fold"), &Node::set_display_folded);
ClassDB::bind_method(D_METHOD("is_displayed_folded"), &Node::is_displayed_folded);
@ -3756,8 +3999,13 @@ void Node::_bind_methods() {
mi.name = "rpc";
ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "rpc", &Node::_rpc_bind, mi);
}
mi.arguments.push_front(PropertyInfo(Variant::INT, "peer_id"));
{
MethodInfo mi;
mi.arguments.push_back(PropertyInfo(Variant::INT, "peer_id"));
mi.arguments.push_back(PropertyInfo(Variant::STRING_NAME, "method"));
mi.name = "rpc_id";
ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "rpc_id", &Node::_rpc_id_bind, mi);
@ -3820,6 +4068,7 @@ void Node::_bind_methods() {
BIND_CONSTANT(NOTIFICATION_WM_DPI_CHANGE);
BIND_CONSTANT(NOTIFICATION_VP_MOUSE_ENTER);
BIND_CONSTANT(NOTIFICATION_VP_MOUSE_EXIT);
BIND_CONSTANT(NOTIFICATION_WM_POSITION_CHANGED);
BIND_CONSTANT(NOTIFICATION_OS_MEMORY_WARNING);
BIND_CONSTANT(NOTIFICATION_TRANSLATION_CHANGED);
BIND_CONSTANT(NOTIFICATION_WM_ABOUT);
@ -3831,6 +4080,9 @@ void Node::_bind_methods() {
BIND_CONSTANT(NOTIFICATION_APPLICATION_FOCUS_OUT);
BIND_CONSTANT(NOTIFICATION_TEXT_SERVER_CHANGED);
BIND_CONSTANT(NOTIFICATION_ACCESSIBILITY_UPDATE);
BIND_CONSTANT(NOTIFICATION_ACCESSIBILITY_INVALIDATE);
BIND_ENUM_CONSTANT(PROCESS_MODE_INHERIT);
BIND_ENUM_CONSTANT(PROCESS_MODE_PAUSABLE);
BIND_ENUM_CONSTANT(PROCESS_MODE_WHEN_PAUSED);
@ -3900,16 +4152,28 @@ void Node::_bind_methods() {
ADD_GROUP("Editor Description", "editor_");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "editor_description", PROPERTY_HINT_MULTILINE_TEXT), "set_editor_description", "get_editor_description");
ADD_GROUP("Accessibility", "accessibility_");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "accessibility_name"), "set_accessibility_name", "get_accessibility_name");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "accessibility_description"), "set_accessibility_description", "get_accessibility_description");
ADD_PROPERTY(PropertyInfo(Variant::INT, "accessibility_live", PROPERTY_HINT_ENUM, "Off,Polite,Assertive"), "set_accessibility_live", "get_accessibility_live");
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "accessibility_controls_nodes", PROPERTY_HINT_ARRAY_TYPE, "NodePath"), "set_accessibility_controls_nodes", "get_accessibility_controls_nodes");
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "accessibility_described_by_nodes", PROPERTY_HINT_ARRAY_TYPE, "NodePath"), "set_accessibility_described_by_nodes", "get_accessibility_described_by_nodes");
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "accessibility_labeled_by_nodes", PROPERTY_HINT_ARRAY_TYPE, "NodePath"), "set_accessibility_labeled_by_nodes", "get_accessibility_labeled_by_nodes");
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "accessibility_flow_to_nodes", PROPERTY_HINT_ARRAY_TYPE, "NodePath"), "set_accessibility_flow_to_nodes", "get_accessibility_flow_to_nodes");
GDVIRTUAL_BIND(_process, "delta");
GDVIRTUAL_BIND(_physics_process, "delta");
GDVIRTUAL_BIND(_enter_tree);
GDVIRTUAL_BIND(_exit_tree);
GDVIRTUAL_BIND(_ready);
GDVIRTUAL_BIND(_get_configuration_warnings);
GDVIRTUAL_BIND(_get_accessibility_configuration_warnings);
GDVIRTUAL_BIND(_input, "event");
GDVIRTUAL_BIND(_shortcut_input, "event");
GDVIRTUAL_BIND(_unhandled_input, "event");
GDVIRTUAL_BIND(_unhandled_key_input, "event");
GDVIRTUAL_BIND(_get_focused_accessibility_element);
GDVIRTUAL_BIND(_get_accessibility_container_name, "node");
}
String Node::_get_name_num_separator() {
@ -3950,8 +4214,6 @@ Node::Node() {
data.physics_interpolated_client_side = false;
data.use_identity_transform = false;
data.parent_owned = false;
data.in_constructor = true;
data.use_placeholder = false;
data.display_folded = false;