Implement calibrated Modern stadium periphery preview and staged upgrades (by Codex)
This commit is contained in:
1 parent
fff2cc2f0b
commit
bfcf9a07bf
12 files changed
+470
-37
No files matched your search
@@ -135,3 +135,11 @@ body.matchday .stadium-dialog-action.primary:not([disabled]) {decorator:none;bac
|
||||
body.silver .stadium-block[disabled],body.matchday .stadium-block[disabled] {opacity:.85;border-color:#d8b77f52;background-color:#b6955d0d;}
|
||||
|
||||
.stadium-place-label>span {display:block;width:100%;white-space:nowrap;}
|
||||
|
||||
.stadium-periphery-scene {position:absolute;left:0;top:134dp;width:2612dp;height:1469.25dp;overflow:hidden;}
|
||||
.stadium-scene-sprite,.stadium-periphery-preview {position:absolute;display:block;pointer-events:none;}
|
||||
.stadium-periphery-hit,.stadium-periphery-hit:hover,.stadium-periphery-hit:focus,.stadium-periphery-hit:active {position:absolute;display:block;box-sizing:border-box;padding:0;margin:0;border:0;border-radius:0;background-color:transparent;decorator:none;opacity:1;}
|
||||
.stadium-periphery-hit .control-label {display:none;}
|
||||
#stadium-interaction-hint {position:absolute;left:0;top:1636dp;width:2612dp;height:56dp;line-height:56dp;text-align:center;font-size:29dp;color:var(--muted);margin:0;}
|
||||
#stadium-interaction-hint>span {display:block;width:100%;white-space:nowrap;}
|
||||
.stadium-nav-button.half {width:1295dp;}
|
||||
@@ -119,8 +119,9 @@ wird ausdrücklich mit `OPENBMH_BUILD_MODERN_UI=ON` gebaut.
|
||||
Sitzplätzen und Überdachung, acht Ausstattungsbereiche mit eigenen
|
||||
Stufengrafiken, lokalen Bauentwürfen, Kostenprüfung und Vormerkungen.
|
||||
Aktuell/Zukunft, Stadiondaten mit sechs Demo-Kurven und der gemeinsame
|
||||
Eintrittspreis sind umgesetzt. Der Peripherieausbau bleibt ausdrücklich
|
||||
für das angekündigte Redesign zurückgestellt; das Panorama ist nur Ansicht.
|
||||
Eintrittspreis sind umgesetzt. Das kalibrierte Stadionumfeld ergänzt 14
|
||||
unsichtbare Trefferflächen mit Untertiteln, einzelne nächste Ausbaustufen,
|
||||
Baustellen und eine umschaltbare fertige Zukunftsvorschau.
|
||||
|
||||
- [Statistiken](desktop/statistics/README.md): neun Auswertungen mit
|
||||
Möglichkeiten, Transferhistorie, sechs Analytics-Kurven, ewigen Tabellen,
|
||||
|
||||
@@ -44,7 +44,7 @@ Implementierung in der Spiel-Engine.
|
||||
| Spielerstatistiken | [Tore, Vorlagen, Karten, Fotokarten und Bereichsauswahl](desktop/scorers/README.md) |
|
||||
| Fairplay | [Strafpunkte, Karten und Vereinsprofile](desktop/fairplay/README.md) |
|
||||
| Highscore | [Manager-Rangliste und zentrierte Kennzahlen](desktop/highscore/README.md) |
|
||||
| Stadion | [Blöcke A–H, Ausstattung und Stadiondaten ohne Peripherieausbau](desktop/stadium/README.md) |
|
||||
| Stadion | [Blöcke A–H, Ausstattung, kalibriertes Stadionumfeld und Stadiondaten](desktop/stadium/README.md) |
|
||||
| Statistiken | [Neun Auswertungen, Siegerlisten, Analytics und Pokalbilder](desktop/statistics/README.md) |
|
||||
| Einstellungen | [Vier Kategorien, Optionssuche, Automatik und globale UI-Voreinstellungen](desktop/settings/README.md) |
|
||||
| Nachrichten | [Tablet, Postfach, Archiv, Suche, Rückgängig und Desktopvorschau](desktop/news/README.md) |
|
||||
|
||||
@@ -3,16 +3,19 @@
|
||||
<!-- provider:start -->
|
||||
## Demo-Datenprovider und Bauvormerkungen
|
||||
|
||||
Stand: 25. Oktober 2026. Die Preis- und Bauvorlagen stammen aus dem
|
||||
Stand: 26. Oktober 2026. Die Preis- und Bauvorlagen der Innenansicht stammen aus dem
|
||||
privaten HTML-Stand `69eec91c`, `desktop/stadium-menus.js`. Der native
|
||||
Provider in [demo_stadium.hpp](../../../../src/modern/ui/demo_stadium.hpp)
|
||||
und [demo_stadium.cpp](../../../../src/modern/ui/demo_stadium.cpp) übernimmt
|
||||
ausschließlich die acht Stadionblöcke und acht Ausstattungseinträge.
|
||||
**Sämtlicher Peripheriebau ist ausdrücklich ausgeschlossen.**
|
||||
die acht Stadionblöcke, acht Ausstattungseinträge und vierzehn unabhängige
|
||||
Umfeldstandorte. Die kalibrierte Umfeldgestaltung stammt aus dem privaten
|
||||
Sprite-Studio-Commit `82914ae809b12f69c6abfaa7addfcecc7378dd81`.
|
||||
|
||||
`state.stadium` enthält genau `club`, `budget`, `blocks` und `facilities`.
|
||||
`state.stadium` enthält genau `club`, `budget`, `blocks`, `facilities` und
|
||||
`periphery`.
|
||||
Ein Block besitzt `places`, `seats`, `roof` und `job`; eine Einrichtung
|
||||
`level` und `job`. Laufende Aufträge enthalten Zielwerte, Wochen und
|
||||
`level` und `job`; dies gilt auch für die vierzehn Umfeldstandorte.
|
||||
Laufende Aufträge enthalten Zielwerte, Wochen und
|
||||
Kosten. Eintritt bleibt ausschließlich im gemeinsamen obersten
|
||||
Modellfeld `ticket`. Ansicht, Zukunftsschalter, Kurven, Filter und
|
||||
Dialogentwürfe gehören zur lokalen App-Navigation.
|
||||
@@ -46,7 +49,7 @@ Stufendifferenz, Wochen bleiben die feste Vorlage des Eintrags.
|
||||
|
||||
Der einzige Providerbefehl lautet `{kind:"build",request:...}`. Der
|
||||
Blockrequest enthält genau `kind`, `index`, `places`, `seats`, `roof`,
|
||||
der Ausstattungsrequest `kind`, `index`, `level`. Beim Commit wird die
|
||||
der Ausstattungs- beziehungsweise Peripherierequest `kind`, `index`, `level`. Beim Commit wird die
|
||||
Quote erneut aus dem aktuellen Bestand berechnet. Ungültige Stufen,
|
||||
Abbau, laufende Aufträge, No-op, Doppelbuchung oder unzureichendes
|
||||
Baubudget werden atomar abgewiesen. Zusätzliche fremde Aktions- oder
|
||||
@@ -54,8 +57,9 @@ Zustandsfelder werden nicht still übernommen. Restbudget plus Summe
|
||||
sämtlicher korrekt bepreister laufender Aufträge bleibt stets exakt
|
||||
50.000.000 angezeigte Einheiten.
|
||||
|
||||
`migrate_demo_stadium()` ergänzt nur ein vollständig fehlendes
|
||||
Stadionobjekt. Ein bestehender fehlerhafter Bestand wird unverändert
|
||||
`migrate_demo_stadium()` ergänzt ein vollständig fehlendes Stadionobjekt
|
||||
oder erweitert einen gültigen alten Vierfelderbestand um die Peripherie.
|
||||
Ein bestehender fehlerhafter Bestand wird unverändert
|
||||
abgewiesen, nicht repariert. Verein und Stadionname werden über echte
|
||||
Katalogreferenzen gebunden; ohne vorhandenen Stadionnamen erscheint
|
||||
„Stadion“. Die fiktiven Blöcke und Stufen werden weder aus der OBW-
|
||||
@@ -66,7 +70,7 @@ Katalog benötigt keine erfundenen Vereins- oder Stadion-IDs.
|
||||
an die Währungspräzision gebunden und Aufträge werden streng gegen die
|
||||
Preisformeln sowie die Budgetsumme validiert. Die Ansicht verwendet
|
||||
vorhandene Katalogidentität statt des festen HTML-Stadionnamens. Es gibt
|
||||
keinen Peripheriezustand und keine Peripherieaktion in diesem Paket.
|
||||
keine automatische Bauabwicklung in diesem Paket.
|
||||
|
||||
Ein vorgemerkter Block zählt in der aktuellen Kapazität als gesperrt
|
||||
mit null Plätzen; die Zukunftsansicht zählt seine Zielkapazität. Dies
|
||||
@@ -99,6 +103,88 @@ Die Stadiondaten besitzen sechs deterministische Vorschaukurven über 24 Spielta
|
||||
|
||||
Die Preisknöpfe 00–25 verwenden den gemeinsamen obersten Sourcewert `ticket`. Ein anderer Preis öffnet eine explizite Bestätigung; erst deren Annahme führt den gebundenen Ticketbefehl aus. Auswahl des bereits aktuellen Preises ist ein No-op. Abbruch verändert weder Ticket noch Revision. Der gemeinsame Ticketpopover wird nicht zur Vorabzuweisung eines angeklickten Preises missbraucht; es gibt keinen zweiten Stadion-Ticketzustand.
|
||||
|
||||
Die Panoramaansicht ist ausschließlich ein unverändertes Bild mit proportionaler Darstellung. „Peripherie bauen“ bleibt dort deaktiviert und hat keinen Actionhandler. Es gibt keine Peripherie-Hotspots, Bauentwürfe, Kräne, Modellfelder oder Jobs. Die ausdrückliche Nutzer-Ausnahme zur Peripherie bleibt vollständig gewahrt.
|
||||
Die Panoramaansicht setzt die unveränderten 34 PNGs anhand des kalibrierten
|
||||
Exports zusammen. Die 1920 × 1080 große Referenzfläche wird proportional in den
|
||||
Stadioninhalt eingepasst. PNG-Leinwände, Alpha, Anker, Versätze, Skalierungen,
|
||||
Objekt-IDs und stabile Z-Reihenfolge bleiben erhalten. Die sichtbare Szene
|
||||
enthält ausschließlich die Bilder; unsichtbare Trefferflächen tragen weder
|
||||
Rahmen noch eingeblendete Objektnamen. Maus oder Tastaturfokus zeigen den
|
||||
Funktionsnamen als Untertitel unter dem Bild, bei Bauaufträgen zusätzlich
|
||||
„noch … Wochen“. Unten stehen genau „Zurück“ zur Innenansicht und der
|
||||
umschaltbare Knopf „Zukunft“. Zukunft zeigt die vorgemerkten Bauten fertig,
|
||||
ohne sie im Demomodell abzuschließen.
|
||||
|
||||
Verkehr (ID 0) besitzt Stufen 0–4, Parkplatz (ID 4) Stufen 0–3, alle anderen
|
||||
Standorte 0–1. IDs 1–5 sind Arcade-Spielhalle, Einkaufszentrum, Clubhaus,
|
||||
Parkplatz und Restaurant; IDs 6–9 vier unabhängige Imbissbuden, IDs 10–13
|
||||
vier unabhängige Fan-Shops. Jeder Umfeldauftrag erlaubt genau die nächste
|
||||
Stufe. Eine vorhandene Stufe 1 kann hier nur auf 2 erweitert werden; die
|
||||
Innenausstattungen behalten ihre eigene Mehrstufenwahl. Der Umfeldbau öffnet
|
||||
Vorschau, Zielstufe, fiktive Kosten und feste Bauzeit mit „Bauen“/„Abbrechen“.
|
||||
Laufende oder vollständig ausgebaute Standorte bleiben für neue Aufträge
|
||||
gesperrt und für Untertitel erreichbar.
|
||||
|
||||
Im aktuellen Bild verwendet ein Verkehrsbau bereits das Zielpanorama plus
|
||||
Baumarker. IDs 1–5 zeigen Zielgebäude und zugehöriges Baustellenoverlay,
|
||||
IDs 6–13 ausschließlich ihren Marker bis zur Zukunftsvorschau. Das Panorama
|
||||
bleibt Wiese/Wald ohne Skyline oder Animation. Die Stadionvariante folgt der
|
||||
physischen fertigen Blockgröße, in Zukunft der Zielkapazität; gesperrte Blöcke
|
||||
verkleinern nur die verfügbare Kapazitätszahl, nicht die fertige Stadiongrafik.
|
||||
Die fünf Variantengrenzen lauten 10.000/25.000/50.000/75.000/100.000.
|
||||
Der Vollausbauzustand des Exports ist ausschließlich Referenz, kein Startbestand.
|
||||
Die Demo startet Verkehr/Parkplatz/Restaurant auf Stufe 1, andere Standorte auf 0.
|
||||
|
||||
Die Umfeldpreise pro Stufe sind in angezeigten Einheiten 700.000/800.000/
|
||||
1.800.000/650.000/450.000/550.000, je Imbiss 90.000 und je Fan-Shop 140.000.
|
||||
Bauwochen sind 12/14/28/16/9/12, je Imbiss 4 und je Fan-Shop 6. Diese Werte
|
||||
sind ausdrücklich lokale Demoannahmen. Es gibt keinen Wochenfortschritt,
|
||||
keine Fertigstellungsaktion und keinen Bauabbruch nach Buchung; „Abbrechen“
|
||||
im Dialog verwirft ausschließlich den ungebuchten Entwurf. Engine, echte
|
||||
Finanzen und Weltdateien bleiben unberührt.
|
||||
|
||||
Der getrennte GUI-Import erfolgt nach der allgemeinen GUI-Vorbereitung mit
|
||||
`python3 tools/modern_ui/prepare_stadium_assets.py --studio /path/to/sprite-studio
|
||||
--output /path/to/gui-resources`. Der Befehl prüft den freigegebenen Exporthash
|
||||
`7e3e6a013703b392964a0151b17b00d40fb582ea6f51ce125345e080e49cbada`
|
||||
sowie sämtliche Bildhashes und nativen Abmessungen vor dem Kopieren. Bilder
|
||||
und private Konfiguration werden nicht Teil des öffentlichen Quellbestands.
|
||||
Fehlende Umfeldressourcen ergeben eine explizite Meldung im GUI.
|
||||
|
||||
View, Zukunftswahl, sechs Kurvenschalter, Skala, Dialog und Entwurf liegen nur in `stadium_view_`. Der gemeinsame Build einschließlich der parallel übernommenen M9-Engineänderungen und alle 29 Regressionstests bestehen. Die native Grundmatrix umfasst alle drei Themes bei 720p/1080p, sämtliche Block-/Facility-Zuordnungen, alle Stufenzuschnitte, aktuelle/geplante Darstellung und Datenansichten. Fünf funktionale Läufe prüfen lokale Entwürfe, Schrittfehler, genau eine Budgetbuchung, Pending-Sperren, gemeinsame Ticketwerte 0/25 in Desktop/Bilanz und einen echten Checkpoint-Neustart. Die gezielten Abschlussläufe bestätigen den Bildbeschnitt, die sichtbare Kapazitätsbeschriftung und Home/End am tatsächlich per Maus fokussierten Regler; die Navigation zum richtigen Range erfolgt über dessen interne Vorfahren. Ein eigener unabhängiger Abschluss besteht 27/27 Prüfungen mit identischem Quellmodell und Checkpoint nach Cancel. Alle früheren Aufnahmen behalten ihre tatsächlichen Runtimehashes. Die privaten Bilder, UI-Demostände und Replays liegen unter `docs/qa/stadium-batch-2026-10-25/`. Dies ist eine Linux-/OpenGL-Bildprüfung; eine visuelle Windows-/macOS-Laufzeitabnahme wird daraus nicht abgeleitet.
|
||||
|
||||
|
||||
## Prüfung des kalibrierten Umfelds · 26. Oktober 2026
|
||||
|
||||
Der Linux-/OpenGL-Build mit höchstens zwei parallelen Baujobs besteht. Nach
|
||||
vollständigem Neulinken der Modern-Testprogramme bestehen alle 30
|
||||
`modern_*`-Tests. Zusätzlich zur bisherigen Innenprüfung decken die synthetischen
|
||||
Tests alle vierzehn Standorte, jede nächste Verkehr-/Parkplatzstufe,
|
||||
übersprungene Ziele, laufende Aufträge, Budgeterhaltung in beiden
|
||||
Währungspräzisionen, JSON-Roundtrip und alte gültige Vierfelderbestände ab.
|
||||
Die echte DemoSource-Grenze prüft Vormerkung, Revision, Stale-/Doppelsperre,
|
||||
Speichern/Laden und Migration. Fehlerhafte Bestände bleiben unverändert.
|
||||
Der Szenentest prüft alle Kapazitätsgrenzen direkt darunter und exakt darauf,
|
||||
kalibrierte Anker/Hitflächen, stabile Ebenen sowie Baustellen/Zukunft und
|
||||
unveränderte Exportdaten. Der Import weist beschädigte PNGs und einen
|
||||
veränderten Kalibrierungsexport vor einer Ausgabeänderung ab.
|
||||
|
||||
Die privaten nativen Bediennachweise, Eingabeskripte, Screenshots, DOMs,
|
||||
Runtime-/Inputhashes und ladbaren Demo-Checkpoints liegen im lokalen Bündel
|
||||
`periphery-2026-10-26/`. Drei Themes bei 1280 × 720 und 1920 × 1080 prüfen
|
||||
Bildproportionen, Trefferflächen und Untertitel. Weitere Läufe prüfen alle
|
||||
14 unabhängigen Neubauten, Abbrechen/Escape ohne Modelländerung,
|
||||
Tab/Leertaste/Escape, ausgebaut gesperrte Standorte, je einen Auftrag pro
|
||||
Revision, Bauwochen-Untertitel, aktuelle Marker/Overlays, fertige Zukunft,
|
||||
Rückkehr zur Innenansicht sowie echten Neustart mit laufenden Aufträgen.
|
||||
Fertige Fixturestände prüfen Verkehr 0–4 und Parkplatz 0–3. Insgesamt bestehen
|
||||
171/171 strukturierte Prüfungen aus 15 finalen nativen Läufen sowie zwei
|
||||
Import-Ablehnungsprüfungen; das Bündel enthält 130 finale Screenshots. Die bereits
|
||||
abgenommenen privaten Belege vom 25. Oktober bleiben historisch erhalten.
|
||||
|
||||
Das bestehende Innen-Demomodell endet bei zusammen 96.000 Plätzen. Der
|
||||
vollständig ausgebaute native Fixturestand verwendet daher die fünfte
|
||||
Stadiongrafik. Die sechste Grafik ab 100.000 und ihre Grenzwahl werden
|
||||
synthetisch geprüft; durch die derzeitigen Innen-Demoaktionen ist dieser
|
||||
Stand nicht erreichbar. Baufortschritt, Fertigstellung und Abbruch eines
|
||||
gebuchten Auftrags bleiben offene Engineentscheidungen. Die Prüfung belegt
|
||||
keine Windows-/macOS-Laufzeitabnahme und keine neue Classic-Freigabe.
|
||||
@@ -296,3 +296,12 @@ Der vorher reproduzierte Texturverlust der Standardansichts-Vorschau wird
|
||||
vor/nach abgebrochener Managerwahl mit Quelle, Dirty-Marke, Layout und
|
||||
pixelidentischer wiedergeöffneter Vorschau kontrolliert. Diese Protokolle
|
||||
bleiben im privaten `docs/qa/opening-batch-2026-10-26`.
|
||||
|
||||
|
||||
Am 26. Oktober ergänzt der kalibrierte Sprite-Studio-Export `82914ae8` das
|
||||
[Stadionumfeld](desktop/stadium/README.md). Die bisherige Zurückstellung im
|
||||
obigen historischen Stadionabschluss ist damit aufgehoben. Vierzehn Standorte
|
||||
verwenden unsichtbare Trefferflächen und Untertitel, genau zwei Navigationsknöpfe,
|
||||
strikt einzelne nächste Ausbaustufen sowie aktuelle Baustellen und fertige
|
||||
Zukunftsvorschau. Dies bleibt ein Demoanbieter ohne Bauzeitfortschritt oder
|
||||
Engineanbindung. Die neue Prüfung und ihre Grenzen stehen im Stadiondokument.
|
||||
@@ -20,6 +20,18 @@ constexpr std::array<const char *, 8> facility_names{
|
||||
"Rasenzustand", "Stadionkomfort", "Stadionzustand", "Stadionsicherheit"};
|
||||
constexpr std::array<int, 8> facility_rates{250000,350000,850000,1200000,180000,200000,300000,400000};
|
||||
constexpr std::array<int, 8> facility_weeks{12,15,16,18,8,5,10,14};
|
||||
constexpr std::array<const char *, 14> periphery_names{
|
||||
"Verkehrsanbindung", "Arcade-Spielhalle", "Einkaufszentrum", "Clubhaus", "Parkplatz", "Restaurant",
|
||||
"1. Imbissbude", "2. Imbissbude", "3. Imbissbude", "4. Imbissbude",
|
||||
"1. Fan-Shop", "2. Fan-Shop", "3. Fan-Shop", "4. Fan-Shop"};
|
||||
constexpr std::array<int, 14> periphery_rates{700000,800000,1800000,650000,450000,550000,90000,90000,90000,90000,140000,140000,140000,140000};
|
||||
constexpr std::array<int, 14> periphery_weeks{12,14,28,16,9,12,4,4,4,4,6,6,6,6};
|
||||
int periphery_cap(size_t index) { return index == 0 ? 4 : index == 4 ? 3 : 1; }
|
||||
Json initial_periphery() {
|
||||
Json rows = Json::array();
|
||||
for (size_t i = 0; i < 14; ++i) rows.push_back({{"level", i == 0 || i == 4 || i == 5 ? 1 : 0}, {"job", nullptr}});
|
||||
return rows;
|
||||
}
|
||||
bool keys(const Json &value, std::initializer_list<const char *> expected) {
|
||||
return value.is_object() && value.size() == expected.size() &&
|
||||
std::all_of(expected.begin(), expected.end(), [&](auto *key) { return value.contains(key); });
|
||||
@@ -77,7 +89,7 @@ Json demo_stadium(const Catalog &world, const std::string &club) {
|
||||
facilities.push_back({{"level", initial_levels[i]}, {"job", nullptr}});
|
||||
}
|
||||
return {{"club", owner(world, nullptr, club)}, {"budget", budget_units * finance_currency_factor(world)},
|
||||
{"blocks", blocks}, {"facilities", facilities}};
|
||||
{"blocks", blocks}, {"facilities", facilities}, {"periphery", initial_periphery()}};
|
||||
}
|
||||
|
||||
bool valid_demo_stadium(const Json &state, const Catalog &world, const std::string &club) {
|
||||
@@ -85,11 +97,12 @@ bool valid_demo_stadium(const Json &state, const Catalog &world, const std::stri
|
||||
if (!state.is_object()) return false;
|
||||
const int64_t factor = finance_currency_factor(world), cap = budget_units * factor;
|
||||
const auto &stadium = state.at("stadium");
|
||||
if (!keys(stadium, {"club", "budget", "blocks", "facilities"}) ||
|
||||
if (!keys(stadium, {"club", "budget", "blocks", "facilities", "periphery"}) ||
|
||||
!stadium.at("club").is_string() || stadium.at("club") != owner(world, &state, club) ||
|
||||
!integer(stadium.at("budget"), 0, cap) ||
|
||||
!stadium.at("blocks").is_array() || stadium.at("blocks").size() != 8 ||
|
||||
!stadium.at("facilities").is_array() || stadium.at("facilities").size() != 8) return false;
|
||||
!stadium.at("facilities").is_array() || stadium.at("facilities").size() != 8 ||
|
||||
!stadium.at("periphery").is_array() || stadium.at("periphery").size() != 14) return false;
|
||||
int64_t pending = 0;
|
||||
for (size_t i = 0; i < 8; ++i) {
|
||||
const auto &base = stadium.at("blocks")[i];
|
||||
@@ -120,6 +133,18 @@ bool valid_demo_stadium(const Json &state, const Catalog &world, const std::stri
|
||||
if (job.at("cost") != cost || cost > cap - pending) return false;
|
||||
pending += cost;
|
||||
}
|
||||
for (size_t i = 0; i < 14; ++i) {
|
||||
const auto &base = stadium.at("periphery")[i];
|
||||
if (!keys(base, {"level", "job"}) || !integer(base.at("level"), 0, periphery_cap(i))) return false;
|
||||
const auto &job = base.at("job");
|
||||
if (job.is_null()) continue;
|
||||
const int next = base.at("level").get<int>() + 1;
|
||||
const int64_t cost = periphery_rates[i] * factor;
|
||||
if (next > periphery_cap(i) || !keys(job, {"level", "weeks", "cost"}) ||
|
||||
!integer(job.at("level"), next, next) || !integer(job.at("weeks"), periphery_weeks[i], periphery_weeks[i]) ||
|
||||
job.at("cost") != cost || cost > cap - pending) return false;
|
||||
pending += cost;
|
||||
}
|
||||
return stadium.at("budget").get<int64_t>() == cap - pending;
|
||||
} catch (const std::exception &) { return false; }
|
||||
}
|
||||
@@ -127,7 +152,15 @@ bool valid_demo_stadium(const Json &state, const Catalog &world, const std::stri
|
||||
bool migrate_demo_stadium(Json &state, const Catalog &world, const std::string &club) {
|
||||
try {
|
||||
if (!state.is_object()) return false;
|
||||
if (state.contains("stadium")) return valid_demo_stadium(state, world, club);
|
||||
if (state.contains("stadium")) {
|
||||
if (valid_demo_stadium(state, world, club)) return true;
|
||||
if (!keys(state.at("stadium"), {"club", "budget", "blocks", "facilities"})) return false;
|
||||
auto next = state;
|
||||
next["stadium"]["periphery"] = initial_periphery();
|
||||
if (!valid_demo_stadium(next, world, club)) return false;
|
||||
state = std::move(next);
|
||||
return true;
|
||||
}
|
||||
auto next = state;
|
||||
next["stadium"] = demo_stadium(world, owner(world, &state, club));
|
||||
if (!valid_demo_stadium(next, world, club)) return false;
|
||||
@@ -140,7 +173,7 @@ Json demo_stadium_quote(const Json &state, const Json &request, const Catalog &w
|
||||
if (!valid_demo_stadium(state, world, club)) return error("invalid_stadium_state");
|
||||
try {
|
||||
if (!request.is_object() || !request.contains("kind") || !request.at("kind").is_string() ||
|
||||
!request.contains("index") || !integer(request.at("index"), 0, 7)) return error("invalid_stadium_request");
|
||||
!request.contains("index") || !integer(request.at("index"), 0, request.value("kind", std::string()) == "periphery" ? 13 : 7)) return error("invalid_stadium_request");
|
||||
const auto kind = request.at("kind").get<std::string>();
|
||||
const auto index = request.at("index").get<size_t>();
|
||||
const auto &stadium = state.at("stadium");
|
||||
@@ -161,6 +194,14 @@ Json demo_stadium_quote(const Json &state, const Json &request, const Catalog &w
|
||||
quote = {{"cost", (request.at("level").get<int64_t>() - base.at("level").get<int64_t>()) * facility_rates[index] * factor},
|
||||
{"weeks", facility_weeks[index]}, {"placesCost", 0}, {"seatsCost", 0}, {"roofCost", 0}};
|
||||
pending = !base.at("job").is_null();
|
||||
} else if (kind == "periphery") {
|
||||
const auto &base = stadium.at("periphery")[index];
|
||||
const int next = base.at("level").get<int>() + 1;
|
||||
if (!keys(request, {"kind", "index", "level"}) || next > periphery_cap(index) ||
|
||||
!integer(request.at("level"), next, next)) return error("invalid_stadium_periphery_target");
|
||||
quote = {{"cost", periphery_rates[index] * factor}, {"weeks", periphery_weeks[index]},
|
||||
{"placesCost", 0}, {"seatsCost", 0}, {"roofCost", 0}};
|
||||
pending = !base.at("job").is_null();
|
||||
} else return error("unknown_stadium_request");
|
||||
const auto cost = quote.at("cost").get<int64_t>(), budget = stadium.at("budget").get<int64_t>();
|
||||
const auto reason = pending ? "stadium_pending" : !cost ? "stadium_no_change"
|
||||
@@ -187,7 +228,7 @@ std::string edit_demo_stadium(Json &state, const Json &action, const Catalog &wo
|
||||
next["stadium"]["blocks"][index]["job"] = job;
|
||||
} else {
|
||||
job["level"] = request.at("level");
|
||||
next["stadium"]["facilities"][index]["job"] = job;
|
||||
next["stadium"][quote.at("kind") == "periphery" ? "periphery" : "facilities"][index]["job"] = job;
|
||||
}
|
||||
next["stadium"]["budget"] = quote.at("remaining");
|
||||
if (!valid_demo_stadium(next, world, club)) return "invalid_stadium_state";
|
||||
@@ -208,7 +249,11 @@ Json demo_stadium_rules(const Catalog &world) {
|
||||
facilities.push_back({{"index", i}, {"name", facility_names[i]}, {"max_level", facility_cap(i)},
|
||||
{"rate", facility_rates[i] * factor}, {"weeks", facility_weeks[i]}, {"levels", levels}});
|
||||
}
|
||||
return {{"budget_cap", budget_units * factor}, {"blocks", blocks}, {"facilities", facilities}};
|
||||
Json periphery = Json::array();
|
||||
for (size_t i = 0; i < 14; ++i)
|
||||
periphery.push_back({{"index", i}, {"name", periphery_names[i]}, {"max_level", periphery_cap(i)},
|
||||
{"rate", periphery_rates[i] * factor}, {"weeks", periphery_weeks[i]}});
|
||||
return {{"budget_cap", budget_units * factor}, {"blocks", blocks}, {"facilities", facilities}, {"periphery", periphery}};
|
||||
}
|
||||
|
||||
Json demo_stadium_view(const Json &state, const Catalog &world, bool future, const std::string &club) {
|
||||
@@ -249,6 +294,17 @@ Json demo_stadium_view(const Json &state, const Catalog &world, bool future, con
|
||||
row["display_level"] = level; row["display_label"] = row.at("levels")[size_t(level)];
|
||||
if (building) pending += job.at("cost").get<int64_t>();
|
||||
}
|
||||
for (size_t i = 0; i < 14; ++i) {
|
||||
const auto &base = stadium.at("periphery")[i]; const auto &job = base.at("job");
|
||||
const bool building = !job.is_null(); auto &row = rules["periphery"][i];
|
||||
row["level"] = base.at("level"); row["job"] = job; row["building"] = building;
|
||||
row["display_level"] = (future && building ? job : base).at("level");
|
||||
if (building) pending += job.at("cost").get<int64_t>();
|
||||
}
|
||||
// Closed blocks still contribute their completed size to the physical stadium.
|
||||
int64_t physical = 0;
|
||||
for (const auto &block : stadium.at("blocks")) physical += block.at("places").get<int64_t>();
|
||||
rules["physical_capacity"] = future ? planned : physical;
|
||||
rules["ok"] = true; rules["club"] = id; rules["club_name"] = team ? world.name(*team) : "—";
|
||||
rules["stadium"] = record ? record->at("id") : Json();
|
||||
const auto name = record ? world.name(*record) : "";
|
||||
@@ -258,4 +314,55 @@ Json demo_stadium_view(const Json &state, const Catalog &world, bool future, con
|
||||
rules["capacity"] = future ? planned : available;
|
||||
return rules;
|
||||
}
|
||||
Json demo_stadium_scene(const Json &configuration, const Json &overview, bool future) {
|
||||
if (configuration.at("schemaVersion") != 1 || configuration.at("activeProfile") != "modern")
|
||||
throw editor::Error("invalid_stadium_scene");
|
||||
const auto &profile = configuration.at("profiles").at("modern");
|
||||
if (profile.at("referenceSize").at("width") != 1920 || profile.at("referenceSize").at("height") != 1080 ||
|
||||
profile.at("objects").size() != 14 || overview.at("periphery").size() != 14)
|
||||
throw editor::Error("invalid_stadium_scene");
|
||||
Json layers = Json::array(), areas = Json::array();
|
||||
const auto place = [&](const Json &binding, const Json &transform, const Json &owner, const char *role) {
|
||||
const auto asset = binding.at("asset").get<std::string>();
|
||||
const auto &meta = configuration.at("assets").at(asset);
|
||||
const double scale = transform.at("scale").get<double>();
|
||||
const double width = binding.at("width").get<double>() * binding.at("scale").get<double>() * scale;
|
||||
const double height = width * meta.at("height").get<double>() / meta.at("width").get<double>();
|
||||
layers.push_back({{"asset", asset}, {"owner", owner}, {"role", role}, {"z", transform.at("z")},
|
||||
{"x", transform.at("x").get<double>() + binding.at("offsetX").get<double>() * scale - binding.at("anchorX").get<double>() * width},
|
||||
{"y", transform.at("y").get<double>() + binding.at("offsetY").get<double>() * scale - binding.at("anchorY").get<double>() * height},
|
||||
{"width", width}, {"height", height}});
|
||||
};
|
||||
const auto &transport = overview.at("periphery")[0];
|
||||
const int traffic = (transport.at("building").get<bool>() ? transport.at("job") : transport).at("level").get<int>();
|
||||
const auto &background = profile.at("background");
|
||||
place(profile.at("backgroundOptions")[0].at("variants").at(size_t(traffic)),
|
||||
{{"x", background.at("offsetX")}, {"y", background.at("offsetY")}, {"scale", background.at("scale")}, {"z", 0}}, "background", "background");
|
||||
const auto capacity = overview.at("physical_capacity").get<int64_t>();
|
||||
size_t stadium_index = 0;
|
||||
for (const auto &threshold : profile.at("stadium").at("thresholds")) if (capacity >= threshold.get<int64_t>()) ++stadium_index;
|
||||
place(profile.at("stadium").at("variants").at(stadium_index), profile.at("stadium").at("transform"), "stadium", "stadium");
|
||||
for (size_t i = 0; i < 14; ++i) {
|
||||
const auto &object = profile.at("objects")[i], &row = overview.at("periphery")[i];
|
||||
if (object.at("id") != i) throw editor::Error("invalid_stadium_scene");
|
||||
const auto &transform = object.at("transform"), &area = object.at("hitArea"), &sprites = object.at("sprites");
|
||||
const bool pending = row.at("building").get<bool>(), building = pending && !future;
|
||||
const int level = (pending ? row.at("job") : row).at("level").get<int>();
|
||||
const double scale = transform.at("scale").get<double>();
|
||||
const double w = area.at("width").get<double>() * scale, h = area.at("height").get<double>() * scale;
|
||||
areas.push_back({{"index", i}, {"z", transform.at("z")},
|
||||
{"x", transform.at("x").get<double>() + area.at("offsetX").get<double>() * scale - w / 2},
|
||||
{"y", transform.at("y").get<double>() + area.at("offsetY").get<double>() * scale - h / 2}, {"width", w}, {"height", h}});
|
||||
if (i == 0 || (building && i >= 6)) {
|
||||
if (building) place(sprites.at("marker"), transform, i, "marker");
|
||||
} else if (level) {
|
||||
const size_t variant = i == 4 ? size_t(level - 1) : 0;
|
||||
place(sprites.at("variants").at(variant), transform, i, "building");
|
||||
if (building) place(sprites.at("overlays").at(variant), transform, i, "overlay");
|
||||
}
|
||||
}
|
||||
std::stable_sort(layers.begin(), layers.end(), [](const Json &a, const Json &b) { return a.at("z").get<double>() < b.at("z").get<double>(); });
|
||||
std::stable_sort(areas.begin(), areas.end(), [](const Json &a, const Json &b) { return a.at("z").get<double>() < b.at("z").get<double>(); });
|
||||
return {{"layers", layers}, {"areas", areas}, {"stadium_index", stadium_index}, {"traffic_level", traffic}};
|
||||
}
|
||||
} // namespace bmh::modern_ui
|
||||
@@ -4,8 +4,9 @@
|
||||
|
||||
namespace bmh::modern_ui {
|
||||
// Presentation-only construction ledger. Only state.stadium is owned here:
|
||||
// {club,budget,blocks:[{places,seats,roof,job}],facilities:[{level,job}]}.
|
||||
// All money is currency minor units. No periphery, ticket, navigation, engine,
|
||||
// {club,budget,blocks:[{places,seats,roof,job}],facilities:[{level,job}],periphery:[{level,job}]}.
|
||||
// All money is currency minor units. Includes fourteen independent periphery sites.
|
||||
// No ticket, navigation, engine,
|
||||
// random stream, world edit, legacy initialization, or completion timer.
|
||||
Json demo_stadium(const Catalog &, const std::string &club = {});
|
||||
bool valid_demo_stadium(const Json &state, const Catalog &,
|
||||
@@ -15,7 +16,8 @@ bool valid_demo_stadium(const Json &state, const Catalog &,
|
||||
bool migrate_demo_stadium(Json &state, const Catalog &,
|
||||
const std::string &club = {});
|
||||
// Only {kind:"build",request:{kind:"block",index,places,seats,roof}} or
|
||||
// {kind:"build",request:{kind:"facility",index,level}}. Recompute the quote,
|
||||
// {kind:"build",request:{kind:"facility"|"periphery",index,level}}.
|
||||
// Periphery targets must be exactly the completed level plus one. Recompute the quote,
|
||||
// atomically debit only local stadium budget and stage a pending job.
|
||||
std::string edit_demo_stadium(Json &state, const Json &action, const Catalog &,
|
||||
const std::string &club = {});
|
||||
@@ -39,4 +41,8 @@ Json demo_stadium_rules(const Catalog &);
|
||||
// Stadium identity comes from the catalogue, not its initialization policies.
|
||||
Json demo_stadium_view(const Json &state, const Catalog &, bool future = false,
|
||||
const std::string &club = {});
|
||||
// Pure calibrated sprite layout. Ignores exported simulation/editor/object state;
|
||||
// uses only runtime overview capacity and periphery jobs. Coordinates remain in
|
||||
// the 1920x1080 reference space; stable layers include full transparent canvases.
|
||||
Json demo_stadium_scene(const Json &configuration, const Json &overview, bool future);
|
||||
} // namespace bmh::modern_ui
|
||||
@@ -55,7 +55,7 @@ bool App::stadium_action(const std::string &action,Rml::Element *target) {
|
||||
if(!q.value("can_build",false)||stadium_view_.at("invalid_places").get<bool>()){sync_stadium_draft();return true;}
|
||||
const auto result=source_->apply({stadium_revision_,"stadium",{{"kind","build"},{"request",stadium_view_.at("draft")}}});
|
||||
if(!result.ok){stadium_view_["feedback"]="Der Bauauftrag konnte nicht übernommen werden. Bitte den aktuellen Stand erneut öffnen.";sync_stadium_draft();return true;}
|
||||
stadium_view_["future"]=true;stadium_view_["return_focus"]="stadium-future";cancel();return true;
|
||||
stadium_view_["future"]=stadium_view_.at("draft").at("kind")!="periphery";stadium_view_["hint"]="";stadium_view_["return_focus"]="stadium-future";cancel();return true;
|
||||
}
|
||||
if(action=="stadium-option") {
|
||||
if(stadium_view_.at("dialog")!="facility"||!index||!fresh())return true;
|
||||
@@ -75,6 +75,13 @@ bool App::stadium_action(const std::string &action,Rml::Element *target) {
|
||||
open_amount(std::move(request));return true;
|
||||
}
|
||||
if(stadium_view_.at("dialog")!="")return true;
|
||||
if(action=="stadium-periphery") {
|
||||
if(stadium_view_.at("view")!="panorama"||!index||*index>13||!target)return true;
|
||||
const auto &row=overview.at("periphery")[size_t(*index)];
|
||||
if(row.at("building").get<bool>()||row.at("level").get<int>()>=row.at("max_level").get<int>())return true;
|
||||
stadium_view_["draft"]={{"kind","periphery"},{"index",*index},{"level",row.at("level").get<int>()+1}};
|
||||
stadium_view_["dialog"]="periphery";stadium_view_["bound_club"]=club;stadium_view_["feedback"]="";stadium_view_["invalid_places"]=false;stadium_view_["return_focus"]=target->GetId();stadium_world_=s.world;stadium_revision_=s.revision;stadium_source_=source_.get();focus_after_render_="stadium-build";refresh();return true;
|
||||
}
|
||||
if(action=="stadium-block"||action=="stadium-facility") {
|
||||
if(!index||*index>7||!target)return true;
|
||||
const bool block=action=="stadium-block";
|
||||
@@ -85,7 +92,7 @@ bool App::stadium_action(const std::string &action,Rml::Element *target) {
|
||||
stadium_view_["dialog"]=block?"block":"facility";stadium_view_["bound_club"]=club;stadium_view_["feedback"]="";stadium_view_["invalid_places"]=false;stadium_view_["return_focus"]=target->GetId();stadium_world_=s.world;stadium_revision_=s.revision;stadium_source_=source_.get();focus_after_render_=block?"stadium-place-number":"stadium-option-"+std::to_string(row.at("level").get<int>()+1);refresh();return true;
|
||||
}
|
||||
if(action=="stadium-view"){stadium_view_["view"]=stadium_view_.at("view")=="inside"?"panorama":"inside";focus_after_render_="stadium-view";}
|
||||
else if(action=="stadium-future"){if(stadium_view_.at("view")!="inside")return true;stadium_view_["future"]=!stadium_view_.at("future").get<bool>();focus_after_render_="stadium-future";}
|
||||
else if(action=="stadium-future"){if(stadium_view_.at("view")=="data")return true;stadium_view_["future"]=!stadium_view_.at("future").get<bool>();focus_after_render_="stadium-future";}
|
||||
else if(action=="stadium-data"){stadium_view_["view"]="data";focus_after_render_="stadium-back";}
|
||||
else if(action=="stadium-back"){stadium_view_["view"]="inside";focus_after_render_="stadium-data";}
|
||||
else if(action=="stadium-curve"){if(!index||*index>5)return true;stadium_view_["curves"][size_t(*index)]=!stadium_view_.at("curves")[size_t(*index)].get<bool>();focus_after_render_="stadium-curve-"+id;}
|
||||
@@ -108,10 +115,17 @@ bool App::stadium_event(Rml::Event &event) {
|
||||
const bool dialog=stadium_view_.at("dialog")!="";
|
||||
if((type=="keydown"&&key==Rml::Input::KI_ESCAPE)||(dialog&&type=="mouseup"&&event.GetParameter<int>("button",0)==1)) {
|
||||
if(dialog)stadium_action("stadium-cancel",nullptr);
|
||||
else if(stadium_view_.at("view")=="data")stadium_action("stadium-back",nullptr);
|
||||
else if(stadium_view_.at("view")=="data"||stadium_view_.at("view")=="panorama")stadium_action("stadium-back",nullptr);
|
||||
else return false;
|
||||
event.StopImmediatePropagation();return true;
|
||||
}
|
||||
if(!dialog&&stadium_view_.at("view")=="panorama"&&(type=="mousemove"||type=="focus"||type=="blur")) {
|
||||
const auto hint=[&](Rml::Element *from) {for(auto *n=from;n&&n!=doc_;n=n->GetParentNode())if(n->HasAttribute("data-stadium-hint"))return n->GetAttribute<Rml::String>("data-stadium-hint","");return Rml::String();};
|
||||
auto text=hint(target);
|
||||
if(type=="focus"&&text.empty()&&target&&target->GetId()!="stadium-back"&&target->GetId()!="stadium-future"&&target->GetId()!="window-close")return false;
|
||||
if(type=="blur")text="";
|
||||
if(stadium_view_.at("hint")!=text) {stadium_view_["hint"]=text;if(auto *n=element("stadium-interaction-hint"))n->SetInnerRML("<span>"+esc(text.empty()?"Ein Element im Stadionumfeld auswählen.":text)+"</span>");dirty_=true;}
|
||||
}
|
||||
Rml::Element *place_range=nullptr;
|
||||
for(auto *node=target;node&&node!=doc_;node=node->GetParentNode())if(node->GetId()=="stadium-place-range"){place_range=node;break;}
|
||||
if(dialog&&type=="keydown"&&place_range&&stadium_view_.at("dialog")=="block"&&(key==Rml::Input::KI_HOME||key==Rml::Input::KI_END)) {
|
||||
|
||||
@@ -10,8 +10,8 @@ void stadium_view_defaults(Json &v) {
|
||||
if(!v.contains("view")||!v.at("view").is_string()||(v.at("view")!="inside"&&v.at("view")!="panorama"&&v.at("view")!="data"))v["view"]="inside";
|
||||
for(const auto *key:{"future","relative","invalid_places"})if(!v.contains(key)||!v.at(key).is_boolean())v[key]=std::string(key)=="relative";
|
||||
if(!v.contains("curves")||!v.at("curves").is_array()||v.at("curves").size()!=6||!std::all_of(v.at("curves").begin(),v.at("curves").end(),[](const auto &x){return x.is_boolean();}))v["curves"]={true,true,true,true,true,true};
|
||||
for(const auto *key:{"dialog","return_focus","ticket_return_focus","feedback"})if(!v.contains(key)||!v.at(key).is_string())v[key]="";
|
||||
if(v.at("dialog")!=""&&v.at("dialog")!="block"&&v.at("dialog")!="facility")v["dialog"]="";
|
||||
for(const auto *key:{"dialog","return_focus","ticket_return_focus","feedback","hint"})if(!v.contains(key)||!v.at(key).is_string())v[key]="";
|
||||
if(v.at("dialog")!=""&&v.at("dialog")!="block"&&v.at("dialog")!="facility"&&v.at("dialog")!="periphery")v["dialog"]="";
|
||||
if(!v.contains("draft"))v["draft"]=Json();
|
||||
}
|
||||
std::string stadium_managed(const Snapshot &s) {
|
||||
@@ -109,8 +109,21 @@ std::string App::render_stadium() {
|
||||
out+=btn("stadium-facility","<span class=\"stadium-facility-picture\">"+picture(art,391,125,true)+art_overlay(int(i),level,391,h)+"</span><strong>"+esc(f.at("name").get<std::string>())+"</strong><span class=\"stadium-facility-caption\">"+esc(caption)+"</span>","stadium-facility","id=\"stadium-facility-"+std::to_string(i)+"\" data-id=\""+std::to_string(i)+"\" style=\""+rect((i%4)*411,1148+(i/4)*214,395,198)+"\" aria-label=\""+esc(f.at("name").get<std::string>()+", "+caption)+"\" "+(f.at("building").get<bool>()?"disabled=\"disabled\"":""));
|
||||
}
|
||||
} else if(view=="panorama") {
|
||||
constexpr double panorama_h=2612.0*941/1672;
|
||||
out+="<div class=\"stadium-panorama\">"+img("art.stadium-panorama-v2.png",2608,panorama_h-4,false,false,2880)+"</div>";
|
||||
constexpr double scale=2612.0/1920;
|
||||
out+="<div class=\"stadium-periphery-scene\" id=\"stadium-periphery-scene\">";
|
||||
if(!gui_.contains("stadium.scene"))out+="<p class=\"stadium-empty\">Die kalibrierten Stadionumfeld-Grafiken fehlen im GUI-Paket.</p>";
|
||||
else try {
|
||||
const auto configuration=Json::parse(editor::read_file(gui_.root()/editor::path(gui_.items().at("stadium.scene").at("file").get<std::string>())));
|
||||
const auto scene=demo_stadium_scene(configuration,overview,future);
|
||||
for(const auto &layer:scene.at("layers"))out+="<span class=\"stadium-scene-sprite\" data-owner=\""+esc(layer.at("owner").is_string()?layer.at("owner").get<std::string>():layer.at("owner").dump())+"\" data-role=\""+layer.at("role").get<std::string>()+"\" style=\""+rect(layer.at("x").get<double>()*scale,layer.at("y").get<double>()*scale,layer.at("width").get<double>()*scale,layer.at("height").get<double>()*scale)+"\">"+img("stadium.scene."+layer.at("asset").get<std::string>(),layer.at("width").get<double>()*scale,layer.at("height").get<double>()*scale,false,false,3072)+"</span>";
|
||||
for(const auto &area:scene.at("areas")) {
|
||||
const auto i=area.at("index").get<size_t>();const auto &row=overview.at("periphery")[i];
|
||||
auto hint=row.at("name").get<std::string>();
|
||||
if(row.at("building").get<bool>())hint+=" · noch "+std::to_string(row.at("job").at("weeks").get<int>())+" Wochen";
|
||||
out+=btn("stadium-periphery","","stadium-periphery-hit","id=\"stadium-periphery-"+std::to_string(i)+"\" data-id=\""+std::to_string(i)+"\" data-stadium-hint=\""+esc(hint)+"\" aria-label=\""+esc(hint)+"\" aria-disabled=\""+(row.at("building").get<bool>()||row.at("level")==row.at("max_level")?"true":"false")+"\" style=\""+rect(area.at("x").get<double>()*scale,area.at("y").get<double>()*scale,area.at("width").get<double>()*scale,area.at("height").get<double>()*scale)+"\"");
|
||||
}
|
||||
} catch(const std::exception &) {out+="<p class=\"stadium-empty\">Die Stadionumfeld-Grafiken sind unvollständig.</p>";}
|
||||
out+="</div><p id=\"stadium-interaction-hint\" role=\"status\" aria-live=\"polite\"><span>"+esc(stadium_view_.at("hint").get<std::string>().empty()?"Ein Element im Stadionumfeld auswählen.":stadium_view_.at("hint").get<std::string>())+"</span></p>";
|
||||
} else {
|
||||
const auto graph=stadium_graph_svg(stadium_view_.at("curves"),stadium_view_.at("relative").get<bool>(),theme_);
|
||||
out+="<div class=\"stadium-graph\"><div class=\"stadium-graph-art\">"+picture(renderer_.diagram("stadium-graph",graph,7200),2560,456)+"</div></div>";
|
||||
@@ -128,7 +141,11 @@ std::string App::render_stadium() {
|
||||
out+="</div>";
|
||||
}
|
||||
out+="<nav class=\"stadium-nav\">";
|
||||
if(view=="data")out+=btn("stadium-back","Zurück zum Stadion","stadium-nav-button wide","id=\"stadium-back\"");
|
||||
if(view=="panorama") {
|
||||
out+=btn("stadium-back","Zurück","stadium-nav-button half","id=\"stadium-back\"");
|
||||
out+=btn("stadium-future","Zukunft","stadium-nav-button half","id=\"stadium-future\" aria-pressed=\""+std::string(future?"true":"false")+"\"");
|
||||
}
|
||||
else if(view=="data")out+=btn("stadium-back","Zurück zum Stadion","stadium-nav-button wide","id=\"stadium-back\"");
|
||||
else {
|
||||
out+=btn("stadium-view",view=="inside"?"Sicht: Panorama":"Sicht: Innen","stadium-nav-button","id=\"stadium-view\"");
|
||||
out+=view=="inside"?btn("stadium-future",std::string("Ausbau: ")+(future?"Zukunft":"Aktuell"),"stadium-nav-button","id=\"stadium-future\" aria-pressed=\""+std::string(future?"true":"false")+"\""):"<button class=\"stadium-nav-button control-button\" disabled=\"disabled\"><span class=\"control-label\">Peripherie bauen</span></button>";
|
||||
@@ -142,7 +159,20 @@ std::string App::render_stadium_dialog() {
|
||||
const auto s=snap();if(!s.world||!stadium_view_.at("draft").is_object())return "";
|
||||
const auto &d=stadium_view_.at("draft");const bool block=d.at("kind")=="block";const int index=d.at("index").get<int>();
|
||||
const auto overview=demo_stadium_view(s.state,*s.world,false,stadium_managed(s));if(!overview.value("ok",false))return "";
|
||||
const auto &row=overview.at(block?"blocks":"facilities")[size_t(index)];const auto q=demo_stadium_quote(s.state,d,*s.world,stadium_managed(s));
|
||||
const bool periphery=d.at("kind")=="periphery";
|
||||
const auto &row=overview.at(block?"blocks":periphery?"periphery":"facilities")[size_t(index)];const auto q=demo_stadium_quote(s.state,d,*s.world,stadium_managed(s));
|
||||
if(periphery) {
|
||||
const int level=d.at("level").get<int>();std::string preview;
|
||||
if(gui_.contains("stadium.scene"))try {
|
||||
const auto config=Json::parse(editor::read_file(gui_.root()/editor::path(gui_.items().at("stadium.scene").at("file").get<std::string>())));
|
||||
const auto &profile=config.at("profiles").at("modern");
|
||||
const auto binding=index==0?profile.at("backgroundOptions")[0].at("variants").at(size_t(level)):profile.at("objects").at(size_t(index)).at("sprites").at("variants").at(index==4?size_t(level-1):0);
|
||||
const auto asset=binding.at("asset").get<std::string>();const auto &meta=config.at("assets").at(asset);const double height=800.0*meta.at("height").get<double>()/meta.at("width").get<double>();
|
||||
preview="<span class=\"stadium-periphery-preview\" style=\""+rect(680,174,800,height)+"\">"+img("stadium.scene."+asset,800,height,false,false,1600)+"</span>";
|
||||
} catch(const std::exception &) {}
|
||||
const auto title=row.at("name").get<std::string>();
|
||||
return "<div class=\"stadium-modal\" id=\"stadium-modal\"><section class=\"stadium-draft\" id=\"stadium-draft\" role=\"dialog\" aria-modal=\"true\" aria-labelledby=\"stadium-draft-title\" style=\""+rect(226,377,2160,1110)+"\"><h2 id=\"stadium-draft-title\">"+esc(title)+" ausbauen</h2><div class=\"stadium-draft-summary\"><span>"+(row.at("level")==0?"Neubau":"Erweiterung")+" · Stufe "+std::to_string(level)+"</span><span>Bauzeit: "+std::to_string(q.value("weeks",0))+" Wochen</span></div>"+preview+"<div class=\"stadium-draft-total\" style=\"top:758dp;\"><span>Gesamtbetrag:</span><span id=\"stadium-quote-total\">"+esc(stadium_money(stadium_field(q,"cost"),*s.world))+"</span></div><p id=\"stadium-draft-feedback\" style=\"top:850dp;\">"+esc(stadium_feedback(q,false))+"</p><nav class=\"stadium-draft-actions\" style=\"top:946dp;\">"+btn("stadium-build","Bauen","stadium-dialog-action primary","id=\"stadium-build\" "+std::string(q.value("can_build",false)?"":"disabled=\"disabled\""))+btn("stadium-cancel","Abbrechen","stadium-dialog-action","id=\"stadium-cancel\"")+"</nav></section></div>";
|
||||
}
|
||||
struct Option {int level;Picture art;double height;};std::vector<Option> options;double option_h=0;
|
||||
if(!block)for(int level=row.at("level").get<int>()+1;level<=row.at("max_level").get<int>();++level){const auto a=renderer_.image("stadium.facility."+std::to_string(index)+".level."+std::to_string(level),false,2048);const double h=a.width?592.0*a.height/a.width:325;options.push_back({level,a,h});option_h=std::max(option_h,h+159);}
|
||||
const double height=block?982.5:option_h+499,total_top=block?687.5:option_h+204,feedback_top=block?776.5:option_h+293,actions_top=block?854.5:option_h+371;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "modern/ui/demo_stadium.hpp"
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
#include <cmath>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
@@ -54,8 +55,8 @@ void currency(int precision) {
|
||||
const auto unrelated = state, world_clubs = world.rows("clubs"), world_stadiums = world.rows("stadiums"), manifest = world.manifest();
|
||||
require(!valid_demo_stadium(state, world) && migrate_demo_stadium(state, world) && valid_demo_stadium(state, world) && without_stadium(state) == unrelated, "Missing-state migration altered unrelated fields or failed");
|
||||
const auto defaults = state;
|
||||
require(state.at("stadium").size() == 4 && state.at("stadium").at("club") == second && state.at("stadium").at("budget") == 50000000 * factor, "Canonical fields, manager binding or raw budget wrong");
|
||||
require(!state.at("stadium").contains("periphery") && !state.at("stadium").contains("ticket"), "Excluded construction/navigation leaked into canonical model");
|
||||
require(state.at("stadium").size() == 5 && state.at("stadium").at("club") == second && state.at("stadium").at("budget") == 50000000 * factor, "Canonical fields, manager binding or raw budget wrong");
|
||||
require(state.at("stadium").at("periphery").size() == 14 && !state.at("stadium").contains("ticket"), "Excluded construction/navigation leaked into canonical model");
|
||||
const auto overview = demo_stadium_view(state, world);
|
||||
require(overview.at("capacity") == 36000 && overview.at("planned_capacity") == 36000 && overview.at("available_capacity") == 36000 && overview.at("name") == "Synthetic ground " + second && overview.at("stadium") == "stadium:" + second, "Overview lost identity or incorrectly derived capacity from OBW initialization");
|
||||
const std::array<int, 8> base{3000,6000,3000,5000,3000,6000,3000,7000}, caps{8000,18000,8000,14000,8000,18000,8000,14000}, rates{300000,375000,300000,350000,300000,375000,300000,350000}, weeks{30,37,30,25,30,37,30,25};
|
||||
@@ -114,7 +115,7 @@ void currency(int precision) {
|
||||
require(spent.at("stadium").at("budget") == 465000 * factor && old_quote.at("can_build") == true && demo_stadium_quote(spent, facility(6, 4), world).at("error") == "stadium_budget_exceeded", "Stale quote not revalidated against remaining local budget");
|
||||
reject_build(spent, facility(6, 4), world); conserved(spent, world, factor);
|
||||
for (const auto &action : std::vector<Json>{nullptr, Json::array(), Json::object(), {{"kind", "complete"}}, {{"kind", "ticket"}, {"value", 0}}, {{"kind", "periphery"}, {"index", 0}}, {{"kind", "build"}, {"request", facility(7, 2)}, {"cost", 1}}}) reject(spent, action, world);
|
||||
for (const auto &request : std::vector<Json>{nullptr, {{"kind", "periphery"}, {"index", 0}, {"level", 1}}, {{"kind", "block"}, {"index", -1}, {"places", 4000}, {"seats", false}, {"roof", false}}, {{"kind", "block"}, {"index", true}, {"places", 4000}, {"seats", false}, {"roof", false}}, {{"kind", "block"}, {"index", uint64_t(-1)}, {"places", 4000}, {"seats", false}, {"roof", false}}, {{"kind", "block"}, {"index", 0}, {"places", uint64_t(-1)}, {"seats", false}, {"roof", false}}, {{"kind", "block"}, {"index", 0}, {"places", 4000.0}, {"seats", false}, {"roof", false}}, {{"kind", "facility"}, {"index", 0}, {"level", 2}, {"weeks", 1}}}) { auto next = defaults; reject_build(next, request, world); }
|
||||
for (const auto &request : std::vector<Json>{nullptr, {{"kind", "periphery"}, {"index", 0}, {"level", 3}}, {{"kind", "block"}, {"index", -1}, {"places", 4000}, {"seats", false}, {"roof", false}}, {{"kind", "block"}, {"index", true}, {"places", 4000}, {"seats", false}, {"roof", false}}, {{"kind", "block"}, {"index", uint64_t(-1)}, {"places", 4000}, {"seats", false}, {"roof", false}}, {{"kind", "block"}, {"index", 0}, {"places", uint64_t(-1)}, {"seats", false}, {"roof", false}}, {{"kind", "block"}, {"index", 0}, {"places", 4000.0}, {"seats", false}, {"roof", false}}, {{"kind", "facility"}, {"index", 0}, {"level", 2}, {"weeks", 1}}}) { auto next = defaults; reject_build(next, request, world); }
|
||||
std::vector<Json> corrupt;
|
||||
auto bad = defaults; bad["stadium"]["budget"] = 1; corrupt.push_back(bad);
|
||||
bad = defaults; bad["stadium"]["periphery"] = Json::array(); corrupt.push_back(bad);
|
||||
@@ -146,9 +147,81 @@ void currency(int precision) {
|
||||
require(world.rows("clubs") == world_clubs && world.rows("stadiums") == world_stadiums && world.manifest() == manifest, "Provider mutated original world records");
|
||||
require(demo_stadium(world, first).at("club") == first && !valid_demo_stadium(defaults, world, first), "Explicit manager binding ignored");
|
||||
}
|
||||
Json scene_fixture() {
|
||||
const auto binding=[](const std::string &id) {return Json{{"asset",id},{"width",300},{"scale",1.2},{"anchorX",.4},{"anchorY",.8},{"offsetX",12},{"offsetY",-7}};};
|
||||
Json config={{"schemaVersion",1},{"activeProfile","modern"},{"simulation",{{"capacity",100000}}},{"assets",Json::object()}};
|
||||
auto &profile=config["profiles"]["modern"];
|
||||
profile["referenceSize"]={{"width",1920},{"height",1080}};
|
||||
profile["background"]=binding("panorama-forest");
|
||||
profile["backgroundOptions"]=Json::array({{{"variants",Json::array()}}});
|
||||
const auto add=[&](const std::string &id) {config["assets"][id]={{"width",1500},{"height",1000}};return binding(id);};
|
||||
for(int i=0;i<5;++i)profile["backgroundOptions"][0]["variants"].push_back(add("traffic-"+std::to_string(i)));
|
||||
profile["stadium"]={{"transform",{{"x",945.3},{"y",718.1},{"scale",1},{"z",20}}},{"thresholds",{10000,25000,50000,75000,100000}},{"variants",Json::array()}};
|
||||
for(int i=0;i<6;++i)profile["stadium"]["variants"].push_back(add("stadium-"+std::to_string(i)));
|
||||
profile["objects"]=Json::array();
|
||||
for(int i=0;i<14;++i) {
|
||||
Json variants=Json::array(),overlays=Json::array();const int cap=i==0?0:i==4?3:1;
|
||||
for(int level=1;level<=cap;++level){variants.push_back(add("site-"+std::to_string(i)+"-"+std::to_string(level)));if(i<=5)overlays.push_back(add("overlay-"+std::to_string(i)+"-"+std::to_string(level)));}
|
||||
profile["objects"].push_back({{"id",i},{"transform",{{"x",400+i*50},{"y",650},{"scale",1.5},{"z",i<6?15:40}}},
|
||||
{"hitArea",{{"width",100},{"height",80},{"offsetX",10},{"offsetY",-30}}},
|
||||
{"state",{{"status","built"},{"completedLevel",cap},{"targetLevel",cap}}},
|
||||
{"sprites",{{"variants",variants},{"overlays",overlays},{"marker",add("marker")}}}});
|
||||
}
|
||||
return config;
|
||||
}
|
||||
void periphery() {
|
||||
for(int precision:{0,2}) {
|
||||
Fixture fixture(precision);const auto &world=*fixture.world;const int64_t factor=precision?100:1;
|
||||
Json defaults;defaults=Json::object();require(migrate_demo_stadium(defaults,world),"Initialize periphery fixture");
|
||||
auto old=defaults;old["stadium"].erase("periphery");const auto before=old;
|
||||
require(migrate_demo_stadium(old,world)&&old==defaults,"Old four-field checkpoint not extended exactly");
|
||||
old=before;old["stadium"]["budget"]=3;const auto broken=old;
|
||||
require(!migrate_demo_stadium(old,world)&&old==broken,"Invalid old ledger repaired during periphery migration");
|
||||
for(int i=0;i<14;++i) {
|
||||
const int cap=i==0?4:i==4?3:1;
|
||||
for(int level=0;level<cap;++level) {
|
||||
auto state=defaults;state["stadium"]["periphery"][size_t(i)]["level"]=level;
|
||||
const auto request=Json{{"kind","periphery"},{"index",i},{"level",level+1}};
|
||||
const auto q=demo_stadium_quote(state,request,world);require(q.at("can_build")==true,"Next periphery level rejected");
|
||||
const auto keep=state;reject_build(state,{{"kind","periphery"},{"index",i},{"level",level+2}},world);
|
||||
reject_build(state,{{"kind","periphery"},{"index",i},{"level",level}},world);
|
||||
build(state,request,world);conserved(state,world,factor);
|
||||
const auto current=demo_stadium_view(state,world),future=demo_stadium_view(state,world,true);
|
||||
require(current.at("periphery")[size_t(i)].at("display_level")==level&&future.at("periphery")[size_t(i)].at("display_level")==level+1,"Periphery current/future projection wrong");
|
||||
auto other=state;other["stadium"]["periphery"]=keep.at("stadium").at("periphery");other["stadium"]["budget"]=keep.at("stadium").at("budget");require(other==keep,"Periphery build affected another ledger or finance");
|
||||
reject_build(state,request,world);
|
||||
const auto checkpoint=Json::parse(state.dump());require(valid_demo_stadium(checkpoint,world)&&checkpoint==state,"Periphery checkpoint loses pending weeks/level");
|
||||
auto corrupt=state;corrupt["stadium"]["periphery"][size_t(i)]["job"]["level"]=level+2;require(!valid_demo_stadium(corrupt,world),"Skipped queued periphery level accepted");
|
||||
corrupt=state;corrupt["stadium"]["periphery"][size_t(i)]["job"]["weeks"]=1;require(!valid_demo_stadium(corrupt,world),"Invalid periphery weeks accepted");
|
||||
}
|
||||
}
|
||||
auto state=defaults;for(auto &row:state["stadium"]["periphery"])row["level"]=0;
|
||||
const auto config=scene_fixture(),keep=config;
|
||||
const auto initial=demo_stadium_scene(config,demo_stadium_view(state,world),false);
|
||||
require(initial.at("layers").size()==2&&initial.at("traffic_level")==0,"Export full-build preview leaked into empty career");
|
||||
const auto &area=initial.at("areas")[0];require(area.at("x")==340&&area.at("y")==545&&area.at("width")==150&&area.at("height")==120,"Calibrated hit area did not scale around object transform");
|
||||
build(state,{{"kind","periphery"},{"index",4},{"level",1}},world);
|
||||
build(state,{{"kind","periphery"},{"index",6},{"level",1}},world);
|
||||
build(state,{{"kind","periphery"},{"index",0},{"level",1}},world);
|
||||
auto current=demo_stadium_scene(config,demo_stadium_view(state,world),false),future=demo_stadium_scene(config,demo_stadium_view(state,world,true),true);
|
||||
require(current.at("traffic_level")==1&&future.at("traffic_level")==1,"Construction transport target panorama wrong");
|
||||
bool overlay=false,marker=false;for(const auto &layer:current.at("layers")) {
|
||||
overlay|=layer.at("owner")==4&&layer.at("role")=="overlay";
|
||||
marker|=layer.at("owner")==6&&layer.at("role")=="marker";
|
||||
if(layer.at("owner")==6)require(layer.at("role")=="marker","Snack building appears before completion");
|
||||
if(layer.at("owner")==4)require(std::abs(layer.at("x").get<double>()-402)<.00001&&std::abs(layer.at("y").get<double>()-351.5)<.00001,"PNG anchor/offset geometry changed");
|
||||
}
|
||||
require(overlay&&marker,"Missing parking overlay or independent snack marker");
|
||||
for(const auto &layer:future.at("layers"))require(layer.at("role")!="overlay"&&layer.at("role")!="marker","Future preview retains construction overlay");
|
||||
auto overview=demo_stadium_view(state,world);const std::array<int,5> boundaries{10000,25000,50000,75000,100000};
|
||||
for(size_t i=0;i<boundaries.size();++i)for(int delta:{-1,0}) {overview["physical_capacity"]=boundaries[i]+delta;require(demo_stadium_scene(config,overview,false).at("stadium_index")==i+(delta==0),"Capacity boundary selects wrong stadium");}
|
||||
require(config==keep,"Scene projection mutated calibrated export");
|
||||
auto block_state=defaults;build(block_state,block(0,4000),world);require(demo_stadium_view(block_state,world).at("physical_capacity")==36000&&demo_stadium_view(block_state,world,true).at("physical_capacity")==37000,"Closed block shrinks physical stadium artwork");
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
int main() try {
|
||||
currency(0); currency(2);
|
||||
currency(0); currency(2); periphery();
|
||||
Fixture empty(0, false); Json state = {{"cash", 77}, {"ticket", 13}};
|
||||
require(migrate_demo_stadium(state, *empty.world) && valid_demo_stadium(state, *empty.world) && state.at("stadium").at("club") == "" && demo_stadium_view(state, *empty.world).at("stadium").is_null() && demo_stadium_view(state, *empty.world).at("name") == "Stadion", "Zero-club fixture invented identity or crashed");
|
||||
const auto saved = state; require(!migrate_demo_stadium(state, *empty.world, "club:missing") && state == saved, "Invalid explicit club accepted");
|
||||
|
||||
@@ -140,7 +140,7 @@ void check_stadium_source(const fs::path &root, const std::shared_ptr<const Cata
|
||||
!source.apply({built.revision, "stadium", {{"kind", "build"}, {"request",
|
||||
{{"kind", "periphery"}, {"index", 0}, {"level", 1}}}}}).ok &&
|
||||
source.snapshot().state == built.state && source.snapshot().revision == built.revision,
|
||||
"Stale, duplicate or excluded periphery build changed state");
|
||||
"Stale, duplicate or unchanged periphery build changed state");
|
||||
const auto file = root / "stadium.ui.json";
|
||||
source.save(file, default_desktop());
|
||||
require(source.apply({source.snapshot().revision, "ticket", 9}).ok &&
|
||||
@@ -162,6 +162,37 @@ void check_stadium_source(const fs::path &root, const std::shared_ptr<const Cata
|
||||
source.snapshot().state.at("cash") == built.state.at("cash") &&
|
||||
source.snapshot().state.at("ticket") == built.state.at("ticket"),
|
||||
"Legacy stadium migration reset unrelated values");
|
||||
const auto perimeter_initial = source.snapshot();
|
||||
const auto perimeter_action = [](int level) {
|
||||
return Json{{"kind", "build"}, {"request", {{"kind", "periphery"}, {"index", 0}, {"level", level}}}};
|
||||
};
|
||||
require(!source.apply({perimeter_initial.revision, "stadium", perimeter_action(3)}).ok &&
|
||||
source.snapshot().state == perimeter_initial.state,
|
||||
"Source accepted skipped periphery level");
|
||||
require(source.apply({perimeter_initial.revision, "stadium", perimeter_action(2)}).ok,
|
||||
"Periphery next level did not cross source boundary");
|
||||
const auto perimeter_built = source.snapshot();
|
||||
require(perimeter_built.revision == perimeter_initial.revision + 1 && source.dirty() &&
|
||||
perimeter_built.state.at("stadium").at("periphery")[0].at("job").at("level") == 2 &&
|
||||
!source.apply({perimeter_initial.revision, "stadium", perimeter_action(2)}).ok &&
|
||||
!source.apply({perimeter_built.revision, "stadium", perimeter_action(2)}).ok &&
|
||||
source.snapshot().state == perimeter_built.state,
|
||||
"Periphery stale/duplicate booking changed source");
|
||||
for (const auto &[key, value] : perimeter_initial.state.items())
|
||||
if (key != "stadium") require(perimeter_built.state.at(key) == value, "Periphery changed unrelated state");
|
||||
source.save(file, default_desktop());
|
||||
require(source.apply({source.snapshot().revision, "ticket", 8}).ok, "Ticket change failed");
|
||||
source.load(file);
|
||||
require(source.snapshot().state == perimeter_built.state && !source.dirty(),
|
||||
"Periphery pending checkpoint did not roundtrip");
|
||||
auto old_stadium = Json::parse(bmh::editor::read_file(file));
|
||||
old_stadium["stadium"].erase("periphery");
|
||||
old_stadium["stadium"]["budget"] = initial.state.at("stadium").at("budget");
|
||||
write(root, "old-four-field-stadium.ui.json", old_stadium);
|
||||
source.load(root / "old-four-field-stadium.ui.json");
|
||||
require(source.snapshot().state.at("stadium") == initial.state.at("stadium") &&
|
||||
source.snapshot().state.at("ticket") == perimeter_built.state.at("ticket"),
|
||||
"Old four-field checkpoint did not migrate periphery through source");
|
||||
}
|
||||
void check_finance_source(const fs::path &root,
|
||||
const std::shared_ptr<const Catalog> &base) {
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
"""Attach the approved calibrated Sprite Studio to a private Modern GUI package.
|
||||
|
||||
Use an independently extracted private reference tree, never an OBW directory.
|
||||
The source configuration and PNG canvases are copied byte for byte.
|
||||
"""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import re
|
||||
import shutil
|
||||
import struct
|
||||
|
||||
CONFIG_HASH = '7e3e6a013703b392964a0151b17b00d40fb582ea6f51ce125345e080e49cbada'
|
||||
SOURCE_REVISION = '82914ae809b12f69c6abfaa7addfcecc7378dd81'
|
||||
|
||||
|
||||
def prepare(studio, output):
|
||||
studio = studio.resolve(strict=True)
|
||||
output = output.resolve(strict=True)
|
||||
if studio == output or studio in output.parents or output in studio.parents:
|
||||
raise ValueError('Source and GUI output must be separate directories')
|
||||
manifest_path = output / 'gui-assets.json'
|
||||
manifest = json.loads(manifest_path.read_text())
|
||||
if manifest['schema'] != 'openbmh-gui-assets@1':
|
||||
raise ValueError('Expected an existing private Modern GUI resource package')
|
||||
raw = (studio / 'configurations/OpenBMH-configuration-Stadium.json').read_bytes()
|
||||
if hashlib.sha256(raw).hexdigest() != CONFIG_HASH:
|
||||
raise ValueError('Configuration differs from approved calibrated export')
|
||||
config = json.loads(raw)
|
||||
if len(config['assets']) != 34:
|
||||
raise ValueError('Expected all 34 approved PNGs')
|
||||
# Validate every input before copying anything or publishing the manifest.
|
||||
sources = []
|
||||
for asset_id, asset in config['assets'].items():
|
||||
if not re.fullmatch(r'[a-z0-9-]+', asset_id) or asset['path'] != f'assets/{asset_id}.png':
|
||||
raise ValueError('Unsafe stadium asset path')
|
||||
source = (studio / asset['path']).resolve(strict=True)
|
||||
if not source.is_relative_to(studio):
|
||||
raise ValueError('Stadium PNG escapes source directory')
|
||||
data = source.read_bytes()
|
||||
if hashlib.sha256(data).hexdigest() != asset['sha256'] or data[:8] != b'\x89PNG\r\n\x1a\n' or struct.unpack('>II', data[16:24]) != (asset['width'], asset['height']):
|
||||
raise ValueError(f'PNG hash/dimensions mismatch: {asset_id}')
|
||||
sources.append((asset_id, source, asset))
|
||||
destination = output / 'stadium-scene'
|
||||
if not destination.resolve().is_relative_to(output):
|
||||
raise ValueError('Stadium output escapes GUI package')
|
||||
destination.mkdir(exist_ok=True)
|
||||
for asset_id, source, asset in sources:
|
||||
target = destination / f'{asset_id}.png'
|
||||
if not target.resolve().is_relative_to(output):
|
||||
raise ValueError('Stadium output escapes GUI package')
|
||||
shutil.copyfile(source, target)
|
||||
manifest['items'][f'stadium.scene.{asset_id}'] = {'file': f'stadium-scene/{asset_id}.png', 'sha256': asset['sha256']}
|
||||
(destination / 'configuration.json').write_bytes(raw)
|
||||
manifest['items']['stadium.scene'] = {'file': 'stadium-scene/configuration.json', 'sha256': CONFIG_HASH, 'source_revision': SOURCE_REVISION}
|
||||
manifest_path.write_text(json.dumps(manifest, ensure_ascii=False, indent=2) + '\n')
|
||||
print('Prepared calibrated stadium configuration and 34 unchanged GUI PNGs')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--studio', type=Path, required=True)
|
||||
parser.add_argument('--output', type=Path, required=True)
|
||||
args = parser.parse_args()
|
||||
prepare(args.studio, args.output)
|
||||
Reference in new issue
Block a user