diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 3beb68e455..93c91721e3 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -4,6 +4,7 @@ - Feature: [#21913] [Plugin] Allow precise and safe control of peep animations. - Improved: [#21981] Rendering performance of the map window has been improved considerably. - Improved: [#21981] The map window now defaults to showing as much of the map as fits the screen. +- Improved: [#21983] Taking a screenshot now shows a message again, closing when taking another. - Change: [#7248] Small mini-maps are now centred in the map window. - Fix: [#13294] Map corners are cut off in some directions (original bug). - Fix: [#21974] No reason specified when attempting to place benches, lamps, or bins on path with no unconnected edges (original bug). diff --git a/src/openrct2-ui/WindowManager.cpp b/src/openrct2-ui/WindowManager.cpp index f9f37aa088..3e5ed0baa4 100644 --- a/src/openrct2-ui/WindowManager.cpp +++ b/src/openrct2-ui/WindowManager.cpp @@ -209,14 +209,14 @@ public: } } - WindowBase* ShowError(StringId title, StringId message, const Formatter& args) override + WindowBase* ShowError(StringId title, StringId message, const Formatter& args, bool autoClose /* = false */) override { - return ErrorOpen(title, message, args); + return ErrorOpen(title, message, args, autoClose); } - WindowBase* ShowError(std::string_view title, std::string_view message) override + WindowBase* ShowError(std::string_view title, std::string_view message, bool autoClose /* = false */) override { - return ErrorOpen(title, message); + return ErrorOpen(title, message, autoClose); } WindowBase* OpenIntent(Intent* intent) override diff --git a/src/openrct2-ui/windows/Error.cpp b/src/openrct2-ui/windows/Error.cpp index 192492711f..c835b619b2 100644 --- a/src/openrct2-ui/windows/Error.cpp +++ b/src/openrct2-ui/windows/Error.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -37,11 +38,13 @@ static Widget window_error_widgets[] = { std::string _text; uint16_t _numLines; uint8_t _staleCount; + bool _autoClose; public: - ErrorWindow(std::string text, uint16_t numLines) + ErrorWindow(std::string text, uint16_t numLines, bool autoClose) : _text(std::move(text)) , _numLines(numLines) + , _autoClose(autoClose) { } @@ -109,9 +112,18 @@ static Widget window_error_widgets[] = { Close(); } } + + void OnUpdate() override + { + // Automatically close previous screenshot messages before new screenshot is taken + if (_autoClose && gScreenshotCountdown > 0) + { + Close(); + } + } }; - WindowBase* ErrorOpen(std::string_view title, std::string_view message) + WindowBase* ErrorOpen(std::string_view title, std::string_view message, bool autoClose) { std::string buffer = "{BLACK}"; buffer.append(title); @@ -160,16 +172,16 @@ static Widget window_error_widgets[] = { windowPosition.y = std::min(windowPosition.y - height - 40, maxY); } - auto errorWindow = std::make_unique(std::move(buffer), numLines); + auto errorWindow = std::make_unique(std::move(buffer), numLines, autoClose); return WindowCreate( std::move(errorWindow), WindowClass::Error, windowPosition, width, height, WF_STICK_TO_FRONT | WF_TRANSPARENT | WF_RESIZABLE); } - WindowBase* ErrorOpen(StringId title, StringId message, const Formatter& args) + WindowBase* ErrorOpen(StringId title, StringId message, const Formatter& args, bool autoClose) { auto titlez = FormatStringIDLegacy(title, args.Data()); auto messagez = FormatStringIDLegacy(message, args.Data()); - return ErrorOpen(titlez, messagez); + return ErrorOpen(titlez, messagez, autoClose); } } // namespace OpenRCT2::Ui::Windows diff --git a/src/openrct2-ui/windows/Window.h b/src/openrct2-ui/windows/Window.h index 2219833e1f..bbeb232467 100644 --- a/src/openrct2-ui/windows/Window.h +++ b/src/openrct2-ui/windows/Window.h @@ -107,8 +107,8 @@ namespace OpenRCT2::Ui::Windows WindowBase* ScenarioselectOpen(scenarioselect_callback callback); WindowBase* ScenarioselectOpen(std::function callback); - WindowBase* ErrorOpen(StringId title, StringId message, const class Formatter& formatter); - WindowBase* ErrorOpen(std::string_view title, std::string_view message); + WindowBase* ErrorOpen(StringId title, StringId message, const class Formatter& formatter, bool autoClose = false); + WindowBase* ErrorOpen(std::string_view title, std::string_view message, bool autoClose = false); WindowBase* LoadsaveOpen( int32_t type, std::string_view defaultPath, std::function callback, diff --git a/src/openrct2/Context.cpp b/src/openrct2/Context.cpp index 653dc0a0b6..e2e671cbea 100644 --- a/src/openrct2/Context.cpp +++ b/src/openrct2/Context.cpp @@ -1570,10 +1570,10 @@ void ContextForceCloseWindowByClass(WindowClass windowClass) windowManager->ForceClose(windowClass); } -WindowBase* ContextShowError(StringId title, StringId message, const Formatter& args) +WindowBase* ContextShowError(StringId title, StringId message, const Formatter& args, const bool autoClose /* = false */) { auto windowManager = GetContext()->GetUiContext()->GetWindowManager(); - return windowManager->ShowError(title, message, args); + return windowManager->ShowError(title, message, args, autoClose); } void ContextHandleInput() diff --git a/src/openrct2/Context.h b/src/openrct2/Context.h index 380242729a..8f3b463008 100644 --- a/src/openrct2/Context.h +++ b/src/openrct2/Context.h @@ -221,7 +221,7 @@ void ContextSetCursorTrap(bool value); WindowBase* ContextOpenWindow(WindowClass wc); WindowBase* ContextOpenDetailWindow(uint8_t type, int32_t id); WindowBase* ContextOpenWindowView(uint8_t view); -WindowBase* ContextShowError(StringId title, StringId message, const class Formatter& args); +WindowBase* ContextShowError(StringId title, StringId message, const class Formatter& args, bool autoClose = false); WindowBase* ContextOpenIntent(Intent* intent); void ContextBroadcastIntent(Intent* intent); void ContextForceCloseWindowByClass(WindowClass wc); diff --git a/src/openrct2/interface/Screenshot.cpp b/src/openrct2/interface/Screenshot.cpp index 54292df549..51f8bcd272 100644 --- a/src/openrct2/interface/Screenshot.cpp +++ b/src/openrct2/interface/Screenshot.cpp @@ -26,6 +26,7 @@ #include "../drawing/X8DrawingEngine.h" #include "../localisation/Formatter.h" #include "../localisation/Localisation.h" +#include "../paint/Painter.h" #include "../platform/Platform.h" #include "../util/Util.h" #include "../world/Climate.h" @@ -91,10 +92,17 @@ void ScreenshotCheck() if (!screenshotPath.empty()) { OpenRCT2::Audio::Play(OpenRCT2::Audio::SoundId::WindowOpen, 100, ContextGetWidth() / 2); + + // Show user that screenshot saved successfully + const auto filename = Path::GetFileName(screenshotPath); + Formatter ft; + ft.Add(STR_STRING); + ft.Add(filename.c_str()); + ContextShowError(STR_SCREENSHOT_SAVED_AS, STR_NONE, ft, true); } else { - ContextShowError(STR_SCREENSHOT_FAILED, STR_NONE, {}); + ContextShowError(STR_SCREENSHOT_FAILED, STR_NONE, {}, true); } // redraw_weather(); @@ -384,12 +392,12 @@ void ScreenshotGiant() Formatter ft; ft.Add(STR_STRING); ft.Add(filename.c_str()); - ContextShowError(STR_SCREENSHOT_SAVED_AS, STR_NONE, ft); + ContextShowError(STR_SCREENSHOT_SAVED_AS, STR_NONE, ft, true); } catch (const std::exception& e) { LOG_ERROR("%s", e.what()); - ContextShowError(STR_SCREENSHOT_FAILED, STR_NONE, {}); + ContextShowError(STR_SCREENSHOT_FAILED, STR_NONE, {}, true); } ReleaseDPI(dpi); diff --git a/src/openrct2/ui/DummyWindowManager.cpp b/src/openrct2/ui/DummyWindowManager.cpp index bb88203631..a00e0964c2 100644 --- a/src/openrct2/ui/DummyWindowManager.cpp +++ b/src/openrct2/ui/DummyWindowManager.cpp @@ -27,11 +27,12 @@ namespace OpenRCT2::Ui { return nullptr; } - WindowBase* ShowError(StringId /*title*/, StringId /*message*/, const Formatter& /*formatter*/) override + WindowBase* ShowError( + StringId /*title*/, StringId /*message*/, const Formatter& /*formatter*/, bool /*autoClose*/) override { return nullptr; } - WindowBase* ShowError(std::string_view /*title*/, std::string_view /*message*/) override + WindowBase* ShowError(std::string_view /*title*/, std::string_view /*message*/, bool /*autoClose*/) override { return nullptr; } diff --git a/src/openrct2/ui/WindowManager.h b/src/openrct2/ui/WindowManager.h index 399e347683..ee29a32067 100644 --- a/src/openrct2/ui/WindowManager.h +++ b/src/openrct2/ui/WindowManager.h @@ -33,8 +33,9 @@ namespace OpenRCT2::Ui virtual WindowBase* OpenDetails(uint8_t type, int32_t id) abstract; virtual WindowBase* OpenIntent(Intent* intent) abstract; virtual void BroadcastIntent(const Intent& intent) abstract; - virtual WindowBase* ShowError(StringId title, StringId message, const Formatter& formatter) abstract; - virtual WindowBase* ShowError(std::string_view title, std::string_view message) abstract; + virtual WindowBase* ShowError( + StringId title, StringId message, const Formatter& formatter, bool autoClose = false) abstract; + virtual WindowBase* ShowError(std::string_view title, std::string_view message, bool autoClose = false) abstract; virtual void ForceClose(WindowClass windowClass) abstract; virtual void UpdateMapTooltip() abstract; virtual void HandleInput() abstract;