mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-10 15:21:44 +00:00
Iterate once through menu item list
Avoids any infinite loop cases.
This commit is contained in:
parent
c6f6a17176
commit
c03f4fd094
1 changed files with 21 additions and 41 deletions
|
@ -329,7 +329,7 @@ Menu_AddItem(menuframework_s *menu, void *item)
|
||||||
void
|
void
|
||||||
Menu_AdjustCursor(menuframework_s *m, int dir)
|
Menu_AdjustCursor(menuframework_s *m, int dir)
|
||||||
{
|
{
|
||||||
menucommon_s *citem;
|
menucommon_s *citem = NULL;
|
||||||
|
|
||||||
/* see if it's in a valid spot */
|
/* see if it's in a valid spot */
|
||||||
if ((m->cursor >= 0) && (m->cursor < m->nitems))
|
if ((m->cursor >= 0) && (m->cursor < m->nitems))
|
||||||
|
@ -346,50 +346,31 @@ Menu_AdjustCursor(menuframework_s *m, int dir)
|
||||||
|
|
||||||
/* it's not in a valid spot, so crawl in the direction
|
/* it's not in a valid spot, so crawl in the direction
|
||||||
indicated until we find a valid spot */
|
indicated until we find a valid spot */
|
||||||
if (dir == 1)
|
int cursor = m->nitems;
|
||||||
{
|
|
||||||
while (1)
|
while (cursor-- > 0)
|
||||||
|
{
|
||||||
|
citem = Menu_ItemAtCursor(m);
|
||||||
|
|
||||||
|
if (citem)
|
||||||
{
|
{
|
||||||
citem = Menu_ItemAtCursor(m);
|
if (citem->type != MTYPE_SEPARATOR &&
|
||||||
|
(citem->flags & QMF_INACTIVE) != QMF_INACTIVE)
|
||||||
if (citem)
|
|
||||||
{
|
{
|
||||||
if (citem->type != MTYPE_SEPARATOR &&
|
break;
|
||||||
(citem->flags & QMF_INACTIVE) != QMF_INACTIVE)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m->cursor += dir;
|
|
||||||
|
|
||||||
if (m->cursor >= m->nitems)
|
|
||||||
{
|
|
||||||
m->cursor = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
m->cursor += dir;
|
||||||
{
|
|
||||||
while (1)
|
if (m->cursor >= m->nitems)
|
||||||
{
|
{
|
||||||
citem = Menu_ItemAtCursor(m);
|
m->cursor = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (citem)
|
if (m->cursor < 0)
|
||||||
{
|
{
|
||||||
if (citem->type != MTYPE_SEPARATOR &&
|
m->cursor = m->nitems - 1;
|
||||||
(citem->flags & QMF_INACTIVE) != QMF_INACTIVE)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m->cursor += dir;
|
|
||||||
|
|
||||||
if (m->cursor < 0)
|
|
||||||
{
|
|
||||||
m->cursor = m->nitems - 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -431,9 +412,8 @@ Menu_Draw(menuframework_s *menu)
|
||||||
SpinControl_Draw((menulist_s *)menu->items[i]);
|
SpinControl_Draw((menulist_s *)menu->items[i]);
|
||||||
break;
|
break;
|
||||||
case MTYPE_BITMAP:
|
case MTYPE_BITMAP:
|
||||||
{
|
|
||||||
Bitmap_Draw(( menubitmap_s * )menu->items[i]);
|
Bitmap_Draw(( menubitmap_s * )menu->items[i]);
|
||||||
} break;
|
break;
|
||||||
case MTYPE_ACTION:
|
case MTYPE_ACTION:
|
||||||
Action_Draw((menuaction_s *)menu->items[i]);
|
Action_Draw((menuaction_s *)menu->items[i]);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue