1 #ifndef DIALOG_MULTIPLAYER_CREATE_H
2 #define DIALOG_MULTIPLAYER_CREATE_H
4 CLASS(XonoticServerCreateTab, XonoticTab)
5 METHOD(XonoticServerCreateTab, fill, void(entity));
6 METHOD(XonoticServerCreateTab, gameTypeChangeNotify, void(entity));
7 METHOD(XonoticServerCreateTab, gameTypeSelectNotify, void(entity));
8 ATTRIB(XonoticServerCreateTab, intendedWidth, float, 0.9)
9 ATTRIB(XonoticServerCreateTab, rows, float, 23)
10 ATTRIB(XonoticServerCreateTab, columns, float, 6.2) // added extra .2 for center space
12 ATTRIB(XonoticServerCreateTab, mapListBox, entity, NULL)
13 ATTRIB(XonoticServerCreateTab, sliderFraglimit, entity, NULL)
14 ATTRIB(XonoticServerCreateTab, sliderTeams, entity, NULL)
15 ATTRIB(XonoticServerCreateTab, sliderTimelimit, entity, NULL)
16 ATTRIB(XonoticServerCreateTab, labelFraglimit, entity, NULL)
17 ATTRIB(XonoticServerCreateTab, labelTeams, entity, NULL)
18 ENDCLASS(XonoticServerCreateTab)
19 entity makeXonoticServerCreateTab();
24 void GameType_ConfigureSliders(entity me, string pLabel, float pMin, float pMax, float pStep, string pCvar, string tCvar, string pTooltip)
27 entity e = me.sliderFraglimit;
28 entity l = me.labelFraglimit;
29 e.configureXonoticTextSlider(e, pCvar, pTooltip);
30 e.disabled = l.disabled = !pCvar;
34 for(i = 0; i < e.nValues; ++i);
36 if(e.(valueStrings[i]))
38 strunzone(e.(valueStrings[i]));
39 e.(valueStrings[i]) = string_null;
41 if(e.(valueIdentifiers[i]))
43 strunzone(e.(valueIdentifiers[i]));
44 e.(valueIdentifiers[i]) = string_null;
52 e.addValue(e, strzone(_("Default")), strzone("-1"));
53 for(i = pMin; i <= pMax; i += pStep) { e.addValue(e, strzone(ftos(i)), strzone(ftos(i))); }
54 e.addValue(e, strzone(_("Unlimited")), strzone("0"));
56 e.configureXonoticTextSliderValues(e);
59 entity t = me.sliderTeams;
60 entity tl = me.labelTeams;
61 t.configureXonoticTextSlider(t, tCvar, string_null);
62 tl.disabled = t.disabled = !tCvar;
63 t.nValues = (tCvar == "") ? 0 : 4; // instead of clearing / readding the very same values
64 t.configureXonoticTextSliderValues(t);
67 entity makeXonoticServerCreateTab()
70 me = NEW(XonoticServerCreateTab);
71 me.configureDialog(me);
75 void XonoticServerCreateTab_fill(entity me)
79 // the left half begins here
81 me.gotoRC(me, 0.5, 0);
82 me.TD(me, 1, 3, makeXonoticHeaderLabel(_("Gametype")));
84 me.TD(me, 10.5, 3, e = makeXonoticGametypeList());
86 me.gotoRC(me, 12.5, 0);
87 me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Time limit:")));
88 me.TD(me, 1, 2, e = makeXonoticTextSlider_T("timelimit_override",
89 _("Timelimit in minutes that when hit, will end the match")));
90 #define ADDVALUE_MINUTES(i) e.addValue(e, strzone(sprintf(_("%d minutes"), i)), #i)
91 e.addValue(e, ZCTX(_("TIMLIM^Default")), "-1");
92 e.addValue(e, _("1 minute"), "1");
101 ADDVALUE_MINUTES(10);
102 ADDVALUE_MINUTES(15);
103 ADDVALUE_MINUTES(20);
104 ADDVALUE_MINUTES(25);
105 ADDVALUE_MINUTES(30);
106 ADDVALUE_MINUTES(40);
107 ADDVALUE_MINUTES(50);
108 ADDVALUE_MINUTES(60);
109 e.addValue(e, ZCTX(_("TIMLIM^Infinite")), "0");
110 e.configureXonoticTextSliderValues(e);
111 #undef ADDVALUE_MINUTES
113 me.TD(me, 1, 1, me.labelFraglimit = makeXonoticTextLabel(0, _("Frag limit:")));
114 me.TD(me, 1, 2, e = me.sliderFraglimit = makeXonoticTextSlider("fraglimit_override"));
116 me.gotoRC(me, 15, 0);
117 me.TD(me, 1, 1, me.labelTeams = makeXonoticTextLabel(0, _("Teams:")));
118 me.TD(me, 1, 2, e = me.sliderTeams = makeXonoticTextSlider(string_null));
119 e.addValue(e, _("Default"), "0");
120 e.addValue(e, _("2 teams"), "2");
121 e.addValue(e, _("3 teams"), "3");
122 e.addValue(e, _("4 teams"), "4");
123 e.configureXonoticTextSliderValues(e);
125 me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Player slots:")));
126 me.TD(me, 1, 2, e = makeXonoticSlider_T(1, 32, 1, "menu_maxplayers",
127 _("The maximum amount of players or bots that can be connected to your server at once")));
129 me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Number of bots:")));
130 me.TD(me, 1, 2, e = makeXonoticSlider_T(0, 9, 1, "bot_number",
131 _("Amount of bots on your server")));
133 me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Bot skill:")));
134 setDependent(e, "bot_number", 0, -1);
135 me.TD(me, 1, 2, e = makeXonoticTextSlider_T("skill",
136 _("Specify how experienced the bots will be")));
137 e.addValue(e, _("Botlike"), "0");
138 e.addValue(e, _("Beginner"), "1");
139 e.addValue(e, _("You will win"), "2");
140 e.addValue(e, _("You can win"), "3");
141 e.addValue(e, _("You might win"), "4");
142 e.addValue(e, _("Advanced"), "5");
143 e.addValue(e, _("Expert"), "6");
144 e.addValue(e, _("Pro"), "7");
145 e.addValue(e, _("Assassin"), "8");
146 e.addValue(e, _("Unhuman"), "9");
147 e.addValue(e, _("Godlike"), "10");
148 e.configureXonoticTextSliderValues(e);
149 setDependent(e, "bot_number", 0, -1);
151 me.gotoRC(me, me.rows - 3.8, 0);
152 me.TD(me, 1, 3, e0 = makeXonoticTextLabel(0.5, string_null));
153 e0.textEntity = main.mutatorsDialog;
157 // mapListBox is in the right column but the ref is needed for mutators dialog here
158 me.mapListBox = makeXonoticMapList();
159 // here we use the following line instead of me.TR(me) for better visual spacing;
160 // this decision was made in this poll: http://forums.xonotic.org/showthread.php?tid=5445
161 me.gotoRC(me, me.rows - 2.5, 0);
163 me.TD(me, 1, 2, e = makeXonoticButton_T(_("Mutators..."), '0 0 0',
164 _("Mutators and weapon arenas")));
165 e.onClick = DialogOpenButton_Click;
166 e.onClickEntity = main.mutatorsDialog;
167 main.mutatorsDialog.refilterEntity = me.mapListBox;
169 // The right half begins here
171 me.gotoRC(me, 0.5, 3.2); me.setFirstColumn(me, me.currentColumn);
173 me.TD(me, 1, 3, e = makeXonoticHeaderLabel(_("Maplist")));
174 makeCallback(e, me.mapListBox, me.mapListBox.refilterCallback);
176 // we use 5.8 here to visually match the bottom line of the component on the left (Bot Skill)
177 me.TD(me, me.rows - 6.8, 3, me.mapListBox);
179 me.gotoRC(me, me.rows - 4.5, me.firstColumn);
180 // string filter label and box
181 me.TD(me, 1, 0.35, e = makeXonoticTextLabel(1, _("Filter:")));
182 me.mapListBox.stringFilterBox = makeXonoticInputBox_T(0, string_null,
183 _("Click here or Ctrl-F to provide a keyword to narrow down the map list. Ctrl-Delete to clear; Enter when done."));
184 me.TD(me, 1, me.columns - me.firstColumn - 0.35, e = me.mapListBox.stringFilterBox);
185 e.onChange = MapList_StringFilterBox_Change;
186 e.keyDown = MapList_StringFilterBox_keyDown;
187 e.onChangeEntity = me.mapListBox;
189 me.gotoRC(me, me.rows - 3.5, me.firstColumn);
190 // the selection buttons
192 me.TD(me, 1, 1.3, e = makeXonoticButton_T(_("Add shown"), '0 0 0',
193 _("Add the maps shown in the list to your selection")));
194 e.onClick = MapList_Add_Shown;
195 e.onClickEntity = me.mapListBox;
196 me.TD(me, 1, 1.3, e = makeXonoticButton_T(_("Remove shown"), '0 0 0',
197 _("Remove the maps shown in the list from your selection")));
198 e.onClick = MapList_Remove_Shown;
199 e.onClickEntity = me.mapListBox;
200 me.gotoRC(me, me.rows - 2.5, me.firstColumn);
202 me.TD(me, 1, 1.3, e = makeXonoticButton_T(_("Add all"), '0 0 0',
203 _("Add every available map to your selection")));
204 e.onClick = MapList_Add_All;
205 e.onClickEntity = me.mapListBox;
206 me.TD(me, 1, 1.3, e = makeXonoticButton_T(_("Remove all"), '0 0 0',
207 _("Remove all the maps from your selection")));
208 e.onClick = MapList_Remove_All;
209 e.onClickEntity = me.mapListBox;
211 // The big button at the bottom
213 me.gotoRC(me, me.rows - 1, 0);
214 me.TD(me, 1, me.columns, e = makeXonoticButton(_("Start Multiplayer!"), '0 0 0'));
215 e.onClick = MapList_LoadMap;
216 e.onClickEntity = me.mapListBox;
217 me.mapListBox.startButton = e;
219 me.gameTypeChangeNotify(me);
222 void XonoticServerCreateTab_gameTypeChangeNotify(entity me)
224 switch(MapInfo_CurrentGametype())
226 case MAPINFO_TYPE_CA: GameType_ConfigureSliders(me, _("Frag limit:"), 5, 100, 5, "fraglimit_override", "g_ca_teams_override", _("The amount of frags needed before the match will end")); break;
227 case MAPINFO_TYPE_FREEZETAG: GameType_ConfigureSliders(me, _("Frag limit:"), 5, 100, 5, "fraglimit_override", "g_freezetag_teams_override", _("The amount of frags needed before the match will end")); break;
228 case MAPINFO_TYPE_CTF: GameType_ConfigureSliders(me, _("Capture limit:"), 1, 20, 1, "capturelimit_override", string_null, _("The amount of captures needed before the match will end")); break;
229 case MAPINFO_TYPE_DOMINATION: GameType_ConfigureSliders(me, _("Point limit:"), 50, 500, 10, "g_domination_point_limit", "g_domination_teams_override", _("The amount of points needed before the match will end")); break;
230 case MAPINFO_TYPE_KEYHUNT: GameType_ConfigureSliders(me, _("Point limit:"), 200, 1500, 50, "g_keyhunt_point_limit", "g_keyhunt_teams_override", _("The amount of points needed before the match will end")); break;
231 case MAPINFO_TYPE_LMS: GameType_ConfigureSliders(me, _("Lives:"), 3, 50, 1, "g_lms_lives_override", string_null, string_null); break;
232 case MAPINFO_TYPE_RACE: GameType_ConfigureSliders(me, _("Laps:"), 1, 25, 1, "g_race_laps_limit", string_null, string_null); break;
233 case MAPINFO_TYPE_NEXBALL: GameType_ConfigureSliders(me, _("Goals:"), 1, 50, 1, "g_nexball_goallimit", string_null, _("The amount of goals needed before the match will end")); break;
234 case MAPINFO_TYPE_ASSAULT: GameType_ConfigureSliders(me, _("Point limit:"), 50, 500, 10, string_null, string_null, string_null); break;
235 case MAPINFO_TYPE_ONSLAUGHT: GameType_ConfigureSliders(me, _("Point limit:"), 50, 500, 10, string_null, string_null, string_null); break;
236 case MAPINFO_TYPE_CTS: GameType_ConfigureSliders(me, _("Point limit:"), 50, 500, 10, string_null, string_null, string_null); break;
237 case MAPINFO_TYPE_INVASION: GameType_ConfigureSliders(me, _("Point limit:"), 50, 500, 10, string_null, string_null, string_null); break;
238 case MAPINFO_TYPE_TEAM_DEATHMATCH: GameType_ConfigureSliders(me, _("Point limit:"), 5, 100, 5, "g_tdm_point_limit", "g_tdm_teams_override", _("The amount of points needed before the match will end")); break;
239 default: GameType_ConfigureSliders(me, _("Frag limit:"), 5, 100, 5, "fraglimit_override", string_null, _("The amount of frags needed before the match will end")); break;
242 me.mapListBox.refilter(me.mapListBox);
245 void XonoticServerCreateTab_gameTypeSelectNotify(entity me)
247 me.setFocus(me, me.mapListBox);