diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/input/input.cpp | 15 | ||||
-rw-r--r-- | core/io/resource_loader.cpp | 2 | ||||
-rw-r--r-- | core/string/locales.h | 1 | ||||
-rw-r--r-- | core/string/translation.cpp | 16 |
4 files changed, 18 insertions, 16 deletions
diff --git a/core/input/input.cpp b/core/input/input.cpp index 3ddb151f23..7106bd0745 100644 --- a/core/input/input.cpp +++ b/core/input/input.cpp @@ -518,18 +518,20 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em Ref<InputEventMouseMotion> mm = p_event; if (mm.is_valid()) { - Point2 pos = mm->get_global_position(); - if (mouse_pos != pos) { - set_mouse_position(pos); + Point2 position = mm->get_global_position(); + if (mouse_pos != position) { + set_mouse_position(position); } + Vector2 relative = mm->get_relative(); + mouse_velocity_track.update(relative); if (event_dispatch_function && emulate_touch_from_mouse && !p_is_emulated && (mm->get_button_mask() & MouseButton::LEFT) != MouseButton::NONE) { Ref<InputEventScreenDrag> drag_event; drag_event.instantiate(); - drag_event->set_position(mm->get_position()); - drag_event->set_relative(mm->get_relative()); - drag_event->set_velocity(mm->get_velocity()); + drag_event->set_position(position); + drag_event->set_relative(relative); + drag_event->set_velocity(get_last_mouse_velocity()); event_dispatch_function(drag_event); } @@ -710,7 +712,6 @@ void Input::set_gyroscope(const Vector3 &p_gyroscope) { } void Input::set_mouse_position(const Point2 &p_posf) { - mouse_velocity_track.update(p_posf - mouse_pos); mouse_pos = p_posf; } diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index 3e1c9d2e4a..21bf566b1b 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -820,7 +820,7 @@ String ResourceLoader::_path_remap(const String &p_path, bool *r_translation_rem } String l = res_remaps[i].substr(split + 1).strip_edges(); int score = TranslationServer::get_singleton()->compare_locales(locale, l); - if (score > best_score) { + if (score > 0 && score >= best_score) { new_path = res_remaps[i].left(split); best_score = score; if (score == 10) { diff --git a/core/string/locales.h b/core/string/locales.h index 9ef6dee5ac..32d6608ec2 100644 --- a/core/string/locales.h +++ b/core/string/locales.h @@ -42,6 +42,7 @@ static const char *locale_renames[][2] = { { "in", "id" }, // Indonesian { "iw", "he" }, // Hebrew { "no", "nb" }, // Norwegian Bokmål + { "C", "en" }, // Locale is not set, fallback to English. { nullptr, nullptr } }; diff --git a/core/string/translation.cpp b/core/string/translation.cpp index 674098b06c..355ee238e8 100644 --- a/core/string/translation.cpp +++ b/core/string/translation.cpp @@ -544,7 +544,7 @@ Ref<Translation> TranslationServer::get_translation_object(const String &p_local String l = t->get_locale(); int score = compare_locales(p_locale, l); - if (score > best_score) { + if (score > 0 && score >= best_score) { res = t; best_score = score; if (score == 10) { @@ -566,8 +566,6 @@ StringName TranslationServer::translate(const StringName &p_message, const Strin return p_message; } - ERR_FAIL_COND_V_MSG(locale.length() < 2, p_message, "Could not translate message as configured locale '" + locale + "' is invalid."); - StringName res = _get_message_from_translations(p_message, p_context, locale, false); if (!res && fallback.length() >= 2) { @@ -589,8 +587,6 @@ StringName TranslationServer::translate_plural(const StringName &p_message, cons return p_message_plural; } - ERR_FAIL_COND_V_MSG(locale.length() < 2, p_message, "Could not translate message as configured locale '" + locale + "' is invalid."); - StringName res = _get_message_from_translations(p_message, p_context, locale, true, p_message_plural, p_n); if (!res && fallback.length() >= 2) { @@ -617,13 +613,17 @@ StringName TranslationServer::_get_message_from_translations(const StringName &p String l = t->get_locale(); int score = compare_locales(p_locale, l); - if (score > best_score) { + if (score > 0 && score >= best_score) { StringName r; if (!plural) { - res = t->get_message(p_message, p_context); + r = t->get_message(p_message, p_context); } else { - res = t->get_plural_message(p_message, p_message_plural, p_n, p_context); + r = t->get_plural_message(p_message, p_message_plural, p_n, p_context); + } + if (!r) { + continue; } + res = r; best_score = score; if (score == 10) { break; // Exact match, skip the rest. |