diff --git a/data/language/en-GB.txt b/data/language/en-GB.txt index 5a16c38273..c961ad5969 100644 --- a/data/language/en-GB.txt +++ b/data/language/en-GB.txt @@ -2885,7 +2885,7 @@ STR_5755 :Incorrect Software Version (Server is using {STRING}) STR_5756 :Bad Password STR_5757 :Server Full STR_5758 :{OUTLINE}{GREEN}{STRING} has joined the game -STR_5759 :Downloading map … ({INT32} / {INT32}) KiB +STR_5759 :Downloading map … STR_5760 :Hong Kong Dollars (HK$) STR_5761 :New Taiwan Dollar (NT$) STR_5762 :Chinese Yuan (CN¥) @@ -3449,7 +3449,7 @@ STR_6374 :C STR_6375 :Unknown Ride STR_6376 :{WINDOW_COLOUR_2}Ride vehicle:{NEWLINE}{BLACK}{STRINGID} for {STRINGID} STR_6377 :{WINDOW_COLOUR_2}Type: {BLACK}{STRINGID} for {STRINGID} -STR_6378 :Receiving objects list: {INT32} / {INT32} +STR_6378 :Receiving objects list… STR_6379 :Received invalid data STR_6380 :Update available! STR_6381 :Join OpenRCT2 Discord! @@ -3713,6 +3713,8 @@ STR_6638 :Enlarged UI STR_6639 :Modifies the interface to be more suitable for touch usage STR_6640 :Edit asset packs… STR_6641 :Loading/progress window +STR_6642 :{STRING} ({COMMA32} / {COMMA32}) +STR_6643 :{STRING} ({COMMA32} / {COMMA32} KiB) ############# # Scenarios # diff --git a/src/openrct2-ui/WindowManager.cpp b/src/openrct2-ui/WindowManager.cpp index c6e21df348..cc0dc13c37 100644 --- a/src/openrct2-ui/WindowManager.cpp +++ b/src/openrct2-ui/WindowManager.cpp @@ -346,7 +346,8 @@ public: { uint32_t currentProgress = intent->GetUIntExtra(INTENT_EXTRA_PROGRESS_OFFSET); uint32_t totalCount = intent->GetUIntExtra(INTENT_EXTRA_PROGRESS_TOTAL); - ProgressWindowSet(currentProgress, totalCount); + StringId format = intent->GetUIntExtra(INTENT_EXTRA_STRING_ID); + ProgressWindowSet(currentProgress, totalCount, format); return nullptr; } diff --git a/src/openrct2-ui/windows/ProgressWindow.cpp b/src/openrct2-ui/windows/ProgressWindow.cpp index 7d56ab873e..00f6aebfa2 100644 --- a/src/openrct2-ui/windows/ProgressWindow.cpp +++ b/src/openrct2-ui/windows/ProgressWindow.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -70,8 +71,11 @@ namespace OpenRCT2::Ui::Windows { private: close_callback _onClose = nullptr; - std::string _captionTemplate; + + StringId _progressFormat; + std::string _progressTitle; std::string _currentCaption; + uint32_t _currentProgress; uint32_t _totalCount; int8_t style = -1; @@ -148,18 +152,22 @@ namespace OpenRCT2::Ui::Windows { if (_totalCount > 0) { - std::stringstream caption; - caption << _captionTemplate; - caption << " (" << _currentProgress << " / " << _totalCount << ")"; - _currentCaption = caption.str(); + auto ft = Formatter(); + ft.Add(_progressTitle.c_str()); + ft.Add(_currentProgress); + ft.Add(_totalCount); + + _currentCaption = FormatStringIDLegacy(_progressFormat, ft.Data()); } else - _currentCaption = _captionTemplate; + _currentCaption = _progressTitle; // Set window title - auto ft = Formatter::Common(); - ft.Add(STR_STRING); - ft.Add(_currentCaption.c_str()); + { + auto ft = Formatter::Common(); + ft.Add(STR_STRING); + ft.Add(_currentCaption.c_str()); + } } void OnDraw(DrawPixelInfo& dpi) override @@ -195,9 +203,9 @@ namespace OpenRCT2::Ui::Windows GfxDrawSprite(clipDPI, variant.vehicle, ScreenCoordsXY(position, widget.bottom + 1)); } - void SetCaptionTemplate(const std::string& text) + void SetCaption(const std::string& text) { - _captionTemplate = text; + _progressTitle = text; _currentProgress = 0; _totalCount = 0; @@ -209,8 +217,13 @@ namespace OpenRCT2::Ui::Windows _onClose = onClose; } - void SetProgress(uint32_t currentProgress, uint32_t totalCount) + void SetProgress(uint32_t currentProgress, uint32_t totalCount, StringId format) { + if (format == STR_NONE) + _progressFormat = STR_STRING_M_OF_N; + else + _progressFormat = format; + _currentProgress = currentProgress; _totalCount = totalCount; Invalidate(); @@ -233,12 +246,12 @@ namespace OpenRCT2::Ui::Windows WF_10 | WF_TRANSPARENT | WF_CENTRE_SCREEN | WF_STICK_TO_FRONT); } - window->SetCaptionTemplate(text); + window->SetCaption(text); window->SetCloseCallback(onClose); return window; } - void ProgressWindowSet(uint32_t currentProgress, uint32_t totalCount) + void ProgressWindowSet(uint32_t currentProgress, uint32_t totalCount, StringId format) { auto window = WindowFindByClass(WindowClass::ProgressWindow); if (window == nullptr) @@ -246,7 +259,7 @@ namespace OpenRCT2::Ui::Windows return; } auto progressWindow = static_cast(window); - progressWindow->SetProgress(currentProgress, totalCount); + progressWindow->SetProgress(currentProgress, totalCount, format); } // Closes the window, deliberately *without* executing the callback. diff --git a/src/openrct2-ui/windows/Window.h b/src/openrct2-ui/windows/Window.h index 653140e81d..66cd1e03fc 100644 --- a/src/openrct2-ui/windows/Window.h +++ b/src/openrct2-ui/windows/Window.h @@ -168,7 +168,7 @@ namespace OpenRCT2::Ui::Windows void WindowNetworkStatusClose(); WindowBase* ProgressWindowOpen(const std::string& text, close_callback onClose = nullptr); - void ProgressWindowSet(uint32_t currentProgress, uint32_t totalCount); + void ProgressWindowSet(uint32_t currentProgress, uint32_t totalCount, StringId format = STR_NONE); void ProgressWindowClose(); void WindowTextInputKey(WindowBase* w, uint32_t keycode); diff --git a/src/openrct2/Context.cpp b/src/openrct2/Context.cpp index c2fa8518ca..50ea85c61c 100644 --- a/src/openrct2/Context.cpp +++ b/src/openrct2/Context.cpp @@ -653,11 +653,12 @@ namespace OpenRCT2 ContextOpenIntent(&intent); } - void SetProgress(uint32_t currentProgress, uint32_t totalCount) override + void SetProgress(uint32_t currentProgress, uint32_t totalCount, StringId format = STR_NONE) override { auto intent = Intent(INTENT_ACTION_PROGRESS_SET); intent.PutExtra(INTENT_EXTRA_PROGRESS_OFFSET, currentProgress); intent.PutExtra(INTENT_EXTRA_PROGRESS_TOTAL, totalCount); + intent.PutExtra(INTENT_EXTRA_STRING_ID, format); ContextOpenIntent(&intent); } diff --git a/src/openrct2/Context.h b/src/openrct2/Context.h index 88ea5b391c..39335fb622 100644 --- a/src/openrct2/Context.h +++ b/src/openrct2/Context.h @@ -160,7 +160,7 @@ namespace OpenRCT2 virtual void DisposeDrawingEngine() abstract; virtual void OpenProgress(StringId captionStringId) abstract; - virtual void SetProgress(uint32_t currentProgress, uint32_t totalCount) abstract; + virtual void SetProgress(uint32_t currentProgress, uint32_t totalCount, StringId format = STR_NONE) abstract; virtual void CloseProgress() abstract; virtual bool LoadParkFromFile( diff --git a/src/openrct2/localisation/StringIds.h b/src/openrct2/localisation/StringIds.h index ac760410c4..178b0d76fe 100644 --- a/src/openrct2/localisation/StringIds.h +++ b/src/openrct2/localisation/StringIds.h @@ -1689,6 +1689,8 @@ enum : StringId STR_LOADING_TITLE_SEQUENCE = 6637, STR_THEME_LOADING_WINDOW = 6641, + STR_STRING_M_OF_N = 6642, + STR_STRING_M_OF_N_KIB = 6643, // Have to include resource strings (from scenarios and objects) for the time being now that language is partially working /* MAX_STR_COUNT = 32768 */ // MAX_STR_COUNT - upper limit for number of strings, not the current count strings diff --git a/src/openrct2/network/NetworkBase.cpp b/src/openrct2/network/NetworkBase.cpp index ce4eef6677..14bc539a30 100644 --- a/src/openrct2/network/NetworkBase.cpp +++ b/src/openrct2/network/NetworkBase.cpp @@ -2782,8 +2782,11 @@ void NetworkBase::Client_Handle_MAP([[maybe_unused]] NetworkConnection& connecti chunk_buffer.resize(size); } + const auto currentProgressKiB = (offset + chunksize) / 1024; + const auto totalSizeKiB = size / 1024; + OpenNetworkProgress(STR_MULTIPLAYER_DOWNLOADING_MAP); - GetContext().SetProgress((offset + chunksize) / 1024, size / 1024); + GetContext().SetProgress(currentProgressKiB, totalSizeKiB, STR_STRING_M_OF_N_KIB); std::memcpy(&chunk_buffer[offset], const_cast(static_cast(packet.Read(chunksize))), chunksize); if (offset + chunksize == size) diff --git a/src/openrct2/windows/Intent.h b/src/openrct2/windows/Intent.h index a9365b7341..3707b6d96b 100644 --- a/src/openrct2/windows/Intent.h +++ b/src/openrct2/windows/Intent.h @@ -131,4 +131,5 @@ enum INTENT_EXTRA_SCENERY_GROUP_ENTRY_INDEX, INTENT_EXTRA_PROGRESS_OFFSET, INTENT_EXTRA_PROGRESS_TOTAL, + INTENT_EXTRA_STRING_ID, };