Improve edited scene layout direction detection.

This commit is contained in:
Pāvels Nadtočajevs
2025-04-27 17:32:38 +03:00
parent e37c6261ea
commit 03048aa94a
5 changed files with 14 additions and 2 deletions

View File

@ -381,6 +381,10 @@ String TranslationServer::get_locale() const {
return locale;
}
void TranslationServer::set_fallback_locale(const String &p_locale) {
fallback = p_locale;
}
String TranslationServer::get_fallback_locale() const {
return fallback;
}

View File

@ -104,6 +104,7 @@ public:
void set_locale(const String &p_locale);
String get_locale() const;
void set_fallback_locale(const String &p_locale);
String get_fallback_locale() const;
Ref<Translation> get_translation_object(const String &p_locale);

View File

@ -426,6 +426,11 @@ void EditorNode::_update_from_settings() {
Viewport::DefaultCanvasItemTextureRepeat tr = (Viewport::DefaultCanvasItemTextureRepeat)current_repeat;
scene_root->set_default_canvas_item_texture_repeat(tr);
}
String current_fallback_locale = GLOBAL_GET("internationalization/locale/fallback");
if (current_fallback_locale != TranslationServer::get_singleton()->get_fallback_locale()) {
TranslationServer::get_singleton()->set_fallback_locale(current_fallback_locale);
scene_root->propagate_notification(Control::NOTIFICATION_LAYOUT_DIRECTION_CHANGED);
}
RS::DOFBokehShape dof_shape = RS::DOFBokehShape(int(GLOBAL_GET("rendering/camera/depth_of_field/depth_of_field_bokeh_shape")));
RS::get_singleton()->camera_attributes_set_dof_blur_bokeh_shape(dof_shape);

View File

@ -3404,7 +3404,8 @@ bool Control::is_layout_rtl() const {
String locale = OS::get_singleton()->get_locale();
data.is_rtl = TS->is_locale_right_to_left(locale);
} else {
String locale = TranslationServer::get_singleton()->get_tool_locale();
const Ref<Translation> &t = TranslationServer::get_singleton()->get_translation_object(TranslationServer::get_singleton()->get_locale());
String locale = t.is_valid() ? t->get_locale() : TranslationServer::get_singleton()->get_fallback_locale();
data.is_rtl = TS->is_locale_right_to_left(locale);
}
return data.is_rtl;

View File

@ -2868,7 +2868,8 @@ bool Window::is_layout_rtl() const {
String locale = OS::get_singleton()->get_locale();
return TS->is_locale_right_to_left(locale);
} else {
String locale = TranslationServer::get_singleton()->get_tool_locale();
const Ref<Translation> &t = TranslationServer::get_singleton()->get_translation_object(TranslationServer::get_singleton()->get_locale());
String locale = t.is_valid() ? t->get_locale() : TranslationServer::get_singleton()->get_fallback_locale();
return TS->is_locale_right_to_left(locale);
}
}