summaryrefslogtreecommitdiffstats
path: root/scene/main/missing_node.cpp
diff options
context:
space:
mode:
authorkobewi <kobewi4e@gmail.com>2024-01-04 14:12:27 +0100
committerkobewi <kobewi4e@gmail.com>2024-02-13 19:46:35 +0100
commitbe4cbee8734eb1910f5294171da464ce2ed2862f (patch)
treef254f49bba5c59925565866ab503f018ecd3d852 /scene/main/missing_node.cpp
parentdfe226b93346c208787728eceecc2c64d81a9553 (diff)
downloadredot-engine-be4cbee8734eb1910f5294171da464ce2ed2862f.tar.gz
Allow opening scenes with missing scene dependency
Diffstat (limited to 'scene/main/missing_node.cpp')
-rw-r--r--scene/main/missing_node.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/scene/main/missing_node.cpp b/scene/main/missing_node.cpp
index 49e565a39c..02e079892c 100644
--- a/scene/main/missing_node.cpp
+++ b/scene/main/missing_node.cpp
@@ -66,6 +66,14 @@ String MissingNode::get_original_class() const {
return original_class;
}
+void MissingNode::set_original_scene(const String &p_scene) {
+ original_scene = p_scene;
+}
+
+String MissingNode::get_original_scene() const {
+ return original_scene;
+}
+
void MissingNode::set_recording_properties(bool p_enable) {
recording_properties = p_enable;
}
@@ -77,8 +85,15 @@ bool MissingNode::is_recording_properties() const {
Array MissingNode::get_configuration_warnings() const {
// The mere existence of this node is warning.
Array ret;
- ret.push_back(vformat(RTR("This node was saved as class type '%s', which was no longer available when this scene was loaded."), original_class));
- ret.push_back(RTR("Data from the original node is kept as a placeholder until this type of node is available again. It can hence be safely re-saved without risk of data loss."));
+ if (!original_scene.is_empty()) {
+ ret.push_back(vformat(RTR("This node was an instance of scene '%s', which was no longer available when this scene was loaded."), original_scene));
+ ret.push_back(vformat(RTR("Saving current scene will discard instance and all its properties, including editable children edits (if existing).")));
+ } else if (!original_class.is_empty()) {
+ ret.push_back(vformat(RTR("This node was saved as class type '%s', which was no longer available when this scene was loaded."), original_class));
+ ret.push_back(RTR("Data from the original node is kept as a placeholder until this type of node is available again. It can hence be safely re-saved without risk of data loss."));
+ } else {
+ ret.push_back(RTR("Unrecognized missing node. Check scene dependency errors for details."));
+ }
return ret;
}
@@ -86,11 +101,15 @@ void MissingNode::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_original_class", "name"), &MissingNode::set_original_class);
ClassDB::bind_method(D_METHOD("get_original_class"), &MissingNode::get_original_class);
+ ClassDB::bind_method(D_METHOD("set_original_scene", "name"), &MissingNode::set_original_class);
+ ClassDB::bind_method(D_METHOD("get_original_scene"), &MissingNode::get_original_class);
+
ClassDB::bind_method(D_METHOD("set_recording_properties", "enable"), &MissingNode::set_recording_properties);
ClassDB::bind_method(D_METHOD("is_recording_properties"), &MissingNode::is_recording_properties);
// Expose, but not save.
ADD_PROPERTY(PropertyInfo(Variant::STRING, "original_class", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_original_class", "get_original_class");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "original_scene", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_original_scene", "get_original_scene");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "recording_properties", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_recording_properties", "is_recording_properties");
}