summaryrefslogtreecommitdiffstats
path: root/scene/main/node.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-02-17 19:04:18 +0100
committerRémi Verschelde <rverschelde@gmail.com>2024-02-17 19:04:18 +0100
commit92fcbe2f5c1b0293dea581bc4b7bfd9d7e68a160 (patch)
tree278a62a255c68e3140b6a27abbc0355065d4a0e4 /scene/main/node.cpp
parent21f0529aa923e8d337827074f15a5cf83f73c19a (diff)
downloadredot-engine-92fcbe2f5c1b0293dea581bc4b7bfd9d7e68a160.tar.gz
Revert "Allow configuration warnings to refer to a property"
This reverts commit bf37a9bac6ebfb09c0a374260c35ede8373ce427.
Diffstat (limited to 'scene/main/node.cpp')
-rw-r--r--scene/main/node.cpp97
1 files changed, 6 insertions, 91 deletions
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 77e00e4ab4..853c684b13 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -3204,91 +3204,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;
-}
-
-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;
-}
+PackedStringArray Node::get_configuration_warnings() const {
+ ERR_THREAD_GUARD_V(PackedStringArray());
+ PackedStringArray 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 +3699,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++;
}