Port report menu package and club/player profiles (by Codex)
This commit is contained in:
1 parent
201eef88e4
commit
13461c693a
23 files changed
+2122
-137
No files matched your search
@@ -52,9 +52,9 @@ jobs:
|
||||
- name: Configure opt-in UI without external assets
|
||||
run: cmake -S . -B build-ui -G Ninja -DCMAKE_BUILD_TYPE=Release -DOPENBMH_BUILD_MODERN_UI=ON -DOPENBMH_BUILD_EDITOR=OFF -DBMH_DATA=
|
||||
- name: Compile native frontend and synthetic checks
|
||||
run: cmake --build build-ui --target openbmh_play modern_ui_core_tests modern_ticket_document_tests modern_control_layout_tests --parallel 2
|
||||
run: cmake --build build-ui --target openbmh_play modern_ui_core_tests modern_ticket_document_tests modern_control_layout_tests modern_reports_tests --parallel 2
|
||||
- name: Check controls, fonts, density and draft cancellation
|
||||
run: ctest --test-dir build-ui -R "^modern_(ui_|ticket_|control_)" --output-on-failure --output-junit modern-ui-results.xml
|
||||
run: ctest --test-dir build-ui -R "^modern_(ui_|ticket_|control_|reports_)" --output-on-failure --output-junit modern-ui-results.xml
|
||||
- name: Upload test report
|
||||
if: always()
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<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"/></head>
|
||||
<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"/></head>
|
||||
<body class="midnight">
|
||||
<div id="background"></div>
|
||||
<div id="canvas"></div>
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-only */
|
||||
/* Local to the 2612 x 1864 logical menu-content area, matching the HTML dialog layer. */
|
||||
.report-detail-layer {position:absolute;left:0;top:0;width:100%;height:100%;z-index:30;display:flex;align-items:center;justify-content:center;background-color:#08101980;}
|
||||
.report-detail-card {position:relative;flex-shrink:0;width:2484dp;height:860dp;border:2dp #e1ecf429;border-radius:22dp;background-color:#283542f5;color:#dce3e9;font-size:36dp;}
|
||||
.report-detail-card h2 {position:absolute;left:52dp;right:52dp;top:40dp;height:48dp;line-height:48dp;margin:0;text-align:center;font-size:42dp;font-weight:bold;letter-spacing:-0.4dp;color:#eff0d6;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
|
||||
.report-detail-badge {position:absolute;left:50%;top:123dp;width:220dp;height:220dp;margin-left:-110dp;padding:14dp;border-radius:18dp;background-color:#f4f6f8;overflow:hidden;}
|
||||
.report-detail-note {position:absolute;left:52dp;right:52dp;top:371dp;height:42dp;line-height:42dp;margin:0;text-align:center;font-size:28dp;color:#a4b5c5;}
|
||||
.report-detail-values {display:block;position:absolute;left:52dp;right:52dp;top:448dp;height:258dp;margin:0;}
|
||||
.report-detail-field {position:absolute;left:0;right:0;height:42dp;}
|
||||
.report-detail-values dt,.report-detail-values dd {display:block;position:absolute;top:0;height:42dp;line-height:42dp;margin:0;font-size:36dp;white-space:normal;}
|
||||
.report-detail-values dt {left:0;width:1173dp;}
|
||||
.report-detail-values dd {right:0;width:1173dp;text-align:right;color:#f7e7ac;}
|
||||
.report-detail-actions {position:absolute;left:52dp;right:52dp;bottom:40dp;height:65dp;display:flex;gap:70dp;}
|
||||
.report-detail-actions .report-detail-action {flex:1;min-width:0;height:65dp;padding:12dp 24dp;border:2dp #d4e0ec29;border-radius:12dp;background-color:transparent;decorator:linear-gradient(180deg,#c1d1e31c,#869eb312);font-size:32dp;line-height:37dp;font-weight:normal;color:#e0e6ec;}
|
||||
.report-detail-actions .report-detail-action:hover {decorator:none;background-color:#d0e2f226;}
|
||||
.report-detail-actions .report-detail-action:focus-visible {border-color:var(--accent);}
|
||||
.report-detail-roster {height:1227dp;}
|
||||
.report-detail-roster-scroll {position:absolute;left:52dp;right:52dp;top:123dp;height:950dp;overflow:auto;}
|
||||
.report-detail-table {display:table;width:100%;font-size:34dp;color:#d7e5cf;}
|
||||
.report-detail-row {display:table-row;}
|
||||
.report-detail-cell {display:table-cell;width:16%;height:66dp;padding:6dp 16dp;vertical-align:middle;text-align:right;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
|
||||
.report-detail-cell:first-child {width:52%;text-align:left;}
|
||||
.report-detail-table-head {color:#91bd72;}
|
||||
.report-detail-table-head .report-detail-cell {border-bottom:4dp #4e8b7b;}
|
||||
.report-detail-striped {background-color:#38706b19;}
|
||||
.report-detail-player-link {max-width:100%;padding:2dp 6dp;border:0dp;border-radius:0dp;background-color:transparent;font-size:34dp;text-align:left;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
|
||||
.report-detail-player-link.control-button {justify-content:flex-start;}
|
||||
.report-detail-player-link:hover {background-color:#ffffff1a;}
|
||||
.report-detail-player-link:focus-visible {color:var(--accent);background-color:var(--selected);}
|
||||
.report-detail-empty {margin-top:30dp;text-align:center;color:var(--muted);font-size:32dp;}
|
||||
.report-detail-player {width:1960dp;height:988.667dp;}
|
||||
.report-detail-player h2 {color:#e5edf3;}
|
||||
.report-detail-portrait {position:absolute;left:52dp;top:123dp;width:500dp;height:666.667dp;border:2dp #c5d9e72b;border-radius:18dp;overflow:hidden;}
|
||||
.report-detail-photo-caption {position:absolute;left:52dp;top:807.667dp;width:500dp;height:27dp;line-height:27dp;margin:0;text-align:center;font-size:23dp;color:#a8bece;}
|
||||
.report-detail-player .report-detail-values {left:612dp;right:52dp;top:314.333dp;height:329dp;}
|
||||
.report-detail-player .report-detail-field,.report-detail-player .report-detail-values dt,.report-detail-player .report-detail-values dd {height:37dp;line-height:37dp;font-size:32dp;}
|
||||
.report-detail-player .report-detail-values dt {width:220dp;}
|
||||
.report-detail-player .report-detail-values dd {width:1047dp;color:#d6e5ed;}
|
||||
body.silver .report-detail-card {background-color:#eaf1f7fc;border-color:var(--border);color:var(--text);}
|
||||
body.matchday .report-detail-card {background-color:#2c2c32fc;border-color:var(--border);color:var(--text);}
|
||||
body.silver .report-detail-card h2,body.matchday .report-detail-card h2 {color:var(--text);}
|
||||
body.silver .report-detail-values dd,body.matchday .report-detail-values dd {color:var(--accent);}
|
||||
body.silver .report-detail-player .report-detail-values dd,body.matchday .report-detail-player .report-detail-values dd {color:var(--text);}
|
||||
body.silver .report-detail-photo-caption,body.matchday .report-detail-photo-caption {color:var(--text);}
|
||||
body.silver .report-detail-actions .report-detail-action {border-color:var(--border);color:var(--text);decorator:linear-gradient(180deg,#ffffffb0,#bfd0e259);}
|
||||
body.matchday .report-detail-actions .report-detail-action {border-color:var(--border);color:var(--text);decorator:linear-gradient(180deg,#e8d6dc12,#a1a0aa0d);}
|
||||
body.silver .report-detail-actions .report-detail-action:hover,body.matchday .report-detail-actions .report-detail-action:hover {decorator:none;background-color:var(--hover);}
|
||||
body.silver .report-detail-table,body.matchday .report-detail-table {color:var(--text);}
|
||||
body.silver .report-detail-striped {background-color:#42627d09;}
|
||||
body.matchday .report-detail-striped {background-color:#f8e7e00a;}
|
||||
@@ -0,0 +1,24 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-only */
|
||||
/* Coordinates are local to the report footer, not to the complete menu. */
|
||||
.report-picker-wrapper {position:absolute;bottom:0;height:94dp;overflow:visible;}
|
||||
.report-picker-wrapper .report-picker-trigger {display:flex;align-items:center;justify-content:space-between;gap:20dp;width:100%;height:94dp;padding:12dp 24dp;border:2dp #d4e0ec29;border-radius:12dp;background-color:transparent;decorator:linear-gradient(180deg,#c1d1e31c,#869eb312);color:#e0e6ec;font-size:32dp;font-weight:normal;text-align:left;}
|
||||
.report-picker-label {display:block;flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
|
||||
.report-picker-arrow {display:block;position:relative;flex-shrink:0;width:32dp;height:32dp;pointer-events:none;}
|
||||
.report-picker-arrow span {display:block;position:absolute;left:10dp;top:6dp;width:12dp;height:12dp;border-bottom:3dp #a8b8c8;border-right:3dp #a8b8c8;transform:rotate(45deg);}
|
||||
.report-picker-wrapper .report-picker-trigger:hover {decorator:none;background-color:#d0e2f226;}
|
||||
.report-picker-popup {position:absolute;left:0;right:0;bottom:108dp;z-index:20;max-height:740dp;overflow-y:auto;overflow-x:hidden;padding:10dp;border:2dp #d9e8f13d;border-radius:18dp;background-color:#293744fa;}
|
||||
.report-picker-popup .report-picker-option {display:flex;align-items:center;justify-content:flex-start;gap:12dp;flex:none;width:100%;height:72dp;min-height:72dp;padding:10dp 14dp;border:0dp;border-radius:10dp;background-color:transparent;color:#e0e6ec;font-size:32dp;line-height:1.3;text-align:left;white-space:nowrap;}
|
||||
.report-picker-option-label {display:block;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
|
||||
.report-picker-check-slot {display:block;position:relative;flex-shrink:0;width:34dp;height:42dp;pointer-events:none;}
|
||||
.report-picker-check {display:block;position:absolute;left:12dp;top:8.5dp;width:10dp;height:18dp;border-right:3dp #afdccf;border-bottom:3dp #afdccf;transform:rotate(45deg);}
|
||||
.report-picker-popup .report-picker-option:hover {background-color:#d0e2f226;}
|
||||
.report-picker-popup .report-picker-option:focus {background-color:#6286a855;}
|
||||
body.silver .report-picker-wrapper .report-picker-trigger {border-color:var(--border);color:var(--text);decorator:linear-gradient(180deg,#ffffffb0,#bfd0e259);}
|
||||
body.matchday .report-picker-wrapper .report-picker-trigger {border-color:var(--border);color:var(--text);decorator:linear-gradient(180deg,#e8d6dc12,#a1a0aa0d);}
|
||||
body.silver .report-picker-arrow span,body.matchday .report-picker-arrow span {border-color:var(--muted);}
|
||||
body.silver .report-picker-popup {border-color:var(--border);background-color:#f3f7fcfc;}
|
||||
body.matchday .report-picker-popup {border-color:var(--border);background-color:#303037fc;}
|
||||
body.silver .report-picker-popup .report-picker-option,body.matchday .report-picker-popup .report-picker-option {color:var(--text);}
|
||||
body.silver .report-picker-check,body.matchday .report-picker-check {border-color:var(--accent);}
|
||||
body.silver .report-picker-wrapper .report-picker-trigger:hover,body.matchday .report-picker-wrapper .report-picker-trigger:hover {decorator:none;background-color:var(--hover);}
|
||||
body.silver .report-picker-popup .report-picker-option:hover,body.silver .report-picker-popup .report-picker-option:focus,body.matchday .report-picker-popup .report-picker-option:hover,body.matchday .report-picker-popup .report-picker-option:focus {background-color:var(--hover);}
|
||||
@@ -0,0 +1,70 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-only */
|
||||
.report-underlay {position:absolute;left:0;right:0;top:0;bottom:0;}
|
||||
.report-list {position:absolute;left:0;right:0;top:0;bottom:150dp;overflow-y:auto;overflow-x:hidden;}
|
||||
.report-list.standings-list {bottom:182dp;}
|
||||
.report-row {display:flex;align-items:stretch;font-size:36dp;color:var(--text);}
|
||||
.report-row.striped {background-color:var(--soft);}
|
||||
.report-row:hover {background-color:var(--hover);}
|
||||
.report-head {font-size:30dp;color:var(--muted);border-bottom:2dp var(--border);}
|
||||
.report-cell {display:flex;align-items:center;justify-content:flex-end;flex-shrink:0;padding:7dp 14dp;overflow:hidden;}
|
||||
.report-cell.first {justify-content:flex-start;}
|
||||
.report-cell.score {justify-content:center;}
|
||||
.report-cell.form {font-size:33dp;letter-spacing:1dp;}
|
||||
.report-value {display:block;white-space:nowrap;}
|
||||
.report-club-button {display:flex;align-items:center;gap:14dp;max-width:100%;min-width:0;padding:2dp 6dp;border:0dp;border-radius:0dp;background-color:transparent;font-size:36dp;}
|
||||
.report-club-button .image-frame {flex-shrink:0;}
|
||||
.report-club-name {display:block;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
|
||||
.report-club-button.current {color:var(--accent);}
|
||||
.report-club-button:hover {background-color:transparent;}
|
||||
.report-club-button:focus-visible {background-color:var(--hover);}
|
||||
.report-sort {display:flex;align-items:center;justify-content:flex-end;gap:8dp;padding:4dp 0;border:0dp;border-radius:6dp;background-color:transparent;font-size:30dp;color:var(--muted);}
|
||||
.report-cell.first .report-sort {justify-content:flex-start;}
|
||||
.report-sort-symbol {display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4dp;width:18dp;height:26dp;flex-shrink:0;}
|
||||
.report-sort-arrow {display:block;width:0;height:0;border-left:6dp transparent;border-right:6dp transparent;}
|
||||
.report-sort-arrow.up {border-bottom:7dp var(--muted);}
|
||||
.report-sort-arrow.down {border-top:7dp var(--muted);}
|
||||
.report-cell[aria-sort=ascending] .report-sort,.report-cell[aria-sort=descending] .report-sort {color:var(--text);}
|
||||
.report-cell[aria-sort=ascending] .report-sort-arrow.up {border-bottom-color:var(--text);}
|
||||
.report-cell[aria-sort=descending] .report-sort-arrow.down {border-top-color:var(--text);}
|
||||
.report-rank {display:flex;align-items:center;justify-content:flex-end;flex-shrink:0;width:64dp;margin-right:14dp;}
|
||||
.report-zone {display:block;flex-shrink:0;width:9dp;height:48dp;margin-right:20dp;border-radius:5dp;background-color:transparent;}
|
||||
.report-zone.champions {background-color:#79b8ed;}
|
||||
.report-zone.europa {background-color:#e6a566;}
|
||||
.report-zone.conference {background-color:#8bc493;}
|
||||
.report-zone.relegation {background-color:#e8757e;}
|
||||
.report-zone.promotion {background-color:#8ac9b0;}
|
||||
.report-zone.playoff {background-color:#d8b879;}
|
||||
.report-legend {position:absolute;left:0;right:0;bottom:127dp;display:flex;align-items:center;justify-content:center;gap:38dp;font-size:25dp;}
|
||||
.report-legend-item {display:flex;align-items:center;gap:14dp;}
|
||||
.report-legend .report-zone {width:7dp;height:22dp;margin:0;}
|
||||
.report-footer {position:absolute;left:0;right:0;bottom:0;height:94dp;}
|
||||
.report-reset,.report-round {position:absolute;height:94dp;padding:12dp 24dp;border-radius:12dp;font-size:32dp;decorator:linear-gradient(180deg,#c1d1e31c,#869eb312);background-color:transparent;}
|
||||
.report-round {font-size:56dp;padding:0;}
|
||||
.report-match-heading {position:absolute;left:0;right:0;top:0;text-align:center;}
|
||||
.report-match-heading h2 {font-size:46dp;font-weight:normal;}
|
||||
.report-match-heading p {margin-top:16dp;font-size:28dp;}
|
||||
.report-list.match-list {top:150dp;bottom:160dp;border:2dp var(--border);border-radius:18dp;background-color:var(--soft);}
|
||||
.match-list .report-row,.match-list .report-club-button {font-size:34dp;}
|
||||
.match-list .report-head {font-size:34dp;color:var(--muted);}
|
||||
.match-list .report-cell {padding:12dp 28dp;}
|
||||
body.midnight .report-row {color:#d8e0e8;}
|
||||
body.midnight .report-head,body.midnight .report-sort {color:#a0aebc;}
|
||||
body.midnight .report-cell[aria-sort=ascending] .report-sort,body.midnight .report-cell[aria-sort=descending] .report-sort {color:#dae6f0;}
|
||||
body.midnight .report-cell[aria-sort=ascending] .report-sort-arrow.up {border-bottom-color:#b5d6ee;}
|
||||
body.midnight .report-cell[aria-sort=descending] .report-sort-arrow.down {border-top-color:#b5d6ee;}
|
||||
body.midnight .report-row.striped {background-color:#e3edf605;}
|
||||
body.midnight .report-row:hover {background-color:#bad5f20d;}
|
||||
body.midnight .report-head {border-color:#d5e3ed26;}
|
||||
body.midnight .report-club-button.current {color:#a9dccb;}
|
||||
body.midnight .report-legend {color:#a9bdcd;}
|
||||
body.midnight .report-reset,body.midnight .report-round {color:#e0e6ec;border-color:#d4e0ec29;}
|
||||
body.midnight .report-match-heading h2 {color:#e4edf2;}
|
||||
body.midnight .report-match-heading p {color:#a9becd;}
|
||||
body.midnight .report-list.match-list {border-color:#c5d9e720;background-color:#13263526;}
|
||||
body.midnight .match-list .report-row {color:#d4e0e9;}
|
||||
body.midnight .match-list .report-head {color:#a8bdcc;border-color:#c5d9e72b;}
|
||||
body.midnight .match-list .report-cell.score {color:#bddedc;}
|
||||
body.silver .report-row.striped,body.silver .report-list.match-list {background-color:#42627d09;}
|
||||
body.silver .report-reset,body.silver .report-round {decorator:linear-gradient(180deg,#ffffffb0,#bfd0e259);}
|
||||
body.matchday .report-row.striped,body.matchday .report-list.match-list {background-color:#f8e7e00a;}
|
||||
body.matchday .report-reset,body.matchday .report-round {decorator:linear-gradient(180deg,#e8d6dc12,#a1a0aa0d);}
|
||||
@@ -26,8 +26,8 @@ wird ausdrücklich mit `OPENBMH_BUILD_MODERN_UI=ON` gebaut.
|
||||
- Eintrittspreis-Popover: 330 × 196 Punkte, Entwurf, gesonderte Bestätigung,
|
||||
Abbrechen, Fehler-/Revisionsschutz und Tastaturbedienung.
|
||||
- Trainingslager: drei Karten, 18 Angebote, eigene GUI-Bilder und lokale
|
||||
Vormerkung. Tabellen/Stärken sowie Speichern/Laden sind als erste native
|
||||
Ansichten vorhanden; ihr vollständiger Bedienungsabgleich bleibt offen.
|
||||
Vormerkung. Speichern/Laden sind als erste native Ansichten vorhanden;
|
||||
ihr vollständiger Bedienungsabgleich bleibt offen.
|
||||
- Separate UI-Demostände und Desktopansichten. Ansichten speichern zusätzlich
|
||||
einen Screenshot; die Standardansicht kann nicht gelöscht werden.
|
||||
- [Training](desktop/training/README.md): neun Übungen, vier Arten, Kader mit
|
||||
@@ -39,19 +39,24 @@ wird ausdrücklich mit `OPENBMH_BUILD_MODERN_UI=ON` gebaut.
|
||||
Wochentagsanordnung, Tageswahl und Länder-/Ligavorschau; 18/20 Vereine,
|
||||
Schaltjahre und gespeicherte Auswahl werden berücksichtigt.
|
||||
|
||||
- [Berichte](desktop/reports/README.md): Tabellen und Stärken mit Sortierung,
|
||||
Länder-/Ligaauswahl und 18/20 Zeilen; Ligaspiele und übrige Spiele mit
|
||||
Rundennavigation. Gemeinsame Auswahlmenüs sowie Vereins-, Kader- und
|
||||
Spielerprofile einschließlich Wappen und Porträts. Ergebnisse, Tabellen
|
||||
und Qualifikationsfarben bleiben ausdrücklich Demo-Projektionen.
|
||||
|
||||
**Anstoß führt keine Aktion aus**, weder per Maus noch per Tastatur. Das gilt
|
||||
auch für die direkte Aktionsschnittstelle des Demoanbieters.
|
||||
|
||||
## Noch offen
|
||||
|
||||
Die übrigen Desktop-Untermenüs werden anschließend einzeln vom HTML-Mockup
|
||||
übertragen. Für sie erscheinen derzeit keine vereinfachten Ersatzlayouts.
|
||||
Der Einstellungsdialog, die vollständigen Widgetinhalte, Sortierung/Details,
|
||||
Die übrigen Desktop-Untermenüs werden in zusammengehörigen Paketen vom
|
||||
HTML-Mockup übertragen. Für sie erscheinen derzeit keine vereinfachten Ersatzlayouts.
|
||||
Der Einstellungsdialog, die vollständigen Widgetinhalte,
|
||||
Mod-Importkomfort und dauerhafte globale Voreinstellungen sind noch nicht
|
||||
vollständig. Übersetzungen, echte Engine-Anbindung und Plattform-Abnahme
|
||||
unter Windows/macOS folgen später. Dies ist kein freigegebenes Test-Release.
|
||||
Die [QA-Befundliste](qa-findings.md) nennt insbesondere noch fehlende
|
||||
Sortierung und Detailpfade der ersten Tabellen-/Stärkenansichten.
|
||||
Die [QA-Befundliste](qa-findings.md) hält die noch offenen Abweichungen nach.
|
||||
|
||||
## Architekturgrenze für die Engine
|
||||
|
||||
@@ -77,8 +82,8 @@ python3 tools/modern_ui/prepare_gui_assets.py \
|
||||
--mockup /path/to/bmh_4k_ui --output /path/to/gui-resources
|
||||
cmake -S . -B build-modern -DOPENBMH_BUILD_MODERN_UI=ON \
|
||||
-DBMH_MODERN_GUI_ASSETS=/path/to/gui-resources
|
||||
cmake --build build-modern --target openbmh_play modern_ui_core_tests modern_ticket_document_tests
|
||||
ctest --test-dir build-modern -R '^modern_(ui_core|ticket_)' --output-on-failure
|
||||
cmake --build build-modern --target openbmh_play modern_ui_core_tests modern_reports_tests modern_ticket_document_tests
|
||||
ctest --test-dir build-modern -R '^modern_(ui_core|reports_|ticket_)' --output-on-failure
|
||||
./build-modern/OpenBMH --modern-ui-demo --mod /path/to/Diamond_Modern.obw
|
||||
```
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ Implementierung in der Spiel-Engine.
|
||||
| Training | [Übungen, Kader, Intensität und Demo-Automatik](desktop/training/README.md) |
|
||||
| Taktik | [Interaktive Diagramme und Einsatzregler](desktop/tactics/README.md) |
|
||||
| Kalender | [Zwölf Monate, transponierte Wochen und Ligavorschau](desktop/calendar/README.md) |
|
||||
| Berichte | [Tabellen, Stärken, Ligaspiele, übrige Spiele und Profile](desktop/reports/README.md) |
|
||||
| Transfers | [Ablöse-Kasten und Positionsfilter](desktop/transfers/README.md) |
|
||||
|
||||
Jeder Bereich nennt die geprüfte Quelle, bestehende Funktionen und offene
|
||||
|
||||
@@ -0,0 +1,223 @@
|
||||
# Tabellen, Stärken, Ligaspiele und Übrige Spiele
|
||||
|
||||
Stand: 23. Oktober 2026. Dieses Paket überträgt vier zusammenhängende
|
||||
Desktopansichten in die native RmlUI. Gestaltungsreferenz ist das private,
|
||||
unveränderte HTML-Mockup `bmh_4k_ui`, Revision
|
||||
`494a25611de847f23bf714bfdab6708387f581a7`, insbesondere
|
||||
`desktop/report-menus.js`, `league-preview.js`, `table-window.css` und
|
||||
`menu-themes.css`. Proprietäre Referenzbilder und Weltdaten gehören nicht
|
||||
in dieses öffentliche Dokument.
|
||||
|
||||
Die Ansichten verbinden **echte Katalogdaten aus der geladenen OBW-Welt**
|
||||
mit ausdrücklich fiktiven Berichtsergebnissen. Sie starten keine Karriere,
|
||||
führen keine Spiele aus und ändern weder Weltdatei noch Enginezustand.
|
||||
|
||||
## Sichtbare Daten
|
||||
|
||||
| Ansicht | Darstellung und Herkunft |
|
||||
| --- | --- |
|
||||
| Tabellen | Vereine und Wappen aus dem Katalog; Platz, Spiele, Siege, Unentschieden, Niederlagen, letzte acht Ergebnisse, Punkte, Tore und Tordifferenz aus der deterministischen Demoauswertung. |
|
||||
| Stärken | Tatsächliche Vereine und Kader; gerundete Mittelwerte vorhandener Stärkewerte für Tor, Abwehr, Mittelfeld, Sturm und gesamten Kader. |
|
||||
| Ligaspiele | Paarungen und fiktive Ergebnisse der gewählten Vorschau-Liga und Runde, mit echten Vereins-IDs, Namen und Wappen. |
|
||||
| Übrige Spiele | Meisterschaft wie Ligaspiele; weitere Wettbewerbe als begrenzte fiktive Vorschau. Nach durchlaufenem Demoauftakt kann der DFB-Pokal stattdessen die dort angezeigten Auftaktpaare ohne Ergebnis zeigen. |
|
||||
|
||||
Vereinsanzahl und Reihenfolge stammen aus dem Katalog. Eine Liga mit
|
||||
18 Vereinen hat 18 Tabellen-/Stärkezeilen und neun Begegnungen pro Runde;
|
||||
bei 20 Vereinen sind es 20 Zeilen und zehn Begegnungen. Es gibt keine
|
||||
fest verdrahtete 18er-Vereinsliste oder eine zweite Liste mit kopierten Namen.
|
||||
Der verwaltete Verein wird anhand seiner stabilen ID hervorgehoben.
|
||||
|
||||
Stärkekomponenten verwenden die OBW-Positionen `gk`, `def`, `mid` und `fwd`.
|
||||
Ein Spieler mit mehreren Positionen kann in mehreren Positionsgruppen
|
||||
berücksichtigt werden; die Gesamtstärke mittelt die nutzbaren Kaderwerte.
|
||||
Fehlende Positionen oder fehlende/verwertungsungeeignete Stärkedaten bleiben
|
||||
`null` und erscheinen als `—`. Es werden keine erfundenen Ersatzspieler oder
|
||||
scheinbaren Nullstärken eingesetzt. Eine tatsächlich gespeicherte Stärke
|
||||
von null bleibt dagegen ein vorhandener Wert.
|
||||
|
||||
## Reproduzierbare Ergebnisse und Form
|
||||
|
||||
Die Vorschau bildet zwei Halbserien mit vertauschtem Heimrecht und
|
||||
stabiler Katalogreihenfolge. Die Anzahl der Runden folgt der Ligagröße:
|
||||
18 Vereine ergeben 34, 20 Vereine 38 Runden. Ergebnisse entstehen durch
|
||||
festgelegte Ganzzahlarithmetik aus Runde, Vereinsindizes und Ligaindex,
|
||||
entsprechend dem HTML-Prototyp. Sie verbrauchen keinen Zufall der Engine.
|
||||
Gleicher Katalog und gleicher Vorschauzustand ergeben dieselben Ergebnisse.
|
||||
|
||||
Die Tabelle wertet die ersten **26 gespielten Vorschaurunden** aus, soweit
|
||||
der fiktive Spielplan reicht. Die gewählte Runde des Begegnungsberichts
|
||||
ändert diese Tabellenauswertung nicht. Der Bericht kann auch andere Runden
|
||||
anzeigen; deren Zahlen sind ebenfalls Dummydaten und keine ausgetragenen
|
||||
oder simulierten Spiele.
|
||||
|
||||
`S`, `U` und `N` bezeichnen die letzten bis zu acht Ergebnisse innerhalb
|
||||
des gewählten Tabellenfilters. Für die Sortierung der Formspalte zählen
|
||||
Siege drei und Unentschieden einen Vorschaupunkt. Die Standardsortierung
|
||||
verwendet Punkte, Tordifferenz und erzielte Tore; weitere Gleichstände
|
||||
bleiben stabil. Die farbigen Platzmarkierungen folgen dem errechneten Platz
|
||||
und bleiben auch bei anderer Spaltensortierung dem jeweiligen Verein
|
||||
zugeordnet.
|
||||
|
||||
Die Qualifikationslegende übernimmt die vereinfachte HTML-Darstellung:
|
||||
in der ersten Liga Champions-League-Plätze 1–4, Europa League auf Platz 5,
|
||||
Conference League auf Platz 6 und die letzten drei Plätze als Abstieg.
|
||||
Darunter werden Aufstieg, gegebenenfalls Aufstiegsrelegation und Abstieg
|
||||
markiert; die vierte Stufe zeigt einen direkten Aufstiegsplatz. **Das sind
|
||||
Darstellungsmarken der Demo, keine neuen Wettbewerbs-, Aufstiegs- oder
|
||||
Qualifikationsregeln für eine Engine.** Sie erzeugen keine Teilnehmerlisten.
|
||||
|
||||
## Gemeinsame Auswahl und Sortierung
|
||||
|
||||
Die vier Ansichten teilen einen `reports`-Zustand mit stabiler Liga-ID,
|
||||
Rundenindex, Tabellenfilter, Wettbewerb und getrennten Sortierungen für
|
||||
Tabellen und Stärken. Ein Ligawechsel bleibt deshalb beim Wechsel zwischen
|
||||
den Ansichten erhalten. Länder- und Ligaauswahl ändern die Vorschau,
|
||||
nicht Manageridentität oder verwalteten Verein. Erneutes Wählen desselben
|
||||
Landes setzt wie im HTML auf dessen erste Katalogliga zurück.
|
||||
|
||||
Die Tabellenfilter sind „Alle Spiele“, „Hinrunde“, „Rückrunde“, „Heim“ und
|
||||
„Auswärts“. Die Spaltenköpfe wechseln die Sortierrichtung; numerische
|
||||
Spalten beginnen bei neuer Auswahl absteigend, Platz und Vereinsname
|
||||
aufsteigend. **„Pl. / Verein“ sortiert nach Platz, nicht nach Vereinsname.**
|
||||
In der Stärkenansicht ist die Vereinsspalte nach Namen sortierbar.
|
||||
Gleiche Sortierwerte behalten ihre stabile Ausgangsreihenfolge; fehlende
|
||||
Stärkewerte stehen in beiden Richtungen hinter vorhandenen Werten.
|
||||
|
||||
„Gesamt“ setzt die Tabellenansicht auf die erste deutsche Liga, alle Spiele
|
||||
und Punkte absteigend zurück. Die Stärkensortierung und andere unabhängige
|
||||
Auswahlen bleiben erhalten. Der aktuelle Rundenindex wird auf den gültigen
|
||||
Bereich begrenzt, nicht pauschal wieder auf Runde 27 gesetzt.
|
||||
|
||||
Die Rundenpfeile laufen innerhalb der verfügbaren Vorschaurunden umlaufend.
|
||||
Für nicht zur Meisterschaft gehörende „Übrige Spiele“ übernimmt die Demo
|
||||
34 Vorschaurunden und feste Beispielpaarzahlen je Wettbewerb. Die Vereine
|
||||
dieser Beispiele stammen aus der ersten deutschen Katalogliga; das ist
|
||||
keine echte internationale Teilnehmerauswahl. Gegenüber dem HTML werden
|
||||
Runden bei Liga-/Wettbewerbswechseln und bei der Anzeige eines anderen
|
||||
Kontexts ausdrücklich auf dessen Bereich begrenzt. Diese Absicherung ist
|
||||
eine bewusste Abweichung der UI-Vorschau, keine Terminregel des Spiels.
|
||||
|
||||
## Footerpicker und Fokus
|
||||
|
||||
Die untere Bedienleiste enthält je nach Ansicht:
|
||||
|
||||
- Tabellen: „Gesamt“, Spielefilter, Land und Liga.
|
||||
- Stärken: Land und Liga.
|
||||
- Ligaspiele: zwei Rundenpfeile, Land und Liga.
|
||||
- Übrige Spiele: zwei Rundenpfeile und Wettbewerb.
|
||||
|
||||
Die Berichtspicker sind native RmlUI-Menüs mit sichtbarer Markierung der
|
||||
aktuellen Option. Klick, Enter oder Leertaste öffnen beziehungsweise
|
||||
bestätigen. Auf-/Abwärtspfeil öffnen auch vom geschlossenen Auswahlknopf;
|
||||
im Menü navigieren Auf/Ab sowie Pos1/Ende. Das reine Fokussieren einer
|
||||
Option verändert die gespeicherte Auswahl noch nicht.
|
||||
|
||||
Escape oder Rechtsklick schließen zunächst die offene Auswahl. Tab
|
||||
schließt die Auswahlliste und setzt die normale Fokusfolge fort. Ein Klick
|
||||
außerhalb schließt die Liste, ohne das eigentliche Klickziel zu ersetzen.
|
||||
Nach einer Auswahl liegt der Fokus wieder auf dem zugehörigen Footerknopf;
|
||||
nach Sortierung, Reset oder Rundenschritt auf dem auslösenden Knopf.
|
||||
Details sperren Hintergrundaktionen. Abbruch, Auswahl, Fokusumlauf und
|
||||
Fokusrückgabe wurden mit echten RmlUI-Ereignissen geprüft.
|
||||
|
||||
## Vereins-, Kader- und Spielerprofile
|
||||
|
||||
Vereinsknöpfe in allen vier Ansichten öffnen ein Vereinsprofil. Dort werden
|
||||
Wappen, Stadion, Kapazität, Stärke und Manager aus vorhandenen OBW-Daten
|
||||
beziehungsweise der Demo-Managerzuordnung angezeigt. Vorliegende
|
||||
Stadionbereiche können zur Kapazität summiert werden; fehlende Angaben
|
||||
bleiben sichtbar als `—`. Eine explizite Vereinsstärke und ein aus
|
||||
Kaderspielern gebildeter Mittelwert haben unterschiedliche Datenquellen
|
||||
und werden nicht als identische Kennzahl ausgegeben.
|
||||
|
||||
„Spieler“ führt zum tatsächlichen Kader dieses Vereins, in OBW-Kaderreihenfolge.
|
||||
Ein Spielerknopf öffnet dessen Profil mit aufgelöstem Foto beziehungsweise
|
||||
konfiguriertem Asset-Fallback, Positionen, Alter, Stärke, Verein und Vertrag.
|
||||
Das Alter wird bei vorhandenem Geburtsdatum zum Demodatum berechnet.
|
||||
Ein nur importiertes Referenzalter behält seinen bekannten Bezugszeitpunkt;
|
||||
es wird kein Geburtstag erfunden. Vertragsdauer bedeutet verbleibende
|
||||
vollständige Kalendermonate aus einem passenden vorhandenen Vertrag,
|
||||
keine Vertragsverhandlung oder Initialisierung eines Spielzustands.
|
||||
|
||||
Die Dialogfolge lautet Bericht → Verein → Kader → Spielerprofil.
|
||||
„Zurück“/„Schließen“, Escape oder Rechtsklick schließen die Detailauflage
|
||||
und stellen den ursprünglichen Berichtsfokus wieder her. Es gibt in diesem
|
||||
Paket keinen Vertrags-, Transfer- oder sonstigen Schreibpfad aus einem Profil.
|
||||
Lange Kader werden innerhalb des Dialogs gescrollt. Tab macht den fokussierten
|
||||
Spieler sichtbar; dasselbe gilt für Vereine in langen Begegnungslisten. Dies
|
||||
verbessert bewusst einen Tastaturfehler der HTML-Vorlage, in der verborgene
|
||||
Zeilen zwar fokussiert, aber nicht automatisch sichtbar werden.
|
||||
|
||||
## DataSource, Checkpoints und Kalenderkopplung
|
||||
|
||||
[DemoSource](../../../../src/modern/ui/model.cpp) besitzt die getrennten
|
||||
Präsentationsdaten. [demo_reports](../../../../src/modern/ui/demo_reports.hpp)
|
||||
liefert die Auswertungen; [Berichtsansichten](../../../../src/modern/ui/reports_screens.inc),
|
||||
[Picker](../../../../src/modern/ui/report_pickers.inc) und
|
||||
[Detailansichten](../../../../src/modern/ui/report_details.inc) konsumieren sie.
|
||||
Aktionen werden auf einer Kopie validiert. Unbekannte IDs, unerlaubte
|
||||
Schlüssel, falsche Typen und Werte außerhalb der Grenzen werden ohne
|
||||
Veröffentlichung einer Teiländerung abgelehnt.
|
||||
|
||||
UI-Checkpoints speichern `reports` mit Tabellen-/Stärkensortierung,
|
||||
Filter, Liga, Wettbewerb und Runde. Geöffnete Picker oder Detaildialoge
|
||||
sind flüchtige Ansichtszustände; ein Datensnapshot ist kein Versprechen,
|
||||
diese Auflagen nach dem Laden automatisch wieder zu öffnen.
|
||||
|
||||
Alte UI-Demostände ohne `reports` erhalten dessen Defaults und übernehmen
|
||||
dabei die vorhandene Kalenderliga. Alte Stände ohne `opening_created`
|
||||
erhalten `false`, auch wenn ihr bisheriges `opening`-Feld bereits „complete“
|
||||
lautet. Ungültige vorhandene Berichtsdaten werden nicht still durch Defaults
|
||||
ersetzt. Beim Laden vorhandener gültiger Berichtsdaten ist deren Liga für
|
||||
die gemeinsame Kalender-/Berichtsvorschau maßgeblich.
|
||||
|
||||
Ein Ligawechsel im [Kalender](../calendar/README.md) aktualisiert auch die
|
||||
Berichtsliga und begrenzt deren Runde. Umgekehrt übernehmen Kalender und
|
||||
Berichte die in den Berichten ausgewählte Liga gemeinsam. Datumsauswahl
|
||||
und Manageridentität werden dadurch nicht ersetzt.
|
||||
|
||||
Der Abschluss des Demoauftakts meldet die Aktion `opening = complete`
|
||||
und setzt dabei `opening_created` auf `true`. Der alte gespeicherte
|
||||
Zeichenkettenwert allein ersetzt diese Abschlussmeldung nicht. Danach
|
||||
verwendet „Übrige Spiele → DFB-Pokal“
|
||||
dieselben benachbarten Auftaktpaare aus höchstens 64 deutschen Ligavereinen,
|
||||
also höchstens 32 Begegnungen. Überschrift ist „1. Runde“, Ergebnisse
|
||||
bleiben `null` beziehungsweise „–“, und die Rundenpfeile sind deaktiviert.
|
||||
Das verbindet zwei Demoansichten; es ist weder eine echte Pokalauslosung
|
||||
noch eine neue Session- oder Spielregel.
|
||||
|
||||
## Referenzgeometrie und Prüfstand
|
||||
|
||||
Die HTML-Referenz verwendet den logischen 3840×2160-Desktop mit einem
|
||||
2720×2040-Fenster bei `(560, 60)`, einer Titelleiste mit 108 und einer
|
||||
Footerbedienung mit 94 logischen Pixeln Höhe. Bei 1920×1080 entsprechen Fenster und Footer
|
||||
1360×1020 beziehungsweise 47 physischen Pixeln Höhe. Tabellen- und
|
||||
Stärkenbreiten sowie Zeilenhöhen berücksichtigen die tatsächlichen 18 oder
|
||||
20 Vereine. Bodytext, Tabellenkopf und Auswahlknöpfe orientieren sich an
|
||||
36, 30 und 32 logischen Pixeln; die Spieltagsüberschrift an 46.
|
||||
Die Themes Midnight, Silver und Matchday verwenden die gemeinsame
|
||||
Menügestaltung. Geometrische Zielwerte sind keine Behauptung pixelgleicher
|
||||
Rasterung zwischen Browser und RmlUI.
|
||||
|
||||
[Synthetische Providertests](../../../../tests/modern_reports_tests.cpp)
|
||||
prüfen unter anderem 18-/20-Team-Spielpläne, Hin-/Rückspiel und Heimrecht,
|
||||
Punkte-/Torerhaltung, Filterzerlegung, Sortierung, fehlende Positionswerte,
|
||||
atomare Ablehnung, Reset, Clamping und die begrenzten Auftaktpaare. Der
|
||||
isolierte Linux-Komponententest und alle 17 ausgewählten Integrations-/
|
||||
Regressionstests bestehen auf dem zusammengeführten Stand.
|
||||
|
||||
Die unabhängige Menüprüfung erfasst 48 Fälle: vier Ansichten × drei Themes ×
|
||||
zwei Größen × 18/20 Vereine. 113 native Bedienungszustände und 94
|
||||
Browserreferenzzustände decken unter anderem Sortierrichtungen, Filter,
|
||||
Rücksetzen, Ligawechsel, Rundenumlauf und Wettbewerbe ab. Die Detailprüfung
|
||||
umfasst zusätzlich 22 Zustandsprüfungen und drei finale Sichtprüfungen.
|
||||
Gemessene Textboxen passen in ihre Zellen und stehen vertikal mittig;
|
||||
die Bruchteilsverteilung der 20er-Zeilen weicht um weniger als einen
|
||||
physischen Pixel von Chromiums automatischem Tabellenlayout ab.
|
||||
|
||||
Private Screenshots, Eingabeskripte, Binärhashes und UI-Demostände liegen in
|
||||
`bmh_4k_ui/docs/qa/reports-batch-2026-10-23/`. Der OS-Neustart unterbrach den
|
||||
Build; neun fehlende Matrixfälle und die finalen Aufnahmen wurden danach
|
||||
ergänzt. Die beiden Fokuskorrekturen wurden gezielt nachgeprüft. Diese
|
||||
Nachweise betreffen Linux/OpenGL und die beschriebenen Daten; sie sind
|
||||
keine vollständige Windows-/macOS-Laufzeitabnahme oder Freigabe aller Menüs.
|
||||
@@ -62,3 +62,7 @@ deshalb nicht ins öffentliche Quellcode-Repository. Öffentliche Zusammenfassun
|
||||
- [Nativer Stand](NATIVE_STATUS.md)
|
||||
- [Typografie-Befunde](typography-qa.md)
|
||||
- [Training](desktop/training/README.md) und [Taktik](desktop/tactics/README.md)
|
||||
|
||||
- [Berichte](desktop/reports/README.md): Tabellen/Stärken und zwei Spielübersichten
|
||||
als gemeinsames Paket; eigenständiger HTML-/Renderervergleich einschließlich
|
||||
20 Vereinen, Sortierung, Footerpickern und Vereins-/Spielerprofilen.
|
||||
@@ -7,16 +7,18 @@ Bedienungsnachweise bleiben im privaten QA-Paket.
|
||||
|
||||
| Bereich | Priorität | Noch offen |
|
||||
|---|---|---|
|
||||
| Tabellen/Stärken | P1 | Überschrift-Knöpfe sind vorhanden, Sortieren und Richtungshinweis fehlen. |
|
||||
| Tabellen | P1 | „Gesamt“ muss Land und Filter wie HTML zurücksetzen; derzeit kein vollständiger Rücksetzpfad. |
|
||||
| Vereinsdetails | P1 | Tabellenklick zeigt nur einen Hinweis; Vereinsprofil, Kader- und Spielerprofilpfad fehlen. |
|
||||
| Tabellen | P2 | „Letzte 8“, Qualifikationsfarben/-legende und eigene Vereinsmarkierung ergänzen. |
|
||||
| Stärken | P2 | Spaltenkopf/Zeilenhöhe an die eigene HTML-Ansicht angleichen; keine Tabellenplatznummern. |
|
||||
| Gemeinsame Dropdowns | P2 | Markierungsspalte, Popupzeilenhöhe, Hintergrund/Akzent und Platzierung an der Glasfenstergrenze angleichen. |
|
||||
| Länder-Picker | P2 | Bewusste Neuwahl derselben Nation setzt in HTML auf deren erste Liga zurück; native Selects behandeln unveränderte Werte noch als unverändert. Abbrechen erhält dagegen ausdrücklich die Unterliga. |
|
||||
| Weitere native Dropdowns | P2 | Die neuen HTML-nahen Footerpicker gelten zunächst für Tabellen, Stärken, Ligaspiele und übrige Spiele. Kalender/Manager und weitere Auswahlfelder verwenden noch den bisherigen Select-Unterbau. |
|
||||
| Länder-Picker außerhalb des Berichtpakets | P2 | Bewusste Neuwahl derselben Nation setzt in HTML auf deren erste Liga zurück. In den vier Berichtmenüs umgesetzt; Kalender/Manager noch gesondert angleichen. Abbrechen muss die Unterliga erhalten. |
|
||||
| Desktop/Rahmen | P2 | Vollständiger Bild-, Widgetinhalt- und Glasvergleich noch ausstehend; aktuelle Teilprüfungen betreffen einzelne Komponenten. |
|
||||
| Weitere Untermenüs | Offen | Noch nicht portierte Routen im Gesamtkatalog bleiben ausdrücklich `UNIMPLEMENTED`. |
|
||||
|
||||
Mit dem [Berichtpaket](desktop/reports/README.md) sind Sortierung und
|
||||
Richtungshinweis, „Gesamt“, Formspalte, Qualifikationsfarben/-legende,
|
||||
eigene Vereinsmarkierung und die abweichende Stärkentabelle umgesetzt.
|
||||
Vereinsprofil, Kader und Spielerprofil ersetzen den bisherigen Hinweistext.
|
||||
Die neuen Footerpicker übernehmen Markierungsspalte, Popupzeilen,
|
||||
Themes, Platzierung und Tastatursteuerung der HTML-Vorlage.
|
||||
|
||||
Bereits korrigiert wurden vertikale Button-/Dropdownbeschriftungen,
|
||||
Pfeilausrichtung, Escape/Fokus nach Auswahl, Training-Scrollposition,
|
||||
Budgetumbrüche, lange Spielernamen neben Stärkewerten sowie Taktik-Schatten.
|
||||
@@ -26,7 +28,8 @@ gemeinsamen Controländerungen zusätzlich in mehreren Menüs nachgeprüft.
|
||||
Die erste Gesamterfassung enthält 36 Routen, davon zwölf native Aufnahmen
|
||||
und 24 ausstehende Ports. Diese historische Matrix bleibt unverändert.
|
||||
Der anschließend übertragene Kalender bekommt einen eigenen Vergleich;
|
||||
spätere Meilensteine erfassen denselben Gesamtkatalog erneut.
|
||||
der aktuelle Runner erfasst 15 native Routen und 21 offene Ports.
|
||||
Spätere Meilensteine erfassen denselben Gesamtkatalog erneut.
|
||||
|
||||
Siehe [QA-Ablauf](menu-qa.md), [Typografie](typography-qa.md) und
|
||||
[aktuellen nativen Stand](NATIVE_STATUS.md).
|
||||
@@ -1,5 +1,5 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
add_library(bmh_modern_ui_core STATIC catalog.cpp model.cpp gui_assets.cpp desktop.cpp demo_sports.cpp demo_calendar.cpp)
|
||||
add_library(bmh_modern_ui_core STATIC catalog.cpp model.cpp gui_assets.cpp desktop.cpp demo_sports.cpp demo_calendar.cpp demo_reports.cpp)
|
||||
target_include_directories(bmh_modern_ui_core PUBLIC ../..)
|
||||
target_link_libraries(bmh_modern_ui_core PUBLIC bmh_asset_io)
|
||||
add_library(bmh_modern_ui STATIC view.cpp ticket_popover.cpp)
|
||||
@@ -14,7 +14,7 @@ endif()
|
||||
set(modern_assets "${CMAKE_BINARY_DIR}/assets/modern")
|
||||
FetchContent_GetProperties(rmlui)
|
||||
file(MAKE_DIRECTORY "${modern_assets}")
|
||||
foreach(asset modern.rml theme.rcss ticket.rcss sports.rcss calendar.rcss)
|
||||
foreach(asset modern.rml theme.rcss ticket.rcss sports.rcss calendar.rcss reports.rcss report_details.rcss report_pickers.rcss)
|
||||
configure_file("${CMAKE_SOURCE_DIR}/assets/modern/${asset}" "${modern_assets}/${asset}" COPYONLY)
|
||||
endforeach()
|
||||
file(GLOB modern_icons CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/assets/modern/icons/*.svg")
|
||||
@@ -41,6 +41,12 @@ if(MSVC)
|
||||
target_compile_options(modern_ui_core_tests PRIVATE /utf-8)
|
||||
endif()
|
||||
add_test(NAME modern_ui_core_tests COMMAND modern_ui_core_tests)
|
||||
add_executable(modern_reports_tests ../../../tests/modern_reports_tests.cpp)
|
||||
target_link_libraries(modern_reports_tests PRIVATE bmh_modern_ui_core)
|
||||
if(MSVC)
|
||||
target_compile_options(modern_reports_tests PRIVATE /utf-8)
|
||||
endif()
|
||||
add_test(NAME modern_reports_tests COMMAND modern_reports_tests)
|
||||
add_executable(modern_ticket_document_tests ../../../tests/modern_ticket_document_tests.cpp ticket_popover.cpp)
|
||||
target_link_libraries(modern_ticket_document_tests PRIVATE bmh_modern_ui_core RmlUi::Core)
|
||||
if(MSVC)
|
||||
|
||||
+65
-31
@@ -148,6 +148,27 @@ void App::ProcessEvent(Rml::Event &event) try {
|
||||
n = n->GetParentNode())
|
||||
if (n->GetId() == "native-ticket-layer")
|
||||
return;
|
||||
if (!report_detail_kind_.empty() && popup_.empty()) {
|
||||
const bool keyboard = type == "keydown";
|
||||
const auto key = keyboard
|
||||
? Rml::Input::KeyIdentifier(event.GetParameter<int>("key_identifier", 0))
|
||||
: Rml::Input::KI_UNKNOWN;
|
||||
if ((keyboard && key == Rml::Input::KI_ESCAPE) ||
|
||||
(type == "mouseup" && event.GetParameter<int>("button", 0) == 1)) {
|
||||
report_detail_action("report-detail-close", nullptr);
|
||||
event.StopImmediatePropagation();
|
||||
return;
|
||||
}
|
||||
bool inside = false;
|
||||
for (auto *n = event.GetTargetElement(); n && n != doc_; n = n->GetParentNode())
|
||||
if (n->GetId() == "report-detail-layer") inside = true;
|
||||
if (!inside && (type == "click" || type == "dblclick" || type == "mousedown" ||
|
||||
type == "mouseup" || (keyboard && key != Rml::Input::KI_TAB))) {
|
||||
event.StopImmediatePropagation();
|
||||
return;
|
||||
}
|
||||
} else if (report_detail_kind_.empty() && popup_.empty() && report_picker_event(event))
|
||||
return;
|
||||
if (type == "mouseup" && event.GetParameter<int>("button", 0) == 1) {
|
||||
if (scene_ == "desktop" && !menu_.empty() && popup_.empty()) {
|
||||
menu_.clear();
|
||||
@@ -291,14 +312,16 @@ void App::ProcessEvent(Rml::Event &event) try {
|
||||
if (key == Rml::Input::KI_TAB &&
|
||||
(!menu_.empty() || !popup_.empty() || scene_ != "desktop")) {
|
||||
Rml::ElementList controls;
|
||||
auto *root = !popup_.empty() ? element("popup") : element("canvas");
|
||||
auto *root = !popup_.empty() ? element("popup")
|
||||
: !report_detail_kind_.empty() ? element("report-detail-layer")
|
||||
: element("canvas");
|
||||
root->QuerySelectorAll(
|
||||
controls, !popup_.empty()
|
||||
controls, !popup_.empty() || !report_detail_kind_.empty()
|
||||
? "button,input,select"
|
||||
: ".window button,.window input,.window select");
|
||||
controls.erase(std::remove_if(controls.begin(), controls.end(),
|
||||
[](auto *n) {
|
||||
return !n->IsVisible() ||
|
||||
return !n->IsVisible(true) ||
|
||||
n->HasAttribute("disabled");
|
||||
}),
|
||||
controls.end());
|
||||
@@ -310,6 +333,10 @@ void App::ProcessEvent(Rml::Event &event) try {
|
||||
const auto next = (old + (backwards ? -1 : 1) + int(controls.size())) %
|
||||
int(controls.size());
|
||||
controls[size_t(next)]->Focus(true);
|
||||
if (controls[size_t(next)]->GetId().starts_with("report-detail-player-") ||
|
||||
controls[size_t(next)]->GetId().starts_with("report-club-"))
|
||||
controls[size_t(next)]->ScrollIntoView(
|
||||
Rml::ScrollIntoViewOptions(Rml::ScrollAlignment::Nearest));
|
||||
event.StopImmediatePropagation();
|
||||
}
|
||||
return;
|
||||
@@ -347,6 +374,31 @@ void App::ProcessEvent(Rml::Event &event) try {
|
||||
void App::dispatch(const std::string &action, Rml::Element *target) {
|
||||
const auto id =
|
||||
target ? target->GetAttribute<Rml::String>("data-id", "") : std::string();
|
||||
if (report_detail_action(action, target)) {
|
||||
close_report_picker(false);
|
||||
return;
|
||||
}
|
||||
if (report_picker_action(action, target))
|
||||
return;
|
||||
if (action == "report-sort" || action == "report-reset" || action == "report-round") {
|
||||
Json change;
|
||||
if (action == "report-sort")
|
||||
change = {{"kind", "sort"}, {"view", menu_}, {"key", id}};
|
||||
else if (action == "report-reset")
|
||||
change = {{"kind", "reset"}};
|
||||
else {
|
||||
if (menu_ == "other" && snap().state.value("opening_created", false) &&
|
||||
snap().state.at("reports").value("competition", 0) == 3)
|
||||
return;
|
||||
change = {{"kind", "round"}, {"step", std::stoi(id)}, {"other", menu_ == "other"}};
|
||||
}
|
||||
if (apply("reports", change)) {
|
||||
close_report_picker(false);
|
||||
focus_after_render_ = target->GetId();
|
||||
refresh();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (action == "popup-close") {
|
||||
popup_.clear();
|
||||
confirm_ = {};
|
||||
@@ -932,12 +984,14 @@ void App::dispatch(const std::string &action, Rml::Element *target) {
|
||||
}
|
||||
static const std::set<std::string> available = {
|
||||
"tables", "strengths", "camp", "settings",
|
||||
"save", "load", "training", "tactics", "calendar"};
|
||||
"save", "load", "training", "tactics", "calendar", "league", "other"};
|
||||
if (!available.contains(route)) {
|
||||
message("Diese native Ansicht wird im nächsten Menüpaket übertragen.");
|
||||
return;
|
||||
}
|
||||
menu_ = route;
|
||||
report_picker_.clear();
|
||||
report_detail_kind_.clear();
|
||||
if (route == "settings") {
|
||||
settings_category_ = "display";
|
||||
draft_preferences_ = nullptr;
|
||||
@@ -1124,19 +1178,6 @@ void App::dispatch(const std::string &action, Rml::Element *target) {
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (action == "player-detail") {
|
||||
if (const auto *p = world_->find("players", id))
|
||||
message(world_->name(*p) + " · Stärke " +
|
||||
std::to_string(
|
||||
p->value("attributes", Json::object()).value("strength", 0)));
|
||||
return;
|
||||
}
|
||||
if (action == "club-detail") {
|
||||
if (const auto *c = world_->find("clubs", id))
|
||||
message(world_->name(*c) + " · " +
|
||||
std::to_string(world_->squad(id).size()) + " Spieler");
|
||||
return;
|
||||
}
|
||||
if (action == "squad-tactics") {
|
||||
menu_ = "tactics";
|
||||
refresh();
|
||||
@@ -1187,13 +1228,11 @@ void App::change(Rml::Element *target) {
|
||||
}
|
||||
return;
|
||||
}
|
||||
if ((kind == "manager-country" || kind == "table-country") &&
|
||||
value == country_)
|
||||
if (kind == "manager-country" && value == country_)
|
||||
return;
|
||||
if ((kind == "manager-league" || kind == "table-league") && value == league_)
|
||||
if (kind == "manager-league" && value == league_)
|
||||
return;
|
||||
if (kind == "manager-country" || kind == "manager-league" ||
|
||||
kind == "table-country" || kind == "table-league")
|
||||
if (kind == "manager-country" || kind == "manager-league")
|
||||
focus_after_render_ = target->GetId();
|
||||
if (kind == "manager-country" || kind == "manager-league") {
|
||||
if (!manager_picker_)
|
||||
@@ -1206,15 +1245,6 @@ void App::change(Rml::Element *target) {
|
||||
refresh();
|
||||
} else if (kind == "manager-strength") {
|
||||
selections_["manager-strength"] = value;
|
||||
} else if (kind == "table-country") {
|
||||
country_ = value;
|
||||
league_.clear();
|
||||
refresh();
|
||||
} else if (kind == "table-league") {
|
||||
league_ = value;
|
||||
refresh();
|
||||
} else if (kind == "table-scope") {
|
||||
selections_["table-scope"] = value;
|
||||
}
|
||||
}
|
||||
void App::input(Rml::Element *target) {
|
||||
@@ -1331,6 +1361,10 @@ void App::script() {
|
||||
editor::path(command.at("path").get<std::string>()),
|
||||
Json{{"scene", scene_},
|
||||
{"menu", menu_},
|
||||
{"report_picker", report_picker_},
|
||||
{"report_detail", {{"kind", report_detail_kind_},
|
||||
{"club", report_detail_club_},
|
||||
{"player", report_detail_player_}}},
|
||||
{"desktop", desktop_},
|
||||
{"demo", source_ ? snap().state : Json()}}
|
||||
.dump(2));
|
||||
|
||||
@@ -0,0 +1,436 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "modern/ui/demo_reports.hpp"
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <limits>
|
||||
#include <numeric>
|
||||
#include <set>
|
||||
#include <string_view>
|
||||
|
||||
namespace bmh::modern_ui {
|
||||
namespace {
|
||||
constexpr int played_rounds = 26;
|
||||
constexpr int other_rounds = 34;
|
||||
constexpr std::array<int, 9> other_pairs = {9, 8, 4, 8, 4, 4, 8, 8, 1};
|
||||
struct Fixture {
|
||||
int home, away, home_goals, away_goals, round;
|
||||
};
|
||||
bool integer(const Json &v, int low, int high) {
|
||||
return v.is_number_integer() && v >= low && v <= high;
|
||||
}
|
||||
bool keys(const Json &v, std::initializer_list<const char *> required,
|
||||
std::initializer_list<const char *> optional = {}) {
|
||||
if (!v.is_object())
|
||||
return false;
|
||||
std::set<std::string> allowed;
|
||||
for (const auto *key : required) {
|
||||
if (!v.contains(key))
|
||||
return false;
|
||||
allowed.emplace(key);
|
||||
}
|
||||
for (const auto *key : optional)
|
||||
allowed.emplace(key);
|
||||
for (const auto &entry : v.items())
|
||||
if (!allowed.contains(entry.key()))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
int rounds(size_t size) {
|
||||
if (size < 2)
|
||||
return 1;
|
||||
if (size > size_t(std::numeric_limits<int>::max() / 2 - 1))
|
||||
return 1;
|
||||
return 2 * (int(size) + int(size % 2) - 1);
|
||||
}
|
||||
std::string initial_league(const Catalog &world) {
|
||||
auto leagues = world.leagues("nation:de");
|
||||
if (leagues.empty())
|
||||
leagues = world.leagues();
|
||||
return leagues.empty() ? "" : leagues.front()->at("id").get<std::string>();
|
||||
}
|
||||
bool league_exists(const Catalog &world, const std::string &id) {
|
||||
const auto leagues = world.leagues();
|
||||
if (leagues.empty())
|
||||
return id.empty();
|
||||
return std::any_of(leagues.begin(), leagues.end(), [&](const auto *league) {
|
||||
return league->at("id") == id;
|
||||
});
|
||||
}
|
||||
int league_rounds(const Catalog &world, const std::string &id) {
|
||||
return id.empty() ? 1 : rounds(world.clubs(id).size());
|
||||
}
|
||||
int league_index(const Catalog &world, const std::string &id) {
|
||||
const auto leagues = world.leagues();
|
||||
const auto found = std::find_if(leagues.begin(), leagues.end(), [&](auto *l) {
|
||||
return l->at("id") == id;
|
||||
});
|
||||
return found == leagues.end() ? 0 : int(found - leagues.begin());
|
||||
}
|
||||
bool sort_key(const std::string &view, const std::string &key) {
|
||||
static const std::set<std::string> table_keys = {
|
||||
"original", "rank", "played", "wins", "draw", "loss", "form",
|
||||
"points", "gf", "diff"};
|
||||
static const std::set<std::string> strength_keys = {
|
||||
"original", "club", "keeper", "defence", "midfield", "attack",
|
||||
"strength"};
|
||||
return view == "tables" ? table_keys.contains(key)
|
||||
: view == "strengths" && strength_keys.contains(key);
|
||||
}
|
||||
std::vector<Fixture> fixtures(size_t club_count, int league) {
|
||||
if (club_count < 2 || club_count > size_t(std::numeric_limits<int>::max() / 2 - 1))
|
||||
return {};
|
||||
const int count = int(club_count), ring_size = count + count % 2;
|
||||
std::vector<int> ring(size_t(ring_size), 0);
|
||||
std::iota(ring.begin(), ring.end(), 0);
|
||||
std::vector<Fixture> result;
|
||||
for (int round = 0; round < ring_size - 1; ++round) {
|
||||
for (int pair = 0; pair < ring_size / 2; ++pair) {
|
||||
int home = ring[size_t(pair)], away = ring[size_t(ring_size - 1 - pair)];
|
||||
if ((pair == 0 ? round : pair) % 2)
|
||||
std::swap(home, away);
|
||||
if (home < count && away < count)
|
||||
result.push_back({home, away, 0, 0, round});
|
||||
}
|
||||
std::rotate(ring.begin() + 1, ring.end() - 1, ring.end());
|
||||
}
|
||||
const auto first_size = result.size();
|
||||
for (size_t i = 0; i < first_size; ++i) {
|
||||
const auto first = result[i];
|
||||
result.push_back({first.away, first.home, 0, 0,
|
||||
first.round + ring_size - 1});
|
||||
}
|
||||
for (auto &match : result) {
|
||||
// HTML preview arithmetic, deliberately independent of every game RNG.
|
||||
const uint32_t seed = uint32_t(match.round + 1) * 97u +
|
||||
uint32_t(match.home + 3) * 37u +
|
||||
uint32_t(match.away + 5) * 19u +
|
||||
uint32_t(league) * 53u;
|
||||
match.home_goals = int((seed ^ (seed >> 3)) % 5);
|
||||
match.away_goals = int((seed ^ (seed >> 5)) % 4);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
// Deterministic name ordering without a host locale dependency. Common Latin
|
||||
// accents are primary-equivalent, and digit runs compare numerically.
|
||||
std::string name_key(std::string name) {
|
||||
for (const auto &[from, to] :
|
||||
std::initializer_list<std::pair<std::string_view, std::string_view>>{
|
||||
{"Ä", "a"}, {"ä", "a"}, {"Ö", "o"}, {"ö", "o"},
|
||||
{"Ü", "u"}, {"ü", "u"}, {"ß", "ss"}, {"ẞ", "ss"},
|
||||
{"Á", "a"}, {"á", "a"}, {"À", "a"}, {"à", "a"},
|
||||
{"Â", "a"}, {"â", "a"}, {"É", "e"}, {"é", "e"},
|
||||
{"È", "e"}, {"è", "e"}, {"Ê", "e"}, {"ê", "e"},
|
||||
{"Í", "i"}, {"í", "i"}, {"Ó", "o"}, {"ó", "o"},
|
||||
{"Ô", "o"}, {"ô", "o"}, {"Ú", "u"}, {"ú", "u"},
|
||||
{"Ç", "c"}, {"ç", "c"}, {"Ñ", "n"}, {"ñ", "n"}}) {
|
||||
size_t at = 0;
|
||||
while ((at = name.find(from, at)) != std::string::npos) {
|
||||
name.replace(at, from.size(), to);
|
||||
at += to.size();
|
||||
}
|
||||
}
|
||||
for (char &c : name)
|
||||
if (c >= 'A' && c <= 'Z')
|
||||
c += 'a' - 'A';
|
||||
return name;
|
||||
}
|
||||
int name_compare(const std::string &a, const std::string &b) {
|
||||
const auto x = name_key(a), y = name_key(b);
|
||||
size_t i = 0, j = 0;
|
||||
const auto digit = [](char c) { return c >= '0' && c <= '9'; };
|
||||
while (i < x.size() && j < y.size()) {
|
||||
if (digit(x[i]) && digit(y[j])) {
|
||||
size_t ei = i, ej = j;
|
||||
while (ei < x.size() && digit(x[ei])) ++ei;
|
||||
while (ej < y.size() && digit(y[ej])) ++ej;
|
||||
while (i < ei && x[i] == '0') ++i;
|
||||
while (j < ej && y[j] == '0') ++j;
|
||||
if (ei - i != ej - j)
|
||||
return ei - i < ej - j ? -1 : 1;
|
||||
const int n = x.compare(i, ei - i, y, j, ej - j);
|
||||
if (n)
|
||||
return n < 0 ? -1 : 1;
|
||||
i = ei;
|
||||
j = ej;
|
||||
continue;
|
||||
}
|
||||
if (x[i] != y[j])
|
||||
return static_cast<unsigned char>(x[i]) < static_cast<unsigned char>(y[j]) ? -1 : 1;
|
||||
++i;
|
||||
++j;
|
||||
}
|
||||
return i == x.size() ? (j == y.size() ? 0 : -1) : 1;
|
||||
}
|
||||
Json sorted(std::vector<Json> rows, const Json &sort) {
|
||||
const auto key = sort.at("key").get<std::string>();
|
||||
const bool desc = sort.at("desc").get<bool>();
|
||||
std::stable_sort(rows.begin(), rows.end(), [&](const Json &a, const Json &b) {
|
||||
const auto &x = a.at(key == "club" ? "name" : key);
|
||||
const auto &y = b.at(key == "club" ? "name" : key);
|
||||
if (x.is_null() != y.is_null())
|
||||
return !x.is_null(); // Missing OBW data remains last in both directions.
|
||||
const int comparison = x.is_null() ? 0
|
||||
: key == "club" ? name_compare(x.get<std::string>(), y.get<std::string>())
|
||||
: x == y ? 0 : x < y ? -1 : 1;
|
||||
return comparison ? (desc ? comparison > 0 : comparison < 0)
|
||||
: a.at("original") < b.at("original");
|
||||
});
|
||||
return Json(rows);
|
||||
}
|
||||
Json average(const std::vector<const Json *> &squad, const std::string &position) {
|
||||
double sum = 0;
|
||||
int count = 0;
|
||||
for (auto *player : squad) {
|
||||
const auto attrs = player->find("attributes");
|
||||
if (attrs == player->end() || !attrs->is_object())
|
||||
continue;
|
||||
const auto strength = attrs->find("strength");
|
||||
if (strength == attrs->end() || !strength->is_number())
|
||||
continue;
|
||||
const double value = strength->get<double>();
|
||||
if (!std::isfinite(value) || value < 0 || value > 100)
|
||||
continue;
|
||||
if (!position.empty()) {
|
||||
const auto positions = player->find("positions");
|
||||
if (positions == player->end() || !positions->is_array() ||
|
||||
std::find(positions->begin(), positions->end(), position) == positions->end())
|
||||
continue;
|
||||
}
|
||||
sum += value;
|
||||
++count;
|
||||
}
|
||||
return count ? Json(int(std::lround(sum / count))) : Json();
|
||||
}
|
||||
} // namespace
|
||||
|
||||
Json demo_reports(const Catalog &world) {
|
||||
const auto league = initial_league(world);
|
||||
return {{"league", league},
|
||||
{"round", std::min(26, league_rounds(world, league) - 1)},
|
||||
{"filter", 0}, {"competition", 0},
|
||||
{"sorts", {{"tables", {{"key", "points"}, {"desc", true}}},
|
||||
{"strengths", {{"key", "original"}, {"desc", false}}}}}};
|
||||
}
|
||||
bool valid_demo_reports(const Json &state, const Catalog &world) {
|
||||
try {
|
||||
if (!keys(state, {"league", "round", "filter", "competition", "sorts"}) ||
|
||||
!state.at("league").is_string() ||
|
||||
!league_exists(world, state.at("league").get<std::string>()) ||
|
||||
!integer(state.at("filter"), 0, 4) ||
|
||||
!integer(state.at("competition"), 0, 8))
|
||||
return false;
|
||||
const int count = std::max(league_rounds(world, state.at("league")),
|
||||
state.at("competition") == 0 ? 1 : other_rounds);
|
||||
if (!integer(state.at("round"), 0, count - 1) ||
|
||||
!keys(state.at("sorts"), {"tables", "strengths"}))
|
||||
return false;
|
||||
for (const auto *view : {"tables", "strengths"}) {
|
||||
const auto &sort = state.at("sorts").at(view);
|
||||
if (!keys(sort, {"key", "desc"}) || !sort.at("key").is_string() ||
|
||||
!sort.at("desc").is_boolean() || !sort_key(view, sort.at("key")))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} catch (const Json::exception &) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int report_round_count(const Catalog &world, const Json &state, bool other) {
|
||||
if (!valid_demo_reports(state, world))
|
||||
return 1;
|
||||
return other && state.at("competition") != 0
|
||||
? other_rounds : league_rounds(world, state.at("league"));
|
||||
}
|
||||
std::string edit_demo_reports(Json &state, const Json &action, const Catalog &world) {
|
||||
if (!valid_demo_reports(state, world))
|
||||
return "invalid_reports_state";
|
||||
try {
|
||||
if (!action.is_object() || !action.contains("kind") || !action.at("kind").is_string())
|
||||
return "invalid_reports_action";
|
||||
const auto kind = action.at("kind").get<std::string>();
|
||||
auto next = state;
|
||||
if (kind == "country" || kind == "league") {
|
||||
if (!keys(action, {"kind", "value"}) || !action.at("value").is_string())
|
||||
return "invalid_reports_action";
|
||||
const auto value = action.at("value").get<std::string>();
|
||||
if (kind == "country") {
|
||||
if (!world.find("nations", value))
|
||||
return "invalid_reports_country";
|
||||
const auto leagues = world.leagues(value);
|
||||
if (leagues.empty())
|
||||
return "invalid_reports_country";
|
||||
next["league"] = leagues.front()->at("id");
|
||||
} else {
|
||||
if (value.empty() || !league_exists(world, value))
|
||||
return "invalid_reports_league";
|
||||
next["league"] = value;
|
||||
}
|
||||
next["round"] = std::min(next.at("round").get<int>(),
|
||||
league_rounds(world, next.at("league")) - 1);
|
||||
} else if (kind == "filter" || kind == "competition") {
|
||||
if (!keys(action, {"kind", "value"}) ||
|
||||
!integer(action.at("value"), 0, kind == "filter" ? 4 : 8))
|
||||
return "invalid_reports_action";
|
||||
next[kind] = action.at("value").get<int>();
|
||||
if (kind == "competition")
|
||||
next["round"] = std::min(next.at("round").get<int>(),
|
||||
(next.at("competition") == 0
|
||||
? league_rounds(world, next.at("league"))
|
||||
: other_rounds) - 1);
|
||||
} else if (kind == "round") {
|
||||
if (!keys(action, {"kind", "step"}, {"other"}) ||
|
||||
!integer(action.at("step"), -1, 1) || action.at("step") == 0 ||
|
||||
(action.contains("other") && !action.at("other").is_boolean()))
|
||||
return "invalid_reports_action";
|
||||
const int count = report_round_count(world, next, action.value("other", false));
|
||||
const int current = std::clamp(next.at("round").get<int>(), 0, count - 1);
|
||||
next["round"] = (current + action.at("step").get<int>() + count) % count;
|
||||
} else if (kind == "sort") {
|
||||
if (!keys(action, {"kind", "view", "key"}) ||
|
||||
!action.at("view").is_string() || !action.at("key").is_string())
|
||||
return "invalid_reports_action";
|
||||
const auto view = action.at("view").get<std::string>(), key = action.at("key").get<std::string>();
|
||||
if (!sort_key(view, key))
|
||||
return "invalid_reports_sort";
|
||||
auto &sort = next["sorts"][view];
|
||||
sort["desc"] = sort.at("key") == key ? !sort.at("desc").get<bool>()
|
||||
: key != "club" && key != "rank" && key != "original";
|
||||
sort["key"] = key;
|
||||
} else if (kind == "reset") {
|
||||
if (!keys(action, {"kind"}))
|
||||
return "invalid_reports_action";
|
||||
next["league"] = initial_league(world);
|
||||
next["filter"] = 0;
|
||||
next["sorts"]["tables"] = {{"key", "points"}, {"desc", true}};
|
||||
next["round"] = std::min(next.at("round").get<int>(),
|
||||
league_rounds(world, next.at("league")) - 1);
|
||||
} else {
|
||||
return "unknown_reports_action";
|
||||
}
|
||||
// OpenBMH deviates from the HTML preview by clamping shared round state
|
||||
// when a league/competition changes. The other-competition 34-round range
|
||||
// is a bounded presentation fixture, never an engine scheduling rule.
|
||||
if (!valid_demo_reports(next, world))
|
||||
return "invalid_reports_selection";
|
||||
state = std::move(next);
|
||||
return {};
|
||||
} catch (const Json::exception &) {
|
||||
return "invalid_reports_action";
|
||||
}
|
||||
}
|
||||
Json report_table_rows(const Catalog &world, const Json &state) {
|
||||
if (!valid_demo_reports(state, world))
|
||||
return Json::array();
|
||||
const auto league = state.at("league").get<std::string>();
|
||||
const auto clubs = league.empty() ? std::vector<const Json *>{} : world.clubs(league);
|
||||
std::vector<Json> rows;
|
||||
for (size_t i = 0; i < clubs.size(); ++i)
|
||||
rows.push_back({{"club", clubs[i]->at("id")}, {"original", i}, {"rank", 0},
|
||||
{"played", 0}, {"wins", 0}, {"draw", 0}, {"loss", 0},
|
||||
{"gf", 0}, {"ga", 0}, {"points", 0}, {"diff", 0},
|
||||
{"form", 0}, {"form_text", ""}});
|
||||
const int filter = state.at("filter"), half = league_rounds(world, league) / 2;
|
||||
for (const auto &match : fixtures(clubs.size(), league_index(world, league))) {
|
||||
if (match.round >= played_rounds || (filter == 1 && match.round >= half) ||
|
||||
(filter == 2 && match.round < half))
|
||||
continue;
|
||||
for (int side = 0; side < 2; ++side) {
|
||||
if ((filter == 3 && side != 0) || (filter == 4 && side != 1))
|
||||
continue;
|
||||
auto &row = rows[size_t(side == 0 ? match.home : match.away)];
|
||||
const int gf = side == 0 ? match.home_goals : match.away_goals,
|
||||
ga = side == 0 ? match.away_goals : match.home_goals;
|
||||
row["played"] = row["played"].get<int>() + 1;
|
||||
row["gf"] = row["gf"].get<int>() + gf;
|
||||
row["ga"] = row["ga"].get<int>() + ga;
|
||||
const char form = gf > ga ? 'S' : gf == ga ? 'U' : 'N';
|
||||
const char *metric = form == 'S' ? "wins" : form == 'U' ? "draw" : "loss";
|
||||
row[metric] = row[metric].get<int>() + 1;
|
||||
row["points"] = row["points"].get<int>() + (form == 'S' ? 3 : form == 'U' ? 1 : 0);
|
||||
auto text = row["form_text"].get<std::string>() + form;
|
||||
if (text.size() > 8)
|
||||
text.erase(0, text.size() - 8);
|
||||
row["form_text"] = text;
|
||||
}
|
||||
}
|
||||
for (auto &row : rows) {
|
||||
row["diff"] = row["gf"].get<int>() - row["ga"].get<int>();
|
||||
int form = 0;
|
||||
for (char c : row["form_text"].get<std::string>())
|
||||
form += c == 'S' ? 3 : c == 'U' ? 1 : 0;
|
||||
row["form"] = form;
|
||||
}
|
||||
std::stable_sort(rows.begin(), rows.end(), [](const Json &a, const Json &b) {
|
||||
for (const char *key : {"points", "diff", "gf"})
|
||||
if (a.at(key) != b.at(key)) return a.at(key) > b.at(key);
|
||||
return a.at("original") < b.at("original");
|
||||
});
|
||||
for (size_t i = 0; i < rows.size(); ++i) {
|
||||
rows[i]["rank"] = i + 1;
|
||||
rows[i]["original"] = i; // Gold's stable default-table order, not name order.
|
||||
}
|
||||
return sorted(std::move(rows), state.at("sorts").at("tables"));
|
||||
}
|
||||
Json report_strength_rows(const Catalog &world, const Json &state) {
|
||||
if (!valid_demo_reports(state, world))
|
||||
return Json::array();
|
||||
const auto league = state.at("league").get<std::string>();
|
||||
const auto clubs = league.empty() ? std::vector<const Json *>{} : world.clubs(league);
|
||||
std::vector<Json> rows;
|
||||
for (size_t i = 0; i < clubs.size(); ++i) {
|
||||
const auto id = clubs[i]->at("id").get<std::string>();
|
||||
const auto squad = world.squad(id);
|
||||
rows.push_back({{"club", id}, {"id", id}, {"name", world.name(*clubs[i])},
|
||||
{"original", i}, {"keeper", average(squad, "gk")},
|
||||
{"defence", average(squad, "def")}, {"midfield", average(squad, "mid")},
|
||||
{"attack", average(squad, "fwd")}, {"strength", average(squad, "")}});
|
||||
}
|
||||
return sorted(std::move(rows), state.at("sorts").at("strengths"));
|
||||
}
|
||||
Json report_match_rows(const Catalog &world, const Json &state, bool other) {
|
||||
Json result = Json::array();
|
||||
if (!valid_demo_reports(state, world))
|
||||
return result;
|
||||
const int round = std::clamp(state.at("round").get<int>(), 0,
|
||||
report_round_count(world, state, other) - 1);
|
||||
const auto league = state.at("league").get<std::string>();
|
||||
const auto add = [&](const Json &home, const Json &away, int hg, int ag) {
|
||||
result.push_back({{"home", home}, {"away", away}, {"home_goals", hg},
|
||||
{"away_goals", ag}, {"round", round}});
|
||||
};
|
||||
if (!other || state.at("competition") == 0) {
|
||||
const auto clubs = league.empty() ? std::vector<const Json *>{} : world.clubs(league);
|
||||
for (const auto &match : fixtures(clubs.size(), league_index(world, league)))
|
||||
if (match.round == round)
|
||||
add(clubs[size_t(match.home)]->at("id"), clubs[size_t(match.away)]->at("id"),
|
||||
match.home_goals, match.away_goals);
|
||||
} else {
|
||||
const auto leagues = world.leagues("nation:de");
|
||||
if (leagues.empty()) return result;
|
||||
const auto clubs = world.clubs(leagues.front()->at("id"));
|
||||
if (clubs.size() < 2) return result;
|
||||
const int competition = state.at("competition"), seed = round + competition * 3;
|
||||
for (int i = 0; i < other_pairs[size_t(competition)]; ++i)
|
||||
add(clubs[size_t(i * 2 + seed) % clubs.size()]->at("id"),
|
||||
clubs[size_t(i * 2 + 1 + seed) % clubs.size()]->at("id"),
|
||||
(i + seed) % 4, (i * 3 + seed) % 3);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
Json report_opening_pairs(const Catalog &world) {
|
||||
std::vector<const Json *> pool;
|
||||
for (const auto *league : world.leagues("nation:de"))
|
||||
for (const auto *club : world.clubs(league->at("id")))
|
||||
if (pool.size() < 64)
|
||||
pool.push_back(club);
|
||||
Json result = Json::array();
|
||||
for (size_t i = 0; i + 1 < pool.size(); i += 2)
|
||||
result.push_back({{"home", pool[i]->at("id")},
|
||||
{"away", pool[i + 1]->at("id")},
|
||||
{"home_goals", nullptr}, {"away_goals", nullptr},
|
||||
{"round", 0}});
|
||||
return result;
|
||||
}
|
||||
} // namespace bmh::modern_ui
|
||||
@@ -0,0 +1,25 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
#include "modern/ui/catalog.hpp"
|
||||
|
||||
namespace bmh::modern_ui {
|
||||
// Deterministic presentation fixtures only: no session, engine, or RNG access.
|
||||
// Each function receives the reports subobject, not the complete DemoSource state.
|
||||
Json demo_reports(const Catalog &);
|
||||
bool valid_demo_reports(const Json &, const Catalog &);
|
||||
// Returns an empty string on success, an explicit error on rejection. Rejections
|
||||
// leave the reports object unchanged. Actions use kind/value, or kind=round with
|
||||
// step (+/-1) and optional other, or kind=sort with view/key.
|
||||
std::string edit_demo_reports(Json &, const Json &action, const Catalog &);
|
||||
// Rows retain stable catalog club IDs. Numeric strength components are null when
|
||||
// the corresponding squad positions have no usable OBW strength information.
|
||||
Json report_table_rows(const Catalog &, const Json &);
|
||||
Json report_strength_rows(const Catalog &, const Json &);
|
||||
Json report_match_rows(const Catalog &, const Json &, bool other);
|
||||
// The presentation-only opening draw: adjacent pairs from at most 64 German
|
||||
// league clubs in catalog order; goals are null until a future runtime owns them.
|
||||
Json report_opening_pairs(const Catalog &);
|
||||
// A count (not a last index), always at least 1. Shared round state is clamped
|
||||
// on selection changes; non-league other previews deliberately use 34 rounds.
|
||||
int report_round_count(const Catalog &, const Json &, bool other = false);
|
||||
} // namespace bmh::modern_ui
|
||||
+34
-2
@@ -1,6 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "modern/ui/model.hpp"
|
||||
#include "modern/ui/demo_calendar.hpp"
|
||||
#include "modern/ui/demo_reports.hpp"
|
||||
#include "modern/ui/demo_sports.hpp"
|
||||
#include "modern/ui/desktop.hpp"
|
||||
#include <algorithm>
|
||||
@@ -72,6 +73,7 @@ DemoSource::DemoSource(std::shared_ptr<const Catalog> catalog)
|
||||
{"camp",
|
||||
{{"selected", "resort:4"}, {"confirmed", ""}, {"focus", {5, 4, 6}}}},
|
||||
{"opening", "complete"},
|
||||
{"opening_created", false},
|
||||
{"preferences",
|
||||
{{"theme", "midnight"}, {"volume", 80}, {"effects", true}}},
|
||||
{"edits", Json::object()}};
|
||||
@@ -80,6 +82,7 @@ DemoSource::DemoSource(std::shared_ptr<const Catalog> catalog)
|
||||
if (!valid_date(state_.at("date")))
|
||||
throw editor::Error("invalid_demo_date");
|
||||
state_["calendar"] = demo_calendar(*catalog_, state_.at("date"));
|
||||
state_["reports"] = demo_reports(*catalog_);
|
||||
saved_ = state_;
|
||||
}
|
||||
Snapshot DemoSource::snapshot() const { return {revision_, catalog_, state_}; }
|
||||
@@ -129,6 +132,18 @@ ActionResult DemoSource::apply(const Action &action) {
|
||||
*catalog_);
|
||||
if (!error.empty())
|
||||
return {false, revision_, error};
|
||||
if (action.value.value("kind", "") == "league") {
|
||||
const auto report_error = edit_demo_reports(next["reports"],
|
||||
{{"kind", "league"}, {"value", next["calendar"]["league"]}}, *catalog_);
|
||||
if (!report_error.empty())
|
||||
return {false, revision_, report_error};
|
||||
}
|
||||
} else if (action.kind == "reports") {
|
||||
const auto error = edit_demo_reports(next["reports"], action.value,
|
||||
*catalog_);
|
||||
if (!error.empty())
|
||||
return {false, revision_, error};
|
||||
next["calendar"]["league"] = next["reports"]["league"];
|
||||
} else if (action.kind == "camp.select") {
|
||||
if (!camp_id(action.value))
|
||||
return {false, revision_, "camp_unknown"};
|
||||
@@ -142,9 +157,13 @@ ActionResult DemoSource::apply(const Action &action) {
|
||||
next["camp"]["focus"] = action.value;
|
||||
} else if (action.kind == "camp.remember")
|
||||
next["camp"]["confirmed"] = next["camp"]["selected"];
|
||||
else if (action.kind == "opening")
|
||||
else if (action.kind == "opening") {
|
||||
if (!action.value.is_string())
|
||||
return {false, revision_, "invalid_opening_state"};
|
||||
next["opening"] = action.value;
|
||||
else if (action.kind == "preferences") {
|
||||
if (action.value == "complete")
|
||||
next["opening_created"] = true;
|
||||
} else if (action.kind == "preferences") {
|
||||
if (!preferences(action.value))
|
||||
return {false, revision_, "invalid_preferences"};
|
||||
next["preferences"] = action.value;
|
||||
@@ -200,6 +219,19 @@ Json DemoSource::load(const fs::path &file) {
|
||||
data["calendar"] = demo_calendar(*catalog_, data.at("date"));
|
||||
if (!valid_demo_calendar(data.at("calendar"), *catalog_))
|
||||
throw editor::Error("invalid_demo_calendar");
|
||||
if (!data.contains("reports")) {
|
||||
data["reports"] = demo_reports(*catalog_);
|
||||
const auto error = edit_demo_reports(data["reports"],
|
||||
{{"kind", "league"}, {"value", data["calendar"]["league"]}}, *catalog_);
|
||||
if (!error.empty())
|
||||
throw editor::Error(error);
|
||||
}
|
||||
if (!data.contains("opening_created"))
|
||||
data["opening_created"] = false;
|
||||
if (!valid_demo_reports(data.at("reports"), *catalog_) ||
|
||||
!data.at("opening_created").is_boolean())
|
||||
throw editor::Error("invalid_demo_reports");
|
||||
data["calendar"]["league"] = data["reports"]["league"];
|
||||
const auto &focus = data.at("camp").at("focus");
|
||||
if (!focus.is_array() || focus.size() != 3)
|
||||
throw editor::Error("invalid_focus");
|
||||
|
||||
@@ -0,0 +1,292 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
namespace {
|
||||
std::optional<std::array<int, 3>> report_detail_date(const Json &value) {
|
||||
if (!value.is_string())
|
||||
return {};
|
||||
const auto text = value.get<std::string>();
|
||||
if (text.size() != 10 || text[4] != '-' || text[7] != '-')
|
||||
return {};
|
||||
for (size_t i = 0; i < text.size(); ++i)
|
||||
if (i != 4 && i != 7 && (text[i] < '0' || text[i] > '9'))
|
||||
return {};
|
||||
const std::array<int, 3> date = {std::stoi(text.substr(0, 4)),
|
||||
std::stoi(text.substr(5, 2)),
|
||||
std::stoi(text.substr(8, 2))};
|
||||
if (!std::chrono::year_month_day{std::chrono::year{date[0]},
|
||||
std::chrono::month{unsigned(date[1])},
|
||||
std::chrono::day{unsigned(date[2])}}.ok())
|
||||
return {};
|
||||
return date;
|
||||
}
|
||||
std::string report_detail_position(const Json &player) {
|
||||
std::string result;
|
||||
const auto positions = player.find("positions");
|
||||
if (positions == player.end() || !positions->is_array())
|
||||
return "—";
|
||||
for (const auto &position : *positions) {
|
||||
if (!position.is_string())
|
||||
continue;
|
||||
const auto value = position.get<std::string>();
|
||||
if (value.empty())
|
||||
continue;
|
||||
if (!result.empty())
|
||||
result += " / ";
|
||||
result += value == "gk" ? "TW" : value == "def" ? "ABW"
|
||||
: value == "mid" ? "MIT"
|
||||
: value == "fwd" ? "STU" : value;
|
||||
}
|
||||
return result.empty() ? "—" : result;
|
||||
}
|
||||
std::string report_detail_strength(const Json &player) {
|
||||
const auto attributes = player.find("attributes");
|
||||
if (attributes == player.end() || !attributes->is_object())
|
||||
return "—";
|
||||
const auto value = attributes->find("strength");
|
||||
return value != attributes->end() && value->is_number_integer()
|
||||
? number(value->get<int64_t>()) : "—";
|
||||
}
|
||||
std::string report_detail_age(const Json &player, const Json &date,
|
||||
bool with_unit) {
|
||||
const auto current = report_detail_date(date);
|
||||
const auto born = report_detail_date(player.value("born", Json()));
|
||||
if (born && current && *born <= *current) {
|
||||
const int years = (*current)[0] - (*born)[0] -
|
||||
(std::pair{(*current)[1], (*current)[2]} <
|
||||
std::pair{(*born)[1], (*born)[2]});
|
||||
return std::to_string(years) + (with_unit ? " Jahre" : "");
|
||||
}
|
||||
const auto initial = player.find("age_at_start");
|
||||
if (initial != player.end() && initial->is_object() &&
|
||||
initial->contains("years") && (*initial)["years"].is_number_integer()) {
|
||||
const auto on = report_detail_date(initial->value("on", Json()));
|
||||
if (on && (*initial)["years"].get<int>() >= 0) {
|
||||
const auto iso = (*initial)["on"].get<std::string>();
|
||||
// An imported age has no birthday. Keep its known reference date visible.
|
||||
return std::to_string((*initial)["years"].get<int>()) +
|
||||
(with_unit ? " Jahre" : "") + " (" + iso.substr(8, 2) + "." +
|
||||
iso.substr(5, 2) + "." + iso.substr(0, 4) + ")";
|
||||
}
|
||||
}
|
||||
return "—";
|
||||
}
|
||||
std::string report_detail_term(const Catalog &world, const Json &player,
|
||||
const Json &date) {
|
||||
const auto current = report_detail_date(date);
|
||||
if (!current)
|
||||
return "—";
|
||||
for (const auto &contract : world.rows("contracts")) {
|
||||
if (contract.value("person", "") != player.value("id", "") ||
|
||||
contract.value("team", "") != player.value("team", ""))
|
||||
continue;
|
||||
const auto start = report_detail_date(contract.value("start", Json()));
|
||||
const auto end = report_detail_date(contract.value("end", Json()));
|
||||
if (!end || (start && *start > *current))
|
||||
continue;
|
||||
// Remaining complete calendar months; no Classic initializer is executed.
|
||||
int months = ((*end)[0] - (*current)[0]) * 12 + (*end)[1] - (*current)[1];
|
||||
if ((*end)[2] < (*current)[2])
|
||||
--months;
|
||||
return std::to_string(std::max(0, months)) + " Monate";
|
||||
}
|
||||
return "—";
|
||||
}
|
||||
std::string report_detail_fields(
|
||||
const std::vector<std::pair<std::string, std::string>> &fields,
|
||||
int spacing) {
|
||||
std::string result = "<dl class=\"report-detail-values\">";
|
||||
for (size_t i = 0; i < fields.size(); ++i)
|
||||
result += "<div class=\"report-detail-field\" style=\"top:" +
|
||||
std::to_string(i * spacing) + "dp;\"><dt>" +
|
||||
esc(fields[i].first) + "</dt><dd>" + esc(fields[i].second) +
|
||||
"</dd></div>";
|
||||
return result + "</dl>";
|
||||
}
|
||||
} // namespace
|
||||
|
||||
std::string App::render_report_detail() {
|
||||
if (report_detail_kind_.empty() || !world_)
|
||||
return {};
|
||||
const auto snapshot = snap();
|
||||
const auto current_date = snapshot.state.value("date", Json());
|
||||
const auto *club = world_->find("clubs", report_detail_club_);
|
||||
const auto *player = world_->find("players", report_detail_player_);
|
||||
const auto display_name = [&](const Json *row) {
|
||||
if (!row)
|
||||
return std::string("—");
|
||||
const auto name = world_->name(*row);
|
||||
return name.empty() ? std::string("—") : name;
|
||||
};
|
||||
const auto close = [&](const std::string &caption) {
|
||||
return btn("report-detail-close", esc(caption), "report-detail-action",
|
||||
"id=\"report-detail-close\"");
|
||||
};
|
||||
std::string title, body, actions;
|
||||
if (report_detail_kind_ == "club" && club) {
|
||||
title = display_name(club);
|
||||
const Json *stadium = nullptr;
|
||||
if (const auto id = club->find("stadium");
|
||||
id != club->end() && id->is_string())
|
||||
stadium = world_->find("stadiums", id->get<std::string>());
|
||||
if (!stadium)
|
||||
for (const auto &candidate : world_->rows("stadiums"))
|
||||
if (candidate.value("owner", Json()) == report_detail_club_) {
|
||||
stadium = &candidate;
|
||||
break;
|
||||
}
|
||||
std::string capacity = "—", strength = "—", manager_name = "—";
|
||||
if (stadium) {
|
||||
const auto value = stadium->value("capacity", Json());
|
||||
if (value.is_number_integer())
|
||||
capacity = number(value.get<int64_t>());
|
||||
else if (value.is_object() && !value.empty()) {
|
||||
int64_t total = 0;
|
||||
bool valid = true;
|
||||
for (const auto &[area, seats] : value.items()) {
|
||||
if (!seats.is_number_integer() || seats.get<int64_t>() < 0) {
|
||||
valid = false;
|
||||
break;
|
||||
}
|
||||
total += seats.get<int64_t>();
|
||||
}
|
||||
if (valid)
|
||||
capacity = number(total);
|
||||
}
|
||||
}
|
||||
if (const auto value = club->find("strength");
|
||||
value != club->end() && value->is_number_integer())
|
||||
strength = number(value->get<int64_t>());
|
||||
else {
|
||||
int64_t sum = 0, count = 0;
|
||||
for (const auto *member : world_->squad(report_detail_club_)) {
|
||||
const auto attributes = member->value("attributes", Json::object());
|
||||
if (attributes.is_object() && attributes.contains("strength") &&
|
||||
attributes["strength"].is_number_integer()) {
|
||||
sum += attributes["strength"].get<int64_t>();
|
||||
++count;
|
||||
}
|
||||
}
|
||||
if (count)
|
||||
strength = number(sum / count);
|
||||
}
|
||||
for (const auto &candidate : world_->rows("staff"))
|
||||
if (candidate.value("role", "") == "manager" &&
|
||||
candidate.value("team", "") == report_detail_club_)
|
||||
manager_name = display_name(&candidate);
|
||||
for (const auto &candidate : snapshot.state.at("managers"))
|
||||
if (candidate.value("club", "") == report_detail_club_)
|
||||
manager_name = candidate.value("name", std::string("—"));
|
||||
if (manager_name.empty())
|
||||
manager_name = "—";
|
||||
body = "<div class=\"report-detail-badge\">" + crest(club, 192) +
|
||||
"</div><p class=\"report-detail-note\">Vereinsprofil</p>" +
|
||||
report_detail_fields({{"Stadion", display_name(stadium)},
|
||||
{"Plätze", capacity}, {"Stärke", strength},
|
||||
{"Manager", manager_name}}, 72);
|
||||
actions = btn("report-club-roster", "Spieler", "report-detail-action",
|
||||
"id=\"report-detail-roster\"") + close("Zurück");
|
||||
} else if (report_detail_kind_ == "roster" && club) {
|
||||
title = display_name(club) + " · Kader";
|
||||
body = "<div class=\"report-detail-roster-scroll\" id=\"report-detail-roster-scroll\">"
|
||||
"<div class=\"report-detail-table\"><div class=\"report-detail-row report-detail-table-head\">";
|
||||
for (const auto &heading : {"Spieler", "Pos.", "Stärke", "Alter"})
|
||||
body += "<div class=\"report-detail-cell\">" + std::string(heading) + "</div>";
|
||||
body += "</div>";
|
||||
const auto squad = world_->squad(report_detail_club_);
|
||||
for (size_t i = 0; i < squad.size(); ++i) {
|
||||
const auto *member = squad[i];
|
||||
body += "<div class=\"report-detail-row " +
|
||||
std::string(i % 2 == 0 ? "report-detail-striped" : "") +
|
||||
"\"><div class=\"report-detail-cell\">" +
|
||||
btn("player-detail", esc(display_name(member)),
|
||||
"report-detail-player-link",
|
||||
"id=\"report-detail-player-" + std::to_string(i) +
|
||||
"\" data-id=\"" + esc(member->value("id", "")) + "\"") +
|
||||
"</div><div class=\"report-detail-cell\">" +
|
||||
esc(report_detail_position(*member)) +
|
||||
"</div><div class=\"report-detail-cell\">" +
|
||||
esc(report_detail_strength(*member)) +
|
||||
"</div><div class=\"report-detail-cell\">" +
|
||||
esc(report_detail_age(*member, current_date, false)) + "</div></div>";
|
||||
}
|
||||
body += "</div>";
|
||||
if (squad.empty())
|
||||
body += "<p class=\"report-detail-empty\">Keine Spieler vorhanden.</p>";
|
||||
body += "</div>";
|
||||
actions = close("Zurück");
|
||||
} else if (report_detail_kind_ == "player" && player) {
|
||||
title = display_name(player);
|
||||
std::string photo = player->value("photo", "");
|
||||
if (photo.empty()) {
|
||||
const auto id = player->value("id", "");
|
||||
// Catalog resolves the world's silhouette fallback for an absent photo key.
|
||||
photo = "asset:player/" + (id.starts_with("player:") ? id.substr(7) : id) +
|
||||
"/photo";
|
||||
}
|
||||
body = "<div class=\"report-detail-portrait\">" +
|
||||
img(photo, 496, 662.667, true, true, 1024) +
|
||||
"</div><p class=\"report-detail-photo-caption\">Porträt</p>" +
|
||||
report_detail_fields({{"Position", report_detail_position(*player)},
|
||||
{"Alter", report_detail_age(*player, current_date, true)},
|
||||
{"Stärke", report_detail_strength(*player)},
|
||||
{"Verein", display_name(club)},
|
||||
{"Vertrag", report_detail_term(*world_, *player, current_date)}}, 73);
|
||||
actions = close("Schließen");
|
||||
} else
|
||||
return {};
|
||||
return "<div id=\"report-detail-layer\" class=\"report-detail-layer\">"
|
||||
"<section id=\"report-detail-dialog\" class=\"report-detail-card report-detail-" +
|
||||
esc(report_detail_kind_) +
|
||||
"\" role=\"dialog\" aria-modal=\"true\" aria-labelledby=\"report-detail-title\">"
|
||||
"<h2 id=\"report-detail-title\">" + esc(title) + "</h2>" + body +
|
||||
"<nav class=\"report-detail-actions\">" + actions + "</nav></section></div>";
|
||||
}
|
||||
|
||||
bool App::report_detail_action(const std::string &action, Rml::Element *target) {
|
||||
if (action == "report-detail-close") {
|
||||
if (report_detail_kind_.empty())
|
||||
return false;
|
||||
const auto restore = report_detail_return_focus_;
|
||||
report_detail_kind_.clear();
|
||||
report_detail_club_.clear();
|
||||
report_detail_player_.clear();
|
||||
report_detail_return_focus_.clear();
|
||||
focus_after_render_ = restore;
|
||||
refresh();
|
||||
return true;
|
||||
}
|
||||
if (action != "club-detail" && action != "player-detail" &&
|
||||
action != "report-club-roster")
|
||||
return false;
|
||||
if (!world_ || !target)
|
||||
return true;
|
||||
const auto id = target->GetAttribute<Rml::String>("data-id", "");
|
||||
if (action == "club-detail") {
|
||||
if (!world_->find("clubs", id))
|
||||
return true;
|
||||
if (report_detail_kind_.empty())
|
||||
report_detail_return_focus_ = target->GetId();
|
||||
report_detail_kind_ = "club";
|
||||
report_detail_club_ = id;
|
||||
report_detail_player_.clear();
|
||||
focus_after_render_ = "report-detail-roster";
|
||||
} else if (action == "report-club-roster") {
|
||||
if (!world_->find("clubs", report_detail_club_))
|
||||
return true;
|
||||
report_detail_kind_ = "roster";
|
||||
report_detail_player_.clear();
|
||||
focus_after_render_ = world_->squad(report_detail_club_).empty()
|
||||
? "report-detail-close" : "report-detail-player-0";
|
||||
} else {
|
||||
const auto *player = world_->find("players", id);
|
||||
if (!player)
|
||||
return true;
|
||||
if (report_detail_kind_.empty())
|
||||
report_detail_return_focus_ = target->GetId();
|
||||
report_detail_kind_ = "player";
|
||||
report_detail_player_ = id;
|
||||
report_detail_club_ = player->value("team", "");
|
||||
focus_after_render_ = "report-detail-close";
|
||||
}
|
||||
refresh();
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,275 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
namespace {
|
||||
bool report_picker_menu(const std::string &menu) {
|
||||
return menu == "tables" || menu == "strengths" || menu == "league" ||
|
||||
menu == "other";
|
||||
}
|
||||
bool report_picker_kind(const std::string &kind) {
|
||||
return kind == "country" || kind == "league" || kind == "filter" ||
|
||||
kind == "competition";
|
||||
}
|
||||
} // namespace
|
||||
|
||||
std::vector<std::pair<std::string, std::string>>
|
||||
App::report_picker_items(const std::string &kind) const {
|
||||
std::vector<std::pair<std::string, std::string>> items;
|
||||
if (!world_ || !report_picker_kind(kind))
|
||||
return items;
|
||||
if (kind == "filter" || kind == "competition") {
|
||||
const std::vector<std::string> captions =
|
||||
kind == "filter"
|
||||
? std::vector<std::string>{"Alle Spiele", "Hinrunde", "Rückrunde",
|
||||
"Heim", "Auswärts"}
|
||||
: std::vector<std::string>{"Meisterschaft", "Champ. League", "EM",
|
||||
"DFB-Pokal", "Pokalsieger", "Hallenmasters",
|
||||
"UEFA-Cup", "WM", "Super-Cup"};
|
||||
for (size_t i = 0; i < captions.size(); ++i)
|
||||
items.emplace_back(std::to_string(i), captions[i]);
|
||||
return items;
|
||||
}
|
||||
if (kind == "country") {
|
||||
std::set<std::string> seen;
|
||||
for (const auto *league : world_->leagues()) {
|
||||
const auto nation = league->value("nation", "");
|
||||
if (!nation.empty() && seen.insert(nation).second)
|
||||
items.emplace_back(nation, world_->nation_name(nation));
|
||||
}
|
||||
const std::array<std::string, 5> gold_order = {
|
||||
"Deutschland", "Spanien", "Italien", "Frankreich", "England"};
|
||||
const auto rank = [&](const std::string &caption) {
|
||||
return std::find(gold_order.begin(), gold_order.end(), caption) -
|
||||
gold_order.begin();
|
||||
};
|
||||
std::stable_sort(items.begin(), items.end(), [&](const auto &a, const auto &b) {
|
||||
const auto first = rank(a.second), second = rank(b.second);
|
||||
return first != second ? first < second : a.second < b.second;
|
||||
});
|
||||
return items;
|
||||
}
|
||||
const auto reports = snap().state.at("reports");
|
||||
const auto *league = world_->find("competitions", reports.at("league").get<std::string>());
|
||||
if (league)
|
||||
for (const auto *candidate : world_->leagues(league->value("nation", "")))
|
||||
items.emplace_back(candidate->value("id", ""), world_->name(*candidate));
|
||||
return items;
|
||||
}
|
||||
|
||||
std::string App::report_picker_value(const std::string &kind) const {
|
||||
if (!world_ || !report_picker_kind(kind))
|
||||
return {};
|
||||
const auto reports = snap().state.at("reports");
|
||||
if (kind == "filter" || kind == "competition")
|
||||
return std::to_string(reports.at(kind).get<int>());
|
||||
const auto league = reports.at("league").get<std::string>();
|
||||
if (kind == "league")
|
||||
return league;
|
||||
const auto *row = world_->find("competitions", league);
|
||||
return row ? row->value("nation", "") : "";
|
||||
}
|
||||
|
||||
std::string App::report_picker(const std::string &kind, double left,
|
||||
double width) {
|
||||
if (!report_picker_menu(menu_) || !report_picker_kind(kind))
|
||||
return {};
|
||||
const auto items = report_picker_items(kind);
|
||||
const auto selected = report_picker_value(kind);
|
||||
std::string caption = "—";
|
||||
for (const auto &[value, label] : items)
|
||||
if (value == selected)
|
||||
caption = label;
|
||||
const bool open = report_picker_ == kind;
|
||||
const std::string menu_label = kind == "country" ? "Land"
|
||||
: kind == "league" ? "Liga"
|
||||
: kind == "filter" ? "Spiele" : "Wettbewerb";
|
||||
std::string out =
|
||||
"<div class=\"report-picker-wrapper\" data-report-picker=\"" + kind +
|
||||
"\" style=\"left:" + scalar(left) + "dp;width:" + scalar(width) + "dp;\">" +
|
||||
btn("report-picker", "<span class=\"report-picker-label\">" + esc(caption) +
|
||||
"</span><span class=\"report-picker-arrow\" aria-hidden=\"true\">"
|
||||
"<span></span></span>",
|
||||
"report-picker-trigger",
|
||||
"id=\"report-picker-" + kind + "\" data-kind=\"" + kind +
|
||||
"\" aria-haspopup=\"menu\" aria-expanded=\"" +
|
||||
(open ? "true" : "false") +
|
||||
"\" aria-controls=\"report-picker-options-" + kind + "\" " +
|
||||
(items.empty() ? "disabled" : "")) +
|
||||
"<div class=\"report-picker-popup\" id=\"report-picker-options-" + kind +
|
||||
"\" role=\"menu\" aria-label=\"" + menu_label + "\" style=\"display:" +
|
||||
(open ? "block" : "none") + ";\">";
|
||||
for (size_t i = 0; i < items.size(); ++i) {
|
||||
const bool checked = items[i].first == selected;
|
||||
const auto marker =
|
||||
"<span class=\"report-picker-check-slot\" aria-hidden=\"true\">" +
|
||||
std::string(checked ? "<span class=\"report-picker-check\"></span>" : "") +
|
||||
"</span>";
|
||||
out += btn("report-choice", marker + "<span class=\"report-picker-option-label\">" +
|
||||
esc(items[i].second) + "</span>",
|
||||
"report-picker-option",
|
||||
"id=\"report-option-" + kind + "-" + std::to_string(i) +
|
||||
"\" data-kind=\"" + kind + "\" data-value=\"" +
|
||||
esc(items[i].first) + "\" data-index=\"" + std::to_string(i) +
|
||||
"\" role=\"menuitemradio\" aria-checked=\"" +
|
||||
(checked ? "true" : "false") + "\" style=\"tab-index:none;\"");
|
||||
}
|
||||
return out + "</div></div>";
|
||||
}
|
||||
|
||||
void App::close_report_picker(bool focus) {
|
||||
if (report_picker_.empty())
|
||||
return;
|
||||
const auto kind = report_picker_;
|
||||
report_picker_.clear();
|
||||
if (auto *panel = element("report-picker-options-" + kind))
|
||||
panel->SetProperty("display", "none");
|
||||
auto *trigger = element("report-picker-" + kind);
|
||||
if (trigger)
|
||||
trigger->SetAttribute("aria-expanded", "false");
|
||||
// Commit visibility before the parent Tab trap examines ancestor visibility.
|
||||
// No node is replaced, so an outside mouse event retains its original target.
|
||||
context_->Update();
|
||||
if (focus && trigger)
|
||||
trigger->Focus(keyboard_navigation_);
|
||||
dirty_ = true;
|
||||
}
|
||||
|
||||
bool App::report_picker_action(const std::string &action, Rml::Element *target) {
|
||||
if (action != "report-picker" && action != "report-choice")
|
||||
return false;
|
||||
if (!report_picker_menu(menu_) || !target)
|
||||
return true;
|
||||
const auto kind = target->GetAttribute<Rml::String>("data-kind", "");
|
||||
if (!report_picker_kind(kind))
|
||||
return true;
|
||||
const auto items = report_picker_items(kind);
|
||||
if (items.empty())
|
||||
return true;
|
||||
if (action == "report-picker") {
|
||||
if (report_picker_ == kind) {
|
||||
close_report_picker(true);
|
||||
return true;
|
||||
}
|
||||
close_report_picker(false);
|
||||
report_picker_ = kind;
|
||||
const auto selected = report_picker_value(kind);
|
||||
const auto found = std::find_if(items.begin(), items.end(), [&](const auto &item) {
|
||||
return item.first == selected;
|
||||
});
|
||||
const auto index = found == items.end() ? 0 : found - items.begin();
|
||||
focus_after_render_ = "report-option-" + kind + "-" + std::to_string(index);
|
||||
refresh();
|
||||
return true;
|
||||
}
|
||||
if (report_picker_ != kind)
|
||||
return true;
|
||||
const auto value = target->GetAttribute<Rml::String>("data-value", "");
|
||||
if (std::none_of(items.begin(), items.end(), [&](const auto &item) {
|
||||
return item.first == value;
|
||||
}))
|
||||
return true;
|
||||
const Json selection = kind == "filter" || kind == "competition"
|
||||
? Json(std::stoi(value)) : Json(value);
|
||||
close_report_picker(false);
|
||||
// Commit even an unchanged country: the Gold resets its first league.
|
||||
apply("reports", {{"kind", kind}, {"value", selection}});
|
||||
focus_after_render_ = "report-picker-" + kind;
|
||||
refresh();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool App::report_picker_event(Rml::Event &event) {
|
||||
if (!report_picker_menu(menu_))
|
||||
return false;
|
||||
const auto type = event.GetType();
|
||||
const auto ancestor = [&](const std::string &attribute) -> Rml::Element * {
|
||||
for (auto *node = event.GetTargetElement(); node && node != doc_;
|
||||
node = node->GetParentNode())
|
||||
if (node->HasAttribute(attribute))
|
||||
return node;
|
||||
return nullptr;
|
||||
};
|
||||
if (!report_picker_.empty()) {
|
||||
// Defer the right-button dismissal to mouseup so the same gesture cannot
|
||||
// also fall through to the menu's right-button close handler.
|
||||
if ((type == "mousedown" || type == "mouseup") &&
|
||||
event.GetParameter<int>("button", 0) == 1) {
|
||||
if (type == "mouseup")
|
||||
close_report_picker(true);
|
||||
event.StopImmediatePropagation();
|
||||
return true;
|
||||
}
|
||||
if (type == "contextmenu") {
|
||||
close_report_picker(true);
|
||||
event.StopImmediatePropagation();
|
||||
return true;
|
||||
}
|
||||
if (type == "mousedown") {
|
||||
auto *wrapper = ancestor("data-report-picker");
|
||||
if (!wrapper || wrapper->GetAttribute<Rml::String>("data-report-picker", "") !=
|
||||
report_picker_)
|
||||
close_report_picker(false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (type != "keydown")
|
||||
return false;
|
||||
const auto key = Rml::Input::KeyIdentifier(
|
||||
event.GetParameter<int>("key_identifier", 0));
|
||||
if (!report_picker_.empty()) {
|
||||
if (key == Rml::Input::KI_ESCAPE) {
|
||||
keyboard_navigation_ = true;
|
||||
close_report_picker(true);
|
||||
event.StopImmediatePropagation();
|
||||
return true;
|
||||
}
|
||||
if (key == Rml::Input::KI_TAB) {
|
||||
keyboard_navigation_ = true;
|
||||
close_report_picker(true);
|
||||
return false;
|
||||
}
|
||||
if (key == Rml::Input::KI_UP || key == Rml::Input::KI_DOWN ||
|
||||
key == Rml::Input::KI_HOME || key == Rml::Input::KI_END) {
|
||||
const auto items = report_picker_items(report_picker_);
|
||||
if (items.empty())
|
||||
return false;
|
||||
int current = -1;
|
||||
for (auto *node = context_->GetFocusElement(); node && node != doc_;
|
||||
node = node->GetParentNode())
|
||||
if (node->HasAttribute("data-index") &&
|
||||
node->GetAttribute<Rml::String>("data-kind", "") == report_picker_) {
|
||||
current = node->GetAttribute<int>("data-index", -1);
|
||||
break;
|
||||
}
|
||||
const int count = int(items.size());
|
||||
const int next = key == Rml::Input::KI_HOME ? 0
|
||||
: key == Rml::Input::KI_END ? count - 1
|
||||
: (current + (key == Rml::Input::KI_UP ? -1 : 1) + count) % count;
|
||||
if (auto *node = element("report-option-" + report_picker_ + "-" +
|
||||
std::to_string(next))) {
|
||||
keyboard_navigation_ = true;
|
||||
node->Focus(true);
|
||||
node->ScrollIntoView({Rml::ScrollAlignment::Nearest});
|
||||
dirty_ = true;
|
||||
}
|
||||
event.StopImmediatePropagation();
|
||||
return true;
|
||||
}
|
||||
// Enter/Space use the shared native button click handler, without a draft mutation.
|
||||
return false;
|
||||
}
|
||||
auto *trigger = ancestor("data-kind");
|
||||
if (!trigger || trigger->GetAttribute<Rml::String>("data-action", "") !=
|
||||
"report-picker" ||
|
||||
(key != Rml::Input::KI_UP && key != Rml::Input::KI_DOWN))
|
||||
return false;
|
||||
const auto kind = trigger->GetAttribute<Rml::String>("data-kind", "");
|
||||
keyboard_navigation_ = true;
|
||||
report_picker_action("report-picker", trigger);
|
||||
if (key == Rml::Input::KI_UP && report_picker_ == kind) {
|
||||
const auto items = report_picker_items(kind);
|
||||
if (!items.empty())
|
||||
focus_after_render_ = "report-option-" + kind + "-" +
|
||||
std::to_string(items.size() - 1);
|
||||
}
|
||||
event.StopImmediatePropagation();
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
namespace {
|
||||
std::string report_number(const Json &value) {
|
||||
return value.is_number_integer() ? number(value.get<int64_t>()) : "—";
|
||||
}
|
||||
std::string report_zone(int rank, int count, int tier) {
|
||||
if (rank > count - 3)
|
||||
return "relegation";
|
||||
if (tier == 1) {
|
||||
if (rank <= 4) return "champions";
|
||||
if (rank == 5) return "europa";
|
||||
if (rank == 6) return "conference";
|
||||
} else {
|
||||
if (rank <= (tier == 4 ? 1 : 2)) return "promotion";
|
||||
if (tier != 4 && rank == 3) return "playoff";
|
||||
}
|
||||
return {};
|
||||
}
|
||||
} // namespace
|
||||
|
||||
std::string App::report_club_button(const std::string &id, bool away) {
|
||||
const auto *c = world_->find("clubs", id);
|
||||
if (!c)
|
||||
return "<span>—</span>";
|
||||
const auto name = esc(world_->name(*c));
|
||||
const auto text = "<span class=\"report-club-name\" title=\"" + name +
|
||||
"\">" + name + "</span>";
|
||||
return btn("club-detail", away ? text + crest(c, 42) : crest(c, 42) + text,
|
||||
std::string("report-club-button ") + (away ? "away " : "") +
|
||||
(manager(snap()).value("club", "") == id ? "current" : ""),
|
||||
"id=\"report-club-" + esc(id) + "\" data-id=\"" + esc(id) + "\"");
|
||||
}
|
||||
|
||||
std::string App::render_reports(const std::string &mode) {
|
||||
const auto snapshot = snap();
|
||||
const auto &state = snapshot.state.at("reports");
|
||||
const auto *league = world_->find("competitions", state.value("league", ""));
|
||||
const int tier = league ? league->value("tier", 1) : 1;
|
||||
const bool strengths = mode == "strengths", matches = mode == "league" || mode == "other";
|
||||
const bool opening = mode == "other" && state.value("competition", 0) == 3 &&
|
||||
snapshot.state.value("opening_created", false);
|
||||
const auto rows = matches ? (opening ? report_opening_pairs(*world_)
|
||||
: report_match_rows(*world_, state, mode == "other"))
|
||||
: strengths ? report_strength_rows(*world_, state)
|
||||
: report_table_rows(*world_, state);
|
||||
const std::vector<std::pair<std::string, std::string>> headings =
|
||||
matches ? std::vector<std::pair<std::string, std::string>>{
|
||||
{"", "Heim"}, {"", "Ergebnis"}, {"", "Auswärts"}}
|
||||
: strengths ? std::vector<std::pair<std::string, std::string>>{
|
||||
{"club", "Verein"}, {"keeper", "TW"}, {"defence", "Abwehr"},
|
||||
{"midfield", "Mittelfeld"}, {"attack", "Sturm"}, {"strength", "Stärke"}}
|
||||
: std::vector<std::pair<std::string, std::string>>{
|
||||
{"rank", "Pl. / Verein"}, {"played", "Sp."}, {"wins", "S"},
|
||||
{"draw", "U"}, {"loss", "N"}, {"form", "Letzte 8"},
|
||||
{"points", "Punkte"}, {"gf", "Tore"}, {"diff", "Diff."}};
|
||||
std::vector<double> widths;
|
||||
if (matches)
|
||||
widths = {1104, 400, 1104}; // Match card has two 2dp borders.
|
||||
else if (strengths) {
|
||||
widths.push_back(2612 * .38);
|
||||
for (int i = 0; i < 5; ++i) widths.push_back(2612 * .62 / 5);
|
||||
} else {
|
||||
for (int i = 0; i < 9; ++i)
|
||||
widths.push_back(i == 0 ? 2612 * .32 : i == 5 ? 2612 * .14 : 2612 * .54 / 7);
|
||||
}
|
||||
const double heading_height = matches ? 80 : strengths ? (rows.size() >= 20 ? 64 : 66)
|
||||
: rows.size() >= 20 ? 64 : 80;
|
||||
const double row_height = matches ? 118 : strengths ? (rows.size() >= 20 ? 64 : 66)
|
||||
: rows.size() >= 20 ? (1682 - heading_height) / rows.size() : 80;
|
||||
std::string body = "<div id=\"report-underlay\" class=\"report-underlay\">";
|
||||
if (matches) {
|
||||
const int round = std::clamp(state.value("round", 0), 0,
|
||||
report_round_count(*world_, state, mode == "other") - 1);
|
||||
std::string subtitle;
|
||||
if (mode == "league" || state.value("competition", 0) == 0)
|
||||
subtitle = (league ? world_->nation_name(league->value("nation", "")) : "") +
|
||||
" · " + (league ? world_->name(*league) : "");
|
||||
else {
|
||||
const auto choices = report_picker_items("competition");
|
||||
subtitle = choices.at(size_t(state.value("competition", 0))).second;
|
||||
}
|
||||
body += "<header class=\"report-match-heading\"><h2>" +
|
||||
(opening ? std::string("1. Runde") : std::to_string(round + 1) + ". Spieltag") +
|
||||
"</h2><p>" + esc(subtitle) + "</p></header>";
|
||||
}
|
||||
body += "<div id=\"report-list\" class=\"report-list " +
|
||||
std::string(matches ? "match-list" : strengths ? "strength-list" : "standings-list") +
|
||||
"\"><div class=\"report-table\" role=\"table\"><div class=\"report-row report-head\" "
|
||||
"role=\"row\" style=\"height:" + scalar(heading_height) + "dp;\">";
|
||||
for (size_t column = 0; column < headings.size(); ++column) {
|
||||
const auto &[key, label] = headings[column];
|
||||
const auto sorting = matches ? Json::object() : state.at("sorts").at(mode);
|
||||
const bool current = !matches && sorting.value("key", "") == key;
|
||||
const bool descending = sorting.value("desc", false);
|
||||
body += "<div class=\"report-cell " + std::string(column == 0 ? "first" : "") +
|
||||
(matches && column == 1 ? " score" : "") + "\" role=\"columnheader\" "
|
||||
"aria-sort=\"" + (current ? descending ? "descending" : "ascending" : "none") +
|
||||
"\" style=\"width:" + scalar(widths[column]) + "dp;\">";
|
||||
if (matches)
|
||||
body += "<span class=\"report-value\">" + esc(label) + "</span>";
|
||||
else {
|
||||
std::string indicator = "<span class=\"report-sort-symbol\">";
|
||||
if (!current || !descending)
|
||||
indicator += "<span class=\"report-sort-arrow up\"></span>";
|
||||
if (!current || descending)
|
||||
indicator += "<span class=\"report-sort-arrow down\"></span>";
|
||||
indicator += "</span>";
|
||||
body += btn("report-sort", "<span>" + esc(label) + "</span>" + indicator,
|
||||
"report-sort", "id=\"report-sort-" + key + "\" data-id=\"" + key +
|
||||
"\" aria-label=\"Nach " + esc(label) + " sortieren\"");
|
||||
}
|
||||
body += "</div>";
|
||||
}
|
||||
body += "</div>";
|
||||
for (size_t i = 0; i < rows.size(); ++i) {
|
||||
const auto &row = rows[i];
|
||||
body += "<div class=\"report-row " + std::string(i % 2 == 0 ? "striped" : "") +
|
||||
"\" role=\"row\" data-club=\"" + esc(row.value("club", "")) +
|
||||
"\" style=\"height:" + scalar(row_height) + "dp;\">";
|
||||
for (size_t column = 0; column < headings.size(); ++column) {
|
||||
body += "<div class=\"report-cell " + std::string(column == 0 ? "first" : "") +
|
||||
(matches && column == 1 ? " score" : "") +
|
||||
(!matches && !strengths && column == 5 ? " form" : "") +
|
||||
"\" role=\"cell\" style=\"width:" + scalar(widths[column]) + "dp;\">";
|
||||
if (matches && column != 1)
|
||||
body += report_club_button(row.at(column == 0 ? "home" : "away").get<std::string>(), column == 2);
|
||||
else if (!matches && column == 0) {
|
||||
if (!strengths) {
|
||||
const auto zone = report_zone(row.value("rank", 0), int(rows.size()), tier);
|
||||
body += "<span class=\"report-zone " + zone + "\"></span><span class=\"report-rank\"><span>" +
|
||||
std::to_string(row.value("rank", 0)) + ".</span></span>";
|
||||
}
|
||||
body += report_club_button(row.at("club").get<std::string>());
|
||||
} else {
|
||||
std::string value;
|
||||
if (matches)
|
||||
value = row.at("home_goals").is_null() || row.at("away_goals").is_null()
|
||||
? "–" : report_number(row["home_goals"]) + " : " + report_number(row["away_goals"]);
|
||||
else if (!strengths && column == 5)
|
||||
value = row.value("form_text", "");
|
||||
else if (!strengths && column == 7)
|
||||
value = report_number(row["gf"]) + ":" + report_number(row["ga"]);
|
||||
else
|
||||
value = report_number(row.at(headings[column].first));
|
||||
body += "<span class=\"report-value\">" + esc(value) + "</span>";
|
||||
}
|
||||
body += "</div>";
|
||||
}
|
||||
body += "</div>";
|
||||
}
|
||||
body += "</div></div>";
|
||||
if (!matches && !strengths) {
|
||||
const auto legend = tier == 1
|
||||
? std::vector<std::pair<std::string, std::string>>{
|
||||
{"champions", "Champions League"}, {"europa", "Europa League"},
|
||||
{"conference", "Conference League"}, {"relegation", "Abstieg"}}
|
||||
: tier == 4 ? std::vector<std::pair<std::string, std::string>>{
|
||||
{"promotion", "Aufstieg"}, {"relegation", "Abstieg"}}
|
||||
: std::vector<std::pair<std::string, std::string>>{
|
||||
{"promotion", "Aufstieg"}, {"playoff", "Relegation"}, {"relegation", "Abstieg"}};
|
||||
body += "<div class=\"report-legend\">";
|
||||
for (const auto &[kind, label] : legend)
|
||||
body += "<span class=\"report-legend-item\"><span class=\"report-zone " + kind +
|
||||
"\"></span><span>" + esc(label) + "</span></span>";
|
||||
body += "</div>";
|
||||
}
|
||||
body += "<nav class=\"report-footer\">";
|
||||
if (matches) {
|
||||
for (int i = 0; i < 2; ++i)
|
||||
body += btn("report-round", i ? "›" : "‹", "report-round",
|
||||
"id=\"report-round-" + std::string(i ? "next" : "previous") +
|
||||
"\" data-id=\"" + (i ? "1" : "-1") + "\" style=\"" +
|
||||
rect(i * 130, 0, 110, 94) + "\" " + (opening ? "disabled" : ""));
|
||||
body += mode == "league" ? report_picker("country", 260, 1060) + report_picker("league", 1340, 1272)
|
||||
: report_picker("competition", 260, 2352);
|
||||
} else if (strengths)
|
||||
body += report_picker("country", 0, 1294) + report_picker("league", 1318, 1294);
|
||||
else
|
||||
body += btn("report-reset", "Gesamt", "report-reset", "id=\"report-reset\" style=\"" +
|
||||
rect(0, 0, 635, 94) + "\"") +
|
||||
report_picker("filter", 659, 635) + report_picker("country", 1318, 635) +
|
||||
report_picker("league", 1977, 635);
|
||||
return body + "</nav></div>" + render_report_detail();
|
||||
}
|
||||
@@ -635,84 +635,6 @@ std::string App::render_opening() {
|
||||
return window(opening_page_ < 3 ? "Deutsche Teams" : "DFB-Pokal", body,
|
||||
false);
|
||||
}
|
||||
std::string App::render_table(bool strengths, bool indoor) {
|
||||
auto leagues = world_->leagues(country_);
|
||||
if (std::none_of(leagues.begin(), leagues.end(),
|
||||
[&](auto *r) { return r->value("id", "") == league_; }))
|
||||
league_ = leagues.empty() ? "" : leagues.front()->value("id", "");
|
||||
const auto clubs = world_->clubs(league_);
|
||||
std::string body = "<div class=\"list\" "
|
||||
"style=\"position:absolute;left:0;right:0;top:0;bottom:"
|
||||
"160dp;\"><div class=\"table\"><div class=\"tr\"><div "
|
||||
"class=\"th\" style=\"width:42%;\">" +
|
||||
btn("table-sort", "Pl. / Verein", {}, "data-id=\"rank\"") +
|
||||
"</div>";
|
||||
const std::vector<std::string> headers =
|
||||
strengths ? std::vector<std::string>{"Tor", "Abwehr", "Mittelfeld",
|
||||
"Sturm", "Gesamt"}
|
||||
: std::vector<std::string>{"Sp.", "S", "U", "N",
|
||||
"Punkte", "Tore", "Diff."};
|
||||
for (const auto &h : headers)
|
||||
body += "<div class=\"th center\">" +
|
||||
btn("table-sort", esc(h), {}, "data-id=\"" + esc(h) + "\"") +
|
||||
"</div>";
|
||||
body += "</div>";
|
||||
for (size_t i = 0; i < clubs.size(); ++i) {
|
||||
auto *c = clubs[i];
|
||||
body += "<div class=\"tr " + std::string(i % 2 ? "" : "odd") +
|
||||
"\"><div class=\"td\">" +
|
||||
btn("club-detail",
|
||||
"<span class=\"club-label\"><span class=\"rank\">" +
|
||||
std::to_string(i + 1) + ".</span>" + crest(c, 40) +
|
||||
"<span>" + esc(world_->name(*c)) + "</span></span>",
|
||||
{}, "data-id=\"" + esc(c->value("id", "")) + "\"") +
|
||||
"</div>";
|
||||
if (strengths) {
|
||||
const auto players = world_->squad(c->value("id", ""));
|
||||
for (const auto &position : {"gk", "def", "mid", "fwd", "all"}) {
|
||||
int sum = 0, n = 0;
|
||||
for (auto *p : players) {
|
||||
const auto positions = p->value("positions", Json::array());
|
||||
if (std::string(position) == "all" ||
|
||||
std::find(positions.begin(), positions.end(), position) !=
|
||||
positions.end()) {
|
||||
sum += p->value("attributes", Json::object()).value("strength", 0);
|
||||
++n;
|
||||
}
|
||||
}
|
||||
body += "<div class=\"td center\">" +
|
||||
(n ? std::to_string(sum / n) : "–") + "</div>";
|
||||
}
|
||||
} else
|
||||
for (int n = 0; n < 7; ++n)
|
||||
body += "<div class=\"td center\">" +
|
||||
std::string(n == 5 ? "0:0" : "0") + "</div>";
|
||||
body += "</div>";
|
||||
}
|
||||
body += "</div></div><div class=\"bottom-controls\">";
|
||||
if (!strengths && !indoor)
|
||||
body += btn("table-overall", "Gesamt") + select("table-scope",
|
||||
{{"all", "Alle Spiele"},
|
||||
{"first", "Hinrunde"},
|
||||
{"second", "Rückrunde"},
|
||||
{"home", "Heim"},
|
||||
{"away", "Auswärts"}},
|
||||
selections_["table-scope"],
|
||||
"table-scope");
|
||||
std::vector<std::pair<std::string, std::string>> countries, league_rows;
|
||||
std::set<std::string> seen;
|
||||
for (auto *l : world_->leagues()) {
|
||||
const auto id = l->value("nation", "");
|
||||
if (seen.insert(id).second)
|
||||
countries.emplace_back(id, world_->nation_name(id));
|
||||
if (id == country_)
|
||||
league_rows.emplace_back(l->value("id", ""), world_->name(*l));
|
||||
}
|
||||
body += select("table-country", countries, country_, "table-country") +
|
||||
select("table-league", league_rows, league_, "table-league") +
|
||||
"</div>";
|
||||
return body;
|
||||
}
|
||||
std::string App::render_camp() {
|
||||
const auto index_file =
|
||||
Json::parse(editor::read_file(gui_.root() / "gui-assets.json"));
|
||||
@@ -961,8 +883,8 @@ std::string App::render_save(bool save) {
|
||||
}
|
||||
std::string App::render_menu(const std::string &key) {
|
||||
std::string body;
|
||||
if (key == "tables" || key == "strengths")
|
||||
body = render_table(key == "strengths", false);
|
||||
if (key == "tables" || key == "strengths" || key == "league" || key == "other")
|
||||
body = render_reports(key);
|
||||
else if (key == "training")
|
||||
body = render_training();
|
||||
else if (key == "tactics")
|
||||
|
||||
+45
-1
@@ -6,6 +6,7 @@
|
||||
#include "launch/rml_video.hpp"
|
||||
#include "modern/ui/controls.hpp"
|
||||
#include "modern/ui/demo_calendar.hpp"
|
||||
#include "modern/ui/demo_reports.hpp"
|
||||
#include "modern/ui/demo_sports.hpp"
|
||||
#include "modern/ui/desktop.hpp"
|
||||
#include "modern/ui/gui_assets.hpp"
|
||||
@@ -27,6 +28,7 @@
|
||||
#include <iomanip>
|
||||
#include <nfd.hpp>
|
||||
#include <optional>
|
||||
#include <RmlUi/Core/ScrollTypes.h>
|
||||
#include <sstream>
|
||||
|
||||
namespace bmh::modern_ui {
|
||||
@@ -304,6 +306,10 @@ class App final : public Rml::EventListener {
|
||||
bool keyboard_navigation_ = false;
|
||||
std::string last_rendered_menu_;
|
||||
std::optional<float> training_scroll_;
|
||||
std::optional<float> report_scroll_;
|
||||
std::string last_report_state_, report_picker_, report_detail_kind_,
|
||||
report_detail_club_, report_detail_player_, report_detail_return_focus_,
|
||||
report_option_to_scroll_;
|
||||
float device_ratio_ = 1.f;
|
||||
Json desktop_ = Json::object(), saved_desktop_ = Json::object(),
|
||||
options_ = Json::object();
|
||||
@@ -595,7 +601,17 @@ class App final : public Rml::EventListener {
|
||||
std::string render_desktop();
|
||||
void init_desktop();
|
||||
std::string widget(const std::string &, const Json &);
|
||||
std::string render_table(bool strengths = false, bool indoor = false);
|
||||
std::string render_reports(const std::string &);
|
||||
std::string report_club_button(const std::string &, bool away = false);
|
||||
std::string render_report_detail();
|
||||
bool report_detail_action(const std::string &, Rml::Element *);
|
||||
std::string report_picker(const std::string &, double, double);
|
||||
std::vector<std::pair<std::string, std::string>>
|
||||
report_picker_items(const std::string &) const;
|
||||
std::string report_picker_value(const std::string &) const;
|
||||
bool report_picker_event(Rml::Event &);
|
||||
bool report_picker_action(const std::string &, Rml::Element *);
|
||||
void close_report_picker(bool focus = false);
|
||||
std::string render_camp();
|
||||
std::string render_training();
|
||||
std::string render_tactics();
|
||||
@@ -663,6 +679,11 @@ class App final : public Rml::EventListener {
|
||||
if (menu_ == "training" && last_rendered_menu_ == "training")
|
||||
if (auto *roster = element("training-roster"))
|
||||
training_scroll_ = roster->GetScrollTop();
|
||||
report_scroll_.reset();
|
||||
const auto report_state = source_ ? snap().state.at("reports").dump() : "";
|
||||
if (menu_ == last_rendered_menu_ && report_state == last_report_state_)
|
||||
if (auto *list = element("report-list"))
|
||||
report_scroll_ = list->GetScrollTop();
|
||||
if (ticket_)
|
||||
ticket_->close(false);
|
||||
context_open_ = false;
|
||||
@@ -684,6 +705,13 @@ class App final : public Rml::EventListener {
|
||||
if (!menu_.empty())
|
||||
markup += render_menu(menu_);
|
||||
element("canvas")->SetInnerRML(markup);
|
||||
if (!report_detail_kind_.empty()) {
|
||||
Rml::ElementList behind;
|
||||
doc_->QuerySelectorAll(behind,
|
||||
"#report-underlay button,#report-underlay input,#report-underlay select,.window .titlebar button");
|
||||
for (auto *node : behind)
|
||||
node->SetProperty("pointer-events", "none");
|
||||
}
|
||||
const auto size = context_->GetDimensions();
|
||||
const auto background =
|
||||
img("background", size.x / scale_, size.y / scale_, false, true, 2048);
|
||||
@@ -697,6 +725,7 @@ class App final : public Rml::EventListener {
|
||||
: "saturate(0.34) brightness(0.70)");
|
||||
needs_render_ = false;
|
||||
last_rendered_menu_ = menu_;
|
||||
last_report_state_ = report_state;
|
||||
scale_chalk_shadow();
|
||||
dirty_ = true;
|
||||
if (focus_ticket_) {
|
||||
@@ -707,6 +736,8 @@ class App final : public Rml::EventListener {
|
||||
if (!focus_after_render_.empty()) {
|
||||
if (auto *node = element(focus_after_render_))
|
||||
node->Focus(keyboard_navigation_);
|
||||
if (focus_after_render_.starts_with("report-option-"))
|
||||
report_option_to_scroll_ = focus_after_render_;
|
||||
focus_after_render_.clear();
|
||||
}
|
||||
}
|
||||
@@ -756,6 +787,16 @@ class App final : public Rml::EventListener {
|
||||
roster->SetScrollTop(*training_scroll_);
|
||||
training_scroll_.reset();
|
||||
}
|
||||
if (report_scroll_) {
|
||||
if (auto *list = element("report-list"))
|
||||
list->SetScrollTop(*report_scroll_);
|
||||
report_scroll_.reset();
|
||||
}
|
||||
if (!report_option_to_scroll_.empty()) {
|
||||
if (auto *node = element(report_option_to_scroll_))
|
||||
node->ScrollIntoView(Rml::ScrollIntoViewOptions(Rml::ScrollAlignment::Nearest));
|
||||
report_option_to_scroll_.clear();
|
||||
}
|
||||
renderer_.Clear();
|
||||
renderer_.BeginFrame();
|
||||
context_->Render();
|
||||
@@ -995,6 +1036,9 @@ public:
|
||||
#include "modern/ui/screens.inc"
|
||||
#include "modern/ui/sports_screens.inc"
|
||||
#include "modern/ui/calendar_screen.inc"
|
||||
#include "modern/ui/report_pickers.inc"
|
||||
#include "modern/ui/report_details.inc"
|
||||
#include "modern/ui/reports_screens.inc"
|
||||
} // namespace
|
||||
bool is_modern_world(const fs::path &file) {
|
||||
try {
|
||||
|
||||
@@ -99,7 +99,8 @@ int main(int argc, char **argv) try {
|
||||
"Bold font missing");
|
||||
std::ostringstream css;
|
||||
for (const auto *name : {"theme.rcss", "ticket.rcss", "sports.rcss",
|
||||
"calendar.rcss"}) {
|
||||
"calendar.rcss", "reports.rcss", "report_details.rcss",
|
||||
"report_pickers.rcss"}) {
|
||||
std::ifstream input(root / name);
|
||||
require(bool(input), "Production stylesheet missing");
|
||||
css << input.rdbuf() << '\n';
|
||||
|
||||
@@ -0,0 +1,313 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "modern/ui/demo_reports.hpp"
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <stdexcept>
|
||||
|
||||
using namespace bmh::modern_ui;
|
||||
namespace {
|
||||
void require(bool ok, const char *message) {
|
||||
if (!ok) throw std::runtime_error(message);
|
||||
}
|
||||
void write(const fs::path &root, const std::string &name, const Json &value) {
|
||||
fs::create_directories((root / name).parent_path());
|
||||
bmh::editor::write_atomic(root / name, value.dump());
|
||||
}
|
||||
void table(const fs::path &root, const std::string &name, const Json &items) {
|
||||
write(root, "world/" + name + ".json", {{"items", items}});
|
||||
}
|
||||
std::string league(int i) { return "competition:synthetic-" + std::to_string(i); }
|
||||
std::string club(int group, int i) {
|
||||
return "club:synthetic-" + std::to_string(group) + "-" + std::to_string(i);
|
||||
}
|
||||
struct Fixture {
|
||||
fs::path root;
|
||||
std::shared_ptr<const Catalog> world;
|
||||
explicit Fixture(int home = 18, bool leagues = true) {
|
||||
root = fs::temp_directory_path() /
|
||||
("openbmh-reports-" + std::to_string(
|
||||
std::chrono::steady_clock::now().time_since_epoch().count()));
|
||||
write(root, "manifest.json", {{"format", "openbmh-world"}, {"kind", "world"},
|
||||
{"format_version", "1.1"}, {"id", "world:synthetic-reports"},
|
||||
{"requires", {"editor:world-v1"}},
|
||||
{"x-editor", {{"profile", "editor-world-v1"}}}});
|
||||
table(root, "nations", Json::array({
|
||||
{{"id", "nation:de"}, {"name", "Synthetic home"}},
|
||||
{{"id", "nation:synthetic-foreign"}, {"name", "Synthetic away"}},
|
||||
{{"id", "nation:synthetic-empty"}, {"name", "Empty nation"}}}));
|
||||
Json competitions = Json::array(), clubs = Json::array(), players = Json::array();
|
||||
const std::array<int, 4> counts{20, home, 4, 48};
|
||||
if (leagues) {
|
||||
for (int group = 0; group < 4; ++group)
|
||||
competitions.push_back({{"id", league(group)}, {"type", "league"},
|
||||
{"nation", group == 0 ? "nation:synthetic-foreign" : "nation:de"},
|
||||
{"name", "Synthetic league " + std::to_string(group)}});
|
||||
for (int i = 0; i < 48; ++i)
|
||||
for (int group = 0; group < 4; ++group)
|
||||
if (i < counts[size_t(group)]) {
|
||||
const auto name = group != 1 ? "Synthetic " + std::to_string(i)
|
||||
: i == 0 ? "Zulu 10" : i == 1 || i == 3 ? "alpha 2"
|
||||
: i == 2 ? "Älpha 10" : i == 4 ? "beta" : "Group " + std::to_string(i);
|
||||
clubs.push_back({{"id", club(group, i)}, {"name", name},
|
||||
{"competition", league(group)},
|
||||
{"nation", group == 0 ? "nation:synthetic-foreign" : "nation:de"}});
|
||||
}
|
||||
}
|
||||
competitions.push_back({{"id", "competition:synthetic-cup"}, {"type", "cup"}});
|
||||
int serial = 0;
|
||||
const auto player = [&](int index, const Json &positions, const Json &strength) {
|
||||
if (index >= home || !leagues) return;
|
||||
players.push_back({{"id", "player:synthetic-" + std::to_string(serial++)},
|
||||
{"team", club(1, index)}, {"squad_order", serial},
|
||||
{"positions", positions}, {"attributes", {{"strength", strength}}}});
|
||||
};
|
||||
player(0, {"gk"}, 80); player(0, {"gk"}, 60);
|
||||
player(0, {"def"}, 90); player(0, {"mid"}, 70); player(0, {"fwd"}, 50);
|
||||
player(1, {"def"}, 88); player(1, {"gk"}, "not-a-rating");
|
||||
player(3, {"def", "mid"}, 40);
|
||||
player(4, {"gk"}, 101); player(5, {"gk"}, 99);
|
||||
player(6, {"gk"}, 70); player(7, {"gk"}, 0);
|
||||
table(root, "competitions", competitions); table(root, "clubs", clubs);
|
||||
table(root, "players", players); world = Catalog::open(root);
|
||||
}
|
||||
~Fixture() { std::error_code ec; fs::remove_all(root, ec); }
|
||||
};
|
||||
void edit(Json &state, const Json &action, const Catalog &world) {
|
||||
const auto error = edit_demo_reports(state, action, world);
|
||||
if (!error.empty()) throw std::runtime_error("Unexpected rejection: " + error);
|
||||
require(valid_demo_reports(state, world), "Accepted action produced invalid state");
|
||||
}
|
||||
std::map<std::string, Json> by_club(const Json &rows) {
|
||||
std::map<std::string, Json> result;
|
||||
for (const auto &r : rows) result.emplace(r.at("club").get<std::string>(), r);
|
||||
return result;
|
||||
}
|
||||
void check_league(const Catalog &world, const std::string &id, int count) {
|
||||
auto state = demo_reports(world); edit(state, {{"kind", "league"}, {"value", id}}, world);
|
||||
const int rounds = report_round_count(world, state);
|
||||
require(rounds == (count - 1) * 2, "League round count is not dynamic");
|
||||
std::set<std::pair<std::string, std::string>> ordered_pairs;
|
||||
std::vector<Json> round_rows;
|
||||
std::map<std::string, int> scored, conceded;
|
||||
for (int r = 0; r < rounds; ++r) {
|
||||
state["round"] = r;
|
||||
const auto matches = report_match_rows(world, state, false);
|
||||
require(matches.size() == size_t(count / 2), "Wrong number of matches per round");
|
||||
require(matches == report_match_rows(world, state, true), "Competition zero differs from league");
|
||||
std::set<std::string> teams;
|
||||
for (const auto &m : matches) {
|
||||
const auto home = m.at("home").get<std::string>(), away = m.at("away").get<std::string>();
|
||||
require(home != away && teams.insert(home).second && teams.insert(away).second,
|
||||
"A team appears twice or plays itself");
|
||||
require(ordered_pairs.emplace(home, away).second, "Ordered league pair repeated");
|
||||
require(m.at("round") == r && m.at("home_goals").is_number_integer() &&
|
||||
m.at("away_goals").is_number_integer(), "Malformed match projection");
|
||||
if (r < 26) {
|
||||
scored[home] += m.at("home_goals").get<int>();
|
||||
scored[away] += m.at("away_goals").get<int>();
|
||||
conceded[home] += m.at("away_goals").get<int>();
|
||||
conceded[away] += m.at("home_goals").get<int>();
|
||||
}
|
||||
}
|
||||
require(teams.size() == size_t(count), "League round does not contain every team");
|
||||
round_rows.push_back(matches);
|
||||
}
|
||||
require(ordered_pairs.size() == size_t(count * (count - 1)), "Not a complete two-leg schedule");
|
||||
for (int r = 0; r < rounds / 2; ++r)
|
||||
for (size_t i = 0; i < round_rows[size_t(r)].size(); ++i) {
|
||||
const auto &a = round_rows[size_t(r)][i], &b = round_rows[size_t(r + rounds / 2)][i];
|
||||
require(a.at("home") == b.at("away") && a.at("away") == b.at("home"),
|
||||
"Second half does not reverse venues");
|
||||
}
|
||||
state["round"] = 26;
|
||||
const auto all = by_club(report_table_rows(world, state));
|
||||
int gf = 0, ga = 0, wins = 0, loss = 0, draws = 0, points = 0;
|
||||
for (const auto &[id, row] : all) {
|
||||
require(row.at("played") == 26, "Table must project exactly26 played rounds");
|
||||
const int w = row.at("wins"), d = row.at("draw"), l = row.at("loss");
|
||||
require(w + d + l == 26 && row.at("points") == w * 3 + d, "Points/results conservation failed");
|
||||
require(row.at("gf") == scored[id] && row.at("ga") == conceded[id],
|
||||
"Table goals disagree with match projections");
|
||||
require(row.at("diff") == row.at("gf").get<int>() - row.at("ga").get<int>(), "Wrong goal difference");
|
||||
const auto text = row.at("form_text").get<std::string>();
|
||||
require(text.size() == 8, "Last-eight form length is wrong");
|
||||
int form = 0;
|
||||
for (char c : text) {
|
||||
require(c == 'S' || c == 'U' || c == 'N', "Unknown form symbol");
|
||||
form += c == 'S' ? 3 : c == 'U' ? 1 : 0;
|
||||
}
|
||||
require(row.at("form") == form, "Form metric is not numeric points");
|
||||
gf += row.at("gf").get<int>(); ga += row.at("ga").get<int>();
|
||||
wins += w; loss += l; draws += d; points += row.at("points").get<int>();
|
||||
}
|
||||
require(gf == ga && wins == loss && draws % 2 == 0 && points == wins * 3 + draws,
|
||||
"League totals are not conserved");
|
||||
std::array<std::map<std::string, Json>, 5> filtered;
|
||||
filtered[0] = all;
|
||||
for (int filter = 1; filter < 5; ++filter) {
|
||||
edit(state, {{"kind", "filter"}, {"value", filter}}, world);
|
||||
filtered[size_t(filter)] = by_club(report_table_rows(world, state));
|
||||
}
|
||||
for (const auto &[id, row] : all)
|
||||
for (const char *key : {"played", "wins", "draw", "loss", "gf", "ga", "points", "diff"}) {
|
||||
const int value = row.at(key);
|
||||
require(value == filtered[1].at(id).at(key).get<int>() + filtered[2].at(id).at(key).get<int>(),
|
||||
"First/second half filters do not reconstruct full table");
|
||||
require(value == filtered[3].at(id).at(key).get<int>() + filtered[4].at(id).at(key).get<int>(),
|
||||
"Home/away filters do not reconstruct full table");
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
int main() try {
|
||||
Fixture fixture;
|
||||
const auto &world = *fixture.world;
|
||||
const auto immutable_clubs = world.rows("clubs"), immutable_players = world.rows("players");
|
||||
auto state = demo_reports(world);
|
||||
require(valid_demo_reports(state, world) && state.at("league") == league(1) &&
|
||||
state.at("round") == 26, "Default state did not choose first German league");
|
||||
check_league(world, league(1), 18); check_league(world, league(0), 20);
|
||||
auto first = state; first["round"] = 0;
|
||||
const auto first_match = report_match_rows(world, first, false).front();
|
||||
require(first_match.at("home") == club(1, 0) && first_match.at("away") == club(1, 17) &&
|
||||
first_match.at("home_goals") == 0 && first_match.at("away_goals") == 2,
|
||||
"Pinned synthetic Gold preview score changed");
|
||||
const auto ranked = report_table_rows(world, state);
|
||||
edit(state, {{"kind", "sort"}, {"view", "tables"}, {"key", "rank"}}, world);
|
||||
require(state["sorts"]["tables"]["desc"] == false && report_table_rows(world, state) == ranked,
|
||||
"Rank sort used club names instead of places");
|
||||
edit(state, {{"kind", "sort"}, {"view", "tables"}, {"key", "rank"}}, world);
|
||||
require(report_table_rows(world, state).front().at("rank") == 18, "Rank sort toggle failed");
|
||||
edit(state, {{"kind", "sort"}, {"view", "tables"}, {"key", "gf"}}, world);
|
||||
const auto goals = report_table_rows(world, state);
|
||||
for (size_t i = 1; i < goals.size(); ++i)
|
||||
require(goals[i-1]["gf"] > goals[i]["gf"] ||
|
||||
(goals[i-1]["gf"] == goals[i]["gf"] && goals[i-1]["original"] < goals[i]["original"]),
|
||||
"Numeric sort or stable original tiebreak failed");
|
||||
auto strengths = report_strength_rows(world, state);
|
||||
const auto indexed = by_club(strengths);
|
||||
require(indexed.at(club(1, 0)).at("keeper") == 70 && indexed.at(club(1, 0)).at("strength") == 70,
|
||||
"Strengths did not average actual squad attributes");
|
||||
require(indexed.at(club(1, 1)).at("keeper").is_null() && indexed.at(club(1, 1)).at("defence") == 88 &&
|
||||
indexed.at(club(1, 2)).at("strength").is_null() && indexed.at(club(1, 4)).at("keeper").is_null(),
|
||||
"Missing/malformed positions invented ratings");
|
||||
require(indexed.at(club(1, 3)).at("defence") == 40 && indexed.at(club(1, 3)).at("midfield") == 40 &&
|
||||
indexed.at(club(1, 7)).at("keeper") == 0, "Multi-position or valid zero rating lost");
|
||||
edit(state, {{"kind", "sort"}, {"view", "strengths"}, {"key", "club"}}, world);
|
||||
strengths = report_strength_rows(world, state);
|
||||
require(strengths[0]["club"] == club(1, 1) && strengths[1]["club"] == club(1, 3) &&
|
||||
strengths[2]["club"] == club(1, 2), "Club alphabetic/numeric/accent sort or stable tie failed");
|
||||
edit(state, {{"kind", "sort"}, {"view", "strengths"}, {"key", "keeper"}}, world);
|
||||
strengths = report_strength_rows(world, state);
|
||||
require(strengths[0]["keeper"] == 99 && strengths.back()["keeper"].is_null(), "Nullable descending strength sort failed");
|
||||
const auto saved_strength_sort = state["sorts"]["strengths"];
|
||||
edit(state, {{"kind", "league"}, {"value", league(0)}}, world); state["round"] = 37;
|
||||
edit(state, {{"kind", "competition"}, {"value", 1}}, world);
|
||||
require(state["round"] == 33 && report_round_count(world, state, true) == 34,
|
||||
"Other preview did not clamp its34-round range");
|
||||
state["round"] = 37;
|
||||
require(valid_demo_reports(state, world) && report_match_rows(world, state, true)[0]["round"] == 33,
|
||||
"Shared state was not safely projected in other context");
|
||||
edit(state, {{"kind", "league"}, {"value", league(2)}}, world);
|
||||
require(state["round"] == 5, "Small league change did not clamp round");
|
||||
edit(state, {{"kind", "country"}, {"value", "nation:de"}}, world);
|
||||
require(state["league"] == league(1), "Country reselect did not select first league");
|
||||
edit(state, {{"kind", "filter"}, {"value", 4}}, world);
|
||||
state["round"] = 33;
|
||||
edit(state, {{"kind", "reset"}}, world);
|
||||
require(state["league"] == league(1) && state["filter"] == 0 && state["round"] == 33 &&
|
||||
state["sorts"]["tables"]["key"] == "points" && state["sorts"]["tables"]["desc"] == true &&
|
||||
state["sorts"]["strengths"] == saved_strength_sort && state["competition"] == 1,
|
||||
"Reset lost unrelated sort/competition state or failed defaults");
|
||||
edit(state, {{"kind", "round"}, {"step", 1}}, world);
|
||||
require(state["round"] == 0, "Round wrap forward failed");
|
||||
edit(state, {{"kind", "round"}, {"step", -1}}, world);
|
||||
require(state["round"] == 33, "Round wrap backward failed");
|
||||
auto foreign_reset = state;
|
||||
edit(foreign_reset, {{"kind", "league"}, {"value", league(0)}}, world);
|
||||
foreign_reset["round"] = 37;
|
||||
edit(foreign_reset, {{"kind", "reset"}}, world);
|
||||
require(foreign_reset["league"] == league(1) && foreign_reset["round"] == 33,
|
||||
"Reset from foreign20-team league did not restore/clamp German league");
|
||||
auto other_wrap = state;
|
||||
edit(other_wrap, {{"kind", "league"}, {"value", league(0)}}, world);
|
||||
other_wrap["round"] = 37;
|
||||
edit(other_wrap, {{"kind", "round"}, {"step", 1}, {"other", true}}, world);
|
||||
require(other_wrap["round"] == 0, "Other round context did not clamp/wrap34 rounds");
|
||||
edit(other_wrap, {{"kind", "round"}, {"step", -1}, {"other", true}}, world);
|
||||
require(other_wrap["round"] == 33, "Other round backward wrap failed");
|
||||
edit(other_wrap, {{"kind", "round"}, {"step", 1}, {"other", false}}, world);
|
||||
require(other_wrap["round"] == 34, "League round context lost its38-round range");
|
||||
const std::array<int, 9> counts{9,8,4,8,4,4,8,8,1};
|
||||
for (int competition = 1; competition <= 8; ++competition) {
|
||||
edit(state, {{"kind", "competition"}, {"value", competition}}, world);
|
||||
const auto matches = report_match_rows(world, state, true);
|
||||
require(matches.size() == size_t(counts[size_t(competition)]), "Wrong other competition pair count");
|
||||
for (const auto &m : matches)
|
||||
require(world.find("clubs", m.at("home"))->at("competition") == league(1) &&
|
||||
world.find("clubs", m.at("away"))->at("competition") == league(1),
|
||||
"Other preview used clubs outside first German league");
|
||||
}
|
||||
const auto opening = report_opening_pairs(world);
|
||||
require(opening.size() == 32 && opening[0]["home"] == club(1,0) && opening[8]["away"] == club(1,17) &&
|
||||
opening[9]["home"] == club(2,0) && opening[11]["home"] == club(3,0) &&
|
||||
opening.back()["away"] == club(3,41), "Opening draw order or64-team bound changed");
|
||||
for (const auto &m : opening) require(m["home_goals"].is_null() && m["away_goals"].is_null() && m["round"] == 0,
|
||||
"Opening draw invented results");
|
||||
const std::vector<Json> bad_actions = {nullptr, Json::array(), "bad", Json::object(),
|
||||
{{"kind", nullptr}}, {{"kind", "unknown"}}, {{"kind", "country"}, {"value", "nation:synthetic-empty"}},
|
||||
{{"kind", "country"}, {"value", 1}}, {{"kind", "country"}, {"value", "missing"}},
|
||||
{{"kind", "league"}, {"value", "competition:synthetic-cup"}}, {{"kind", "league"}},
|
||||
{{"kind", "filter"}, {"value", true}}, {{"kind", "filter"}, {"value", 5}},
|
||||
{{"kind", "filter"}, {"value", 1.0}}, {{"kind", "competition"}, {"value", -1}},
|
||||
{{"kind", "competition"}, {"value", 9}}, {{"kind", "round"}, {"step", 0}},
|
||||
{{"kind", "round"}, {"step", 2}}, {{"kind", "round"}, {"step", true}},
|
||||
{{"kind", "round"}, {"step", 1}, {"other", "false"}},
|
||||
{{"kind", "sort"}, {"view", "tables"}, {"key", "club"}},
|
||||
{{"kind", "sort"}, {"view", "__proto__"}, {"key", "points"}},
|
||||
{{"kind", "sort"}, {"view", "strengths"}, {"key", "form_text"}},
|
||||
{{"kind", "reset"}, {"unexpected", 1}}, {{"kind", "filter"}, {"value", 0}, {"round", 4}}};
|
||||
for (const auto &action : bad_actions) {
|
||||
const auto before = state;
|
||||
require(!edit_demo_reports(state, action, world).empty() && state == before,
|
||||
"Invalid action threw or mutated reports");
|
||||
}
|
||||
for (const auto *key : {"league", "round", "filter", "competition", "sorts"}) {
|
||||
auto bad = state; bad.erase(key); require(!valid_demo_reports(bad, world), "Missing reports field accepted");
|
||||
const auto before = bad; require(!edit_demo_reports(bad, {{"kind", "reset"}}, world).empty() && bad == before,
|
||||
"Corrupt reports state was partially repaired");
|
||||
}
|
||||
std::vector<Json> bad_states;
|
||||
for (const auto &value : std::vector<Json>{-1, 38, 1.5, true, uint64_t(-1)}) {
|
||||
auto invalid = state;
|
||||
invalid["round"] = value;
|
||||
bad_states.push_back(invalid);
|
||||
}
|
||||
auto bad = state; bad["sorts"]["tables"]["key"] = "club"; bad_states.push_back(bad);
|
||||
bad = state; bad["sorts"]["strengths"]["desc"] = 1; bad_states.push_back(bad);
|
||||
bad = state; bad["unexpected"] = 0; bad_states.push_back(bad);
|
||||
bad = state; bad["league"] = "missing"; bad_states.push_back(bad);
|
||||
bad = state; bad["filter"] = true; bad_states.push_back(bad);
|
||||
bad = state; bad["sorts"]["tables"]["unexpected"] = 0; bad_states.push_back(bad);
|
||||
for (const auto &v : bad_states) require(!valid_demo_reports(v, world), "Malformed reports state accepted");
|
||||
Fixture tiny(2); auto small = demo_reports(*tiny.world);
|
||||
require(small["round"] == 1, "Default round did not clamp for two clubs");
|
||||
edit(small, {{"kind", "competition"}, {"value", 1}}, *tiny.world); small["round"] = 33;
|
||||
require(report_match_rows(*tiny.world, small, false)[0]["round"] == 1, "Local league projection did not clamp shared round");
|
||||
edit(small, {{"kind", "competition"}, {"value", 0}}, *tiny.world);
|
||||
require(small["round"] == 1, "Switching back to league clamped to the wrong round");
|
||||
Fixture empty(0, false); const auto none = demo_reports(*empty.world);
|
||||
require(valid_demo_reports(none, *empty.world) && report_round_count(*empty.world, none) == 1 &&
|
||||
report_table_rows(*empty.world, none).empty() && report_opening_pairs(*empty.world).empty(),
|
||||
"Empty presentation catalogue is unsafe");
|
||||
require(world.rows("clubs") == immutable_clubs && world.rows("players") == immutable_players,
|
||||
"Report projection mutated immutable world data");
|
||||
std::cout << "Modern report projection checks passed\n";
|
||||
return 0;
|
||||
} catch (const std::exception &error) {
|
||||
std::cerr << error.what() << '\n';
|
||||
return 1;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "modern/ui/demo_sports.hpp"
|
||||
#include "modern/ui/demo_calendar.hpp"
|
||||
#include "modern/ui/demo_reports.hpp"
|
||||
#include "modern/ui/desktop.hpp"
|
||||
#include "modern/ui/gui_assets.hpp"
|
||||
#include "modern/ui/model.hpp"
|
||||
@@ -331,6 +332,46 @@ int main(int argc, char **argv) try {
|
||||
restored_calendar.load(root / "calendar.ui.json");
|
||||
require(restored_calendar.snapshot().state["calendar"] == calendar,
|
||||
"Calendar selection was lost on process restoration");
|
||||
require(restored_calendar.snapshot().state["reports"]["league"] == "comp:other",
|
||||
"Calendar and report league selection diverged");
|
||||
require(restored_calendar.apply({restored_calendar.snapshot().revision, "reports",
|
||||
{{"kind", "league"}, {"value", "comp:home"}}}).ok &&
|
||||
restored_calendar.snapshot().state["calendar"]["league"] == "comp:home" &&
|
||||
restored_calendar.snapshot().state["calendar"]["selected"] == 30,
|
||||
"Report selection failed to sync without losing the calendar day");
|
||||
require(restored_calendar.apply({restored_calendar.snapshot().revision, "opening", "complete"}).ok &&
|
||||
restored_calendar.snapshot().state["opening_created"] == true,
|
||||
"Completed opening lost its cup preview marker");
|
||||
restored_calendar.save(root / "reports.ui.json", default_desktop());
|
||||
DemoSource restored_reports(calendar_world);
|
||||
restored_reports.load(root / "reports.ui.json");
|
||||
require(restored_reports.snapshot().state == restored_calendar.snapshot().state,
|
||||
"Report state or completed opening failed to round-trip");
|
||||
auto old_reports = Json::parse(bmh::editor::read_file(root / "calendar.ui.json"));
|
||||
old_reports.erase("reports");
|
||||
old_reports.erase("opening_created");
|
||||
write(root, "old-reports.ui.json", old_reports);
|
||||
restored_reports.load(root / "old-reports.ui.json");
|
||||
require(valid_demo_reports(restored_reports.snapshot().state["reports"], *calendar_world) &&
|
||||
restored_reports.snapshot().state["reports"]["league"] == "comp:other" &&
|
||||
restored_reports.snapshot().state["opening_created"] == false,
|
||||
"Old checkpoint migration lost the selected league or invented a draw");
|
||||
const auto accepted_reports = restored_reports.snapshot();
|
||||
auto bad_reports = Json::parse(bmh::editor::read_file(root / "reports.ui.json"));
|
||||
bad_reports["reports"]["round"] = -1;
|
||||
write(root, "bad-reports.ui.json", bad_reports);
|
||||
rejected = false;
|
||||
try {
|
||||
restored_reports.load(root / "bad-reports.ui.json");
|
||||
} catch (const std::exception &) {
|
||||
rejected = true;
|
||||
}
|
||||
require(rejected && restored_reports.snapshot().state == accepted_reports.state &&
|
||||
restored_reports.snapshot().revision == accepted_reports.revision &&
|
||||
!restored_reports.apply({accepted_reports.revision, "reports",
|
||||
{{"kind", "league"}, {"value", "missing"}}}).ok &&
|
||||
restored_reports.snapshot().state == accepted_reports.state,
|
||||
"Rejected report load/action partially mutated the session");
|
||||
GuiAssets absent(root / "missing-gui");
|
||||
require(!absent.available(),
|
||||
"World resources were mistaken for GUI resources");
|
||||
|
||||
Reference in new issue
Block a user