X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fmenu%2Fxonotic%2Fstatslist.qc;h=7d19516cf01673cfd38f150a63ab4678de6612ca;hp=3e94738a9ab500d89a162003be58ef67106e49f0;hb=565754a35f9e84a3b8e6eac08635ec27145b369a;hpb=641c47df604de42c11c68a7d80813b29affcefb2 diff --git a/qcsrc/menu/xonotic/statslist.qc b/qcsrc/menu/xonotic/statslist.qc index 3e94738a9..7d19516cf 100644 --- a/qcsrc/menu/xonotic/statslist.qc +++ b/qcsrc/menu/xonotic/statslist.qc @@ -41,12 +41,11 @@ string XonoticStatsList_convertDate(string input) default: return input; // failed, why? } - return sprintf( - "%s %s, %d", - monthname, - count_ordinal(stof(substring(input, 8, 2))), - stof(substring(input, 0, 4)) - ); + string date = ZCTX(_("DATE^%m %d, %Y")); + date = strreplace("%Y", substring(input, 0, 4), date); + date = strreplace("%d", ftos(stof(substring(input, 8, 2))), date); // ftos-stof removes leading 0 + date = strreplace("%m", monthname, date); + return date; } void XonoticStatsList_getStats(entity me) @@ -100,21 +99,21 @@ void XonoticStatsList_getStats(entity me) case "overall/last_seen_dt": { order = 1; - outstr = _("Last_Seen:"); + outstr = _("Last match:"); data = XonoticStatsList_convertDate(car(data)); break; } case "overall/alivetime": { order = 1; - outstr = _("Time_Played:"); + outstr = _("Time played:"); data = process_time(3, stof(data)); break; } case "overall/favorite-map": { order = 2; - outstr = _("Favorite_Map:"); + outstr = _("Favorite map:"); data = car(data); break; } @@ -146,13 +145,13 @@ void XonoticStatsList_getStats(entity me) if((order == -1) && (out_total_matches >= 0) && (out_total_wins >= 0)) { - bufstr_add(me.listStats, sprintf("003Matches: %d", out_total_matches), true); + bufstr_add(me.listStats, sprintf("003%s\n%d", _("Matches:"), out_total_matches), true); if(out_total_matches > 0) // don't show extra info if there are no matches played { out_total_losses = max(0, (out_total_matches - out_total_wins)); - bufstr_add(me.listStats, sprintf("003Wins/Losses: %d/%d", out_total_wins, out_total_losses), true); - bufstr_add(me.listStats, sprintf("004Win_Percentage: %d%%", ((out_total_wins / out_total_matches) * 100)), true); + bufstr_add(me.listStats, sprintf("003%s\n%d/%d", _("Wins/Losses:"), out_total_wins, out_total_losses), true); + bufstr_add(me.listStats, sprintf("004%s\n%d%%", _("Win percentage:"), ((out_total_wins / out_total_matches) * 100)), true); } out_total_matches = -1; @@ -163,13 +162,13 @@ void XonoticStatsList_getStats(entity me) if((order == -1) && (out_total_kills >= 0) && (out_total_deaths >= 0)) { - bufstr_add(me.listStats, sprintf("005Kills/Deaths: %d/%d", out_total_kills, out_total_deaths), true); + bufstr_add(me.listStats, sprintf("005%s\n%d/%d", _("Kills/Deaths:"), out_total_kills, out_total_deaths), true); // if there are no deaths, just show kill count - if(out_total_deaths > 0) - bufstr_add(me.listStats, sprintf("006Kill_Ratio: %.2f", (out_total_kills / out_total_deaths)), true); - else - bufstr_add(me.listStats, sprintf("006Kill_Ratio: %.2f", out_total_kills), true); + if(out_total_deaths == 0) + out_total_deaths = 1; + + bufstr_add(me.listStats, sprintf("006%s\n%.2f", _("Kill ratio:"), (out_total_kills / out_total_deaths)), true); out_total_kills = -1; out_total_deaths = -1; @@ -198,28 +197,27 @@ void XonoticStatsList_getStats(entity me) case "matches": { order = 1; - outstr = sprintf(_("%s_Matches:"), strtoupper(gametype)); - //data = sprintf(_("%d (unranked)"), data); + outstr = _("Matches:"); break; } case "elo": { order = 2; - outstr = sprintf(_("%s_ELO:"), strtoupper(gametype)); + outstr = _("ELO:"); data = sprintf("%d", stof(data)); break; } case "rank": { order = 3; - outstr = sprintf(_("%s_Rank:"), strtoupper(gametype)); + outstr = _("Rank:"); data = sprintf("%d", stof(data)); break; } case "percentile": { order = 4; - outstr = sprintf(_("%s_Percentile:"), strtoupper(gametype)); + outstr = _("Percentile:"); data = sprintf("%d%%", stof(data)); break; } @@ -228,8 +226,7 @@ void XonoticStatsList_getStats(entity me) case "favorite-map": { order = 5; - outstr = sprintf(_("%s_Favorite_Map:"), strtoupper(gametype)); - //data = sprintf(_("%d (unranked)"), data); + outstr = _("Favorite map:"); break; } #endif @@ -237,12 +234,14 @@ void XonoticStatsList_getStats(entity me) default: continue; // nothing to see here } + outstr = strcat(strtoupper(gametype), " ", outstr); // now set up order for sorting later orderstr = sprintf("%2.2s%d", gametype, order); } else if(event == "matches") { - outstr = sprintf(_("%s_Matches:"), strtoupper(gametype)); + outstr = _("Matches:"); + outstr = strcat(strtoupper(gametype), " ", outstr); data = sprintf(_("%d (unranked)"), stof(data)); // unranked game modes ALWAYS get put last @@ -251,7 +250,7 @@ void XonoticStatsList_getStats(entity me) else { continue; } } - bufstr_add(me.listStats, sprintf("%s%s %s", orderstr, outstr, data), true); + bufstr_add(me.listStats, sprintf("%s%s\n%s", orderstr, outstr, data), true); } me.nItems = buf_getsize(me.listStats); @@ -270,8 +269,10 @@ void XonoticStatsList_resizeNotify(entity me, vector relOrigin, vector relSize, me.itemAbsSize = '0 0 0'; SUPER(XonoticStatsList).resizeNotify(me, relOrigin, relSize, absOrigin, absSize); - me.realFontSize_y = me.fontSize / (me.itemAbsSize_y = (absSize.y * me.itemHeight)); - me.realFontSize_x = me.fontSize / (me.itemAbsSize_x = (absSize.x * (1 - me.controlWidth))); + me.itemAbsSize.y = absSize.y * me.itemHeight; + me.itemAbsSize.x = absSize.x * (1 - me.controlWidth); + me.realFontSize.y = me.fontSize / me.itemAbsSize.y; + me.realFontSize.x = me.fontSize / me.itemAbsSize.x; me.realUpperMargin = 0.5 * (1 - me.realFontSize.y); #if 0 @@ -294,14 +295,13 @@ void XonoticStatsList_drawListBoxItem(entity me, int i, vector absSize, bool isS } string data = bufstr_get(me.listStats, i); - string s = car(data); - string d = cdr(data); + int ofs = strstrofs(data, "\n", 0); - s = substring(s, 3, strlen(s) - 3); - s = strreplace("_", " ", s); + string s = substring(data, 3, ofs - 3); s = draw_TextShortenToWidth(s, 0.5 * me.columnNameSize, 0, me.realFontSize); draw_Text(me.realUpperMargin * eY + me.columnNameOrigin * eX, s, me.realFontSize, '1 1 1', SKINALPHA_TEXT, 1); + string d = substring(data, ofs + 1, strlen(data) - (ofs + 1)); d = draw_TextShortenToWidth(d, me.columnNameSize - draw_TextWidth(s, 0, me.realFontSize), 0, me.realFontSize); draw_Text(me.realUpperMargin * eY + (me.columnNameOrigin + 1 * (me.columnNameSize - draw_TextWidth(d, 0, me.realFontSize))) * eX, d, me.realFontSize, '1 1 1', SKINALPHA_TEXT, 1); }