From ba541c0fcad029461436c6ca6505a05ac055fe8c Mon Sep 17 00:00:00 2001 From: Dario Date: Tue, 3 Dec 2024 23:15:59 -0300 Subject: [PATCH] Add queued update when using files pickers. --- UnleashedRecomp/ui/installer_wizard.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/UnleashedRecomp/ui/installer_wizard.cpp b/UnleashedRecomp/ui/installer_wizard.cpp index fb0d45fc..b4b74322 100644 --- a/UnleashedRecomp/ui/installer_wizard.cpp +++ b/UnleashedRecomp/ui/installer_wizard.cpp @@ -115,6 +115,7 @@ static WizardPage g_currentPage = g_firstPage; static std::string g_currentMessagePrompt = ""; static bool g_currentMessagePromptConfirmation = false; static int g_currentMessageResult = -1; +static bool g_currentMessageUpdateRemaining = false; const char CREDITS_TEXT[] = "Sajid (RIP)"; @@ -620,6 +621,8 @@ static bool ShowFilesPicker(std::list &filePaths) const nfdpathset_t *pathSet; nfdresult_t result = NFD_OpenDialogMultipleU8(&pathSet, nullptr, 0, nullptr); + g_currentMessageUpdateRemaining = true; + if (result == NFD_OKAY) { bool pathsConverted = ConvertPathSet(pathSet, filePaths); @@ -638,6 +641,8 @@ static bool ShowFoldersPicker(std::list &folderPaths) const nfdpathset_t *pathSet; nfdresult_t result = NFD_PickFolderMultipleU8(&pathSet, nullptr); + g_currentMessageUpdateRemaining = true; + if (result == NFD_OKAY) { bool pathsConverted = ConvertPathSet(pathSet, folderPaths); @@ -1019,6 +1024,15 @@ static void DrawMessagePrompt() return; } + if (g_currentMessageUpdateRemaining) + { + // If a blocking function like the files picker is called, we must wait one update before actually showing + // the message box, as a lot of time has passed since the last real update. Otherwise, animations will play + // too quickly and input glitches might happen. + g_currentMessageUpdateRemaining = false; + return; + } + bool messageWindowReturned = false; if (g_currentMessagePromptConfirmation) {