X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fmenu%2Fxonotic%2Fserverlist.c;h=ce9676f3781dbafaf81d8f267917d4ebcbfdbbfa;hb=464d479e139258446caa20521eb0d42ae322cc73;hp=d721c2555e2dbae45621da79f75b5d4601c88978;hpb=0218563b4059e788652d927ef6e8ce738c055ba1;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/menu/xonotic/serverlist.c b/qcsrc/menu/xonotic/serverlist.c index d721c2555..ce9676f37 100644 --- a/qcsrc/menu/xonotic/serverlist.c +++ b/qcsrc/menu/xonotic/serverlist.c @@ -10,6 +10,8 @@ CLASS(XonoticServerList) EXTENDS(XonoticListBox) ATTRIB(XonoticServerList, realFontSize, vector, '0 0 0') ATTRIB(XonoticServerList, realUpperMargin, float, 0) + ATTRIB(XonoticServerList, columnIconsOrigin, float, 0) + ATTRIB(XonoticServerList, columnIconsSize, float, 0) ATTRIB(XonoticServerList, columnPingOrigin, float, 0) ATTRIB(XonoticServerList, columnPingSize, float, 0) ATTRIB(XonoticServerList, columnNameOrigin, float, 0) @@ -95,41 +97,76 @@ void ServerList_UpdateFieldIDs() float IsFavorite(string srv) { + string p; float i, n; + if(srv == "") + return FALSE; srv = netaddress_resolve(srv, 26000); + p = crypto_getidfp(srv); n = tokenize_console(cvar_string("net_slist_favorites")); for(i = 0; i < n; ++i) - if(srv == netaddress_resolve(argv(i), 26000)) - return TRUE; + { + if(substring(argv(i), 0, 1) != "[" && strlen(argv(i)) == 44 && strstrofs(argv(i), ".", 0) < 0) + { + if(p) + if(argv(i) == p) + return TRUE; + } + else + { + if(srv == netaddress_resolve(argv(i), 26000)) + return TRUE; + } + } return FALSE; } void ToggleFavorite(string srv) { - string s, s0, s1, s2, srv_resolved; - float i, n; + string s, s0, s1, s2, srv_resolved, p; + float i, n, f; srv_resolved = netaddress_resolve(srv, 26000); + p = crypto_getidfp(srv_resolved); s = cvar_string("net_slist_favorites"); n = tokenize_console(s); + f = 0; for(i = 0; i < n; ++i) - if(srv_resolved == netaddress_resolve(argv(i), 26000)) + { + if(substring(argv(i), 0, 1) != "[" && strlen(argv(i)) == 44 && strstrofs(argv(i), ".", 0) < 0) { - s0 = s1 = s2 = ""; - if(i > 0) - s0 = substring(s, 0, argv_end_index(i - 1)); - if(i < n-1) - s2 = substring(s, argv_start_index(i + 1), -1); - if(s0 != "" && s2 != "") - s1 = " "; - print("s0 = >>", s0, "<<\ns1 = >>", s1, "<<\ns2 = >>", s2, "<<\n"); - cvar_set("net_slist_favorites", strcat(s0, s1, s2)); - return; + if(p) + if(argv(i) != p) + continue; } + else + { + if(srv_resolved != netaddress_resolve(argv(i), 26000)) + continue; + } + s0 = s1 = s2 = ""; + if(i > 0) + s0 = substring(s, 0, argv_end_index(i - 1)); + if(i < n-1) + s2 = substring(s, argv_start_index(i + 1), -1); + if(s0 != "" && s2 != "") + s1 = " "; + cvar_set("net_slist_favorites", strcat(s0, s1, s2)); + s = cvar_string("net_slist_favorites"); + n = tokenize_console(s); + f = 1; + --i; + } - s1 = ""; - if(s != "") - s1 = " "; - cvar_set("net_slist_favorites", strcat(s, " ", srv)); + if(!f) + { + s1 = ""; + if(s != "") + s1 = " "; + if(p) + cvar_set("net_slist_favorites", strcat(s, s1, p)); + else + cvar_set("net_slist_favorites", strcat(s, s1, srv)); + } resorthostcache(); } @@ -455,12 +492,14 @@ void XonoticServerList_resizeNotify(entity me, vector relOrigin, vector relSize, me.realFontSize_x = me.fontSize / (absSize_x * (1 - me.controlWidth)); me.realUpperMargin = 0.5 * (1 - me.realFontSize_y); - me.columnPingOrigin = 0; + me.columnIconsOrigin = 0; + me.columnIconsSize = me.realFontSize_x * 2; me.columnPingSize = me.realFontSize_x * 4; me.columnMapSize = me.realFontSize_x * 12; me.columnTypeSize = me.realFontSize_x * 4; me.columnPlayersSize = me.realFontSize_x * 6; - me.columnNameSize = 1 - me.columnPlayersSize - me.columnMapSize - me.columnPingSize - me.columnTypeSize - 4 * me.realFontSize_x; + me.columnNameSize = 1 - me.columnPlayersSize - me.columnMapSize - me.columnPingSize - me.columnIconsSize - me.columnTypeSize - 5 * me.realFontSize_x; + me.columnPingOrigin = me.columnIconsOrigin + me.columnIconsSize + me.realFontSize_x; me.columnNameOrigin = me.columnPingOrigin + me.columnPingSize + me.realFontSize_x; me.columnMapOrigin = me.columnNameOrigin + me.columnNameSize + me.realFontSize_x; me.columnTypeOrigin = me.columnMapOrigin + me.columnMapSize + me.realFontSize_x; @@ -517,7 +556,7 @@ void XonoticServerList_drawListBoxItem(entity me, float i, vector absSize, float { // layout: Ping, Server name, Map name, NP, TP, MP string s; - float p; + float p, q; vector theColor; float theAlpha; @@ -556,6 +595,52 @@ void XonoticServerList_drawListBoxItem(entity me, float i, vector absSize, float theAlpha = theAlpha * (1 - SKINALPHA_SERVERLIST_FAVORITE) + SKINALPHA_SERVERLIST_FAVORITE; } + s = gethostcachestring(SLIST_FIELD_CNAME, i); + q = stof(substring(crypto_getencryptlevel(s), 0, 1)); + if((q <= 0 && cvar("crypto_aeslevel") >= 3) || (q >= 3 && cvar("crypto_aeslevel") <= 0)) + { + theColor = SKINCOLOR_SERVERLIST_IMPOSSIBLE; + theAlpha = SKINALPHA_SERVERLIST_IMPOSSIBLE; + } + + if(q == 1) + { + if(cvar("crypto_aeslevel") >= 2) + q |= 4; + } + if(q == 2) + { + if(cvar("crypto_aeslevel") >= 1) + q |= 4; + } + if(q == 3) + q = 5; + if(q >= 3) + q -= 2; + // possible status: + // 0: crypto off + // 1: AES possible + // 2: AES recommended but not available + // 3: AES possible and will be used + // 4: AES recommended and will be used + // 5: AES required + + s = gethostcachestring(SLIST_FIELD_QCSTATUS, i); + { + vector iconSize; + iconSize_y = 1; + iconSize_x = iconSize_y * (absSize_y / absSize_x); + + vector iconPos; + iconPos_x = (me.columnIconsSize - 2 * iconSize_x) * 0.5; + iconPos_y = (1 - iconSize_y) * 0.5; + + draw_Picture(iconPos, strcat(SKINGFX_SERVERLIST_ICON, "_pure", ftos(strstrofs(s, ":P0:", 0) >= 0)), iconSize, '1 1 1', 1); + + iconPos_x += iconSize_x; + draw_Picture(iconPos, strcat(SKINGFX_SERVERLIST_ICON, "_aeslevel", ftos(q)), iconSize, '1 1 1', 1); + } + s = ftos(p); draw_Text(me.realUpperMargin * eY + (me.columnPingSize - draw_TextWidth(s, 0, me.realFontSize)) * eX, s, me.realFontSize, theColor, theAlpha, 0); s = draw_TextShortenToWidth(gethostcachestring(SLIST_FIELD_NAME, i), me.columnNameSize, 0, me.realFontSize);