]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/menu/xonotic/checkbox_string.qc
Merge remote-tracking branch 'origin/master' into terencehill/menu_remove_tab_title
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / checkbox_string.qc
1 #ifndef CHECKBOX_STRING_H
2 #define CHECKBOX_STRING_H
3 #include "../item/checkbox.qc"
4 CLASS(XonoticCheckBoxString, CheckBox)
5         METHOD(XonoticCheckBoxString, configureXonoticCheckBoxString, void(entity, string, string, string, string))
6         METHOD(XonoticCheckBoxString, setChecked, void(entity, float))
7         ATTRIB(XonoticCheckBoxString, fontSize, float, SKINFONTSIZE_NORMAL)
8         ATTRIB(XonoticCheckBoxString, image, string, SKINGFX_CHECKBOX)
9         ATTRIB(XonoticCheckBoxString, yesString, string, string_null)
10         ATTRIB(XonoticCheckBoxString, noString, string, string_null)
11
12         ATTRIB(XonoticCheckBoxString, color, vector, SKINCOLOR_CHECKBOX_N)
13         ATTRIB(XonoticCheckBoxString, colorC, vector, SKINCOLOR_CHECKBOX_C)
14         ATTRIB(XonoticCheckBoxString, colorF, vector, SKINCOLOR_CHECKBOX_F)
15         ATTRIB(XonoticCheckBoxString, colorD, vector, SKINCOLOR_CHECKBOX_D)
16
17         ATTRIB(XonoticCheckBoxString, cvarName, string, string_null)
18         METHOD(XonoticCheckBoxString, loadCvars, void(entity))
19         METHOD(XonoticCheckBoxString, saveCvars, void(entity))
20         ATTRIB(XonoticCheckBoxString, sendCvars, float, 0)
21
22         ATTRIB(XonoticCheckBoxString, alpha, float, SKINALPHA_TEXT)
23         ATTRIB(XonoticCheckBoxString, disabledAlpha, float, SKINALPHA_DISABLED)
24 ENDCLASS(XonoticCheckBoxString)
25 entity makeXonoticCheckBoxString(string, string, string, string);
26 #endif
27
28 #ifdef IMPLEMENTATION
29 entity makeXonoticCheckBoxString(string theYesValue, string theNoValue, string theCvar, string theText)
30 {
31         entity me;
32         me = NEW(XonoticCheckBoxString);
33         me.configureXonoticCheckBoxString(me, theYesValue, theNoValue, theCvar, theText);
34         return me;
35 }
36 void XonoticCheckBoxString_configureXonoticCheckBoxString(entity me, string theYesValue, string theNoValue, string theCvar, string theText)
37 {
38         me.yesString = theYesValue;
39         me.noString = theNoValue;
40         me.checked = 0;
41         if(theCvar)
42         {
43                 me.cvarName = theCvar;
44                 me.tooltip = getZonedTooltipForIdentifier(theCvar);
45                 me.loadCvars(me);
46         }
47         me.configureCheckBox(me, theText, me.fontSize, me.image);
48 }
49 void XonoticCheckBoxString_setChecked(entity me, float foo)
50 {
51         me.checked = !me.checked;
52         me.saveCvars(me);
53 }
54 void XonoticCheckBoxString_loadCvars(entity me)
55 {
56         if (!me.cvarName)
57                 return;
58
59         if(cvar_string(me.cvarName) == me.yesString)
60                 me.checked = 1;
61 }
62 void XonoticCheckBoxString_saveCvars(entity me)
63 {
64         if (!me.cvarName)
65                 return;
66
67         if(me.checked)
68                 cvar_set(me.cvarName, me.yesString);
69         else
70                 cvar_set(me.cvarName, me.noString);
71
72         CheckSendCvars(me, me.cvarName);
73 }
74 #endif