]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/menu/xonotic/commandbutton.qc
Sort menu classes
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / commandbutton.qc
1 #ifndef COMMANDBUTTON_CLOSE
2 # define COMMANDBUTTON_CLOSE 1
3 # define COMMANDBUTTON_APPLY 2
4 //# define COMMANDBUTTON_REVERT 4
5 #endif
6
7 #ifndef COMMANDBUTTON_H
8 #define COMMANDBUTTON_H
9 CLASS(XonoticCommandButton, XonoticButton)
10         METHOD(XonoticCommandButton, configureXonoticCommandButton, void(entity, string, vector, string, float))
11         ATTRIB(XonoticCommandButton, onClickCommand, string, string_null)
12         ATTRIB(XonoticCommandButton, flags, float, 0)
13 ENDCLASS(XonoticCommandButton)
14 entity makeXonoticCommandButton(string theText, vector theColor, string theCommand, float closesMenu);
15 #endif
16
17 #ifdef IMPLEMENTATION
18 entity makeXonoticCommandButton(string theText, vector theColor, string theCommand, float theFlags)
19 {
20         entity me;
21         me = NEW(XonoticCommandButton);
22         me.configureXonoticCommandButton(me, theText, theColor, theCommand, theFlags);
23         return me;
24 }
25
26 void XonoticCommandButton_Click(entity me, entity other)
27 {
28         //if(me.flags & COMMANDBUTTON_APPLY)
29         //      saveAllCvars(me.parent);
30         cmd("\n", me.onClickCommand, "\n");
31         //if(me.flags & COMMANDBUTTON_REVERT)
32         //      loadAllCvars(me.parent);
33         if(me.flags & COMMANDBUTTON_CLOSE)
34                 m_goto(string_null);
35 }
36
37 void XonoticCommandButton_configureXonoticCommandButton(entity me, string theText, vector theColor, string theCommand, float theFlags)
38 {
39         me.configureXonoticButton(me, theText, theColor);
40         me.onClickCommand = theCommand;
41         me.flags = theFlags;
42         me.onClick = XonoticCommandButton_Click;
43         me.onClickEntity = me;
44 }
45 #endif