diff options
Diffstat (limited to 'core/string')
-rw-r--r-- | core/string/print_string.cpp | 2 | ||||
-rw-r--r-- | core/string/translation.cpp | 9 | ||||
-rw-r--r-- | core/string/translation.h | 2 | ||||
-rw-r--r-- | core/string/ustring.cpp | 9 |
4 files changed, 18 insertions, 4 deletions
diff --git a/core/string/print_string.cpp b/core/string/print_string.cpp index 7b90710308..dcdde3c175 100644 --- a/core/string/print_string.cpp +++ b/core/string/print_string.cpp @@ -164,6 +164,8 @@ void __print_line_rich(String p_string) { p_string_ansi = p_string_ansi.replace("[/fgcolor]", "\u001b[39;49m"); } + p_string_ansi += "\u001b[0m"; // Reset. + OS::get_singleton()->print_rich("%s\n", p_string_ansi.utf8().get_data()); _global_lock(); diff --git a/core/string/translation.cpp b/core/string/translation.cpp index 3ca2e5ccdf..02380c92bb 100644 --- a/core/string/translation.cpp +++ b/core/string/translation.cpp @@ -82,6 +82,15 @@ void Translation::_set_messages(const Dictionary &p_messages) { void Translation::set_locale(const String &p_locale) { locale = TranslationServer::get_singleton()->standardize_locale(p_locale); + if (Thread::is_main_thread()) { + _notify_translation_changed_if_applies(); + } else { + // Avoid calling non-thread-safe functions here. + callable_mp(this, &Translation::_notify_translation_changed_if_applies).call_deferred(); + } +} + +void Translation::_notify_translation_changed_if_applies() { if (OS::get_singleton()->get_main_loop() && TranslationServer::get_singleton()->get_loaded_locales().has(get_locale())) { OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_TRANSLATION_CHANGED); } diff --git a/core/string/translation.h b/core/string/translation.h index 01d239f81c..ca8b460312 100644 --- a/core/string/translation.h +++ b/core/string/translation.h @@ -47,6 +47,8 @@ class Translation : public Resource { virtual Dictionary _get_messages() const; virtual void _set_messages(const Dictionary &p_messages); + void _notify_translation_changed_if_applies(); + protected: static void _bind_methods(); diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp index 49c7ead423..12e6423724 100644 --- a/core/string/ustring.cpp +++ b/core/string/ustring.cpp @@ -4281,12 +4281,13 @@ String String::pad_zeros(int p_digits) const { begin++; } - if (begin >= end) { + int zeros_to_add = p_digits - (end - begin); + + if (zeros_to_add <= 0) { return s; + } else { + return s.insert(begin, String("0").repeat(zeros_to_add)); } - - int zeros_to_add = p_digits - (end - begin); - return s.insert(begin, String("0").repeat(zeros_to_add)); } String String::trim_prefix(const String &p_prefix) const { |