]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/menu/nexuiz/modbutton.c
fix the havoc button when connected
[divverent/nexuiz.git] / data / qcsrc / menu / nexuiz / modbutton.c
1 #ifdef INTERFACE
2 CLASS(NexuizModButton) EXTENDS(NexuizButton)
3         METHOD(NexuizModButton, configureNexuizModButton, void(entity, string))
4         ATTRIB(NexuizModButton, destination, string, string_null)
5 ENDCLASS(NexuizModButton)
6 entity makeNexuizModButton(string menu);
7 void NexuizModButton_Click(entity me, entity other);
8 #endif
9
10 #ifdef IMPLEMENTATION
11 entity makeNexuizModButton(string menu)
12 {
13         entity me;
14         me = spawnNexuizModButton();
15         me.configureNexuizModButton(me, menu);
16         return me;
17 }
18
19 void NexuizModButton_Click(entity me, entity other)
20 {
21         string thecmd;
22         thecmd = strcat("\ndisconnect\nmenu_restart");
23
24         if (me.destination != "")
25                 thecmd = strcat(thecmd, "\ntogglemenu\ndefer 0.1 \"menu_cmd directmenu ", me.destination,"\"\n");
26
27         if (cvar_string("menu_slist_modfilter") == "havoc")
28                 thecmd = strcat("\ngamedir data", thecmd);
29         else
30                 thecmd = strcat("\ngamedir havoc", thecmd);
31         cmd(thecmd);
32 }
33
34 void configureNexuizModButtonNexuizModButton(entity me, string menu)
35 {
36         me.configureNexuizButton(me, "", '0 0 0');
37         me.onClick = NexuizModButton_Click;
38         me.onClickEntity = me;
39         me.destination = menu;
40
41         if (cvar_string("menu_slist_modfilter") == "havoc")
42                 me.text = "Switch to Nexuiz mode";
43         else
44                 me.text = "Switch to Havoc mode";
45 }
46 #endif