Xonotic
dialog_multiplayer_create.qc
Go to the documentation of this file.
2 
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 "inputbox.qh"
17 
18 void GameType_ConfigureSliders(entity me, string pLabel, float pMin, float pMax, float pStep, string pCvar, string tCvar, string pTooltip)
19 {
20  int i;
21  entity e = me.sliderFraglimit;
22  entity l = me.labelFraglimit;
23  e.configureXonoticTextSlider(e, pCvar, pTooltip);
24  e.disabled = l.disabled = !pCvar;
25  l.setText(l, pLabel);
26 
27  // clear old values
28  for(i = 0; i < e.nValues; ++i);
29  {
30  strfree(e.(valueStrings[i]));
31  strfree(e.(valueIdentifiers[i]));
32  }
33  e.clearValues(e);
34 
35  if(pCvar != "")
36  {
37  // set new values
38  e.addValue(e, strzone(_("Default")), strzone("-1"));
39  for(i = pMin; i <= pMax; i += pStep) { e.addValue(e, strzone(ftos(i)), strzone(ftos(i))); }
40  e.addValue(e, strzone(_("Unlimited")), strzone("0"));
41  }
42  e.configureXonoticTextSliderValues(e);
43 
44 
45  entity t = me.sliderTeams;
46  entity tl = me.labelTeams;
47  t.configureXonoticTextSlider(t, tCvar, string_null);
48  tl.disabled = t.disabled = !tCvar;
49  t.nValues = (tCvar == "") ? 0 : 4; // instead of clearing / readding the very same values
50  t.configureXonoticTextSliderValues(t);
51 }
52 
54 {
56  gt.m_configuremenu(gt, me, GameType_ConfigureSliders);
57 }
58 
60 {
61  entity me;
63  me.configureDialog(me);
64  return me;
65 }
66 
68 {
69  entity e, e0;
70 
71  // the left half begins here
72 
73  me.gotoRC(me, 0.5, 0);
74  me.TD(me, 1, 3, makeXonoticHeaderLabel(_("Gametype")));
75  me.TR(me);
76  me.TD(me, 10.5, 3, e = makeXonoticGametypeList());
77 
78  me.gotoRC(me, 12.5, 0);
79  me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Time limit:")));
80  me.TD(me, 1, 2, e = makeXonoticTextSlider_T("timelimit_override",
81  _("Timelimit in minutes that when hit, will end the match")));
82  #define ADDVALUE_MINUTES(i) e.addValue(e, strzone(sprintf(_("%d minutes"), i)), #i)
83  e.addValue(e, ZCTX(_("TIMLIM^Default")), "-1");
84  e.addValue(e, _("1 minute"), "1");
93  ADDVALUE_MINUTES(10);
94  ADDVALUE_MINUTES(15);
95  ADDVALUE_MINUTES(20);
96  ADDVALUE_MINUTES(25);
97  ADDVALUE_MINUTES(30);
98  ADDVALUE_MINUTES(40);
99  ADDVALUE_MINUTES(50);
100  ADDVALUE_MINUTES(60);
101  e.addValue(e, ZCTX(_("TIMLIM^Infinite")), "0");
102  e.configureXonoticTextSliderValues(e);
103  #undef ADDVALUE_MINUTES
104  me.TR(me);
105  me.TD(me, 1, 1, me.labelFraglimit = makeXonoticTextLabel(0, _("Frag limit:")));
106  me.TD(me, 1, 2, e = me.sliderFraglimit = makeXonoticTextSlider("fraglimit_override"));
107 
108  me.gotoRC(me, 15, 0);
109  me.TD(me, 1, 1, me.labelTeams = makeXonoticTextLabel(0, _("Teams:")));
110  me.TD(me, 1, 2, e = me.sliderTeams = makeXonoticTextSlider(string_null));
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);
116  me.TR(me);
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")));
120  me.TR(me);
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")));
124  me.TR(me);
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);
142 
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;
146  e0.allowCut = 1;
147  //e0.allowWrap = 1;
148 
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);
154  me.TDempty(me, 0.5);
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;
160 
161  // The right half begins here
162 
163  me.gotoRC(me, 0.5, 3.2); me.setFirstColumn(me, me.currentColumn);
164  // the maplistbox
165  me.TD(me, 1, 3, e = makeXonoticHeaderLabel(_("Maplist")));
166  makeCallback(e, me.mapListBox, me.mapListBox.refilterCallback);
167  me.TR(me);
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);
170 
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 map list. 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;
179  e.onChangeEntity = me.mapListBox;
180 
181  me.gotoRC(me, me.rows - 3.5, me.firstColumn);
182  // the selection buttons
183  me.TDempty(me, 0.2);
184  me.TD(me, 1, 1.3, e = makeXonoticButton_T(_("Add shown"), '0 0 0',
185  _("Add the maps shown in the list to your selection")));
186  e.onClick = MapList_Add_Shown;
187  e.onClickEntity = me.mapListBox;
188  me.TD(me, 1, 1.3, e = makeXonoticButton_T(_("Remove shown"), '0 0 0',
189  _("Remove the maps shown in the list from your selection")));
190  e.onClick = MapList_Remove_Shown;
191  e.onClickEntity = me.mapListBox;
192  me.gotoRC(me, me.rows - 2.5, me.firstColumn);
193  me.TDempty(me, 0.2);
194  me.TD(me, 1, 1.3, e = makeXonoticButton_T(_("Add all"), '0 0 0',
195  _("Add every available map to your selection")));
196  e.onClick = MapList_Add_All;
197  e.onClickEntity = me.mapListBox;
198  me.TD(me, 1, 1.3, e = makeXonoticButton_T(_("Remove all"), '0 0 0',
199  _("Remove all the maps from your selection")));
200  e.onClick = MapList_Remove_All;
201  e.onClickEntity = me.mapListBox;
202 
203  // The big button at the bottom
204 
205  me.gotoRC(me, me.rows - 1, 0);
206  me.TD(me, 1, me.columns, e = makeXonoticButton(_("Start Multiplayer!"), '0 0 0'));
207  e.onClick = MapList_LoadMap;
208  e.onClickEntity = me.mapListBox;
209  me.mapListBox.startButton = e;
210 
212 }
213 
215 {
217 
218  me.mapListBox.refilter(me.mapListBox);
219 }
220 
222 {
223  me.setFocus(me, me.mapListBox);
224 }
void XonoticServerCreateTab_gameTypeChangeNotify(entity me)
void MapList_Remove_All(entity btn, entity me)
Definition: maplist.qc:263
string string_null
Definition: nil.qh:9
float MapList_StringFilterBox_keyDown(entity me, float scan, float ascii, float shift)
Definition: maplist.qc:382
#define NEW(cname,...)
Definition: oo.qh:105
void GameType_ConfigureSliders_for_CurrentGametype(entity me)
void MapList_StringFilterBox_Change(entity box, entity me)
Definition: maplist.qc:218
entity makeXonoticHeaderLabel(string theText)
Definition: textlabel.qc:10
void MapList_Remove_Shown(entity btn, entity me)
Definition: maplist.qc:239
entity() spawn
void DialogOpenButton_Click(entity button, entity tab)
entity makeXonoticTextLabel(float theAlign, string theText)
Definition: textlabel.qc:3
entity makeXonoticTextSlider_T(string theCvar, string theTooltip)
Definition: textslider.qc:3
void MapList_Add_Shown(entity btn, entity me)
Definition: maplist.qc:227
void MapList_LoadMap(entity btn, entity me)
Definition: maplist.qc:269
Gametype MapInfo_CurrentGametype()
Definition: mapinfo.qc:1150
#define ZCTX(s)
Definition: i18n.qh:68
entity makeXonoticSlider_T(float theValueMin, float theValueMax, float theValueStep, string theCvar, string theTooltip)
Definition: slider.qc:3
entity makeXonoticServerCreateTab()
entity makeXonoticGametypeList()
Definition: gametypelist.qc:7
void GameType_ConfigureSliders(entity me, string pLabel, float pMin, float pMax, float pStep, string pCvar, string tCvar, string pTooltip)
void XonoticServerCreateTab_fill(entity me)
entity makeXonoticTextSlider(string theCvar)
Definition: textslider.qc:10
void XonoticServerCreateTab_gameTypeSelectNotify(entity me)
#define ADDVALUE_MINUTES(i)
#define strfree(this)
Definition: string.qh:56
entity makeXonoticMapList()
Definition: maplist.qc:15
void MapList_Add_All(entity btn, entity me)
Definition: maplist.qc:251
entity makeXonoticInputBox_T(float doEditColorCodes, string theCvar, string theTooltip)
Definition: inputbox.qc:3