]> de.git.xonotic.org Git - voretournament/voretournament.git/blob - data/qcsrc/menu/voret/commandbutton.c
Initial checkout of Vore Tournament 0.1.alpha.
[voretournament/voretournament.git] / data / qcsrc / menu / voret / commandbutton.c
1 #ifndef COMMANDBUTTON_CLOSE\r
2 # define COMMANDBUTTON_CLOSE 1\r
3 # define COMMANDBUTTON_APPLY 2\r
4 //# define COMMANDBUTTON_REVERT 4\r
5 #endif\r
6 \r
7 #ifdef INTERFACE\r
8 CLASS(VoretCommandButton) EXTENDS(VoretButton)\r
9         METHOD(VoretCommandButton, configureVoretCommandButton, void(entity, string, vector, string, float))\r
10         ATTRIB(VoretCommandButton, onClickCommand, string, string_null)\r
11         ATTRIB(VoretCommandButton, flags, float, 0)\r
12 ENDCLASS(VoretCommandButton)\r
13 entity makeVoretCommandButton(string theText, vector theColor, string theCommand, float closesMenu);\r
14 #endif\r
15 \r
16 #ifdef IMPLEMENTATION\r
17 entity makeVoretCommandButton(string theText, vector theColor, string theCommand, float theFlags)\r
18 {\r
19         entity me;\r
20         me = spawnVoretCommandButton();\r
21         me.configureVoretCommandButton(me, theText, theColor, theCommand, theFlags);\r
22         return me;\r
23 }\r
24 \r
25 void VoretCommandButton_Click(entity me, entity other)\r
26 {\r
27         //if(me.flags & COMMANDBUTTON_APPLY)\r
28         //      saveAllCvars(me.parent);\r
29         cmd("\n", me.onClickCommand, "\n");\r
30         //if(me.flags & COMMANDBUTTON_REVERT)\r
31         //      loadAllCvars(me.parent);\r
32         if(me.flags & COMMANDBUTTON_CLOSE)\r
33                 m_goto(string_null);\r
34 }\r
35 \r
36 void configureVoretCommandButtonVoretCommandButton(entity me, string theText, vector theColor, string theCommand, float theFlags)\r
37 {\r
38         me.configureVoretButton(me, theText, theColor);\r
39         me.onClickCommand = theCommand;\r
40         me.flags = theFlags;\r
41         me.onClick = VoretCommandButton_Click;\r
42         me.onClickEntity = me;\r
43 }\r
44 #endif\r