10 me.configureXonoticStatsList(me);
16 me.configureXonoticListBox(me);
20 if (SKINBOOL_STATSLIST_ICON_BLUR)
33 string month_num =
substring(input, 5, 2);
35 switch (
stoi(month_num))
37 case 1: monthname = _(
"January");
break;
38 case 2: monthname = _(
"February");
break;
39 case 3: monthname = _(
"March");
break;
40 case 4: monthname = _(
"April");
break;
41 case 5: monthname = _(
"May");
break;
42 case 6: monthname = _(
"June");
break;
43 case 7: monthname = _(
"July");
break;
44 case 8: monthname = _(
"August");
break;
45 case 9: monthname = _(
"September");
break;
46 case 10: monthname = _(
"October");
break;
47 case 11: monthname = _(
"November");
break;
48 case 12: monthname = _(
"December");
break;
49 default:
return input;
56 string date =
CTX(_(
"DATE^%MMMM %d, %y"));
58 date = strreplace(
"%yy",
substring(input, 2, 2), date);
59 date = strreplace(
"%y",
substring(input, 0, 4), date);
62 date = strreplace(
"%dd", day_num, date);
63 date = strreplace(
"%d",
itos(
stoi(day_num)), date);
65 date = strreplace(
"%MMMM", monthname, date);
66 date = strreplace(
"%MM", month_num, date);
67 date = strreplace(
"%M",
itos(
stoi(month_num)), date);
75 if (me.listStats >= 0)
76 buf_del(me.listStats);
82 bool have_unranked_stats =
false;
83 if (me.controlledTextLabel)
84 me.controlledTextLabel.setText(me.controlledTextLabel,
"");
99 int out_total_matches = -1;
100 int out_total_wins = -1;
101 int out_total_losses = -1;
102 int out_total_kills = -1;
103 int out_total_deaths = -1;
116 case "overall/joined_dt":
118 outstr = _(
"Joined:");
121 case "overall/last_seen_dt":
123 outstr = _(
"Last match:");
126 case "overall/alivetime":
128 outstr = _(
"Time played:");
131 case "overall/favorite-map":
133 outstr = _(
"Favorite map:");
136 case "overall/matches":
138 out_total_matches =
stoi(data);
142 out_total_wins =
stoi(data);
144 case "overall/total-kills":
146 out_total_kills =
stoi(data);
148 case "overall/total-deaths":
150 out_total_deaths =
stoi(data);
154 if (order == -1 && out_total_matches >= 0 && out_total_wins >= 0)
156 bufstr_add(me.listStats, sprintf(
"003%s\n%d\n", _(
"Matches:"), out_total_matches),
true);
158 if (out_total_matches > 0)
160 out_total_losses =
max(0, out_total_matches - out_total_wins);
161 bufstr_add(me.listStats, sprintf(
"004%s\n%d/%d\n", _(
"Wins/Losses:"), out_total_wins, out_total_losses),
true);
162 bufstr_add(me.listStats, sprintf(
"005%s\n%s\n", _(
"Win percentage:"),
ftos_decimals_percentage(out_total_wins / out_total_matches, 0)),
true);
165 out_total_matches = -1;
167 out_total_losses = -1;
171 if (order == -1 && out_total_kills >= 0 && out_total_deaths >= 0)
173 bufstr_add(me.listStats, sprintf(
"006%s\n%d/%d\n", _(
"Kills/Deaths:"), out_total_kills, out_total_deaths),
true);
176 if (out_total_deaths == 0)
177 out_total_deaths = 1;
179 bufstr_add(me.listStats, sprintf(
"007%s\n%.2f\n", _(
"Kill-death ratio:"), out_total_kills / out_total_deaths),
true);
181 out_total_kills = -1;
182 out_total_deaths = -1;
188 orderstr = sprintf(
"%03d", order);
196 string event =
substring(e, dividerpos + 1,
strlen(e) - (dividerpos + 1));
207 int num =
stoi(data);
214 outstr = _(
"Skill:");
215 data = sprintf(
"%d",
stoi(data));
219 outstr = _(
"Favorite map:");
226 outstr = sprintf(outstr, strtoupper(
gametype));
228 orderstr = sprintf(
"%2.2s%d",
gametype, order);
230 else if (event ==
"matches")
234 int num =
stoi(data);
239 if (!have_unranked_stats && me.controlledTextLabel)
241 me.controlledTextLabel.setText(me.controlledTextLabel, _(
"* = unranked"));
242 have_unranked_stats =
true;
252 bufstr_add(me.listStats,
strcat(orderstr, outstr,
"\n", data,
"\n", extra),
true);
255 me.nItems = buf_getsize(me.listStats);
257 buf_sort(me.listStats, 128,
false);
263 buf_del(me.listStats);
268 me.itemAbsSize =
'0 0 0';
271 me.itemAbsSize.y = absSize.y * me.itemHeight;
272 me.itemAbsSize.x = absSize.x * (1 - me.controlWidth);
273 me.realFontSize.y = me.fontSize / me.itemAbsSize.y;
274 me.realFontSize.x = me.fontSize / me.itemAbsSize.x;
275 me.realUpperMargin = 0.5 * (1 - me.realFontSize.y);
277 me.columnIconOrigin = 0.25 * me.realFontSize.x;
278 me.columnIconSize = me.itemAbsSize.y / me.itemAbsSize.x;
279 me.columnNameOrigin = me.columnIconOrigin * 2 + me.columnIconSize;
280 me.columnNameSize = 1 - me.columnIconOrigin - me.columnIconSize - me.realFontSize.x;
287 me.focusedItemAlpha =
getFadedAlpha(me.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED);
288 draw_Fill(
'0 0 0',
'1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha);
291 string data = bufstr_get(me.listStats, i);
293 int ofs_extra =
strstrofs(data,
"\n", ofs_data + 1);
295 string s =
substring(data, 3, ofs_data - 3);
296 string d =
substring(data, ofs_data + 1, ofs_extra - (ofs_data + 1));
297 string icon =
substring(data, ofs_extra + 1,
strlen(data) - (ofs_extra + 1));
300 draw_Picture(me.columnIconOrigin *
eX, icon, me.columnIconSize *
eX +
eY,
'1 1 1', SKINALPHA_LISTBOX_SELECTED);
305 vector fs = me.realFontSize;
308 draw_Text(me.realUpperMargin *
eY + me.columnNameOrigin *
eX, s, fs,
'1 1 1', SKINALPHA_TEXT, 0);
314 fs = me.realFontSize;
317 bool drawStar = (
substring(d, -1, 1) ==
"*");
325 draw_Text(me.realUpperMargin *
eY + (me.columnNameOrigin + me.columnNameSize - starwidth - textwidth) *
eX, d, fs, SKINCOLOR_TEXT, SKINALPHA_TEXT, 0);
327 draw_Text(me.realUpperMargin *
eY + (me.columnNameOrigin + me.columnNameSize - starwidth) *
eX,
"*", fs, SKINCOLOR_HEADER, SKINALPHA_HEADER, 0);
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define count_matches(num)
ERASEABLE string process_time(float outputtype, int seconds)
float PRECACHE_PIC_MIPMAP
ERASEABLE string CTX(string s)
ERASEABLE string db_get(int db, string key)
string MapInfo_Type_ToText(Gametype t)
Gametype MapInfo_Type_FromString(string gtype, bool dowarn, bool is_q3compat)
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
void PlayerStats_PlayerDetail_CheckUpdate()
void XonoticStatsList_configureXonoticStatsList(entity me)
float XonoticStatsList_keyDown(entity me, float scan, float ascii, float shift)
void XonoticStatsList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused)
void XonoticStatsList_getStats(entity me)
entity makeXonoticStatsList()
void XonoticStatsList_showNotify(entity me)
void XonoticStatsList_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
void XonoticStatsList_doubleClickListBoxItem(entity me, float i, vector where)
string XonoticStatsList_convertDate(string input)
void XonoticStatsList_destroy(entity me)
ERASEABLE string car(string s)
Returns first word.
ERASEABLE string ftos_decimals_percentage(float number, int decimals)
Converts a percentage to a string with the indicated number of decimals.