From a943abdbb3abd2b46610e62e3ffbb9a396f630f4 Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Mon, 20 May 2024 20:14:48 +0200 Subject: [PATCH] Keep same style while window is open, but random at the start --- src/openrct2-ui/windows/ProgressWindow.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/openrct2-ui/windows/ProgressWindow.cpp b/src/openrct2-ui/windows/ProgressWindow.cpp index 083eed4748..75e5d31bc3 100644 --- a/src/openrct2-ui/windows/ProgressWindow.cpp +++ b/src/openrct2-ui/windows/ProgressWindow.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include namespace OpenRCT2::Ui::Windows @@ -71,7 +72,7 @@ namespace OpenRCT2::Ui::Windows std::string _currentCaption; uint32_t _currentProgress; uint32_t _totalCount; - uint8_t style; + int8_t style = -1; public: void OnOpen() override @@ -103,8 +104,21 @@ namespace OpenRCT2::Ui::Windows void ApplyStyle() { - style = nextStyle++; - nextStyle %= std::size(kVehicleStyles); + if (style >= 0) + { + // Take the next available style, rotating + style = nextStyle++; + nextStyle %= std::size(kVehicleStyles); + } + else + { + // Pick a random style to start off with + std::random_device r; + auto upperBound = static_cast(std::size(kVehicleStyles)) - 1; + std::uniform_int_distribution uniform_dist(0, upperBound); + std::default_random_engine e(r()); + style = static_cast(uniform_dist(e)); + } } void PrepareCaption() @@ -164,7 +178,6 @@ namespace OpenRCT2::Ui::Windows _currentProgress = 0; _totalCount = 0; - ApplyStyle(); Invalidate(); }