From b845bbfcbc112d4cbfdc25704e1b687efc02aca7 Mon Sep 17 00:00:00 2001 From: Codex Date: Tue, 27 Oct 2026 10:59:45 +0100 Subject: [PATCH] Show attendance and weather before live ticker kickoff (by Codex) --- assets/modern/live.rcss | 3 ++- docs/new_ui/desktop/live/README.md | 24 ++++++++++++++++++++ src/modern/ui/demo_live.cpp | 22 +++++++++++++++++++ src/modern/ui/demo_post_match.cpp | 21 +++++++++++++----- src/modern/ui/live_match_info.hpp | 33 ++++++++++++++++++++++++++++ src/modern/ui/live_screens.inc | 2 +- src/modern/ui/postmatch_screens.inc | 15 +++++++++---- src/modern/ui/view.cpp | 1 + tests/modern_live_ui_tests.cpp | 22 +++++++++++++++++++ tests/modern_post_match_ui_tests.cpp | 15 ++++++++++--- 10 files changed, 144 insertions(+), 14 deletions(-) create mode 100644 src/modern/ui/live_match_info.hpp diff --git a/assets/modern/live.rcss b/assets/modern/live.rcss index 583bb22..b6c8816 100644 --- a/assets/modern/live.rcss +++ b/assets/modern/live.rcss @@ -23,7 +23,7 @@ body.matchday {--live-bg:#242426;--live-surface:#302f34ec;--live-wash:#efc7ce0a; .live-coverage button {height:72dp;padding:0 26dp;font-size:32dp;} .live-clock {display:block;margin-left:auto;color:var(--live-accent);font-size:44dp;flex-shrink:0;} .live-cards {padding:24dp;display:flex;flex-wrap:wrap;gap:20dp;} -.live-stage .live-game {width:48%;flex-grow:1;flex-shrink:0;height:178dp;min-width:0;display:block;border:2dp var(--live-line);border-radius:22dp;background-color:var(--live-wash);padding:12dp 22dp;} +.live-stage .live-game {width:48%;flex-grow:1;flex-shrink:0;height:218dp;min-width:0;display:block;border:2dp var(--live-line);border-radius:22dp;background-color:var(--live-wash);padding:12dp 22dp;} .live-coverage .live-match-arrow {width:70dp;padding:0;} .live-cards.single .live-game {width:100%;} .live-game.active {border-color:var(--live-accent);} @@ -34,6 +34,7 @@ body.matchday {--live-bg:#242426;--live-surface:#302f34ec;--live-wash:#efc7ce0a; .live-team-name.away {text-align:left;} .live-score {display:block;font-size:64dp;font-weight:normal;flex-shrink:0;text-align:center;min-width:134dp;white-space:nowrap;} .live-card-caption {display:block;font-size:22dp;color:var(--live-muted);text-align:center;margin-top:8dp;} +.live-match-info {display:block;font-size:25dp;line-height:1.3;color:var(--live-muted);text-align:center;margin-top:8dp;white-space:nowrap;} .live-badge {display:flex;align-items:center;justify-content:center;flex-shrink:0;} .live-ticker {display:flex;flex-direction:column;flex:1;min-height:0;} .live-panel-heading {height:108dp;padding:24dp 42dp;display:flex;align-items:center;justify-content:space-between;gap:24dp;border-bottom:2dp var(--live-line);flex-shrink:0;} diff --git a/docs/new_ui/desktop/live/README.md b/docs/new_ui/desktop/live/README.md index af45075..72de66c 100644 --- a/docs/new_ui/desktop/live/README.md +++ b/docs/new_ui/desktop/live/README.md @@ -175,3 +175,27 @@ Der Treiber erfindet keine Livezustände: Klick, Taste, Mausrad und Wartezeit laufen durch die normalen RmlUI-/SDL-Pfade. Die JSON-/DOM-/Geometrieproben und PNG-Ausgaben bleiben am angegebenen Ziel. Für den eigenen Xvfb werden ein installiertes `Xvfb` oder alternativ `--display` benötigt. + + +## Zuschauer und Wetter vor dem Start + +Jede eindeutige Partie zeigt bereits bei Sequenz 0 ihre Zuschauerzahl und das +Wetter. Die Zeile bleibt während der Wiedergabe sichtbar; die Halle zeigt „Halle“ +statt Außenwetter. Zwei gegnerische menschliche Manager teilen dieselbe Partie +und damit dieselben Bedingungen. Die Werte werden auch in den Nachspielbericht +übernommen; eine Übersicht zählt jede Partie nur einmal. + +Die optionalen Felder auf jedem `openbmh-live-fixture@1.matches[]`-Eintrag sind: + +```json +{"attendance": 26400, "weather": {"temperature": 18, "rain": 0}} +``` + +`attendance` ist eine nichtnegative Ganzzahl (bis INT32_MAX), `temperature` +eine vorzeichenbehaftete Celsius-Ganzzahl (-128…127). `rain` ist der originale +Wetterbild-Code 0…7, kein Prozentwert: sonnig, heiter, wolkig, bedeckt, Regen, +Regen, Schnee, Schnee. Es werden keine Wetterwerte aus der Temperatur abgeleitet. +Fehlende oder `null`-Werte bleiben unbekannt; 0 Zuschauer und 0 °C bleiben +sichtbar. Alte Aufnahmen ohne diese Felder sind weiterhin gültig. Die mitgelieferte +UI-Demo enthält explizite Beispieldaten, ohne RNG, Uhr, Revision oder Karriere zu +verändern. Ein autoritativer Anbieter liefert die tatsächlichen Bedingungen. diff --git a/src/modern/ui/demo_live.cpp b/src/modern/ui/demo_live.cpp index 034c346..39767f3 100644 --- a/src/modern/ui/demo_live.cpp +++ b/src/modern/ui/demo_live.cpp @@ -196,6 +196,14 @@ Json make_demo_live(const Catalog &world, const Json &state, uint64_t revision) } const auto identity = Json{{"world", world.manifest().value("id", "")}, {"date", state.at("date")}, {"role", role}, {"surface", surface}, {"matches", matches}}; + // Explicit presentation examples, separate from the authored event tape. + // Add after identity construction so existing fixture/match/event IDs stay + // compatible. Real providers supply their own recorded conditions. + for (size_t i = 0; i < matches.size(); ++i) { + matches[i]["attendance"] = indoor ? 2200 + int(i) * 350 : 26400 + int(i) * 4750; + matches[i]["weather"] = indoor ? Json() : Json{{"temperature", 18 + int(i)}, + {"rain", std::array{0,2,4,1}[i]}}; + } return {{"ok", true}, {"schema", "openbmh-live-fixture@1"}, {"source", "ui-demo-fixture"}, {"fixture_id", "ui-live:" + fingerprint(identity.dump())}, {"source_revision", revision}, {"world", world.manifest().value("id", "")}, {"date", state.at("date")}, @@ -243,6 +251,20 @@ bool valid_live_fixture(const Json &v) { } } for (const auto &match : v.at("matches")) { + if (match.contains("attendance") && !match.at("attendance").is_null() && + !uint_value(match.at("attendance"), INT32_MAX)) return false; + if (match.contains("weather") && !match.at("weather").is_null()) { + const auto &weather = match.at("weather"); + if (!weather.is_object()) return false; + if (weather.contains("temperature") && !weather.at("temperature").is_null() && + (!weather.at("temperature").is_number_integer() || + (weather.at("temperature").is_number_unsigned() && + weather.at("temperature").get() > 127) || + weather.at("temperature").get() < -128 || + weather.at("temperature").get() > 127)) return false; + if (weather.contains("rain") && !weather.at("rain").is_null() && + !uint_value(weather.at("rain"), 7)) return false; + } if (!string_value(match.at("id")) || !match_ids.insert(match.at("id")).second || !match.at("owners").is_array() || match.at("owners").empty()) return false; for (auto side : {"home", "away"}) diff --git a/src/modern/ui/demo_post_match.cpp b/src/modern/ui/demo_post_match.cpp index 21a1465..95e1574 100644 --- a/src/modern/ui/demo_post_match.cpp +++ b/src/modern/ui/demo_post_match.cpp @@ -121,8 +121,9 @@ Json report(const Json &fixture, const Json &match, int minute) { // no player actor, assist or exact playing-time/ratings, so none is inferred. out["events"] = match_events(frame->at("events"), match.at("id")); out["timeline"] = match_events(frames.back().at("events"), match.at("id")); - out["attendance"] = nullptr; - out["attendance_reason"] = "not_recorded"; + out["attendance"] = match.value("attendance", Json()); + out["attendance_reason"] = out["attendance"].is_null() ? "not_recorded" : "recorded"; + out["weather"] = match.value("weather", Json()); out["actor"] = nullptr; out["assists"] = nullptr; out["ratings"] = nullptr; out["playing_minutes"] = nullptr; return out; @@ -145,14 +146,19 @@ Json make_demo_post_match(const Json &fixture, size_t completed_sequence, const out["matches"] = Json::array(); out["tables"] = Json::array(); Json totals = {{"games", fixture.at("matches").size()}, {"goals", 0}, {"yellow", 0}, {"red", 0}, {"chances", 0}, - {"attendance", nullptr}, {"attendance_reason", "not_recorded"}, + {"attendance", int64_t(0)}, {"attendance_reason", "recorded"}, {"scope", "recorded_human_matches"}}; + bool crowds_known = true; for (const auto &match : fixture.at("matches")) { const auto &final = match_snapshot(last, match.at("id")); auto row = match; row["final"] = final; row["events"] = match_events(last.at("events"), match.at("id")); - row["attendance"] = nullptr; row["attendance_reason"] = "not_recorded"; + row["attendance"] = match.value("attendance", Json()); + row["attendance_reason"] = row["attendance"].is_null() ? "not_recorded" : "recorded"; + row["weather"] = match.value("weather", Json()); + if (row["attendance"].is_null()) crowds_known = false; + else totals["attendance"] = totals.at("attendance").get() + row.at("attendance").get(); out["matches"].push_back(std::move(row)); for (auto key : {"yellow", "red", "chances"}) totals[key] = totals.at(key).get() + final.at(key)[0].get() + final.at(key)[1].get(); @@ -170,9 +176,14 @@ Json make_demo_post_match(const Json &fixture, size_t completed_sequence, const {"wins", nullptr}, {"draws", nullptr}, {"losses", nullptr}}); } } + if (!crowds_known) { + totals["attendance"] = nullptr; + totals["attendance_reason"] = "not_recorded"; + } out["overview"] = std::move(totals); out["eleven"] = {{"available", false}, {"reason", "not_recorded"}, {"rows", Json::array()}}; - out["unknown_fields"] = Json::array({"attendance", "actor", "assists", "ratings", "playing_minutes", "eleven", "wins", "draws", "losses"}); + out["unknown_fields"] = Json::array({"actor", "assists", "ratings", "playing_minutes", "eleven", "wins", "draws", "losses"}); + if (!crowds_known) out["unknown_fields"].push_back("attendance"); if (const auto *error = attach_records(out, fixture, records)) return failure(error); return out; } catch (const std::exception &) { return failure("invalid_post_match_fixture"); } diff --git a/src/modern/ui/live_match_info.hpp b/src/modern/ui/live_match_info.hpp new file mode 100644 index 0000000..65ca402 --- /dev/null +++ b/src/modern/ui/live_match_info.hpp @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: GPL-3.0-only +#pragma once +#include "modern/ui/catalog.hpp" +#include + +namespace bmh::modern_ui { +// The rain code selects the original eight weather pictograms. It is not a +// precipitation percentage or a temperature-based forecast. +inline std::string live_weather_label(int code) { + static constexpr std::array labels{ + "sonnig", "heiter", "wolkig", "bedeckt", "Regen", "Regen", "Schnee", "Schnee"}; + return code >= 0 && code < int(labels.size()) ? labels[size_t(code)] : "Wetter —"; +} +inline std::string live_attendance_text(const Json &match) { + if (!match.contains("attendance") || !match.at("attendance").is_number_integer()) + return "Zuschauer —"; + const auto count = match.at("attendance").get(); + if (count < 0) return "Zuschauer —"; + auto text = std::to_string(count); + for (int at = int(text.size()) - 3; at > 0; at -= 3) text.insert(size_t(at), "."); + return text + " Zuschauer"; +} +inline std::string live_match_info_text(const Json &match, bool indoor) { + auto text = live_attendance_text(match); + if (indoor) return text + " · Halle"; + const auto weather = match.value("weather", Json()); + if (!weather.is_object()) return text + " · Wetter —"; + if (weather.contains("temperature") && weather.at("temperature").is_number_integer()) + text += " · " + std::to_string(weather.at("temperature").get()) + " °C"; + const auto rain = weather.value("rain", Json()); + return text + " · " + (rain.is_number_integer() ? live_weather_label(rain.get()) : "Wetter —"); +} +} // namespace bmh::modern_ui diff --git a/src/modern/ui/live_screens.inc b/src/modern/ui/live_screens.inc index 0ac34bd..6b751c6 100644 --- a/src/modern/ui/live_screens.inc +++ b/src/modern/ui/live_screens.inc @@ -162,7 +162,7 @@ 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(); } - out += ""; + out += ""; } out += "

" + live_text("Gemeinsamer Live-Ticker") + "

" + live_text(live_coverage_ == "single" ? "Gewählte Partie" : "Alle Manager", "live-small") + "