]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/menu/nexuiz/gametypebutton.c
try fixing the addition of CA
[divverent/nexuiz.git] / data / qcsrc / menu / nexuiz / gametypebutton.c
1 #ifdef INTERFACE
2 CLASS(NexuizGametypeButton) EXTENDS(RadioButton)
3         METHOD(NexuizGametypeButton, configureNexuizGametypeButton, void(entity, float, string, string))
4         METHOD(NexuizGametypeButton, setChecked, void(entity, float))
5         ATTRIB(NexuizGametypeButton, fontSize, float, SKINFONTSIZE_NORMAL)
6         ATTRIB(NexuizGametypeButton, image, string, SKINGFX_BUTTON_BIG)
7         ATTRIB(NexuizGametypeButton, color, vector, SKINCOLOR_BUTTON_N)
8         ATTRIB(NexuizGametypeButton, colorC, vector, SKINCOLOR_BUTTON_C)
9         ATTRIB(NexuizGametypeButton, colorF, vector, SKINCOLOR_BUTTON_F)
10         ATTRIB(NexuizGametypeButton, colorD, vector, SKINCOLOR_BUTTON_D)
11         ATTRIB(NexuizGametypeButton, srcMulti, float, 1)
12         ATTRIB(NexuizGametypeButton, useDownAsChecked, float, 1)
13
14         ATTRIB(NexuizGametypeButton, cvarName, string, string_null)
15         METHOD(NexuizGametypeButton, loadCvars, void(entity))
16         METHOD(NexuizGametypeButton, saveCvars, void(entity))
17
18         ATTRIB(NexuizGametypeButton, alpha, float, SKINALPHA_TEXT)
19         ATTRIB(NexuizGametypeButton, disabledAlpha, float, SKINALPHA_DISABLED)
20 ENDCLASS(NexuizGametypeButton)
21 entity makeNexuizGametypeButton(float, string, string);
22 #endif
23
24 #ifdef IMPLEMENTATION
25 void GameTypeButton_Click(entity me, entity other);
26 entity makeNexuizGametypeButton(float theGroup, string theCvar, string theText)
27 {
28         entity me;
29         me = spawnNexuizGametypeButton();
30         me.configureNexuizGametypeButton(me, theGroup, theCvar, theText);
31         return me;
32 }
33 void configureNexuizGametypeButtonNexuizGametypeButton(entity me, float theGroup, string theCvar, string theText)
34 {
35         if(theCvar)
36         {
37                 me.cvarName = theCvar;
38                 me.tooltip = getZonedTooltipForIdentifier(theCvar);
39                 me.loadCvars(me);
40         }
41         me.configureRadioButton(me, theText, me.fontSize, me.image, theGroup, 0);
42         me.align = 0.5;
43         me.onClick = GameTypeButton_Click;
44         me.onClickEntity = NULL;
45 }
46 void setCheckedNexuizGametypeButton(entity me, float val)
47 {
48         if(val != me.checked)
49         {
50                 me.checked = val;
51                 me.saveCvars(me);
52         }
53 }
54 void loadCvarsNexuizGametypeButton(entity me)
55 {
56         if not(me.cvarName)
57                 return;
58
59         me.checked = cvar(me.cvarName);
60 }
61 void saveCvarsNexuizGametypeButton(entity me)
62 {
63         if not(me.cvarName)
64                 return;
65
66         cvar_set(me.cvarName, ftos(me.checked));
67 }
68 void GameTypeButton_Click(entity me, entity other)
69 {
70         RadioButton_Click(me, other);
71         me.parent.gameTypeChangeNotify(me.parent);
72 }
73 #endif