METHOD(Slider, mouseRelease, float(entity, vector));
METHOD(Slider, valueToText, string(entity, float));
METHOD(Slider, toString, string(entity));
+ METHOD(Slider, setValue_allowAnim, void(entity, float, bool));
+ METHOD(Slider, setValue_noAnim, void(entity, float));
METHOD(Slider, setValue, void(entity, float));
METHOD(Slider, setSliderValue, void(entity, float));
METHOD(Slider, showNotify, void(entity));
#endif
#ifdef IMPLEMENTATION
-void Slider_setValue(entity me, float val)
+void Slider_setValue_allowAnim(entity me, float val, bool allowAnim)
{
- if (me.animated) {
+ if(allowAnim && me.animated) {
float t = 0.5;
if(me.pressed == 2)
t = 0.3; // slightly more responsive while dragging the handle
}
me.value = val;
}
+void Slider_setValue_noAnim(entity me, float val)
+{
+ Slider_setValue_allowAnim(me, val, false);
+}
+void Slider_setValue(entity me, float val)
+{
+ Slider_setValue_allowAnim(me, val, true);
+}
void Slider_setSliderValue(entity me, float val)
{
me.sliderValue = val;
CLASS(TextSlider, Slider)
METHOD(TextSlider, valueToText, string(entity, float));
METHOD(TextSlider, valueToIdentifier, string(entity, float));
+ METHOD(TextSlider, setValueFromIdentifier_allowAnim, void(entity, string, bool));
+ METHOD(TextSlider, setValueFromIdentifier_noAnim, void(entity, string));
METHOD(TextSlider, setValueFromIdentifier, void(entity, string));
METHOD(TextSlider, getIdentifier, string(entity));
METHOD(TextSlider, clearValues, void(entity));
return _("Custom");
return me.(valueStrings[val]);
}
-void TextSlider_setValueFromIdentifier(entity me, string id)
+void TextSlider_setValueFromIdentifier_allowAnim(entity me, string id, bool allowAnim)
{
int i;
for(i = 0; i < me.nValues; ++i)
if(me.valueToIdentifier(me, i) == id)
{
- SUPER(TextSlider).setValue( me, i );
+ SUPER(TextSlider).setValue_allowAnim(me, i, allowAnim);
return;
}
- SUPER(TextSlider).setValue( me, -1 );
+ SUPER(TextSlider).setValue_allowAnim(me, -1, allowAnim);
+}
+void TextSlider_setValueFromIdentifier_noAnim(entity me, string id)
+{
+ TextSlider_setValueFromIdentifier_allowAnim(me, id, false);
+}
+void TextSlider_setValueFromIdentifier(entity me, string id)
+{
+ TextSlider_setValueFromIdentifier_allowAnim(me, id, true);
}
string TextSlider_getIdentifier(entity me)
{
void TextSlider_configureTextSliderValues(entity me, string theDefault)
{
me.configureSliderValues(me, 0, 0, me.nValues - 1, 1, 1, 1);
- me.setValueFromIdentifier(me, theDefault);
+ me.setValueFromIdentifier_noAnim(me, theDefault);
}
#endif
if (!me.cvarName)
return;
- me.setValue( me, cvar(me.cvarName) );
+ me.setValue_noAnim(me, cvar(me.cvarName));
}
void XonoticSlider_saveCvars(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)
{
}
void XonoticParticlesSlider_loadCvars(entity me)
{
- me.setValueFromIdentifier(me, sprintf("%s %s %s",
+ me.setValueFromIdentifier_noAnim(me, sprintf("%s %s %s",
cvar_string("cl_particles_quality"),
cvar_string("r_drawparticles_drawdistance"),
cvar_string("cl_damageeffect")
}
void XonoticResolutionSlider_loadCvars(entity me)
{
- me.setValueFromIdentifier(me, strcat(cvar_string("_menu_vid_width"), " ", cvar_string("_menu_vid_height"), " ", cvar_string("_menu_vid_pixelheight")));
+ me.setValueFromIdentifier_noAnim(me, strcat(cvar_string("_menu_vid_width"), " ", cvar_string("_menu_vid_height"), " ", cvar_string("_menu_vid_pixelheight")));
}
void XonoticResolutionSlider_saveCvars(entity me)
{
}
void XonoticScoreboardFadeTimeSlider_loadCvars(entity me)
{
- me.setValueFromIdentifier(me, sprintf("%s %s",
+ me.setValueFromIdentifier_noAnim(me, sprintf("%s %s",
cvar_string("scoreboard_fadeinspeed"),
cvar_string("scoreboard_fadeoutspeed")
));
float i;
for(i = 1; i < n; ++i)
s = strcat(s, " ", cvar_string(argv(i)));
- me.setValueFromIdentifier(me, s);
+ me.setValueFromIdentifier_noAnim(me, s);
if(me.value < 0 && n > 1)
{
// if it failed: check if all cvars have the same value
if(cvar_string(argv(i)) != cvar_string(argv(i-1)))
break;
if(i >= n)
- me.setValueFromIdentifier(me, cvar_string(argv(0)));
+ me.setValueFromIdentifier_noAnim(me, cvar_string(argv(0)));
}
}
void XonoticTextSlider_saveCvars(entity me)