1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-07 03:54:40 +00:00

Ask for confirmation to exit OpenMW

This commit is contained in:
scrawl 2014-03-26 22:05:21 +01:00
parent a5598e9c2e
commit e5e1e84c52
2 changed files with 18 additions and 1 deletions

View File

@ -68,6 +68,11 @@ namespace MWGui
MWBase::Environment::get().getStateManager()->newGame();
}
void MainMenu::onExitConfirmed()
{
MWBase::Environment::get().getStateManager()->requestQuit();
}
void MainMenu::onButtonClicked(MyGUI::Widget *sender)
{
std::string name = *sender->getUserData<std::string>();
@ -82,7 +87,18 @@ namespace MWGui
else if (name == "credits")
MWBase::Environment::get().getWorld()->playVideo("mw_credits.bik", true);
else if (name == "exitgame")
MWBase::Environment::get().getStateManager()->requestQuit();
{
if (MWBase::Environment::get().getStateManager()->getState() == MWBase::StateManager::State_NoGame)
onExitConfirmed();
else
{
ConfirmationDialog* dialog = MWBase::Environment::get().getWindowManager()->getConfirmationDialog();
dialog->open("#{sMessage2}");
dialog->eventOkClicked.clear();
dialog->eventOkClicked += MyGUI::newDelegate(this, &MainMenu::onExitConfirmed);
dialog->eventCancelClicked.clear();
}
}
else if (name == "newgame")
{
if (MWBase::Environment::get().getStateManager()->getState() == MWBase::StateManager::State_NoGame)

View File

@ -33,6 +33,7 @@ namespace MWGui
void onButtonClicked (MyGUI::Widget* sender);
void onNewGameConfirmed();
void onExitConfirmed();
void updateMenu();