]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/menu/xonotic/commandbutton.c
Merge branch 'master' into terencehill/music_player
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / 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(XonoticCommandButton) EXTENDS(XonoticButton)
9         METHOD(XonoticCommandButton, configureXonoticCommandButton, void(entity, string, vector, string, float))
10         ATTRIB(XonoticCommandButton, onClickCommand, string, string_null)
11         ATTRIB(XonoticCommandButton, flags, float, 0)
12 ENDCLASS(XonoticCommandButton)
13 entity makeXonoticCommandButton(string theText, vector theColor, string theCommand, float closesMenu);
14 #endif
15
16 #ifdef IMPLEMENTATION
17 entity makeXonoticCommandButton(string theText, vector theColor, string theCommand, float theFlags)
18 {
19         entity me;
20         me = spawnXonoticCommandButton();
21         me.configureXonoticCommandButton(me, theText, theColor, theCommand, theFlags);
22         return me;
23 }
24
25 void XonoticCommandButton_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 XonoticCommandButton_configureXonoticCommandButton(entity me, string theText, vector theColor, string theCommand, float theFlags)
37 {
38         me.configureXonoticButton(me, theText, theColor);
39         me.onClickCommand = theCommand;
40         me.flags = theFlags;
41         me.onClick = XonoticCommandButton_Click;
42         me.onClickEntity = me;
43 }
44 #endif