diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2024-02-17 19:04:18 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-02-17 19:04:18 +0100 |
commit | 92fcbe2f5c1b0293dea581bc4b7bfd9d7e68a160 (patch) | |
tree | 278a62a255c68e3140b6a27abbc0355065d4a0e4 /scene/main | |
parent | 21f0529aa923e8d337827074f15a5cf83f73c19a (diff) | |
download | redot-engine-92fcbe2f5c1b0293dea581bc4b7bfd9d7e68a160.tar.gz |
Revert "Allow configuration warnings to refer to a property"
This reverts commit bf37a9bac6ebfb09c0a374260c35ede8373ce427.
Diffstat (limited to 'scene/main')
-rw-r--r-- | scene/main/node.compat.inc | 41 | ||||
-rw-r--r-- | scene/main/node.cpp | 97 | ||||
-rw-r--r-- | scene/main/node.h | 9 |
3 files changed, 8 insertions, 139 deletions
diff --git a/scene/main/node.compat.inc b/scene/main/node.compat.inc deleted file mode 100644 index 7e957e5a14..0000000000 --- a/scene/main/node.compat.inc +++ /dev/null @@ -1,41 +0,0 @@ -/**************************************************************************/ -/* node.compat.inc */ -/**************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/**************************************************************************/ -/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/**************************************************************************/ - -#ifndef DISABLE_DEPRECATED - -PackedStringArray Node::get_configuration_warnings_bind_compat_68420() const { - return PackedStringArray(get_configuration_warnings()); -} - -void Node::_bind_compatibility_methods() { - ClassDB::bind_compatibility_method(D_METHOD("get_configuration_warnings"), &Node::get_configuration_warnings_bind_compat_68420); -} - -#endif // DISABLE_DEPRECATED 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++; } diff --git a/scene/main/node.h b/scene/main/node.h index bbbdb87a32..b936cdd375 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -304,7 +304,6 @@ protected: static void _bind_methods(); static String _get_name_num_separator(); - static StringName get_configuration_warning_icon(int p_count); friend class SceneState; @@ -331,7 +330,7 @@ protected: GDVIRTUAL0(_enter_tree) GDVIRTUAL0(_exit_tree) GDVIRTUAL0(_ready) - GDVIRTUAL0RC(Array, _get_configuration_warnings) + GDVIRTUAL0RC(Vector<String>, _get_configuration_warnings) GDVIRTUAL1(_input, Ref<InputEvent>) GDVIRTUAL1(_shortcut_input, Ref<InputEvent>) @@ -648,11 +647,7 @@ public: _FORCE_INLINE_ Viewport *get_viewport() const { return data.viewport; } - virtual Array get_configuration_warnings() const; - Dictionary configuration_warning_to_dict(const Variant &p_warning) const; - Vector<Dictionary> get_configuration_warnings_as_dicts() const; - Vector<Dictionary> get_configuration_warnings_of_property(const String &p_property = String()) const; - PackedStringArray get_configuration_warnings_as_strings(bool p_wrap_lines, const String &p_property = String()) const; + virtual PackedStringArray get_configuration_warnings() const; void update_configuration_warnings(); |