diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/core_constants.cpp | 1 | ||||
-rw-r--r-- | core/math/math_defs.h | 3 | ||||
-rw-r--r-- | core/string/translation.cpp | 21 | ||||
-rw-r--r-- | core/string/translation.h | 2 | ||||
-rw-r--r-- | core/templates/hashfuncs.h | 18 |
5 files changed, 44 insertions, 1 deletions
diff --git a/core/core_constants.cpp b/core/core_constants.cpp index 57ea10c074..db22a9ecf6 100644 --- a/core/core_constants.cpp +++ b/core/core_constants.cpp @@ -128,6 +128,7 @@ void register_global_constants() { BIND_CORE_ENUM_CONSTANT(HALIGN_LEFT); BIND_CORE_ENUM_CONSTANT(HALIGN_CENTER); BIND_CORE_ENUM_CONSTANT(HALIGN_RIGHT); + BIND_CORE_ENUM_CONSTANT(HALIGN_FILL); BIND_CORE_ENUM_CONSTANT(VALIGN_TOP); BIND_CORE_ENUM_CONSTANT(VALIGN_CENTER); diff --git a/core/math/math_defs.h b/core/math/math_defs.h index 5192722839..4d97f72ebf 100644 --- a/core/math/math_defs.h +++ b/core/math/math_defs.h @@ -73,7 +73,8 @@ enum Orientation { enum HAlign { HALIGN_LEFT, HALIGN_CENTER, - HALIGN_RIGHT + HALIGN_RIGHT, + HALIGN_FILL, }; enum VAlign { diff --git a/core/string/translation.cpp b/core/string/translation.cpp index df8a26e5ce..7b8c28e2e2 100644 --- a/core/string/translation.cpp +++ b/core/string/translation.cpp @@ -34,6 +34,11 @@ #include "core/io/resource_loader.h" #include "core/os/os.h" +#ifdef TOOLS_ENABLED +#include "editor/editor_settings.h" +#include "main/main.h" +#endif + // ISO 639-1 language codes, with the addition of glibc locales with their // regional identifiers. This list must match the language names (in English) // of locale_names. @@ -1214,6 +1219,22 @@ void TranslationServer::set_tool_translation(const Ref<Translation> &p_translati tool_translation = p_translation; } +Ref<Translation> TranslationServer::get_tool_translation() const { + return tool_translation; +} + +String TranslationServer::get_tool_locale() { +#ifdef TOOLS_ENABLED + if (TranslationServer::get_singleton()->get_tool_translation().is_valid() && (Engine::get_singleton()->is_editor_hint() || Main::is_project_manager())) { + return tool_translation->get_locale(); + } else { +#else + { +#endif + return get_locale(); + } +} + StringName TranslationServer::tool_translate(const StringName &p_message, const StringName &p_context) const { if (tool_translation.is_valid()) { StringName r = tool_translation->get_message(p_message, p_context); diff --git a/core/string/translation.h b/core/string/translation.h index 8d34f7997e..c7ffe4d065 100644 --- a/core/string/translation.h +++ b/core/string/translation.h @@ -110,7 +110,9 @@ public: static String standardize_locale(const String &p_locale); static String get_language_code(const String &p_locale); + String get_tool_locale(); void set_tool_translation(const Ref<Translation> &p_translation); + Ref<Translation> get_tool_translation() const; StringName tool_translate(const StringName &p_message, const StringName &p_context = "") const; StringName tool_translate_plural(const StringName &p_message, const StringName &p_message_plural, int p_n, const StringName &p_context = "") const; void set_doc_translation(const Ref<Translation> &p_translation); diff --git a/core/templates/hashfuncs.h b/core/templates/hashfuncs.h index 86bb1b5228..1ed9ab1987 100644 --- a/core/templates/hashfuncs.h +++ b/core/templates/hashfuncs.h @@ -114,6 +114,24 @@ static inline uint32_t make_uint32_t(T p_in) { return _u._u32; } +static inline uint64_t hash_djb2_one_float_64(double p_in, uint64_t p_prev = 5381) { + union { + double d; + uint64_t i; + } u; + + // Normalize +/- 0.0 and NaN values so they hash the same. + if (p_in == 0.0f) { + u.d = 0.0; + } else if (Math::is_nan(p_in)) { + u.d = Math_NAN; + } else { + u.d = p_in; + } + + return ((p_prev << 5) + p_prev) + u.i; +} + static inline uint64_t hash_djb2_one_64(uint64_t p_in, uint64_t p_prev = 5381) { return ((p_prev << 5) + p_prev) + p_in; } |