2 CLASS(XonoticSingleplayerDialog) EXTENDS(XonoticDialog)
3 METHOD(XonoticSingleplayerDialog, fill, void(entity))
4 ATTRIB(XonoticSingleplayerDialog, title, string, _("Singleplayer"))
5 ATTRIB(XonoticSingleplayerDialog, color, vector, SKINCOLOR_DIALOG_SINGLEPLAYER)
6 ATTRIB(XonoticSingleplayerDialog, intendedWidth, float, 0.80)
7 ATTRIB(XonoticSingleplayerDialog, rows, float, 24)
8 ATTRIB(XonoticSingleplayerDialog, columns, float, 5)
9 ATTRIB(XonoticSingleplayerDialog, campaignBox, entity, NULL)
10 ENDCLASS(XonoticSingleplayerDialog)
15 void InstantAction_LoadMap(entity btn, entity dummy)
19 glob = search_begin("maps/*.instantaction", TRUE, TRUE);
22 i = ceil(random() * search_getsize(glob)) - 1;
23 fh = fopen(search_getfilename(glob, i), FILE_READ);
27 while((s = fgets(fh)))
29 if(substring(s, 0, 4) == "set ")
30 s = substring(s, 4, strlen(s) - 4);
31 n = tokenize_console(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")
43 localcmd("\nmenu_loadmap_prepare\n");
44 MapInfo_SwitchGameType(MAPINFO_TYPE_DEATHMATCH);
45 MapInfo_LoadMap(argv(1));
46 cvar_set("lastlevel", "1");
53 void XonoticSingleplayerDialog_fill(entity me)
55 entity e, btnPrev, btnNext, lblTitle;
58 me.TDempty(me, (me.columns - 3) / 2);
59 me.TD(me, 2, 3, e = makeXonoticBigButton(_("Instant action! (random map with bots)"), '0 0 0'));
60 e.onClick = InstantAction_LoadMap;
61 e.onClickEntity = NULL;
65 me.TD(me, 1, 1, btnPrev = makeXonoticButton("<<", '0 0 0'));
66 me.TD(me, 1, me.columns - 2, lblTitle = makeXonoticTextLabel(0.5, _("???")));
67 me.TD(me, 1, 1, btnNext = makeXonoticButton(">>", '0 0 0'));
69 me.TD(me, me.rows - 5, me.columns, me.campaignBox = makeXonoticCampaignList());
70 btnPrev.onClick = MultiCampaign_Prev;
71 btnPrev.onClickEntity = me.campaignBox;
72 btnNext.onClick = MultiCampaign_Next;
73 btnNext.onClickEntity = me.campaignBox;
74 me.campaignBox.buttonNext = btnNext;
75 me.campaignBox.buttonPrev = btnPrev;
76 me.campaignBox.labelTitle = lblTitle;
77 me.campaignBox.campaignGo(me.campaignBox, 0);
79 me.gotoRC(me, me.rows - 1, 0);
80 me.TD(me, 1, me.columns, e = makeXonoticButton(_("Start Singleplayer!"), '0 0 0'));
81 e.onClick = CampaignList_LoadMap;
82 e.onClickEntity = me.campaignBox;