]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/menu/xonotic/checkbox_string.qc
menu: #undef IMPLEMENTATION
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / checkbox_string.qc
1 #include "checkbox_string.qh"
2
3 entity makeXonoticCheckBoxString(string theYesValue, string theNoValue, string theCvar, string theText)
4 {
5         entity me;
6         me = NEW(XonoticCheckBoxString);
7         me.configureXonoticCheckBoxString(me, theYesValue, theNoValue, theCvar, theText);
8         return me;
9 }
10 void XonoticCheckBoxString_configureXonoticCheckBoxString(entity me, string theYesValue, string theNoValue, string theCvar, string theText)
11 {
12         me.yesString = theYesValue;
13         me.noString = theNoValue;
14         me.checked = 0;
15         me.cvarName = (theCvar) ? theCvar : string_null;
16         me.loadCvars(me);
17         me.configureCheckBox(me, theText, me.fontSize, me.image);
18 }
19 void XonoticCheckBoxString_setChecked(entity me, float foo)
20 {
21         me.checked = !me.checked;
22         me.saveCvars(me);
23 }
24 void XonoticCheckBoxString_loadCvars(entity me)
25 {
26         if (!me.cvarName)
27                 return;
28
29         if(cvar_string(me.cvarName) == me.yesString)
30                 me.checked = 1;
31 }
32 void XonoticCheckBoxString_saveCvars(entity me)
33 {
34         if (!me.cvarName)
35                 return;
36
37         if(me.checked)
38                 cvar_set(me.cvarName, me.yesString);
39         else
40                 cvar_set(me.cvarName, me.noString);
41
42         CheckSendCvars(me, me.cvarName);
43 }