- added some range checks to PgUp(PgDown code for option menus.

This commit is contained in:
Christoph Oelckers 2016-01-23 21:23:02 +01:00
parent c4377b7039
commit 0dabaca7df

View file

@ -274,7 +274,14 @@ bool DOptionMenu::MenuEvent (int mkey, bool fromcontroller)
mDesc->mSelectedItem = mDesc->mScrollTop + mDesc->mScrollPos + 1; mDesc->mSelectedItem = mDesc->mScrollTop + mDesc->mScrollPos + 1;
while (!mDesc->mItems[mDesc->mSelectedItem]->Selectable()) while (!mDesc->mItems[mDesc->mSelectedItem]->Selectable())
{ {
++mDesc->mSelectedItem; if (++mDesc->mSelectedItem >= (int)mDesc->mItems.Size())
{
mDesc->mSelectedItem = 0;
}
}
if (mDesc->mScrollPos > mDesc->mSelectedItem)
{
mDesc->mScrollPos = mDesc->mSelectedItem;
} }
} }
} }
@ -294,7 +301,14 @@ bool DOptionMenu::MenuEvent (int mkey, bool fromcontroller)
mDesc->mSelectedItem = mDesc->mScrollTop + mDesc->mScrollPos; mDesc->mSelectedItem = mDesc->mScrollTop + mDesc->mScrollPos;
while (!mDesc->mItems[mDesc->mSelectedItem]->Selectable()) while (!mDesc->mItems[mDesc->mSelectedItem]->Selectable())
{ {
++mDesc->mSelectedItem; if (++mDesc->mSelectedItem >= (int)mDesc->mItems.Size())
{
mDesc->mSelectedItem = 0;
}
}
if (mDesc->mScrollPos > mDesc->mSelectedItem)
{
mDesc->mScrollPos = mDesc->mSelectedItem;
} }
} }
} }