Initial checkout of Vore Tournament 0.1.alpha.
[voretournament/voretournament.git] / data / qcsrc / menu / voret / dialog_singleplayer.c
1 #ifdef INTERFACE\r
2 CLASS(VoretSingleplayerDialog) EXTENDS(VoretDialog)\r
3         METHOD(VoretSingleplayerDialog, fill, void(entity))\r
4         ATTRIB(VoretSingleplayerDialog, title, string, "Singleplayer")\r
5         ATTRIB(VoretSingleplayerDialog, color, vector, SKINCOLOR_DIALOG_SINGLEPLAYER)\r
6         ATTRIB(VoretSingleplayerDialog, intendedWidth, float, 0.80)\r
7         ATTRIB(VoretSingleplayerDialog, rows, float, 24)\r
8         ATTRIB(VoretSingleplayerDialog, columns, float, 5)\r
9         ATTRIB(VoretSingleplayerDialog, campaignBox, entity, NULL)\r
10 ENDCLASS(VoretSingleplayerDialog)\r
11 #endif\r
12 \r
13 #ifdef IMPLEMENTATION\r
14 \r
15 void InstantAction_LoadMap(entity btn, entity dummy)\r
16 {\r
17         float glob, i, n, fh;\r
18         string s;\r
19         glob = search_begin("maps/*.instantaction", TRUE, TRUE);\r
20         if(glob < 0)\r
21                 return;\r
22         i = ceil(random() * search_getsize(glob)) - 1;\r
23         fh = fopen(search_getfilename(glob, i), FILE_READ);\r
24         search_end(glob);\r
25         if(fh < 0)\r
26                 return;\r
27         while((s = fgets(fh)))\r
28         {\r
29                 if(substring(s, 0, 4) == "set ")\r
30                         s = substring(s, 4, strlen(s) - 4);\r
31                 n = tokenize_console(s);\r
32                 if(argv(0) == "bot_number")\r
33                         cvar_set("bot_number", argv(1));\r
34                 else if(argv(0) == "skill")\r
35                         cvar_set("skill", argv(1));\r
36                 else if(argv(0) == "timelimit")\r
37                         cvar_set("timelimit_override", argv(1));\r
38                 else if(argv(0) == "fraglimit")\r
39                         cvar_set("fraglimit_override", argv(1));\r
40                 else if(argv(0) == "changelevel")\r
41                 {\r
42                         fclose(fh);\r
43                         localcmd("\nmenu_loadmap_prepare\n");\r
44                         MapInfo_SwitchGameType(MAPINFO_TYPE_DEATHMATCH);\r
45                         MapInfo_LoadMap(argv(1));\r
46                         cvar_set("lastlevel", "1");\r
47                         return;\r
48                 }\r
49         }\r
50         fclose(fh);\r
51 }\r
52 \r
53 void fillVoretSingleplayerDialog(entity me)\r
54 {\r
55         entity e, btnPrev, btnNext, lblTitle;\r
56 \r
57         me.TR(me);\r
58                 me.TDempty(me, (me.columns - 3) / 2);\r
59                 me.TD(me, 2, 3, e = makeVoretBigButton("Instant action! (random map with bots)", '0 0 0'));\r
60                         e.onClick = InstantAction_LoadMap;\r
61                         e.onClickEntity = NULL;\r
62         me.TR(me);\r
63         me.TR(me);\r
64         me.TR(me);\r
65                 me.TD(me, 1, 1, btnPrev = makeVoretButton("<<", '0 0 0'));\r
66                 me.TD(me, 1, me.columns - 2, lblTitle = makeVoretTextLabel(0.5, "???"));\r
67                 me.TD(me, 1, 1, btnNext = makeVoretButton(">>", '0 0 0'));\r
68         me.TR(me);\r
69                 me.TD(me, me.rows - 5, me.columns, me.campaignBox = makeVoretCampaignList());\r
70                         btnPrev.onClick = MultiCampaign_Prev;\r
71                         btnPrev.onClickEntity = me.campaignBox;\r
72                         btnNext.onClick = MultiCampaign_Next;\r
73                         btnNext.onClickEntity = me.campaignBox;\r
74                         me.campaignBox.buttonNext = btnNext;\r
75                         me.campaignBox.buttonPrev = btnPrev;\r
76                         me.campaignBox.labelTitle = lblTitle;\r
77                         me.campaignBox.campaignGo(me.campaignBox, 0);\r
78 \r
79         me.gotoRC(me, me.rows - 1, 0);\r
80                 //me.TD(me, 1, 2, e = makeVoretModButton("Singleplayer"));\r
81                 me.TD(me, 1, me.columns, e = makeVoretButton("Start Singleplayer!", '0 0 0'));\r
82                         e.onClick = CampaignList_LoadMap;\r
83                         e.onClickEntity = me.campaignBox;\r
84 }\r
85 #endif\r