diff --git a/Common/System/OSD.h b/Common/System/OSD.h index a229623fc3..144850ba4b 100644 --- a/Common/System/OSD.h +++ b/Common/System/OSD.h @@ -60,7 +60,7 @@ public: void Show(OSDType type, std::string_view text, std::string_view text2, std::string_view icon, float duration_s = 0.0f, const char *id = nullptr); void ShowOnOff(std::string_view message, bool on, float duration_s = 0.0f); - void CancelById(std::string_view id); + void CancelById(std::string_view id); // Deletes the message immediately with no animation. bool IsEmpty() const { return entries_.empty(); } // Shortcut to skip rendering. diff --git a/Core/Screenshot.cpp b/Core/Screenshot.cpp index 38662b2a72..be137ba9a6 100644 --- a/Core/Screenshot.cpp +++ b/Core/Screenshot.cpp @@ -524,6 +524,9 @@ void TakeUserScreenshot() { type = ScreenshotType::Output; } + // Close any earlier screenshot popups, so they don't end up in the next one. + g_OSD.CancelById("screenshot_link"); + ScheduleScreenshot(filename, g_Config.bScreenshotsAsPNG ? ScreenshotFormat::PNG : ScreenshotFormat::JPG, type, -1, [filename](ScreenshotResult result) { if (result == ScreenshotResult::Success) { const std::string friendlyPath = GetFriendlyPath(filename); diff --git a/SDL/CocoaBarItems.mm b/SDL/CocoaBarItems.mm index b886626e28..3d6c4d3143 100644 --- a/SDL/CocoaBarItems.mm +++ b/SDL/CocoaBarItems.mm @@ -17,6 +17,7 @@ #include "Core/System.h" #include "Core/Core.h" #include "Core/SaveState.h" +#include "Core/Screenshot.h" #include "Core/RetroAchievements.h" #include "Core/ELF/ParamSFO.h" #include "Core/HLE/sceNet.h" @@ -37,8 +38,6 @@ extern "C" { #endif -extern bool g_TakeScreenshot; - typedef BOOL (^MenuCondition)(void); // A menu item that carries its own action, and optionally how to tell whether it's checked, @@ -425,7 +424,7 @@ static bool CanUseSaveStates(bool isSaveAction) { [self addSeparatorTo:menu]; [self addItem:DesktopUI("Take Screenshot") to:menu action:^{ - g_TakeScreenshot = true; + TakeUserScreenshot(); }].enabledWhen = inGame; [self addItem:DesktopUI("Save frame dump") to:menu action:^{ System_PostUIMessage(UIMessage::SAVE_FRAME_DUMP); diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 73ba801d2f..e15e17c9da 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -105,8 +105,6 @@ using namespace std::placeholders; static AVIDump avi; #endif -extern bool g_TakeScreenshot; - // Handles control rotation due to internal screen rotation. void EmuScreen::UpdatePSPButtons(uint32_t bitsToSet, uint32_t bitsToClear) { if (!IsOnTop()) { diff --git a/UI/ImDebugger/ImDebugger.cpp b/UI/ImDebugger/ImDebugger.cpp index 634d521db1..8f32259f25 100644 --- a/UI/ImDebugger/ImDebugger.cpp +++ b/UI/ImDebugger/ImDebugger.cpp @@ -11,10 +11,12 @@ #include "Common/Log/LogManager.h" #include "Common/TimeUtil.h" #include "Common/Data/Text/I18n.h" +#include "Common/System/NativeApp.h" #include "Core/RetroAchievements.h" #include "Core/Config.h" #include "Core/System.h" #include "Core/SaveState.h" +#include "Core/Screenshot.h" #include "Core/WebServer.h" #include "Core/Debugger/MemBlockInfo.h" #include "Core/Debugger/LineInfo.h" @@ -72,7 +74,6 @@ #include "UI/GameInfoCache.h" #include "UI/PauseScreen.h" -extern bool g_TakeScreenshot; static ImVec4 g_normalTextColor; void ShowInMemoryViewerMenuItem(uint32_t addr, ImControl &control) { @@ -2642,7 +2643,7 @@ void ImDebugger::Frame(MIPSDebugInterface *mipsDebug, GPUCommon *gpuDebug, Draw: ImGui::MenuItem("Auto save/load symbols (PSP/SYSTEM/SYMBOLS)", nullptr, &g_Config.bAutoSaveLoadSymbols); ImGui::Separator(); if (ImGui::MenuItem("Take screenshot")) { - g_TakeScreenshot = true; + TakeUserScreenshot(); } ImGui::MenuItem("Save screenshot as .png", nullptr, &g_Config.bScreenshotsAsPNG); if (ImGui::MenuItem("Restart graphics")) { diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index d7e397db1e..cdc5528810 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -184,8 +184,6 @@ void SaveFrameDump(); ScreenManager *g_screenManager; std::string config_filename; -// Really need to clean this mess of globals up... but instead I add more :P -bool g_TakeScreenshot; static bool resized = false; static int renderCounter = 0; diff --git a/UI/OnScreenDisplay.cpp b/UI/OnScreenDisplay.cpp index 79ec0d3357..c0af73f7a8 100644 --- a/UI/OnScreenDisplay.cpp +++ b/UI/OnScreenDisplay.cpp @@ -24,8 +24,6 @@ static inline const char *DeNull(const char *ptr) { return ptr ? ptr : ""; } -extern bool g_TakeScreenshot; - static const float g_atlasIconSize = 36.0f; // Align only matters here for the ASCII-only flag. @@ -107,10 +105,6 @@ static void RenderLeaderboardTracker(UIContext &dc, const Bounds &bounds, const } void OnScreenMessagesView::Draw(UIContext &dc) { - if (g_TakeScreenshot) { - return; - } - dc.Flush(); double now = time_now_d();