1 #include "dialog_multiplayer_create.qh"
3 #include "dialog_multiplayer_create_mapinfo.qh"
4 #include "dialog_multiplayer_create_mutators.qh"
6 #include "gametypelist.qh"
8 #include <common/mapinfo.qh>
11 #include "textslider.qh"
12 #include "textlabel.qh"
14 #include "mainwindow.qh"
16 #include "commandbutton.qh"
17 #include "leavematchbutton.qh"
18 #include "inputbox.qh"
20 void GameType_ConfigureSliders(entity me, string pLabel, float pMin, float pMax, float pStep, string pCvar, string tCvar, string pTooltip)
23 entity e = me.sliderFraglimit;
24 entity l = me.labelFraglimit;
25 e.configureXonoticTextSlider(e, pCvar, pTooltip);
26 e.disabled = l.disabled = !pCvar;
30 for(i = 0; i < e.nValues; ++i);
32 strfree(e.(valueStrings[i]));
33 strfree(e.(valueIdentifiers[i]));
40 e.addValue(e, strzone(_("Default")), strzone("-1"));
41 for(i = pMin; i <= pMax; i += pStep) { e.addValue(e, strzone(ftos(i)), strzone(ftos(i))); }
42 e.addValue(e, strzone(_("Unlimited")), strzone("0"));
44 e.configureXonoticTextSliderValues(e);
47 entity t = me.sliderTeams;
48 entity tl = me.labelTeams;
49 t.configureXonoticTextSlider(t, tCvar, string_null);
50 tl.disabled = t.disabled = !tCvar;
51 t.nValues = (tCvar == "") ? 0 : 4; // instead of clearing / readding the very same values
52 t.configureXonoticTextSliderValues(t);
55 void GameType_ConfigureSliders_for_CurrentGametype(entity me)
57 Gametype gt = MapInfo_CurrentGametype();
58 gt.m_configuremenu(gt, me, GameType_ConfigureSliders);
61 entity makeXonoticServerCreateTab()
64 me = NEW(XonoticServerCreateTab);
65 me.configureDialog(me);
69 void XonoticServerCreateTab_fill(entity me)
73 // the left half begins here
75 me.gotoRC(me, 0.5, 0);
76 me.TD(me, 1, 3, makeXonoticHeaderLabel(_("Gametype")));
78 me.TD(me, 10.5, 3, e = makeXonoticGametypeList());
80 me.gotoRC(me, 12.5, 0);
81 me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Time limit:")));
82 me.TD(me, 1, 2, e = makeXonoticTextSlider_T("timelimit_override",
83 _("Timelimit in minutes that when hit, will end the match")));
84 #define ADDVALUE_MINUTES(i) e.addValue(e, strzone(sprintf(_("%d minutes"), i)), #i)
85 e.addValue(e, ZCTX(_("TIMLIM^Default")), "-1");
86 e.addValue(e, _("1 minute"), "1");
100 ADDVALUE_MINUTES(40);
101 ADDVALUE_MINUTES(50);
102 ADDVALUE_MINUTES(60);
103 e.addValue(e, ZCTX(_("TIMLIM^Infinite")), "0");
104 e.configureXonoticTextSliderValues(e);
105 #undef ADDVALUE_MINUTES
107 me.TD(me, 1, 1, me.labelFraglimit = makeXonoticTextLabel(0, _("Frag limit:")));
108 me.TD(me, 1, 2, e = me.sliderFraglimit = makeXonoticTextSlider("fraglimit_override"));
110 me.gotoRC(me, 15, 0);
111 me.TD(me, 1, 1, me.labelTeams = makeXonoticTextLabel(0, _("Teams:")));
112 me.TD(me, 1, 2, e = me.sliderTeams = makeXonoticTextSlider(string_null));
113 e.addValue(e, _("Default"), "0");
114 e.addValue(e, _("2 teams"), "2");
115 e.addValue(e, _("3 teams"), "3");
116 e.addValue(e, _("4 teams"), "4");
117 e.configureXonoticTextSliderValues(e);
119 me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Player slots:")));
120 me.TD(me, 1, 2, e = makeXonoticSlider_T(1, 32, 1, "menu_maxplayers",
121 _("The maximum amount of players or bots that can be connected to your server at once")));
123 me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Number of bots:")));
124 setDependent(e, "g_campaign", 0, 0);
125 me.TD(me, 1, 2, e = makeXonoticSlider_T(0, 9, 1, "bot_number",
126 _("Amount of bots on your server")));
127 setDependent(e, "g_campaign", 0, 0);
129 me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Bot skill:")));
130 setDependentAND(e, "bot_number", 0, -1, "g_campaign", 0, 0);
131 me.TD(me, 1, 2, e = makeXonoticTextSlider_T("skill",
132 _("Specify how experienced the bots will be")));
133 e.addValue(e, _("Botlike"), "0");
134 e.addValue(e, _("Beginner"), "1");
135 e.addValue(e, _("You will win"), "2");
136 e.addValue(e, _("You can win"), "3");
137 e.addValue(e, _("You might win"), "4");
138 e.addValue(e, _("Advanced"), "5");
139 e.addValue(e, _("Expert"), "6");
140 e.addValue(e, _("Pro"), "7");
141 e.addValue(e, _("Assassin"), "8");
142 e.addValue(e, _("Unhuman"), "9");
143 e.addValue(e, _("Godlike"), "10");
144 e.configureXonoticTextSliderValues(e);
145 setDependentAND(e, "bot_number", 0, -1, "g_campaign", 0, 0);
147 me.gotoRC(me, me.rows - 3.8, 0);
148 me.TD(me, 1, 3, e0 = makeXonoticTextLabel(0.5, string_null));
149 e0.textEntity = main.mutatorsDialog;
152 setDependent(e0, "g_campaign", 0, 0);
154 // mapListBox is in the right column but the ref is needed for mutators dialog here
155 me.mapListBox = makeXonoticMapList();
156 // here we use the following line instead of me.TR(me) for better visual spacing;
157 // this decision was made in this poll: http://forums.xonotic.org/showthread.php?tid=5445
158 me.gotoRC(me, me.rows - 2.5, 0);
160 me.TD(me, 1, 2, e = makeXonoticButton_T(_("Mutators..."), '0 0 0',
161 _("Mutators and weapon arenas")));
162 e.onClick = DialogOpenButton_Click;
163 e.onClickEntity = main.mutatorsDialog;
164 main.mutatorsDialog.refilterEntity = me.mapListBox;
165 setDependent(e, "g_campaign", 0, 0);
167 // The right half begins here
169 me.gotoRC(me, 0.5, 3.2); me.setFirstColumn(me, me.currentColumn);
171 me.TD(me, 1, 3, e = makeXonoticHeaderLabel(_("Maplist")));
172 makeCallback(e, me.mapListBox, me.mapListBox.refilterCallback);
174 // we use 5.8 here to visually match the bottom line of the component on the left (Bot Skill)
175 me.TD(me, me.rows - 6.8, 3, me.mapListBox);
177 me.gotoRC(me, me.rows - 4.5, me.firstColumn);
178 // string filter label and box
179 me.TD(me, 1, 0.35, e = makeXonoticTextLabel(1, _("Filter:")));
180 me.mapListBox.stringFilterBox = makeXonoticInputBox_T(0, string_null,
181 _("Click here or Ctrl-F to provide a keyword to narrow down the map list. Ctrl-Delete to clear; Enter when done."));
182 me.TD(me, 1, me.columns - me.firstColumn - 0.35, e = me.mapListBox.stringFilterBox);
183 e.onChange = MapList_StringFilterBox_Change;
184 e.keyDown = MapList_StringFilterBox_keyDown;
185 e.onChangeEntity = me.mapListBox;
187 me.gotoRC(me, me.rows - 3.5, me.firstColumn);
188 // the selection buttons
190 me.TD(me, 1, 1.3, e = makeXonoticButton_T(_("Add shown"), '0 0 0',
191 _("Add the maps shown in the list to your selection")));
192 e.onClick = MapList_Add_Shown;
193 e.onClickEntity = me.mapListBox;
194 me.TD(me, 1, 1.3, e = makeXonoticButton_T(_("Remove shown"), '0 0 0',
195 _("Remove the maps shown in the list from your selection")));
196 e.onClick = MapList_Remove_Shown;
197 e.onClickEntity = me.mapListBox;
198 me.gotoRC(me, me.rows - 2.5, me.firstColumn);
200 me.TD(me, 1, 1.3, e = makeXonoticButton_T(_("Add all"), '0 0 0',
201 _("Add every available map to your selection")));
202 e.onClick = MapList_Add_All;
203 e.onClickEntity = me.mapListBox;
204 me.TD(me, 1, 1.3, e = makeXonoticButton_T(_("Remove all"), '0 0 0',
205 _("Remove all the maps from your selection")));
206 e.onClick = MapList_Remove_All;
207 e.onClickEntity = me.mapListBox;
210 me.gotoRC(me, me.rows - 1, 0);
211 me.TDempty(me, me.columns * 1/12);
212 me.TD(me, 1, me.columns * 5/12, e = makeXonoticLeaveMatchButton('0 0 0', 0));
213 me.TD(me, 1, me.columns * 5/12, e = makeXonoticButton(_("Start multiplayer!"), '0 0 0'));
214 e.onClick = MapList_LoadMap;
215 e.onClickEntity = me.mapListBox;
216 me.mapListBox.startButton = e;
218 GameType_ConfigureSliders_for_CurrentGametype(me);
221 void XonoticServerCreateTab_gameTypeChangeNotify(entity me)
223 GameType_ConfigureSliders_for_CurrentGametype(me);
225 me.mapListBox.refilter(me.mapListBox);
228 void XonoticServerCreateTab_gameTypeSelectNotify(entity me)
230 me.setFocus(me, me.mapListBox);