diff options
Diffstat (limited to 'scene/resources/scene_format_text.cpp')
| -rw-r--r-- | scene/resources/scene_format_text.cpp | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/scene/resources/scene_format_text.cpp b/scene/resources/scene_format_text.cpp index d9f6beabc0..6bd5f520d2 100644 --- a/scene/resources/scene_format_text.cpp +++ b/scene/resources/scene_format_text.cpp @@ -389,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 { @@ -720,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; @@ -1124,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; @@ -1268,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()); @@ -1298,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; |