]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/menu/xonotic/commandbutton.qc
Merge branch 'master' into Mario/buff_updates
[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 #include "button.qc"
10 CLASS(XonoticCommandButton, XonoticButton)
11         METHOD(XonoticCommandButton, configureXonoticCommandButton, void(entity, string, vector, string, float))
12         ATTRIB(XonoticCommandButton, onClickCommand, string, string_null)
13         ATTRIB(XonoticCommandButton, flags, float, 0)
14 ENDCLASS(XonoticCommandButton)
15 entity makeXonoticCommandButton(string theText, vector theColor, string theCommand, float closesMenu);
16 #endif
17
18 #ifdef IMPLEMENTATION
19 entity makeXonoticCommandButton(string theText, vector theColor, string theCommand, float theFlags)
20 {
21         entity me;
22         me = NEW(XonoticCommandButton);
23         me.configureXonoticCommandButton(me, theText, theColor, theCommand, theFlags);
24         return me;
25 }
26
27 void XonoticCommandButton_Click(entity me, entity other)
28 {
29         //if(me.flags & COMMANDBUTTON_APPLY)
30         //      saveAllCvars(me.parent);
31         cmd("\n", me.onClickCommand, "\n");
32         //if(me.flags & COMMANDBUTTON_REVERT)
33         //      loadAllCvars(me.parent);
34         if(me.flags & COMMANDBUTTON_CLOSE)
35                 m_goto(string_null);
36 }
37
38 void XonoticCommandButton_configureXonoticCommandButton(entity me, string theText, vector theColor, string theCommand, float theFlags)
39 {
40         me.configureXonoticButton(me, theText, theColor);
41         me.onClickCommand = theCommand;
42         me.flags = theFlags;
43         me.onClick = XonoticCommandButton_Click;
44         me.onClickEntity = me;
45 }
46 #endif