From 3f0e53e60afe4417f183f0ff8108b621a317c83f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 29 Nov 2022 16:29:43 +0100 Subject: [PATCH] Let the running game show through the background of all the PromptScreen dialogs. --- UI/EmuScreen.cpp | 2 +- UI/GameScreen.cpp | 6 +++--- UI/GameSettingsScreen.cpp | 11 ++++++----- UI/MiscScreens.cpp | 4 ++-- UI/MiscScreens.h | 4 ++-- UI/PauseScreen.cpp | 2 +- 6 files changed, 15 insertions(+), 14 deletions(-) diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 34375650b8..e3e8a6dcfa 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -1058,7 +1058,7 @@ void EmuScreen::update() { errLoadingFile.append(" "); errLoadingFile.append(err->T(errorMessage_.c_str())); - screenManager()->push(new PromptScreen(errLoadingFile, "OK", "")); + screenManager()->push(new PromptScreen(gamePath_, errLoadingFile, "OK", "")); errorMessage_.clear(); quit_ = true; return; diff --git a/UI/GameScreen.cpp b/UI/GameScreen.cpp index 4486bbd9a3..33773e5adb 100644 --- a/UI/GameScreen.cpp +++ b/UI/GameScreen.cpp @@ -243,7 +243,7 @@ UI::EventReturn GameScreen::OnDeleteConfig(UI::EventParams &e) auto di = GetI18NCategory("Dialog"); auto ga = GetI18NCategory("Game"); screenManager()->push( - new PromptScreen(di->T("DeleteConfirmGameConfig", "Do you really want to delete the settings for this game?"), ga->T("ConfirmDelete"), di->T("Cancel"), + new PromptScreen(gamePath_, di->T("DeleteConfirmGameConfig", "Do you really want to delete the settings for this game?"), ga->T("ConfirmDelete"), di->T("Cancel"), std::bind(&GameScreen::CallbackDeleteConfig, this, std::placeholders::_1))); return UI::EVENT_DONE; @@ -374,7 +374,7 @@ UI::EventReturn GameScreen::OnDeleteSaveData(UI::EventParams &e) { // Check that there's any savedata to delete if (saveDirs.size()) { screenManager()->push( - new PromptScreen(di->T("DeleteConfirmAll", "Do you really want to delete all\nyour save data for this game?"), ga->T("ConfirmDelete"), di->T("Cancel"), + new PromptScreen(gamePath_, di->T("DeleteConfirmAll", "Do you really want to delete all\nyour save data for this game?"), ga->T("ConfirmDelete"), di->T("Cancel"), std::bind(&GameScreen::CallbackDeleteSaveData, this, std::placeholders::_1))); } } @@ -398,7 +398,7 @@ UI::EventReturn GameScreen::OnDeleteGame(UI::EventParams &e) { std::shared_ptr info = g_gameInfoCache->GetInfo(NULL, gamePath_, GAMEINFO_WANTBG | GAMEINFO_WANTSIZE); if (info) { screenManager()->push( - new PromptScreen(di->T("DeleteConfirmGame", "Do you really want to delete this game\nfrom your device? You can't undo this."), ga->T("ConfirmDelete"), di->T("Cancel"), + new PromptScreen(gamePath_, di->T("DeleteConfirmGame", "Do you really want to delete this game\nfrom your device? You can't undo this."), ga->T("ConfirmDelete"), di->T("Cancel"), std::bind(&GameScreen::CallbackDeleteGame, this, std::placeholders::_1))); } diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 7ba8120ce9..c85513f0e4 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1445,7 +1445,7 @@ UI::EventReturn GameSettingsScreen::OnRenderingBackend(UI::EventParams &e) { // It only makes sense to show the restart prompt if the backend was actually changed. if (g_Config.iGPUBackend != (int)GetGPUBackend()) { - screenManager()->push(new PromptScreen(di->T("ChangingGPUBackends", "Changing GPU backends requires PPSSPP to restart. Restart now?"), di->T("Yes"), di->T("No"), + screenManager()->push(new PromptScreen(gamePath_, di->T("ChangingGPUBackends", "Changing GPU backends requires PPSSPP to restart. Restart now?"), di->T("Yes"), di->T("No"), std::bind(&GameSettingsScreen::CallbackRenderingBackend, this, std::placeholders::_1))); } return UI::EVENT_DONE; @@ -1457,7 +1457,7 @@ UI::EventReturn GameSettingsScreen::OnRenderingDevice(UI::EventParams &e) { // It only makes sense to show the restart prompt if the device was actually changed. std::string *deviceNameSetting = GPUDeviceNameSetting(); if (deviceNameSetting && *deviceNameSetting != GetGPUBackendDevice()) { - screenManager()->push(new PromptScreen(di->T("ChangingGPUBackends", "Changing GPU backends requires PPSSPP to restart. Restart now?"), di->T("Yes"), di->T("No"), + screenManager()->push(new PromptScreen(gamePath_, di->T("ChangingGPUBackends", "Changing GPU backends requires PPSSPP to restart. Restart now?"), di->T("Yes"), di->T("No"), std::bind(&GameSettingsScreen::CallbackRenderingDevice, this, std::placeholders::_1))); } return UI::EVENT_DONE; @@ -1466,7 +1466,7 @@ UI::EventReturn GameSettingsScreen::OnRenderingDevice(UI::EventParams &e) { UI::EventReturn GameSettingsScreen::OnInflightFramesChoice(UI::EventParams &e) { auto di = GetI18NCategory("Dialog"); if (g_Config.iInflightFrames != prevInflightFrames_) { - screenManager()->push(new PromptScreen(di->T("ChangingInflightFrames", "Changing graphics command buffering requires PPSSPP to restart. Restart now?"), di->T("Yes"), di->T("No"), + screenManager()->push(new PromptScreen(gamePath_, di->T("ChangingInflightFrames", "Changing graphics command buffering requires PPSSPP to restart. Restart now?"), di->T("Yes"), di->T("No"), std::bind(&GameSettingsScreen::CallbackInflightFrames, this, std::placeholders::_1))); } return UI::EVENT_DONE; @@ -1580,6 +1580,7 @@ UI::EventReturn GameSettingsScreen::OnChangeMacAddress(UI::EventParams &e) { std::string combined = std::string(confirmMessage) + "\n\n" + warningMessage; auto confirmScreen = new PromptScreen( + gamePath_, combined, di->T("Yes"), di->T("No"), [&](bool success) { if (success) { @@ -1844,13 +1845,13 @@ UI::EventReturn GameSettingsScreen::OnRestoreDefaultSettings(UI::EventParams &e) if (g_Config.bGameSpecific) { screenManager()->push( - new PromptScreen(dev->T("RestoreGameDefaultSettings", "Are you sure you want to restore the game-specific settings back to the ppsspp defaults?\n"), di->T("OK"), di->T("Cancel"), + new PromptScreen(gamePath_, dev->T("RestoreGameDefaultSettings", "Are you sure you want to restore the game-specific settings back to the ppsspp defaults?\n"), di->T("OK"), di->T("Cancel"), std::bind(&GameSettingsScreen::CallbackRestoreDefaults, this, std::placeholders::_1))); } else { screenManager()->push( - new PromptScreen(dev->T("RestoreDefaultSettings", "Are you sure you want to restore all settings(except control mapping)\nback to their defaults?\nYou can't undo this.\nPlease restart PPSSPP after restoring settings."), di->T("OK"), di->T("Cancel"), + new PromptScreen(gamePath_, dev->T("RestoreDefaultSettings", "Are you sure you want to restore all settings(except control mapping)\nback to their defaults?\nYou can't undo this.\nPlease restart PPSSPP after restoring settings."), di->T("OK"), di->T("Cancel"), std::bind(&GameSettingsScreen::CallbackRestoreDefaults, this, std::placeholders::_1))); } diff --git a/UI/MiscScreens.cpp b/UI/MiscScreens.cpp index d5d7ec5f85..85b04a4717 100644 --- a/UI/MiscScreens.cpp +++ b/UI/MiscScreens.cpp @@ -507,8 +507,8 @@ void UIDialogScreenWithBackground::sendMessage(const char *message, const char * HandleCommonMessages(message, value, screenManager(), this); } -PromptScreen::PromptScreen(std::string message, std::string yesButtonText, std::string noButtonText, std::function callback) - : message_(message), callback_(callback) { +PromptScreen::PromptScreen(const Path &gamePath, std::string message, std::string yesButtonText, std::string noButtonText, std::function callback) + : UIDialogScreenWithGameBackground(gamePath), message_(message), callback_(callback) { auto di = GetI18NCategory("Dialog"); yesButtonText_ = di->T(yesButtonText.c_str()); noButtonText_ = di->T(noButtonText.c_str()); diff --git a/UI/MiscScreens.h b/UI/MiscScreens.h index 2790f85c37..341e3b7915 100644 --- a/UI/MiscScreens.h +++ b/UI/MiscScreens.h @@ -76,9 +76,9 @@ protected: bool darkenGameBackground_ = true; }; -class PromptScreen : public UIDialogScreenWithBackground { +class PromptScreen : public UIDialogScreenWithGameBackground { public: - PromptScreen(std::string message, std::string yesButtonText, std::string noButtonText, + PromptScreen(const Path& gamePath, std::string message, std::string yesButtonText, std::string noButtonText, std::function callback = &NoOpVoidBool); void CreateViews() override; diff --git a/UI/PauseScreen.cpp b/UI/PauseScreen.cpp index 2ff43b61ab..85d60a480f 100644 --- a/UI/PauseScreen.cpp +++ b/UI/PauseScreen.cpp @@ -460,7 +460,7 @@ UI::EventReturn GamePauseScreen::OnDeleteConfig(UI::EventParams &e) auto di = GetI18NCategory("Dialog"); auto ga = GetI18NCategory("Game"); screenManager()->push( - new PromptScreen(di->T("DeleteConfirmGameConfig", "Do you really want to delete the settings for this game?"), ga->T("ConfirmDelete"), di->T("Cancel"), + new PromptScreen(gamePath_, di->T("DeleteConfirmGameConfig", "Do you really want to delete the settings for this game?"), ga->T("ConfirmDelete"), di->T("Cancel"), std::bind(&GamePauseScreen::CallbackDeleteConfig, this, std::placeholders::_1))); return UI::EVENT_DONE;