]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/menu/nexuiz/commandbutton.c
the usual (forgot two files)
[divverent/nexuiz.git] / data / qcsrc / menu / nexuiz / commandbutton.c
1 #ifndef COMMANDBUTTON_CLOSE
2 # define COMMANDBUTTON_CLOSE 1
3 # define COMMANDBUTTON_APPLY 2
4 //# define COMMANDBUTTON_REVERT 4
5 #endif
6
7 #ifdef INTERFACE
8 CLASS(NexuizCommandButton) EXTENDS(NexuizButton)
9         METHOD(NexuizCommandButton, configureNexuizCommandButton, void(entity, string, vector, string, float))
10         ATTRIB(NexuizCommandButton, onClickCommand, string, string_null)
11         ATTRIB(NexuizCommandButton, flags, float, 0)
12 ENDCLASS(NexuizCommandButton)
13 entity makeNexuizCommandButton(string theText, vector theColor, string theCommand, float closesMenu);
14 #endif
15
16 #ifdef IMPLEMENTATION
17 entity makeNexuizCommandButton(string theText, vector theColor, string theCommand, float theFlags)
18 {
19         entity me;
20         me = spawnNexuizCommandButton();
21         me.configureNexuizCommandButton(me, theText, theColor, theCommand, theFlags);
22         return me;
23 }
24
25 void NexuizCommandButton_Click(entity me, entity other)
26 {
27         //if(me.flags & COMMANDBUTTON_APPLY)
28         //      saveAllCvars(me.parent);
29         cmd("\n", me.onClickCommand, "\n");
30         //if(me.flags & COMMANDBUTTON_REVERT)
31         //      loadAllCvars(me.parent);
32         if(me.flags & COMMANDBUTTON_CLOSE)
33                 m_goto(string_null);
34 }
35
36 void configureNexuizCommandButtonNexuizCommandButton(entity me, string theText, vector theColor, string theCommand, float theFlags)
37 {
38         me.configureNexuizButton(me, theText, theColor);
39         me.onClickCommand = theCommand;
40         me.flags = theFlags;
41         me.onClick = NexuizCommandButton_Click;
42         me.onClickEntity = me;
43 }
44 #endif