X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fmenu%2Fxonotic%2Fslider.qc;h=c8e057a641416aa922a9760b6cbaafa3072b881e;hb=0d4410adb034af1a9989862211e49e442fa9b9dd;hp=d95cac7e9eebedce1ddb3c4df75369e06b4a0251;hpb=b09b7687da385e1cdc51e2f63fb7de4c9f9e12a3;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/menu/xonotic/slider.qc b/qcsrc/menu/xonotic/slider.qc index d95cac7e9..c8e057a64 100644 --- a/qcsrc/menu/xonotic/slider.qc +++ b/qcsrc/menu/xonotic/slider.qc @@ -1,40 +1,17 @@ -#ifndef SLIDER_H -#define SLIDER_H -#include "../item/slider.qc" -CLASS(XonoticSlider, Slider) - METHOD(XonoticSlider, configureXonoticSlider, void(entity, float, float, float, string)) - METHOD(XonoticSlider, setValue, void(entity, float)) - ATTRIB(XonoticSlider, fontSize, float, SKINFONTSIZE_NORMAL) - ATTRIB(XonoticSlider, valueSpace, float, SKINWIDTH_SLIDERTEXT) - ATTRIB(XonoticSlider, image, string, SKINGFX_SLIDER) - ATTRIB(XonoticSlider, tolerance, vector, SKINTOLERANCE_SLIDER) - ATTRIB(XonoticSlider, align, float, 0.5) - ATTRIB(XonoticSlider, color, vector, SKINCOLOR_SLIDER_N) - ATTRIB(XonoticSlider, colorC, vector, SKINCOLOR_SLIDER_C) - ATTRIB(XonoticSlider, colorF, vector, SKINCOLOR_SLIDER_F) - ATTRIB(XonoticSlider, colorD, vector, SKINCOLOR_SLIDER_D) - ATTRIB(XonoticSlider, color2, vector, SKINCOLOR_SLIDER_S) +#include "slider.qh" - ATTRIB(XonoticSlider, cvarName, string, string_null) - METHOD(XonoticSlider, loadCvars, void(entity)) - METHOD(XonoticSlider, saveCvars, void(entity)) - ATTRIB(XonoticSlider, sendCvars, float, 0) - - ATTRIB(XonoticSlider, alpha, float, SKINALPHA_TEXT) - ATTRIB(XonoticSlider, disabledAlpha, float, SKINALPHA_DISABLED) -ENDCLASS(XonoticSlider) -entity makeXonoticSlider(float, float, float, string); -#endif - -#ifdef IMPLEMENTATION -entity makeXonoticSlider(float theValueMin, float theValueMax, float theValueStep, string theCvar) +entity makeXonoticSlider_T(float theValueMin, float theValueMax, float theValueStep, string theCvar, string theTooltip) { entity me; me = NEW(XonoticSlider); - me.configureXonoticSlider(me, theValueMin, theValueMax, theValueStep, theCvar); + me.configureXonoticSlider(me, theValueMin, theValueMax, theValueStep, theCvar, theTooltip); return me; } -void XonoticSlider_configureXonoticSlider(entity me, float theValueMin, float theValueMax, float theValueStep, string theCvar) +entity makeXonoticSlider(float theValueMin, float theValueMax, float theValueStep, string theCvar) +{ + return makeXonoticSlider_T(theValueMin, theValueMax, theValueStep, theCvar, string_null); +} +void XonoticSlider_configureXonoticSlider(entity me, float theValueMin, float theValueMax, float theValueStep, string theCvar, string theTooltip) { float vp; vp = theValueStep * 10; @@ -43,17 +20,15 @@ void XonoticSlider_configureXonoticSlider(entity me, float theValueMin, float th me.configureSliderVisuals(me, me.fontSize, me.align, me.valueSpace, me.image); + me.cvarName = (theCvar) ? theCvar : string_null; if(theCvar) - { // Prevent flickering of the slider button by initialising the // slider out of bounds to hide the button before loading the cvar me.configureSliderValues(me, theValueMin, theValueMin-theValueStep, theValueMax, theValueStep, theValueStep, vp); - me.cvarName = theCvar; - me.loadCvars(me); - me.tooltip = getZonedTooltipForIdentifier(theCvar); - } else me.configureSliderValues(me, theValueMin, theValueMin, theValueMax, theValueStep, theValueStep, vp); + me.loadCvars(me); + setZonedTooltip(me, theTooltip, theCvar); } void XonoticSlider_setValue(entity me, float val) { @@ -63,20 +38,27 @@ void XonoticSlider_setValue(entity me, float val) me.saveCvars(me); } } +void XonoticSlider_setValue_noAnim(entity me, float val) +{ + if(val != me.value) + { + SUPER(XonoticSlider).setValue_noAnim(me, val); + me.saveCvars(me); + } +} void XonoticSlider_loadCvars(entity me) { if (!me.cvarName) return; - me.setValue( me, cvar(me.cvarName) ); + me.setValue_noAnim(me, cvar(me.cvarName)); } void XonoticSlider_saveCvars(entity me) { if (!me.cvarName) return; - cvar_set(me.cvarName, ftos(me.value)); + cvar_set(me.cvarName, ftos_mindecimals(me.value)); CheckSendCvars(me, me.cvarName); } -#endif