Port scoped National UI routes and isolated dummy planning (by Codex)
This commit is contained in:
1 parent
4fddecb06e
commit
1eb5e99847
19 files changed
+1075
-8
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
<rml>
|
<rml>
|
||||||
<head><title>OpenBMH</title><link type="text/rcss" href="theme.rcss"/><link type="text/rcss" href="ticket.rcss"/><link type="text/rcss" href="sports.rcss"/><link type="text/rcss" href="calendar.rcss"/><link type="text/rcss" href="reports.rcss"/><link type="text/rcss" href="report_details.rcss"/><link type="text/rcss" href="report_pickers.rcss"/><link type="text/rcss" href="indoor.rcss"/><link type="text/rcss" href="planning.rcss"/><link type="text/rcss" href="almanac.rcss"/><link type="text/rcss" href="finance.rcss"/>
|
<head><title>OpenBMH</title><link type="text/rcss" href="theme.rcss"/><link type="text/rcss" href="ticket.rcss"/><link type="text/rcss" href="sports.rcss"/><link type="text/rcss" href="calendar.rcss"/><link type="text/rcss" href="reports.rcss"/><link type="text/rcss" href="report_details.rcss"/><link type="text/rcss" href="report_pickers.rcss"/><link type="text/rcss" href="indoor.rcss"/><link type="text/rcss" href="planning.rcss"/><link type="text/rcss" href="almanac.rcss"/><link type="text/rcss" href="finance.rcss"/>
|
||||||
<link type="text/rcss" href="bank.rcss"/><link type="text/rcss" href="contracts.rcss"/><link type="text/rcss" href="amount.rcss"/><link type="text/rcss" href="environment.rcss"/><link type="text/rcss" href="advertising.rcss"/><link type="text/rcss" href="toto.rcss"/><link type="text/rcss" href="lineup.rcss"/><link type="text/rcss" href="transfer.rcss"/><link type="text/rcss" href="career_reports.rcss"/><link type="text/rcss" href="rankings.rcss"/><link type="text/rcss" href="stadium.rcss"/><link type="text/rcss" href="statistics.rcss"/><link type="text/rcss" href="news.rcss"/><link type="text/rcss" href="settings.rcss"/><link type="text/rcss" href="widgets.rcss"/><link type="text/rcss" href="files.rcss"/><link type="text/rcss" href="front.rcss"/><link type="text/rcss" href="entry.rcss"/><link type="text/rcss" href="career.rcss"/><link type="text/rcss" href="opening.rcss"/><link type="text/rcss" href="select_menu.rcss"/><link type="text/rcss" href="live.rcss"/></head>
|
<link type="text/rcss" href="bank.rcss"/><link type="text/rcss" href="contracts.rcss"/><link type="text/rcss" href="amount.rcss"/><link type="text/rcss" href="environment.rcss"/><link type="text/rcss" href="advertising.rcss"/><link type="text/rcss" href="toto.rcss"/><link type="text/rcss" href="lineup.rcss"/><link type="text/rcss" href="transfer.rcss"/><link type="text/rcss" href="career_reports.rcss"/><link type="text/rcss" href="rankings.rcss"/><link type="text/rcss" href="stadium.rcss"/><link type="text/rcss" href="statistics.rcss"/><link type="text/rcss" href="news.rcss"/><link type="text/rcss" href="settings.rcss"/><link type="text/rcss" href="widgets.rcss"/><link type="text/rcss" href="files.rcss"/><link type="text/rcss" href="front.rcss"/><link type="text/rcss" href="entry.rcss"/><link type="text/rcss" href="career.rcss"/><link type="text/rcss" href="national.rcss"/><link type="text/rcss" href="opening.rcss"/><link type="text/rcss" href="select_menu.rcss"/><link type="text/rcss" href="live.rcss"/></head>
|
||||||
<body class="midnight">
|
<body class="midnight">
|
||||||
<div id="background"></div>
|
<div id="background"></div>
|
||||||
<div id="canvas"></div>
|
<div id="canvas"></div>
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
/* SPDX-License-Identifier: GPL-3.0-only */
|
||||||
|
.national-root {position:absolute;left:0;right:0;top:0;bottom:0;font-size:34dp;}
|
||||||
|
.national-heading {position:absolute;left:0;right:0;top:0;height:120dp;}
|
||||||
|
.national-heading h2 {font-size:48dp;font-weight:normal;margin:0;display:flex;align-items:center;gap:30dp;width:100%;}
|
||||||
|
.national-heading p {font-size:30dp;color:var(--muted);margin:12dp 0;display:flex;align-items:center;width:100%;}
|
||||||
|
.national-team-label {display:flex;align-items:center;gap:20dp;vertical-align:middle;}
|
||||||
|
.national-team-label>.image-frame {flex-shrink:0;}
|
||||||
|
.national-cup {position:absolute;border:2dp var(--border);border-radius:26dp;background-color:var(--panel);padding:30dp;display:flex;flex-direction:column;align-items:center;justify-content:center;}
|
||||||
|
.national-cup-art {width:100%;height:600dp;display:flex;justify-content:center;}
|
||||||
|
.national-cup h3 {font-size:38dp;margin:30dp 0;font-weight:normal;}
|
||||||
|
.national-cup strong {font-size:45dp;color:var(--accent);}
|
||||||
|
.national-cup p {font-size:30dp;color:var(--muted);margin:30dp 0;text-align:center;width:100%;}
|
||||||
|
.national-history {position:absolute;left:0;right:0;bottom:0;height:230dp;padding:30dp;border-top:2dp var(--border);}
|
||||||
|
.national-history h3 {font-size:32dp;}.national-history p {font-size:30dp;color:var(--muted);margin-top:24dp;}
|
||||||
|
.national-opponent {position:absolute;display:flex;flex-direction:column;justify-content:center;align-items:center;gap:22dp;border:2dp var(--border);border-radius:24dp;background-color:var(--panel);font-size:38dp;}
|
||||||
|
.national-opponent>.image-frame {flex-shrink:0;}.national-opponent small {font-size:28dp;color:var(--muted);}
|
||||||
|
.national-actions {position:absolute;left:0;right:0;bottom:0;height:100dp;display:flex;justify-content:flex-end;gap:25dp;}
|
||||||
|
.national-actions button {height:94dp;font-size:32dp;padding:12dp 28dp;}
|
||||||
|
.national-month {position:absolute;left:0;top:150dp;width:1540dp;bottom:140dp;padding:26dp;border:2dp var(--border);border-radius:24dp;}
|
||||||
|
.national-month>header {position:absolute;left:26dp;right:26dp;top:26dp;height:74dp;display:flex;align-items:center;justify-content:space-between;gap:20dp;}
|
||||||
|
.national-month h3 {font-size:38dp;font-weight:normal;}.national-month header button {width:84dp;height:74dp;font-size:40dp;}
|
||||||
|
.national-weekday,.national-day {position:absolute;display:flex;align-items:center;justify-content:center;font-size:36dp;}
|
||||||
|
.national-weekday {font-size:24dp;color:var(--muted);}.national-day {border:2dp var(--border);border-radius:14dp;background-color:var(--soft);padding:0;}
|
||||||
|
.national-day[disabled] {opacity:.35;border-color:transparent;background-color:transparent;}
|
||||||
|
.national-day.selected {border-color:var(--accent);background-color:var(--selected);}
|
||||||
|
.national-selection {position:absolute;left:1585dp;right:0;top:150dp;bottom:140dp;border:2dp var(--border);border-radius:24dp;background-color:var(--panel);padding:40dp;overflow-y:auto;}
|
||||||
|
.national-selection h3 {font-size:38dp;}.national-selection h4 {font-size:30dp;margin-top:35dp;}.national-selection p {font-size:30dp;line-height:45dp;color:var(--muted);margin:24dp 0;}
|
||||||
|
.national-stat-tabs {position:absolute;left:0;right:0;top:150dp;height:94dp;display:flex;gap:20dp;}
|
||||||
|
.national-stat-tabs button {flex:1;font-size:34dp;}.national-stat-tabs .selected {border-color:var(--accent);background-color:var(--selected);}
|
||||||
|
.national-stat-scroll {position:absolute;left:0;right:0;top:274dp;bottom:100dp;overflow-y:auto;}
|
||||||
|
.national-stat-row {height:96dp;display:flex;align-items:center;border-bottom:2dp var(--border);font-size:34dp;}
|
||||||
|
.national-stat-row>span:first-child {width:110dp;text-align:center;flex-shrink:0;}
|
||||||
|
.national-stat-row>.national-player {width:1260dp;padding:0 20dp;text-align:left;background-color:transparent;border:0;flex-shrink:0;}
|
||||||
|
.national-stat-row>.national-team-label {width:900dp;flex-shrink:0;}
|
||||||
|
.national-stat-row>span:last-child {width:330dp;text-align:center;flex-shrink:0;}
|
||||||
|
.national-stat-head {height:72dp;color:var(--muted);font-size:26dp;}.national-stat-head>span:nth-child(2) {width:1260dp;}.national-stat-head>span:nth-child(3) {width:900dp;}
|
||||||
|
.national-note {position:absolute;left:0;right:0;bottom:0;height:65dp;font-size:26dp;line-height:36dp;color:var(--muted);}
|
||||||
|
.national-dialog-layer {left:0;right:0;top:0;bottom:0;padding:0;}
|
||||||
|
.national-dialog {width:2484dp;}.national-dialog>h2 {width:100%;text-align:center;margin-bottom:35dp;}
|
||||||
|
.national-dialog p {font-size:32dp;line-height:48dp;margin:32dp 0;}
|
||||||
|
.national-dialog .national-team-label {font-size:38dp;}.national-dialog footer button {height:94dp;}
|
||||||
|
|
||||||
|
.national-month h3 {flex:1;width:100%;text-align:center;}
|
||||||
|
.national-month h3>span {width:100%;}
|
||||||
|
|
||||||
|
.national-stat-row>.national-player.control-button {justify-content:flex-start;}
|
||||||
@@ -87,3 +87,5 @@ Die [Widgetdokumentation](widgets/README.md) beschreibt den nativen Katalog,
|
|||||||
Raster und Arbeitsanordnung; die [Dateiverwaltung](save-load/README.md) die
|
Raster und Arbeitsanordnung; die [Dateiverwaltung](save-load/README.md) die
|
||||||
getrennten Karriere- und Ansichtsdateien. Beide lesen weiterhin Demodaten und
|
getrennten Karriere- und Ansichtsdateien. Beide lesen weiterhin Demodaten und
|
||||||
bestätigen keine Engine-Spielbarkeit.
|
bestätigen keine Engine-Spielbarkeit.
|
||||||
|
|
||||||
|
[Nationalmannschaft: getrennte Erfolge, Spielerstatistik und Dummy-Freundschaftsplanung](national/README.md).
|
||||||
@@ -9,3 +9,10 @@ Der erste Manager und dessen Verein werden aus dem aktuellen Snapshot gelesen. V
|
|||||||
Seite und Dialog liegen ausschließlich in `career_view_`. Öffnen, Blättern, Profilansicht und Schließen verändern weder den kanonischen Demozustand noch Revision, Wallet, RNG, Engine oder OBW. Ein Vereins-/Weltwechsel darf keine alte Vereinsgeschichte stillschweigend einem anderen Verein zuordnen. Später muss ein Sitzungsadapter die Diagramm- und Historienwerte aus tatsächlichen Saisonaufzeichnungen liefern.
|
Seite und Dialog liegen ausschließlich in `career_view_`. Öffnen, Blättern, Profilansicht und Schließen verändern weder den kanonischen Demozustand noch Revision, Wallet, RNG, Engine oder OBW. Ein Vereins-/Weltwechsel darf keine alte Vereinsgeschichte stillschweigend einem anderen Verein zuordnen. Später muss ein Sitzungsadapter die Diagramm- und Historienwerte aus tatsächlichen Saisonaufzeichnungen liefern.
|
||||||
|
|
||||||
Synthetische Providerprüfungen decken die fünf Fenster, acht beziehungsweise zwölf Saisons, vier Ligafarben, Titel und Nichtteilnahme, Saisonwechsel, ungültige Seiten, kurze/leere Kataloge, aktuelle Manageridentität, Filterunabhängigkeit und unveränderte Eingaben ab. Der gemeinsame Linux-Build und alle 28 Regressionstests sind bestanden. Die native Abnahme umfasst alle drei Themes bei 1920×1080 und 1280×720, die fünf Seiten samt Grenzen, zwölf Historienzeilen, Tabumlauf, Profilrücknavigation, unveränderte Fullstate-/Revisions-/Dirtywerte und einen tatsächlichen Checkpoint-Neustart. Gezielte Nachbilder bestätigen die korrigierte Linksausrichtung der Vereinsangabe. Ein zusätzlicher unabhängiger Silver-720-Lauf bestätigt das erneute Öffnen von Profil und Vereinsgeschichte per Tastatur. Die privaten Nachweise liegen im Statistik-QA-Paket; eine Windows-/macOS-Laufzeitabnahme wird damit nicht behauptet.
|
Synthetische Providerprüfungen decken die fünf Fenster, acht beziehungsweise zwölf Saisons, vier Ligafarben, Titel und Nichtteilnahme, Saisonwechsel, ungültige Seiten, kurze/leere Kataloge, aktuelle Manageridentität, Filterunabhängigkeit und unveränderte Eingaben ab. Der gemeinsame Linux-Build und alle 28 Regressionstests sind bestanden. Die native Abnahme umfasst alle drei Themes bei 1920×1080 und 1280×720, die fünf Seiten samt Grenzen, zwölf Historienzeilen, Tabumlauf, Profilrücknavigation, unveränderte Fullstate-/Revisions-/Dirtywerte und einen tatsächlichen Checkpoint-Neustart. Gezielte Nachbilder bestätigen die korrigierte Linksausrichtung der Vereinsangabe. Ein zusätzlicher unabhängiger Silver-720-Lauf bestätigt das erneute Öffnen von Profil und Vereinsgeschichte per Tastatur. Die privaten Nachweise liegen im Statistik-QA-Paket; eine Windows-/macOS-Laufzeitabnahme wird damit nicht behauptet.
|
||||||
|
|
||||||
|
## Nationalkontext
|
||||||
|
|
||||||
|
Im Nationalkontext ersetzt die [eigene Nationalansicht](../national/README.md)
|
||||||
|
diese Vereinsprojektion. Sie liest die aktive Manageridentität, zeigt keine
|
||||||
|
erfundenen Vereinsleistungen oder Nationalstatistiken und hält eventuelle
|
||||||
|
Dummy-Vormerkungen vollständig vom Vereinskalender und Geld getrennt.
|
||||||
@@ -146,3 +146,10 @@ Der Austragungsort heißt nativ „Heimspiel“ statt des im Gold fest gebundene
|
|||||||
„Heimspiel in Frankfurt“. Die Demo erfindet keinen Ortsdatensatz für andere
|
„Heimspiel in Frankfurt“. Die Demo erfindet keinen Ortsdatensatz für andere
|
||||||
verwaltete Vereine. Beim Wechsel über OS-Beenden → Speichern wird eine offene
|
verwaltete Vereine. Beim Wechsel über OS-Beenden → Speichern wird eine offene
|
||||||
Planungsauflage verworfen; der Speicherbildschirm bleibt per Tab bedienbar.
|
Planungsauflage verworfen; der Speicherbildschirm bleibt per Tab bedienbar.
|
||||||
|
|
||||||
|
## Nationalkontext
|
||||||
|
|
||||||
|
Im Nationalkontext ersetzt die [eigene Nationalansicht](../national/README.md)
|
||||||
|
diese Vereinsprojektion. Sie liest die aktive Manageridentität, zeigt keine
|
||||||
|
erfundenen Vereinsleistungen oder Nationalstatistiken und hält eventuelle
|
||||||
|
Dummy-Vormerkungen vollständig vom Vereinskalender und Geld getrennt.
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
# Nationalmannschaft · Erfolge, Spielerstatistik und Freundschaftsplanung
|
||||||
|
|
||||||
|
Stand: 27. Oktober 2026. Der native RmlUI-Port folgt der privaten HTML-Referenz
|
||||||
|
`66cd7572`, insbesondere `desktop/national-menus.js` und `.css`. Nur die drei
|
||||||
|
Routen Erfolge, Torjäger/Spielerstatistik und Freundschaftsspiele erhalten im
|
||||||
|
Nationalkontext diese eigene Darstellung. Die vorhandenen Vereinsansichten
|
||||||
|
bleiben erhalten. Die Entscheidung erfolgt über die bestätigte Karriere-Rolle
|
||||||
|
und die aktiv ausgewählte Manageridentität, nicht über Person 0.
|
||||||
|
|
||||||
|
## Sichtbare Daten und Grenzen
|
||||||
|
|
||||||
|
Erfolge zeigt zwei Pokalkarten für Welt- und Europameisterschaft und eine leere
|
||||||
|
Turnierhistorie. Ohne aufgezeichnete Ergebnisse werden weder Titel noch
|
||||||
|
Teilnahmen oder Vereinsmeisterschaften erfunden. Die Striche bedeuten fehlende
|
||||||
|
Aufzeichnungen, nicht eine bestätigte sportliche Nullbilanz.
|
||||||
|
|
||||||
|
Die Spielerstatistik bietet Tore, Vorlagen sowie gelbe und rote Karten. Ihre
|
||||||
|
Namen stammen aus der tatsächlichen, schreibgeschützten Kaderbasis des aktiven
|
||||||
|
Managers. Die Ansicht bezeichnet diese Basis ausdrücklich als POC und nicht
|
||||||
|
als echte Nationalberufung. Es liegen keine abgeschlossenen Nationalspiele im
|
||||||
|
nativen Demozustand vor; deshalb bleiben die Statistiken —. Die vorab lesbare
|
||||||
|
Live-Demo-Aufzeichnung wird nicht als absolviertes Spiel ausgewertet. Im
|
||||||
|
Spielerdialog werden vorhandene Katalogattribute `caps` nur dann gezeigt, wenn
|
||||||
|
sie nichtnegative Ganzzahlen sind; fehlende Angaben bleiben —. Engine-Adapter,
|
||||||
|
echte Berufungen und belastbare Spielaufzeichnungen stehen aus.
|
||||||
|
|
||||||
|
Die Freundschaftsplanung enthält dieselben acht Gegner-IDs wie Gold:
|
||||||
|
`national-fr`, `national-it`, `national-es`, `national-en`, `national-nl`,
|
||||||
|
`national-pl`, `national-se` und `national-at`. Namen und Flaggen gehören zum
|
||||||
|
GUI-Ressourcensatz. Die angegebenen Stärken sind ausdrücklich POC-Beispiele.
|
||||||
|
Heim/Auswärts führt zum Monatskalender von Juli bis Juni. Die zwölf möglichen
|
||||||
|
Dummyfenster liegen sieben Tage nach dem aktuellen Demodatum und danach alle
|
||||||
|
14 Tage, ausschließlich innerhalb der laufenden Saison. Sie behaupten keinen
|
||||||
|
FIFA-Kalender und lesen oder sperren keine Vereinskalendertermine.
|
||||||
|
|
||||||
|
## Zustand, Bedienung und Speicherung
|
||||||
|
|
||||||
|
`DemoSource.state.national` enthält genau `opponent`, `home`, `day`, `month`,
|
||||||
|
`stage`, `scorer_kind` und `friendlies`. Die Liste enthält höchstens zwölf
|
||||||
|
Einträge `{date, opponent, home}` mit eindeutigen, gültigen Saisondaten. Alte
|
||||||
|
Checkpoints ohne diesen Block erhalten einen leeren Standard. Vorhandene
|
||||||
|
ungültige Blöcke werden vollständig abgelehnt; es erfolgt keine stille
|
||||||
|
Reparatur. Auswahlen und Vormerkungen bleiben beim Checkpoint-Roundtrip erhalten.
|
||||||
|
|
||||||
|
Aktionen der Source-Kategorie `national` sind revisionsgebunden und verlangen
|
||||||
|
die aktive `manager_portrait` im Nationalkontext. Jede Übernahme validiert den
|
||||||
|
vollständigen neuen Nationalblock, bevor sie ihn atomar austauscht. Die Aktionen
|
||||||
|
verändern ausschließlich diesen Block: kein Geld, Vereinskalender, Datum,
|
||||||
|
Aufstellung, Vertrag oder Katalog. Das gleiche gilt für das Vormerken.
|
||||||
|
|
||||||
|
Austragungsort und Buchung besitzen eigene Bestätigungen. Abbrechen/Escape
|
||||||
|
schließt nur den offenen Dialog; eine abgebrochene Buchung legt keinen Termin
|
||||||
|
an. Tab bleibt im Dialog, danach kehrt der Fokus zum aufrufenden Knopf zurück.
|
||||||
|
Ein Quellen-, Revisions- oder Managerwechsel verwirft eine veraltete Bestätigung.
|
||||||
|
Die Liste der Vormerkungen und Spielerdetails sind rein lesend.
|
||||||
|
|
||||||
|
## Prüfstand
|
||||||
|
|
||||||
|
`modern_national_ui_tests` prüft mit synthetischem Katalog die Rollen-, Manager-
|
||||||
|
und Revisionsbindung, acht Gegner, fehlende Statistikwerte, zwölf Buchungen,
|
||||||
|
Saison- und Datumsgrenzen, fehlerhafte Checkpoints, Migration und Roundtrip sowie
|
||||||
|
atomare Ablehnung und die vollständige Unverändertheit aller übrigen Felder.
|
||||||
|
Linux-Coretest und nativer App-Link bestehen. Die Eingabeabnahme wird getrennt
|
||||||
|
mit tatsächlichem Binary-, GUI- und Welt-Hash dokumentiert; sie ist keine
|
||||||
|
Windows-/macOS-Abnahme und keine Enginefreigabe.
|
||||||
|
|
||||||
|
Die abschließende native Linux-Kohorte besteht aus drei Bedienläufen
|
||||||
|
(Midnight 1080p, Silver 720p, Matchday 1080p) und einem tatsächlichen Neustart.
|
||||||
|
41/41 Zustands-, Inhalts- und Textflächenprüfungen bestehen. Geprüft sind die
|
||||||
|
acht Gegner, Heim/Auswärts, beide Abbrüche, Bestätigung, Vormerkungsliste,
|
||||||
|
Statistikwechsel, unbekannte Vorlagen sowie identische Nationaldaten nach dem
|
||||||
|
Neustart. Vor und nach den Läufen bleiben Binary und Eingabewelt bytegleich.
|
||||||
|
Die Bilder wurden auf sichtbare Überschriften, Wochentage, lesbare Themefarben
|
||||||
|
und passende Inhaltsgrenzen geprüft. Eine numerische Glyphen-/Pixelparität zur
|
||||||
|
HTML-Referenz wird nicht behauptet.
|
||||||
@@ -102,3 +102,10 @@ den zugehörigen Ablauf reproduziert.
|
|||||||
Ein späterer Modern-Sessionadapter muss tatsächliche, zeitlich definierte
|
Ein späterer Modern-Sessionadapter muss tatsächliche, zeitlich definierte
|
||||||
Statistikprojektionen liefern. Der Renderer greift weder auf Enginearchive
|
Statistikprojektionen liefern. Der Renderer greift weder auf Enginearchive
|
||||||
noch auf `.obs` oder Classic-Spielstände zu.
|
noch auf `.obs` oder Classic-Spielstände zu.
|
||||||
|
|
||||||
|
## Nationalkontext
|
||||||
|
|
||||||
|
Im Nationalkontext ersetzt die [eigene Nationalansicht](../national/README.md)
|
||||||
|
diese Vereinsprojektion. Sie liest die aktive Manageridentität, zeigt keine
|
||||||
|
erfundenen Vereinsleistungen oder Nationalstatistiken und hält eventuelle
|
||||||
|
Dummy-Vormerkungen vollständig vom Vereinskalender und Geld getrennt.
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
# SPDX-License-Identifier: GPL-3.0-only
|
# SPDX-License-Identifier: GPL-3.0-only
|
||||||
add_library(bmh_modern_ui_core STATIC catalog.cpp model.cpp demo_career.cpp gui_assets.cpp desktop.cpp demo_sports.cpp demo_calendar.cpp demo_reports.cpp demo_almanac.cpp demo_finance.cpp demo_environment.cpp demo_advertising.cpp demo_toto.cpp demo_lineup.cpp demo_live.cpp demo_transfer.cpp demo_career_reports.cpp demo_rankings.cpp demo_stadium.cpp demo_statistics.cpp demo_news.cpp demo_settings.cpp ui_preferences.cpp demo_widgets.cpp demo_files.cpp demo_opening.cpp)
|
add_library(bmh_modern_ui_core STATIC catalog.cpp model.cpp demo_career.cpp demo_national_ui.cpp gui_assets.cpp desktop.cpp demo_sports.cpp demo_calendar.cpp demo_reports.cpp demo_almanac.cpp demo_finance.cpp demo_environment.cpp demo_advertising.cpp demo_toto.cpp demo_lineup.cpp demo_live.cpp demo_transfer.cpp demo_career_reports.cpp demo_rankings.cpp demo_stadium.cpp demo_statistics.cpp demo_news.cpp demo_settings.cpp ui_preferences.cpp demo_widgets.cpp demo_files.cpp demo_opening.cpp)
|
||||||
target_include_directories(bmh_modern_ui_core PUBLIC ../..)
|
target_include_directories(bmh_modern_ui_core PUBLIC ../..)
|
||||||
target_link_libraries(bmh_modern_ui_core PUBLIC bmh_asset_io)
|
target_link_libraries(bmh_modern_ui_core PUBLIC bmh_asset_io)
|
||||||
add_library(bmh_modern_ui_mods STATIC mod_library.cpp)
|
add_library(bmh_modern_ui_mods STATIC mod_library.cpp)
|
||||||
@@ -38,7 +38,7 @@ endif()
|
|||||||
set(modern_assets "${CMAKE_BINARY_DIR}/assets/modern")
|
set(modern_assets "${CMAKE_BINARY_DIR}/assets/modern")
|
||||||
FetchContent_GetProperties(rmlui)
|
FetchContent_GetProperties(rmlui)
|
||||||
file(MAKE_DIRECTORY "${modern_assets}")
|
file(MAKE_DIRECTORY "${modern_assets}")
|
||||||
foreach(asset modern.rml theme.rcss ticket.rcss sports.rcss calendar.rcss reports.rcss report_details.rcss report_pickers.rcss indoor.rcss planning.rcss almanac.rcss finance.rcss bank.rcss contracts.rcss amount.rcss environment.rcss advertising.rcss toto.rcss lineup.rcss live.rcss transfer.rcss career_reports.rcss rankings.rcss stadium.rcss statistics.rcss news.rcss settings.rcss widgets.rcss files.rcss front.rcss entry.rcss opening.rcss select_menu.rcss career.rcss)
|
foreach(asset modern.rml theme.rcss ticket.rcss sports.rcss calendar.rcss reports.rcss report_details.rcss report_pickers.rcss indoor.rcss planning.rcss almanac.rcss finance.rcss bank.rcss contracts.rcss amount.rcss environment.rcss advertising.rcss toto.rcss lineup.rcss live.rcss transfer.rcss career_reports.rcss rankings.rcss stadium.rcss statistics.rcss news.rcss settings.rcss widgets.rcss files.rcss front.rcss entry.rcss opening.rcss select_menu.rcss career.rcss national.rcss)
|
||||||
configure_file("${CMAKE_SOURCE_DIR}/assets/modern/${asset}" "${modern_assets}/${asset}" COPYONLY)
|
configure_file("${CMAKE_SOURCE_DIR}/assets/modern/${asset}" "${modern_assets}/${asset}" COPYONLY)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
@@ -124,7 +124,7 @@ foreach(component environment advertising toto lineup transfer stadium)
|
|||||||
add_test(NAME modern_${component}_ui_tests COMMAND modern_${component}_ui_tests)
|
add_test(NAME modern_${component}_ui_tests COMMAND modern_${component}_ui_tests)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
foreach(component statistics news settings desktop files entry opening career live)
|
foreach(component statistics news settings desktop files entry opening career live national)
|
||||||
add_executable(modern_${component}_ui_tests ../../../tests/modern_${component}_ui_tests.cpp)
|
add_executable(modern_${component}_ui_tests ../../../tests/modern_${component}_ui_tests.cpp)
|
||||||
target_link_libraries(modern_${component}_ui_tests PRIVATE bmh_modern_ui_core)
|
target_link_libraries(modern_${component}_ui_tests PRIVATE bmh_modern_ui_core)
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
|
|||||||
@@ -149,6 +149,7 @@ void App::ProcessEvent(Rml::Event &event) try {
|
|||||||
return;
|
return;
|
||||||
if(front_event(event))return;
|
if(front_event(event))return;
|
||||||
if (live_event(event)) return;
|
if (live_event(event)) return;
|
||||||
|
if(national_event(event))return;
|
||||||
if (career_event(event)) return;
|
if (career_event(event)) return;
|
||||||
if (entry_event(event)) return;
|
if (entry_event(event)) return;
|
||||||
if (opening_event(event)) return;
|
if (opening_event(event)) return;
|
||||||
@@ -467,6 +468,7 @@ void App::dispatch(const std::string &action, Rml::Element *target) {
|
|||||||
target ? target->GetAttribute<Rml::String>("data-id", "") : std::string();
|
target ? target->GetAttribute<Rml::String>("data-id", "") : std::string();
|
||||||
if(front_action(action,target))return;
|
if(front_action(action,target))return;
|
||||||
if (live_action(action, target)) return;
|
if (live_action(action, target)) return;
|
||||||
|
if(national_action(action,target))return;
|
||||||
if (career_action(action,target)) return;
|
if (career_action(action,target)) return;
|
||||||
if (entry_action(action, target)) return;
|
if (entry_action(action, target)) return;
|
||||||
if (opening_action(action, target)) return;
|
if (opening_action(action, target)) return;
|
||||||
@@ -991,7 +993,7 @@ void App::script() {
|
|||||||
{"transfer_view", transfer_view_}, {"transfer_dialog", transfer_dialog_}, {"transfer_draft", transfer_draft_},
|
{"transfer_view", transfer_view_}, {"transfer_dialog", transfer_dialog_}, {"transfer_draft", transfer_draft_},
|
||||||
{"career_view", career_view_}, {"rankings_view", rankings_view_},
|
{"career_view", career_view_}, {"rankings_view", rankings_view_},
|
||||||
{"stadium_view", stadium_view_},
|
{"stadium_view", stadium_view_},
|
||||||
{"select_menu", select_menu_ ? select_menu_->snapshot() : Json()}, {"career_context",source_?demo_career_context(snap().state,*world_):Json()}, {"manager_hub",{{"resign_open",career_resign_open_},{"game_end",career_game_end_},{"owner",field("career-resign-owner")}}}, {"entry_view", entry_snapshot()}, {"front_view",front_snapshot_view()}, {"files_view",{{"mode",files_mode_},{"selected",files_selected_},{"name",files_name_},{"feedback",files_feedback_}}}, {"widget_view",{{"query",widget_query_},{"notice",widget_notice_}}}, {"ui_preferences",ui_preferences_}, {"settings_draft",settings_draft_}, {"settings_category",settings_category_}, {"settings_query",settings_query_}, {"settings_notice",settings_notice_},
|
{"select_menu", select_menu_ ? select_menu_->snapshot() : Json()}, {"career_context",source_?demo_career_context(snap().state,*world_):Json()}, {"national_view",{{"dialog",national_dialog_},{"menu",national_menu_},{"portrait",national_portrait_},{"revision",national_revision_}}}, {"manager_hub",{{"resign_open",career_resign_open_},{"game_end",career_game_end_},{"owner",field("career-resign-owner")}}}, {"entry_view", entry_snapshot()}, {"front_view",front_snapshot_view()}, {"files_view",{{"mode",files_mode_},{"selected",files_selected_},{"name",files_name_},{"feedback",files_feedback_}}}, {"widget_view",{{"query",widget_query_},{"notice",widget_notice_}}}, {"ui_preferences",ui_preferences_}, {"settings_draft",settings_draft_}, {"settings_category",settings_category_}, {"settings_query",settings_query_}, {"settings_notice",settings_notice_},
|
||||||
{"statistics_view", statistics_view_}, {"statistics_trophy", statistics_trophy_},
|
{"statistics_view", statistics_view_}, {"statistics_trophy", statistics_trophy_},
|
||||||
{"statistics_scrolls", statistics_scrolls_},
|
{"statistics_scrolls", statistics_scrolls_},
|
||||||
{"news_view", news_view_}, {"news_dialog", news_dialog_},
|
{"news_view", news_view_}, {"news_dialog", news_dialog_},
|
||||||
|
|||||||
@@ -0,0 +1,272 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
#include "modern/ui/demo_national_ui.hpp"
|
||||||
|
#include "modern/ui/demo_career.hpp"
|
||||||
|
#include <algorithm>
|
||||||
|
#include <array>
|
||||||
|
#include <chrono>
|
||||||
|
#include <cmath>
|
||||||
|
#include <iomanip>
|
||||||
|
#include <optional>
|
||||||
|
#include <set>
|
||||||
|
#include <sstream>
|
||||||
|
namespace bmh::modern_ui {
|
||||||
|
namespace {
|
||||||
|
std::optional<std::chrono::sys_days> day(const Json &v) {
|
||||||
|
if (!v.is_string())
|
||||||
|
return {};
|
||||||
|
const auto s = v.get<std::string>();
|
||||||
|
if (s.size() != 10 || s[4] != '-' || s[7] != '-')
|
||||||
|
return {};
|
||||||
|
for (size_t i = 0; i < s.size(); ++i)
|
||||||
|
if (i != 4 && i != 7 && (s[i] < '0' || s[i] > '9'))
|
||||||
|
return {};
|
||||||
|
const auto ymd = std::chrono::year_month_day{
|
||||||
|
std::chrono::year{std::stoi(s.substr(0, 4))},
|
||||||
|
std::chrono::month{unsigned(std::stoi(s.substr(5, 2)))},
|
||||||
|
std::chrono::day{unsigned(std::stoi(s.substr(8, 2)))}};
|
||||||
|
if (!ymd.ok() || int(ymd.year()) < 1)
|
||||||
|
return {};
|
||||||
|
return std::chrono::sys_days{ymd};
|
||||||
|
}
|
||||||
|
std::string iso(std::chrono::sys_days value) {
|
||||||
|
const auto ymd = std::chrono::year_month_day{value};
|
||||||
|
std::ostringstream out;
|
||||||
|
out << int(ymd.year()) << '-' << std::setfill('0') << std::setw(2)
|
||||||
|
<< unsigned(ymd.month()) << '-' << std::setw(2) << unsigned(ymd.day());
|
||||||
|
return out.str();
|
||||||
|
}
|
||||||
|
bool opponent(const Json &v) {
|
||||||
|
return v.is_string() &&
|
||||||
|
std::any_of(national_ui_opponents().begin(),
|
||||||
|
national_ui_opponents().end(),
|
||||||
|
[&](const auto &row) { return row.at("id") == v; });
|
||||||
|
}
|
||||||
|
bool integer(const Json &v, int low, int high) {
|
||||||
|
return v.is_number_integer() && v >= low && v <= high;
|
||||||
|
}
|
||||||
|
int season(const Json &state) {
|
||||||
|
const auto date = day(state.at("date"));
|
||||||
|
if (!date)
|
||||||
|
throw editor::Error("invalid_national_date");
|
||||||
|
const auto ymd = std::chrono::year_month_day{*date};
|
||||||
|
return int(ymd.year()) - (unsigned(ymd.month()) < 7);
|
||||||
|
}
|
||||||
|
bool season_date(const Json &state, const Json &v) {
|
||||||
|
const auto d = day(v);
|
||||||
|
if (!d)
|
||||||
|
return false;
|
||||||
|
const int year = season(state);
|
||||||
|
return *d >= std::chrono::sys_days{std::chrono::year{year} / 7 / 1} &&
|
||||||
|
*d <= std::chrono::sys_days{std::chrono::year{year + 1} / 6 / 30};
|
||||||
|
}
|
||||||
|
Json attribute(const Json &p, const char *key) {
|
||||||
|
if (p.contains("attributes") && p.at("attributes").is_object()) {
|
||||||
|
const auto i = p.at("attributes").find(key);
|
||||||
|
if (i != p.at("attributes").end() && i->is_number_integer() &&
|
||||||
|
std::isfinite(i->get<double>()) && *i >= 0)
|
||||||
|
return *i;
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
const Json &national_ui_opponents() {
|
||||||
|
static const Json rows = [] {
|
||||||
|
Json out = Json::array();
|
||||||
|
int i = 0;
|
||||||
|
for (const auto &[code, name] :
|
||||||
|
std::array<std::pair<const char *, const char *>, 8>{
|
||||||
|
{{"fr", "Frankreich"},
|
||||||
|
{"it", "Italien"},
|
||||||
|
{"es", "Spanien"},
|
||||||
|
{"en", "England"},
|
||||||
|
{"nl", "Niederlande"},
|
||||||
|
{"pl", "Polen"},
|
||||||
|
{"se", "Schweden"},
|
||||||
|
{"at", "Österreich"}}}) {
|
||||||
|
out.push_back({{"id", std::string("national-") + code},
|
||||||
|
{"name", name},
|
||||||
|
{"code", code},
|
||||||
|
{"gui_image", std::string("career.national-") + code},
|
||||||
|
{"strength", 85 - (i++ % 5) * 2}});
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}();
|
||||||
|
return rows;
|
||||||
|
}
|
||||||
|
Json default_national_ui() {
|
||||||
|
return {{"opponent", "national-fr"},
|
||||||
|
{"home", true},
|
||||||
|
{"day", ""},
|
||||||
|
{"month", 0},
|
||||||
|
{"stage", "opponents"},
|
||||||
|
{"scorer_kind", 0},
|
||||||
|
{"friendlies", Json::array()}};
|
||||||
|
}
|
||||||
|
bool valid_national_ui(const Json &state) {
|
||||||
|
try {
|
||||||
|
if (!day(state.at("date")))
|
||||||
|
return false;
|
||||||
|
const auto &n = state.at("national");
|
||||||
|
if (!n.is_object() || n.size() != 7 || !opponent(n.at("opponent")) ||
|
||||||
|
!n.at("home").is_boolean() || !n.at("day").is_string() ||
|
||||||
|
(!n.at("day").get<std::string>().empty() &&
|
||||||
|
!season_date(state, n.at("day"))) ||
|
||||||
|
!integer(n.at("month"), 0, 11) || !n.at("stage").is_string() ||
|
||||||
|
(n.at("stage") != "opponents" && n.at("stage") != "calendar") ||
|
||||||
|
!integer(n.at("scorer_kind"), 0, 3) || !n.at("friendlies").is_array() ||
|
||||||
|
n.at("friendlies").size() > 12)
|
||||||
|
return false;
|
||||||
|
std::set<std::string> used;
|
||||||
|
for (const auto &row : n.at("friendlies"))
|
||||||
|
if (!row.is_object() || row.size() != 3 ||
|
||||||
|
!season_date(state, row.at("date")) ||
|
||||||
|
!opponent(row.at("opponent")) || !row.at("home").is_boolean() ||
|
||||||
|
!used.insert(row.at("date").get<std::string>()).second)
|
||||||
|
return false;
|
||||||
|
if (n.at("day") != "") {
|
||||||
|
const auto dates = national_ui_dates(state);
|
||||||
|
if (std::find(dates.begin(), dates.end(), n.at("day")) == dates.end())
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} catch (const std::exception &) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bool migrate_national_ui(Json &state) {
|
||||||
|
auto next = state;
|
||||||
|
if (!next.contains("national"))
|
||||||
|
next["national"] = default_national_ui();
|
||||||
|
if (!valid_national_ui(next))
|
||||||
|
return false;
|
||||||
|
state = std::move(next);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Json national_ui_dates(const Json &state) {
|
||||||
|
Json dates = Json::array();
|
||||||
|
try {
|
||||||
|
const auto current = day(state.at("date"));
|
||||||
|
if (!current)
|
||||||
|
return dates;
|
||||||
|
for (int i = 0; i < 12; ++i) {
|
||||||
|
const auto value = iso(*current + std::chrono::days{7 + i * 14});
|
||||||
|
if (!season_date(state, value))
|
||||||
|
continue;
|
||||||
|
const auto &bookings = state.at("national").at("friendlies");
|
||||||
|
if (std::none_of(bookings.begin(), bookings.end(),
|
||||||
|
[&](const auto &r) { return r.at("date") == value; }))
|
||||||
|
dates.push_back(value);
|
||||||
|
}
|
||||||
|
} catch (const std::exception &) {
|
||||||
|
}
|
||||||
|
return dates;
|
||||||
|
}
|
||||||
|
std::string edit_national_ui(Json &state, const Json &action) {
|
||||||
|
try {
|
||||||
|
if (!valid_national_ui(state) || !action.is_object() ||
|
||||||
|
!action.contains("kind") || !action.at("kind").is_string() ||
|
||||||
|
!action.contains("manager_portrait") ||
|
||||||
|
!action.at("manager_portrait").is_number_integer())
|
||||||
|
return "invalid_national_action";
|
||||||
|
if (state.at("career").value("role", "club") != "national" ||
|
||||||
|
state.at("career").value("ended", false) ||
|
||||||
|
action.at("manager_portrait") !=
|
||||||
|
demo_career_manager(state).value("portrait", 0))
|
||||||
|
return "national_context_changed";
|
||||||
|
auto next = state;
|
||||||
|
auto &n = next["national"];
|
||||||
|
const auto kind = action.at("kind").get<std::string>();
|
||||||
|
if (kind == "opponent") {
|
||||||
|
if (action.size() != 4 || !opponent(action.at("opponent")) ||
|
||||||
|
!action.at("home").is_boolean())
|
||||||
|
return "invalid_national_opponent";
|
||||||
|
n["opponent"] = action.at("opponent");
|
||||||
|
n["home"] = action.at("home");
|
||||||
|
n["stage"] = "calendar";
|
||||||
|
n["day"] = "";
|
||||||
|
const auto ymd = std::chrono::year_month_day{*day(state.at("date"))};
|
||||||
|
n["month"] = (int(ymd.year()) - season(state)) * 12 +
|
||||||
|
int(unsigned(ymd.month())) - 7;
|
||||||
|
} else if (kind == "month") {
|
||||||
|
if (action.size() != 3 || !integer(action.at("value"), 0, 11))
|
||||||
|
return "invalid_national_month";
|
||||||
|
n["month"] = action.at("value");
|
||||||
|
} else if (kind == "day") {
|
||||||
|
const auto dates = national_ui_dates(state);
|
||||||
|
if (action.size() != 3 || !action.at("value").is_string() ||
|
||||||
|
std::find(dates.begin(), dates.end(), action.at("value")) ==
|
||||||
|
dates.end())
|
||||||
|
return "invalid_national_day";
|
||||||
|
n["day"] = action.at("value");
|
||||||
|
} else if (kind == "book") {
|
||||||
|
const auto dates = national_ui_dates(state);
|
||||||
|
if (action.size() != 2 || n.at("friendlies").size() >= 12 ||
|
||||||
|
std::find(dates.begin(), dates.end(), n.at("day")) == dates.end())
|
||||||
|
return "invalid_national_booking";
|
||||||
|
n["friendlies"].push_back({{"date", n.at("day")},
|
||||||
|
{"opponent", n.at("opponent")},
|
||||||
|
{"home", n.at("home")}});
|
||||||
|
n["day"] = "";
|
||||||
|
} else if (kind == "back") {
|
||||||
|
if (action.size() != 2)
|
||||||
|
return "invalid_national_action";
|
||||||
|
n["stage"] = "opponents";
|
||||||
|
} else if (kind == "scorer_kind") {
|
||||||
|
if (action.size() != 3 || !integer(action.at("value"), 0, 3))
|
||||||
|
return "invalid_national_stat";
|
||||||
|
n["scorer_kind"] = action.at("value");
|
||||||
|
} else
|
||||||
|
return "invalid_national_action";
|
||||||
|
if (!valid_national_ui(next))
|
||||||
|
return "invalid_national_state";
|
||||||
|
state = std::move(next);
|
||||||
|
return {};
|
||||||
|
} catch (const std::exception &) {
|
||||||
|
return "invalid_national_action";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Json query_national_ui(const Catalog &world, const Json &state,
|
||||||
|
const std::string &menu) {
|
||||||
|
if (!valid_national_ui(state))
|
||||||
|
return {{"ok", false}, {"error", "invalid_national_state"}};
|
||||||
|
const auto context = demo_career_context(state, world);
|
||||||
|
if (context.at("role") != "national" || context.at("ended") == true)
|
||||||
|
return {{"ok", false}, {"error", "national_context_changed"}};
|
||||||
|
Json out = {{"ok", true},
|
||||||
|
{"fictional", true},
|
||||||
|
{"source", "ui-demo-unrecorded-national"},
|
||||||
|
{"team", context.at("current_team")},
|
||||||
|
{"manager", context.at("current_manager")},
|
||||||
|
{"planning", state.at("national")},
|
||||||
|
{"opponents", national_ui_opponents()},
|
||||||
|
{"available_dates", national_ui_dates(state)},
|
||||||
|
{"season", season(state)}};
|
||||||
|
if (menu == "achievements") {
|
||||||
|
out["tournaments"] =
|
||||||
|
Json::array({{{"name", "Weltmeisterschaft"},
|
||||||
|
{"gui_image", "trophy.world-cup"},
|
||||||
|
{"titles", nullptr}},
|
||||||
|
{{"name", "Europameisterschaft"},
|
||||||
|
{"gui_image", "trophy.european-championship"},
|
||||||
|
{"titles", nullptr}}});
|
||||||
|
out["history"] = Json::array();
|
||||||
|
} else if (menu == "scorers") {
|
||||||
|
out["recorded_matches"] = 0;
|
||||||
|
out["rows"] = Json::array();
|
||||||
|
out["roster_basis_club"] = demo_career_manager(state).value("club", "");
|
||||||
|
for (auto *p : world.squad(out.at("roster_basis_club").get<std::string>()))
|
||||||
|
out["rows"].push_back({{"id", p->at("id")},
|
||||||
|
{"name", world.name(*p)},
|
||||||
|
{"position", p->value("positions", Json::array())},
|
||||||
|
{"goals", nullptr},
|
||||||
|
{"assists", nullptr},
|
||||||
|
{"yellow", nullptr},
|
||||||
|
{"red", nullptr},
|
||||||
|
{"caps", attribute(*p, "caps")},
|
||||||
|
{"catalog_international_goals",
|
||||||
|
attribute(*p, "international_goals")}});
|
||||||
|
} else if (menu != "friendlies")
|
||||||
|
return {{"ok", false}, {"error", "unsupported_national_view"}};
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
} // namespace bmh::modern_ui
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
#pragma once
|
||||||
|
#include "modern/ui/catalog.hpp"
|
||||||
|
namespace bmh::modern_ui {
|
||||||
|
const Json &national_ui_opponents();
|
||||||
|
Json default_national_ui();
|
||||||
|
bool migrate_national_ui(Json &);
|
||||||
|
bool valid_national_ui(const Json &);
|
||||||
|
Json national_ui_dates(const Json &);
|
||||||
|
Json query_national_ui(const Catalog &, const Json &, const std::string &menu);
|
||||||
|
std::string edit_national_ui(Json &, const Json &);
|
||||||
|
} // namespace bmh::modern_ui
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "modern/ui/demo_almanac.hpp"
|
#include "modern/ui/demo_almanac.hpp"
|
||||||
#include "modern/ui/demo_calendar.hpp"
|
#include "modern/ui/demo_calendar.hpp"
|
||||||
#include "modern/ui/demo_career.hpp"
|
#include "modern/ui/demo_career.hpp"
|
||||||
|
#include "modern/ui/demo_national_ui.hpp"
|
||||||
#include "modern/ui/demo_environment.hpp"
|
#include "modern/ui/demo_environment.hpp"
|
||||||
#include "modern/ui/demo_finance.hpp"
|
#include "modern/ui/demo_finance.hpp"
|
||||||
#include "modern/ui/demo_lineup.hpp"
|
#include "modern/ui/demo_lineup.hpp"
|
||||||
@@ -233,6 +234,7 @@ DemoSource::DemoSource(std::shared_ptr<const Catalog> catalog)
|
|||||||
throw editor::Error("Ungültige Saisonvorbereitung.");
|
throw editor::Error("Ungültige Saisonvorbereitung.");
|
||||||
if (!migrate_demo_career(state_, *catalog_))
|
if (!migrate_demo_career(state_, *catalog_))
|
||||||
throw editor::Error("invalid_demo_career");
|
throw editor::Error("invalid_demo_career");
|
||||||
|
if(!migrate_national_ui(state_))throw editor::Error("invalid_demo_national");
|
||||||
saved_ = state_;
|
saved_ = state_;
|
||||||
}
|
}
|
||||||
Snapshot DemoSource::snapshot() const { return {revision_, catalog_, state_}; }
|
Snapshot DemoSource::snapshot() const { return {revision_, catalog_, state_}; }
|
||||||
@@ -251,7 +253,8 @@ ActionResult DemoSource::apply(const Action &action) {
|
|||||||
if(state_.value("career",Json::object()).value("ended",false)&&action.kind!="start")return {false,revision_,"career_ended"};
|
if(state_.value("career",Json::object()).value("ended",false)&&action.kind!="start")return {false,revision_,"career_ended"};
|
||||||
auto next = state_;
|
auto next = state_;
|
||||||
try {
|
try {
|
||||||
if (action.kind == "career") {
|
if(action.kind=="national"){const auto error=edit_national_ui(next,action.value);if(!error.empty())return {false,revision_,error};
|
||||||
|
} else if (action.kind == "career") {
|
||||||
const auto previous_club = demo_career_manager(next).value("club", "");
|
const auto previous_club = demo_career_manager(next).value("club", "");
|
||||||
const auto old_view = demo_career_view(next);
|
const auto old_view = demo_career_view(next);
|
||||||
const auto error = edit_demo_career(next, action.value, *catalog_);
|
const auto error = edit_demo_career(next, action.value, *catalog_);
|
||||||
@@ -552,6 +555,7 @@ Json DemoSource::load_data(Json data, bool saved) {
|
|||||||
throw editor::Error("invalid_demo_settings");
|
throw editor::Error("invalid_demo_settings");
|
||||||
if (!migrate_demo_opening(data, *catalog_))
|
if (!migrate_demo_opening(data, *catalog_))
|
||||||
throw editor::Error("Ungültige oder inkonsistente Saisonvorbereitung.");
|
throw editor::Error("Ungültige oder inkonsistente Saisonvorbereitung.");
|
||||||
|
if(!migrate_national_ui(data))throw editor::Error("invalid_demo_national");
|
||||||
for (const auto &[id,view]:data.at("career_views").items()) {
|
for (const auto &[id,view]:data.at("career_views").items()) {
|
||||||
auto probe=data;probe["career_views"]=Json::object();probe["desktop"]=default_desktop();
|
auto probe=data;probe["career_views"]=Json::object();probe["desktop"]=default_desktop();
|
||||||
probe["managers"]=Json::array({{{"name","Vorschau"},{"club",id},{"portrait",0}}});
|
probe["managers"]=Json::array({{{"name","Vorschau"},{"club",id},{"portrait",0}}});
|
||||||
|
|||||||
@@ -0,0 +1,157 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
bool App::national_action(const std::string &action, Rml::Element *target) {
|
||||||
|
if (!action.starts_with("national-") || !source_ || !world_)
|
||||||
|
return false;
|
||||||
|
const auto s = snap();
|
||||||
|
if (s.state.at("career").value("role", "club") != "national" ||
|
||||||
|
!std::set<std::string>{"achievements", "scorers", "friendlies"}.contains(
|
||||||
|
menu_) ||
|
||||||
|
!popup_.empty())
|
||||||
|
return false;
|
||||||
|
const auto id =
|
||||||
|
target ? target->GetAttribute<Rml::String>("data-id", "") : "";
|
||||||
|
const auto commit = [&](Json value) {
|
||||||
|
value["manager_portrait"] = national_portrait_;
|
||||||
|
if (national_source_ != source_.get()) {
|
||||||
|
national_dialog_.clear();
|
||||||
|
message("Die Nationalansicht hat sich geändert. Bitte erneut öffnen.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const auto result = source_->apply({national_revision_, "national", value});
|
||||||
|
if (!result.ok) {
|
||||||
|
national_dialog_.clear();
|
||||||
|
message("Die Nationalplanung hat sich geändert. Bitte erneut öffnen.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
refresh();
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
if (action == "national-close") {
|
||||||
|
national_dialog_.clear();
|
||||||
|
national_pending_.clear();
|
||||||
|
focus_after_render_ = national_return_focus_;
|
||||||
|
refresh();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!national_dialog_.empty()) {
|
||||||
|
if (national_dialog_ == "venue" &&
|
||||||
|
(action == "national-home" || action == "national-away")) {
|
||||||
|
const auto opponent = national_pending_;
|
||||||
|
national_dialog_.clear();
|
||||||
|
if (commit({{"kind", "opponent"},
|
||||||
|
{"opponent", opponent},
|
||||||
|
{"home", action == "national-home"}})) {
|
||||||
|
const auto dates = national_ui_dates(snap().state);
|
||||||
|
focus_after_render_ =
|
||||||
|
dates.empty() ? "national-back"
|
||||||
|
: "national-day-" + dates[0].get<std::string>();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (national_dialog_ == "book" && action == "national-confirm") {
|
||||||
|
national_dialog_.clear();
|
||||||
|
if (commit({{"kind", "book"}}))
|
||||||
|
focus_after_render_ = "national-list";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (target)
|
||||||
|
national_return_focus_ = target->GetId();
|
||||||
|
if (action == "national-opponent") {
|
||||||
|
national_pending_ = id;
|
||||||
|
national_dialog_ = "venue";
|
||||||
|
focus_after_render_ = "national-home";
|
||||||
|
refresh();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (action == "national-month") {
|
||||||
|
try {
|
||||||
|
commit({{"kind", "month"}, {"value", std::stoi(id)}});
|
||||||
|
} catch (const std::exception &) {
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (action == "national-day") {
|
||||||
|
if (commit({{"kind", "day"}, {"value", id}}))
|
||||||
|
focus_after_render_ = "national-day-" + id;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (action == "national-back") {
|
||||||
|
commit({{"kind", "back"}});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (action == "national-book") {
|
||||||
|
national_dialog_ = "book";
|
||||||
|
focus_after_render_ = "national-close";
|
||||||
|
refresh();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (action == "national-list") {
|
||||||
|
national_dialog_ = "list";
|
||||||
|
focus_after_render_ = "national-close";
|
||||||
|
refresh();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (action == "national-stat") {
|
||||||
|
try {
|
||||||
|
if (commit({{"kind", "scorer_kind"}, {"value", std::stoi(id)}}))
|
||||||
|
focus_after_render_ = "national-stat-" + id;
|
||||||
|
} catch (const std::exception &) {
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (action == "national-player") {
|
||||||
|
national_pending_ = id;
|
||||||
|
national_dialog_ = "player";
|
||||||
|
focus_after_render_ = "national-close";
|
||||||
|
refresh();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool App::national_event(Rml::Event &event) {
|
||||||
|
if (!source_ ||
|
||||||
|
!std::set<std::string>{"achievements", "scorers", "friendlies"}.contains(
|
||||||
|
menu_) ||
|
||||||
|
snap().state.at("career").value("role", "club") != "national" ||
|
||||||
|
national_dialog_.empty() || !popup_.empty())
|
||||||
|
return false;
|
||||||
|
const auto type = event.GetType();
|
||||||
|
const bool key = type == "keydown";
|
||||||
|
const auto code = key ? Rml::Input::KeyIdentifier(
|
||||||
|
event.GetParameter<int>("key_identifier", 0))
|
||||||
|
: Rml::Input::KI_UNKNOWN;
|
||||||
|
if (code == Rml::Input::KI_ESCAPE ||
|
||||||
|
(type == "mouseup" && event.GetParameter<int>("button", 0) == 1)) {
|
||||||
|
national_action("national-close", nullptr);
|
||||||
|
event.StopImmediatePropagation();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (code == Rml::Input::KI_TAB) {
|
||||||
|
Rml::ElementList rows;
|
||||||
|
if (auto *dialog = element("national-dialog-layer"))
|
||||||
|
dialog->QuerySelectorAll(rows, "button:not([disabled])");
|
||||||
|
if (!rows.empty()) {
|
||||||
|
const auto old =
|
||||||
|
std::find(rows.begin(), rows.end(), context_->GetFocusElement());
|
||||||
|
const int at = old == rows.end() ? -1 : int(old - rows.begin()),
|
||||||
|
step = event.GetParameter<int>("shift_key", 0) ? -1 : 1;
|
||||||
|
rows[size_t((at + step + int(rows.size())) % int(rows.size()))]->Focus(
|
||||||
|
true);
|
||||||
|
}
|
||||||
|
event.StopImmediatePropagation();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool inside = false;
|
||||||
|
for (auto *n = event.GetTargetElement(); n && n != doc_;
|
||||||
|
n = n->GetParentNode())
|
||||||
|
if (n->GetId() == "national-dialog-layer")
|
||||||
|
inside = true;
|
||||||
|
if (!inside && (type == "mousedown" || type == "mouseup" || type == "click" ||
|
||||||
|
type == "dblclick")) {
|
||||||
|
event.StopImmediatePropagation();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
@@ -0,0 +1,253 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
std::string App::render_national(const std::string &key) {
|
||||||
|
const auto s = snap();
|
||||||
|
const auto data = query_national_ui(*s.world, s.state, key);
|
||||||
|
if (!data.value("ok", false))
|
||||||
|
return "<p>Für diese Nationalansicht liegen keine Daten vor.</p>";
|
||||||
|
const auto context = demo_career_context(s.state, *s.world);
|
||||||
|
if (!national_dialog_.empty() &&
|
||||||
|
(national_source_ != source_.get() || national_revision_ != s.revision ||
|
||||||
|
national_portrait_ !=
|
||||||
|
context.at("current_manager").value("portrait", 0))) {
|
||||||
|
national_dialog_.clear();
|
||||||
|
national_pending_.clear();
|
||||||
|
}
|
||||||
|
national_source_ = source_.get();
|
||||||
|
national_revision_ = s.revision;
|
||||||
|
national_portrait_ = context.at("current_manager").value("portrait", 0);
|
||||||
|
if (national_menu_ != key) {
|
||||||
|
national_dialog_.clear();
|
||||||
|
national_pending_.clear();
|
||||||
|
national_menu_ = key;
|
||||||
|
}
|
||||||
|
const auto &n = data.at("planning");
|
||||||
|
const auto team = [&](const Json &t, int size = 62) {
|
||||||
|
return "<span class=\"national-team-label\">" +
|
||||||
|
img(t.value("gui_image", "career.national-de"), size,
|
||||||
|
size * 72.0 / 62.0, false, false, 256) +
|
||||||
|
"<span>" + esc(t.value("name", "Deutschland")) + "</span></span>";
|
||||||
|
};
|
||||||
|
const auto &opponents = national_ui_opponents();
|
||||||
|
const auto find_opponent = [&](const std::string &id) -> Json {
|
||||||
|
for (const auto &o : opponents)
|
||||||
|
if (o.at("id") == id)
|
||||||
|
return o;
|
||||||
|
return Json::object();
|
||||||
|
};
|
||||||
|
const auto own =
|
||||||
|
Json{{"name", "Deutschland"}, {"gui_image", "career.national-de"}};
|
||||||
|
std::string body =
|
||||||
|
"<div class=\"national-root\" id=\"national-underlay\"><header "
|
||||||
|
"class=\"national-heading\">";
|
||||||
|
if (key == "achievements") {
|
||||||
|
body += "<h2><span>Erfolge der "
|
||||||
|
"Nationalmannschaft</span></h2><p><span>Weltmeisterschaft und "
|
||||||
|
"Europameisterschaft</span></p></header>";
|
||||||
|
for (size_t i = 0; i < 2; ++i) {
|
||||||
|
const auto &t = data.at("tournaments")[i];
|
||||||
|
body += "<section class=\"national-cup\" style=\"" +
|
||||||
|
rect(i * 1326, 150, 1286, 1450) +
|
||||||
|
"\"><div class=\"national-cup-art\">" +
|
||||||
|
img(t.at("gui_image"), 1200, 600, false, false, 1200) +
|
||||||
|
"</div><h3>" + esc(t.at("name").get<std::string>()) +
|
||||||
|
"</h3><strong>—</strong><p>Keine Turnierergebnisse in dieser "
|
||||||
|
"POC-Karriere aufgezeichnet.</p></section>";
|
||||||
|
}
|
||||||
|
body += "<section "
|
||||||
|
"class=\"national-history\"><h3>Turnierhistorie</h3><p>Noch keine "
|
||||||
|
"abgeschlossene WM- oder EM-Teilnahme aufgezeichnet.</p></section>";
|
||||||
|
} else if (key == "scorers") {
|
||||||
|
body += "<h2><span>Spielerstatistiken</span></h2><p>" + team(own, 40) +
|
||||||
|
"<span> · keine erfassten abgeschlossenen "
|
||||||
|
"POC-Länderspiele</span></p></header><nav "
|
||||||
|
"class=\"national-stat-tabs\" role=\"tablist\">";
|
||||||
|
const std::array<const char *, 4> names = {"Tore", "Vorlagen",
|
||||||
|
"Gelbe Karten", "Rote Karten"};
|
||||||
|
const int kind = n.at("scorer_kind");
|
||||||
|
for (int i = 0; i < 4; ++i)
|
||||||
|
body +=
|
||||||
|
btn("national-stat", names[size_t(i)], i == kind ? "selected" : "",
|
||||||
|
"id=\"national-stat-" + std::to_string(i) + "\" data-id=\"" +
|
||||||
|
std::to_string(i) + "\" role=\"tab\" aria-selected=\"" +
|
||||||
|
(i == kind ? "true" : "false") + "\"");
|
||||||
|
body += "</nav><div class=\"national-stat-scroll\" "
|
||||||
|
"id=\"national-stat-scroll\"><div class=\"national-stat-row "
|
||||||
|
"national-stat-head\"><span>Pl.</span><span>Spieler</"
|
||||||
|
"span><span>Nationalmannschaft</span><span>" +
|
||||||
|
std::string(names[size_t(kind)]) + "</span></div>";
|
||||||
|
size_t row = 0;
|
||||||
|
for (const auto &p : data.at("rows")) {
|
||||||
|
const auto index = row++;
|
||||||
|
body +=
|
||||||
|
"<div class=\"national-stat-row\"><span>" +
|
||||||
|
std::to_string(index + 1) + "</span>" +
|
||||||
|
btn("national-player", esc(p.at("name").get<std::string>()),
|
||||||
|
"national-player",
|
||||||
|
"data-id=\"" + esc(p.at("id").get<std::string>()) +
|
||||||
|
"\" id=\"national-player-" + std::to_string(index) + "\"") +
|
||||||
|
team(own, 35) + "<span>—</span></div>";
|
||||||
|
}
|
||||||
|
body += "</div><p class=\"national-note\">POC-Kaderbasis des gewählten "
|
||||||
|
"Managers, keine echte Nationalberufung. Fehlende Länderspielwerte "
|
||||||
|
"und Vorlagen bleiben —.</p>";
|
||||||
|
} else {
|
||||||
|
const bool booking = n.at("stage") == "calendar";
|
||||||
|
const auto opponent = find_opponent(n.at("opponent"));
|
||||||
|
body += "<h2>" +
|
||||||
|
std::string(booking ? team(own) + "<span>–</span>" + team(opponent)
|
||||||
|
: "<span>Länderspiel vereinbaren</span>") +
|
||||||
|
"</h2><p><span>" +
|
||||||
|
(booking ? std::string(n.at("home") == true ? "Heimspiel"
|
||||||
|
: "Auswärtsspiel") +
|
||||||
|
" · Dummytermin auswählen"
|
||||||
|
: "Gegner für die deutsche Nationalmannschaft wählen") +
|
||||||
|
"</span></p></header>";
|
||||||
|
if (!booking) {
|
||||||
|
for (size_t i = 0; i < opponents.size(); ++i) {
|
||||||
|
const auto &o = opponents[i];
|
||||||
|
body += btn(
|
||||||
|
"national-opponent",
|
||||||
|
img(o.at("gui_image"), 160, 184, false, false, 384) + "<strong>" +
|
||||||
|
esc(o.at("name").get<std::string>()) +
|
||||||
|
"</strong><small>Stärke " +
|
||||||
|
std::to_string(o.at("strength").get<int>()) + " · POC</small>",
|
||||||
|
"national-opponent",
|
||||||
|
"id=\"national-opponent-" + o.at("code").get<std::string>() +
|
||||||
|
"\" data-id=\"" + o.at("id").get<std::string>() +
|
||||||
|
"\" style=\"" +
|
||||||
|
rect((i % 4) * 661.75, 150 + (i / 4) * 804.5, 626.75, 769.5) +
|
||||||
|
"\"");
|
||||||
|
}
|
||||||
|
body += "<footer class=\"national-actions\">" +
|
||||||
|
btn("national-list",
|
||||||
|
"Vorgemerkte Spiele · " +
|
||||||
|
std::to_string(n.at("friendlies").size()),
|
||||||
|
{}, "id=\"national-list\"") +
|
||||||
|
"</footer>";
|
||||||
|
} else {
|
||||||
|
using namespace std::chrono;
|
||||||
|
const int season = data.at("season"), offset = n.at("month");
|
||||||
|
const auto ym = year_month{year{season}, month{7}} + months{offset};
|
||||||
|
const auto start = sys_days{ym / 1};
|
||||||
|
const int count =
|
||||||
|
int(unsigned(year_month_day{sys_days{ym / last}}.day())),
|
||||||
|
lead = int(weekday{start}.iso_encoding()) - 1,
|
||||||
|
weeks = (count + lead + 6) / 7;
|
||||||
|
const std::array<const char *, 12> month_names = {
|
||||||
|
"Januar", "Februar", "März", "April", "Mai", "Juni",
|
||||||
|
"Juli", "August", "September", "Oktober", "November", "Dezember"};
|
||||||
|
body += "<section class=\"national-month\"><header>" +
|
||||||
|
btn("national-month", "‹", {},
|
||||||
|
"id=\"national-month-prev\" data-id=\"" +
|
||||||
|
std::to_string(offset - 1) + "\" " +
|
||||||
|
(offset == 0 ? "disabled" : "")) +
|
||||||
|
"<h3><span>" +
|
||||||
|
std::string(month_names[unsigned(ym.month()) - 1]) + " " +
|
||||||
|
std::to_string(int(ym.year())) + "</span></h3>" +
|
||||||
|
btn("national-month", "›", {},
|
||||||
|
"id=\"national-month-next\" data-id=\"" +
|
||||||
|
std::to_string(offset + 1) + "\" " +
|
||||||
|
(offset == 11 ? "disabled" : "")) +
|
||||||
|
"</header>";
|
||||||
|
const std::array<const char *, 7> weekdays = {"Mo", "Di", "Mi", "Do",
|
||||||
|
"Fr", "Sa", "So"};
|
||||||
|
const double cell_w = 195.46, gap = 18,
|
||||||
|
cell_h = (1356.0 - (weeks - 1) * 18) / weeks;
|
||||||
|
for (int i = 0; i < 7; ++i)
|
||||||
|
body += "<span class=\"national-weekday\" style=\"" +
|
||||||
|
rect(26 + i * (cell_w + gap), 124, cell_w, 50) + "\"><span>" +
|
||||||
|
weekdays[size_t(i)] + "</span></span>";
|
||||||
|
for (int d = 1; d <= count; ++d) {
|
||||||
|
const auto date = year_month_day{ym / unsigned(d)};
|
||||||
|
std::ostringstream iso;
|
||||||
|
iso << int(date.year()) << '-' << std::setfill('0') << std::setw(2)
|
||||||
|
<< unsigned(date.month()) << '-' << std::setw(2) << d;
|
||||||
|
const auto value = iso.str();
|
||||||
|
const int index = lead + d - 1;
|
||||||
|
const auto &available = data.at("available_dates");
|
||||||
|
const bool open = std::find(available.begin(), available.end(),
|
||||||
|
value) != available.end();
|
||||||
|
body +=
|
||||||
|
btn("national-day", std::to_string(d),
|
||||||
|
n.at("day") == value ? "national-day selected" : "national-day",
|
||||||
|
"id=\"national-day-" + value + "\" data-id=\"" + value +
|
||||||
|
"\" aria-pressed=\"" +
|
||||||
|
(n.at("day") == value ? "true" : "false") + "\" style=\"" +
|
||||||
|
rect(26 + (index % 7) * (cell_w + gap),
|
||||||
|
192 + (index / 7) * (cell_h + 18), cell_w, cell_h) +
|
||||||
|
"\" " + (open ? "" : "disabled"));
|
||||||
|
}
|
||||||
|
body += "</section><aside class=\"national-selection\"><h3>Deine "
|
||||||
|
"Auswahl</h3><p>" +
|
||||||
|
(n.at("day") == ""
|
||||||
|
? std::string("Einen hervorgehobenen Dummytermin wählen.")
|
||||||
|
: esc(n.at("day").get<std::string>())) +
|
||||||
|
"</p><p>" + std::to_string(n.at("friendlies").size()) +
|
||||||
|
" / 12 Spiele vorgemerkt</p><h4>Nur POC-Vormerkung</h4><p>Keine "
|
||||||
|
"FIFA-Termine, keine Vereinstermine, keine Kostenbuchung.</p>";
|
||||||
|
for (const auto &b : n.at("friendlies"))
|
||||||
|
body +=
|
||||||
|
"<p>" + esc(b.at("date").get<std::string>()) + " · " +
|
||||||
|
esc(find_opponent(b.at("opponent")).at("name").get<std::string>()) +
|
||||||
|
"</p>";
|
||||||
|
body +=
|
||||||
|
"</aside><footer class=\"national-actions\">" +
|
||||||
|
btn("national-back", "Gegner ändern", {}, "id=\"national-back\"") +
|
||||||
|
btn("national-list", "Vorgemerkte Spiele", {},
|
||||||
|
"id=\"national-list\"") +
|
||||||
|
btn("national-book", "Termin vormerken", {},
|
||||||
|
"id=\"national-book\" " +
|
||||||
|
std::string(n.at("day") == "" ||
|
||||||
|
n.at("friendlies").size() >= 12
|
||||||
|
? "disabled"
|
||||||
|
: "")) +
|
||||||
|
"</footer>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
body += "</div>";
|
||||||
|
if (!national_dialog_.empty()) {
|
||||||
|
std::string title, content, actions;
|
||||||
|
if (national_dialog_ == "venue") {
|
||||||
|
title = "Austragungsort";
|
||||||
|
content = team(find_opponent(national_pending_)) +
|
||||||
|
"<p>Heimspiel oder Auswärtsspiel?</p>";
|
||||||
|
actions = btn("national-home", "Heim", {}, "id=\"national-home\"") +
|
||||||
|
btn("national-away", "Auswärts", {}, "id=\"national-away\"") +
|
||||||
|
btn("national-close", "Abbrechen", {}, "id=\"national-close\"");
|
||||||
|
} else if (national_dialog_ == "book") {
|
||||||
|
title = "Länderspiel vormerken?";
|
||||||
|
content = team(find_opponent(n.at("opponent"))) + "<p>" +
|
||||||
|
esc(n.at("day").get<std::string>()) + " · " +
|
||||||
|
(n.at("home") == true ? "Heimspiel" : "Auswärtsspiel") +
|
||||||
|
" · reine POC-Vormerkung</p>";
|
||||||
|
actions =
|
||||||
|
btn("national-close", "Abbrechen", {}, "id=\"national-close\"") +
|
||||||
|
btn("national-confirm", "Vormerken", {}, "id=\"national-confirm\"");
|
||||||
|
} else if (national_dialog_ == "list") {
|
||||||
|
title = "Vorgemerkte Länderspiele";
|
||||||
|
for (const auto &b : n.at("friendlies"))
|
||||||
|
content += "<p>" + esc(b.at("date").get<std::string>()) + " · " +
|
||||||
|
team(find_opponent(b.at("opponent"))) + " · " +
|
||||||
|
(b.at("home") == true ? "Heim" : "Auswärts") + "</p>";
|
||||||
|
if (content.empty())
|
||||||
|
content = "<p>Noch kein Länderspiel vorgemerkt.</p>";
|
||||||
|
actions = btn("national-close", "Schließen", {}, "id=\"national-close\"");
|
||||||
|
} else {
|
||||||
|
title = "POC-Kaderbasis";
|
||||||
|
for (const auto &p : data.value("rows", Json::array()))
|
||||||
|
if (p.at("id") == national_pending_)
|
||||||
|
content = "<h3>" + esc(p.at("name").get<std::string>()) +
|
||||||
|
"</h3><p>Deutschland · keine echte Berufung</p><p>Im "
|
||||||
|
"Datensatz erfasste Länderspiele: " +
|
||||||
|
(p.at("caps").is_number() ? p.at("caps").dump() : "—") +
|
||||||
|
"</p><p>Erfasste POC-Vorlagen: —</p>";
|
||||||
|
actions = btn("national-close", "Schließen", {}, "id=\"national-close\"");
|
||||||
|
}
|
||||||
|
body += "<div id=\"national-dialog-layer\" class=\"entry-dialog-layer "
|
||||||
|
"national-dialog-layer\"><section class=\"entry-dialog "
|
||||||
|
"national-dialog\" role=\"dialog\" aria-modal=\"true\"><h2>" +
|
||||||
|
title + "</h2>" + content + "<footer>" + actions +
|
||||||
|
"</footer></section></div>";
|
||||||
|
}
|
||||||
|
return body;
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
std::string national_dialog_, national_pending_, national_menu_,
|
||||||
|
national_return_focus_;
|
||||||
|
uint64_t national_revision_ = 0;
|
||||||
|
int national_portrait_ = 0;
|
||||||
|
const DataSource *national_source_ = nullptr;
|
||||||
|
std::string render_national(const std::string &);
|
||||||
|
bool national_action(const std::string &, Rml::Element *);
|
||||||
|
bool national_event(Rml::Event &);
|
||||||
@@ -167,7 +167,9 @@ std::string App::render_menu(const std::string &key) {
|
|||||||
if (key == "news")
|
if (key == "news")
|
||||||
return "<div class=\"fill\" style=\"z-index:100;\">" + render_news() + "</div>";
|
return "<div class=\"fill\" style=\"z-index:100;\">" + render_news() + "</div>";
|
||||||
std::string body;
|
std::string body;
|
||||||
if (key == "tables" || key == "strengths" || key == "league" || key == "other")
|
if(source_ && snap().state.at("career").value("role","club")=="national" && std::set<std::string>{"achievements","friendlies","scorers"}.contains(key))
|
||||||
|
body=render_national(key);
|
||||||
|
else if (key == "tables" || key == "strengths" || key == "league" || key == "other")
|
||||||
body = render_reports(key);
|
body = render_reports(key);
|
||||||
else if (key == "almanac")
|
else if (key == "almanac")
|
||||||
body = render_almanac();
|
body = render_almanac();
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
#include "modern/ui/demo_lineup.hpp"
|
#include "modern/ui/demo_lineup.hpp"
|
||||||
#include "modern/ui/demo_live.hpp"
|
#include "modern/ui/demo_live.hpp"
|
||||||
#include "modern/ui/demo_career.hpp"
|
#include "modern/ui/demo_career.hpp"
|
||||||
|
#include "modern/ui/demo_national_ui.hpp"
|
||||||
#include "modern/ui/demo_transfer.hpp"
|
#include "modern/ui/demo_transfer.hpp"
|
||||||
#include "modern/ui/demo_career_reports.hpp"
|
#include "modern/ui/demo_career_reports.hpp"
|
||||||
#include "modern/ui/demo_rankings.hpp"
|
#include "modern/ui/demo_rankings.hpp"
|
||||||
@@ -452,6 +453,7 @@ class App final : public Rml::EventListener {
|
|||||||
#include "modern/ui/files_state.inc"
|
#include "modern/ui/files_state.inc"
|
||||||
#include "modern/ui/front_state.inc"
|
#include "modern/ui/front_state.inc"
|
||||||
#include "modern/ui/live_state.inc"
|
#include "modern/ui/live_state.inc"
|
||||||
|
#include "modern/ui/national_state.inc"
|
||||||
std::map<std::string, std::string> selections_;
|
std::map<std::string, std::string> selections_;
|
||||||
Rml::Element *element(const std::string &id) const {
|
Rml::Element *element(const std::string &id) const {
|
||||||
return doc_->GetElementById(id);
|
return doc_->GetElementById(id);
|
||||||
@@ -961,6 +963,7 @@ class App final : public Rml::EventListener {
|
|||||||
Rml::ElementList background;doc_->QuerySelectorAll(background,".desktop-layer button,.desktop-layer [data-action]");
|
Rml::ElementList background;doc_->QuerySelectorAll(background,".desktop-layer button,.desktop-layer [data-action]");
|
||||||
for(auto *node:background){node->SetProperty("pointer-events","none");node->SetAttribute("tabindex",-1);}
|
for(auto *node:background){node->SetProperty("pointer-events","none");node->SetAttribute("tabindex",-1);}
|
||||||
}
|
}
|
||||||
|
if(!national_dialog_.empty() && source_ && snap().state.at("career").value("role","club")=="national"){Rml::ElementList behind;doc_->QuerySelectorAll(behind,"#national-underlay button,#national-underlay select,.window>.titlebar button");for(auto *node:behind){node->SetProperty("pointer-events","none");node->SetAttribute("tabindex",-1);}}
|
||||||
news_after_render();
|
news_after_render();
|
||||||
if (!report_detail_kind_.empty() || !planning_dialog_.empty() || !contracts_dialog_.empty() || !toto_dialog_.empty() || !transfer_dialog_.empty() || !career_view_.value("dialog", "").empty() || !stadium_view_.value("dialog", "").empty()) {
|
if (!report_detail_kind_.empty() || !planning_dialog_.empty() || !contracts_dialog_.empty() || !toto_dialog_.empty() || !transfer_dialog_.empty() || !career_view_.value("dialog", "").empty() || !stadium_view_.value("dialog", "").empty()) {
|
||||||
Rml::ElementList behind;
|
Rml::ElementList behind;
|
||||||
@@ -1412,6 +1415,8 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
#include "modern/ui/entry_controls.inc"
|
#include "modern/ui/entry_controls.inc"
|
||||||
|
#include "modern/ui/national_screens.inc"
|
||||||
|
#include "modern/ui/national_controls.inc"
|
||||||
#include "modern/ui/career_screens.inc"
|
#include "modern/ui/career_screens.inc"
|
||||||
#include "modern/ui/career_controls.inc"
|
#include "modern/ui/career_controls.inc"
|
||||||
#include "modern/ui/entry_screens.inc"
|
#include "modern/ui/entry_screens.inc"
|
||||||
|
|||||||
@@ -0,0 +1,207 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
#include "modern/ui/demo_career.hpp"
|
||||||
|
#include "modern/ui/demo_national_ui.hpp"
|
||||||
|
#include "modern/ui/desktop.hpp"
|
||||||
|
#include "modern/ui/model.hpp"
|
||||||
|
#include <iostream>
|
||||||
|
#include <set>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
|
using namespace bmh::modern_ui;
|
||||||
|
namespace {
|
||||||
|
void require(bool yes, const char *message) {
|
||||||
|
if (!yes)
|
||||||
|
throw std::runtime_error(message);
|
||||||
|
}
|
||||||
|
struct Fixture {
|
||||||
|
fs::path root;
|
||||||
|
std::shared_ptr<const Catalog> world;
|
||||||
|
Fixture()
|
||||||
|
: root(fs::temp_directory_path() /
|
||||||
|
bmh::editor::new_id("openbmh-entry-test-")) {
|
||||||
|
fs::create_directories(root / "world");
|
||||||
|
const auto write = [&](const char *path, const Json &data) {
|
||||||
|
bmh::editor::write_atomic(root / path, data.dump());
|
||||||
|
};
|
||||||
|
write("manifest.json", {{"format", "openbmh-world"},
|
||||||
|
{"kind", "world"},
|
||||||
|
{"format_version", "1.1"},
|
||||||
|
{"id", "world:synthetic-entry"},
|
||||||
|
{"start_date", "2032-07-01"},
|
||||||
|
{"requires", {"editor:world-v1"}},
|
||||||
|
{"x-editor", {{"profile", "editor-world-v1"}}}});
|
||||||
|
write("world/nations.json",
|
||||||
|
{{"items",
|
||||||
|
{{{"id", "nation:de"}, {"name", "Synthetic Germany"}},
|
||||||
|
{{"id", "nation:es"}, {"name", "Synthetic Spain"}}}}});
|
||||||
|
write("world/competitions.json", {{"items",
|
||||||
|
{{{"id", "competition:de"},
|
||||||
|
{"name", "Synthetic DE"},
|
||||||
|
{"nation", "nation:de"},
|
||||||
|
{"type", "league"}},
|
||||||
|
{{"id", "competition:es"},
|
||||||
|
{"name", "Synthetic ES"},
|
||||||
|
{"nation", "nation:es"},
|
||||||
|
{"type", "league"}}}}});
|
||||||
|
Json clubs = Json::array();
|
||||||
|
for (int index = 0; index < 5; ++index)
|
||||||
|
clubs.push_back({{"id", "club:entry-" + std::to_string(index)},
|
||||||
|
{"name", "Synthetic club " + std::to_string(index)},
|
||||||
|
{"nation", "nation:de"},
|
||||||
|
{"competition", "competition:de"}});
|
||||||
|
clubs.push_back({{"id", "club:foreign"},
|
||||||
|
{"name", "Foreign club"},
|
||||||
|
{"nation", "nation:es"},
|
||||||
|
{"competition", "competition:es"}});
|
||||||
|
write("world/clubs.json", {{"items", clubs}});
|
||||||
|
Json players = Json::array();
|
||||||
|
for (int team = 0; team < 5; ++team)
|
||||||
|
for (int n = 0; n < 16; ++n)
|
||||||
|
players.push_back(
|
||||||
|
{{"id", "player:" + std::to_string(team) + "-" + std::to_string(n)},
|
||||||
|
{"name", "Synthetic player " + std::to_string(n)},
|
||||||
|
{"team", "club:entry-" + std::to_string(team)},
|
||||||
|
{"squad_order", n},
|
||||||
|
{"positions", Json::array({n < 2 ? "gk"
|
||||||
|
: n < 7 ? "def"
|
||||||
|
: n < 12 ? "mid"
|
||||||
|
: "fwd"})}});
|
||||||
|
players[0]["attributes"] = {{"caps", 3}, {"international_goals", 1}};
|
||||||
|
players[1]["attributes"] = {{"caps", -1},
|
||||||
|
{"international_goals", "unknown"}};
|
||||||
|
write("world/players.json", {{"items", players}});
|
||||||
|
world = Catalog::open(root);
|
||||||
|
}
|
||||||
|
~Fixture() {
|
||||||
|
std::error_code error;
|
||||||
|
fs::remove_all(root, error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace
|
||||||
|
int main() {
|
||||||
|
try {
|
||||||
|
Fixture f;
|
||||||
|
DemoSource source(f.world);
|
||||||
|
const auto first = source.snapshot();
|
||||||
|
require(first.state.contains("national") && valid_national_ui(first.state),
|
||||||
|
"National state missing");
|
||||||
|
const auto apply = [&](Json action) {
|
||||||
|
return source.apply({source.snapshot().revision, "national", action});
|
||||||
|
};
|
||||||
|
auto action = [](const std::string &kind) {
|
||||||
|
return Json{{"kind", kind}, {"manager_portrait", 0}};
|
||||||
|
};
|
||||||
|
auto select = action("opponent");
|
||||||
|
select["opponent"] = "national-fr";
|
||||||
|
select["home"] = true;
|
||||||
|
require(!apply(select).ok && source.snapshot().state == first.state,
|
||||||
|
"Club context accepted national booking");
|
||||||
|
require(source
|
||||||
|
.apply({source.snapshot().revision,
|
||||||
|
"career",
|
||||||
|
{{"kind", "role"}, {"value", "national"}}})
|
||||||
|
.ok,
|
||||||
|
"National role");
|
||||||
|
auto before = source.snapshot();
|
||||||
|
auto wrong = select;
|
||||||
|
wrong["manager_portrait"] = 9;
|
||||||
|
require(!apply(wrong).ok && source.snapshot().state == before.state,
|
||||||
|
"Wrong owner changed planning");
|
||||||
|
require(!source.apply({before.revision - 1, "national", select}).ok &&
|
||||||
|
source.snapshot().state == before.state,
|
||||||
|
"Stale revision changed planning");
|
||||||
|
const auto achievements =
|
||||||
|
query_national_ui(*f.world, before.state, "achievements");
|
||||||
|
require(achievements.at("history").empty() &&
|
||||||
|
achievements.at("tournaments").size() == 2 &&
|
||||||
|
achievements.at("tournaments")[0].at("titles").is_null(),
|
||||||
|
"Invented national titles/history");
|
||||||
|
const auto scorers = query_national_ui(*f.world, before.state, "scorers");
|
||||||
|
require(scorers.at("recorded_matches") == 0 &&
|
||||||
|
scorers.at("rows").size() == 16,
|
||||||
|
"National POC roster unavailable");
|
||||||
|
for (const auto &p : scorers.at("rows")) {
|
||||||
|
require(p.at("goals").is_null() && p.at("assists").is_null(),
|
||||||
|
"Invented recorded goal/assist fact");
|
||||||
|
if (p.at("id") == "player:0-0")
|
||||||
|
require(p.at("caps") == 3 && p.at("catalog_international_goals") == 1,
|
||||||
|
"Verified catalog attribute was lost");
|
||||||
|
else
|
||||||
|
require(p.at("caps").is_null() &&
|
||||||
|
p.at("catalog_international_goals").is_null(),
|
||||||
|
"Missing/invalid catalog fact was invented");
|
||||||
|
}
|
||||||
|
require(national_ui_opponents().size() == 8, "Wrong country count");
|
||||||
|
std::set<std::string> codes;
|
||||||
|
for (const auto &n : national_ui_opponents())
|
||||||
|
codes.insert(n.at("code"));
|
||||||
|
require(codes == std::set<std::string>{"fr", "it", "es", "en", "nl", "pl",
|
||||||
|
"se", "at"},
|
||||||
|
"National countries became club leagues");
|
||||||
|
require(apply(select).ok, "Select opponent");
|
||||||
|
const auto role_state = source.snapshot().state;
|
||||||
|
for (int i = 0; i < 12; ++i) {
|
||||||
|
const auto dates = national_ui_dates(source.snapshot().state);
|
||||||
|
require(!dates.empty(), "Dummy slot unexpectedly missing");
|
||||||
|
auto day = action("day");
|
||||||
|
day["value"] = dates[0];
|
||||||
|
require(apply(day).ok && apply(action("book")).ok,
|
||||||
|
"National plan booking failed");
|
||||||
|
}
|
||||||
|
const auto booked = source.snapshot();
|
||||||
|
require(booked.state.at("national").at("friendlies").size() == 12,
|
||||||
|
"Booking cap differs");
|
||||||
|
require(!apply(action("book")).ok &&
|
||||||
|
source.snapshot().state == booked.state,
|
||||||
|
"13th booking changed state");
|
||||||
|
auto only = booked.state;
|
||||||
|
only["national"] = role_state.at("national");
|
||||||
|
require(only == role_state,
|
||||||
|
"National booking changed cash/date/club calendar or other state");
|
||||||
|
auto invalid = booked.state;
|
||||||
|
invalid["national"]["friendlies"][0]["date"] = "2034-07-01";
|
||||||
|
const auto bad_before = invalid;
|
||||||
|
require(!migrate_national_ui(invalid) && invalid == bad_before,
|
||||||
|
"Outside-season restore silently repaired");
|
||||||
|
invalid = booked.state;
|
||||||
|
invalid["national"]["friendlies"][1]["date"] =
|
||||||
|
invalid["national"]["friendlies"][0]["date"];
|
||||||
|
require(!valid_national_ui(invalid), "Duplicate restore accepted");
|
||||||
|
invalid = booked.state;
|
||||||
|
invalid["national"]["month"] = 12;
|
||||||
|
require(!valid_national_ui(invalid), "Invalid month accepted");
|
||||||
|
auto saved = booked.state;
|
||||||
|
saved["desktop"] = default_desktop();
|
||||||
|
DemoSource restored(f.world);
|
||||||
|
restored.load_data(saved);
|
||||||
|
require(restored.snapshot().state == booked.state,
|
||||||
|
"National checkpoint did not roundtrip");
|
||||||
|
auto wrong_file = saved;
|
||||||
|
wrong_file["national"]["home"] = 0;
|
||||||
|
const auto load_before = restored.snapshot();
|
||||||
|
bool rejected = false;
|
||||||
|
try {
|
||||||
|
restored.load_data(wrong_file);
|
||||||
|
} catch (const std::exception &) {
|
||||||
|
rejected = true;
|
||||||
|
}
|
||||||
|
require(rejected && restored.snapshot().state == load_before.state &&
|
||||||
|
restored.snapshot().revision == load_before.revision,
|
||||||
|
"Bad national restore partially published");
|
||||||
|
auto legacy = first.state;
|
||||||
|
legacy.erase("national");
|
||||||
|
legacy["desktop"] = default_desktop();
|
||||||
|
restored.load_data(legacy);
|
||||||
|
require(valid_national_ui(restored.snapshot().state),
|
||||||
|
"Old checkpoint did not gain empty national plan");
|
||||||
|
auto late = before.state;
|
||||||
|
late["date"] = "2033-06-29";
|
||||||
|
require(national_ui_dates(late).empty(),
|
||||||
|
"Invented slots beyond season end");
|
||||||
|
std::cout << "national presentation tests passed\n";
|
||||||
|
return 0;
|
||||||
|
} catch (const std::exception &e) {
|
||||||
|
std::cerr << e.what() << '\n';
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -84,7 +84,7 @@ def main():
|
|||||||
x,y,w,h=rect
|
x,y,w,h=rect
|
||||||
add(key,sheet,[x/1448,y/1086,w/1448,h/1086])
|
add(key,sheet,[x/1448,y/1086,w/1448,h/1086])
|
||||||
items[key]['source_rect']=rect
|
items[key]['source_rect']=rect
|
||||||
for code in ('de','fr'):
|
for code in ('de','fr','it','es','en','nl','pl','se','at'):
|
||||||
file='assets/vector/career-national-'+code+'.svg'
|
file='assets/vector/career-national-'+code+'.svg'
|
||||||
if (source/file).exists():add('career.national-'+code,file)
|
if (source/file).exists():add('career.national-'+code,file)
|
||||||
for key, file in [('menu.club-office','menu-studies/club-office/assets/club-office.png'),('menu.trophy-office','menu-studies/trophy-office/assets/manager-office.png')]:
|
for key, file in [('menu.club-office','menu-studies/club-office/assets/club-office.png'),('menu.trophy-office','menu-studies/trophy-office/assets/manager-office.png')]:
|
||||||
|
|||||||
Reference in new issue
Block a user