Block exit button from terminating the installer while it's in progress.

This commit is contained in:
Dario 2025-02-06 18:43:16 -03:00
parent 47b1f20679
commit dc39969ccd
7 changed files with 45 additions and 15 deletions

View file

@ -6971,14 +6971,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)
@ -7093,6 +7093,8 @@ public:
fclose(f);
}
return false;
}
};
SDLEventListenerForPSOCaching g_sdlEventListenerForPSOCaching;

View file

@ -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;

View file

@ -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;

View file

@ -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; }
};

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)
{

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 inputAllowed = g_currentMessagePrompt.empty() && !g_currentPickerVisible && hid::IsInputAllowed();
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 (inputAllowed)
g_currentCursorBack = true;
return true;
}
if (!inputAllowed)
return false;
constexpr float AxisValueRange = 32767.0f;
constexpr float AxisTapRange = 0.5f;
@ -326,6 +341,8 @@ public:
g_currentCursorIndex = newCursorIndex;
}
return false;
}
}
g_sdlEventListenerForInstaller;

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;