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>
This commit is contained in:
MichaelandClaude Fable 5.2 committed 2026-11-14 12:36:33 +01:00
1 parent bd20960f90
commit 9708b720b2
33 files changed
+418 -373

No files matched your search

+48 -1
View File
@@ -8650,6 +8650,29 @@ std::vector<std::pair<std::string, ui::MailboxMessage>> ui_mailbox(const ModernS
std::vector<std::pair<std::string, ui::MailboxMessage>> out;
ui::MailboxState box;
try { box = ui::mailbox_state_from_game(g, manager); } catch (const std::exception&) { return out; }
// The stored texts name players and clubs in the fixed-width spelling of the mailbox
// ("URBIG", "HAMBURG"). Where the world has its own spelling the read shows that one;
// longer names first, so a club's full name wins over a part of it.
std::vector<std::pair<std::string, std::string>> spellings;
for (size_t t = 0; t < g.world_club_name.size(); ++t)
if (!g.world_club_name[t].empty())
spellings.emplace_back(ui::original_to_utf8(g.club_name(int(t))), g.world_club_name[t]);
for (size_t p = 0; p < g.player_last.size() && p < g.players.size(); ++p)
if (!g.player_last[p].empty())
spellings.emplace_back(ui::original_to_utf8(g.player_name(int(p))), g.player_last[p]);
std::erase_if(spellings, [](const auto& s) { return s.first.size() < 3 || s.first == s.second; });
std::stable_sort(spellings.begin(), spellings.end(), [](const auto& a, const auto& b) { return a.first.size() > b.first.size(); });
spellings.erase(std::unique(spellings.begin(), spellings.end(), [](const auto& a, const auto& b) { return a.first == b.first; }), spellings.end());
const auto letter = [](unsigned char c) { return std::isalnum(c) || c >= 0x80; };
const auto respell = [&](std::string& text) {
for (const auto& [stored, world] : spellings)
for (size_t at = text.find(stored); at != std::string::npos; at = text.find(stored, at)) {
const bool whole = (at == 0 || !letter(static_cast<unsigned char>(text[at - 1]))) &&
(at + stored.size() == text.size() || !letter(static_cast<unsigned char>(text[at + stored.size()])));
if (whole) text.replace(at, stored.size(), world), at += world.size();
else at += stored.size();
}
};
std::map<std::string, int> seen;
for (auto& m : box.messages) {
uint32_t hash = 2166136261u; // FNV-1a
@@ -8672,6 +8695,12 @@ std::vector<std::pair<std::string, ui::MailboxMessage>> ui_mailbox(const ModernS
if (whole) clean.append(m.text, i, length), i += length;
else ++i;
}
respell(clean);
// amounts carry the two-letter currency mark of the stored texts
for (size_t at = clean.find(" EU"); at != std::string::npos; at = clean.find(" EU", at + 1))
if (at > 0 && std::isdigit(static_cast<unsigned char>(clean[at - 1])) &&
(at + 3 == clean.size() || !letter(static_cast<unsigned char>(clean[at + 3]))))
clean.replace(at, 3, " €");
m.text = std::move(clean);
out.emplace_back(std::move(id), std::move(m));
}
@@ -8753,7 +8782,18 @@ cli::Json ModernSession::read_live(const cli::Json& request) const {
events.push_back(O{{"minute", value}, {"kind", kKinds[code]}, {"side", side_team == home ? "home" : "away"},
{"player", person(player)}, {"other", person(assistant)}, {"headline", headline}, {"body", body}});
}
matches.push_back(O{{"events", std::move(events)},
// the elevens that started, for the teams that play with their players
cli::Json::Object starters;
for (int side = 0; side < 2; ++side) {
const int team = side ? away : home;
if (!fields_players(g_, team)) { starters[side ? "away" : "home"] = nullptr; continue; }
const SquadRange range = squad_range(team);
cli::Json::Array eleven;
for (size_t s = 0; s < range.count && s < 11; ++s)
if (const int p = g_.squad_slots.at(range.first + s) & 0x0fff; p != 0x0fff) eleven.push_back(plain_name(p));
starters[side ? "away" : "home"] = std::move(eleven);
}
matches.push_back(O{{"events", std::move(events)}, {"lineups", std::move(starters)},
{"home", O{{"id", modern::ui_team_id(g_, home)}, {"name", club_label(home)}}},
{"away", O{{"id", modern::ui_team_id(g_, away)}, {"name", club_label(away)}}},
{"homeManagerId", hm >= 0 ? cli::Json(modern::ui_manager_id(g_, hm)) : cli::Json(nullptr)},
@@ -8964,7 +9004,14 @@ cli::Json ModernSession::ui_read(const cli::Json& request, uint64_t revision) co
matching && !desk.national_team ? curve.current_position : std::nullopt,
matching ? curve.strength : std::nullopt);
}
// the own club's table places of the season so far and its last recorded matches
A places;
if (!desk.national_team)
for (const auto &sample : desk.rank_curves[0].samples)
if (sample.source_rank >= 0 && sample.source_rank < 24) places.push_back(int64_t(sample.source_rank + 1));
return modern::ui_snapshot(g_, context, request_id, O{{"kind", "desktop-widgets"},
{"rankCurve", std::move(places)},
{"recent", modern::recent_results(g_, modern::ui_team_id(g_, g_.manager_teams[size_t(manager)]), 6)},
{"own", summary(g_.manager_teams[size_t(manager)],
desk.national_team ? std::nullopt : desk.table_position, desk.strength)},
{"opponent", std::move(opponent)}, {"warnings", std::move(warnings)},