From 8d3021903c6838918247d0e889029b60842fe999 Mon Sep 17 00:00:00 2001 From: div0 Date: Sat, 26 Jan 2008 12:21:31 +0000 Subject: [PATCH] change dragScrollTimer to be an absolute time instead of a counter that gets decreased by frametime; fixes drag scrolling speed issues with menu_slowmo git-svn-id: svn://svn.icculus.org/nexuiz/trunk@3283 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/qcsrc/menu/item/inputbox.c | 9 ++++----- data/qcsrc/menu/item/listbox.c | 9 ++++----- data/qcsrc/menu/nexuiz/credits.c | 2 +- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/data/qcsrc/menu/item/inputbox.c b/data/qcsrc/menu/item/inputbox.c index 7afd04517..959eeb72f 100644 --- a/data/qcsrc/menu/item/inputbox.c +++ b/data/qcsrc/menu/item/inputbox.c @@ -61,7 +61,7 @@ float mouseDragInputBox(entity me, vector pos) float mousePressInputBox(entity me, vector pos) { - me.dragScrollTimer = 0; + me.dragScrollTimer = time; me.pressed = 1; return mouseDragInputBox(me, pos); } @@ -85,7 +85,7 @@ void enterTextInputBox(entity me, string ch) float keyDownInputBox(entity me, float key, float ascii, float shift) { me.lastChangeTime = time; - me.dragScrollTimer = 0; + me.dragScrollTimer = time; if(ascii >= 32 && ascii != 127) { me.enterText(me, chr(ascii)); @@ -149,14 +149,13 @@ void drawInputBox(entity me) cursorPosInWidths = draw_TextWidth(substring(me.text, 0, me.cursorPos), 0) * me.realFontSize_x; totalSizeInWidths = draw_TextWidth(strcat(me.text, CURSOR), 0) * me.realFontSize_x; - me.dragScrollTimer -= frametime; - if(me.dragScrollTimer < 0) + if(me.dragScrollTimer < time) { float save; save = me.scrollPos; me.scrollPos = bound(cursorPosInWidths - (0.875 - me.keepspaceLeft - me.keepspaceRight), me.scrollPos, cursorPosInWidths - 0.125); if(me.scrollPos != save) - me.dragScrollTimer = 0.2; + me.dragScrollTimer = time + 0.2; } me.scrollPos = min(me.scrollPos, totalSizeInWidths - (1 - me.keepspaceRight - me.keepspaceLeft)); me.scrollPos = max(0, me.scrollPos); diff --git a/data/qcsrc/menu/item/listbox.c b/data/qcsrc/menu/item/listbox.c index cf35fffb7..99bbc4505 100644 --- a/data/qcsrc/menu/item/listbox.c +++ b/data/qcsrc/menu/item/listbox.c @@ -54,7 +54,7 @@ void configureListBoxListBox(entity me, float theScrollbarWidth, float theItemHe } float keyDownListBox(entity me, float key, float ascii, float shift) { - me.dragScrollTimer = 0; + me.dragScrollTimer = time; if(key == K_MWHEELUP) { me.scrollPos = max(me.scrollPos - 0.5, 0); @@ -129,7 +129,7 @@ float mousePressListBox(entity me, vector pos) if(pos_y >= 1) return 0; me.dragScrollPos = pos; me.updateControlTopBottom(me); - me.dragScrollTimer = 0; + me.dragScrollTimer = time; if(pos_x >= 1 - me.controlWidth) { // if hit, set me.pressed, otherwise scroll by one page @@ -200,8 +200,7 @@ void updateControlTopBottomListBox(entity me) { if(frametime) // only do this in draw frames { - me.dragScrollTimer -= frametime; - if(me.dragScrollTimer < 0) + if(me.dragScrollTimer < time) { float save; save = me.scrollPos; @@ -210,7 +209,7 @@ void updateControlTopBottomListBox(entity me) // if selected item is above listbox, decrease scrollpos so it is in me.scrollPos = min(me.scrollPos, me.selectedItem * me.itemHeight); if(me.scrollPos != save) - me.dragScrollTimer = 0.2; + me.dragScrollTimer = time + 0.2; } } // if scroll pos is below end of list, fix it diff --git a/data/qcsrc/menu/nexuiz/credits.c b/data/qcsrc/menu/nexuiz/credits.c index 50fc57d42..2cfd8d77c 100644 --- a/data/qcsrc/menu/nexuiz/credits.c +++ b/data/qcsrc/menu/nexuiz/credits.c @@ -83,7 +83,7 @@ void drawListBoxItemNexuizCreditsList(entity me, float i, vector absSize, float float keyDownNexuizCreditsList(entity me, float scan, float ascii, float shift) { float i; - me.dragScrollTimer = 0; + me.dragScrollTimer = time; me.scrolling = 0; if(scan == K_PGUP) -- 2.39.2