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.68)
8 ATTRIB(XonoticServerInfoDialog, rows, float, 15)
9 ATTRIB(XonoticServerInfoDialog, columns, float, 12)
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, currentServerMod, string, string_null)
19 ATTRIB(XonoticServerInfoDialog, currentServerVersion, string, string_null)
20 ATTRIB(XonoticServerInfoDialog, currentServerPing, 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, modLabel, entity, NULL)
34 ATTRIB(XonoticServerInfoDialog, versionLabel, entity, NULL)
35 ATTRIB(XonoticServerInfoDialog, pingLabel, 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 float SLIST_FIELD_NAME;
44 float SLIST_FIELD_CNAME;
45 float SLIST_FIELD_QCSTATUS;
46 float SLIST_FIELD_MAP;
47 float SLIST_FIELD_PLAYERS;
48 float SLIST_FIELD_NUMHUMANS;
49 float SLIST_FIELD_MAXPLAYERS;
50 float SLIST_FIELD_NUMBOTS;
51 float SLIST_FIELD_MOD;
52 float SLIST_FIELD_PING;
53 void Join_Click(entity btn, entity me);
57 void XonoticServerInfoDialog_loadServerInfo(entity me, float i)
59 float m, pure, j, numh, maxp;
60 string s, typestr, versionstr, k, v;
62 if(me.currentServerName)
63 strunzone(me.currentServerName);
64 me.currentServerName = string_null;
65 if(me.currentServerCName)
66 strunzone(me.currentServerCName);
67 me.currentServerCName = string_null;
68 if(me.currentServerType)
69 strunzone(me.currentServerType);
70 me.currentServerType = string_null;
71 if(me.currentServerMap)
72 strunzone(me.currentServerMap);
73 me.currentServerMap = string_null;
74 if(me.currentServerPlayers)
75 strunzone(me.currentServerPlayers);
76 me.currentServerPlayers = string_null;
77 if(me.currentServerNumPlayers)
78 strunzone(me.currentServerNumPlayers);
79 me.currentServerNumPlayers = string_null;
80 if(me.currentServerNumBots)
81 strunzone(me.currentServerNumBots);
82 me.currentServerNumBots = string_null;
83 if(me.currentServerMod)
84 strunzone(me.currentServerMod);
85 me.currentServerMod = string_null;
86 if(me.currentServerVersion)
87 strunzone(me.currentServerVersion);
88 me.currentServerVersion = string_null;
89 if(me.currentServerPing)
90 strunzone(me.currentServerPing);
91 me.currentServerPing = string_null;
92 if(me.currentServerKey)
93 strunzone(me.currentServerKey);
94 me.currentServerKey = string_null;
95 if(me.currentServerID)
96 strunzone(me.currentServerID);
97 me.currentServerID = string_null;
99 //if(me.currentServerEncrypt)
100 // strunzone(me.currentServerEncrypt);
101 //me.currentServerEncrypt = string_null;
102 if(me.currentServerPure)
103 strunzone(me.currentServerPure);
104 me.currentServerPure = string_null;
106 SLIST_FIELD_NAME = gethostcacheindexforkey("name");
107 me.currentServerName = strzone(gethostcachestring(SLIST_FIELD_NAME, i));
108 me.nameLabel.setText(me.nameLabel, me.currentServerName);
110 SLIST_FIELD_CNAME = gethostcacheindexforkey("cname");
111 me.currentServerCName = strzone(gethostcachestring(SLIST_FIELD_CNAME, i));
112 me.cnameLabel.setText(me.cnameLabel, me.currentServerCName);
116 versionstr = _("N/A");
118 SLIST_FIELD_QCSTATUS = gethostcacheindexforkey("qcstatus");
119 s = gethostcachestring(SLIST_FIELD_QCSTATUS, i);
120 m = tokenizebyseparator(s, ":");
124 versionstr = argv(1);
126 for(j = 2; j < m; ++j)
130 k = substring(argv(j), 0, 1);
131 v = substring(argv(j), 1, -1);
136 me.currentServerType = strzone(typestr);
137 me.typeLabel.setText(me.typeLabel, me.currentServerType);
139 SLIST_FIELD_MAP = gethostcacheindexforkey("map");
140 me.currentServerMap = strzone(gethostcachestring(SLIST_FIELD_MAP, i));
141 me.mapLabel.setText(me.mapLabel, me.currentServerMap);
143 SLIST_FIELD_PLAYERS = gethostcacheindexforkey("players");
144 me.currentServerPlayers = strzone(gethostcachestring(SLIST_FIELD_PLAYERS, i));
145 me.rawPlayerList.setPlayerList(me.rawPlayerList, me.currentServerPlayers);
147 SLIST_FIELD_NUMHUMANS = gethostcacheindexforkey("numhumans");
148 numh = gethostcachenumber(SLIST_FIELD_NUMHUMANS, i);
149 SLIST_FIELD_MAXPLAYERS = gethostcacheindexforkey("maxplayers");
150 maxp = gethostcachenumber(SLIST_FIELD_MAXPLAYERS, i);
151 me.currentServerNumPlayers = strzone(sprintf(_("%d/%d"), numh, maxp));
152 me.numPlayersLabel.setText(me.numPlayersLabel, me.currentServerNumPlayers);
154 SLIST_FIELD_NUMBOTS = gethostcacheindexforkey("numbots");
155 s = ftos(gethostcachenumber(SLIST_FIELD_NUMBOTS, i));
156 me.currentServerNumBots = strzone(s);
157 me.numBotsLabel.setText(me.numBotsLabel, me.currentServerNumBots);
159 SLIST_FIELD_MOD = gethostcacheindexforkey("mod");
160 me.currentServerMod = strzone(gethostcachestring(SLIST_FIELD_MOD, i));
161 me.modLabel.setText(me.modLabel, me.currentServerMod);
163 me.currentServerVersion = strzone(versionstr);
164 me.versionLabel.setText(me.versionLabel, me.currentServerVersion);
166 me.currentServerPure = ((pure < 0) ? "N/A" : (pure == 0) ? _("Official settings") : sprintf(_("%d modified settings"), pure));
167 me.currentServerPure = strzone(me.currentServerPure);
168 me.pureLabel.setText(me.pureLabel, me.currentServerPure);
170 SLIST_FIELD_PING = gethostcacheindexforkey("ping");
171 s = ftos(gethostcachenumber(SLIST_FIELD_PING, i));
172 me.currentServerPing = strzone(s);
173 me.pingLabel.setText(me.pingLabel, me.currentServerPing);
175 s = crypto_getidfp(me.currentServerCName);
178 me.currentServerID = strzone(s);
179 me.idLabel.setText(me.idLabel, me.currentServerID);
181 s = crypto_getkeyfp(me.currentServerCName);
184 me.currentServerKey = strzone(s);
185 me.keyLabel.setText(me.keyLabel, me.currentServerKey);
187 s = crypto_getencryptlevel(me.currentServerCName);
190 if(cvar("crypto_aeslevel") >= 3)
191 me.currentServerEncrypt = _("N/A (can't connect)");
193 me.currentServerEncrypt = _("N/A");
195 else switch(stof(substring(s, 0, 1)))
198 if(cvar("crypto_aeslevel") >= 3)
199 me.currentServerEncrypt = _("not supported (can't connect)");
201 me.currentServerEncrypt = _("not supported (won't encrypt)");
204 if(cvar("crypto_aeslevel") >= 2)
205 me.currentServerEncrypt = _("supported (will encrypt)");
207 me.currentServerEncrypt = _("supported (won't encrypt)");
210 if(cvar("crypto_aeslevel") >= 1)
211 me.currentServerEncrypt = _("requested (will encrypt)");
213 me.currentServerEncrypt = _("requested (won't encrypt)");
216 if(cvar("crypto_aeslevel") <= 0)
217 me.currentServerEncrypt = _("required (can't connect)");
219 me.currentServerEncrypt = _("required (will encrypt)");
222 me.encryptLabel.setText(me.encryptLabel, me.currentServerEncrypt);
225 void XonoticServerInfoDialog_fill(entity me)
229 me.TD(me, 1, me.columns, e = makeXonoticTextLabel(0.5, ""));
230 e.colorL = SKINCOLOR_SERVERINFO_NAME;
234 me.TD(me, 1, me.columns, e = makeXonoticTextLabel(0.5, ""));
235 e.colorL = SKINCOLOR_SERVERINFO_IP;
240 me.TD(me, 1, 5.5, e = makeXonoticTextLabel(0, _("Players:")));
242 me.TD(me, me.rows - 4, 6, e = makeXonoticPlayerList());
243 me.rawPlayerList = e;
245 me.gotoRC(me, 1, 6.25); me.setFirstColumn(me, me.currentColumn);
248 me.TD(me, 1, 1.75, e = makeXonoticTextLabel(0, _("Type:")));
249 me.TD(me, 1, 4.0, e = makeXonoticTextLabel(0, ""));
253 me.TD(me, 1, 1.75, e = makeXonoticTextLabel(0, _("Map:")));
254 me.TD(me, 1, 4.0, e = makeXonoticTextLabel(0, ""));
258 me.TD(me, 1, 1.75, e = makeXonoticTextLabel(0, _("Gameplay:")));
259 me.TD(me, 1, 4.0, e = makeXonoticTextLabel(0, ""));
263 me.TD(me, 1, 1.75, e = makeXonoticTextLabel(0, _("Players:")));
264 me.TD(me, 1, 4.0, e = makeXonoticTextLabel(0, ""));
266 me.numPlayersLabel = e;
268 me.TD(me, 1, 1.75, e = makeXonoticTextLabel(0, _("Bots:")));
269 me.TD(me, 1, 4.0, e = makeXonoticTextLabel(0, ""));
273 me.TD(me, 1, 1.75, e = makeXonoticTextLabel(0, _("Mod:")));
274 me.TD(me, 1, 4.0, e = makeXonoticTextLabel(0, ""));
278 me.TD(me, 1, 1.75, e = makeXonoticTextLabel(0, _("Version:")));
279 me.TD(me, 1, 4.0, e = makeXonoticTextLabel(0, ""));
283 me.TD(me, 1, 1.75, e = makeXonoticTextLabel(0, _("Ping:")));
284 me.TD(me, 1, 4.0, e = makeXonoticTextLabel(0, ""));
289 me.TD(me, 1, 1.75, e = makeXonoticTextLabel(0, _("CA:")));
290 me.TD(me, 1, 4.0, e = makeXonoticTextLabel(0, ""));
295 me.TD(me, 1, 1.75, e = makeXonoticTextLabel(0, _("Key:")));
296 me.TD(me, 1, 4.0, e = makeXonoticTextLabel(0, ""));
301 me.TD(me, 1, 1.75, e = makeXonoticTextLabel(0, _("Encryption:")));
302 me.TD(me, 1, 4.0, e = makeXonoticTextLabel(0, ""));
306 me.gotoRC(me, me.rows - 1, 0);
308 me.TD(me, 1, me.columns - 6, e = makeXonoticButton(_("Close"), '0 0 0'));
309 e.onClick = Dialog_Close;
310 e.onClickEntity = me;
311 me.TD(me, 1, me.columns - 6, e = makeXonoticButton(_("Join!"), '0 0 0'));
312 e.onClick = Join_Click;
313 e.onClickEntity = me;
316 void Join_Click(entity btn, entity me)
318 localcmd("connect ", me.currentServerCName, "\n");