summaryrefslogtreecommitdiff
path: root/scene/resources/scene_format_text.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/resources/scene_format_text.cpp')
-rw-r--r--scene/resources/scene_format_text.cpp39
1 files changed, 38 insertions, 1 deletions
diff --git a/scene/resources/scene_format_text.cpp b/scene/resources/scene_format_text.cpp
index f3dcf16e28..6bd5f520d2 100644
--- a/scene/resources/scene_format_text.cpp
+++ b/scene/resources/scene_format_text.cpp
@@ -170,6 +170,7 @@ Error ResourceInteractiveLoaderText::poll() {
_printerr();
}
+ resource_current++;
return error;
@@ -227,6 +228,8 @@ Error ResourceInteractiveLoaderText::poll() {
}
+ resource_current++;
+
while(true) {
String assign;
@@ -291,6 +294,8 @@ Error ResourceInteractiveLoaderText::poll() {
resource=Ref<Resource>(r);
+ resource_current++;
+
while(true) {
String assign;
@@ -384,6 +389,22 @@ Error ResourceInteractiveLoaderText::poll() {
}
}
+ if (next_tag.fields.has("instance_placeholder")) {
+
+ String path=next_tag.fields["instance_placeholder"];
+
+ int path_v = packed_scene->get_state()->add_value(path);
+
+ if (packed_scene->get_state()->get_node_count()==0) {
+ error=ERR_FILE_CORRUPT;
+ error_text="Instance Placeholder can't be used for inheritance.";
+ _printerr();
+ return error;
+ }
+
+ instance=path_v|SceneState::FLAG_INSTANCE_IS_PLACEHOLDER;
+ }
+
if (next_tag.fields.has("owner")) {
owner=packed_scene->get_state()->add_node_path(next_tag.fields["owner"]);
} else {
@@ -715,6 +736,7 @@ Error ResourceInteractiveLoaderText::rename_dependencies(FileAccess *p_f, const
fw->store_8(c);
c=f->get_8();
}
+ f->close();
bool all_ok = fw->get_error()==OK;
@@ -745,6 +767,8 @@ void ResourceInteractiveLoaderText::open(FileAccess *p_f,bool p_skip_first_tag)
stream.f=f;
is_scene=false;
+ resource_current=0;
+
VariantParser::Tag tag;
Error err = VariantParser::parse_tag(&stream,lines,error_text,tag);
@@ -1117,7 +1141,10 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path,const RES& p_re
if (packed_scene.is_valid()) {
//add instances to external resources if saving a packed scene
for(int i=0;i<packed_scene->get_state()->get_node_count();i++) {
- Ref<PackedScene> instance=packed_scene->get_state()->get_node_instance(i);
+ if (packed_scene->get_state()->is_node_instance_placeholder(i))
+ continue;
+
+ Ref<PackedScene> instance=packed_scene->get_state()->get_node_instance(i);
if (instance.is_valid() && !external_resources.has(instance)) {
int index = external_resources.size();
external_resources[instance]=index;
@@ -1261,8 +1288,10 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path,const RES& p_re
NodePath path = state->get_node_path(i,true);
NodePath owner = state->get_node_owner_path(i);
Ref<PackedScene> instance = state->get_node_instance(i);
+ String instance_placeholder = state->get_node_instance_placeholder(i);
Vector<StringName> groups = state->get_node_groups(i);
+
if (instance.is_valid())
print_line("for path "+String(path)+" instance "+instance->get_path());
@@ -1291,6 +1320,14 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path,const RES& p_re
f->store_string(header);
+ if (instance_placeholder!=String()) {
+
+ String vars;
+ f->store_string(" instance_placeholder=");
+ VariantWriter::write_to_string(instance_placeholder,vars,_write_resources,this);
+ f->store_string(vars);
+ }
+
if (instance.is_valid()) {
String vars;