From 5442b0dd2dc34230f341f57d040095479ef7bfd8 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Tue, 21 May 2024 00:40:08 +0100 Subject: [PATCH] Fix: Make progress bars obey language direction. (#12704) With RTL languages, progress bars should start from the right. --- src/genworld_gui.cpp | 2 +- src/network/network_content_gui.cpp | 2 +- src/network/network_gui.cpp | 2 +- src/newgrf_gui.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp index 827223e932..e8dfa4b999 100644 --- a/src/genworld_gui.cpp +++ b/src/genworld_gui.cpp @@ -1429,7 +1429,7 @@ struct GenerateProgressWindow : public Window { /* Draw the % complete with a bar and a text */ DrawFrameRect(r, COLOUR_GREY, FR_BORDERONLY | FR_LOWERED); Rect br = r.Shrink(WidgetDimensions::scaled.bevel); - DrawFrameRect(br.WithWidth(br.Width() * _gws.percent / 100, false), COLOUR_MAUVE, FR_NONE); + DrawFrameRect(br.WithWidth(br.Width() * _gws.percent / 100, _current_text_dir == TD_RTL), COLOUR_MAUVE, FR_NONE); SetDParam(0, _gws.percent); DrawString(br.left, br.right, CenterBounds(br.top, br.bottom, GetCharacterHeight(FS_NORMAL)), STR_GENERATION_PROGRESS, TC_FROMSTRING, SA_HOR_CENTER); break; diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp index a1a8472b76..8facf62fe4 100644 --- a/src/network/network_content_gui.cpp +++ b/src/network/network_content_gui.cpp @@ -142,7 +142,7 @@ void BaseNetworkContentDownloadStatusWindow::DrawWidget(const Rect &r, WidgetID /* Draw the % complete with a bar and a text */ DrawFrameRect(r, COLOUR_GREY, FR_BORDERONLY | FR_LOWERED); Rect ir = r.Shrink(WidgetDimensions::scaled.bevel); - DrawFrameRect(ir.WithWidth((uint64_t)ir.Width() * this->downloaded_bytes / this->total_bytes, false), COLOUR_MAUVE, FR_NONE); + DrawFrameRect(ir.WithWidth((uint64_t)ir.Width() * this->downloaded_bytes / this->total_bytes, _current_text_dir == TD_RTL), COLOUR_MAUVE, FR_NONE); SetDParam(0, this->downloaded_bytes); SetDParam(1, this->total_bytes); SetDParam(2, this->downloaded_bytes * 100LL / this->total_bytes); diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index e8f20eccf9..e6a45e5ce9 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -2111,7 +2111,7 @@ struct NetworkJoinStatusWindow : Window { progress = 15 + _network_join_bytes * (100 - 15) / _network_join_bytes_total; break; } - DrawFrameRect(ir.WithWidth(ir.Width() * progress / 100, false), COLOUR_MAUVE, FR_NONE); + DrawFrameRect(ir.WithWidth(ir.Width() * progress / 100, _current_text_dir == TD_RTL), COLOUR_MAUVE, FR_NONE); DrawString(ir.left, ir.right, CenterBounds(ir.top, ir.bottom, GetCharacterHeight(FS_NORMAL)), STR_NETWORK_CONNECTING_1 + _network_join_status, TC_FROMSTRING, SA_HOR_CENTER); break; } diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp index 7cf2a5283c..163a1cc709 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -2243,7 +2243,7 @@ struct ScanProgressWindow : public Window { DrawFrameRect(r, COLOUR_GREY, FR_BORDERONLY | FR_LOWERED); Rect ir = r.Shrink(WidgetDimensions::scaled.bevel); uint percent = scanned * 100 / std::max(1U, _settings_client.gui.last_newgrf_count); - DrawFrameRect(ir.WithWidth(ir.Width() * percent / 100, false), COLOUR_MAUVE, FR_NONE); + DrawFrameRect(ir.WithWidth(ir.Width() * percent / 100, _current_text_dir == TD_RTL), COLOUR_MAUVE, FR_NONE); SetDParam(0, percent); DrawString(ir.left, ir.right, CenterBounds(ir.top, ir.bottom, GetCharacterHeight(FS_NORMAL)), STR_GENERATION_PROGRESS, TC_FROMSTRING, SA_HOR_CENTER); break;