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 e, entity l, string pLabel, float pMin, float pMax, float pStep, string pCvar)
28 e.configureXonoticTextSlider(e, string_null, string_null);
30 e.disabled = l.disabled = true;
34 e.configureXonoticTextSlider(e, pCvar, "-");
38 for(i = 0; i <= e.nValues; ++i);
40 if(e.(valueStrings[i])) { strunzone(e.(valueStrings[i])); }
41 if(e.(valueIdentifiers[i])) { strunzone(e.(valueIdentifiers[i])); }
46 e.addValue(e, strzone(_("Default")), strzone("-1"));
47 for(i = pMin; i <= pMax; i += pStep) { e.addValue(e, strzone(ftos(i)), strzone(ftos(i))); }
48 e.addValue(e, strzone(_("Unlimited")), strzone("0"));
49 e.configureXonoticTextSliderValues(e);
53 e.disabled = l.disabled = false;
57 entity makeXonoticServerCreateTab()
60 me = NEW(XonoticServerCreateTab);
61 me.configureDialog(me);
65 void XonoticServerCreateTab_fill(entity me)
69 // the left half begins here
71 me.gotoRC(me, 0.5, 0);
72 me.TD(me, 1, 3, makeXonoticHeaderLabel(_("Gametype")));
74 me.TD(me, 10.5, 3, e = makeXonoticGametypeList());
76 me.gotoRC(me, 12.5, 0);
77 me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Time limit:")));
78 me.TD(me, 1, 2, e = makeXonoticTextSlider_T("timelimit_override",
79 _("Timelimit in minutes that when hit, will end the match")));
80 e.addValue(e, ZCTX(_("TIMLIM^Default")), "-1");
81 e.addValue(e, ZCTX(_("TIMLIM^1 minute")), "1");
82 e.addValue(e, ZCTX(_("TIMLIM^2 minutes")), "2");
83 e.addValue(e, ZCTX(_("TIMLIM^3 minutes")), "3");
84 e.addValue(e, ZCTX(_("TIMLIM^4 minutes")), "4");
85 e.addValue(e, ZCTX(_("TIMLIM^5 minutes")), "5");
86 e.addValue(e, ZCTX(_("TIMLIM^6 minutes")), "6");
87 e.addValue(e, ZCTX(_("TIMLIM^7 minutes")), "7");
88 e.addValue(e, ZCTX(_("TIMLIM^8 minutes")), "8");
89 e.addValue(e, ZCTX(_("TIMLIM^9 minutes")), "9");
90 e.addValue(e, ZCTX(_("TIMLIM^10 minutes")), "10");
91 e.addValue(e, ZCTX(_("TIMLIM^15 minutes")), "15");
92 e.addValue(e, ZCTX(_("TIMLIM^20 minutes")), "20");
93 e.addValue(e, ZCTX(_("TIMLIM^25 minutes")), "25");
94 e.addValue(e, ZCTX(_("TIMLIM^30 minutes")), "30");
95 e.addValue(e, ZCTX(_("TIMLIM^40 minutes")), "40");
96 e.addValue(e, ZCTX(_("TIMLIM^50 minutes")), "50");
97 e.addValue(e, ZCTX(_("TIMLIM^60 minutes")), "60");
98 e.addValue(e, ZCTX(_("TIMLIM^Infinite")), "0");
99 e.configureXonoticTextSliderValues(e);
101 me.TD(me, 1, 1, me.labelFraglimit = makeXonoticTextLabel(0, _("Frag limit:")));
102 me.TD(me, 1, 2, e = me.sliderFraglimit = makeXonoticTextSlider("fraglimit_override"));
103 // TODO add logic to update tooltip. fraglimit_override tooltip:
104 // _("The amount of frags needed before the match will end")
105 GameType_ConfigureSliders(me.sliderFraglimit, me.labelFraglimit, _("Frag limit:"), 5, 100, 5, "fraglimit_override");
107 me.gotoRC(me, 15, 0);
108 me.TD(me, 1, 1, me.labelTeams = makeXonoticTextLabel(0, _("Teams:")));
109 me.TD(me, 1, 2, e = me.sliderTeams = makeXonoticTextSlider(string_null));
110 // TODO add logic to change the default tooltip: _("The amount of frags needed before the match will end")
111 e.addValue(e, _("Default"), "0");
112 e.addValue(e, _("2 teams"), "2");
113 e.addValue(e, _("3 teams"), "3");
114 e.addValue(e, _("4 teams"), "4");
115 e.configureXonoticTextSliderValues(e);
117 me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Player slots:")));
118 me.TD(me, 1, 2, e = makeXonoticSlider_T(1, 32, 1, "menu_maxplayers",
119 _("The maximum amount of players or bots that can be connected to your server at once")));
121 me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Number of bots:")));
122 me.TD(me, 1, 2, e = makeXonoticSlider_T(0, 9, 1, "bot_number",
123 _("Amount of bots on your server")));
125 me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Bot skill:")));
126 setDependent(e, "bot_number", 0, -1);
127 me.TD(me, 1, 2, e = makeXonoticTextSlider_T("skill",
128 _("Specify how experienced the bots will be")));
129 e.addValue(e, _("Botlike"), "0");
130 e.addValue(e, _("Beginner"), "1");
131 e.addValue(e, _("You will win"), "2");
132 e.addValue(e, _("You can win"), "3");
133 e.addValue(e, _("You might win"), "4");
134 e.addValue(e, _("Advanced"), "5");
135 e.addValue(e, _("Expert"), "6");
136 e.addValue(e, _("Pro"), "7");
137 e.addValue(e, _("Assassin"), "8");
138 e.addValue(e, _("Unhuman"), "9");
139 e.addValue(e, _("Godlike"), "10");
140 e.configureXonoticTextSliderValues(e);
141 setDependent(e, "bot_number", 0, -1);
143 me.gotoRC(me, me.rows - 3.8, 0);
144 me.TD(me, 1, 3, e0 = makeXonoticTextLabel(0.5, string_null));
145 e0.textEntity = main.mutatorsDialog;
149 // mapListBox is in the right column but the ref is needed for mutators dialog here
150 me.mapListBox = makeXonoticMapList();
151 // here we use the following line instead of me.TR(me) for better visual spacing;
152 // this decision was made in this poll: http://forums.xonotic.org/showthread.php?tid=5445
153 me.gotoRC(me, me.rows - 2.5, 0);
155 me.TD(me, 1, 2, e = makeXonoticButton_T(_("Mutators..."), '0 0 0',
156 _("Mutators and weapon arenas")));
157 e.onClick = DialogOpenButton_Click;
158 e.onClickEntity = main.mutatorsDialog;
159 main.mutatorsDialog.refilterEntity = me.mapListBox;
161 // The right half begins here
163 me.gotoRC(me, 0.5, 3.2); me.setFirstColumn(me, me.currentColumn);
165 me.TD(me, 1, 3, e = makeXonoticHeaderLabel(_("Maplist")));
166 makeCallback(e, me.mapListBox, me.mapListBox.refilterCallback);
168 // we use 5.8 here to visually match the bottom line of the component on the left (Bot Skill)
169 me.TD(me, me.rows - 6.8, 3, me.mapListBox);
171 me.gotoRC(me, me.rows - 4.5, me.firstColumn);
172 // string filter label and box
173 me.TD(me, 1, 0.35, e = makeXonoticTextLabel(1, _("Filter:")));
174 me.mapListBox.stringFilterBox = makeXonoticInputBox_T(0, string_null,
175 _("Click here or Ctrl-F to provide a keyword to narrow down the maplist above. Ctrl-Delete to clear; Enter when done."));
176 me.TD(me, 1, me.columns - me.firstColumn - 0.35, e = me.mapListBox.stringFilterBox);
177 e.onChange = MapList_StringFilterBox_Change;
178 e.keyDown = MapList_StringFilterBox_keyDown;
179 e.onChangeEntity = me.mapListBox;
180 me.mapListBox.controlledTextbox = e;
182 me.gotoRC(me, me.rows - 3.5, me.firstColumn);
183 // the selection buttons
185 me.TD(me, 1, 1.3, e = makeXonoticButton_T(_("Add shown"), '0 0 0',
186 _("Add the maps shown in Maplist above to your selection")));
187 e.onClick = MapList_Add_Shown;
188 e.onClickEntity = me.mapListBox;
189 me.TD(me, 1, 1.3, e = makeXonoticButton_T(_("Remove shown"), '0 0 0',
190 _("Remove the maps shown in Maplist above from your selection")));
191 e.onClick = MapList_Remove_Shown;
192 e.onClickEntity = me.mapListBox;
193 me.gotoRC(me, me.rows - 2.5, me.firstColumn);
195 me.TD(me, 1, 1.3, e = makeXonoticButton_T(_("Add all"), '0 0 0',
196 _("Add every available map to your selection")));
197 e.onClick = MapList_Add_All;
198 e.onClickEntity = me.mapListBox;
199 me.TD(me, 1, 1.3, e = makeXonoticButton_T(_("Remove all"), '0 0 0',
200 _("Remove all the maps from your selection")));
201 e.onClick = MapList_Remove_All;
202 e.onClickEntity = me.mapListBox;
204 // The big button at the bottom
206 me.gotoRC(me, me.rows - 1, 0);
207 me.TD(me, 1, me.columns, e = makeXonoticButton(_("Start Multiplayer!"), '0 0 0'));
208 e.onClick = MapList_LoadMap;
209 e.onClickEntity = me.mapListBox;
210 me.mapListBox.startButton = e;
212 me.gameTypeChangeNotify(me);
215 void XonoticServerCreateTab_gameTypeChangeNotify(entity me)
217 // tell the map list to update
220 gt = MapInfo_CurrentGametype();
221 e = me.sliderFraglimit;
222 l = me.labelFraglimit;
226 case MAPINFO_TYPE_CTF: GameType_ConfigureSliders(e, l, _("Capture limit:"), 1, 20, 1, "capturelimit_override"); break;
227 case MAPINFO_TYPE_DOMINATION: GameType_ConfigureSliders(e, l, _("Point limit:"), 50, 500, 10, "g_domination_point_limit"); break;
228 case MAPINFO_TYPE_KEYHUNT: GameType_ConfigureSliders(e, l, _("Point limit:"), 200, 1500, 50, "g_keyhunt_point_limit"); break;
229 case MAPINFO_TYPE_LMS: GameType_ConfigureSliders(e, l, _("Lives:"), 3, 50, 1, "g_lms_lives_override"); break;
230 case MAPINFO_TYPE_RACE: GameType_ConfigureSliders(e, l, _("Laps:"), 1, 25, 1, "g_race_laps_limit"); break;
231 case MAPINFO_TYPE_NEXBALL: GameType_ConfigureSliders(e, l, _("Goals:"), 1, 50, 1, "g_nexball_goallimit"); break;
232 case MAPINFO_TYPE_ASSAULT: GameType_ConfigureSliders(e, l, _("Point limit:"), 50, 500, 10, ""); break;
233 case MAPINFO_TYPE_ONSLAUGHT: GameType_ConfigureSliders(e, l, _("Point limit:"), 50, 500, 10, ""); break;
234 case MAPINFO_TYPE_CTS: GameType_ConfigureSliders(e, l, _("Point limit:"), 50, 500, 10, ""); break;
235 case MAPINFO_TYPE_INVASION: GameType_ConfigureSliders(e, l, _("Point limit:"), 5, 0, 5, ""); break;
236 case MAPINFO_TYPE_TEAM_DEATHMATCH:GameType_ConfigureSliders(e, l, _("Point limit:"), 5, 100, 5, "g_tdm_point_limit"); break;
237 default: GameType_ConfigureSliders(e, l, _("Frag limit:"), 5, 100, 5, "fraglimit_override"); break;
240 string x = string_null;
244 case MAPINFO_TYPE_CA: x = "g_ca_teams_override"; break;
245 case MAPINFO_TYPE_DOMINATION: x = "g_domination_teams_override"; break;
246 case MAPINFO_TYPE_FREEZETAG: x = "g_freezetag_teams_override"; break;
247 case MAPINFO_TYPE_KEYHUNT: x = "g_keyhunt_teams_override"; break;
248 case MAPINFO_TYPE_TEAM_DEATHMATCH: x = "g_tdm_teams_override"; break;
249 // TODO add logic to update tooltip
251 e.configureXonoticTextSlider(e, x, string_null);
252 e.configureXonoticTextSliderValues(e);
255 me.sliderTeams.disabled = me.labelTeams.disabled = !x;
257 me.mapListBox.refilter(me.mapListBox);
260 void XonoticServerCreateTab_gameTypeSelectNotify(entity me)
262 me.setFocus(me, me.mapListBox);