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, 14)
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, currentServerCanConnect, 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 ENDCLASS(XonoticServerInfoDialog)
42 float SLIST_FIELD_NAME;
43 float SLIST_FIELD_CNAME;
44 float SLIST_FIELD_QCSTATUS;
45 float SLIST_FIELD_MAP;
46 float SLIST_FIELD_PLAYERS;
47 float SLIST_FIELD_NUMHUMANS;
48 float SLIST_FIELD_MAXPLAYERS;
49 float SLIST_FIELD_NUMBOTS;
50 float SLIST_FIELD_MOD;
51 float SLIST_FIELD_PING;
52 void Join_Click(entity btn, entity me);
56 void XonoticServerInfoDialog_loadServerInfo(entity me, float i)
59 string s, typestr, versionstr, numh, maxp;
61 SLIST_FIELD_NAME = gethostcacheindexforkey("name");
62 me.currentServerName = strzone(gethostcachestring(SLIST_FIELD_NAME, i));
63 me.nameLabel.setText(me.nameLabel, me.currentServerName);
65 SLIST_FIELD_CNAME = gethostcacheindexforkey("cname");
66 me.currentServerCName = strzone(gethostcachestring(SLIST_FIELD_CNAME, i));
67 me.cnameLabel.setText(me.cnameLabel, me.currentServerCName);
69 SLIST_FIELD_QCSTATUS = gethostcacheindexforkey("qcstatus");
70 s = gethostcachestring(SLIST_FIELD_QCSTATUS, i);
71 m = tokenizebyseparator(s, ":");
82 me.currentServerType = strzone(typestr);
83 me.typeLabel.setText(me.typeLabel, me.currentServerType);
85 SLIST_FIELD_MAP = gethostcacheindexforkey("map");
86 me.currentServerMap = strzone(gethostcachestring(SLIST_FIELD_MAP, i));
87 me.mapLabel.setText(me.mapLabel, me.currentServerMap);
89 SLIST_FIELD_PLAYERS = gethostcacheindexforkey("players");
90 me.currentServerPlayers = strzone(gethostcachestring(SLIST_FIELD_PLAYERS, i));
91 me.rawPlayerList.setPlayerList(me.rawPlayerList, me.currentServerPlayers);
93 SLIST_FIELD_NUMHUMANS = gethostcacheindexforkey("numhumans");
94 numh = ftos(gethostcachenumber(SLIST_FIELD_NUMHUMANS, i));
95 SLIST_FIELD_MAXPLAYERS = gethostcacheindexforkey("maxplayers");
96 maxp = ftos(gethostcachenumber(SLIST_FIELD_MAXPLAYERS, i));
97 me.currentServerNumPlayers = strzone(strcat(numh,"/",maxp));
98 me.numPlayersLabel.setText(me.numPlayersLabel, me.currentServerNumPlayers);
100 SLIST_FIELD_NUMBOTS = gethostcacheindexforkey("numbots");
101 s = ftos(gethostcachenumber(SLIST_FIELD_NUMBOTS, i));
102 me.currentServerNumBots = strzone(s);
103 me.numBotsLabel.setText(me.numBotsLabel, me.currentServerNumBots);
105 SLIST_FIELD_MOD = gethostcacheindexforkey("mod");
106 me.currentServerMod = strzone(gethostcachestring(SLIST_FIELD_MOD, i));
107 me.modLabel.setText(me.modLabel, me.currentServerMod);
109 me.currentServerVersion = strzone(versionstr);
110 me.versionLabel.setText(me.versionLabel, me.currentServerVersion);
112 SLIST_FIELD_PING = gethostcacheindexforkey("ping");
113 s = ftos(gethostcachenumber(SLIST_FIELD_PING, i));
114 me.currentServerPing = strzone(s);
115 me.pingLabel.setText(me.pingLabel, me.currentServerPing);
117 print(me.currentServerCName, "\n");
119 s = crypto_getidfp(me.currentServerCName);
122 me.currentServerID = strzone(s);
123 me.idLabel.setText(me.idLabel, me.currentServerID);
125 s = crypto_getkeyfp(me.currentServerCName);
128 me.currentServerKey = strzone(s);
129 me.keyLabel.setText(me.keyLabel, me.currentServerKey);
131 s = crypto_getencryptlevel(me.currentServerCName);
134 if(cvar("crypto_aeslevel") >= 3)
135 me.currentServerEncrypt = "N/A (can't connect)";
137 me.currentServerEncrypt = "N/A";
139 else switch(stof(substring(s, 0, 1)))
142 if(cvar("crypto_aeslevel") >= 3)
143 me.currentServerEncrypt = "not supported (can't connect)";
145 me.currentServerEncrypt = "not supported";
148 me.currentServerEncrypt = "supported";
151 me.currentServerEncrypt = "requested";
154 if(cvar("crypto_aeslevel") <= 0)
155 me.currentServerEncrypt = "required (can't connect)";
157 me.currentServerEncrypt = "required";
160 me.encryptLabel.setText(me.encryptLabel, me.currentServerEncrypt);
163 void XonoticServerInfoDialog_fill(entity me)
167 me.TD(me, 1, me.columns, e = makeXonoticTextLabel(0.5, ""));
168 e.colorL = SKINCOLOR_SERVERINFO_NAME;
172 me.TD(me, 1, me.columns, e = makeXonoticTextLabel(0.5, ""));
173 e.colorL = SKINCOLOR_SERVERINFO_IP;
178 me.TD(me, 1, 5.5, e = makeXonoticTextLabel(0, "Players:"));
180 me.TD(me, me.rows - 4, 6, e = makeXonoticPlayerList());
181 me.rawPlayerList = e;
183 me.gotoRC(me, 1, 6.25); me.setFirstColumn(me, me.currentColumn);
186 me.TD(me, 1, 1.75, e = makeXonoticTextLabel(0, "Type:"));
187 me.TD(me, 1, 4.0, e = makeXonoticTextLabel(0, ""));
191 me.TD(me, 1, 1.75, e = makeXonoticTextLabel(0, "Map:"));
192 me.TD(me, 1, 4.0, e = makeXonoticTextLabel(0, ""));
196 me.TD(me, 1, 1.75, e = makeXonoticTextLabel(0, "Players:"));
197 me.TD(me, 1, 4.0, e = makeXonoticTextLabel(0, ""));
199 me.numPlayersLabel = e;
201 me.TD(me, 1, 1.75, e = makeXonoticTextLabel(0, "Bots:"));
202 me.TD(me, 1, 4.0, e = makeXonoticTextLabel(0, ""));
206 me.TD(me, 1, 1.75, e = makeXonoticTextLabel(0, "Mod:"));
207 me.TD(me, 1, 4.0, e = makeXonoticTextLabel(0, ""));
211 me.TD(me, 1, 1.75, e = makeXonoticTextLabel(0, "Version:"));
212 me.TD(me, 1, 4.0, e = makeXonoticTextLabel(0, ""));
216 me.TD(me, 1, 1.75, e = makeXonoticTextLabel(0, "Ping:"));
217 me.TD(me, 1, 4.0, e = makeXonoticTextLabel(0, ""));
222 me.TD(me, 1, 1.75, e = makeXonoticTextLabel(0, "CA:"));
223 me.TD(me, 1, 4.0, e = makeXonoticTextLabel(0, ""));
228 me.TD(me, 1, 1.75, e = makeXonoticTextLabel(0, "Key:"));
229 me.TD(me, 1, 4.0, e = makeXonoticTextLabel(0, ""));
234 me.TD(me, 1, 1.75, e = makeXonoticTextLabel(0, "Encryption:"));
235 me.TD(me, 1, 4.0, e = makeXonoticTextLabel(0, ""));
239 me.gotoRC(me, me.rows - 1, 0);
241 me.TD(me, 1, me.columns - 6, e = makeXonoticButton("Close", '0 0 0'));
242 e.onClick = Dialog_Close;
243 e.onClickEntity = me;
244 me.TD(me, 1, me.columns - 6, e = makeXonoticButton("Join!", '0 0 0'));
245 e.onClick = Join_Click;
246 e.onClickEntity = me;
249 void Join_Click(entity btn, entity me)
251 localcmd("connect ", me.currentServerCName, "\n");