- fixed Exhumed's ingame menu.

The bad setup here didn't let the menu's exit action pass to the game code, it still needed ugly workarounds.
This commit is contained in:
Christoph Oelckers 2020-03-01 16:32:41 +01:00
parent 2e8ace603b
commit 12af524dcc
3 changed files with 28 additions and 8 deletions

View file

@ -838,8 +838,18 @@ bool M_DoResponder (event_t *ev)
bool M_Responder(event_t* ev) bool M_Responder(event_t* ev)
{ {
bool res = false;
// delayed deletion, so that self-deleting menus don't crash if they are getting accessed after being closed. // delayed deletion, so that self-deleting menus don't crash if they are getting accessed after being closed.
auto res = M_DoResponder(ev); try
{
res = M_DoResponder(ev);
}
catch (...)
{
for (auto p : toDelete) delete p;
toDelete.Clear();
throw;
}
for (auto p : toDelete) delete p; for (auto p : toDelete) delete p;
toDelete.Clear(); toDelete.Clear();
return res; return res;

View file

@ -42,11 +42,9 @@ int handle1;
int MenuExitCondition; int MenuExitCondition;
int MenuStartCondition;
int menu_Menu(int nVal) int menu_Menu(int nVal)
{ {
MenuStartCondition = nVal;
MenuExitCondition = -2; MenuExitCondition = -2;
M_StartControlPanel(false); M_StartControlPanel(false);
M_SetMenu(NAME_MainMenu); M_SetMenu(NAME_MainMenu);
@ -70,7 +68,9 @@ int menu_Menu(int nVal)
videoNextPage(); videoNextPage();
} }
return MenuExitCondition; int me = MenuExitCondition;
MenuExitCondition = -2;
return me;
} }
@ -107,7 +107,13 @@ class PSMainMenu : public DListMenu
void PreDraw() override void PreDraw() override
{ {
if (mDesc->mMenuName == NAME_MainMenu)
menu_DoPlasma(); menu_DoPlasma();
else
{
auto nLogoTile = EXHUMED ? kExhumedLogo : kPowerslaveLogo;
overwritesprite(160, 40, nLogoTile, 32, 3, kPalNormal);
}
} }
}; };

View file

@ -822,9 +822,12 @@ void timerhandler()
} }
} }
extern int MenuExitCondition;
void HandleAsync() void HandleAsync()
{ {
MenuExitCondition = -2;
handleevents(); handleevents();
} }
int MyGetStringWidth(const char *str) int MyGetStringWidth(const char *str)
@ -2357,12 +2360,12 @@ GAMELOOP:
} }
if (!bInDemo) if (!bInDemo)
{ {
if (inputState.GetKeyStatus(sc_Escape)) nMenu = MenuExitCondition;
if (nMenu != -2)
{ {
inputState.ClearKeyStatus(sc_Escape); MenuExitCondition = -2;
// MENU2: // MENU2:
bInMove = kTrue; bInMove = kTrue;
nMenu = menu_Menu(1);
switch (nMenu) switch (nMenu)
{ {
@ -2379,6 +2382,7 @@ GAMELOOP:
goto LOOP2; goto LOOP2;
case 3: case 3:
forcelevel = 0;
goto STARTGAME2; goto STARTGAME2;
case 6: case 6:
goto GAMELOOP; goto GAMELOOP;