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 if(modname == "Xonotic")
160 j = MapInfo_Type_FromString(typestr); // try and get the real name of the game type
161 if(j) { typestr = MapInfo_Type_ToText(j); } // only set it if we actually found it
163 me.currentServerType = strzone(typestr);
164 me.typeLabel.setText(me.typeLabel, me.currentServerType);
166 me.currentServerMap = strzone(gethostcachestring(SLIST_FIELD_MAP, i));
167 me.mapLabel.setText(me.mapLabel, me.currentServerMap);
169 me.currentServerPlayers = strzone(gethostcachestring(SLIST_FIELD_PLAYERS, i));
170 me.rawPlayerList.setPlayerList(me.rawPlayerList, me.currentServerPlayers);
172 numh = gethostcachenumber(SLIST_FIELD_NUMHUMANS, i);
173 maxp = gethostcachenumber(SLIST_FIELD_MAXPLAYERS, i);
174 numb = gethostcachenumber(SLIST_FIELD_NUMBOTS, i);
175 me.currentServerNumPlayers = strzone(sprintf(_("%d/%d"), numh, maxp));
176 me.numPlayersLabel.setText(me.numPlayersLabel, me.currentServerNumPlayers);
179 me.currentServerNumBots = strzone(s);
180 me.numBotsLabel.setText(me.numBotsLabel, me.currentServerNumBots);
182 if(freeslots < 0) { freeslots = maxp - numh - numb; }
184 me.currentServerNumFreeSlots = strzone(s);
185 me.numFreeSlotsLabel.setText(me.numFreeSlotsLabel, me.currentServerNumFreeSlots);
187 me.currentServerMod = ((modname == "Xonotic") ? _("Default") : modname);
188 me.currentServerMod = strzone(modname);
189 me.modLabel.setText(me.modLabel, me.currentServerMod);
191 me.currentServerVersion = strzone(versionstr);
192 me.versionLabel.setText(me.versionLabel, me.currentServerVersion);
194 me.currentServerPure = ((pure < 0) ? "N/A" : (pure == 0) ? _("Official") : sprintf(_("%d modified"), pure));
195 me.currentServerPure = strzone(me.currentServerPure);
196 me.pureLabel.setText(me.pureLabel, me.currentServerPure);
198 s = crypto_getencryptlevel(me.currentServerCName);
201 if(cvar("crypto_aeslevel") >= 3)
202 me.currentServerEncrypt = _("N/A (auth library missing, can't connect)");
204 me.currentServerEncrypt = _("N/A (auth library missing)");
206 else switch(stof(substring(s, 0, 1)))
209 if(cvar("crypto_aeslevel") >= 3)
210 me.currentServerEncrypt = _("Not supported (can't connect)");
212 me.currentServerEncrypt = _("Not supported (won't encrypt)");
215 if(cvar("crypto_aeslevel") >= 2)
216 me.currentServerEncrypt = _("Supported (will encrypt)");
218 me.currentServerEncrypt = _("Supported (won't encrypt)");
221 if(cvar("crypto_aeslevel") >= 1)
222 me.currentServerEncrypt = _("Requested (will encrypt)");
224 me.currentServerEncrypt = _("Requested (won't encrypt)");
227 if(cvar("crypto_aeslevel") <= 0)
228 me.currentServerEncrypt = _("Required (can't connect)");
230 me.currentServerEncrypt = _("Required (will encrypt)");
233 me.encryptLabel.setText(me.encryptLabel, me.currentServerEncrypt);
235 s = crypto_getidfp(me.currentServerCName);
236 if not(s) { s = _("N/A"); }
237 me.currentServerID = strzone(s);
238 me.idLabel.setText(me.idLabel, me.currentServerID);
240 s = crypto_getkeyfp(me.currentServerCName);
241 if not(s) { s = _("N/A"); }
242 me.currentServerKey = strzone(s);
243 me.keyLabel.setText(me.keyLabel, me.currentServerKey);
246 void XonoticServerInfoDialog_fill(entity me)
250 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Hostname:")));
251 me.TD(me, 1, 4.6, e = makeXonoticTextLabel(0.5, ""));
252 e.colorL = SKINCOLOR_SERVERINFO_NAME;
256 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Address:")));
257 me.TD(me, 1, 4.6, e = makeXonoticTextLabel(0.5, ""));
258 e.colorL = SKINCOLOR_SERVERINFO_IP;
264 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Gametype:")));
265 me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, ""));
269 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Map:")));
270 me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, ""));
274 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Mod:")));
275 me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, ""));
279 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Version:")));
280 me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, ""));
284 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Settings:")));
285 me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, ""));
291 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Players:")));
292 me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, ""));
294 me.numPlayersLabel = e;
296 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Bots:")));
297 me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, ""));
301 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Free slots:")));
302 me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, ""));
304 me.numFreeSlotsLabel = e;
306 me.gotoRC(me, me.rows - 5, 0);
307 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Encryption:")));
308 me.TD(me, 1, 5.4, e = makeXonoticTextLabel(0, ""));
312 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("ID:")));
313 me.TD(me, 1, 5.4, e = makeXonoticTextLabel(0, ""));
317 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Key:")));
318 me.TD(me, 1, 5.4, e = makeXonoticTextLabel(0, ""));
322 me.gotoRC(me, 2, 2.2); me.setFirstColumn(me, me.currentColumn);
323 me.TD(me, 1, 3, e = makeXonoticTextLabel(0, _("Players:")));
325 me.TD(me, me.rows - 8, 4, e = makeXonoticPlayerList());
326 me.rawPlayerList = e;
328 me.gotoRC(me, me.rows - 1, 0);
329 me.TD(me, 1, me.columns/2, e = makeXonoticButton(_("Close"), '0 0 0'));
330 e.onClick = Dialog_Close;
331 e.onClickEntity = me;
332 //me.TD(me, 1, me.columns/3, e = makeXonoticButton("", '0 0 0')); // TODO: Add bookmark button here
333 // e.onClick = ServerList_Favorite_Click;
334 // e.onClickEntity = slist;
335 // slist.favoriteButton = e;
336 me.TD(me, 1, me.columns/2, e = makeXonoticButton(_("Join!"), '0 0 0'));
337 e.onClick = Join_Click;
338 e.onClickEntity = me;
341 void Join_Click(entity btn, entity me)
343 localcmd("connect ", me.currentServerCName, "\n");