1 #include "dialog_multiplayer_join_serverinfo.qh"
2 #include <common/mapinfo.qh>
4 #include "tabcontroller.qh"
5 #include "serverlist.qh"
6 #include "playerlist.qh"
8 #include "textlabel.qh"
10 #include "dialog_multiplayer_join_serverinfotab.qh"
11 #include "dialog_multiplayer_join_termsofservice.qh"
14 void XonoticServerInfoDialog_loadServerInfo(entity me, float i)
17 float m, pure_violations, freeslots, numh, maxp, numb, sflags;
18 string s, typestr, versionstr, k, v, modname;
20 // ====================================
21 // First clear and unzone the strings
22 // ====================================
23 strfree(me.currentServerName);
24 strfree(me.currentServerCName);
25 strfree(me.currentServerType);
26 strfree(me.currentServerMap);
27 strfree(me.currentServerPlayers);
28 strfree(me.currentServerNumPlayers);
29 strfree(me.currentServerNumBots);
30 strfree(me.currentServerNumFreeSlots);
31 strfree(me.currentServerMod);
32 strfree(me.currentServerVersion);
34 // strfree(me.currentServerEncrypt);
35 strfree(me.currentServerPure);
36 strfree(me.currentServerKey);
37 strfree(me.currentServerID);
39 // ==========================
40 // Now, fill in the strings
41 // ==========================
42 me.currentServerName = strzone(gethostcachestring(SLIST_FIELD_NAME, i));
43 me.infoTab.nameLabel.setText(me.infoTab.nameLabel, me.currentServerName);
45 me.currentServerCName = strzone(gethostcachestring(SLIST_FIELD_CNAME, i));
46 me.infoTab.cnameLabel.setText(me.infoTab.cnameLabel, me.currentServerCName);
48 pure_available = false;
51 versionstr = _("N/A");
53 s = gethostcachestring(SLIST_FIELD_QCSTATUS, i);
54 m = tokenizebyseparator(s, ":");
63 bool ToSSpecified = false;
64 for(int j = 2; j < m; ++j)
68 k = substring(argv(j), 0, 1);
69 v = substring(argv(j), 1, -1);
72 pure_available = true;
73 pure_violations = stof(v);
90 string downloadurl = v;
91 if (downloadurl == "INVALID")
93 me.ToSTab.textBox.setText(me.ToSTab.textBox, _("No Terms of Service specified"));
97 downloadurl = strreplace("|", ":", downloadurl);
98 me.ToSTab.loadToS(me.ToSTab, downloadurl);
105 me.ToSTab.textBox.setText(me.ToSTab.textBox, _("No Terms of Service specified"));
108 #ifdef COMPAT_NO_MOD_IS_XONOTIC
113 s = gethostcachestring(SLIST_FIELD_MOD, i);
115 modname = sprintf("%s (%s)", modname, s);
117 Gametype j = MapInfo_Type_FromString(typestr, false, false); // try and get the real name of the game type
118 if(j) { typestr = MapInfo_Type_ToText(j); } // only set it if we actually found it
120 me.currentServerType = strzone(typestr);
121 me.infoTab.typeLabel.setText(me.infoTab.typeLabel, me.currentServerType);
123 me.currentServerMap = strzone(gethostcachestring(SLIST_FIELD_MAP, i));
124 me.infoTab.mapLabel.setText(me.infoTab.mapLabel, me.currentServerMap);
126 me.currentServerPlayers = strzone(gethostcachestring(SLIST_FIELD_PLAYERS, i));
127 me.infoTab.rawPlayerList.setPlayerList(me.infoTab.rawPlayerList, me.currentServerPlayers);
129 numh = gethostcachenumber(SLIST_FIELD_NUMHUMANS, i);
130 maxp = gethostcachenumber(SLIST_FIELD_MAXPLAYERS, i);
131 numb = gethostcachenumber(SLIST_FIELD_NUMBOTS, i);
132 me.currentServerNumPlayers = strzone(sprintf("%d/%d", numh, maxp));
133 me.infoTab.numPlayersLabel.setText(me.infoTab.numPlayersLabel, me.currentServerNumPlayers);
136 me.currentServerNumBots = strzone(s);
137 me.infoTab.numBotsLabel.setText(me.infoTab.numBotsLabel, me.currentServerNumBots);
139 if(freeslots < 0) { freeslots = maxp - numh - numb; }
141 me.currentServerNumFreeSlots = strzone(s);
142 me.infoTab.numFreeSlotsLabel.setText(me.infoTab.numFreeSlotsLabel, me.currentServerNumFreeSlots);
144 me.currentServerMod = ((modname == "Xonotic") ? ZCTX(_("MOD^Default")) : modname);
145 me.currentServerMod = strzone(me.currentServerMod);
146 me.infoTab.modLabel.setText(me.infoTab.modLabel, me.currentServerMod);
148 me.currentServerVersion = strzone(versionstr);
149 me.infoTab.versionLabel.setText(me.infoTab.versionLabel, me.currentServerVersion);
151 me.currentServerPure = ((!pure_available) ? _("N/A") : (pure_violations == 0) ? _("Official") : sprintf(_("%d modified"), pure_violations));
152 me.currentServerPure = strzone(me.currentServerPure);
153 me.infoTab.pureLabel.setText(me.infoTab.pureLabel, me.currentServerPure);
155 s = crypto_getencryptlevel(me.currentServerCName);
158 if(cvar("crypto_aeslevel") >= 3)
159 me.currentServerEncrypt = _("N/A (auth library missing, can't connect)");
161 me.currentServerEncrypt = _("N/A (auth library missing)");
163 else switch(stof(substring(s, 0, 1)))
166 if(cvar("crypto_aeslevel") >= 3)
167 me.currentServerEncrypt = _("Not supported (can't connect)");
169 me.currentServerEncrypt = _("Not supported (won't encrypt)");
172 if(cvar("crypto_aeslevel") >= 2)
173 me.currentServerEncrypt = _("Supported (will encrypt)");
175 me.currentServerEncrypt = _("Supported (won't encrypt)");
178 if(cvar("crypto_aeslevel") >= 1)
179 me.currentServerEncrypt = _("Requested (will encrypt)");
181 me.currentServerEncrypt = _("Requested (won't encrypt)");
184 if(cvar("crypto_aeslevel") <= 0)
185 me.currentServerEncrypt = _("Required (can't connect)");
187 me.currentServerEncrypt = _("Required (will encrypt)");
190 me.infoTab.encryptLabel.setText(me.infoTab.encryptLabel, me.currentServerEncrypt);
191 setZonedTooltip(me.infoTab.encryptLabel, _("Use the `crypto_aeslevel` cvar to change your preferences"), string_null);
193 s = crypto_getidfp(me.currentServerCName);
194 if (!s) { s = _("N/A"); }
195 me.currentServerID = strzone(s);
196 me.infoTab.idLabel.setText(me.infoTab.idLabel, me.currentServerID);
198 s = crypto_getkeyfp(me.currentServerCName);
199 if (!s) { s = _("N/A"); }
200 me.currentServerKey = strzone(s);
201 me.infoTab.keyLabel.setText(me.infoTab.keyLabel, me.currentServerKey);
203 me.currentServerStatsStatus = ((sflags >= 0 && (sflags & SERVERFLAG_PLAYERSTATS)) ? ((sflags & SERVERFLAG_PLAYERSTATS_CUSTOM) ? _("custom stats server") : _("stats enabled")) : _("stats disabled"));
204 me.currentServerStatsStatus = strzone(me.currentServerStatsStatus);
205 me.infoTab.statsLabel.setText(me.infoTab.statsLabel, me.currentServerStatsStatus);
208 void XonoticServerInfoDialog_fill(entity me)
211 mc = makeXonoticTabController(me.rows - 2);
213 me.TD(me, 1, 1, e = mc.makeTabButton(mc, _("Status"), me.infoTab = makeXonoticServerInfoTab()));
214 me.TD(me, 1, 1, e = mc.makeTabButton(mc, _("Terms of Service"), me.ToSTab = makeXonoticServerToSTab()));
217 me.TD(me, me.rows - 2, me.columns, mc);
219 me.gotoRC(me, me.rows - 1, 0);
220 me.TD(me, 1, me.columns/2, e = makeXonoticButton(_("Close"), '0 0 0'));
221 e.onClick = Dialog_Close;
222 e.onClickEntity = me;
223 //me.TD(me, 1, me.columns/3, e = makeXonoticButton("", '0 0 0')); // TODO: Add bookmark button here
224 // e.onClick = ServerList_Favorite_Click;
225 // e.onClickEntity = slist;
226 // slist.favoriteButton = e;
227 me.TD(me, 1, me.columns/2, e = makeXonoticButton(_("Join!"), '0 0 0'));
228 e.onClick = Join_Click;
229 e.onClickEntity = me;
232 void Join_Click(entity btn, entity me)
234 localcmd("connect ", me.currentServerCName, "\n");