feat: modules moved and engine moved to submodule
This commit is contained in:
parent
dfb5e645cd
commit
c33d2130cc
5136 changed files with 225275 additions and 64485 deletions
|
|
@ -35,14 +35,15 @@
|
|||
#include "core/io/resource_loader.h"
|
||||
#include "core/templates/local_vector.h"
|
||||
#include "scene/2d/node_2d.h"
|
||||
#ifndef _3D_DISABLED
|
||||
#include "scene/3d/node_3d.h"
|
||||
#endif // _3D_DISABLED
|
||||
#include "scene/gui/control.h"
|
||||
#include "scene/main/instance_placeholder.h"
|
||||
#include "scene/main/missing_node.h"
|
||||
#include "scene/property_utils.h"
|
||||
|
||||
#ifndef _3D_DISABLED
|
||||
#include "scene/3d/node_3d.h"
|
||||
#endif // _3D_DISABLED
|
||||
|
||||
#define PACKED_SCENE_VERSION 3
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
|
|
@ -127,14 +128,14 @@ Node *SceneState::instantiate(GenEditState p_edit_state) const {
|
|||
// Nodes where instantiation failed (because something is missing.)
|
||||
List<Node *> stray_instances;
|
||||
|
||||
#define NODE_FROM_ID(p_name, p_id) \
|
||||
Node *p_name; \
|
||||
if (p_id & FLAG_ID_IS_PATH) { \
|
||||
NodePath np = node_paths[p_id & FLAG_MASK]; \
|
||||
p_name = ret_nodes[0]->get_node_or_null(np); \
|
||||
} else { \
|
||||
ERR_FAIL_INDEX_V(p_id &FLAG_MASK, nc, nullptr); \
|
||||
p_name = ret_nodes[p_id & FLAG_MASK]; \
|
||||
#define NODE_FROM_ID(p_name, p_id) \
|
||||
Node *p_name; \
|
||||
if (p_id & FLAG_ID_IS_PATH) { \
|
||||
NodePath np = node_paths[p_id & FLAG_MASK]; \
|
||||
p_name = ret_nodes[0]->get_node_or_null(np); \
|
||||
} else { \
|
||||
ERR_FAIL_INDEX_V(p_id & FLAG_MASK, nc, nullptr); \
|
||||
p_name = ret_nodes[p_id & FLAG_MASK]; \
|
||||
}
|
||||
|
||||
int nc = nodes.size();
|
||||
|
|
@ -176,7 +177,7 @@ Node *SceneState::instantiate(GenEditState p_edit_state) const {
|
|||
#ifdef DEBUG_ENABLED
|
||||
if (!nparent && (n.parent & FLAG_ID_IS_PATH)) {
|
||||
WARN_PRINT(String("Parent path '" + String(node_paths[n.parent & FLAG_MASK]) + "' for node '" + String(snames[n.name]) + "' has vanished when instantiating: '" + get_path() + "'.").ascii().get_data());
|
||||
old_parent_path = String(node_paths[n.parent & FLAG_MASK]).trim_prefix("./").replace("/", "@");
|
||||
old_parent_path = String(node_paths[n.parent & FLAG_MASK]).trim_prefix("./").replace_char('/', '@');
|
||||
nparent = ret_nodes[0];
|
||||
}
|
||||
#endif
|
||||
|
|
@ -328,7 +329,7 @@ Node *SceneState::instantiate(GenEditState p_edit_state) const {
|
|||
|
||||
DeferredNodePathProperties dnp;
|
||||
dnp.value = props[nprops[j].value];
|
||||
dnp.base = node;
|
||||
dnp.base = node->get_instance_id();
|
||||
dnp.property = snames[name_idx];
|
||||
deferred_node_paths.push_back(dnp);
|
||||
continue;
|
||||
|
|
@ -521,45 +522,47 @@ Node *SceneState::instantiate(GenEditState p_edit_state) const {
|
|||
|
||||
for (const DeferredNodePathProperties &dnp : deferred_node_paths) {
|
||||
// Replace properties stored as NodePaths with actual Nodes.
|
||||
Node *base = ObjectDB::get_instance<Node>(dnp.base);
|
||||
ERR_CONTINUE_EDMSG(!base, vformat("Failed to set deferred property '%s' as the base node disappeared.", dnp.property));
|
||||
if (dnp.value.get_type() == Variant::ARRAY) {
|
||||
Array paths = dnp.value;
|
||||
|
||||
bool valid;
|
||||
Array array = dnp.base->get(dnp.property, &valid);
|
||||
ERR_CONTINUE_EDMSG(!valid, vformat("Failed to get property '%s' from node '%s'.", dnp.property, dnp.base->get_name()));
|
||||
Array array = base->get(dnp.property, &valid);
|
||||
ERR_CONTINUE_EDMSG(!valid, vformat("Failed to get property '%s' from node '%s'.", dnp.property, base->get_name()));
|
||||
array = array.duplicate();
|
||||
|
||||
array.resize(paths.size());
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
array.set(i, dnp.base->get_node_or_null(paths[i]));
|
||||
array.set(i, base->get_node_or_null(paths[i]));
|
||||
}
|
||||
dnp.base->set(dnp.property, array);
|
||||
base->set(dnp.property, array);
|
||||
} else if (dnp.value.get_type() == Variant::DICTIONARY) {
|
||||
Dictionary paths = dnp.value;
|
||||
|
||||
bool valid;
|
||||
Dictionary dict = dnp.base->get(dnp.property, &valid);
|
||||
ERR_CONTINUE_EDMSG(!valid, vformat("Failed to get property '%s' from node '%s'.", dnp.property, dnp.base->get_name()));
|
||||
Dictionary dict = base->get(dnp.property, &valid);
|
||||
ERR_CONTINUE_EDMSG(!valid, vformat("Failed to get property '%s' from node '%s'.", dnp.property, base->get_name()));
|
||||
dict = dict.duplicate();
|
||||
bool convert_key = dict.get_typed_key_builtin() == Variant::OBJECT &&
|
||||
ClassDB::is_parent_class(dict.get_typed_key_class_name(), "Node");
|
||||
bool convert_value = dict.get_typed_value_builtin() == Variant::OBJECT &&
|
||||
ClassDB::is_parent_class(dict.get_typed_value_class_name(), "Node");
|
||||
|
||||
for (int i = 0; i < paths.size(); i++) {
|
||||
Variant key = paths.get_key_at_index(i);
|
||||
for (const KeyValue<Variant, Variant> &kv : paths) {
|
||||
Variant key = kv.key;
|
||||
if (convert_key) {
|
||||
key = dnp.base->get_node_or_null(key);
|
||||
key = base->get_node_or_null(key);
|
||||
}
|
||||
Variant value = paths.get_value_at_index(i);
|
||||
Variant value = kv.value;
|
||||
if (convert_value) {
|
||||
value = dnp.base->get_node_or_null(value);
|
||||
value = base->get_node_or_null(value);
|
||||
}
|
||||
dict[key] = value;
|
||||
}
|
||||
dnp.base->set(dnp.property, dict);
|
||||
base->set(dnp.property, dict);
|
||||
} else {
|
||||
dnp.base->set(dnp.property, dnp.base->get_node_or_null(dnp.value));
|
||||
base->set(dnp.property, base->get_node_or_null(dnp.value));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -827,7 +830,7 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Has
|
|||
int slash_pos = subtype_string.find_char('/');
|
||||
PropertyHint subtype_hint = PropertyHint::PROPERTY_HINT_NONE;
|
||||
if (slash_pos >= 0) {
|
||||
subtype_hint = PropertyHint(subtype_string.get_slice("/", 1).to_int());
|
||||
subtype_hint = PropertyHint(subtype_string.get_slicec('/', 1).to_int());
|
||||
subtype_string = subtype_string.substr(0, slash_pos);
|
||||
}
|
||||
Variant::Type subtype = Variant::Type(subtype_string.to_int());
|
||||
|
|
@ -857,7 +860,7 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Has
|
|||
int key_slash_pos = key_subtype_string.find_char('/');
|
||||
PropertyHint key_subtype_hint = PropertyHint::PROPERTY_HINT_NONE;
|
||||
if (key_slash_pos >= 0) {
|
||||
key_subtype_hint = PropertyHint(key_subtype_string.get_slice("/", 1).to_int());
|
||||
key_subtype_hint = PropertyHint(key_subtype_string.get_slicec('/', 1).to_int());
|
||||
key_subtype_string = key_subtype_string.substr(0, key_slash_pos);
|
||||
}
|
||||
Variant::Type key_subtype = Variant::Type(key_subtype_string.to_int());
|
||||
|
|
@ -868,7 +871,7 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Has
|
|||
int value_slash_pos = value_subtype_string.find_char('/');
|
||||
PropertyHint value_subtype_hint = PropertyHint::PROPERTY_HINT_NONE;
|
||||
if (value_slash_pos >= 0) {
|
||||
value_subtype_hint = PropertyHint(value_subtype_string.get_slice("/", 1).to_int());
|
||||
value_subtype_hint = PropertyHint(value_subtype_string.get_slicec('/', 1).to_int());
|
||||
value_subtype_string = value_subtype_string.substr(0, value_slash_pos);
|
||||
}
|
||||
Variant::Type value_subtype = Variant::Type(value_subtype_string.to_int());
|
||||
|
|
@ -878,14 +881,14 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Has
|
|||
use_deferred_node_path_bit = true;
|
||||
Dictionary dict = value;
|
||||
Dictionary new_dict;
|
||||
for (int i = 0; i < dict.size(); i++) {
|
||||
Variant new_key = dict.get_key_at_index(i);
|
||||
for (const KeyValue<Variant, Variant> &kv : dict) {
|
||||
Variant new_key = kv.key;
|
||||
if (convert_key && new_key.get_type() == Variant::OBJECT) {
|
||||
if (Node *n = Object::cast_to<Node>(new_key)) {
|
||||
new_key = p_node->get_path_to(n);
|
||||
}
|
||||
}
|
||||
Variant new_value = dict.get_value_at_index(i);
|
||||
Variant new_value = kv.value;
|
||||
if (convert_value && new_value.get_type() == Variant::OBJECT) {
|
||||
if (Node *n = Object::cast_to<Node>(new_value)) {
|
||||
new_value = p_node->get_path_to(n);
|
||||
|
|
@ -2090,6 +2093,8 @@ Vector<String> SceneState::_get_node_groups(int p_idx) const {
|
|||
void SceneState::_bind_methods() {
|
||||
//unbuild API
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_path"), &SceneState::get_path);
|
||||
ClassDB::bind_method(D_METHOD("get_base_scene_state"), &SceneState::get_base_scene_state);
|
||||
ClassDB::bind_method(D_METHOD("get_node_count"), &SceneState::get_node_count);
|
||||
ClassDB::bind_method(D_METHOD("get_node_type", "idx"), &SceneState::get_node_type);
|
||||
ClassDB::bind_method(D_METHOD("get_node_name", "idx"), &SceneState::get_node_name);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue