]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/menu/xonotic/dialog_multiplayer_create.qc
Show "Quit multiplayer / Disconnect from the server" as tooltip when hovering over...
[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 "inputbox.qh"
18
19 void GameType_ConfigureSliders(entity me, string pLabel, float pMin, float pMax, float pStep, string pCvar, string tCvar, string pTooltip)
20 {
21         int i;
22         entity e = me.sliderFraglimit;
23         entity l = me.labelFraglimit;
24         e.configureXonoticTextSlider(e, pCvar, pTooltip);
25         e.disabled = l.disabled = !pCvar;
26         l.setText(l, pLabel);
27
28         // clear old values
29         for(i = 0; i < e.nValues; ++i);
30         {
31                 strfree(e.(valueStrings[i]));
32                 strfree(e.(valueIdentifiers[i]));
33         }
34         e.clearValues(e);
35
36         if(pCvar != "")
37         {
38                 // set new values
39                 e.addValue(e, strzone(_("Default")), strzone("-1"));
40                 for(i = pMin; i <= pMax; i += pStep) { e.addValue(e, strzone(ftos(i)), strzone(ftos(i))); }
41                 e.addValue(e, strzone(_("Unlimited")), strzone("0"));
42         }
43         e.configureXonoticTextSliderValues(e);
44
45
46         entity t = me.sliderTeams;
47         entity tl = me.labelTeams;
48         t.configureXonoticTextSlider(t, tCvar, string_null);
49         tl.disabled = t.disabled = !tCvar;
50         t.nValues = (tCvar == "") ? 0 : 4; // instead of clearing / readding the very same values
51         t.configureXonoticTextSliderValues(t);
52 }
53
54 void GameType_ConfigureSliders_for_CurrentGametype(entity me)
55 {
56         Gametype gt = MapInfo_CurrentGametype();
57         gt.m_configuremenu(gt, me, GameType_ConfigureSliders);
58 }
59
60 entity makeXonoticServerCreateTab()
61 {
62         entity me;
63         me = NEW(XonoticServerCreateTab);
64         me.configureDialog(me);
65         return me;
66 }
67
68 .entity quitGameButton;
69 void XonoticServerCreateTab_draw(entity me)
70 {
71         entity e = me.quitGameButton;
72         e.disabled = !(gamestatus & (GAME_ISSERVER | GAME_CONNECTED));
73         e.setText(e, quitGameButton_getText(e));
74         setZonedTooltip(e, quitGameButton_getTooltip(e), string_null);
75         SUPER(XonoticServerCreateTab).draw(me);
76 }
77
78 void XonoticServerCreateTab_fill(entity me)
79 {
80         entity e, e0;
81
82         // the left half begins here
83
84         me.gotoRC(me, 0.5, 0);
85                 me.TD(me, 1, 3, makeXonoticHeaderLabel(_("Gametype")));
86         me.TR(me);
87                 me.TD(me, 10.5, 3, e = makeXonoticGametypeList());
88
89         me.gotoRC(me, 12.5, 0);
90                 me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Time limit:")));
91                 me.TD(me, 1, 2, e = makeXonoticTextSlider_T("timelimit_override",
92                         _("Timelimit in minutes that when hit, will end the match")));
93                         #define ADDVALUE_MINUTES(i) e.addValue(e, strzone(sprintf(_("%d minutes"), i)), #i)
94                         e.addValue(e, ZCTX(_("TIMLIM^Default")), "-1");
95                         e.addValue(e, _("1 minute"), "1");
96                         ADDVALUE_MINUTES(2);
97                         ADDVALUE_MINUTES(3);
98                         ADDVALUE_MINUTES(4);
99                         ADDVALUE_MINUTES(5);
100                         ADDVALUE_MINUTES(6);
101                         ADDVALUE_MINUTES(7);
102                         ADDVALUE_MINUTES(8);
103                         ADDVALUE_MINUTES(9);
104                         ADDVALUE_MINUTES(10);
105                         ADDVALUE_MINUTES(15);
106                         ADDVALUE_MINUTES(20);
107                         ADDVALUE_MINUTES(25);
108                         ADDVALUE_MINUTES(30);
109                         ADDVALUE_MINUTES(40);
110                         ADDVALUE_MINUTES(50);
111                         ADDVALUE_MINUTES(60);
112                         e.addValue(e, ZCTX(_("TIMLIM^Infinite")), "0");
113                         e.configureXonoticTextSliderValues(e);
114                         #undef ADDVALUE_MINUTES
115         me.TR(me);
116                 me.TD(me, 1, 1, me.labelFraglimit = makeXonoticTextLabel(0, _("Frag limit:")));
117                 me.TD(me, 1, 2, e = me.sliderFraglimit = makeXonoticTextSlider("fraglimit_override"));
118
119         me.gotoRC(me, 15, 0);
120                 me.TD(me, 1, 1, me.labelTeams = makeXonoticTextLabel(0, _("Teams:")));
121                 me.TD(me, 1, 2, e = me.sliderTeams = makeXonoticTextSlider(string_null));
122                         e.addValue(e, _("Default"), "0");
123                         e.addValue(e, _("2 teams"), "2");
124                         e.addValue(e, _("3 teams"), "3");
125                         e.addValue(e, _("4 teams"), "4");
126                         e.configureXonoticTextSliderValues(e);
127         me.TR(me);
128                 me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Player slots:")));
129                 me.TD(me, 1, 2, e = makeXonoticSlider_T(1, 32, 1, "menu_maxplayers",
130                         _("The maximum amount of players or bots that can be connected to your server at once")));
131         me.TR(me);
132                 me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Number of bots:")));
133                         setDependent(e, "g_campaign", 0, 0);
134                 me.TD(me, 1, 2, e = makeXonoticSlider_T(0, 9, 1, "bot_number",
135                         _("Amount of bots on your server")));
136                         setDependent(e, "g_campaign", 0, 0);
137         me.TR(me);
138                 me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Bot skill:")));
139                         setDependentAND(e, "bot_number", 0, -1, "g_campaign", 0, 0);
140                 me.TD(me, 1, 2, e = makeXonoticTextSlider_T("skill",
141                         _("Specify how experienced the bots will be")));
142                         e.addValue(e, _("Botlike"), "0");
143                         e.addValue(e, _("Beginner"), "1");
144                         e.addValue(e, _("You will win"), "2");
145                         e.addValue(e, _("You can win"), "3");
146                         e.addValue(e, _("You might win"), "4");
147                         e.addValue(e, _("Advanced"), "5");
148                         e.addValue(e, _("Expert"), "6");
149                         e.addValue(e, _("Pro"), "7");
150                         e.addValue(e, _("Assassin"), "8");
151                         e.addValue(e, _("Unhuman"), "9");
152                         e.addValue(e, _("Godlike"), "10");
153                         e.configureXonoticTextSliderValues(e);
154                         setDependentAND(e, "bot_number", 0, -1, "g_campaign", 0, 0);
155
156         me.gotoRC(me, me.rows - 3.8, 0);
157                 me.TD(me, 1, 3, e0 = makeXonoticTextLabel(0.5, string_null));
158                         e0.textEntity = main.mutatorsDialog;
159                         e0.allowCut = 1;
160                         //e0.allowWrap = 1;
161                         setDependent(e0, "g_campaign", 0, 0);
162
163         // mapListBox is in the right column but the ref is needed for mutators dialog here
164         me.mapListBox = makeXonoticMapList();
165         // here we use the following line instead of me.TR(me) for better visual spacing;
166         // this decision was made in this poll: http://forums.xonotic.org/showthread.php?tid=5445
167         me.gotoRC(me, me.rows - 2.5, 0);
168                 me.TDempty(me, 0.5);
169                 me.TD(me, 1, 2, e = makeXonoticButton_T(_("Mutators..."), '0 0 0',
170                         _("Mutators and weapon arenas")));
171                         e.onClick = DialogOpenButton_Click;
172                         e.onClickEntity = main.mutatorsDialog;
173                         main.mutatorsDialog.refilterEntity = me.mapListBox;
174                         setDependent(e, "g_campaign", 0, 0);
175
176         // The right half begins here
177
178         me.gotoRC(me, 0.5, 3.2); me.setFirstColumn(me, me.currentColumn);
179                 // the maplistbox
180                 me.TD(me, 1, 3, e = makeXonoticHeaderLabel(_("Maplist")));
181                         makeCallback(e, me.mapListBox, me.mapListBox.refilterCallback);
182         me.TR(me);
183                 // we use 5.8 here to visually match the bottom line of the component on the left (Bot Skill)
184                 me.TD(me, me.rows - 6.8, 3, me.mapListBox);
185
186         me.gotoRC(me, me.rows - 4.5, me.firstColumn);
187                 // string filter label and box
188                 me.TD(me, 1, 0.35, e = makeXonoticTextLabel(1, _("Filter:")));
189                 me.mapListBox.stringFilterBox = makeXonoticInputBox_T(0, string_null,
190                         _("Click here or Ctrl-F to provide a keyword to narrow down the map list. Ctrl-Delete to clear; Enter when done."));
191                 me.TD(me, 1, me.columns - me.firstColumn - 0.35, e = me.mapListBox.stringFilterBox);
192                         e.onChange = MapList_StringFilterBox_Change;
193                         e.keyDown = MapList_StringFilterBox_keyDown;
194                         e.onChangeEntity = me.mapListBox;
195
196         me.gotoRC(me, me.rows - 3.5, me.firstColumn);
197                 // the selection buttons
198                 me.TDempty(me, 0.2);
199                 me.TD(me, 1, 1.3, e = makeXonoticButton_T(_("Add shown"), '0 0 0',
200                         _("Add the maps shown in the list to your selection")));
201                         e.onClick = MapList_Add_Shown;
202                         e.onClickEntity = me.mapListBox;
203                 me.TD(me, 1, 1.3, e = makeXonoticButton_T(_("Remove shown"), '0 0 0',
204                         _("Remove the maps shown in the list from your selection")));
205                         e.onClick = MapList_Remove_Shown;
206                         e.onClickEntity = me.mapListBox;
207         me.gotoRC(me, me.rows - 2.5, me.firstColumn);
208                 me.TDempty(me, 0.2);
209                 me.TD(me, 1, 1.3, e = makeXonoticButton_T(_("Add all"), '0 0 0',
210                         _("Add every available map to your selection")));
211                         e.onClick = MapList_Add_All;
212                         e.onClickEntity = me.mapListBox;
213                 me.TD(me, 1, 1.3, e = makeXonoticButton_T(_("Remove all"), '0 0 0',
214                         _("Remove all the maps from your selection")));
215                         e.onClick = MapList_Remove_All;
216                         e.onClickEntity = me.mapListBox;
217
218         // bottom row
219         me.gotoRC(me, me.rows - 1, 0);
220                 me.TDempty(me, me.columns * 1/12);
221                 me.TD(me, 1, me.columns * 5/12, me.quitGameButton = makeXonoticCommandButton(string_null, '0 0 0', QUITGAME_CMD, 0));
222                 me.TD(me, 1, me.columns * 5/12, e = makeXonoticButton(_("Start multiplayer!"), '0 0 0'));
223                         e.onClick = MapList_LoadMap;
224                         e.onClickEntity = me.mapListBox;
225                         me.mapListBox.startButton = e;
226
227         GameType_ConfigureSliders_for_CurrentGametype(me);
228 }
229
230 void XonoticServerCreateTab_gameTypeChangeNotify(entity me)
231 {
232         GameType_ConfigureSliders_for_CurrentGametype(me);
233
234         me.mapListBox.refilter(me.mapListBox);
235 }
236
237 void XonoticServerCreateTab_gameTypeSelectNotify(entity me)
238 {
239         me.setFocus(me, me.mapListBox);
240 }