Skip to content

Commit

Permalink
libcommon|Menu: Close the game menu if open when performing a reset
Browse files Browse the repository at this point in the history
On second thought, simply close the menu if its open at reset time.
It may be that the previously active page no longer exists, or, it
no longer has an equivalent focusable item following the rebuild.
  • Loading branch information
danij-deng committed Jul 20, 2014
1 parent ea64050 commit 71f3307
Showing 1 changed file with 4 additions and 21 deletions.
25 changes: 4 additions & 21 deletions doomsday/plugins/common/src/hu_menu.cpp
Expand Up @@ -3579,19 +3579,8 @@ Page *Hu_MenuNewPage(char const *name, Point2Raw const *origin, int flags,

void Hu_MenuInit()
{
cvarbutton_t *cvb;
bool wasOpen = false;
String activePageName;

if(inited)
{
// Remember the previously open menu page, if any.
/// @todo Remember the previously focused widget on said page -ds
wasOpen = Hu_MenuIsActive();
activePageName = Hu_MenuFindPageName(Hu_MenuActivePage());

Hu_MenuShutdown();
}
// Close the menu (if open) and shutdown (if initialized - we're reinitializing).
Hu_MenuShutdown();

mnAlpha = mnTargetAlpha = 0;
menuActivePage = 0;
Expand All @@ -3606,7 +3595,7 @@ void Hu_MenuInit()
Hu_MenuLoadResources();

// Set default Yes/No strings.
for(cvb = mnCVarButtons; cvb->cvarname; cvb++)
for(cvarbutton_t *cvb = mnCVarButtons; cvb->cvarname; cvb++)
{
if(!cvb->yes) cvb->yes = "Yes";
if(!cvb->no) cvb->no = "No";
Expand All @@ -3626,20 +3615,14 @@ void Hu_MenuInit()
}
#endif

// Are we re-opening?
if(wasOpen)
{
Hu_MenuCommand(MCMD_OPEN);
}
Hu_MenuSetActivePage(Hu_MenuFindPageByName(activePageName));

inited = true;
}

void Hu_MenuShutdown()
{
if(!inited) return;

Hu_MenuCommand(MCMD_CLOSEFAST);
destroyAllPages();
inited = false;
}
Expand Down

0 comments on commit 71f3307

Please sign in to comment.