]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/menu-div0test/nexuiz/gametypebutton.c
add map info dialog
[divverent/nexuiz.git] / data / qcsrc / menu-div0test / 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)
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, disabledAlpha, float, SKINALPHA_DISABLED)
19 ENDCLASS(NexuizGametypeButton)
20 entity makeNexuizGametypeButton(float, string, string);
21 #endif
22
23 #ifdef IMPLEMENTATION
24 void GameTypeButton_Click(entity me, entity other);
25 entity makeNexuizGametypeButton(float theGroup, string theCvar, string theText)
26 {
27         entity me;
28         me = spawnNexuizGametypeButton();
29         me.configureNexuizGametypeButton(me, theGroup, theCvar, theText);
30         return me;
31 }
32 void configureNexuizGametypeButtonNexuizGametypeButton(entity me, float theGroup, string theCvar, string theText)
33 {
34         if(theCvar)
35         {
36                 me.cvarName = theCvar;
37                 me.loadCvars(me);
38         }
39         me.configureRadioButton(me, theText, me.fontSize, me.image, theGroup, 0);
40         me.align = 0.5;
41         me.onClick = GameTypeButton_Click;
42         me.onClickEntity = NULL;
43 }
44 void setCheckedNexuizGametypeButton(entity me, float val)
45 {
46         if(val != me.checked)
47         {
48                 me.checked = val;
49                 me.saveCvars(me);
50         }
51 }
52 void loadCvarsNexuizGametypeButton(entity me)
53 {
54         me.checked = cvar(me.cvarName);
55 }
56 void saveCvarsNexuizGametypeButton(entity me)
57 {
58         cvar_set(me.cvarName, ftos(me.checked));
59 }
60 void GameTypeButton_Click(entity me, entity other)
61 {
62         RadioButton_Click(me, other);
63         me.parent.gameTypeChangeNotify(me.parent);
64 }
65 #endif