]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix subtle bug where if you drag the handle of the master volume slider to OFF the...
authorterencehill <piuntn@gmail.com>
Sat, 6 Jun 2020 20:01:13 +0000 (22:01 +0200)
committerterencehill <piuntn@gmail.com>
Sat, 6 Jun 2020 20:01:13 +0000 (22:01 +0200)
qcsrc/menu/item/slider.qc

index b569c3b0c4c228bec7d158f558129e21fded4f7c..b98f59bbb444f663643e9860645b820ada792052 100644 (file)
                                // handle dragging
                                me.pressed = 2;
 
-                               v = median(0, (pos.x - me.pressOffset - 0.5 * me.controlWidth) / (1 - me.textSpace - me.controlWidth), 1) * (me.valueMax - me.valueMin) + me.valueMin;
-                               if (me.valueStep) v = floor(0.5 + v / me.valueStep) * me.valueStep;
+                               float f = bound(0, (pos.x - me.pressOffset - 0.5 * me.controlWidth) / (1 - me.textSpace - me.controlWidth), 1);
+                               v = f * (me.valueMax - me.valueMin) + me.valueMin;
+                               // there's no need to round min and max value... also if we did, v could be set
+                               // to an out of bounds value due to precision errors
+                               if (f > 0 && f < 1 && me.valueStep)
+                                       v = floor(0.5 + v / me.valueStep) * me.valueStep;
                                me.setValue_noAnim(me, v);
                                if(me.applyButton)
                                if(me.previousValue != me.value)