1 #include "dialog_multiplayer_join_serverinfo.qh"
2 #include <common/mapinfo.qh>
4 #include "serverlist.qh"
5 #include "playerlist.qh"
7 #include "textlabel.qh"
10 void XonoticServerInfoDialog_loadServerInfo(entity me, float i)
13 float m, pure_violations, freeslots, j, numh, maxp, numb, sflags;
14 string s, typestr, versionstr, k, v, modname;
16 // ====================================
17 // First clear and unzone the strings
18 // ====================================
19 if(me.currentServerName)
20 strunzone(me.currentServerName);
21 me.currentServerName = string_null;
23 if(me.currentServerCName)
24 strunzone(me.currentServerCName);
25 me.currentServerCName = string_null;
27 if(me.currentServerType)
28 strunzone(me.currentServerType);
29 me.currentServerType = string_null;
31 if(me.currentServerMap)
32 strunzone(me.currentServerMap);
33 me.currentServerMap = string_null;
35 if(me.currentServerPlayers)
36 strunzone(me.currentServerPlayers);
37 me.currentServerPlayers = string_null;
39 if(me.currentServerNumPlayers)
40 strunzone(me.currentServerNumPlayers);
41 me.currentServerNumPlayers = string_null;
43 if(me.currentServerNumBots)
44 strunzone(me.currentServerNumBots);
45 me.currentServerNumBots = string_null;
47 if(me.currentServerNumFreeSlots)
48 strunzone(me.currentServerNumFreeSlots);
49 me.currentServerNumFreeSlots = string_null;
51 if(me.currentServerMod)
52 strunzone(me.currentServerMod);
53 me.currentServerMod = string_null;
55 if(me.currentServerVersion)
56 strunzone(me.currentServerVersion);
57 me.currentServerVersion = string_null;
60 //if(me.currentServerEncrypt)
61 // strunzone(me.currentServerEncrypt);
62 //me.currentServerEncrypt = string_null;
63 if(me.currentServerPure)
64 strunzone(me.currentServerPure);
65 me.currentServerPure = string_null;
67 if(me.currentServerKey)
68 strunzone(me.currentServerKey);
69 me.currentServerKey = string_null;
71 if(me.currentServerID)
72 strunzone(me.currentServerID);
73 me.currentServerID = string_null;
75 // ==========================
76 // Now, fill in the strings
77 // ==========================
78 me.currentServerName = strzone(gethostcachestring(SLIST_FIELD_NAME, i));
79 me.nameLabel.setText(me.nameLabel, me.currentServerName);
81 me.currentServerCName = strzone(gethostcachestring(SLIST_FIELD_CNAME, i));
82 me.cnameLabel.setText(me.cnameLabel, me.currentServerCName);
84 pure_available = false;
87 versionstr = _("N/A");
89 s = gethostcachestring(SLIST_FIELD_QCSTATUS, i);
90 m = tokenizebyseparator(s, ":");
99 for(j = 2; j < m; ++j)
103 k = substring(argv(j), 0, 1);
104 v = substring(argv(j), 1, -1);
107 pure_available = true;
108 pure_violations = stof(v);
118 #ifdef COMPAT_NO_MOD_IS_XONOTIC
123 s = gethostcachestring(SLIST_FIELD_MOD, i);
125 modname = sprintf("%s (%s)", modname, s);
127 j = MapInfo_Type_FromString(typestr); // try and get the real name of the game type
128 if(j) { typestr = MapInfo_Type_ToText(j); } // only set it if we actually found it
130 me.currentServerType = strzone(typestr);
131 me.typeLabel.setText(me.typeLabel, me.currentServerType);
133 me.currentServerMap = strzone(gethostcachestring(SLIST_FIELD_MAP, i));
134 me.mapLabel.setText(me.mapLabel, me.currentServerMap);
136 me.currentServerPlayers = strzone(gethostcachestring(SLIST_FIELD_PLAYERS, i));
137 me.rawPlayerList.setPlayerList(me.rawPlayerList, me.currentServerPlayers);
139 numh = gethostcachenumber(SLIST_FIELD_NUMHUMANS, i);
140 maxp = gethostcachenumber(SLIST_FIELD_MAXPLAYERS, i);
141 numb = gethostcachenumber(SLIST_FIELD_NUMBOTS, i);
142 me.currentServerNumPlayers = strzone(sprintf("%d/%d", numh, maxp));
143 me.numPlayersLabel.setText(me.numPlayersLabel, me.currentServerNumPlayers);
146 me.currentServerNumBots = strzone(s);
147 me.numBotsLabel.setText(me.numBotsLabel, me.currentServerNumBots);
149 if(freeslots < 0) { freeslots = maxp - numh - numb; }
151 me.currentServerNumFreeSlots = strzone(s);
152 me.numFreeSlotsLabel.setText(me.numFreeSlotsLabel, me.currentServerNumFreeSlots);
154 me.currentServerMod = ((modname == "Xonotic") ? ZCTX(_("MOD^Default")) : modname);
155 me.currentServerMod = strzone(me.currentServerMod);
156 me.modLabel.setText(me.modLabel, me.currentServerMod);
158 me.currentServerVersion = strzone(versionstr);
159 me.versionLabel.setText(me.versionLabel, me.currentServerVersion);
161 me.currentServerPure = ((!pure_available) ? _("N/A") : (pure_violations == 0) ? _("Official") : sprintf(_("%d modified"), pure_violations));
162 me.currentServerPure = strzone(me.currentServerPure);
163 me.pureLabel.setText(me.pureLabel, me.currentServerPure);
165 s = crypto_getencryptlevel(me.currentServerCName);
168 if(cvar("crypto_aeslevel") >= 3)
169 me.currentServerEncrypt = _("N/A (auth library missing, can't connect)");
171 me.currentServerEncrypt = _("N/A (auth library missing)");
173 else switch(stof(substring(s, 0, 1)))
176 if(cvar("crypto_aeslevel") >= 3)
177 me.currentServerEncrypt = _("Not supported (can't connect)");
179 me.currentServerEncrypt = _("Not supported (won't encrypt)");
182 if(cvar("crypto_aeslevel") >= 2)
183 me.currentServerEncrypt = _("Supported (will encrypt)");
185 me.currentServerEncrypt = _("Supported (won't encrypt)");
188 if(cvar("crypto_aeslevel") >= 1)
189 me.currentServerEncrypt = _("Requested (will encrypt)");
191 me.currentServerEncrypt = _("Requested (won't encrypt)");
194 if(cvar("crypto_aeslevel") <= 0)
195 me.currentServerEncrypt = _("Required (can't connect)");
197 me.currentServerEncrypt = _("Required (will encrypt)");
200 me.encryptLabel.setText(me.encryptLabel, me.currentServerEncrypt);
202 s = crypto_getidfp(me.currentServerCName);
203 if (!s) { s = _("N/A"); }
204 me.currentServerID = strzone(s);
205 me.idLabel.setText(me.idLabel, me.currentServerID);
207 s = crypto_getkeyfp(me.currentServerCName);
208 if (!s) { s = _("N/A"); }
209 me.currentServerKey = strzone(s);
210 me.keyLabel.setText(me.keyLabel, me.currentServerKey);
213 void XonoticServerInfoDialog_fill(entity me)
217 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Hostname:")));
218 me.TD(me, 1, 4.6, e = makeXonoticTextLabel(0.5, ""));
219 e.colorL = SKINCOLOR_SERVERINFO_NAME;
223 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Address:")));
224 me.TD(me, 1, 4.6, e = makeXonoticTextLabel(0.5, ""));
225 e.colorL = SKINCOLOR_SERVERINFO_IP;
231 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Gametype:")));
232 me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, ""));
236 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Map:")));
237 me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, ""));
241 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Mod:")));
242 me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, ""));
246 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Version:")));
247 me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, ""));
251 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Settings:")));
252 me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, ""));
258 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Players:")));
259 me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, ""));
261 me.numPlayersLabel = e;
263 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Bots:")));
264 me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, ""));
268 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Free slots:")));
269 me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, ""));
271 me.numFreeSlotsLabel = e;
273 me.gotoRC(me, me.rows - 5, 0);
274 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Encryption:")));
275 me.TD(me, 1, 5.4, e = makeXonoticTextLabel(0, ""));
279 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("ID:")));
280 me.TD(me, 1, 5.4, e = makeXonoticTextLabel(0, ""));
284 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Key:")));
285 me.TD(me, 1, 5.4, e = makeXonoticTextLabel(0, ""));
289 me.gotoRC(me, 2, 2.2); me.setFirstColumn(me, me.currentColumn);
290 me.TD(me, 1, 3, e = makeXonoticTextLabel(0, _("Players:")));
292 me.TD(me, me.rows - 8, 4, e = makeXonoticPlayerList());
293 me.rawPlayerList = e;
295 me.gotoRC(me, me.rows - 1, 0);
296 me.TD(me, 1, me.columns/2, e = makeXonoticButton(_("Close"), '0 0 0'));
297 e.onClick = Dialog_Close;
298 e.onClickEntity = me;
299 //me.TD(me, 1, me.columns/3, e = makeXonoticButton("", '0 0 0')); // TODO: Add bookmark button here
300 // e.onClick = ServerList_Favorite_Click;
301 // e.onClickEntity = slist;
302 // slist.favoriteButton = e;
303 me.TD(me, 1, me.columns/2, e = makeXonoticButton(_("Join!"), '0 0 0'));
304 e.onClick = Join_Click;
305 e.onClickEntity = me;
308 void Join_Click(entity btn, entity me)
310 localcmd("connect ", me.currentServerCName, "\n");