summaryrefslogtreecommitdiff
path: root/scene/resources/scene_format_text.cpp
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-12-16 18:35:00 +0100
committerGitHub <noreply@github.com>2017-12-16 18:35:00 +0100
commit1e2a8132f333245bf3f77244b83e625a56418067 (patch)
tree826dc4d17ed0d5cf8586e25703788a52d77e1ad3 /scene/resources/scene_format_text.cpp
parentcaf3a405ab1d7831a03dabc04b5fe2301e82c28e (diff)
parentced1ff63a8267773bf440610792ce3ab4eb2f8ec (diff)
Merge pull request #14406 from hoelzl/pr-instance-node-order
Fix some issues with instanced scenes
Diffstat (limited to 'scene/resources/scene_format_text.cpp')
-rw-r--r--scene/resources/scene_format_text.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/scene/resources/scene_format_text.cpp b/scene/resources/scene_format_text.cpp
index aebbb5b562..7bf5f24269 100644
--- a/scene/resources/scene_format_text.cpp
+++ b/scene/resources/scene_format_text.cpp
@@ -198,6 +198,7 @@ Ref<PackedScene> ResourceInteractiveLoaderText::_parse_node_tag(VariantParser::R
int type = -1;
int name = -1;
int instance = -1;
+ int index = -1;
//int base_scene=-1;
if (next_tag.fields.has("name")) {
@@ -249,7 +250,11 @@ Ref<PackedScene> ResourceInteractiveLoaderText::_parse_node_tag(VariantParser::R
owner = 0; //if no owner, owner is root
}
- int node_id = packed_scene->get_state()->add_node(parent, owner, type, name, instance);
+ if (next_tag.fields.has("index")) {
+ index = next_tag.fields["index"];
+ }
+
+ int node_id = packed_scene->get_state()->add_node(parent, owner, type, name, instance, index);
if (next_tag.fields.has("groups")) {
@@ -1609,6 +1614,7 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r
StringName type = state->get_node_type(i);
StringName name = state->get_node_name(i);
+ int index = state->get_node_index(i);
NodePath path = state->get_node_path(i, true);
NodePath owner = state->get_node_owner_path(i);
Ref<PackedScene> instance = state->get_node_instance(i);
@@ -1626,6 +1632,9 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r
if (owner != NodePath() && owner != NodePath(".")) {
header += " owner=\"" + String(owner.simplified()) + "\"";
}
+ if (index >= 0) {
+ header += " index=\"" + itos(index) + "\"";
+ }
if (groups.size()) {
String sgroups = " groups=[\n";