The first pages in the notebook's own format: tables, fixtures, strengths, scorers, fair play, indoor
A page of the notebook is 1244 x 720 design units under the sheet's heading; its building blocks (panels, tables, pills, pickers, meters, dialogs) are in pages.inc and pages.rcss with the notebook's inks for all three skins. The league reports are laid out in it; the other menus stay scaled sheets until they follow. The older dialogs take the same cream note with round corners and pill buttons. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
fc2974084c
commit
ac455eabfe
12 files changed
+479
-351
No files matched your search
@@ -56,21 +56,14 @@ std::string App::render_reports(const std::string &mode) {
|
||||
{"points", "Punkte"}, {"gf", "Tore"}, {"diff", "Diff."}};
|
||||
const bool real_other=engine_mode_&&mode=="other";
|
||||
const auto &fixture=real_other?engine_other_value_:engine_fixtures_value_;
|
||||
std::vector<double> widths;
|
||||
if (matches)
|
||||
widths = real_other?std::vector<double>{1184,240,1184}:std::vector<double>{1224,160,1224}; // Match card has two 2dp borders.
|
||||
else if (strengths) {
|
||||
widths.push_back(2612 * .38);
|
||||
for (int i = 0; i < 5; ++i) widths.push_back(2612 * .62 / 5);
|
||||
} else {
|
||||
for (int i = 0; i < 9; ++i)
|
||||
widths.push_back(i == 0 ? 2612 * .32 : i == 5 ? 2612 * .14 : 2612 * .54 / 7);
|
||||
}
|
||||
const double heading_height = matches ? 80 : strengths ? (rows.size() >= 20 ? 64 : 66)
|
||||
: rows.size() >= 20 ? 64 : 80;
|
||||
const double row_height = matches ? 118 : strengths ? (rows.size() >= 20 ? 64 : 66)
|
||||
: rows.size() >= 16 ? (1682 - heading_height) / rows.size() : 80;
|
||||
std::string body = "<div id=\"report-underlay\" class=\"report-underlay\">";
|
||||
const auto own_id = engine_mode_ ? engine_data_.at("desktop").at("meta").at("scope").at("teamId").get<std::string>()
|
||||
: snap().state.at("career").value("role", "club") == "club" ? manager(snap()).value("club", "") : std::string();
|
||||
// a place the season decides tints its row: Europe, promotion, relegation
|
||||
const auto zone_of = [&](const Json &row) -> std::string {
|
||||
const auto zone = engine_mode_ ? row.value("zone", std::string()) : report_zone(row.value("rank", 0), int(rows.size()), tier);
|
||||
return zone == "europe" || zone == "champions" || zone == "europa" || zone == "conference" ? "eu" : zone == "promotion" || zone == "playoff" ? "auf" : zone == "relegation" ? "ab" : "";
|
||||
};
|
||||
std::string body = "<div id=\"report-underlay\" class=\"pg-page\">";
|
||||
if (matches) {
|
||||
const int round = engine_mode_?fixture.at("round").get<int>()-1:std::clamp(state.value("round", 0), 0,
|
||||
report_round_count(*world_, state, mode == "other") - 1);
|
||||
@@ -84,142 +77,96 @@ std::string App::render_reports(const std::string &mode) {
|
||||
const auto choices = report_picker_items("competition");
|
||||
subtitle = choices.at(size_t(state.value("competition", 0))).second;
|
||||
}
|
||||
body += "<header class=\"report-match-heading\"><h2>" +
|
||||
const double mid = real_other ? 190 : 120;
|
||||
body += "<header class=\"pg-heading\"><h2 class=\"pg-h large\">" +
|
||||
(real_other?fixture.at("heading").get<std::string>():opening ? std::string("1. Runde") : std::to_string(round + 1) + ". Spieltag") +
|
||||
"</h2><p>" + esc(subtitle) + "</p></header>";
|
||||
}
|
||||
body += "<div id=\"report-list\" class=\"report-list " +
|
||||
std::string(matches ? "match-list" : strengths ? "strength-list" : "standings-list") +
|
||||
"\"><div class=\"report-table\" role=\"table\"><div class=\"report-row report-head\" "
|
||||
"role=\"row\" style=\"height:" + scalar(heading_height) + "dp;\">";
|
||||
for (size_t column = 0; column < headings.size(); ++column) {
|
||||
const auto &[key, label] = headings[column];
|
||||
const auto sorting = matches ? Json::object() : state.at("sorts").at(mode);
|
||||
const bool current = !matches && sorting.value("key", "") == key;
|
||||
const bool descending = sorting.value("desc", false);
|
||||
body += "<div class=\"report-cell " + std::string(column == 0 ? "first" : "") +
|
||||
(matches && column == 1 ? " score" : "") + "\" role=\"columnheader\" "
|
||||
"aria-sort=\"" + (current ? descending ? "descending" : "ascending" : "none") +
|
||||
"\" style=\"width:" + scalar(widths[column]) + "dp;\">";
|
||||
if (matches)
|
||||
body += "<span class=\"report-value\">" + esc(label) + "</span>";
|
||||
else {
|
||||
std::string indicator = "<span class=\"report-sort-symbol\">";
|
||||
if (!current || !descending)
|
||||
indicator += "<span class=\"report-sort-arrow up\"></span>";
|
||||
if (!current || descending)
|
||||
indicator += "<span class=\"report-sort-arrow down\"></span>";
|
||||
indicator += "</span>";
|
||||
body += btn("report-sort", "<span>" + esc(label) + "</span>" + indicator,
|
||||
"report-sort", "id=\"report-sort-" + key + "\" data-id=\"" + key +
|
||||
"\" aria-label=\"Nach " + esc(label) + " sortieren\"");
|
||||
"</h2><span class=\"pg-mut\">" + esc(subtitle) + "</span></header><div class=\"pg-panel pg-col pg-grow\" style=\"" + pg_css("gap:0px;padding:10px 14px;") + "\">"
|
||||
"<div class=\"pg-match-head\">" + pg_kicker("Heim", "text-align:right;") + "<span class=\"pg-k pg-c\" style=\"flex:none;width:" + pg(mid) + ";\">ERGEBNIS</span>" + pg_kicker("Auswärts") + "</div>"
|
||||
"<div id=\"report-list\" class=\"pg-tbody " + std::string(rows.size() <= 12 ? "even" : "") + "\">";
|
||||
for (const auto &row : rows) {
|
||||
const auto home = row.at("home").get<std::string>(), away = row.at("away").get<std::string>();
|
||||
std::string value = row.at("home_goals").is_null() || row.at("away_goals").is_null()
|
||||
? std::string() : report_number(row["home_goals"]) + " : " + report_number(row["away_goals"]);
|
||||
std::string middle, detail;
|
||||
if (real_other) {
|
||||
const auto phase = [](const Json &v) { return v == 1 ? std::string(" n.V.") : v == 2 ? std::string(" n.E.") : std::string(); };
|
||||
if (!value.empty()) value += phase(row.at("phase"));
|
||||
if (row.at("secondLegVisible").get<bool>()) {
|
||||
detail = "Hin: " + (row.at("secondLeg").is_null() ? std::string("–") : report_number(row.at("secondLeg")[0]) + ":" + report_number(row.at("secondLeg")[1]) + phase(row.at("secondLegPhase")));
|
||||
if (!value.empty()) value = "Rück: " + value;
|
||||
} else if (row.at("status") == "scheduled" && row.at("date").is_string()) detail = row.at("date").get<std::string>();
|
||||
}
|
||||
const bool moved = engine_mode_ && (row.value("status", "") == "rescheduled" || row.value("status", "") == "postponed");
|
||||
if (!value.empty()) middle = "<span class=\"pg-score\">" + esc(value) + "</span>" + (detail.empty() ? "" : "<small>" + esc(detail) + "</small>");
|
||||
else if (moved) middle = "<span class=\"pg-tag accent\" style=\"display:inline-block;\">verlegt</span>";
|
||||
else if (!detail.empty()) middle = "<span class=\"pg-tag\" style=\"display:inline-block;\">" + esc(detail) + "</span>";
|
||||
else middle = "<span class=\"pg-mut\">–</span>";
|
||||
body += "<div class=\"pg-match " + std::string(!own_id.empty() && (home == own_id || away == own_id) ? "me" : "") + "\" role=\"row\"><div class=\"pg-match-side home\">" + pg_club(home, 50, true) +
|
||||
"</div><div class=\"pg-match-mid\" style=\"width:" + pg(mid) + ";\">" + middle + "</div><div class=\"pg-match-side\">" + pg_club(away) + "</div></div>";
|
||||
}
|
||||
body += "</div>";
|
||||
}
|
||||
body += "</div>";
|
||||
for (size_t i = 0; i < rows.size(); ++i) {
|
||||
const auto &row = rows[i];
|
||||
// the manager's own club stands out: a bar in its colour down the left edge
|
||||
const std::string row_club = row.value("club", "");
|
||||
const bool own_row = !matches && !row_club.empty() &&
|
||||
(engine_mode_ ? engine_data_.at("desktop").at("meta").at("scope").at("teamId") == row_club
|
||||
: snap().state.at("career").value("role", "club") == "club" && manager(snap()).value("club", "") == row_club);
|
||||
std::string own_colour;
|
||||
if (own_row)
|
||||
if (const auto *club = world_->find("clubs", row_club); club && !club->value("crest", "").empty()) own_colour = renderer_.crest_colour(club->value("crest", ""));
|
||||
// a place the season decides tints its whole row
|
||||
const std::string row_zone = matches || strengths ? std::string()
|
||||
: engine_mode_ ? row.value("zone", std::string()) : report_zone(row.value("rank", 0), int(rows.size()), tier);
|
||||
body += "<div class=\"report-row " + std::string(i % 2 == 0 ? "striped" : "") + (own_row ? " own" : "") + (row_zone.empty() ? "" : " zone-" + row_zone) +
|
||||
"\" role=\"row\" data-club=\"" + esc(row.value("club", "")) +
|
||||
"\" style=\"height:" + scalar(row_height) + "dp;" + (own_colour.empty() ? "" : "border-left-color:" + own_colour + ";") + "\">";
|
||||
if (real_other && rows.empty())
|
||||
body += "<div class=\"pg-empty\">" + std::string(!fixture.at("available").get<bool>() ? "Diese Runde ist noch nicht ausgelost oder die vorherige Phase ist noch nicht abgeschlossen." : "Keine Paarungen vorhanden.") + "</div>";
|
||||
body += "</div></div>";
|
||||
} else {
|
||||
// the widths of the columns in design units; the first takes the room that is left
|
||||
const std::vector<double> widths = strengths ? std::vector<double>{0, 150, 150, 150, 150, 110} : std::vector<double>{0, 52, 52, 52, 52, 190, 80, 80, 70};
|
||||
const auto sorting = state.at("sorts").at(mode);
|
||||
const double row_height = rows.size() > 20 ? 1420.0 / rows.size() : 70;
|
||||
body += "<div class=\"pg-panel pg-col pg-grow\" style=\"" + pg_css("gap:0px;padding:4px 12px;") + "\"><div class=\"pg-t\" role=\"table\"><div class=\"pg-thead\" role=\"row\">";
|
||||
for (size_t column = 0; column < headings.size(); ++column) {
|
||||
body += "<div class=\"report-cell " + std::string(column == 0 ? "first" : "") +
|
||||
(matches && column == 1 ? " score" : "") +
|
||||
(!matches && !strengths && column == 5 ? " form" : "") +
|
||||
"\" role=\"cell\" style=\"width:" + scalar(widths[column]) + "dp;\">";
|
||||
if (matches && column != 1)
|
||||
body += report_club_button(row.at(column == 0 ? "home" : "away").get<std::string>(), column == 0);
|
||||
else if (!matches && column == 0) {
|
||||
if (!strengths) {
|
||||
const auto zone = engine_mode_?row.value("zone", std::string()):report_zone(row.value("rank", 0), int(rows.size()), tier);
|
||||
body += "<span class=\"report-zone " + zone + "\"></span><span class=\"report-rank\"><span>" +
|
||||
std::to_string(row.value("rank", 0)) + ".</span></span>";
|
||||
}
|
||||
body += report_club_button(row.at("club").get<std::string>());
|
||||
} else {
|
||||
std::string value;
|
||||
if (matches)
|
||||
value = row.at("home_goals").is_null() || row.at("away_goals").is_null()
|
||||
? (engine_mode_&&(row.value("status","")=="rescheduled"||row.value("status","")=="postponed")?"verlegt":"–") : report_number(row["home_goals"]) + " : " + report_number(row["away_goals"]);
|
||||
else if (!strengths && column == 5)
|
||||
value = row.value("form_text", "");
|
||||
else if (!strengths && column == 7)
|
||||
value = report_number(row["gf"]) + ":" + report_number(row["ga"]);
|
||||
else
|
||||
value = report_number(row.at(headings[column].first));
|
||||
if(real_other&&matches) {
|
||||
const auto phase=[](const Json &v){return v==1?std::string(" n.V."):v==2?std::string(" n.E."):std::string();};
|
||||
value+=phase(row.at("phase"));
|
||||
std::string detail;
|
||||
if(row.at("secondLegVisible").get<bool>()) {
|
||||
detail="Hin: "+(row.at("secondLeg").is_null()?std::string("–"):report_number(row.at("secondLeg")[0])+":"+report_number(row.at("secondLeg")[1])+phase(row.at("secondLegPhase")));
|
||||
value="Rück: "+value;
|
||||
} else if(row.at("status")=="scheduled"&&row.at("date").is_string())detail=row.at("date").get<std::string>();
|
||||
body+="<div class=\"report-score-lines\"><span class=\"report-value\">"+esc(value)+"</span>"+(detail.empty()?"":"<span class=\"report-score-note\">"+esc(detail)+"</span>")+"</div>";
|
||||
} else if (!matches && !strengths && column == 5) {
|
||||
// the last matches as marks: won, drawn, lost, not played
|
||||
body += "<span class=\"report-form\" title=\"" + esc(value) + "\">";
|
||||
for (const char c : value)
|
||||
body += std::string("<span class=\"form-mark ") + (c == 'S' ? "won" : c == 'U' ? "drawn" : c == 'N' ? "lost" : "none") + "\"></span>";
|
||||
body += "</span>";
|
||||
} else body += "<span class=\"report-value\">" + esc(value) + "</span>";
|
||||
const auto &[key, label] = headings[column];
|
||||
const bool current = sorting.value("key", "") == key, descending = sorting.value("desc", false);
|
||||
body += pg_th(label, widths[column], column == 0 ? "" : !strengths && column == 5 ? "" : "r", "report-sort",
|
||||
"id=\"report-sort-" + key + "\" data-id=\"" + key + "\" aria-label=\"Nach " + esc(label) + " sortieren\"", current ? (descending ? -1 : 1) : 0);
|
||||
}
|
||||
body += "</div><div id=\"report-list\" class=\"pg-tbody\">";
|
||||
for (const auto &row : rows) {
|
||||
const auto club = row.value("club", std::string());
|
||||
const auto zone = strengths ? std::string() : zone_of(row);
|
||||
body += "<div class=\"pg-tr " + std::string(!club.empty() && club == own_id ? "me " : "") + (zone.empty() ? "" : "z-" + zone) + "\" role=\"row\" data-club=\"" + esc(club) +
|
||||
"\" style=\"height:" + scalar(row_height) + "dp;\">";
|
||||
for (size_t column = 0; column < headings.size(); ++column) {
|
||||
const auto &key = headings[column].first;
|
||||
if (column == 0)
|
||||
body += pg_td((strengths ? std::string() : "<span class=\"pg-zone " + zone + "\"></span><span class=\"pg-rank\">" + std::to_string(row.value("rank", 0)) + "</span>") + pg_club(club), 0, "", true);
|
||||
else if (strengths && column < 5) {
|
||||
const auto value = row.at(key).is_number_integer() ? row.at(key).get<int>() : 0;
|
||||
body += pg_td("<span style=\"display:block;width:" + pg(70) + ";\">" + pg_bar((value - 50) / 40.0 * 100) + "</span><strong style=\"display:block;width:" + pg(26) + ";text-align:right;\">" + report_number(row.at(key)) + "</strong>", widths[column], "r", true);
|
||||
} else if (strengths)
|
||||
body += pg_td("<span class=\"pg-num\">" + report_number(row.at(key)) + "</span>", widths[column], "r");
|
||||
else if (column == 5)
|
||||
body += pg_td(pg_form(row.value("form_text", "")), widths[column], "", true);
|
||||
else if (column == 6)
|
||||
body += pg_td("<span class=\"pg-num\">" + report_number(row.at(key)) + "</span>", widths[column], "r");
|
||||
else if (column == 7)
|
||||
body += pg_td(report_number(row["gf"]) + ":" + report_number(row["ga"]), widths[column], "r");
|
||||
else if (column == 8) {
|
||||
const auto diff = row.at(key).is_number_integer() ? row.at(key).get<int64_t>() : 0;
|
||||
body += pg_td((diff > 0 ? "+" : "") + report_number(row.at(key)), widths[column], "r");
|
||||
} else
|
||||
body += pg_td(report_number(row.at(key)), widths[column], "r");
|
||||
}
|
||||
body += "</div>";
|
||||
}
|
||||
body += "</div>";
|
||||
body += "</div></div></div>";
|
||||
}
|
||||
body += "</div>";
|
||||
if(real_other&&rows.empty())body+="<p class=\"report-detail-empty\">"+std::string(!fixture.at("available").get<bool>()?"Diese Runde ist noch nicht ausgelost oder die vorherige Phase ist noch nicht abgeschlossen.":"Keine Paarungen vorhanden.")+"</p>";
|
||||
body+="</div>";
|
||||
if (!matches && !strengths && engine_mode_) {
|
||||
// only the zones this league has
|
||||
std::string items;
|
||||
for (const auto &[kind, label] : std::array<std::pair<const char *, const char *>, 3>{{{"europe", "Europapokal"}, {"promotion", "Aufstieg"}, {"relegation", "Abstieg"}}})
|
||||
if (std::any_of(rows.begin(), rows.end(), [&](const Json &row) { return row.value("zone", "") == kind; }))
|
||||
items += "<span class=\"report-legend-item\"><span class=\"report-zone " + std::string(kind) + "\"></span><span>" + label + "</span></span>";
|
||||
if (!items.empty()) body += "<div class=\"report-legend\">" + items + "</div>";
|
||||
}
|
||||
if (!matches && !strengths && !engine_mode_) {
|
||||
const auto legend = tier == 1
|
||||
? std::vector<std::pair<std::string, std::string>>{
|
||||
{"champions", "Champions League"}, {"europa", "Europa League"},
|
||||
{"conference", "Conference League"}, {"relegation", "Abstieg"}}
|
||||
: tier == 4 ? std::vector<std::pair<std::string, std::string>>{
|
||||
{"promotion", "Aufstieg"}, {"relegation", "Abstieg"}}
|
||||
: std::vector<std::pair<std::string, std::string>>{
|
||||
{"promotion", "Aufstieg"}, {"playoff", "Relegation"}, {"relegation", "Abstieg"}};
|
||||
body += "<div class=\"report-legend\">";
|
||||
for (const auto &[kind, label] : legend)
|
||||
body += "<span class=\"report-legend-item\"><span class=\"report-zone " + kind +
|
||||
"\"></span><span>" + esc(label) + "</span></span>";
|
||||
body += "</div>";
|
||||
}
|
||||
body += "<nav class=\"report-footer\">";
|
||||
// the foot: steps and pickers at the left, a legend or a note at the right
|
||||
body += "<nav class=\"pg-foot\">";
|
||||
if (matches) {
|
||||
for (int i = 0; i < 2; ++i)
|
||||
body += btn("report-round", i ? "›" : "‹", "report-round",
|
||||
"id=\"report-round-" + std::string(i ? "next" : "previous") +
|
||||
"\" data-id=\"" + (i ? "1" : "-1") + "\" style=\"" +
|
||||
rect(i * 130, 0, 110, 94) + "\" " + ((opening||(engine_mode_&&(i?fixture.at("round")==fixture.at("rounds"):fixture.at("round")==1))) ? "disabled" : ""));
|
||||
body += mode == "league" ? report_picker("country", 260, 1060) + report_picker("league", 1340, 1272)
|
||||
: report_picker("competition", 260, 2352);
|
||||
body += pg_button("report-round", i ? "›" : "‹", "round",
|
||||
"id=\"report-round-" + std::string(i ? "next" : "previous") + "\" data-id=\"" + (i ? "1" : "-1") + "\" aria-label=\"" + (i ? "Nächste Runde" : "Vorige Runde") + "\" " +
|
||||
((opening||(engine_mode_&&(i?fixture.at("round")==fixture.at("rounds"):fixture.at("round")==1))) ? "disabled" : ""));
|
||||
body += mode == "league" ? report_picker("country", -1, 0) + report_picker("league", -1, 0) : report_picker("competition", -1, 0);
|
||||
} else if (strengths)
|
||||
body += report_picker("country", 0, 1294) + report_picker("league", 1318, 1294);
|
||||
else
|
||||
body += btn("report-reset", "Gesamt", "report-reset", "id=\"report-reset\" style=\"" +
|
||||
rect(0, 0, 635, 94) + "\"") +
|
||||
report_picker("filter", 659, 635) + report_picker("country", 1318, 635) +
|
||||
report_picker("league", 1977, 635);
|
||||
body += report_picker("country", -1, 0) + report_picker("league", -1, 0) + "<span class=\"pg-sp\"></span>" +
|
||||
pg_status((league ? world_->name(*league) + " · " : std::string()) + std::to_string(rows.size()) + " Vereine · Spaltenkopf anklicken zum Sortieren");
|
||||
else {
|
||||
body += pg_button("report-reset", "Gesamt", "", "id=\"report-reset\"") + report_picker("filter", -1, 0) + report_picker("country", -1, 0) + report_picker("league", -1, 0) + "<span class=\"pg-sp\"></span><span class=\"pg-legend\">";
|
||||
for (const auto &[kind, label] : std::array<std::pair<const char *, const char *>, 3>{{{"eu", "Europapokal"}, {"auf", "Aufstieg"}, {"ab", "Abstieg"}}})
|
||||
if (std::any_of(rows.begin(), rows.end(), [&](const Json &row) { return zone_of(row) == kind; }))
|
||||
body += "<span class=\"pg-legend-item\"><span class=\"pg-legend-mark pg-zone " + std::string(kind) + "\"></span><span>" + label + "</span></span>";
|
||||
body += "</span>";
|
||||
}
|
||||
return body + "</nav></div>" + render_report_detail();
|
||||
}
|
||||
Reference in new issue
Block a user