Two fixes concerning items selection in menu

The first fixes the last use of menusel, that wasn't checked for range yet.
The second one brings menusel back into range, if there is no
refresh function.
This commit is contained in:
aurhat
2014-07-05 12:55:15 +02:00
parent c2dbf57816
commit 4c3176611a
+6 -4
View File
@@ -128,7 +128,7 @@ void menuselect(void *menu, int sel)
{
if(sel!=oldsel)
{
m.items[oldsel]->focus(false);
if(m.items.inrange(oldsel)) m.items[oldsel]->focus(false);
m.items[sel]->focus(true);
audiomgr.playsound(S_MENUSELECT, SP_HIGHEST);
}
@@ -1210,9 +1210,11 @@ void rendermenumdl()
void gmenu::refresh()
{
if(!refreshfunc) return;
(*refreshfunc)(this, !inited);
inited = true;
if(refreshfunc)
{
(*refreshfunc)(this, !inited);
inited = true;
}
if(menusel>=items.length()) menusel = max(items.length()-1, 0);
}