diff options
author | Spartan322 <Megacake1234@gmail.com> | 2024-10-30 05:22:24 -0400 |
---|---|---|
committer | Spartan322 <Megacake1234@gmail.com> | 2024-10-30 05:22:24 -0400 |
commit | 82de309d58c5f0e221b85463cca2983cd7ed0289 (patch) | |
tree | 5c87dc486c61310a1eafc2e7cb2fd52be0d52e22 /core/string | |
parent | 77eaec766e2e40f2a5d399989d827f9582a3be15 (diff) | |
parent | 8004c7524fb9f43425c4d6f614410a76678e0f7c (diff) | |
download | redot-engine-82de309d58c5f0e221b85463cca2983cd7ed0289.tar.gz |
Merge commit godotengine/godot@8004c7524fb9f43425c4d6f614410a76678e0f7c
Diffstat (limited to 'core/string')
-rw-r--r-- | core/string/translation_domain.cpp | 2 | ||||
-rw-r--r-- | core/string/ustring.cpp | 13 | ||||
-rw-r--r-- | core/string/ustring.h | 4 |
3 files changed, 15 insertions, 4 deletions
diff --git a/core/string/translation_domain.cpp b/core/string/translation_domain.cpp index dfbc664783..1fdf5b7e75 100644 --- a/core/string/translation_domain.cpp +++ b/core/string/translation_domain.cpp @@ -125,7 +125,7 @@ String TranslationDomain::_double_vowels(const String &p_message) const { } } return res; -}; +} String TranslationDomain::_replace_with_accented_string(const String &p_message) const { String res; diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp index 73ffe14e50..38f610eaca 100644 --- a/core/string/ustring.cpp +++ b/core/string/ustring.cpp @@ -35,6 +35,7 @@ #include "core/crypto/crypto_core.h" #include "core/math/color.h" #include "core/math/math_funcs.h" +#include "core/object/object.h" #include "core/os/memory.h" #include "core/string/print_string.h" #include "core/string/string_name.h" @@ -4066,8 +4067,18 @@ String String::format(const Variant &values, const String &placeholder) const { for (const Variant &key : keys) { new_string = new_string.replace(placeholder.replace("_", key), d[key]); } + } else if (values.get_type() == Variant::OBJECT) { + Object *obj = values.get_validated_object(); + ERR_FAIL_NULL_V(obj, new_string); + + List<PropertyInfo> props; + obj->get_property_list(&props); + + for (const PropertyInfo &E : props) { + new_string = new_string.replace(placeholder.replace("_", E.name), obj->get(E.name)); + } } else { - ERR_PRINT(String("Invalid type: use Array or Dictionary.").ascii().get_data()); + ERR_PRINT(String("Invalid type: use Array, Dictionary or Object.").ascii().get_data()); } return new_string; diff --git a/core/string/ustring.h b/core/string/ustring.h index 491f82e109..d6c0907ecc 100644 --- a/core/string/ustring.h +++ b/core/string/ustring.h @@ -120,7 +120,7 @@ public: Char16String &operator+=(char16_t p_char); int length() const { return size() ? size() - 1 : 0; } const char16_t *get_data() const; - operator const char16_t *() const { return get_data(); }; + operator const char16_t *() const { return get_data(); } protected: void copy_from(const char16_t *p_cstr); @@ -162,7 +162,7 @@ public: CharString &operator+=(char p_char); int length() const { return size() ? size() - 1 : 0; } const char *get_data() const; - operator const char *() const { return get_data(); }; + operator const char *() const { return get_data(); } protected: void copy_from(const char *p_cstr); |