mirror of
https://github.com/stenzek/duckstation.git
synced 2025-06-07 12:05:52 +00:00
FullscreenUI: Move UpdateRunIdleState() for system soft-fail to host
That way it's always in the correct state for e.g. memory card shutdown confirmations.
This commit is contained in:
parent
128bab29f8
commit
02234715c5
@ -210,7 +210,6 @@ struct PostProcessingStageInfo
|
|||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// Main
|
// Main
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
static void UpdateRunIdleState();
|
|
||||||
static void PauseForMenuOpen(bool set_pause_menu_open);
|
static void PauseForMenuOpen(bool set_pause_menu_open);
|
||||||
static bool AreAnyDialogsOpen();
|
static bool AreAnyDialogsOpen();
|
||||||
static void ClosePauseMenu();
|
static void ClosePauseMenu();
|
||||||
@ -1122,25 +1121,18 @@ void FullscreenUI::DoStartPath(std::string path, std::string state, std::optiona
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// This can "fail" if HC mode is enabled and the user cancels, or other startup cancel paths.
|
// This can "fail" if HC mode is enabled and the user cancels, or other startup cancel paths.
|
||||||
// In that case, we need to re-trigger the idle state so the user can interact with the message.
|
|
||||||
// But we can skip it if we have a system, because OnSystemStarted() fixed it up.
|
|
||||||
Error error;
|
Error error;
|
||||||
const bool result = System::BootSystem(std::move(params), &error);
|
if (!System::BootSystem(std::move(params), &error))
|
||||||
if (result && System::IsValid())
|
{
|
||||||
return;
|
GPUThread::RunOnThread([error_desc = error.TakeDescription()]() {
|
||||||
|
if (!IsInitialized())
|
||||||
|
return;
|
||||||
|
|
||||||
GPUThread::RunOnThread([error_desc = error.TakeDescription(), result]() {
|
|
||||||
if (!IsInitialized())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
OpenInfoMessageDialog(TRANSLATE_STR("System", "Error"),
|
OpenInfoMessageDialog(TRANSLATE_STR("System", "Error"),
|
||||||
fmt::format(TRANSLATE_FS("System", "Failed to boot system: {}"), error_desc));
|
fmt::format(TRANSLATE_FS("System", "Failed to boot system: {}"), error_desc));
|
||||||
}
|
UpdateRunIdleState();
|
||||||
|
});
|
||||||
UpdateRunIdleState();
|
}
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1246,21 +1238,25 @@ void FullscreenUI::ConfirmIfSavingMemoryCards(std::string action, std::function<
|
|||||||
|
|
||||||
void FullscreenUI::RequestShutdown(bool save_state)
|
void FullscreenUI::RequestShutdown(bool save_state)
|
||||||
{
|
{
|
||||||
|
s_state.current_main_window = MainWindowType::None;
|
||||||
|
|
||||||
ConfirmIfSavingMemoryCards(FSUI_STR("shut down"), [save_state](bool result) {
|
ConfirmIfSavingMemoryCards(FSUI_STR("shut down"), [save_state](bool result) {
|
||||||
if (result)
|
if (result)
|
||||||
Host::RunOnCPUThread([save_state]() { Host::RequestSystemShutdown(false, save_state); });
|
Host::RunOnCPUThread([save_state]() { Host::RequestSystemShutdown(false, save_state); });
|
||||||
else
|
|
||||||
ClosePauseMenu();
|
ClosePauseMenu();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void FullscreenUI::RequestReset()
|
void FullscreenUI::RequestReset()
|
||||||
{
|
{
|
||||||
|
s_state.current_main_window = MainWindowType::None;
|
||||||
|
|
||||||
ConfirmIfSavingMemoryCards(FSUI_STR("reset"), [](bool result) {
|
ConfirmIfSavingMemoryCards(FSUI_STR("reset"), [](bool result) {
|
||||||
if (result)
|
if (result)
|
||||||
Host::RunOnCPUThread(System::ResetSystem);
|
Host::RunOnCPUThread(System::ResetSystem);
|
||||||
else
|
|
||||||
ClosePauseMenu();
|
ClosePauseMenu();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1297,7 +1293,7 @@ void FullscreenUI::StartChangeDiscFromFile()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnToPreviousWindow();
|
ReturnToMainWindow();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -6683,10 +6679,7 @@ void FullscreenUI::DrawPauseMenu()
|
|||||||
OpenPauseSubMenu(PauseSubMenu::None);
|
OpenPauseSubMenu(PauseSubMenu::None);
|
||||||
|
|
||||||
if (ActiveButton(FSUI_ICONSTR(ICON_FA_SYNC, "Reset System"), false))
|
if (ActiveButton(FSUI_ICONSTR(ICON_FA_SYNC, "Reset System"), false))
|
||||||
{
|
|
||||||
ClosePauseMenu();
|
|
||||||
RequestReset();
|
RequestReset();
|
||||||
}
|
|
||||||
|
|
||||||
if (ActiveButton(FSUI_ICONSTR(ICON_FA_SAVE, "Exit And Save State"), false))
|
if (ActiveButton(FSUI_ICONSTR(ICON_FA_SAVE, "Exit And Save State"), false))
|
||||||
RequestShutdown(true);
|
RequestShutdown(true);
|
||||||
|
@ -34,6 +34,7 @@ void OpenLeaderboardsWindow();
|
|||||||
void ReturnToMainWindow();
|
void ReturnToMainWindow();
|
||||||
void ReturnToPreviousWindow();
|
void ReturnToPreviousWindow();
|
||||||
void SetStandardSelectionFooterText(bool back_instead_of_cancel);
|
void SetStandardSelectionFooterText(bool back_instead_of_cancel);
|
||||||
|
void UpdateRunIdleState();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void Shutdown(bool clear_state);
|
void Shutdown(bool clear_state);
|
||||||
|
@ -732,7 +732,7 @@ void MainWindow::quit()
|
|||||||
// Make sure VM is gone. It really should be if we're here.
|
// Make sure VM is gone. It really should be if we're here.
|
||||||
if (s_system_valid)
|
if (s_system_valid)
|
||||||
{
|
{
|
||||||
g_emu_thread->shutdownSystem(false, true);
|
g_emu_thread->shutdownSystem(false, false);
|
||||||
QtUtils::ProcessEventsWithSleep(QEventLoop::ExcludeUserInputEvents, []() { return s_system_valid; });
|
QtUtils::ProcessEventsWithSleep(QEventLoop::ExcludeUserInputEvents, []() { return s_system_valid; });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1990,30 +1990,51 @@ void Host::ConfirmMessageAsync(std::string_view title, std::string_view message,
|
|||||||
if (no_text.empty())
|
if (no_text.empty())
|
||||||
no_text = TRANSLATE_SV("QtHost", "No");
|
no_text = TRANSLATE_SV("QtHost", "No");
|
||||||
|
|
||||||
|
// Ensure it always comes from the CPU thread.
|
||||||
|
if (!g_emu_thread->isCurrentThread())
|
||||||
|
{
|
||||||
|
Host::RunOnCPUThread([title = std::string(title), message = std::string(message), callback = std::move(callback),
|
||||||
|
yes_text = std::string(yes_text), no_text = std::string(no_text)]() mutable {
|
||||||
|
ConfirmMessageAsync(title, message, std::move(callback));
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pause system while dialog is up.
|
||||||
|
const bool needs_pause = System::IsValid() && !System::IsPaused();
|
||||||
|
if (needs_pause)
|
||||||
|
System::PauseSystem(true);
|
||||||
|
|
||||||
// Use FSUI to display the confirmation if it is active.
|
// Use FSUI to display the confirmation if it is active.
|
||||||
if (FullscreenUI::IsInitialized())
|
if (FullscreenUI::IsInitialized())
|
||||||
{
|
{
|
||||||
// This.. should not be a thing.
|
|
||||||
if (!g_emu_thread->isCurrentThread())
|
|
||||||
{
|
|
||||||
Host::RunOnCPUThread([title = std::string(title), message = std::string(message), callback = std::move(callback),
|
|
||||||
yes_text = std::string(yes_text), no_text = std::string(no_text)]() mutable {
|
|
||||||
ConfirmMessageAsync(title, message, std::move(callback));
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
GPUThread::RunOnThread([title = std::string(title), message = std::string(message), callback = std::move(callback),
|
GPUThread::RunOnThread([title = std::string(title), message = std::string(message), callback = std::move(callback),
|
||||||
yes_text = std::string(yes_text), no_text = std::string(no_text)]() mutable {
|
yes_text = std::string(yes_text), no_text = std::string(no_text), needs_pause]() mutable {
|
||||||
if (!FullscreenUI::Initialize())
|
if (!FullscreenUI::Initialize())
|
||||||
{
|
{
|
||||||
callback(false);
|
callback(false);
|
||||||
|
|
||||||
|
if (needs_pause)
|
||||||
|
{
|
||||||
|
Host::RunOnCPUThread([]() {
|
||||||
|
if (System::IsValid())
|
||||||
|
System::PauseSystem(false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGuiFullscreen::OpenConfirmMessageDialog(std::move(title), std::move(message), std::move(callback),
|
// Need to reset run idle state _again_ after displaying.
|
||||||
|
auto final_callback = [callback = std::move(callback)](bool result) {
|
||||||
|
FullscreenUI::UpdateRunIdleState();
|
||||||
|
callback(result);
|
||||||
|
};
|
||||||
|
|
||||||
|
ImGuiFullscreen::OpenConfirmMessageDialog(std::move(title), std::move(message), std::move(final_callback),
|
||||||
fmt::format(ICON_FA_CHECK " {}", yes_text),
|
fmt::format(ICON_FA_CHECK " {}", yes_text),
|
||||||
fmt::format(ICON_FA_TIMES " {}", no_text));
|
fmt::format(ICON_FA_TIMES " {}", no_text));
|
||||||
|
FullscreenUI::UpdateRunIdleState();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2021,7 +2042,7 @@ void Host::ConfirmMessageAsync(std::string_view title, std::string_view message,
|
|||||||
// Otherwise, use the desktop UI.
|
// Otherwise, use the desktop UI.
|
||||||
QtHost::RunOnUIThread([title = QtUtils::StringViewToQString(title), message = QtUtils::StringViewToQString(message),
|
QtHost::RunOnUIThread([title = QtUtils::StringViewToQString(title), message = QtUtils::StringViewToQString(message),
|
||||||
callback = std::move(callback), yes_text = QtUtils::StringViewToQString(yes_text),
|
callback = std::move(callback), yes_text = QtUtils::StringViewToQString(yes_text),
|
||||||
no_text = QtUtils::StringViewToQString(no_text)]() mutable {
|
no_text = QtUtils::StringViewToQString(no_text), needs_pause]() mutable {
|
||||||
auto lock = g_main_window->pauseAndLockSystem();
|
auto lock = g_main_window->pauseAndLockSystem();
|
||||||
|
|
||||||
bool result;
|
bool result;
|
||||||
@ -2038,6 +2059,14 @@ void Host::ConfirmMessageAsync(std::string_view title, std::string_view message,
|
|||||||
}
|
}
|
||||||
|
|
||||||
callback(result);
|
callback(result);
|
||||||
|
|
||||||
|
if (needs_pause)
|
||||||
|
{
|
||||||
|
Host::RunOnCPUThread([]() {
|
||||||
|
if (System::IsValid())
|
||||||
|
System::PauseSystem(false);
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user