From: TimePath Date: Wed, 16 Sep 2015 05:07:27 +0000 (+1000) Subject: Smooth scroll: averaging_time cvar `menu_scroll_averaging_time` X-Git-Tag: xonotic-v0.8.2~1927 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=a81ef9fc9c4896fc3f3c367e0a8ffd4a348339f4;p=xonotic%2Fxonotic-data.pk3dir.git Smooth scroll: averaging_time cvar `menu_scroll_averaging_time` --- diff --git a/qcsrc/menu/item/listbox.qc b/qcsrc/menu/item/listbox.qc index 9cd76fe98..87f1719b4 100644 --- a/qcsrc/menu/item/listbox.qc +++ b/qcsrc/menu/item/listbox.qc @@ -397,6 +397,9 @@ void ListBox_updateControlTopBottom(entity me) } } } +AUTOCVAR(menu_scroll_averaging_time, float, 0.16, "smooth scroll averaging time"); +// scroll faster while dragging the scrollbar +AUTOCVAR(menu_scroll_averaging_time_pressed, float, 0.06, "smooth scroll averaging time when dragging the scrollbar"); void ListBox_draw(entity me) { float i; @@ -418,11 +421,11 @@ void ListBox_draw(entity me) } if(me.scrollPos != me.scrollPosTarget) { - float averaging_time = 0.16; - if(me.pressed == 1) - averaging_time = 0.06; // scroll faster while dragging the scrollbar + float averaging_time = (me.pressed == 1) + ? autocvar_menu_scroll_averaging_time_pressed + : autocvar_menu_scroll_averaging_time; // this formula works with whatever framerate - float f = exp(-frametime / averaging_time); + float f = averaging_time ? exp(-frametime / averaging_time) : 0; me.scrollPos = me.scrollPos * f + me.scrollPosTarget * (1 - f); if(fabs(me.scrollPos - me.scrollPosTarget) < 0.001) me.scrollPos = me.scrollPosTarget;