Files
Dreierpack-Manager/src/modern/ui/engine_widgets.inc
T
MichaelandClaude Fable 5.2 9708b720b2 Show line-ups before kickoff, bind form and table widgets, rewrite the press wording
- Live ticker: the paused live state carries both starting elevens; the ticker lists
  them until the first report. A single match no longer gets an empty strip above the
  score, repeated status lines are gone, whistles carry no club badge, dates are
  written out.
- Desk: "Die letzten Spiele" and the table place curve are fed by the engine
  (desktop-widgets read: recent, rankCurve) and belong to the default layout; the own
  crest widget is bound.
- News: the German press templates are rewritten to one plain sentence each (the
  catalogue accepts a single sentence now); the reference snapshots follow, and the
  catalogue test can rewrite them with --update. Mailbox texts show world spellings
  of clubs and players and the euro sign.
- Small type raised in advertising, lineup, news, toto, transfer and others; the
  transfer market column no longer runs under its scrollbar.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-14 12:36:33 +01:00

99 lines
5.3 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// SPDX-License-Identifier: GPL-3.0-only
std::string App::engine_widget_crest(const Json &team, double size) {
const auto *club = world_->find("clubs", team.at("id").get<std::string>());
if (club)
return crest(club, size);
return picture(renderer_.crest(team.value("crestAssetId", std::string()),
theme_ == "silver"),
size, size);
}
std::string App::engine_widget(const std::string &id, const Json &o) {
if (id == "news")
return engine_news_value_.is_object() ? render_news_widget(o)
: std::string();
if (id != "warnings" && id != "competition" && id != "own-summary" &&
id != "opponent-summary" && id != "results" && id != "own-curve")
return {};
const auto data = engine_widgets_projection(engine_data_);
if (id == "results") {
// the last recorded matches, newest on the right; nothing to show before the first one
const auto &rows = data.at("recent");
if (!rows.is_array() || rows.empty())
return widget_heading("Letzte Spiele", false) + "<div class=\"desk-fixture center\"><span>Noch kein Spiel gespielt.</span></div>";
const int w = o.at("w");
const bool wide = o.at("h") == 224;
int won = 0, drawn = 0, lost = 0;
std::string out = widget_heading(rows.size() == 1 ? "Letztes Spiel" : "Die letzten " + std::to_string(rows.size()) + " Spiele", false) + "<div class=\"desk-form\">";
for (const auto &row : rows) {
const auto form = row.value("form", std::string("U"));
++(form == "S" ? won : form == "N" ? lost : drawn);
out += "<div><span class=\"form-" + esc(form) + "\" style=\"width:" + scalar(wide ? 50 : w * .08) + "dp;height:" + scalar(wide ? 50 : w * .08) +
"dp;font-size:" + scalar(wide ? 28 : std::max(28., w * .04)) + "dp;\"><span>" + esc(form) + "</span></span><strong style=\"font-size:" +
scalar(wide ? 29 : std::max(28., w * .035)) + "dp;\">" + esc(row.value("score", std::string())) + "</strong></div>";
}
const auto count = [](int n, const char *one, const char *many) { return std::to_string(n) + " " + (n == 1 ? one : many); };
return out + "</div>" + (wide ? std::string() : "<p class=\"desk-card-note\">" + count(won, "Sieg", "Siege") + " · " + std::to_string(drawn) + " Unentschieden · " + count(lost, "Niederlage", "Niederlagen") + "</p>");
}
if (id == "own-curve") {
const auto &places = data.at("rankCurve");
if (!places.is_array() || places.size() < 2)
return widget_heading("Tabellenplatz", false) + "<div class=\"desk-fixture center\"><span>Die Kurve beginnt nach dem zweiten Spieltag.</span></div>";
// widget_curve draws from the widget values; lend it the engine's series
const Json kept = widget_data_;
widget_data_ = {{"own_curve", places}};
const auto curve = widget_curve(id, o, o.at("w"), o.at("h"));
widget_data_ = kept;
return widget_heading("Tabellenplatz", false) + curve;
}
if (id == "warnings")
return widget_warnings(data.at("warnings"), o);
if (id == "own-summary" || id == "opponent-summary") {
const auto &row = data.at(id == "own-summary" ? "own" : "opponent");
if (!row.is_object())
return widget_heading("Platz & Stärke", false) +
"<div class=\"center\">Noch kein Gegner bestätigt.</div>";
const auto *club =
world_->find("clubs", row.at("teamId").get<std::string>());
const auto number = [&](const char *key) {
return row.at(key).is_null() ? std::string("—")
: std::to_string(row.at(key).get<int>());
};
std::string name = club ? world_->name(*club) : "Nationalteam";
if (!club) {
const auto &desk = engine_data_.at("desktop").at("data");
if (desk.at("team").at("id") == row.at("teamId"))
name = engine_text(desk.at("team").at("name"));
else if (data.at("fixture").is_object())
for (const auto *side : {"home", "away"})
if (data.at("fixture").at(side).at("id") == row.at("teamId"))
name = engine_text(data.at("fixture").at(side).at("name"));
}
return widget_heading(name, false) +
"<div "
"class=\"desk-summary\"><div><small>Tabellenplatz</small><strong>" +
number("rank") +
"</strong></div><div><small>Teamstärke</small><strong>" +
number("strength") + "</strong></div></div>";
}
const auto &next = data.at("fixture");
if (!next.is_object())
return widget_heading("Nächste Begegnung", false) +
"<div class=\"desk-fixture center\"><span>Keine bestätigte "
"Begegnung.</span></div>";
const auto &home = next.at("home"), &away = next.at("away");
const auto team = [&](const Json &v) {
return "<div>" +
engine_widget_crest(v, o.at("w").get<int>() <= 472 ? 68 : 80) +
"<span>" + esc(engine_text(v.at("name"))) + "</span></div>";
};
return widget_heading("Nächste Begegnung", false) +
"<div class=\"desk-fixture\">" + team(home) +
"<div class=\"desk-fixture-centre\"><small>" +
esc(engine_text(next.at("competition"))) +
"</small><strong>–</strong><span>" +
(home.at("id") == data.at("own").at("teamId")
? std::string("Heimspiel")
: std::string("Auswärtsspiel")) +
"</span></div>" + team(away) + "</div>";
}