]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/menu/xonotic/slider_decibels.qc
Don't play any animation when loading the initial value of a slider since the animati...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / slider_decibels.qc
index 07632320ed29d89da88f90d7e914c00576833b35..2878b505682c126f29a1edb988f5a034855ba534 100644 (file)
@@ -1,10 +1,10 @@
-#include "../../warpzonelib/mathlib.qh"
-
-#ifdef INTERFACE
-CLASS(XonoticDecibelsSlider) EXTENDS(XonoticSlider)
-       METHOD(XonoticDecibelsSlider, loadCvars, void(entity))
-       METHOD(XonoticDecibelsSlider, saveCvars, void(entity))
-       METHOD(XonoticDecibelsSlider, valueToText, string(entity, float))
+#ifndef SLIDER_DECIBELS_H
+#define SLIDER_DECIBELS_H
+#include "slider.qc"
+CLASS(XonoticDecibelsSliderXonoticSlider)
+       METHOD(XonoticDecibelsSlider, loadCvars, void(entity));
+       METHOD(XonoticDecibelsSlider, saveCvars, void(entity));
+       METHOD(XonoticDecibelsSlider, valueToText, string(entity, float));
 ENDCLASS(XonoticDecibelsSlider)
 entity makeXonoticDecibelsSlider(float, float, float, string);
 #endif
@@ -42,7 +42,7 @@ float fromDecibelOfSquare(float f, float mi)
 entity makeXonoticDecibelsSlider(float theValueMin, float theValueMax, float theValueStep, string theCvar)
 {
        entity me;
-       me = spawnXonoticDecibelsSlider();
+       me = NEW(XonoticDecibelsSlider);
        me.configureXonoticSlider(me, theValueMin, theValueMax, theValueStep, theCvar);
        return me;
 }
@@ -57,9 +57,9 @@ void XonoticDecibelsSlider_loadCvars(entity me)
 
        // snapping
        if(v > fromDecibelOfSquare(me.valueMax - 0.5 * me.valueStep, me.valueMin))
-               Slider_setValue(me, me.valueMax);
+               Slider_setValue_noAnim(me, me.valueMax);
        else
-               Slider_setValue(me, me.valueStep * floor(0.5 + toDecibelOfSquare(v, me.valueMin) / me.valueStep) );
+               Slider_setValue_noAnim(me, me.valueStep * floor(0.5 + toDecibelOfSquare(v, me.valueMin) / me.valueStep));
 }
 void XonoticDecibelsSlider_saveCvars(entity me)
 {
@@ -98,7 +98,7 @@ void _TEST_XonoticDecibelsSlider()
                float v = fromDecibelOfSquare(db, -40);
                float dbv = toDecibelOfSquare(v, -40);
                float d = dbv - db;
-               printf("%f -> %f -> %f (diff: %f)\n", db, v, dbv, d);
+               LOG_INFOF("%f -> %f -> %f (diff: %f)\n", db, v, dbv, d);
                TEST_Check(fabs(d) > 0.02);
        }
        TEST_OK();