You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-12-02 16:48:55 +00:00
Merge pull request #57121 from KoBeWi/noddeganger
Add `DUPLICATE_INTERNAL_STATE` flag
This commit is contained in:
@@ -282,6 +282,7 @@
|
||||
<description>
|
||||
Duplicates the node, returning a new node with all of its properties, signals, groups, and children copied from the original. The behavior can be tweaked through the [param flags] (see [enum DuplicateFlags]). Internal nodes are not duplicated.
|
||||
[b]Note:[/b] For nodes with a [Script] attached, if [method Object._init] has been defined with required parameters, the duplicated node will not have a [Script].
|
||||
[b]Note:[/b] By default, this method will duplicate only properties marked for serialization (i.e. using [constant @GlobalScope.PROPERTY_USAGE_STORAGE], or in GDScript, [annotation @GDScript.@export]). If you want to duplicate all properties, use [constant DUPLICATE_INTERNAL_STATE].
|
||||
</description>
|
||||
</method>
|
||||
<method name="find_child" qualifiers="const">
|
||||
@@ -1381,6 +1382,16 @@
|
||||
<constant name="DUPLICATE_USE_INSTANTIATION" value="8" enum="DuplicateFlags">
|
||||
Duplicate using [method PackedScene.instantiate]. If the node comes from a scene saved on disk, reuses [method PackedScene.instantiate] as the base for the duplicated node and its children.
|
||||
</constant>
|
||||
<constant name="DUPLICATE_INTERNAL_STATE" value="16" enum="DuplicateFlags">
|
||||
Duplicate also non-serializable variables (i.e. without [constant @GlobalScope.PROPERTY_USAGE_STORAGE]).
|
||||
</constant>
|
||||
<constant name="DUPLICATE_DEFAULT" value="15" enum="DuplicateFlags">
|
||||
Duplicate using default flags. This constant is useful to add or remove a single flag.
|
||||
[codeblock]
|
||||
# Duplicate non-exported variables.
|
||||
var dupe = duplicate(DUPLICATE_DEFAULT | DUPLICATE_INTERNAL_STATE)
|
||||
[/codeblock]
|
||||
</constant>
|
||||
<constant name="INTERNAL_MODE_DISABLED" value="0" enum="InternalMode">
|
||||
The node will not be internal.
|
||||
</constant>
|
||||
|
||||
@@ -3060,7 +3060,7 @@ void Node::_duplicate_properties(const Node *p_root, const Node *p_original, Nod
|
||||
p_original->get_property_list(&props);
|
||||
const StringName &script_property_name = CoreStringName(script);
|
||||
for (const PropertyInfo &E : props) {
|
||||
if (!(E.usage & PROPERTY_USAGE_STORAGE)) {
|
||||
if (!(p_flags & DUPLICATE_INTERNAL_STATE) && !(E.usage & PROPERTY_USAGE_STORAGE)) {
|
||||
continue;
|
||||
}
|
||||
const StringName name = E.name;
|
||||
@@ -3840,7 +3840,7 @@ void Node::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_tree"), &Node::get_tree);
|
||||
ClassDB::bind_method(D_METHOD("create_tween"), &Node::create_tween);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("duplicate", "flags"), &Node::duplicate, DEFVAL(DUPLICATE_USE_INSTANTIATION | DUPLICATE_SIGNALS | DUPLICATE_GROUPS | DUPLICATE_SCRIPTS));
|
||||
ClassDB::bind_method(D_METHOD("duplicate", "flags"), &Node::duplicate, DEFVAL(DUPLICATE_DEFAULT));
|
||||
ClassDB::bind_method(D_METHOD("replace_by", "node", "keep_groups"), &Node::replace_by, DEFVAL(false));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_scene_instance_load_placeholder", "load_placeholder"), &Node::set_scene_instance_load_placeholder);
|
||||
@@ -3990,6 +3990,8 @@ void Node::_bind_methods() {
|
||||
BIND_ENUM_CONSTANT(DUPLICATE_GROUPS);
|
||||
BIND_ENUM_CONSTANT(DUPLICATE_SCRIPTS);
|
||||
BIND_ENUM_CONSTANT(DUPLICATE_USE_INSTANTIATION);
|
||||
BIND_ENUM_CONSTANT(DUPLICATE_INTERNAL_STATE);
|
||||
BIND_ENUM_CONSTANT(DUPLICATE_DEFAULT);
|
||||
|
||||
BIND_ENUM_CONSTANT(INTERNAL_MODE_DISABLED);
|
||||
BIND_ENUM_CONSTANT(INTERNAL_MODE_FRONT);
|
||||
|
||||
@@ -103,8 +103,10 @@ public:
|
||||
DUPLICATE_GROUPS = 2,
|
||||
DUPLICATE_SCRIPTS = 4,
|
||||
DUPLICATE_USE_INSTANTIATION = 8,
|
||||
DUPLICATE_INTERNAL_STATE = 16,
|
||||
DUPLICATE_DEFAULT = DUPLICATE_SIGNALS | DUPLICATE_GROUPS | DUPLICATE_SCRIPTS | DUPLICATE_USE_INSTANTIATION,
|
||||
#ifdef TOOLS_ENABLED
|
||||
DUPLICATE_FROM_EDITOR = 16,
|
||||
DUPLICATE_FROM_EDITOR = 32,
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user