From: Rudolf Polzer Date: Tue, 8 Oct 2013 03:51:16 +0000 (+0200) Subject: Fixes X-Git-Tag: xonotic-v0.8.0~300 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=ac828a4561855509c384c8d589b04c6f0115a837;p=xonotic%2Fxonotic-data.pk3dir.git Fixes --- diff --git a/qcsrc/menu/item/listbox.c b/qcsrc/menu/item/listbox.c index dc2663149..1087c3479 100644 --- a/qcsrc/menu/item/listbox.c +++ b/qcsrc/menu/item/listbox.c @@ -106,13 +106,33 @@ float ListBox_keyDown(entity me, float key, float ascii, float shift) } else if(key == K_PGUP || key == K_KP_PGUP) { - me.scrollPos = max(me.scrollPos - 1, 0); - me.setSelected(me, min(me.selectedItem, me.getLastFullyVisibleItemAtScrollPos(me, me.scrollPos))); + float i = me.selectedItem; + float a = me.getItemHeight(me, i); + for(;;) + { + --i; + if (i < 0) + break; + a += me.getItemHeight(me, i); + if (a >= 1) + break; + } + me.setSelected(me, i + 1); } else if(key == K_PGDN || key == K_KP_PGDN) { - me.scrollPos = min(me.scrollPos + 1, me.getTotalHeight(me) - 1); - me.setSelected(me, max(me.selectedItem, me.getFirstFullyVisibleItemAtScrollPos(me, me.scrollPos))); + float i = me.selectedItem; + float a = me.getItemHeight(me, i); + for(;;) + { + ++i; + if (i >= me.nItems) + break; + a += me.getItemHeight(me, i); + if (a >= 1) + break; + } + me.setSelected(me, i - 1); } else if(key == K_UPARROW || key == K_KP_UPARROW) me.setSelected(me, me.selectedItem - 1); @@ -325,7 +345,7 @@ void ListBox_draw(entity me) absSize = boxToGlobalSize(relSize, me.size); draw_scale = boxToGlobalSize(relSize, oldscale); me.drawListBoxItem(me, i, absSize, (me.selectedItem == i)); - y += absSize_y; + y += relSize_y; } draw_ClearClip();