]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/menu/xonotic/modbutton.c
move scripts and env into the maps repo, as they really are only used there
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / modbutton.c
1 #ifdef INTERFACE
2 CLASS(XonoticModButton) EXTENDS(XonoticButton)
3         METHOD(XonoticModButton, configureXonoticModButton, void(entity, string))
4         ATTRIB(XonoticModButton, destination, string, string_null)
5 ENDCLASS(XonoticModButton)
6 entity makeXonoticModButton(string menu);
7 void XonoticModButton_Click(entity me, entity other);
8 #endif
9
10 #ifdef IMPLEMENTATION
11 entity makeXonoticModButton(string menu)
12 {
13         entity me;
14         me = spawnXonoticModButton();
15         me.configureXonoticModButton(me, menu);
16         return me;
17 }
18
19 void XonoticModButton_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 configureXonoticModButtonXonoticModButton(entity me, string menu)
35 {
36         me.configureXonoticButton(me, "", '0 0 0');
37         me.onClick = XonoticModButton_Click;
38         me.onClickEntity = me;
39         me.destination = menu;
40
41         if (cvar_string("menu_slist_modfilter") == "havoc")
42                 me.text = "Switch to Xonotic mode";
43         else
44                 me.text = "Switch to Havoc mode";
45 }
46 #endif