2 CLASS(XonoticServerInfoDialog) EXTENDS(XonoticDialog)
3 METHOD(XonoticServerInfoDialog, fill, void(entity))
4 METHOD(XonoticServerInfoDialog, loadServerInfo, void(entity, float))
5 ATTRIB(XonoticServerInfoDialog, title, string, _("Server Information"))
6 ATTRIB(XonoticServerInfoDialog, color, vector, SKINCOLOR_DIALOG_SERVERINFO)
7 ATTRIB(XonoticServerInfoDialog, intendedWidth, float, 0.8)
8 ATTRIB(XonoticServerInfoDialog, rows, float, 18)
9 ATTRIB(XonoticServerInfoDialog, columns, float, 6.2)
11 ATTRIB(XonoticServerInfoDialog, currentServerName, string, string_null)
12 ATTRIB(XonoticServerInfoDialog, currentServerCName, string, string_null)
13 ATTRIB(XonoticServerInfoDialog, currentServerType, string, string_null)
14 ATTRIB(XonoticServerInfoDialog, currentServerMap, string, string_null)
15 ATTRIB(XonoticServerInfoDialog, currentServerPlayers, string, string_null)
16 ATTRIB(XonoticServerInfoDialog, currentServerNumPlayers, string, string_null)
17 ATTRIB(XonoticServerInfoDialog, currentServerNumBots, string, string_null)
18 ATTRIB(XonoticServerInfoDialog, currentServerNumFreeSlots, string, string_null)
19 ATTRIB(XonoticServerInfoDialog, currentServerMod, string, string_null)
20 ATTRIB(XonoticServerInfoDialog, currentServerVersion, string, string_null)
21 ATTRIB(XonoticServerInfoDialog, currentServerKey, string, string_null)
22 ATTRIB(XonoticServerInfoDialog, currentServerID, string, string_null)
23 ATTRIB(XonoticServerInfoDialog, currentServerEncrypt, string, string_null)
24 ATTRIB(XonoticServerInfoDialog, currentServerPure, string, string_null)
26 ATTRIB(XonoticServerInfoDialog, nameLabel, entity, NULL)
27 ATTRIB(XonoticServerInfoDialog, cnameLabel, entity, NULL)
28 ATTRIB(XonoticServerInfoDialog, typeLabel, entity, NULL)
29 ATTRIB(XonoticServerInfoDialog, mapLabel, entity, NULL)
30 ATTRIB(XonoticServerInfoDialog, rawPlayerList, entity, NULL)
31 ATTRIB(XonoticServerInfoDialog, numPlayersLabel, entity, NULL)
32 ATTRIB(XonoticServerInfoDialog, numBotsLabel, entity, NULL)
33 ATTRIB(XonoticServerInfoDialog, numFreeSlotsLabel, entity, NULL)
34 ATTRIB(XonoticServerInfoDialog, modLabel, entity, NULL)
35 ATTRIB(XonoticServerInfoDialog, versionLabel, entity, NULL)
36 ATTRIB(XonoticServerInfoDialog, keyLabel, entity, NULL)
37 ATTRIB(XonoticServerInfoDialog, idLabel, entity, NULL)
38 ATTRIB(XonoticServerInfoDialog, encryptLabel, entity, NULL)
39 ATTRIB(XonoticServerInfoDialog, canConnectLabel, entity, NULL)
40 ATTRIB(XonoticServerInfoDialog, pureLabel, entity, NULL)
41 ENDCLASS(XonoticServerInfoDialog)
43 void Join_Click(entity btn, entity me);
47 void XonoticServerInfoDialog_loadServerInfo(entity me, float i)
49 float m, pure, freeslots, j, numh, maxp, numb, sflags;
50 string s, typestr, versionstr, k, v, modname;
52 // ====================================
53 // First clear and unzone the strings
54 // ====================================
55 if(me.currentServerName)
56 strunzone(me.currentServerName);
57 me.currentServerName = string_null;
59 if(me.currentServerCName)
60 strunzone(me.currentServerCName);
61 me.currentServerCName = string_null;
63 if(me.currentServerType)
64 strunzone(me.currentServerType);
65 me.currentServerType = string_null;
67 if(me.currentServerMap)
68 strunzone(me.currentServerMap);
69 me.currentServerMap = string_null;
71 if(me.currentServerPlayers)
72 strunzone(me.currentServerPlayers);
73 me.currentServerPlayers = string_null;
75 if(me.currentServerNumPlayers)
76 strunzone(me.currentServerNumPlayers);
77 me.currentServerNumPlayers = string_null;
79 if(me.currentServerNumBots)
80 strunzone(me.currentServerNumBots);
81 me.currentServerNumBots = string_null;
83 if(me.currentServerNumFreeSlots)
84 strunzone(me.currentServerNumFreeSlots);
85 me.currentServerNumFreeSlots = string_null;
87 if(me.currentServerMod)
88 strunzone(me.currentServerMod);
89 me.currentServerMod = string_null;
91 if(me.currentServerVersion)
92 strunzone(me.currentServerVersion);
93 me.currentServerVersion = string_null;
96 //if(me.currentServerEncrypt)
97 // strunzone(me.currentServerEncrypt);
98 //me.currentServerEncrypt = string_null;
99 if(me.currentServerPure)
100 strunzone(me.currentServerPure);
101 me.currentServerPure = string_null;
103 if(me.currentServerKey)
104 strunzone(me.currentServerKey);
105 me.currentServerKey = string_null;
107 if(me.currentServerID)
108 strunzone(me.currentServerID);
109 me.currentServerID = string_null;
111 // ==========================
112 // Now, fill in the strings
113 // ==========================
114 me.currentServerName = strzone(gethostcachestring(SLIST_FIELD_NAME, i));
115 me.nameLabel.setText(me.nameLabel, me.currentServerName);
117 me.currentServerCName = strzone(gethostcachestring(SLIST_FIELD_CNAME, i));
118 me.cnameLabel.setText(me.cnameLabel, me.currentServerCName);
122 versionstr = _("N/A");
124 s = gethostcachestring(SLIST_FIELD_QCSTATUS, i);
125 m = tokenizebyseparator(s, ":");
129 versionstr = argv(1);
134 for(j = 2; j < m; ++j)
138 k = substring(argv(j), 0, 1);
139 v = substring(argv(j), 1, -1);
150 #ifdef COMPAT_NO_MOD_IS_XONOTIC
155 s = gethostcachestring(SLIST_FIELD_MOD, i);
157 modname = sprintf(_("%s (%s)"), modname, s);
159 j = MapInfo_Type_FromString(typestr); // try and get the real name of the game type
160 if(j) { typestr = MapInfo_Type_ToText(j); } // only set it if we actually found it
162 me.currentServerType = strzone(typestr);
163 me.typeLabel.setText(me.typeLabel, me.currentServerType);
165 me.currentServerMap = strzone(gethostcachestring(SLIST_FIELD_MAP, i));
166 me.mapLabel.setText(me.mapLabel, me.currentServerMap);
168 me.currentServerPlayers = strzone(gethostcachestring(SLIST_FIELD_PLAYERS, i));
169 me.rawPlayerList.setPlayerList(me.rawPlayerList, me.currentServerPlayers);
171 numh = gethostcachenumber(SLIST_FIELD_NUMHUMANS, i);
172 maxp = gethostcachenumber(SLIST_FIELD_MAXPLAYERS, i);
173 numb = gethostcachenumber(SLIST_FIELD_NUMBOTS, i);
174 me.currentServerNumPlayers = strzone(sprintf(_("%d/%d"), numh, maxp));
175 me.numPlayersLabel.setText(me.numPlayersLabel, me.currentServerNumPlayers);
178 me.currentServerNumBots = strzone(s);
179 me.numBotsLabel.setText(me.numBotsLabel, me.currentServerNumBots);
181 if(freeslots < 0) { freeslots = maxp - numh - numb; }
183 me.currentServerNumFreeSlots = strzone(s);
184 me.numFreeSlotsLabel.setText(me.numFreeSlotsLabel, me.currentServerNumFreeSlots);
186 me.currentServerMod = ((modname == "Xonotic") ? _("Default") : modname);
187 me.currentServerMod = strzone(me.currentServerMod);
188 me.modLabel.setText(me.modLabel, me.currentServerMod);
190 me.currentServerVersion = strzone(versionstr);
191 me.versionLabel.setText(me.versionLabel, me.currentServerVersion);
193 me.currentServerPure = ((pure < 0) ? "N/A" : (pure == 0) ? _("Official") : sprintf(_("%d modified"), pure));
194 me.currentServerPure = strzone(me.currentServerPure);
195 me.pureLabel.setText(me.pureLabel, me.currentServerPure);
197 s = crypto_getencryptlevel(me.currentServerCName);
200 if(cvar("crypto_aeslevel") >= 3)
201 me.currentServerEncrypt = _("N/A (auth library missing, can't connect)");
203 me.currentServerEncrypt = _("N/A (auth library missing)");
205 else switch(stof(substring(s, 0, 1)))
208 if(cvar("crypto_aeslevel") >= 3)
209 me.currentServerEncrypt = _("Not supported (can't connect)");
211 me.currentServerEncrypt = _("Not supported (won't encrypt)");
214 if(cvar("crypto_aeslevel") >= 2)
215 me.currentServerEncrypt = _("Supported (will encrypt)");
217 me.currentServerEncrypt = _("Supported (won't encrypt)");
220 if(cvar("crypto_aeslevel") >= 1)
221 me.currentServerEncrypt = _("Requested (will encrypt)");
223 me.currentServerEncrypt = _("Requested (won't encrypt)");
226 if(cvar("crypto_aeslevel") <= 0)
227 me.currentServerEncrypt = _("Required (can't connect)");
229 me.currentServerEncrypt = _("Required (will encrypt)");
232 me.encryptLabel.setText(me.encryptLabel, me.currentServerEncrypt);
234 s = crypto_getidfp(me.currentServerCName);
235 if (!s) { s = _("N/A"); }
236 me.currentServerID = strzone(s);
237 me.idLabel.setText(me.idLabel, me.currentServerID);
239 s = crypto_getkeyfp(me.currentServerCName);
240 if (!s) { s = _("N/A"); }
241 me.currentServerKey = strzone(s);
242 me.keyLabel.setText(me.keyLabel, me.currentServerKey);
245 void XonoticServerInfoDialog_fill(entity me)
249 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Hostname:")));
250 me.TD(me, 1, 4.6, e = makeXonoticTextLabel(0.5, ""));
251 e.colorL = SKINCOLOR_SERVERINFO_NAME;
255 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Address:")));
256 me.TD(me, 1, 4.6, e = makeXonoticTextLabel(0.5, ""));
257 e.colorL = SKINCOLOR_SERVERINFO_IP;
263 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Gametype:")));
264 me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, ""));
268 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Map:")));
269 me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, ""));
273 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Mod:")));
274 me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, ""));
278 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Version:")));
279 me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, ""));
283 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Settings:")));
284 me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, ""));
290 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Players:")));
291 me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, ""));
293 me.numPlayersLabel = e;
295 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Bots:")));
296 me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, ""));
300 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Free slots:")));
301 me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, ""));
303 me.numFreeSlotsLabel = e;
305 me.gotoRC(me, me.rows - 5, 0);
306 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Encryption:")));
307 me.TD(me, 1, 5.4, e = makeXonoticTextLabel(0, ""));
311 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("ID:")));
312 me.TD(me, 1, 5.4, e = makeXonoticTextLabel(0, ""));
316 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Key:")));
317 me.TD(me, 1, 5.4, e = makeXonoticTextLabel(0, ""));
321 me.gotoRC(me, 2, 2.2); me.setFirstColumn(me, me.currentColumn);
322 me.TD(me, 1, 3, e = makeXonoticTextLabel(0, _("Players:")));
324 me.TD(me, me.rows - 8, 4, e = makeXonoticPlayerList());
325 me.rawPlayerList = e;
327 me.gotoRC(me, me.rows - 1, 0);
328 me.TD(me, 1, me.columns/2, e = makeXonoticButton(_("Close"), '0 0 0'));
329 e.onClick = Dialog_Close;
330 e.onClickEntity = me;
331 //me.TD(me, 1, me.columns/3, e = makeXonoticButton("", '0 0 0')); // TODO: Add bookmark button here
332 // e.onClick = ServerList_Favorite_Click;
333 // e.onClickEntity = slist;
334 // slist.favoriteButton = e;
335 me.TD(me, 1, me.columns/2, e = makeXonoticButton(_("Join!"), '0 0 0'));
336 e.onClick = Join_Click;
337 e.onClickEntity = me;
340 void Join_Click(entity btn, entity me)
342 localcmd("connect ", me.currentServerCName, "\n");