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:
Darío
2025-02-06 19:21:18 -03:00
committed by GitHub
parent e7cc5a858e
commit 266d436c28
7 changed files with 45 additions and 15 deletions
+6 -1
View File
@@ -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)
{
+20 -3
View File
@@ -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;
+4 -2
View File
@@ -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;