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)
17 float pmin, pmax, pstep;
19 cvar_set("timelimit_override", "10");
20 cvar_set("g_lms_lives_override", "9");
22 if(random() < 0.4) // 40% are DM
24 MapInfo_SwitchGameType(MAPINFO_TYPE_DEATHMATCH);
29 else if(random() < 0.5) // half of the remaining 60%, i.e. 30%, are CTF
31 MapInfo_SwitchGameType(MAPINFO_TYPE_CTF);
36 else if(random() < 0.5) // half of the remaining 30%, i.e. 15%, are TDM
38 MapInfo_SwitchGameType(MAPINFO_TYPE_TEAM_DEATHMATCH);
43 else if(random() < 0.666) // 2/3 of the remaining 15%, i.e. 10%, are KH
45 MapInfo_SwitchGameType(MAPINFO_TYPE_KEYHUNT);
48 pstep = 6; // works both for 2 and 3 teams
49 // TODO find team count of map, set pstep=2 or 3, and use 2v2(v2) games at least
51 else // somehow distribute the remaining 5%
54 r = floor(random() * 4);
59 MapInfo_SwitchGameType(MAPINFO_TYPE_LMS);
63 cvar_set("timelimit_override", "-1");
66 MapInfo_SwitchGameType(MAPINFO_TYPE_DOMINATION);
72 MapInfo_SwitchGameType(MAPINFO_TYPE_ONSLAUGHT);
78 MapInfo_SwitchGameType(MAPINFO_TYPE_ASSAULT);
83 // CA, Freezetag: bot AI does not work, add them once it does
88 MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
93 m = floor(random() * MapInfo_count);
94 s = MapInfo_BSPName_ByID(m);
96 while(!fexists(sprintf("maps/%s.waypoints", s)));
97 MapInfo_LoadMap(s, 1);
101 pmin = pstep * ceil(pmin / pstep);
102 pmax = pstep * floor(pmax / pstep);
103 p = pmin + pstep * floor(random() * ((pmax - pmin) / pstep + 1));
104 cvar_set("bot_number", ftos(p - 1));
106 // make sure we go back to menu
107 cvar_set("lastlevel", "1");
110 void XonoticSingleplayerDialog_fill(entity me)
112 entity e, btnPrev, btnNext, lblTitle;
115 me.TDempty(me, (me.columns - 3) / 2);
116 me.TD(me, 2, 3, e = makeXonoticBigButton(_("Instant action! (random map with bots)"), '0 0 0'));
117 e.onClick = InstantAction_LoadMap;
118 e.onClickEntity = NULL;
122 me.TD(me, 1, 1, btnPrev = makeXonoticButton("<<", '0 0 0'));
123 me.TD(me, 1, me.columns - 2, lblTitle = makeXonoticTextLabel(0.5, _("???")));
124 me.TD(me, 1, 1, btnNext = makeXonoticButton(">>", '0 0 0'));
126 me.TD(me, me.rows - 5, me.columns, me.campaignBox = makeXonoticCampaignList());
127 btnPrev.onClick = MultiCampaign_Prev;
128 btnPrev.onClickEntity = me.campaignBox;
129 btnNext.onClick = MultiCampaign_Next;
130 btnNext.onClickEntity = me.campaignBox;
131 me.campaignBox.buttonNext = btnNext;
132 me.campaignBox.buttonPrev = btnPrev;
133 me.campaignBox.labelTitle = lblTitle;
134 me.campaignBox.campaignGo(me.campaignBox, 0);
136 me.gotoRC(me, me.rows - 1, 0);
137 me.TD(me, 1, me.columns, e = makeXonoticButton(_("Start Singleplayer!"), '0 0 0'));
138 e.onClick = CampaignList_LoadMap;
139 e.onClickEntity = me.campaignBox;