From a81ef9fc9c4896fc3f3c367e0a8ffd4a348339f4 Mon Sep 17 00:00:00 2001 From: TimePath Date: Wed, 16 Sep 2015 15:07:27 +1000 Subject: [PATCH] Smooth scroll: averaging_time cvar `menu_scroll_averaging_time` --- qcsrc/menu/item/listbox.qc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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; -- 2.39.2