diff --git a/es-app/src/guis/GuiApplicationUpdater.cpp b/es-app/src/guis/GuiApplicationUpdater.cpp index c63d6463f..c458d19dc 100644 --- a/es-app/src/guis/GuiApplicationUpdater.cpp +++ b/es-app/src/guis/GuiApplicationUpdater.cpp @@ -177,7 +177,7 @@ GuiApplicationUpdater::GuiApplicationUpdater() if (mDownloading) { mWindow->pushGui( new GuiMsgBox(getHelpStyle(), "DOWNLOAD ABORTED\nNO PACKAGE SAVED TO DISK", "OK", - nullptr, "", nullptr, "", nullptr, true, true, + nullptr, "", nullptr, "", nullptr, nullptr, true, true, (mRenderer->getIsVerticalOrientation() ? 0.70f : 0.45f * (1.778f / mRenderer->getScreenAspectRatio())))); @@ -185,7 +185,7 @@ GuiApplicationUpdater::GuiApplicationUpdater() else if (mHasDownloaded || mReadyToInstall) { mWindow->pushGui(new GuiMsgBox( getHelpStyle(), "PACKAGE WAS DOWNLOADED AND\nCAN BE MANUALLY INSTALLED", "OK", - nullptr, "", nullptr, "", nullptr, true, true, + nullptr, "", nullptr, "", nullptr, nullptr, true, true, (mRenderer->getIsVerticalOrientation() ? 0.70f : 0.45f * (1.778f / mRenderer->getScreenAspectRatio())))); diff --git a/es-app/src/guis/GuiMenu.cpp b/es-app/src/guis/GuiMenu.cpp index ef58466a8..ce69cede5 100644 --- a/es-app/src/guis/GuiMenu.cpp +++ b/es-app/src/guis/GuiMenu.cpp @@ -672,7 +672,7 @@ void GuiMenu::openUIOptions() false); mWindow->invalidateCachedBackground(); }, - "CANCEL", nullptr, "", nullptr, true)); + "CANCEL", nullptr, "", nullptr, nullptr, true)); } else { LOG(LogDebug) << "GuiMenu::openUISettings(): Setting UI mode to '" << selectedMode @@ -1144,7 +1144,7 @@ void GuiMenu::openConfigInput(GuiSettings* settings) window->pushGui(new GuiMsgBox( getHelpStyle(), message, "PROCEED", [window] { window->pushGui(new GuiDetectDevice(false, false, nullptr)); }, "CANCEL", - nullptr, "", nullptr, false, true, + nullptr, "", nullptr, nullptr, false, true, (mRenderer->getIsVerticalOrientation() ? 0.84f : 0.54f * (1.778f / mRenderer->getScreenAspectRatio())))); @@ -1665,20 +1665,20 @@ void GuiMenu::openUtilities() } ViewController::getInstance()->rescanROMDirectory(); }, - "", nullptr, "", nullptr, true)); + "", nullptr, "", nullptr, nullptr, true)); } else { mWindow->pushGui( new GuiMsgBox(getHelpStyle(), "ERROR CREATING SYSTEM DIRECTORIES, PERMISSION PROBLEMS OR " "DISK FULL?\nSEE THE LOG FILE FOR MORE DETAILS", - "OK", nullptr, "", nullptr, "", nullptr, true, true, + "OK", nullptr, "", nullptr, "", nullptr, nullptr, true, true, (mRenderer->getIsVerticalOrientation() ? 0.70f : 0.44f * (1.778f / mRenderer->getScreenAspectRatio())))); } }, - "CANCEL", nullptr, "", nullptr, false, true, + "CANCEL", nullptr, "", nullptr, nullptr, false, true, (mRenderer->getIsVerticalOrientation() ? 0.80f : 0.52f * (1.778f / mRenderer->getScreenAspectRatio())))); @@ -1712,7 +1712,7 @@ void GuiMenu::openUtilities() } ViewController::getInstance()->rescanROMDirectory(); }, - "CANCEL", nullptr, "", nullptr, false, true, + "CANCEL", nullptr, "", nullptr, nullptr, false, true, (mRenderer->getIsVerticalOrientation() ? 0.80f : 0.52f * (1.778f / mRenderer->getScreenAspectRatio())))); diff --git a/es-app/src/guis/GuiMetaDataEd.cpp b/es-app/src/guis/GuiMetaDataEd.cpp index b76066c88..725c6b56c 100644 --- a/es-app/src/guis/GuiMetaDataEd.cpp +++ b/es-app/src/guis/GuiMetaDataEd.cpp @@ -997,7 +997,7 @@ void GuiMetaDataEd::close() save(); closeFunc(); }, - "NO", closeFunc, "", nullptr, true)); + "NO", closeFunc, "", nullptr, nullptr, true)); } else { // Always save if the media files have been changed (i.e. newly scraped images). diff --git a/es-app/src/guis/GuiScraperMenu.cpp b/es-app/src/guis/GuiScraperMenu.cpp index 4666dc11f..2e5dc4036 100644 --- a/es-app/src/guis/GuiScraperMenu.cpp +++ b/es-app/src/guis/GuiScraperMenu.cpp @@ -1244,7 +1244,7 @@ void GuiScraperMenu::pressedStart() mWindow->pushGui( new GuiMsgBox(getHelpStyle(), Utils::String::toUpper(warningString), "PROCEED", std::bind(&GuiScraperMenu::start, this), "CANCEL", nullptr, "", - nullptr, false, true, + nullptr, nullptr, false, true, (mRenderer->getIsVerticalOrientation() ? 0.80f : 0.50f * (1.778f / mRenderer->getScreenAspectRatio())))); diff --git a/es-app/src/guis/GuiScraperMulti.cpp b/es-app/src/guis/GuiScraperMulti.cpp index 82c0f6ced..db6aa0aa6 100644 --- a/es-app/src/guis/GuiScraperMulti.cpp +++ b/es-app/src/guis/GuiScraperMulti.cpp @@ -319,10 +319,18 @@ void GuiScraperMulti::finish() << mTotalSkipped << " GAME" << ((mTotalSkipped > 1) ? "S" : "") << " SKIPPED"; } - mWindow->pushGui(new GuiMsgBox(getHelpStyle(), ss.str())); - - mIsProcessing = false; - delete this; + // Pressing either OK or using the back button should delete us. + mWindow->pushGui(new GuiMsgBox( + getHelpStyle(), ss.str(), "OK", + [&] { + mIsProcessing = false; + delete this; + }, + "", nullptr, "", nullptr, + [&] { + mIsProcessing = false; + delete this; + })); } std::vector GuiScraperMulti::getHelpPrompts() diff --git a/es-app/src/guis/GuiScraperSearch.cpp b/es-app/src/guis/GuiScraperSearch.cpp index 52351a2bc..8bf747c33 100644 --- a/es-app/src/guis/GuiScraperSearch.cpp +++ b/es-app/src/guis/GuiScraperSearch.cpp @@ -571,13 +571,14 @@ void GuiScraperSearch::onSearchError(const std::string& error, LOG(LogError) << "GuiScraperSearch: " << Utils::String::replace(error, "\n", ""); mWindow->pushGui(new GuiMsgBox(getHelpStyle(), Utils::String::toUpper(error), "RETRY", std::bind(&GuiScraperSearch::search, this, mLastSearch), - "SKIP", mSkipCallback, "CANCEL", mCancelCallback, true)); + "SKIP", mSkipCallback, "CANCEL", mCancelCallback, nullptr, + true)); } else { LOG(LogError) << "GuiScraperSearch: " << Utils::String::replace(error, "\n", ""); mWindow->pushGui(new GuiMsgBox(getHelpStyle(), Utils::String::toUpper(error), "RETRY", std::bind(&GuiScraperSearch::search, this, mLastSearch), - "CANCEL", mCancelCallback, "", nullptr, true)); + "CANCEL", mCancelCallback, "", nullptr, nullptr, true)); } } diff --git a/es-app/src/guis/GuiThemeDownloader.cpp b/es-app/src/guis/GuiThemeDownloader.cpp index 1f9b2a7dd..8bfa6a278 100644 --- a/es-app/src/guis/GuiThemeDownloader.cpp +++ b/es-app/src/guis/GuiThemeDownloader.cpp @@ -548,7 +548,7 @@ bool GuiThemeDownloader::renameDirectory(const std::string& path, const std::str if (renameStatus) { mWindow->pushGui(new GuiMsgBox( getHelpStyle(), "COULDN'T RENAME DIRECTORY \"" + path + "\", PERMISSION PROBLEMS?", - "OK", [] { return; }, "", nullptr, "", nullptr, true)); + "OK", [] { return; }, "", nullptr, "", nullptr, nullptr, true)); return true; } else { @@ -571,7 +571,7 @@ void GuiThemeDownloader::parseThemesList() LOG(LogError) << "GuiThemeDownloader: No themes.json file found"; mWindow->pushGui(new GuiMsgBox( getHelpStyle(), "COULDN'T FIND THE THEMES LIST CONFIGURATION FILE", "OK", - [] { return; }, "", nullptr, "", nullptr, true)); + [] { return; }, "", nullptr, "", nullptr, nullptr, true)); mGrid.removeEntry(mCenterGrid); mGrid.setCursorTo(mButtons); return; @@ -587,7 +587,7 @@ void GuiThemeDownloader::parseThemesList() getHelpStyle(), "COULDN'T PARSE THE THEMES LIST CONFIGURATION FILE, MAYBE THE LOCAL REPOSITORY IS " "CORRUPT?", - "OK", [] { return; }, "", nullptr, "", nullptr, true)); + "OK", [] { return; }, "", nullptr, "", nullptr, nullptr, true)); mGrid.removeEntry(mCenterGrid); mGrid.setCursorTo(mButtons); return; @@ -602,7 +602,7 @@ void GuiThemeDownloader::parseThemesList() getHelpStyle(), "IT SEEMS AS IF YOU'RE NOT RUNNING THE LATEST ES-DE RELEASE, PLEASE UPGRADE BEFORE " "PROCEEDING AS THESE THEMES MAY NOT BE COMPATIBLE WITH YOUR VERSION", - "OK", [] { return; }, "", nullptr, "", nullptr, true)); + "OK", [] { return; }, "", nullptr, "", nullptr, nullptr, true)); } } @@ -724,7 +724,7 @@ void GuiThemeDownloader::populateGUI() mStatusType = StatusType::STATUS_DOWNLOADING; mStatusText = "DOWNLOADING THEME"; }, - "CANCEL", [] { return; }, "", nullptr, true, true, + "CANCEL", [] { return; }, "", nullptr, nullptr, true, true, (mRenderer->getIsVerticalOrientation() ? 0.75f : 0.46f * (1.778f / mRenderer->getScreenAspectRatio())))); @@ -752,7 +752,7 @@ void GuiThemeDownloader::populateGUI() mStatusType = StatusType::STATUS_DOWNLOADING; mStatusText = "DOWNLOADING THEME"; }, - "CANCEL", [] { return; }, "", nullptr, true, true, + "CANCEL", [] { return; }, "", nullptr, nullptr, true, true, (mRenderer->getIsVerticalOrientation() ? 0.75f : 0.46f * (1.778f / mRenderer->getScreenAspectRatio())))); @@ -779,7 +779,7 @@ void GuiThemeDownloader::populateGUI() mStatusType = StatusType::STATUS_DOWNLOADING; mStatusText = "DOWNLOADING THEME"; }, - "CANCEL", [] { return; }, "", nullptr, true, true, + "CANCEL", [] { return; }, "", nullptr, nullptr, true, true, (mRenderer->getIsVerticalOrientation() ? 0.75f : 0.46f * (1.778f / mRenderer->getScreenAspectRatio())))); @@ -799,7 +799,7 @@ void GuiThemeDownloader::populateGUI() mStatusType = StatusType::STATUS_UPDATING; mStatusText = "UPDATING THEME"; }, - "CANCEL", [] { return; }, "", nullptr, true, true, + "CANCEL", [] { return; }, "", nullptr, nullptr, true, true, (mRenderer->getIsVerticalOrientation() ? 0.75f : 0.45f * (1.778f / mRenderer->getScreenAspectRatio())))); @@ -978,7 +978,7 @@ void GuiThemeDownloader::update(int deltaTime) errorMessage.append(Utils::String::toUpper(mMessage)); mWindow->pushGui(new GuiMsgBox( getHelpStyle(), errorMessage, "OK", [] { return; }, "", nullptr, "", - nullptr, true)); + nullptr, nullptr, true)); mMessage = ""; getHelpPrompts(); } @@ -1164,7 +1164,7 @@ bool GuiThemeDownloader::input(InputConfig* config, Input input) if (!Utils::FileSystem::removeDirectory(themeDirectory.string(), true)) { mWindow->pushGui(new GuiMsgBox( getHelpStyle(), "COULDN'T DELETE THEME, PERMISSION PROBLEMS?", "OK", - [] { return; }, "", nullptr, "", nullptr, true)); + [] { return; }, "", nullptr, "", nullptr, nullptr, true)); } else { mMessage = "THEME WAS DELETED"; @@ -1173,7 +1173,7 @@ bool GuiThemeDownloader::input(InputConfig* config, Input input) makeInventory(); updateGUI(); }, - "CANCEL", nullptr, "", nullptr, true, true, + "CANCEL", nullptr, "", nullptr, nullptr, true, true, (mRenderer->getIsVerticalOrientation() ? 0.70f : 0.44f * (1.778f / mRenderer->getScreenAspectRatio())))); @@ -1247,7 +1247,7 @@ bool GuiThemeDownloader::fetchThemesList() delete this; return false; }, - "", nullptr, true, true, + "", nullptr, nullptr, true, true, (mRenderer->getIsVerticalOrientation() ? 0.75f : 0.50f * (1.778f / mRenderer->getScreenAspectRatio())))); @@ -1285,7 +1285,7 @@ bool GuiThemeDownloader::fetchThemesList() delete this; return false; }, - "", nullptr, true, true, + "", nullptr, nullptr, true, true, (mRenderer->getIsVerticalOrientation() ? 0.85f : 0.54f * (1.778f / mRenderer->getScreenAspectRatio())))); diff --git a/es-app/src/views/ViewController.cpp b/es-app/src/views/ViewController.cpp index 7621049b9..52de54a88 100644 --- a/es-app/src/views/ViewController.cpp +++ b/es-app/src/views/ViewController.cpp @@ -148,7 +148,8 @@ void ViewController::unsafeUpgradeDialog() "README.TXT FILE THAT CAN BE FOUND IN THE EMULATIONSTATION-DE " "DIRECTORY."}; mWindow->pushGui(new GuiMsgBox( - HelpStyle(), upgradeMessage.c_str(), "OK", [] {}, "", nullptr, "", nullptr, true, true, + HelpStyle(), upgradeMessage.c_str(), "OK", [] {}, "", nullptr, "", nullptr, nullptr, true, + true, (mRenderer->getIsVerticalOrientation() ? 0.85f : 0.55f * (1.778f / mRenderer->getScreenAspectRatio())))); @@ -170,7 +171,7 @@ void ViewController::invalidSystemsFileDialog() quit.type = SDL_QUIT; SDL_PushEvent(&quit); }, - "", nullptr, "", nullptr, true, true, + "", nullptr, "", nullptr, nullptr, true, true, (mRenderer->getIsVerticalOrientation() ? 0.85f : 0.55f * (1.778f / mRenderer->getScreenAspectRatio())))); @@ -220,7 +221,7 @@ void ViewController::noGamesDialog() "ROM DIRECTORY SETTING SAVED, RESTART\n" "THE APPLICATION TO RESCAN THE SYSTEMS", "OK", nullptr, "", nullptr, "", nullptr, - true, true)); + nullptr, true, true)); } }, false, "SAVE", "SAVE CHANGES?", "Currently configured path:", @@ -245,7 +246,7 @@ void ViewController::noGamesDialog() "ROM DIRECTORY SETTING SAVED, RESTART\n" "THE APPLICATION TO RESCAN THE SYSTEMS", "OK", nullptr, "", nullptr, "", nullptr, - true)); + nullptr, true)); }, false, "SAVE", "SAVE CHANGES?", "Currently configured path:", currentROMDirectory, "LOAD CURRENTLY CONFIGURED PATH", @@ -268,7 +269,7 @@ void ViewController::noGamesDialog() "GENERATED, EXIT THE APPLICATION AND PLACE\n" "YOUR GAMES IN THE NEWLY CREATED FOLDERS", "OK", nullptr, "", nullptr, "", nullptr, - true)); + nullptr, true)); } else { mWindow->pushGui(new GuiMsgBox(HelpStyle(), @@ -276,10 +277,10 @@ void ViewController::noGamesDialog() "PERMISSION PROBLEMS OR DISK FULL?\n\n" "SEE THE LOG FILE FOR MORE DETAILS", "OK", nullptr, "", nullptr, "", nullptr, - true)); + nullptr, true)); } }, - "CANCEL", nullptr, "", nullptr, true)); + "CANCEL", nullptr, "", nullptr, nullptr, true)); }, "QUIT", [] { @@ -287,7 +288,7 @@ void ViewController::noGamesDialog() quit.type = SDL_QUIT; SDL_PushEvent(&quit); }, - true, false, + nullptr, true, false, (mRenderer->getIsVerticalOrientation() ? 0.90f : 0.62f * (1.778f / mRenderer->getScreenAspectRatio()))); @@ -305,7 +306,7 @@ void ViewController::invalidAlternativeEmulatorDialog() "CONFIGURATION FILE, PLEASE REVIEW YOUR\n" "SETUP USING THE 'ALTERNATIVE EMULATORS'\n" "INTERFACE IN THE 'OTHER SETTINGS' MENU", - "OK", nullptr, "", nullptr, "", nullptr, true, true)); + "OK", nullptr, "", nullptr, "", nullptr, nullptr, true, true)); } void ViewController::updateAvailableDialog() @@ -355,20 +356,20 @@ void ViewController::updateAvailableDialog() } mWindow->pushGui(new GuiMsgBox( getHelpStyle(), upgradeMessage.c_str(), "OK", [] {}, "", nullptr, "", - nullptr, true, true, + nullptr, nullptr, true, true, (mRenderer->getIsVerticalOrientation() ? 0.85f : 0.535f * (1.778f / mRenderer->getScreenAspectRatio())))); } }, - "CANCEL", [] { return; }, "", nullptr, true, true, + "CANCEL", [] { return; }, "", nullptr, nullptr, true, true, (mRenderer->getIsVerticalOrientation() ? 0.70f : 0.45f * (1.778f / mRenderer->getScreenAspectRatio())))); } else { mWindow->pushGui(new GuiMsgBox(getHelpStyle(), results, "OK", nullptr, "", nullptr, "", - nullptr, true, true, + nullptr, nullptr, true, true, (mRenderer->getIsVerticalOrientation() ? 0.70f : 0.45f * (1.778f / mRenderer->getScreenAspectRatio())))); diff --git a/es-core/src/guis/GuiMsgBox.cpp b/es-core/src/guis/GuiMsgBox.cpp index ed67ccc70..12ef4a155 100644 --- a/es-core/src/guis/GuiMsgBox.cpp +++ b/es-core/src/guis/GuiMsgBox.cpp @@ -23,6 +23,7 @@ GuiMsgBox::GuiMsgBox(const HelpStyle& helpstyle, const std::function& func2, const std::string& name3, const std::function& func3, + const std::function& backFunc, const bool disableBackButton, const bool deleteOnButtonPress, const float maxWidthMultiplier) @@ -30,6 +31,7 @@ GuiMsgBox::GuiMsgBox(const HelpStyle& helpstyle, , mBackground {":/graphics/frame.svg"} , mGrid {glm::ivec2 {1, 2}} , mHelpStyle {helpstyle} + , mBackFunc {backFunc} , mDisableBackButton {disableBackButton} , mDeleteOnButtonPress {deleteOnButtonPress} , mMaxWidthMultiplier {maxWidthMultiplier} @@ -133,6 +135,8 @@ void GuiMsgBox::changeText(const std::string& newText) bool GuiMsgBox::input(InputConfig* config, Input input) { if (!mDisableBackButton && config->isMappedTo("b", input) && input.value != 0) { + if (mBackFunc) + mBackFunc(); delete this; return true; } diff --git a/es-core/src/guis/GuiMsgBox.h b/es-core/src/guis/GuiMsgBox.h index 67d082fcd..c751eda65 100644 --- a/es-core/src/guis/GuiMsgBox.h +++ b/es-core/src/guis/GuiMsgBox.h @@ -28,6 +28,7 @@ public: const std::function& func2 = nullptr, const std::string& name3 = "", const std::function& func3 = nullptr, + const std::function& backFunc = nullptr, const bool disableBackButton = false, const bool deleteOnButtonPress = true, const float maxWidthMultiplier = 0.0f); @@ -51,6 +52,7 @@ private: std::shared_ptr mMsg; std::vector> mButtons; std::shared_ptr mButtonGrid; + const std::function mBackFunc; bool mDisableBackButton; bool mDeleteOnButtonPress; float mMaxWidthMultiplier; diff --git a/es-core/src/guis/GuiTextEditKeyboardPopup.cpp b/es-core/src/guis/GuiTextEditKeyboardPopup.cpp index 8af4766f1..43a5dfeed 100644 --- a/es-core/src/guis/GuiTextEditKeyboardPopup.cpp +++ b/es-core/src/guis/GuiTextEditKeyboardPopup.cpp @@ -375,7 +375,7 @@ bool GuiTextEditKeyboardPopup::input(InputConfig* config, Input input) delete this; return true; }, - "", nullptr, true)); + "", nullptr, nullptr, true)); } else { delete this; diff --git a/es-core/src/guis/GuiTextEditPopup.cpp b/es-core/src/guis/GuiTextEditPopup.cpp index e8e1bffad..1565d23f1 100644 --- a/es-core/src/guis/GuiTextEditPopup.cpp +++ b/es-core/src/guis/GuiTextEditPopup.cpp @@ -186,7 +186,7 @@ bool GuiTextEditPopup::input(InputConfig* config, Input input) delete this; return true; }, - "", nullptr, true)); + "", nullptr, nullptr, true)); } else { delete this;