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, numh, maxp, numb, sflags;
14 string s, typestr, versionstr, k, v, modname;
16 // ====================================
17 // First clear and unzone the strings
18 // ====================================
19 strfree(me.currentServerName);
20 strfree(me.currentServerCName);
21 strfree(me.currentServerType);
22 strfree(me.currentServerMap);
23 strfree(me.currentServerPlayers);
24 strfree(me.currentServerNumPlayers);
25 strfree(me.currentServerNumBots);
26 strfree(me.currentServerNumFreeSlots);
27 strfree(me.currentServerMod);
28 strfree(me.currentServerVersion);
30 // strfree(me.currentServerEncrypt);
31 strfree(me.currentServerPure);
32 strfree(me.currentServerKey);
33 strfree(me.currentServerID);
35 // ==========================
36 // Now, fill in the strings
37 // ==========================
38 me.currentServerName = strzone(gethostcachestring(SLIST_FIELD_NAME, i));
39 me.nameLabel.setText(me.nameLabel, me.currentServerName);
41 me.currentServerCName = strzone(gethostcachestring(SLIST_FIELD_CNAME, i));
42 me.cnameLabel.setText(me.cnameLabel, me.currentServerCName);
44 pure_available = false;
47 versionstr = _("N/A");
49 s = gethostcachestring(SLIST_FIELD_QCSTATUS, i);
50 m = tokenizebyseparator(s, ":");
59 for(int j = 2; j < m; ++j)
63 k = substring(argv(j), 0, 1);
64 v = substring(argv(j), 1, -1);
67 pure_available = true;
68 pure_violations = stof(v);
78 #ifdef COMPAT_NO_MOD_IS_XONOTIC
83 s = gethostcachestring(SLIST_FIELD_MOD, i);
85 modname = sprintf("%s (%s)", modname, s);
87 Gametype j = MapInfo_Type_FromString(typestr, false); // try and get the real name of the game type
88 if(j) { typestr = MapInfo_Type_ToText(j); } // only set it if we actually found it
90 me.currentServerType = strzone(typestr);
91 me.typeLabel.setText(me.typeLabel, me.currentServerType);
93 me.currentServerMap = strzone(gethostcachestring(SLIST_FIELD_MAP, i));
94 me.mapLabel.setText(me.mapLabel, me.currentServerMap);
96 me.currentServerPlayers = strzone(gethostcachestring(SLIST_FIELD_PLAYERS, i));
97 me.rawPlayerList.setPlayerList(me.rawPlayerList, me.currentServerPlayers);
99 numh = gethostcachenumber(SLIST_FIELD_NUMHUMANS, i);
100 maxp = gethostcachenumber(SLIST_FIELD_MAXPLAYERS, i);
101 numb = gethostcachenumber(SLIST_FIELD_NUMBOTS, i);
102 me.currentServerNumPlayers = strzone(sprintf("%d/%d", numh, maxp));
103 me.numPlayersLabel.setText(me.numPlayersLabel, me.currentServerNumPlayers);
106 me.currentServerNumBots = strzone(s);
107 me.numBotsLabel.setText(me.numBotsLabel, me.currentServerNumBots);
109 if(freeslots < 0) { freeslots = maxp - numh - numb; }
111 me.currentServerNumFreeSlots = strzone(s);
112 me.numFreeSlotsLabel.setText(me.numFreeSlotsLabel, me.currentServerNumFreeSlots);
114 me.currentServerMod = ((modname == "Xonotic") ? ZCTX(_("MOD^Default")) : modname);
115 me.currentServerMod = strzone(me.currentServerMod);
116 me.modLabel.setText(me.modLabel, me.currentServerMod);
118 me.currentServerVersion = strzone(versionstr);
119 me.versionLabel.setText(me.versionLabel, me.currentServerVersion);
121 me.currentServerPure = ((!pure_available) ? _("N/A") : (pure_violations == 0) ? _("Official") : sprintf(_("%d modified"), pure_violations));
122 me.currentServerPure = strzone(me.currentServerPure);
123 me.pureLabel.setText(me.pureLabel, me.currentServerPure);
125 s = crypto_getencryptlevel(me.currentServerCName);
128 if(cvar("crypto_aeslevel") >= 3)
129 me.currentServerEncrypt = _("N/A (auth library missing, can't connect)");
131 me.currentServerEncrypt = _("N/A (auth library missing)");
133 else switch(stof(substring(s, 0, 1)))
136 if(cvar("crypto_aeslevel") >= 3)
137 me.currentServerEncrypt = _("Not supported (can't connect)");
139 me.currentServerEncrypt = _("Not supported (won't encrypt)");
142 if(cvar("crypto_aeslevel") >= 2)
143 me.currentServerEncrypt = _("Supported (will encrypt)");
145 me.currentServerEncrypt = _("Supported (won't encrypt)");
148 if(cvar("crypto_aeslevel") >= 1)
149 me.currentServerEncrypt = _("Requested (will encrypt)");
151 me.currentServerEncrypt = _("Requested (won't encrypt)");
154 if(cvar("crypto_aeslevel") <= 0)
155 me.currentServerEncrypt = _("Required (can't connect)");
157 me.currentServerEncrypt = _("Required (will encrypt)");
160 me.encryptLabel.setText(me.encryptLabel, me.currentServerEncrypt);
161 setZonedTooltip(me.encryptLabel, _("Use the `crypto_aeslevel` cvar to change your preferences"), string_null);
163 s = crypto_getidfp(me.currentServerCName);
164 if (!s) { s = _("N/A"); }
165 me.currentServerID = strzone(s);
166 me.idLabel.setText(me.idLabel, me.currentServerID);
168 s = crypto_getkeyfp(me.currentServerCName);
169 if (!s) { s = _("N/A"); }
170 me.currentServerKey = strzone(s);
171 me.keyLabel.setText(me.keyLabel, me.currentServerKey);
174 void XonoticServerInfoDialog_fill(entity me)
178 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Hostname:")));
179 me.TD(me, 1, 4.6, e = makeXonoticTextLabel(0.5, ""));
180 e.colorL = SKINCOLOR_SERVERINFO_NAME;
184 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Address:")));
185 me.TD(me, 1, 4.6, e = makeXonoticTextLabel(0.5, ""));
186 e.colorL = SKINCOLOR_SERVERINFO_IP;
192 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Gametype:")));
193 me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, ""));
197 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Map:")));
198 me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, ""));
202 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Mod:")));
203 me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, ""));
207 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Version:")));
208 me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, ""));
212 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Settings:")));
213 me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, ""));
219 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Players:")));
220 me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, ""));
222 me.numPlayersLabel = e;
224 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Bots:")));
225 me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, ""));
229 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Free slots:")));
230 me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, ""));
232 me.numFreeSlotsLabel = e;
234 me.gotoRC(me, me.rows - 5, 0);
235 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Encryption:")));
236 me.TD(me, 1, 5.4, e = makeXonoticTextLabel(0, ""));
240 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("ID:")));
241 me.TD(me, 1, 5.4, e = makeXonoticTextLabel(0, ""));
245 me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Key:")));
246 me.TD(me, 1, 5.4, e = makeXonoticTextLabel(0, ""));
250 me.gotoRC(me, 2, 2.2); me.setFirstColumn(me, me.currentColumn);
251 me.TD(me, 1, 3, e = makeXonoticTextLabel(0, _("Players:")));
253 me.TD(me, me.rows - 8, 4, e = makeXonoticPlayerList());
254 me.rawPlayerList = e;
256 me.gotoRC(me, me.rows - 1, 0);
257 me.TD(me, 1, me.columns/2, e = makeXonoticButton(_("Close"), '0 0 0'));
258 e.onClick = Dialog_Close;
259 e.onClickEntity = me;
260 //me.TD(me, 1, me.columns/3, e = makeXonoticButton("", '0 0 0')); // TODO: Add bookmark button here
261 // e.onClick = ServerList_Favorite_Click;
262 // e.onClickEntity = slist;
263 // slist.favoriteButton = e;
264 me.TD(me, 1, me.columns/2, e = makeXonoticButton(_("Join!"), '0 0 0'));
265 e.onClick = Join_Click;
266 e.onClickEntity = me;
269 void Join_Click(entity btn, entity me)
271 localcmd("connect ", me.currentServerCName, "\n");