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