]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/menu-div0test/nexuiz/dialog_singleplayer.c
-scmenu; make mapinfo default
[divverent/nexuiz.git] / data / qcsrc / menu-div0test / nexuiz / dialog_singleplayer.c
1 #ifdef INTERFACE
2 CLASS(NexuizSingleplayerDialog) EXTENDS(NexuizDialog)
3         METHOD(NexuizSingleplayerDialog, fill, void(entity))
4         ATTRIB(NexuizSingleplayerDialog, title, string, "Singleplayer")
5         ATTRIB(NexuizSingleplayerDialog, color, vector, SKINCOLOR_DIALOG_SINGLEPLAYER)
6         ATTRIB(NexuizSingleplayerDialog, intendedWidth, float, 0.80)
7         ATTRIB(NexuizSingleplayerDialog, rows, float, 24)
8         ATTRIB(NexuizSingleplayerDialog, columns, float, 5)
9         ATTRIB(NexuizSingleplayerDialog, campaignBox, entity, NULL)
10 ENDCLASS(NexuizSingleplayerDialog)
11 #endif
12
13 #ifdef IMPLEMENTATION
14
15 void InstantAction_LoadMap(entity btn, entity dummy)
16 {
17         float glob, i, n, fh;
18         string s;
19         glob = search_begin("maps/*.instantaction", TRUE, TRUE);
20         if(glob < 0)
21                 return;
22         i = ceil(random() * search_getsize(glob)) - 1;
23         fh = fopen(search_getfilename(glob, i), FILE_READ);
24         search_end(glob);
25         if(fh < 0)
26                 return;
27         while((s = fgets(fh)))
28         {
29                 if(substring(s, 0, 4) == "set ")
30                         s = substring(s, 4, strlen(s) - 4);
31                 n = tokenize(s);
32                 if(argv(0) == "bot_number")
33                         cvar_set("bot_number", argv(1));
34                 else if(argv(0) == "skill")
35                         cvar_set("skill", argv(1));
36                 else if(argv(0) == "timelimit")
37                         cvar_set("timelimit_override", argv(1));
38                 else if(argv(0) == "fraglimit")
39                         cvar_set("fraglimit_override", argv(1));
40                 else if(argv(0) == "changelevel")
41                 {
42                         fclose(fh);
43                         MapInfo_SwitchGameType(MAPINFO_TYPE_DEATHMATCH);
44                         MapInfo_LoadMap(argv(1));
45                         cvar_set("lastlevel", "1");
46                         return;
47                 }
48         }
49         fclose(fh);
50 }
51
52 void fillNexuizSingleplayerDialog(entity me)
53 {
54         entity e;
55
56         me.TR(me);
57                 me.TDempty(me, (me.columns - 2) / 2);
58                 me.TD(me, 2, 2, e = makeNexuizButton("Instant action!", '0 0 0'));
59                         e.onClick = InstantAction_LoadMap;
60                         e.onClickEntity = NULL;
61         me.TR(me);
62         me.TR(me);
63         me.TR(me);
64                 me.TD(me, me.rows - 5, me.columns, me.campaignBox = makeNexuizCampaignList());
65
66         me.gotoXY(me, me.rows - 1, 0);
67                 me.TD(me, 1, me.columns, e = makeNexuizButton("Start!", '0 0 0'));
68                         e.onClick = CampaignList_LoadMap;
69                         e.onClickEntity = me.campaignBox;
70 }
71 #endif