mirror of
				https://github.com/hedge-dev/UnleashedRecomp.git
				synced 2025-10-30 07:11:05 +00:00 
			
		
		
		
	Block exit button from terminating the installer while it's in progress. (#300)
* Block exit button from terminating the installer while it's in progress. * Fix quit prompt not appearing when closing the game from the taskbar. --------- Co-authored-by: Skyth <19259897+blueskythlikesclouds@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									e7cc5a858e
								
							
						
					
					
						commit
						266d436c28
					
				
					 7 changed files with 45 additions and 15 deletions
				
			
		|  | @ -6973,14 +6973,14 @@ PPC_FUNC(sub_82E328D8) | |||
| class SDLEventListenerForPSOCaching : public SDLEventListener | ||||
| { | ||||
| public: | ||||
|     void OnSDLEvent(SDL_Event* event) override  | ||||
|     bool OnSDLEvent(SDL_Event* event) override  | ||||
|     { | ||||
|         if (event->type != SDL_QUIT) | ||||
|             return; | ||||
|             return false; | ||||
| 
 | ||||
|         std::lock_guard lock(g_pipelineCacheMutex); | ||||
|         if (g_pipelineStatesToCache.empty()) | ||||
|             return; | ||||
|             return false; | ||||
| 
 | ||||
|         FILE* f = fopen("send_this_file_to_skyth.txt", "ab"); | ||||
|         if (f != nullptr) | ||||
|  | @ -7095,6 +7095,8 @@ public: | |||
| 
 | ||||
|             fclose(f); | ||||
|         } | ||||
| 
 | ||||
|         return false; | ||||
|     } | ||||
| }; | ||||
| SDLEventListenerForPSOCaching g_sdlEventListenerForPSOCaching; | ||||
|  |  | |||
|  | @ -9,10 +9,10 @@ static class FrontendListener : public SDLEventListener | |||
|     bool m_isF8KeyDown = false; | ||||
| 
 | ||||
| public: | ||||
|     void OnSDLEvent(SDL_Event* event) override | ||||
|     bool OnSDLEvent(SDL_Event* event) override | ||||
|     { | ||||
|         if (!Config::HUDToggleHotkey || OptionsMenu::s_isVisible) | ||||
|             return; | ||||
|             return false; | ||||
| 
 | ||||
|         switch (event->type) | ||||
|         { | ||||
|  | @ -34,6 +34,8 @@ public: | |||
|             m_isF8KeyDown = event->key.keysym.sym != SDLK_F8; | ||||
|             break; | ||||
|         } | ||||
| 
 | ||||
|         return false; | ||||
|     } | ||||
| } | ||||
| g_frontendListener; | ||||
|  |  | |||
|  | @ -121,10 +121,10 @@ public: | |||
|         } | ||||
|     } | ||||
| 
 | ||||
|     void OnSDLEvent(SDL_Event* event) override | ||||
|     bool OnSDLEvent(SDL_Event* event) override | ||||
|     { | ||||
|         if (!hid::IsInputAllowed()) | ||||
|             return; | ||||
|             return false; | ||||
| 
 | ||||
|         switch (event->type) | ||||
|         { | ||||
|  | @ -202,6 +202,8 @@ public: | |||
|                 ms_touchpadFingerCount--; | ||||
|                 break; | ||||
|         } | ||||
| 
 | ||||
|         return false; | ||||
|     } | ||||
| } | ||||
| g_sdlEventListenerForInputPatches; | ||||
|  |  | |||
|  | @ -4,7 +4,7 @@ class ISDLEventListener | |||
| { | ||||
| public: | ||||
|     virtual ~ISDLEventListener() = default; | ||||
|     virtual void OnSDLEvent(SDL_Event* event) = 0; | ||||
|     virtual bool OnSDLEvent(SDL_Event* event) = 0; | ||||
| }; | ||||
| 
 | ||||
| extern std::vector<ISDLEventListener*>& GetEventListeners(); | ||||
|  | @ -17,5 +17,5 @@ public: | |||
|         GetEventListeners().emplace_back(this); | ||||
|     } | ||||
| 
 | ||||
|     void OnSDLEvent(SDL_Event* event) override {} | ||||
|     bool OnSDLEvent(SDL_Event* event) override { return false; } | ||||
| }; | ||||
|  |  | |||
|  | @ -24,7 +24,12 @@ int Window_OnSDLEvent(void*, SDL_Event* event) | |||
|         ImGui_ImplSDL2_ProcessEvent(event); | ||||
| 
 | ||||
|     for (auto listener : GetEventListeners()) | ||||
|         listener->OnSDLEvent(event); | ||||
|     { | ||||
|         if (listener->OnSDLEvent(event)) | ||||
|         { | ||||
|             return 0; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     switch (event->type) | ||||
|     { | ||||
|  |  | |||
|  | @ -170,10 +170,25 @@ static std::string g_creditsStr; | |||
| class SDLEventListenerForInstaller : public SDLEventListener | ||||
| { | ||||
| public: | ||||
|     void OnSDLEvent(SDL_Event *event) override | ||||
|     bool OnSDLEvent(SDL_Event *event) override | ||||
|     { | ||||
|         if (!InstallerWizard::s_isVisible || !g_currentMessagePrompt.empty() || g_currentPickerVisible || !hid::IsInputAllowed()) | ||||
|             return; | ||||
|         if (!InstallerWizard::s_isVisible) | ||||
|             return false; | ||||
| 
 | ||||
|         bool noModals = g_currentMessagePrompt.empty() && !g_currentPickerVisible; | ||||
|         if (event->type == SDL_QUIT && g_currentPage == WizardPage::Installing) | ||||
|         { | ||||
|             // Pretend the back button was pressed if the user tried quitting during installation.
 | ||||
|             // This condition is above the rest of the event processing as we want to block the exit
 | ||||
|             // button while there's confirmation message is open as well.
 | ||||
|             if (noModals) | ||||
|                 g_currentCursorBack = true; | ||||
| 
 | ||||
|             return true; | ||||
|         } | ||||
| 
 | ||||
|         if (!noModals || !hid::IsInputAllowed()) | ||||
|             return false; | ||||
| 
 | ||||
|         constexpr float AxisValueRange = 32767.0f; | ||||
|         constexpr float AxisTapRange = 0.5f; | ||||
|  | @ -326,6 +341,8 @@ public: | |||
| 
 | ||||
|             g_currentCursorIndex = newCursorIndex; | ||||
|         } | ||||
| 
 | ||||
|         return false; | ||||
|     } | ||||
| } | ||||
| g_sdlEventListenerForInstaller; | ||||
|  |  | |||
|  | @ -48,10 +48,10 @@ int g_cancelButtonIndex; | |||
| class SDLEventListenerForMessageWindow : public SDLEventListener | ||||
| { | ||||
| public: | ||||
|     void OnSDLEvent(SDL_Event* event) override | ||||
|     bool OnSDLEvent(SDL_Event* event) override | ||||
|     { | ||||
|         if (App::s_isInit || !MessageWindow::s_isVisible || !hid::IsInputAllowed()) | ||||
|             return; | ||||
|             return false; | ||||
| 
 | ||||
|         constexpr float axisValueRange = 32767.0f; | ||||
|         constexpr float axisTapRange = 0.5f; | ||||
|  | @ -142,6 +142,8 @@ public: | |||
|                 break; | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         return false; | ||||
|     } | ||||
| } | ||||
| g_sdlEventListenerForMessageWindow; | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Darío
						Darío