Added support for defining an explicit back button function for GuiMsgBox

This commit is contained in:
Leon Styhre 2023-09-17 11:47:58 +02:00
parent a122774d46
commit 2adde87050
12 changed files with 59 additions and 43 deletions

View file

@ -177,7 +177,7 @@ GuiApplicationUpdater::GuiApplicationUpdater()
if (mDownloading) { if (mDownloading) {
mWindow->pushGui( mWindow->pushGui(
new GuiMsgBox(getHelpStyle(), "DOWNLOAD ABORTED\nNO PACKAGE SAVED TO DISK", "OK", new GuiMsgBox(getHelpStyle(), "DOWNLOAD ABORTED\nNO PACKAGE SAVED TO DISK", "OK",
nullptr, "", nullptr, "", nullptr, true, true, nullptr, "", nullptr, "", nullptr, nullptr, true, true,
(mRenderer->getIsVerticalOrientation() ? (mRenderer->getIsVerticalOrientation() ?
0.70f : 0.70f :
0.45f * (1.778f / mRenderer->getScreenAspectRatio())))); 0.45f * (1.778f / mRenderer->getScreenAspectRatio()))));
@ -185,7 +185,7 @@ GuiApplicationUpdater::GuiApplicationUpdater()
else if (mHasDownloaded || mReadyToInstall) { else if (mHasDownloaded || mReadyToInstall) {
mWindow->pushGui(new GuiMsgBox( mWindow->pushGui(new GuiMsgBox(
getHelpStyle(), "PACKAGE WAS DOWNLOADED AND\nCAN BE MANUALLY INSTALLED", "OK", getHelpStyle(), "PACKAGE WAS DOWNLOADED AND\nCAN BE MANUALLY INSTALLED", "OK",
nullptr, "", nullptr, "", nullptr, true, true, nullptr, "", nullptr, "", nullptr, nullptr, true, true,
(mRenderer->getIsVerticalOrientation() ? (mRenderer->getIsVerticalOrientation() ?
0.70f : 0.70f :
0.45f * (1.778f / mRenderer->getScreenAspectRatio())))); 0.45f * (1.778f / mRenderer->getScreenAspectRatio()))));

View file

@ -672,7 +672,7 @@ void GuiMenu::openUIOptions()
false); false);
mWindow->invalidateCachedBackground(); mWindow->invalidateCachedBackground();
}, },
"CANCEL", nullptr, "", nullptr, true)); "CANCEL", nullptr, "", nullptr, nullptr, true));
} }
else { else {
LOG(LogDebug) << "GuiMenu::openUISettings(): Setting UI mode to '" << selectedMode LOG(LogDebug) << "GuiMenu::openUISettings(): Setting UI mode to '" << selectedMode
@ -1144,7 +1144,7 @@ void GuiMenu::openConfigInput(GuiSettings* settings)
window->pushGui(new GuiMsgBox( window->pushGui(new GuiMsgBox(
getHelpStyle(), message, "PROCEED", getHelpStyle(), message, "PROCEED",
[window] { window->pushGui(new GuiDetectDevice(false, false, nullptr)); }, "CANCEL", [window] { window->pushGui(new GuiDetectDevice(false, false, nullptr)); }, "CANCEL",
nullptr, "", nullptr, false, true, nullptr, "", nullptr, nullptr, false, true,
(mRenderer->getIsVerticalOrientation() ? (mRenderer->getIsVerticalOrientation() ?
0.84f : 0.84f :
0.54f * (1.778f / mRenderer->getScreenAspectRatio())))); 0.54f * (1.778f / mRenderer->getScreenAspectRatio()))));
@ -1665,20 +1665,20 @@ void GuiMenu::openUtilities()
} }
ViewController::getInstance()->rescanROMDirectory(); ViewController::getInstance()->rescanROMDirectory();
}, },
"", nullptr, "", nullptr, true)); "", nullptr, "", nullptr, nullptr, true));
} }
else { else {
mWindow->pushGui( mWindow->pushGui(
new GuiMsgBox(getHelpStyle(), new GuiMsgBox(getHelpStyle(),
"ERROR CREATING SYSTEM DIRECTORIES, PERMISSION PROBLEMS OR " "ERROR CREATING SYSTEM DIRECTORIES, PERMISSION PROBLEMS OR "
"DISK FULL?\nSEE THE LOG FILE FOR MORE DETAILS", "DISK FULL?\nSEE THE LOG FILE FOR MORE DETAILS",
"OK", nullptr, "", nullptr, "", nullptr, true, true, "OK", nullptr, "", nullptr, "", nullptr, nullptr, true, true,
(mRenderer->getIsVerticalOrientation() ? (mRenderer->getIsVerticalOrientation() ?
0.70f : 0.70f :
0.44f * (1.778f / mRenderer->getScreenAspectRatio())))); 0.44f * (1.778f / mRenderer->getScreenAspectRatio()))));
} }
}, },
"CANCEL", nullptr, "", nullptr, false, true, "CANCEL", nullptr, "", nullptr, nullptr, false, true,
(mRenderer->getIsVerticalOrientation() ? (mRenderer->getIsVerticalOrientation() ?
0.80f : 0.80f :
0.52f * (1.778f / mRenderer->getScreenAspectRatio())))); 0.52f * (1.778f / mRenderer->getScreenAspectRatio()))));
@ -1712,7 +1712,7 @@ void GuiMenu::openUtilities()
} }
ViewController::getInstance()->rescanROMDirectory(); ViewController::getInstance()->rescanROMDirectory();
}, },
"CANCEL", nullptr, "", nullptr, false, true, "CANCEL", nullptr, "", nullptr, nullptr, false, true,
(mRenderer->getIsVerticalOrientation() ? (mRenderer->getIsVerticalOrientation() ?
0.80f : 0.80f :
0.52f * (1.778f / mRenderer->getScreenAspectRatio())))); 0.52f * (1.778f / mRenderer->getScreenAspectRatio()))));

View file

@ -997,7 +997,7 @@ void GuiMetaDataEd::close()
save(); save();
closeFunc(); closeFunc();
}, },
"NO", closeFunc, "", nullptr, true)); "NO", closeFunc, "", nullptr, nullptr, true));
} }
else { else {
// Always save if the media files have been changed (i.e. newly scraped images). // Always save if the media files have been changed (i.e. newly scraped images).

View file

@ -1244,7 +1244,7 @@ void GuiScraperMenu::pressedStart()
mWindow->pushGui( mWindow->pushGui(
new GuiMsgBox(getHelpStyle(), Utils::String::toUpper(warningString), "PROCEED", new GuiMsgBox(getHelpStyle(), Utils::String::toUpper(warningString), "PROCEED",
std::bind(&GuiScraperMenu::start, this), "CANCEL", nullptr, "", std::bind(&GuiScraperMenu::start, this), "CANCEL", nullptr, "",
nullptr, false, true, nullptr, nullptr, false, true,
(mRenderer->getIsVerticalOrientation() ? (mRenderer->getIsVerticalOrientation() ?
0.80f : 0.80f :
0.50f * (1.778f / mRenderer->getScreenAspectRatio())))); 0.50f * (1.778f / mRenderer->getScreenAspectRatio()))));

View file

@ -319,10 +319,18 @@ void GuiScraperMulti::finish()
<< mTotalSkipped << " GAME" << ((mTotalSkipped > 1) ? "S" : "") << " SKIPPED"; << mTotalSkipped << " GAME" << ((mTotalSkipped > 1) ? "S" : "") << " SKIPPED";
} }
mWindow->pushGui(new GuiMsgBox(getHelpStyle(), ss.str())); // Pressing either OK or using the back button should delete us.
mWindow->pushGui(new GuiMsgBox(
mIsProcessing = false; getHelpStyle(), ss.str(), "OK",
delete this; [&] {
mIsProcessing = false;
delete this;
},
"", nullptr, "", nullptr,
[&] {
mIsProcessing = false;
delete this;
}));
} }
std::vector<HelpPrompt> GuiScraperMulti::getHelpPrompts() std::vector<HelpPrompt> GuiScraperMulti::getHelpPrompts()

View file

@ -571,13 +571,14 @@ void GuiScraperSearch::onSearchError(const std::string& error,
LOG(LogError) << "GuiScraperSearch: " << Utils::String::replace(error, "\n", ""); LOG(LogError) << "GuiScraperSearch: " << Utils::String::replace(error, "\n", "");
mWindow->pushGui(new GuiMsgBox(getHelpStyle(), Utils::String::toUpper(error), "RETRY", mWindow->pushGui(new GuiMsgBox(getHelpStyle(), Utils::String::toUpper(error), "RETRY",
std::bind(&GuiScraperSearch::search, this, mLastSearch), std::bind(&GuiScraperSearch::search, this, mLastSearch),
"SKIP", mSkipCallback, "CANCEL", mCancelCallback, true)); "SKIP", mSkipCallback, "CANCEL", mCancelCallback, nullptr,
true));
} }
else { else {
LOG(LogError) << "GuiScraperSearch: " << Utils::String::replace(error, "\n", ""); LOG(LogError) << "GuiScraperSearch: " << Utils::String::replace(error, "\n", "");
mWindow->pushGui(new GuiMsgBox(getHelpStyle(), Utils::String::toUpper(error), "RETRY", mWindow->pushGui(new GuiMsgBox(getHelpStyle(), Utils::String::toUpper(error), "RETRY",
std::bind(&GuiScraperSearch::search, this, mLastSearch), std::bind(&GuiScraperSearch::search, this, mLastSearch),
"CANCEL", mCancelCallback, "", nullptr, true)); "CANCEL", mCancelCallback, "", nullptr, nullptr, true));
} }
} }

View file

@ -548,7 +548,7 @@ bool GuiThemeDownloader::renameDirectory(const std::string& path, const std::str
if (renameStatus) { if (renameStatus) {
mWindow->pushGui(new GuiMsgBox( mWindow->pushGui(new GuiMsgBox(
getHelpStyle(), "COULDN'T RENAME DIRECTORY \"" + path + "\", PERMISSION PROBLEMS?", getHelpStyle(), "COULDN'T RENAME DIRECTORY \"" + path + "\", PERMISSION PROBLEMS?",
"OK", [] { return; }, "", nullptr, "", nullptr, true)); "OK", [] { return; }, "", nullptr, "", nullptr, nullptr, true));
return true; return true;
} }
else { else {
@ -571,7 +571,7 @@ void GuiThemeDownloader::parseThemesList()
LOG(LogError) << "GuiThemeDownloader: No themes.json file found"; LOG(LogError) << "GuiThemeDownloader: No themes.json file found";
mWindow->pushGui(new GuiMsgBox( mWindow->pushGui(new GuiMsgBox(
getHelpStyle(), "COULDN'T FIND THE THEMES LIST CONFIGURATION FILE", "OK", getHelpStyle(), "COULDN'T FIND THE THEMES LIST CONFIGURATION FILE", "OK",
[] { return; }, "", nullptr, "", nullptr, true)); [] { return; }, "", nullptr, "", nullptr, nullptr, true));
mGrid.removeEntry(mCenterGrid); mGrid.removeEntry(mCenterGrid);
mGrid.setCursorTo(mButtons); mGrid.setCursorTo(mButtons);
return; return;
@ -587,7 +587,7 @@ void GuiThemeDownloader::parseThemesList()
getHelpStyle(), getHelpStyle(),
"COULDN'T PARSE THE THEMES LIST CONFIGURATION FILE, MAYBE THE LOCAL REPOSITORY IS " "COULDN'T PARSE THE THEMES LIST CONFIGURATION FILE, MAYBE THE LOCAL REPOSITORY IS "
"CORRUPT?", "CORRUPT?",
"OK", [] { return; }, "", nullptr, "", nullptr, true)); "OK", [] { return; }, "", nullptr, "", nullptr, nullptr, true));
mGrid.removeEntry(mCenterGrid); mGrid.removeEntry(mCenterGrid);
mGrid.setCursorTo(mButtons); mGrid.setCursorTo(mButtons);
return; return;
@ -602,7 +602,7 @@ void GuiThemeDownloader::parseThemesList()
getHelpStyle(), getHelpStyle(),
"IT SEEMS AS IF YOU'RE NOT RUNNING THE LATEST ES-DE RELEASE, PLEASE UPGRADE BEFORE " "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", "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; mStatusType = StatusType::STATUS_DOWNLOADING;
mStatusText = "DOWNLOADING THEME"; mStatusText = "DOWNLOADING THEME";
}, },
"CANCEL", [] { return; }, "", nullptr, true, true, "CANCEL", [] { return; }, "", nullptr, nullptr, true, true,
(mRenderer->getIsVerticalOrientation() ? (mRenderer->getIsVerticalOrientation() ?
0.75f : 0.75f :
0.46f * (1.778f / mRenderer->getScreenAspectRatio())))); 0.46f * (1.778f / mRenderer->getScreenAspectRatio()))));
@ -752,7 +752,7 @@ void GuiThemeDownloader::populateGUI()
mStatusType = StatusType::STATUS_DOWNLOADING; mStatusType = StatusType::STATUS_DOWNLOADING;
mStatusText = "DOWNLOADING THEME"; mStatusText = "DOWNLOADING THEME";
}, },
"CANCEL", [] { return; }, "", nullptr, true, true, "CANCEL", [] { return; }, "", nullptr, nullptr, true, true,
(mRenderer->getIsVerticalOrientation() ? (mRenderer->getIsVerticalOrientation() ?
0.75f : 0.75f :
0.46f * (1.778f / mRenderer->getScreenAspectRatio())))); 0.46f * (1.778f / mRenderer->getScreenAspectRatio()))));
@ -779,7 +779,7 @@ void GuiThemeDownloader::populateGUI()
mStatusType = StatusType::STATUS_DOWNLOADING; mStatusType = StatusType::STATUS_DOWNLOADING;
mStatusText = "DOWNLOADING THEME"; mStatusText = "DOWNLOADING THEME";
}, },
"CANCEL", [] { return; }, "", nullptr, true, true, "CANCEL", [] { return; }, "", nullptr, nullptr, true, true,
(mRenderer->getIsVerticalOrientation() ? (mRenderer->getIsVerticalOrientation() ?
0.75f : 0.75f :
0.46f * (1.778f / mRenderer->getScreenAspectRatio())))); 0.46f * (1.778f / mRenderer->getScreenAspectRatio()))));
@ -799,7 +799,7 @@ void GuiThemeDownloader::populateGUI()
mStatusType = StatusType::STATUS_UPDATING; mStatusType = StatusType::STATUS_UPDATING;
mStatusText = "UPDATING THEME"; mStatusText = "UPDATING THEME";
}, },
"CANCEL", [] { return; }, "", nullptr, true, true, "CANCEL", [] { return; }, "", nullptr, nullptr, true, true,
(mRenderer->getIsVerticalOrientation() ? (mRenderer->getIsVerticalOrientation() ?
0.75f : 0.75f :
0.45f * (1.778f / mRenderer->getScreenAspectRatio())))); 0.45f * (1.778f / mRenderer->getScreenAspectRatio()))));
@ -978,7 +978,7 @@ void GuiThemeDownloader::update(int deltaTime)
errorMessage.append(Utils::String::toUpper(mMessage)); errorMessage.append(Utils::String::toUpper(mMessage));
mWindow->pushGui(new GuiMsgBox( mWindow->pushGui(new GuiMsgBox(
getHelpStyle(), errorMessage, "OK", [] { return; }, "", nullptr, "", getHelpStyle(), errorMessage, "OK", [] { return; }, "", nullptr, "",
nullptr, true)); nullptr, nullptr, true));
mMessage = ""; mMessage = "";
getHelpPrompts(); getHelpPrompts();
} }
@ -1164,7 +1164,7 @@ bool GuiThemeDownloader::input(InputConfig* config, Input input)
if (!Utils::FileSystem::removeDirectory(themeDirectory.string(), true)) { if (!Utils::FileSystem::removeDirectory(themeDirectory.string(), true)) {
mWindow->pushGui(new GuiMsgBox( mWindow->pushGui(new GuiMsgBox(
getHelpStyle(), "COULDN'T DELETE THEME, PERMISSION PROBLEMS?", "OK", getHelpStyle(), "COULDN'T DELETE THEME, PERMISSION PROBLEMS?", "OK",
[] { return; }, "", nullptr, "", nullptr, true)); [] { return; }, "", nullptr, "", nullptr, nullptr, true));
} }
else { else {
mMessage = "THEME WAS DELETED"; mMessage = "THEME WAS DELETED";
@ -1173,7 +1173,7 @@ bool GuiThemeDownloader::input(InputConfig* config, Input input)
makeInventory(); makeInventory();
updateGUI(); updateGUI();
}, },
"CANCEL", nullptr, "", nullptr, true, true, "CANCEL", nullptr, "", nullptr, nullptr, true, true,
(mRenderer->getIsVerticalOrientation() ? (mRenderer->getIsVerticalOrientation() ?
0.70f : 0.70f :
0.44f * (1.778f / mRenderer->getScreenAspectRatio())))); 0.44f * (1.778f / mRenderer->getScreenAspectRatio()))));
@ -1247,7 +1247,7 @@ bool GuiThemeDownloader::fetchThemesList()
delete this; delete this;
return false; return false;
}, },
"", nullptr, true, true, "", nullptr, nullptr, true, true,
(mRenderer->getIsVerticalOrientation() ? (mRenderer->getIsVerticalOrientation() ?
0.75f : 0.75f :
0.50f * (1.778f / mRenderer->getScreenAspectRatio())))); 0.50f * (1.778f / mRenderer->getScreenAspectRatio()))));
@ -1285,7 +1285,7 @@ bool GuiThemeDownloader::fetchThemesList()
delete this; delete this;
return false; return false;
}, },
"", nullptr, true, true, "", nullptr, nullptr, true, true,
(mRenderer->getIsVerticalOrientation() ? (mRenderer->getIsVerticalOrientation() ?
0.85f : 0.85f :
0.54f * (1.778f / mRenderer->getScreenAspectRatio())))); 0.54f * (1.778f / mRenderer->getScreenAspectRatio()))));

View file

@ -148,7 +148,8 @@ void ViewController::unsafeUpgradeDialog()
"README.TXT FILE THAT CAN BE FOUND IN THE EMULATIONSTATION-DE " "README.TXT FILE THAT CAN BE FOUND IN THE EMULATIONSTATION-DE "
"DIRECTORY."}; "DIRECTORY."};
mWindow->pushGui(new GuiMsgBox( 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() ? (mRenderer->getIsVerticalOrientation() ?
0.85f : 0.85f :
0.55f * (1.778f / mRenderer->getScreenAspectRatio())))); 0.55f * (1.778f / mRenderer->getScreenAspectRatio()))));
@ -170,7 +171,7 @@ void ViewController::invalidSystemsFileDialog()
quit.type = SDL_QUIT; quit.type = SDL_QUIT;
SDL_PushEvent(&quit); SDL_PushEvent(&quit);
}, },
"", nullptr, "", nullptr, true, true, "", nullptr, "", nullptr, nullptr, true, true,
(mRenderer->getIsVerticalOrientation() ? (mRenderer->getIsVerticalOrientation() ?
0.85f : 0.85f :
0.55f * (1.778f / mRenderer->getScreenAspectRatio())))); 0.55f * (1.778f / mRenderer->getScreenAspectRatio()))));
@ -220,7 +221,7 @@ void ViewController::noGamesDialog()
"ROM DIRECTORY SETTING SAVED, RESTART\n" "ROM DIRECTORY SETTING SAVED, RESTART\n"
"THE APPLICATION TO RESCAN THE SYSTEMS", "THE APPLICATION TO RESCAN THE SYSTEMS",
"OK", nullptr, "", nullptr, "", nullptr, "OK", nullptr, "", nullptr, "", nullptr,
true, true)); nullptr, true, true));
} }
}, },
false, "SAVE", "SAVE CHANGES?", "Currently configured path:", false, "SAVE", "SAVE CHANGES?", "Currently configured path:",
@ -245,7 +246,7 @@ void ViewController::noGamesDialog()
"ROM DIRECTORY SETTING SAVED, RESTART\n" "ROM DIRECTORY SETTING SAVED, RESTART\n"
"THE APPLICATION TO RESCAN THE SYSTEMS", "THE APPLICATION TO RESCAN THE SYSTEMS",
"OK", nullptr, "", nullptr, "", nullptr, "OK", nullptr, "", nullptr, "", nullptr,
true)); nullptr, true));
}, },
false, "SAVE", "SAVE CHANGES?", "Currently configured path:", false, "SAVE", "SAVE CHANGES?", "Currently configured path:",
currentROMDirectory, "LOAD CURRENTLY CONFIGURED PATH", currentROMDirectory, "LOAD CURRENTLY CONFIGURED PATH",
@ -268,7 +269,7 @@ void ViewController::noGamesDialog()
"GENERATED, EXIT THE APPLICATION AND PLACE\n" "GENERATED, EXIT THE APPLICATION AND PLACE\n"
"YOUR GAMES IN THE NEWLY CREATED FOLDERS", "YOUR GAMES IN THE NEWLY CREATED FOLDERS",
"OK", nullptr, "", nullptr, "", nullptr, "OK", nullptr, "", nullptr, "", nullptr,
true)); nullptr, true));
} }
else { else {
mWindow->pushGui(new GuiMsgBox(HelpStyle(), mWindow->pushGui(new GuiMsgBox(HelpStyle(),
@ -276,10 +277,10 @@ void ViewController::noGamesDialog()
"PERMISSION PROBLEMS OR DISK FULL?\n\n" "PERMISSION PROBLEMS OR DISK FULL?\n\n"
"SEE THE LOG FILE FOR MORE DETAILS", "SEE THE LOG FILE FOR MORE DETAILS",
"OK", nullptr, "", nullptr, "", nullptr, "OK", nullptr, "", nullptr, "", nullptr,
true)); nullptr, true));
} }
}, },
"CANCEL", nullptr, "", nullptr, true)); "CANCEL", nullptr, "", nullptr, nullptr, true));
}, },
"QUIT", "QUIT",
[] { [] {
@ -287,7 +288,7 @@ void ViewController::noGamesDialog()
quit.type = SDL_QUIT; quit.type = SDL_QUIT;
SDL_PushEvent(&quit); SDL_PushEvent(&quit);
}, },
true, false, nullptr, true, false,
(mRenderer->getIsVerticalOrientation() ? (mRenderer->getIsVerticalOrientation() ?
0.90f : 0.90f :
0.62f * (1.778f / mRenderer->getScreenAspectRatio()))); 0.62f * (1.778f / mRenderer->getScreenAspectRatio())));
@ -305,7 +306,7 @@ void ViewController::invalidAlternativeEmulatorDialog()
"CONFIGURATION FILE, PLEASE REVIEW YOUR\n" "CONFIGURATION FILE, PLEASE REVIEW YOUR\n"
"SETUP USING THE 'ALTERNATIVE EMULATORS'\n" "SETUP USING THE 'ALTERNATIVE EMULATORS'\n"
"INTERFACE IN THE 'OTHER SETTINGS' MENU", "INTERFACE IN THE 'OTHER SETTINGS' MENU",
"OK", nullptr, "", nullptr, "", nullptr, true, true)); "OK", nullptr, "", nullptr, "", nullptr, nullptr, true, true));
} }
void ViewController::updateAvailableDialog() void ViewController::updateAvailableDialog()
@ -355,20 +356,20 @@ void ViewController::updateAvailableDialog()
} }
mWindow->pushGui(new GuiMsgBox( mWindow->pushGui(new GuiMsgBox(
getHelpStyle(), upgradeMessage.c_str(), "OK", [] {}, "", nullptr, "", getHelpStyle(), upgradeMessage.c_str(), "OK", [] {}, "", nullptr, "",
nullptr, true, true, nullptr, nullptr, true, true,
(mRenderer->getIsVerticalOrientation() ? (mRenderer->getIsVerticalOrientation() ?
0.85f : 0.85f :
0.535f * (1.778f / mRenderer->getScreenAspectRatio())))); 0.535f * (1.778f / mRenderer->getScreenAspectRatio()))));
} }
}, },
"CANCEL", [] { return; }, "", nullptr, true, true, "CANCEL", [] { return; }, "", nullptr, nullptr, true, true,
(mRenderer->getIsVerticalOrientation() ? (mRenderer->getIsVerticalOrientation() ?
0.70f : 0.70f :
0.45f * (1.778f / mRenderer->getScreenAspectRatio())))); 0.45f * (1.778f / mRenderer->getScreenAspectRatio()))));
} }
else { else {
mWindow->pushGui(new GuiMsgBox(getHelpStyle(), results, "OK", nullptr, "", nullptr, "", mWindow->pushGui(new GuiMsgBox(getHelpStyle(), results, "OK", nullptr, "", nullptr, "",
nullptr, true, true, nullptr, nullptr, true, true,
(mRenderer->getIsVerticalOrientation() ? (mRenderer->getIsVerticalOrientation() ?
0.70f : 0.70f :
0.45f * (1.778f / mRenderer->getScreenAspectRatio())))); 0.45f * (1.778f / mRenderer->getScreenAspectRatio()))));

View file

@ -23,6 +23,7 @@ GuiMsgBox::GuiMsgBox(const HelpStyle& helpstyle,
const std::function<void()>& func2, const std::function<void()>& func2,
const std::string& name3, const std::string& name3,
const std::function<void()>& func3, const std::function<void()>& func3,
const std::function<void()>& backFunc,
const bool disableBackButton, const bool disableBackButton,
const bool deleteOnButtonPress, const bool deleteOnButtonPress,
const float maxWidthMultiplier) const float maxWidthMultiplier)
@ -30,6 +31,7 @@ GuiMsgBox::GuiMsgBox(const HelpStyle& helpstyle,
, mBackground {":/graphics/frame.svg"} , mBackground {":/graphics/frame.svg"}
, mGrid {glm::ivec2 {1, 2}} , mGrid {glm::ivec2 {1, 2}}
, mHelpStyle {helpstyle} , mHelpStyle {helpstyle}
, mBackFunc {backFunc}
, mDisableBackButton {disableBackButton} , mDisableBackButton {disableBackButton}
, mDeleteOnButtonPress {deleteOnButtonPress} , mDeleteOnButtonPress {deleteOnButtonPress}
, mMaxWidthMultiplier {maxWidthMultiplier} , mMaxWidthMultiplier {maxWidthMultiplier}
@ -133,6 +135,8 @@ void GuiMsgBox::changeText(const std::string& newText)
bool GuiMsgBox::input(InputConfig* config, Input input) bool GuiMsgBox::input(InputConfig* config, Input input)
{ {
if (!mDisableBackButton && config->isMappedTo("b", input) && input.value != 0) { if (!mDisableBackButton && config->isMappedTo("b", input) && input.value != 0) {
if (mBackFunc)
mBackFunc();
delete this; delete this;
return true; return true;
} }

View file

@ -28,6 +28,7 @@ public:
const std::function<void()>& func2 = nullptr, const std::function<void()>& func2 = nullptr,
const std::string& name3 = "", const std::string& name3 = "",
const std::function<void()>& func3 = nullptr, const std::function<void()>& func3 = nullptr,
const std::function<void()>& backFunc = nullptr,
const bool disableBackButton = false, const bool disableBackButton = false,
const bool deleteOnButtonPress = true, const bool deleteOnButtonPress = true,
const float maxWidthMultiplier = 0.0f); const float maxWidthMultiplier = 0.0f);
@ -51,6 +52,7 @@ private:
std::shared_ptr<TextComponent> mMsg; std::shared_ptr<TextComponent> mMsg;
std::vector<std::shared_ptr<ButtonComponent>> mButtons; std::vector<std::shared_ptr<ButtonComponent>> mButtons;
std::shared_ptr<ComponentGrid> mButtonGrid; std::shared_ptr<ComponentGrid> mButtonGrid;
const std::function<void()> mBackFunc;
bool mDisableBackButton; bool mDisableBackButton;
bool mDeleteOnButtonPress; bool mDeleteOnButtonPress;
float mMaxWidthMultiplier; float mMaxWidthMultiplier;

View file

@ -375,7 +375,7 @@ bool GuiTextEditKeyboardPopup::input(InputConfig* config, Input input)
delete this; delete this;
return true; return true;
}, },
"", nullptr, true)); "", nullptr, nullptr, true));
} }
else { else {
delete this; delete this;

View file

@ -186,7 +186,7 @@ bool GuiTextEditPopup::input(InputConfig* config, Input input)
delete this; delete this;
return true; return true;
}, },
"", nullptr, true)); "", nullptr, nullptr, true));
} }
else { else {
delete this; delete this;