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