- don't freeze if the menu item search can't find anything selectable.

This commit is contained in:
Christoph Oelckers 2016-03-03 10:47:11 +01:00
parent d8c009bb41
commit 4d2b9fbe1b
1 changed files with 4 additions and 0 deletions

View File

@ -156,7 +156,9 @@ bool DListMenu::Responder (event_t *ev)
bool DListMenu::MenuEvent (int mkey, bool fromcontroller)
{
int oldSelect = mDesc->mSelectedItem;
int startedAt = mDesc->mSelectedItem;
if (startedAt < 0) startedAt = 0;
switch (mkey)
{
@ -166,6 +168,7 @@ bool DListMenu::MenuEvent (int mkey, bool fromcontroller)
if (--mDesc->mSelectedItem < 0) mDesc->mSelectedItem = mDesc->mItems.Size()-1;
}
while (!mDesc->mItems[mDesc->mSelectedItem]->Selectable() && mDesc->mSelectedItem != startedAt);
if (mDesc->mSelectedItem == startedAt) mDesc->mSelectedItem = oldSelect;
S_Sound (CHAN_VOICE | CHAN_UI, "menu/cursor", snd_menuvolume, ATTN_NONE);
return true;
@ -175,6 +178,7 @@ bool DListMenu::MenuEvent (int mkey, bool fromcontroller)
if (++mDesc->mSelectedItem >= (int)mDesc->mItems.Size()) mDesc->mSelectedItem = 0;
}
while (!mDesc->mItems[mDesc->mSelectedItem]->Selectable() && mDesc->mSelectedItem != startedAt);
if (mDesc->mSelectedItem == startedAt) mDesc->mSelectedItem = oldSelect;
S_Sound (CHAN_VOICE | CHAN_UI, "menu/cursor", snd_menuvolume, ATTN_NONE);
return true;