1 #include "textslider.qh"
3 entity makeXonoticTextSlider_T(string theCvar, string theTooltip)
6 me = NEW(XonoticTextSlider);
7 me.configureXonoticTextSlider(me, theCvar, theTooltip);
10 entity makeXonoticTextSlider(string theCvar)
12 return makeXonoticTextSlider_T(theCvar, string_null);
14 void XonoticTextSlider_configureXonoticTextSlider(entity me, string theCvar, string theTooltip)
16 me.configureSliderVisuals(me, me.fontSize, me.align, me.valueSpace, me.image);
17 me.cvarName = (theCvar) ? theCvar : string_null;
18 // me.loadCvars(me); // don't load it yet
19 setZonedTooltip(me, theTooltip, theCvar);
21 void XonoticTextSlider_setValue(entity me, float val)
25 SUPER(XonoticTextSlider).setValue( me, val );
29 void XonoticTextSlider_setValue_noAnim(entity me, float val)
33 SUPER(XonoticTextSlider).setValue_noAnim(me, val);
37 void XonoticTextSlider_loadCvars(entity me)
42 float n = tokenize_console(me.cvarName);
43 string s = cvar_string(argv(0));
45 for(i = 1; i < n; ++i)
46 s = strcat(s, " ", cvar_string(argv(i)));
47 me.setValueFromIdentifier_noAnim(me, s);
48 if(me.value < 0 && n > 1)
50 // if it failed: check if all cvars have the same value
51 // if yes, try its value as 1-word identifier
52 for(i = 1; i < n; ++i)
53 if(cvar_string(argv(i)) != cvar_string(argv(i-1)))
56 me.setValueFromIdentifier_noAnim(me, cvar_string(argv(0)));
59 void XonoticTextSlider_saveCvars(entity me)
64 if(me.value >= 0 && me.value < me.nValues)
66 float n = tokenize_console(me.cvarName);
69 // this is a special case to allow spaces in the identifiers
70 cvar_set(argv(0), me.getIdentifier(me));
71 CheckSendCvars(me, argv(0));
76 float m = tokenize_console(strcat(me.cvarName, " ", me.getIdentifier(me)));
79 for(i = 0; i < n; ++i)
81 cvar_set(argv(i), argv(n));
82 CheckSendCvars(me, argv(i));
87 for(i = 0; i < n; ++i)
89 cvar_set(argv(i), argv(i + n));
90 CheckSendCvars(me, argv(i));
94 error("XonoticTextSlider: invalid identifier ", me.getIdentifier(me), " does not match cvar list ", me.cvarName);
98 void XonoticTextSlider_configureXonoticTextSliderValues(entity me)
100 me.configureTextSliderValues(me, string_null);