summaryrefslogtreecommitdiffstats
path: root/scene/main/node.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/main/node.cpp')
-rw-r--r--scene/main/node.cpp107
1 files changed, 10 insertions, 97 deletions
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 77e00e4ab4..f827f68def 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -110,14 +110,12 @@ void Node::_notification(int p_notification) {
// Don't translate UI elements when they're being edited.
if (is_part_of_edited_scene()) {
set_message_translation(false);
- } else if (data.auto_translate_mode != AUTO_TRANSLATE_MODE_DISABLED) {
- notification(NOTIFICATION_TRANSLATION_CHANGED);
}
-#else
+#endif
+
if (data.auto_translate_mode != AUTO_TRANSLATE_MODE_DISABLED) {
notification(NOTIFICATION_TRANSLATION_CHANGED);
}
-#endif
if (data.input) {
add_to_group("_vp_input" + itos(get_viewport()->get_instance_id()));
@@ -2506,7 +2504,7 @@ StringName Node::get_property_store_alias(const StringName &p_property) const {
bool Node::is_part_of_edited_scene() const {
return Engine::get_singleton()->is_editor_hint() && is_inside_tree() && get_tree()->get_edited_scene_root() &&
- (get_tree()->get_edited_scene_root() == this || get_tree()->get_edited_scene_root()->is_ancestor_of(this));
+ get_tree()->get_edited_scene_root()->get_parent()->is_ancestor_of(this);
}
#endif
@@ -3027,9 +3025,9 @@ Array Node::_get_node_and_resource(const NodePath &p_path) {
Node *Node::get_node_and_resource(const NodePath &p_path, Ref<Resource> &r_res, Vector<StringName> &r_leftover_subpath, bool p_last_is_property) const {
ERR_THREAD_GUARD_V(nullptr);
- Node *node = get_node(p_path);
r_res = Ref<Resource>();
r_leftover_subpath = Vector<StringName>();
+ Node *node = get_node_or_null(p_path);
if (!node) {
return nullptr;
}
@@ -3204,91 +3202,16 @@ void Node::clear_internal_tree_resource_paths() {
}
}
-Array Node::get_configuration_warnings() const {
- ERR_THREAD_GUARD_V(Array());
- Array warnings;
- GDVIRTUAL_CALL(_get_configuration_warnings, warnings);
- return warnings;
-}
+PackedStringArray Node::get_configuration_warnings() const {
+ ERR_THREAD_GUARD_V(PackedStringArray());
+ PackedStringArray ret;
-Dictionary Node::configuration_warning_to_dict(const Variant &p_warning) const {
- switch (p_warning.get_type()) {
- case Variant::Type::DICTIONARY:
- return p_warning;
- case Variant::Type::STRING: {
- // Convert string to dictionary.
- Dictionary warning;
- warning["message"] = p_warning;
- return warning;
- }
- default: {
- ERR_FAIL_V_MSG(Dictionary(), "Node::get_configuration_warnings returned a value which is neither a string nor a dictionary, but a " + Variant::get_type_name(p_warning.get_type()));
- }
- }
-}
-
-Vector<Dictionary> Node::get_configuration_warnings_as_dicts() const {
- Vector<Dictionary> ret;
- Array mixed = get_configuration_warnings();
- for (int i = 0; i < mixed.size(); i++) {
- ret.append(configuration_warning_to_dict(mixed[i]));
- }
- return ret;
-}
-
-Vector<Dictionary> Node::get_configuration_warnings_of_property(const String &p_property) const {
- Vector<Dictionary> ret;
- Vector<Dictionary> warnings = get_configuration_warnings_as_dicts();
- if (p_property.is_empty()) {
+ Vector<String> warnings;
+ if (GDVIRTUAL_CALL(_get_configuration_warnings, warnings)) {
ret.append_array(warnings);
- } else {
- // Filter by property path.
- for (int i = 0; i < warnings.size(); i++) {
- Dictionary warning = warnings[i];
- String warning_property = warning.get("property", String());
- if (p_property == warning_property) {
- ret.append(warning);
- }
- }
}
- return ret;
-}
-
-PackedStringArray Node::get_configuration_warnings_as_strings(bool p_wrap_lines, const String &p_property) const {
- Vector<Dictionary> warnings = get_configuration_warnings_of_property(p_property);
- const String bullet_point = U"• ";
- PackedStringArray all_warnings;
- for (const Dictionary &warning : warnings) {
- if (!warning.has("message")) {
- continue;
- }
-
- // Prefix with property name if we are showing all warnings.
- String text;
- if (warning.has("property") && p_property.is_empty()) {
- text = bullet_point + vformat("[%s] %s", warning["property"], warning["message"]);
- } else {
- text = bullet_point + static_cast<String>(warning["message"]);
- }
-
- if (p_wrap_lines) {
- // Limit the line width while keeping some padding.
- // It is not efficient, but it does not have to be.
- const PackedInt32Array boundaries = TS->string_get_word_breaks(text, "", 80);
- PackedStringArray lines;
- for (int i = 0; i < boundaries.size(); i += 2) {
- const int start = boundaries[i];
- const int end = boundaries[i + 1];
- String line = text.substr(start, end - start);
- lines.append(line);
- }
- text = String("\n").join(lines);
- }
- text = text.replace("\n", "\n ");
- all_warnings.append(text);
- }
- return all_warnings;
+ return ret;
}
void Node::update_configuration_warnings() {
@@ -3774,16 +3697,6 @@ String Node::_get_name_num_separator() {
return " ";
}
-StringName Node::get_configuration_warning_icon(int p_count) {
- if (p_count == 1) {
- return SNAME("NodeWarning");
- } else if (p_count <= 3) {
- return vformat("NodeWarnings%d", p_count);
- } else {
- return SNAME("NodeWarnings4Plus");
- }
-}
-
Node::Node() {
orphan_node_count++;
}