]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/menu/xonotic/dialog_multiplayer_create.qc
Use "leave" instead of "quit" in the menu where appropriate; the "Quit" dialogue...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / dialog_multiplayer_create.qc
1 #include "dialog_multiplayer_create.qh"
2
3 #include "dialog_multiplayer_create_mapinfo.qh"
4 #include "dialog_multiplayer_create_mutators.qh"
5
6 #include "gametypelist.qh"
7 #include "maplist.qh"
8 #include <common/mapinfo.qh>
9
10 #include "image.qh"
11 #include "textslider.qh"
12 #include "textlabel.qh"
13 #include "slider.qh"
14 #include "mainwindow.qh"
15 #include "button.qh"
16 #include "commandbutton.qh"
17 #include "leavematchbutton.qh"
18 #include "inputbox.qh"
19
20 void GameType_ConfigureSliders(entity me, string pLabel, float pMin, float pMax, float pStep, string pCvar, string tCvar, string pTooltip)
21 {
22         int i;
23         entity e = me.sliderFraglimit;
24         entity l = me.labelFraglimit;
25         e.configureXonoticTextSlider(e, pCvar, pTooltip);
26         e.disabled = l.disabled = !pCvar;
27         l.setText(l, pLabel);
28
29         // clear old values
30         for(i = 0; i < e.nValues; ++i);
31         {
32                 strfree(e.(valueStrings[i]));
33                 strfree(e.(valueIdentifiers[i]));
34         }
35         e.clearValues(e);
36
37         if(pCvar != "")
38         {
39                 // set new values
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"));
43         }
44         e.configureXonoticTextSliderValues(e);
45
46
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);
53 }
54
55 void GameType_ConfigureSliders_for_CurrentGametype(entity me)
56 {
57         Gametype gt = MapInfo_CurrentGametype();
58         gt.m_configuremenu(gt, me, GameType_ConfigureSliders);
59 }
60
61 entity makeXonoticServerCreateTab()
62 {
63         entity me;
64         me = NEW(XonoticServerCreateTab);
65         me.configureDialog(me);
66         return me;
67 }
68
69 .entity leaveMatchButton;
70
71 void XonoticServerCreateTab_fill(entity me)
72 {
73         entity e, e0;
74
75         // the left half begins here
76
77         me.gotoRC(me, 0.5, 0);
78                 me.TD(me, 1, 3, makeXonoticHeaderLabel(_("Gametype")));
79         me.TR(me);
80                 me.TD(me, 10.5, 3, e = makeXonoticGametypeList());
81
82         me.gotoRC(me, 12.5, 0);
83                 me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Time limit:")));
84                 me.TD(me, 1, 2, e = makeXonoticTextSlider_T("timelimit_override",
85                         _("Timelimit in minutes that when hit, will end the match")));
86                         #define ADDVALUE_MINUTES(i) e.addValue(e, strzone(sprintf(_("%d minutes"), i)), #i)
87                         e.addValue(e, ZCTX(_("TIMLIM^Default")), "-1");
88                         e.addValue(e, _("1 minute"), "1");
89                         ADDVALUE_MINUTES(2);
90                         ADDVALUE_MINUTES(3);
91                         ADDVALUE_MINUTES(4);
92                         ADDVALUE_MINUTES(5);
93                         ADDVALUE_MINUTES(6);
94                         ADDVALUE_MINUTES(7);
95                         ADDVALUE_MINUTES(8);
96                         ADDVALUE_MINUTES(9);
97                         ADDVALUE_MINUTES(10);
98                         ADDVALUE_MINUTES(15);
99                         ADDVALUE_MINUTES(20);
100                         ADDVALUE_MINUTES(25);
101                         ADDVALUE_MINUTES(30);
102                         ADDVALUE_MINUTES(40);
103                         ADDVALUE_MINUTES(50);
104                         ADDVALUE_MINUTES(60);
105                         e.addValue(e, ZCTX(_("TIMLIM^Infinite")), "0");
106                         e.configureXonoticTextSliderValues(e);
107                         #undef ADDVALUE_MINUTES
108         me.TR(me);
109                 me.TD(me, 1, 1, me.labelFraglimit = makeXonoticTextLabel(0, _("Frag limit:")));
110                 me.TD(me, 1, 2, e = me.sliderFraglimit = makeXonoticTextSlider("fraglimit_override"));
111
112         me.gotoRC(me, 15, 0);
113                 me.TD(me, 1, 1, me.labelTeams = makeXonoticTextLabel(0, _("Teams:")));
114                 me.TD(me, 1, 2, e = me.sliderTeams = makeXonoticTextSlider(string_null));
115                         e.addValue(e, _("Default"), "0");
116                         e.addValue(e, _("2 teams"), "2");
117                         e.addValue(e, _("3 teams"), "3");
118                         e.addValue(e, _("4 teams"), "4");
119                         e.configureXonoticTextSliderValues(e);
120         me.TR(me);
121                 me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Player slots:")));
122                 me.TD(me, 1, 2, e = makeXonoticSlider_T(1, 32, 1, "menu_maxplayers",
123                         _("The maximum amount of players or bots that can be connected to your server at once")));
124         me.TR(me);
125                 me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Number of bots:")));
126                         setDependent(e, "g_campaign", 0, 0);
127                 me.TD(me, 1, 2, e = makeXonoticSlider_T(0, 9, 1, "bot_number",
128                         _("Amount of bots on your server")));
129                         setDependent(e, "g_campaign", 0, 0);
130         me.TR(me);
131                 me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Bot skill:")));
132                         setDependentAND(e, "bot_number", 0, -1, "g_campaign", 0, 0);
133                 me.TD(me, 1, 2, e = makeXonoticTextSlider_T("skill",
134                         _("Specify how experienced the bots will be")));
135                         e.addValue(e, _("Botlike"), "0");
136                         e.addValue(e, _("Beginner"), "1");
137                         e.addValue(e, _("You will win"), "2");
138                         e.addValue(e, _("You can win"), "3");
139                         e.addValue(e, _("You might win"), "4");
140                         e.addValue(e, _("Advanced"), "5");
141                         e.addValue(e, _("Expert"), "6");
142                         e.addValue(e, _("Pro"), "7");
143                         e.addValue(e, _("Assassin"), "8");
144                         e.addValue(e, _("Unhuman"), "9");
145                         e.addValue(e, _("Godlike"), "10");
146                         e.configureXonoticTextSliderValues(e);
147                         setDependentAND(e, "bot_number", 0, -1, "g_campaign", 0, 0);
148
149         me.gotoRC(me, me.rows - 3.8, 0);
150                 me.TD(me, 1, 3, e0 = makeXonoticTextLabel(0.5, string_null));
151                         e0.textEntity = main.mutatorsDialog;
152                         e0.allowCut = 1;
153                         //e0.allowWrap = 1;
154                         setDependent(e0, "g_campaign", 0, 0);
155
156         // mapListBox is in the right column but the ref is needed for mutators dialog here
157         me.mapListBox = makeXonoticMapList();
158         // here we use the following line instead of me.TR(me) for better visual spacing;
159         // this decision was made in this poll: http://forums.xonotic.org/showthread.php?tid=5445
160         me.gotoRC(me, me.rows - 2.5, 0);
161                 me.TDempty(me, 0.5);
162                 me.TD(me, 1, 2, e = makeXonoticButton_T(_("Mutators..."), '0 0 0',
163                         _("Mutators and weapon arenas")));
164                         e.onClick = DialogOpenButton_Click;
165                         e.onClickEntity = main.mutatorsDialog;
166                         main.mutatorsDialog.refilterEntity = me.mapListBox;
167                         setDependent(e, "g_campaign", 0, 0);
168
169         // The right half begins here
170
171         me.gotoRC(me, 0.5, 3.2); me.setFirstColumn(me, me.currentColumn);
172                 // the maplistbox
173                 me.TD(me, 1, 3, e = makeXonoticHeaderLabel(_("Maplist")));
174                         makeCallback(e, me.mapListBox, me.mapListBox.refilterCallback);
175         me.TR(me);
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);
178
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;
188
189         me.gotoRC(me, me.rows - 3.5, me.firstColumn);
190                 // the selection buttons
191                 me.TDempty(me, 0.2);
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);
201                 me.TDempty(me, 0.2);
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;
210
211         // bottom row
212         me.gotoRC(me, me.rows - 1, 0);
213                 me.TDempty(me, me.columns * 1/12);
214                 me.TD(me, 1, me.columns * 5/12, me.leaveMatchButton = makeXonoticLeaveMatchButton('0 0 0', 0));
215                 me.TD(me, 1, me.columns * 5/12, e = makeXonoticButton(_("Start multiplayer!"), '0 0 0'));
216                         e.onClick = MapList_LoadMap;
217                         e.onClickEntity = me.mapListBox;
218                         me.mapListBox.startButton = e;
219
220         GameType_ConfigureSliders_for_CurrentGametype(me);
221 }
222
223 void XonoticServerCreateTab_gameTypeChangeNotify(entity me)
224 {
225         GameType_ConfigureSliders_for_CurrentGametype(me);
226
227         me.mapListBox.refilter(me.mapListBox);
228 }
229
230 void XonoticServerCreateTab_gameTypeSelectNotify(entity me)
231 {
232         me.setFocus(me, me.mapListBox);
233 }