Port achievements and player rankings to the Modern UI (by Codex)

This commit is contained in:
Codex committed 2026-10-25 13:51:36 +01:00
1 parent d419943e86
commit 96e88c9579
29 files changed
+1362 -17

No files matched your search

+19 -3
View File
@@ -2,11 +2,11 @@
namespace {
bool report_picker_menu(const std::string &menu) {
return menu == "tables" || menu == "strengths" || menu == "league" ||
menu == "other" || menu == "calendar" || menu == "friendlies" || menu == "almanac";
menu == "other" || menu == "calendar" || menu == "friendlies" || menu == "almanac" || menu == "scorers";
}
bool report_picker_kind(const std::string &kind) {
return kind == "country" || kind == "league" || kind == "filter" ||
kind == "competition" || kind == "year";
kind == "competition" || kind == "year" || kind == "scorer-scope";
}
} // namespace
@@ -15,6 +15,11 @@ App::report_picker_items(const std::string &kind) const {
std::vector<std::pair<std::string, std::string>> items;
if (!world_ || !report_picker_kind(kind))
return items;
if (kind == "scorer-scope") {
if (menu_ == "scorers")
items = {{"0", "Gesamte Liga"}, {"1", "Eigener Verein"}};
return items;
}
if (kind == "year") {
if (!source_) return items;
const auto index = source_->read_almanac({{"kind", "index"}});
@@ -66,6 +71,13 @@ std::string App::report_picker_value(const std::string &kind) const {
if (!world_ || !report_picker_kind(kind))
return {};
if (kind == "year") return std::to_string(almanac_year_);
if (menu_ == "scorers") {
if (kind == "scorer-scope") return std::to_string(rankings_view_.value("scope", 0));
const auto league = rankings_view_.value("league", "");
if (kind == "league") return league;
const auto *row = world_->find("competitions", league);
return row ? row->value("nation", "") : "";
}
const auto reports = snap().state.at("reports");
if (kind == "filter" || kind == "competition")
return std::to_string(reports.at(kind).get<int>());
@@ -92,7 +104,7 @@ std::string App::report_picker(const std::string &kind, double left,
const bool open = report_picker_ == kind;
const std::string menu_label = kind == "country" ? "Land"
: kind == "league" ? "Liga"
: kind == "filter" ? "Spiele" : kind == "year" ? "Kalenderjahr" : "Wettbewerb";
: kind == "filter" ? "Spiele" : kind == "year" ? "Kalenderjahr" : kind == "scorer-scope" ? "Bereich" : "Wettbewerb";
std::string out =
"<div class=\"report-picker-wrapper\" data-report-picker=\"" + kind +
"\" style=\"left:" + scalar(left) + "dp;width:" + scalar(width) + "dp;\">" +
@@ -191,6 +203,10 @@ bool App::report_picker_action(const std::string &action, Rml::Element *target)
almanac_day_.clear();
almanac_match_.clear();
almanac_tab_ = "lineups";
} else if (menu_ == "scorers") {
const auto ranking_action_name = kind == "country" ? "rankings-country"
: kind == "league" ? "rankings-league" : "rankings-scope";
rankings_action(ranking_action_name, target);
} else if (menu_ == "friendlies")
apply("calendar", {{"kind", "friendly-" + kind}, {"value", selection}});
else if (menu_ == "calendar") {