- made some adjustments to DMessageBoxMenu to handle screens that must close the menu before performing their option.

Fixes #173. The "End Game" menu option needs this.
This commit is contained in:
Christoph Oelckers 2020-08-12 19:04:19 +02:00
parent 2d545767ef
commit 2dad86a304
3 changed files with 8 additions and 4 deletions

View file

@ -766,7 +766,7 @@ void I_ReleaseMouseCapture();
struct MenuClassDescriptor;
extern TArray<MenuClassDescriptor*> menuClasses;
using hFunc = std::function<void(bool)>;
using hFunc = std::function<bool(bool)>;
DMenu* CreateMessageBoxMenu(DMenu* parent, const char* message, int messagemode, int scriptID, bool playsound, FName action = NAME_None, hFunc handler = nullptr);

View file

@ -77,7 +77,7 @@ class DMessageBoxMenu : public DMenu
int messageSelection;
int mMouseLeft, mMouseRight, mMouseY;
FName mAction;
std::function<void(bool)> mActionFunc;
std::function<bool(bool)> mActionFunc;
public:
@ -170,8 +170,7 @@ void DMessageBoxMenu::HandleResult(bool res)
{
if (mActionFunc)
{
mActionFunc(res);
Close();
if (mActionFunc(res)) Close();
}
else if (mAction == NAME_None && mParentMenu)
{
@ -433,7 +432,9 @@ CCMD (menu_endgame)
STAT_Cancel();
M_ClearMenus();
gi->QuitToTitle();
return false;
}
return true;
});
M_ActivateMenu(newmenu);
@ -456,6 +457,7 @@ CCMD (menu_quit)
DMenu *newmenu = CreateMessageBoxMenu(CurrentMenu, EndString, 0, 500, false, NAME_None, [](bool res)
{
if (res) gi->ExitFromMenu();
return true;
});
M_ActivateMenu(newmenu);

View file

@ -668,6 +668,7 @@ CCMD(quicksave)
{
savegameManager.SaveGame(savegameManager.quickSaveSlot, true, true);
}
return true;
});
M_ActivateMenu(newmenu);
@ -716,6 +717,7 @@ CCMD(quickload)
{
savegameManager.LoadGame(savegameManager.quickSaveSlot);
}
return true;
});
M_ActivateMenu(newmenu);
}