]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/menu/nexuiz/gametypebutton.c
cl_hitsound + some menu changes
[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.loadCvars(me);
39         }
40         me.configureRadioButton(me, theText, me.fontSize, me.image, theGroup, 0);
41         me.align = 0.5;
42         me.onClick = GameTypeButton_Click;
43         me.onClickEntity = NULL;
44 }
45 void setCheckedNexuizGametypeButton(entity me, float val)
46 {
47         if(val != me.checked)
48         {
49                 me.checked = val;
50                 me.saveCvars(me);
51         }
52 }
53 void loadCvarsNexuizGametypeButton(entity me)
54 {
55         if not(me.cvarName)
56                 return;
57
58         me.checked = cvar(me.cvarName);
59 }
60 void saveCvarsNexuizGametypeButton(entity me)
61 {
62         if not(me.cvarName)
63                 return;
64
65         cvar_set(me.cvarName, ftos(me.checked));
66 }
67 void GameTypeButton_Click(entity me, entity other)
68 {
69         RadioButton_Click(me, other);
70         me.parent.gameTypeChangeNotify(me.parent);
71 }
72 #endif