Trim the career's ticker, news, line-up and transfer wording; show world names in contracts

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
MichaelandClaude Fable 5.2 committed 2026-11-14 10:37:49 +01:00
1 parent 46d0341829
commit 46cd93472f
6 files changed
+29 -14

No files matched your search

+4 -1
View File
@@ -527,7 +527,10 @@ Json engine_contracts_projection(const Json &bundle) {
const auto salary = engine_money_minor(person->at("salaryMonthly"));
require(salary >= 0 && salary <= std::numeric_limits<int64_t>::max() - total, "Ungültiges Monatsgehalt."); total += salary;
require(person->at("contractRemaining").at("unit") == "months" && person->at("offerBlocked").is_boolean(), "Unbekannte Vertragseinheit oder Sperre.");
row["name"] = person->at("name"); row["position"] = person->at("position");
// the squad row carries the player's name as the world spells it; the contract read only
// has the short upper-case form of the original
if (!row.contains("name") || !row.at("name").is_string() || row.at("name").get<std::string>().empty()) row["name"] = person->at("name");
row["position"] = person->at("position");
row["age"] = whole_in_range(person->at("age"), 0, 255);
row["salary"] = salary; row["months"] = whole_in_range(person->at("contractRemaining").at("value"), 0, 255);
row["insurance"] = whole_in_range(person->at("insuranceMonths"), 0, 255);
+1 -2
View File
@@ -20,8 +20,7 @@ std::string App::engine_lineup_controls() {
}
return "<div class=\"lineup-engine-controls\" style=\"position:relative;width:100%;height:100%;\"><h2>Aufstellung</h2>"
"<p class=\"lineup-engine-instruction\">Zwei Spieler zum Tauschen anklicken.</p>"
"<p class=\"lineup-engine-hint\">Der Tausch wird erst nach Bestätigung übernommen. "
"Formationen, Anweisungen und Schützen sind hier noch nicht angebunden.</p>" + pairs +
"<p class=\"lineup-engine-hint\">Der Tausch wird erst nach Bestätigung übernommen.</p>" + pairs +
"<p class=\"small muted\" style=\"position:absolute;left:0;right:0;bottom:0;\">" +
esc(engine_busy_ ? engine_operation_ : engine_notice_) + "</p></div>";
}
+12 -1
View File
@@ -5,6 +5,7 @@
#include "modern/ui/engine_live.hpp"
#include <algorithm>
#include <cctype>
#include <map>
#include <set>
@@ -268,7 +269,17 @@ Json engine_live_progress(const Json &previous, const Json &state, const Json &b
}
Json home = m.at("home"), away = m.at("away");
home["role"] = role; away["role"] = role;
out["matches"].push_back({{"id", id}, {"home", home}, {"away", away}, {"owners", owners}, {"competition", "Spieltag"},
// the desk announced this fixture with its competition; other matches stay unnamed
std::string competition = "Spieltag";
try {
const auto &next = bundle.at("desktop").at("data").at("nextFixture");
if (next.is_object() && next.at("home").at("id") == m.at("home").at("id")) {
competition = next.at("competition").value("text", competition);
std::replace(competition.begin(), competition.end(), '\n', ' ');
}
} catch (const std::exception &) {}
out["matches"].push_back({{"id", id}, {"home", home}, {"away", away}, {"owners", owners}, {"competition", competition},
{"attendance", m.value("attendance", Json())}, {"weather", m.value("weather", Json())}});
}
if (out.at("owners").empty() || out.at("matches").empty()) return failure("live_no_human_match");
+7 -6
View File
@@ -177,7 +177,7 @@ std::string App::live_ticker_events(const Json &frame, size_t &shown) {
"<div class=\"live-event-copy\">" + live_text(match.at("home").at("name").get<std::string>() + " · " + match.at("away").at("name").get<std::string>(), "live-event-owners") + "<h3>" + live_text(event.at("headline")) + "</h3><p>" + live_text(event.at("body")) + "</p></div>" + live_text(live_score_text(event.at("score")), "live-event-score") + "</article>";
++shown;
}
if (!shown) out += "<p class=\"live-note\">" + live_text(fixture.at("source") == "engine-recording" ? "Für diesen Filter liegt noch keine Meldung vor." : "Für diesen Filter liegt noch keine Demomeldung vor.") + "</p>";
if (!shown) out += "<p class=\"live-note\">" + live_text(fixture.at("source") == "engine-recording" ? "Noch keine Meldungen." : "Für diesen Filter liegt noch keine Demomeldung vor.") + "</p>";
return out;
}
std::string App::render_live() {
@@ -192,13 +192,14 @@ std::string App::render_live() {
const bool recorded = fixture.at("source") == "engine-recording";
const auto phase_text = live_.finished() ? "Beendet" : phase == "interval" ? "Halbzeit" : live_.speed() ? (recorded ? (phase == "extra_time" ? "Verlängerung" : phase == "shootout" ? "Elfmeterschießen" : "Spiel läuft") : "Aufzeichnung läuft") : (recorded ? "Pausiert" : "Gemeinsam pausiert");
const auto arrow = [&](bool right) { const auto color = theme_ == "silver" ? "#376b84" : theme_ == "matchday" ? "#efb2aa" : "#b5dbd2"; return picture(renderer_.diagram(right ? "live-arrow-right" : "live-arrow-left", "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\"><path d=\"" + std::string(right ? "M7 4l6 6-6 6" : "M13 4l-6 6 6 6") + "\" fill=\"none\" stroke=\"" + color + "\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg>", 72), 36, 36); };
std::string out = "<section id=\"live-stage\" class=\"live-stage\" data-source=\"" + std::string(recorded ? "engine-recording" : "ui-demo-fixture") + "\" data-fixture-id=\"" + esc(fixture.at("fixture_id").get<std::string>()) + "\"><header class=\"live-header\"><div>" + live_text("SPIELTAG · LIVE-TICKER", "live-eyebrow") +
std::string out = "<section id=\"live-stage\" class=\"live-stage\" data-source=\"" + std::string(recorded ? "engine-recording" : "ui-demo-fixture") + "\" data-fixture-id=\"" + esc(fixture.at("fixture_id").get<std::string>()) + "\"><header class=\"live-header\"><div>" + (recorded ? std::string() : live_text("SPIELTAG · LIVE-TICKER", "live-eyebrow")) +
"<h1>" + live_text(live_review_ ? "Ergebnisse & Bericht" : fixture.at("role") == "national" ? "Deutschland · Demo-Länderspiel" : fixture.at("surface") == "indoor" ? "Hallenpartien · 40 Minuten" : recorded ? fixture.at("matches").front().value("competition", std::string("Spieltag")) : std::string("Gemeinsamer Spieltag")) + "</h1></div>" + live_text(recorded ? fixture.value("date", std::string()) : std::string("UI-Demo · vorgegebene Ergebnisse"), "live-demo-tag") + "</header>";
const auto scoreline = [&](const Json &match) {
const auto &value = live_score_by_id(frame, match.at("id"));
return "<div class=\"live-scoreline\">" + live_text(match.at("home").at("name"), "live-team-name home") + live_badge(match.at("home"), 58) + live_text(live_score_text(value.at("score")), "live-score") + live_badge(match.at("away"), 58) + live_text(match.at("away").at("name"), "live-team-name away") + "</div>";
};
out += "<div id=\"live-underlay\" class=\"live-body\"><div class=\"live-left\"><section class=\"live-panel live-overview\"><nav class=\"live-coverage\">";
if (!(recorded && fixture.at("matches").size() == 1))
for (const auto &[id, text] : std::array<std::pair<const char *, const char *>, 3>{{{"all", "Alle Spiele"}, {"single", "Einzelspiel"}, {"conference", "Konferenz"}}})
out += btn("live-coverage", text, live_coverage_ == id ? "selected" : "", "id=\"live-coverage-" + std::string(id) + "\" data-id=\"" + id + "\"");
if (live_coverage_ == "single" && fixture.at("matches").size() > 1) out += btn("live-match-prev", arrow(false), "live-match-arrow", "id=\"live-match-prev\" aria-label=\"Vorherige Tickerpartie\"") + btn("live-match-next", arrow(true), "live-match-arrow", "id=\"live-match-next\" aria-label=\"Nächste Tickerpartie\"");
@@ -207,14 +208,14 @@ std::string App::render_live() {
if (live_coverage_ == "single" && match.at("id") != live_selected_match_) continue;
std::string names;
for (const auto &id : match.at("owners")) for (const auto &person : fixture.at("owners")) if (person.at("id") == id) { if (!names.empty()) names += " · "; names += person.at("name").get<std::string>(); }
out += "<button data-action=\"live-match\" class=\"live-game " + std::string(match.at("id") == live_selected_match_ ? "active" : "") + "\" data-live-match=\"" + esc(match.at("id").get<std::string>()) + "\" data-id=\"" + esc(match.at("id").get<std::string>()) + "\">" + live_text(names, "live-owners") + scoreline(match) + live_text(std::to_string(minute) + "′ · " + (match.at("owners").size() > 1 ? std::string("Zwei menschliche Manager") : recorded ? match.value("competition", std::string("Eine menschliche Mannschaft")) : std::string("Eine menschliche Mannschaft")), "live-card-caption") + live_text(live_match_info_text(match, fixture.at("surface") == "indoor"), "live-match-info") + "</button>";
out += "<button data-action=\"live-match\" class=\"live-game " + std::string(match.at("id") == live_selected_match_ ? "active" : "") + "\" data-live-match=\"" + esc(match.at("id").get<std::string>()) + "\" data-id=\"" + esc(match.at("id").get<std::string>()) + "\">" + (recorded && fixture.at("owners").size() == 1 ? std::string() : live_text(names, "live-owners")) + scoreline(match) + live_text(std::to_string(minute) + "′ · " + (match.at("owners").size() > 1 ? std::string("Zwei menschliche Manager") : recorded ? match.value("competition", std::string("Eine menschliche Mannschaft")) : std::string("Eine menschliche Mannschaft")), "live-card-caption") + live_text(live_match_info_text(match, fixture.at("surface") == "indoor"), "live-match-info") + "</button>";
}
out += "</div></section><section class=\"live-panel live-ticker\"><header class=\"live-panel-heading\"><h2>" + live_text("Gemeinsamer Live-Ticker") + "</h2>" + live_text(live_coverage_ == "single" ? "Gewählte Partie" : "Alle Manager", "live-small") + "</header><nav class=\"live-filters\">";
out += "</div></section><section class=\"live-panel live-ticker\"><header class=\"live-panel-heading\"><h2>" + live_text(recorded ? "Ticker" : "Gemeinsamer Live-Ticker") + "</h2>" + (recorded && fixture.at("owners").size() == 1 ? std::string() : live_text(live_coverage_ == "single" ? "Gewählte Partie" : "Alle Manager", "live-small")) + "</header><nav class=\"live-filters\">";
for (const auto &[id, label] : std::array<std::pair<const char *, const char *>, 4>{{{"all", "Alles"}, {"highlights", "Highlights"}, {"goal", "Tore"}, {"yellow", "Karten"}}}) out += btn("live-filter", label, live_filter_ == id ? "selected" : "", "id=\"live-filter-" + std::string(id) + "\" data-id=\"" + id + "\"");
out += "</nav><div id=\"live-ticker\" class=\"live-event-list\" tabindex=\"0\" aria-label=\"Gemeinsamer Ereignisverlauf\">";
size_t shown = 0;
out += live_ticker_events(frame, shown);
out += "</div><footer class=\"live-ticker-footer\">" "<span id=\"live-event-count\" class=\"live-small\">" + esc(std::to_string(shown) + (live_.fixture().at("source") == "engine-recording" ? " Meldungen" : " Meldungen · feste Aufzeichnung")) + "</span>" + "<span id=\"live-phase-status\" class=\"live-small\">" + esc(phase_text) + "</span></footer></section></div><aside id=\"live-detail\" class=\"live-detail live-panel\"><header class=\"live-panel-heading\"><div class=\"live-detail-heading\"><h2>" + "<span id=\"live-owner-team\">" + esc(owner.at("team").at("name").get<std::string>()) + "</span></h2><p><span id=\"live-owner-name\">" + esc(owner.at("name").get<std::string>()) + "</span>" + "</p></div><nav class=\"live-team-switch\" aria-label=\"Managerdetails wechseln\">" +
out += "</div><footer class=\"live-ticker-footer\">" "<span id=\"live-event-count\" class=\"live-small\">" + esc(std::to_string(shown) + (live_.fixture().at("source") == "engine-recording" ? (shown == 1 ? " Meldung" : " Meldungen") : " Meldungen · feste Aufzeichnung")) + "</span>" + "<span id=\"live-phase-status\" class=\"live-small\">" + esc(phase_text) + "</span></footer></section></div><aside id=\"live-detail\" class=\"live-detail live-panel\"><header class=\"live-panel-heading\"><div class=\"live-detail-heading\"><h2>" + "<span id=\"live-owner-team\">" + esc(owner.at("team").at("name").get<std::string>()) + "</span></h2><p><span id=\"live-owner-name\">" + esc(owner.at("name").get<std::string>()) + "</span>" + "</p></div><nav class=\"live-team-switch\" aria-label=\"Managerdetails wechseln\">" +
btn("live-owner-prev", arrow(false), "", "id=\"live-owner-prev\" aria-label=\"Vorheriger Manager\" " + std::string(fixture.at("owners").size() == 1 ? "disabled" : "")) + btn("live-owner-next", arrow(true), "", "id=\"live-owner-next\" aria-label=\"Nächster Manager\" " + std::string(fixture.at("owners").size() == 1 ? "disabled" : "")) + "</nav></header><nav class=\"live-tabs\">";
for (const auto &[id, label] : std::array<std::pair<const char *, const char *>, 5>{{{"team", "Team"}, {"tactics", "Taktik"}, {"opponent", "Gegner"}, {"table", "Live-Tabelle"}, {"stats", "Statistik"}}}) out += btn("live-tab", label, live_tab_ == id ? "selected" : "", "id=\"live-tab-" + std::string(id) + "\" data-id=\"" + id + "\" aria-pressed=\"" + (live_tab_ == id ? "true" : "false") + "\"");
out += "</nav><div id=\"live-detail-body\" class=\"live-detail-body\" tabindex=\"0\">" + live_detail(owner, frame) + "</div><footer class=\"live-detail-footer\">" + btn("live-intervene-lineup", "Aufstellung & Wechsel", "", "id=\"live-lineup-edit\" " + std::string(live_.finished() || (recorded && !live_.running()) ? "disabled" : "")) + "</footer></aside></div>";
@@ -266,7 +267,7 @@ void App::live_update_parts() {
auto *list = element("live-ticker"); auto *count = element("live-event-count");
if (!list || !count) { refresh(); return; }
size_t shown = 0; list->SetInnerRML(live_ticker_events(frame, shown));
count->SetInnerRML(esc(std::to_string(shown) + (live_.fixture().at("source") == "engine-recording" ? " Meldungen" : " Meldungen · feste Aufzeichnung")));
count->SetInnerRML(esc(std::to_string(shown) + (live_.fixture().at("source") == "engine-recording" ? (shown == 1 ? " Meldung" : " Meldungen") : " Meldungen · feste Aufzeichnung")));
list->SetScrollTop(0); live_ticker_scroll_ = 0; live_reset_ticker_ = false;
Rml::ElementList filters; doc_->QuerySelectorAll(filters, ".live-filters button");
for (auto *filter : filters)
+3 -2
View File
@@ -55,8 +55,9 @@ std::string App::render_news_feed(const Json &data) {
out += btn("news-open", esc(name), "news-message-title",
"id=\"news-read-" + id + "\" data-id=\"" + id +
"\" aria-label=\"Nachricht lesen: " + esc(name) + "\"");
out += "<p class=\"news-excerpt\">" + esc(m.at("body").get<std::string>()) +
"</p></div><div class=\"news-row-actions\">";
// a one-line message is its own headline; the excerpt would only repeat it
out += (m.at("body").get<std::string>() == name ? std::string() : "<p class=\"news-excerpt\">" + esc(m.at("body").get<std::string>()) + "</p>") +
"</div><div class=\"news-row-actions\">";
// Native CSS line-art has no private bitmap or SVG dependency.
out += btn(
"news-move",
+2 -2
View File
@@ -432,12 +432,12 @@ std::string App::render_transfer() {
const bool pending_loan = pending && chosen.at("bid").value("loan",false);
out +=
btn("transfer-offer",
mine && listed(chosen.at("id")) ? "Vom Markt nehmen" : "Ver-kaufen",
mine && listed(chosen.at("id")) ? "Vom Markt nehmen" : "Verkaufen",
"",
"id=\"transfer-offer-buy-sell\" data-kind=\"" +
std::string(mine ? "sell" : "buy") + "\" " +
std::string(chosen.is_object() && (!engine_mode_ || !mine || !listed(chosen.at("id"))) && (!pending || !pending_loan) ? "" : "disabled")) +
btn("transfer-offer", "Ver-leihen", "",
btn("transfer-offer", "Verleihen", "",
"id=\"transfer-offer-loan-lend\" data-kind=\"" +
std::string(mine ? "lend" : "loan") + "\" " +
std::string(chosen.is_object() && (!engine_mode_ || !mine || !listed(chosen.at("id"))) && (!pending || pending_loan) && (!engine_mode_ || mine || chosen.value("loan_allowed",false)) ? "" : "disabled")) +