Complete Modern season preparation with persistent draw progress (by Codex)

This commit is contained in:
Codex committed 2026-10-26 11:10:25 +01:00
1 parent 967520190d
commit e81ecf95f2
27 files changed
+1432 -208

No files matched your search

+2 -2
View File
@@ -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 modern_reports_tests modern_planning_tests modern_almanac_ui_tests modern_finance_ui_tests modern_environment_ui_tests modern_advertising_ui_tests modern_toto_ui_tests modern_lineup_ui_tests modern_transfer_ui_tests modern_career_reports_tests modern_rankings_tests modern_stadium_ui_tests modern_statistics_ui_tests modern_news_ui_tests modern_settings_ui_tests modern_desktop_ui_tests modern_files_ui_tests modern_mods_ui_tests modern_entry_ui_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 modern_planning_tests modern_almanac_ui_tests modern_finance_ui_tests modern_environment_ui_tests modern_advertising_ui_tests modern_toto_ui_tests modern_lineup_ui_tests modern_transfer_ui_tests modern_career_reports_tests modern_rankings_tests modern_stadium_ui_tests modern_statistics_ui_tests modern_news_ui_tests modern_settings_ui_tests modern_desktop_ui_tests modern_files_ui_tests modern_mods_ui_tests modern_entry_ui_tests modern_opening_ui_tests --parallel 2
- name: Check controls, fonts, density and draft cancellation
run: ctest --test-dir build-ui -R "^modern_(ui_|ticket_|control_|reports_|planning_|almanac_ui_|finance_ui_|environment_ui_|advertising_ui_|toto_ui_|lineup_ui_|transfer_ui_|career_reports_|rankings_|stadium_ui_|statistics_ui_|news_ui_|settings_ui_|desktop_ui_|files_ui_|mods_ui_|entry_ui_)" --output-on-failure --output-junit modern-ui-results.xml
run: ctest --test-dir build-ui -R "^modern_(ui_|ticket_|control_|reports_|planning_|almanac_ui_|finance_ui_|environment_ui_|advertising_ui_|toto_ui_|lineup_ui_|transfer_ui_|career_reports_|rankings_|stadium_ui_|statistics_ui_|news_ui_|settings_ui_|desktop_ui_|files_ui_|mods_ui_|entry_ui_|opening_ui_)" --output-on-failure --output-junit modern-ui-results.xml
- name: Upload test report
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
+1 -1
View File
@@ -1,6 +1,6 @@
<rml>
<head><title>OpenBMH</title><link type="text/rcss" href="theme.rcss"/><link type="text/rcss" href="ticket.rcss"/><link type="text/rcss" href="sports.rcss"/><link type="text/rcss" href="calendar.rcss"/><link type="text/rcss" href="reports.rcss"/><link type="text/rcss" href="report_details.rcss"/><link type="text/rcss" href="report_pickers.rcss"/><link type="text/rcss" href="indoor.rcss"/><link type="text/rcss" href="planning.rcss"/><link type="text/rcss" href="almanac.rcss"/><link type="text/rcss" href="finance.rcss"/>
<link type="text/rcss" href="bank.rcss"/><link type="text/rcss" href="contracts.rcss"/><link type="text/rcss" href="amount.rcss"/><link type="text/rcss" href="environment.rcss"/><link type="text/rcss" href="advertising.rcss"/><link type="text/rcss" href="toto.rcss"/><link type="text/rcss" href="lineup.rcss"/><link type="text/rcss" href="transfer.rcss"/><link type="text/rcss" href="career_reports.rcss"/><link type="text/rcss" href="rankings.rcss"/><link type="text/rcss" href="stadium.rcss"/><link type="text/rcss" href="statistics.rcss"/><link type="text/rcss" href="news.rcss"/><link type="text/rcss" href="settings.rcss"/><link type="text/rcss" href="widgets.rcss"/><link type="text/rcss" href="files.rcss"/><link type="text/rcss" href="front.rcss"/><link type="text/rcss" href="entry.rcss"/></head>
<link type="text/rcss" href="bank.rcss"/><link type="text/rcss" href="contracts.rcss"/><link type="text/rcss" href="amount.rcss"/><link type="text/rcss" href="environment.rcss"/><link type="text/rcss" href="advertising.rcss"/><link type="text/rcss" href="toto.rcss"/><link type="text/rcss" href="lineup.rcss"/><link type="text/rcss" href="transfer.rcss"/><link type="text/rcss" href="career_reports.rcss"/><link type="text/rcss" href="rankings.rcss"/><link type="text/rcss" href="stadium.rcss"/><link type="text/rcss" href="statistics.rcss"/><link type="text/rcss" href="news.rcss"/><link type="text/rcss" href="settings.rcss"/><link type="text/rcss" href="widgets.rcss"/><link type="text/rcss" href="files.rcss"/><link type="text/rcss" href="front.rcss"/><link type="text/rcss" href="entry.rcss"/><link type="text/rcss" href="opening.rcss"/></head>
<body class="midnight">
<div id="background"></div>
<div id="canvas"></div>
+87
View File
@@ -0,0 +1,87 @@
/* SPDX-License-Identifier: GPL-3.0-only */
/* Gold season-opening geometry in logical desktop units; data is canonical. */
body {--opening-selected:#8ebfaf12;--opening-accent-border:#b1d9cd70;--opening-current:#b3d6d20d;--opening-divider:#c5d9e712;--opening-indicator:#b5dbd2;}
body.silver {--opening-selected:#a3c3dd54;--opening-accent-border:#356f966e;--opening-current:#a3c3dd30;--opening-divider:#6c879c28;--opening-indicator:#25617a;}
body.matchday {--opening-selected:#d48c7b26;--opening-accent-border:#e5a19770;--opening-current:#d48c7b12;--opening-divider:#ead9da16;--opening-indicator:#efb2aa;}
.opening-layout {position:absolute;left:0;right:0;top:0;bottom:0;color:var(--text);}
.opening-heading {height:110dp;display:flex;align-items:center;justify-content:space-between;gap:30dp;}
.opening-heading>div {display:block;min-width:0;flex:1;}
.opening-heading h2 {margin:0;font-size:46dp;font-weight:normal;}
.opening-heading h2>span {display:block;}
.opening-heading p {margin:14dp 0 0;font-size:28dp;color:var(--muted);}
.opening-heading p>span {display:block;}
.opening-heading-detail {display:block;font-size:27dp;white-space:nowrap;color:var(--muted);flex-shrink:0;}
.opening-entrant-grid {position:absolute;left:150dp;right:150dp;top:180dp;bottom:180dp;overflow-y:auto;overflow-x:hidden;}
.opening-entrant-content {position:relative;display:flex;flex-direction:column;gap:50dp;width:100%;height:100%;min-height:0;}
.opening-entrant-row {display:flex;align-items:stretch;gap:50dp;flex:1;min-width:0;min-height:0;width:100%;}
.opening-entrant {display:flex;flex-direction:column;align-items:center;justify-content:center;gap:26dp;flex:1;min-width:0;min-height:0;padding:34dp;border:2dp var(--border);border-radius:22dp;background-color:var(--panel);}
.opening-entrant-spacer {flex:1;min-width:0;min-height:0;padding:34dp;border:2dp transparent;}
.opening-entrant-crest {display:block;position:relative;flex-shrink:0;width:360dp;height:360dp;}
.opening-entrant-crest>.image-frame {flex-shrink:0;}
.opening-entrant h3 {width:100%;margin:0;font-size:50dp;font-weight:normal;text-align:center;line-height:1.2;flex-shrink:0;max-width:100%;}
.opening-entrant h3>span {display:block;width:100%;text-align:center;}
.opening-entrant p {width:100%;margin:0;text-align:center;color:var(--accent);font-size:25dp;flex-shrink:0;}
.opening-entrant p>span {display:block;width:100%;text-align:center;}
.opening-entrant.own-entrant {border-color:var(--opening-accent-border);background-color:var(--opening-selected);}
.opening-entrant-content.single-entrant-content {align-items:center;justify-content:center;}
.opening-entrant.single-entrant {flex:none;width:1200dp;height:1000dp;max-width:100%;max-height:100%;gap:52dp;}
.single-entrant .opening-entrant-crest {width:620dp;height:620dp;}
.single-entrant h3 {font-size:64dp;}
.opening-empty-entrants {position:absolute;left:0;right:0;top:0;bottom:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:28dp;padding:60dp;text-align:center;border:2dp var(--border);border-radius:22dp;background-color:var(--panel);}
.opening-empty-entrants h3 {width:100%;margin:0;text-align:center;font-size:44dp;font-weight:normal;flex-shrink:0;}
.opening-empty-entrants p {width:100%;margin:0;text-align:center;font-size:30dp;line-height:1.5;color:var(--muted);flex-shrink:0;}
.opening-empty-entrants span {display:block;width:100%;text-align:center;}
.opening-actions {position:absolute;left:0;right:0;bottom:0;height:94dp;display:flex;align-items:center;justify-content:flex-end;gap:22dp;}
.opening-actions button {min-width:390dp;height:94dp;font-size:30dp;flex-shrink:0;}
.opening-actions button:focus-visible {border-color:var(--accent);}
.opening-demo-note {display:block;min-width:0;flex:1;margin-right:24dp;font-size:25dp;line-height:1.4;color:var(--muted);}
.opening-draw-scene {position:absolute;left:0;right:0;top:138dp;height:850dp;display:flex;justify-content:center;align-items:center;}
.opening-draw-art {position:relative;display:block;box-sizing:content-box;flex-shrink:0;border:2dp var(--border);border-radius:18dp;overflow:hidden;box-shadow:0dp 20dp 50dp #0003;}
.opening-draw-art>.image-frame {position:absolute;left:0;top:0;}
.opening-art-missing {margin:0;font-size:32dp;color:var(--muted);}
.opening-art-missing>span {display:block;}
.opening-draw-indicator {position:absolute;left:50%;margin-left:-10dp;bottom:30dp;width:20dp;height:20dp;border-radius:10dp;background-color:var(--opening-indicator);opacity:0;pointer-events:none;}
.opening-draw-indicator.is-playing {animation:0.45s cubic-in-out infinite alternate opening-draw-pulse;}
@keyframes opening-draw-pulse {from {opacity:0.2;transform:scale(0.65);} to {opacity:0.8;transform:scale(1);}}
.opening-draw-indicator.is-paused {opacity:0;}
.opening-current-pair {position:absolute;left:130dp;right:130dp;top:1026dp;height:126dp;border:2dp var(--border);border-radius:16dp;background-color:var(--opening-current);padding:10dp 28dp;}
.opening-pair-row {display:flex;align-items:center;gap:18dp;width:100%;height:100%;min-width:0;font-size:30dp;}
.opening-pair-number {display:block;width:46dp;text-align:right;color:var(--muted);font-size:24dp;flex-shrink:0;}
.opening-pair-number>span {display:block;}
.opening-pair-versus {display:block;width:40dp;text-align:center;color:var(--muted);flex-shrink:0;}
.opening-pair-versus>span {display:block;}
.opening-pair-counter {display:block;width:46dp;flex-shrink:0;}
.opening-pair-side {display:flex;align-items:center;gap:18dp;min-width:0;flex:1;}
.opening-pair-side.home {justify-content:flex-end;text-align:right;}
.opening-pair-side.away {justify-content:flex-start;text-align:left;}
.opening-pair-name {display:block;min-width:0;flex:1;overflow:hidden;white-space:nowrap;}
.opening-pair-name>span {display:block;}
.opening-pair-side.home .opening-pair-name {text-align:right;}
.opening-pair-side.away .opening-pair-name {text-align:left;}
.opening-pair-crest {display:block;width:42dp;height:42dp;flex-shrink:0;}
.opening-pair-crest>.image-frame {flex-shrink:0;}
.opening-pair-row.own-pair {color:var(--accent);}
.opening-pair-row .opening-unknown {color:var(--muted);}
.opening-pair-row.current {font-size:38dp;}
.opening-pair-row.current .opening-pair-crest {width:66dp;height:66dp;}
.opening-recent {position:absolute;left:130dp;right:130dp;top:1190dp;bottom:145dp;}
.opening-recent-row {position:absolute;left:0;right:0;height:171dp;padding:0 28dp;border-bottom:2dp var(--opening-divider);}
.opening-no-pairs {height:100%;margin:0;display:flex;align-items:center;justify-content:center;text-align:center;font-size:30dp;color:var(--muted);}
.opening-no-pairs>span {display:block;}
.opening-pair-columns {position:absolute;left:0;right:0;top:154dp;bottom:140dp;}
.opening-overview-column {position:absolute;top:0;bottom:0;width:1289dp;padding:12dp 18dp;border:2dp var(--border);border-radius:18dp;background-color:var(--panel);}
.opening-overview-column.single-column {width:100%;}
.opening-overview-list {position:absolute;left:18dp;right:18dp;top:12dp;bottom:12dp;display:flex;flex-direction:column;overflow-y:auto;overflow-x:hidden;}
.opening-overview-row {flex:1;min-height:0;padding:8dp 0;border-bottom:2dp var(--opening-divider);}
.opening-overview-row:last-child {border-bottom:0dp;}
.opening-pair-row.compact {gap:12dp;font-size:27dp;}
.opening-pair-row.compact .opening-pair-number {width:34dp;font-size:21dp;}
.opening-pair-row.compact .opening-pair-counter {width:34dp;}
.opening-pair-row.compact .opening-pair-versus {width:22dp;}
.opening-pair-row.compact .opening-pair-side {gap:12dp;}
.opening-pair-row.compact .opening-pair-crest {width:36dp;height:36dp;}
.opening-empty-overview {position:absolute;left:0;right:0;top:0;bottom:0;display:flex;align-items:center;justify-content:center;padding:60dp;border:2dp var(--border);border-radius:18dp;background-color:var(--panel);}
.opening-empty-overview p {margin:0;font-size:34dp;color:var(--muted);text-align:center;}
.opening-empty-overview p>span {display:block;}
+9 -5
View File
@@ -23,8 +23,10 @@ wird ausdrücklich mit `OPENBMH_BUILD_MODERN_UI=ON` gebaut.
lassen sich mit derselben Ansicht ergänzen; vier belegte Plätze bleiben
sichtbar und gesperrt. Ausländische
Vereine bleiben sichtbar und sind für Manager gesperrt.
- Drei Teilnehmerseiten, automatische Demo-Auslosung mit Pause/Überspringen
und Übersicht; in dieser Folge gibt es keinen Schließen-Knopf.
- [Saisonvorbereitung](main-menu/opening/README.md): drei Teilnehmerseiten,
automatische Demo-Auslosung mit Pause/Überspringen, gespeicherter Reihenfolge
und Fortsetzung nach Neustart. Eigene Vereine, Phasenstatus und Paarungszähler
folgen dem Gold; in dieser Folge gibt es keinen Schließen-Knopf.
- Desktop mit Statusleiste, Buttons, fixierter Standardanordnung, Raster und
freiem Verschieben, Rechtsklickmenü, gemeinsamer Fixierung, Rückgängig,
[vollständigem Widgetkatalog](desktop/widgets/README.md), Größenwahl und
@@ -141,9 +143,11 @@ auch für die direkte Aktionsschnittstelle des Demoanbieters.
Die verbleibenden Routen und Teilbereiche werden in zusammengehörigen Paketen
vom HTML-Mockup übertragen. Für fehlende Ports erscheinen keine vereinfachten
Ersatzlayouts. Der Katalog zählt jetzt 34 native und drei noch nicht separat
zugeordnete Routen; diese Zahl bestätigt keine vollständige gestalterische
Abnahme aller früheren Teilimplementierungen.
Ersatzlayouts. Der allgemeine Capture-Katalog zählt 34 direkt zugeordnete Ansichten und drei
noch nicht separat zugeordnete Routen. Neuer Spieler und Saisonvorbereitung
werden zusätzlich als echte Bedienfolgen geprüft; Anstoß bleibt bewusst
ohne Aktion. Diese Zuordnungszahl ist kein Fertigstellungsprozentsatz und
bestätigt keine vollständige gestalterische Abnahme aller Ansichten.
Bildschirmkonfiguration und Audioausgabe benötigen noch die
Plattform-/Engine-Anbindung der nun gespeicherten UI-Voreinstellungen. Übersetzungen, echte Engine-Anbindung und Plattform-Abnahme
unter Windows/macOS folgen später. Dies ist kein freigegebenes Test-Release.
+1
View File
@@ -15,6 +15,7 @@ Implementierung in der Spiel-Engine.
| Ressourcen | [GUI-Assets, Weltbilder und spätere Paketbereinigung](assets.md) |
| Hauptmenü & Mods | [Bibliothek, Import und explizite Aktivierung](main-menu/README.md) |
| Spieleinstieg | [Grundeinstellungen, Managerwahl und Bestätigung](main-menu/entry/README.md) |
| Saisonvorbereitung | [Teilnehmer, Ziehung und Fortsetzung](main-menu/opening/README.md) |
| Desktop | [Statusleiste, Gestaltung und Fenster](desktop/README.md) |
| Widgets | [17 Typen, 48 Größen, Raster, Fixierung und Arbeitsanordnung](desktop/widgets/README.md) |
| Dateiverwaltung | [Spielstände und Desktopansichten mit Vorschauen](desktop/save-load/README.md) |
+2 -2
View File
@@ -3,8 +3,8 @@
Die native Modern-UI-Demo auf `0.3` übernimmt Grundeinstellungen, Managerwahl
und Bestätigung aus dem privaten HTML-Mockup, Referenzstand `97c19979`.
Die POC-Daten bleiben Präsentationsdaten. Es entsteht keine Engine-Karriere;
Anstoß bleibt ohne Aktion. Saisonvorbereitung und deren fortsetzbare Speicherung
bilden einen eigenen Folgeschritt.
Anstoß bleibt ohne Aktion. [Saisonvorbereitung und fortsetzbare Speicherung](../opening/README.md)
werden als separates Paket geführt.
## Ablauf und Datenvertrag
+65
View File
@@ -0,0 +1,65 @@
# Saisonvorbereitung bis zum Desktop
Die native RmlUI-Demo übernimmt Teilnehmerseiten, automatische Ziehung und
Paarungsübersicht aus dem privaten HTML-Mockup (`season-opening.js/.css`,
Goldquelle `97c19979`). Die drei Teilnehmerseiten zeigen UEFA-Cup,
Champions League und Pokalsieger mit Phase, Saisonspanne und Hervorhebung
der eigenen Vereine. Es folgt die Ziehung mit aktuellem Paar, drei vorigen
Paaren, Pause und Überspringen; die vollständige Übersicht führt zum Desktop.
Heimnamen stehen rechtsbündig, Auswärtsnamen linksbündig; Wappen liegen innen
neben dem mittigen Trennzeichen. Escape und Rechtsklick verlassen diese Folge
nicht. Die Grafik behält ihr tatsächliches Seitenverhältnis.
## Präsentationsdaten
`opening_flow` gehört ausschließlich zum JSON-Demostand. Es enthält Schema 1,
`created`, `phase`, `revealed`, `playing`, stabile Vereins-IDs in `order` und
die Teilnehmer unter `entrants`. Die Phasen sind `uefa`, `champions`, `winners`,
`draw`, `overview`, `done`. `opening.flow` nimmt die Aktionen `next`, `reveal`,
`toggle`, `pause`, `skip` und `finish` entgegen; ungültige oder veraltete
Anfragen lassen Quelle, Revision und Dirty-Marke unverändert.
Die Teilnehmer sind ausdrücklich fiktiv: erste vier verfügbare Vereine der
ersten deutschen Katalogliga im UEFA-Cup, anschließend je einer in Champions
League und Pokalsiegerwettbewerb. Es wird keine echte Qualifikation behauptet.
Der Lostopf enthält höchstens 64 unterschiedliche deutsche Vereine deutscher
Ligen. Ein eigener LCG mit festem Seed `20270701` folgt dem Gold-Demoalgorithmus;
er verwendet keine Engine-Zufallsquelle. Kleine Kataloge zeigen ihre tatsächliche
Anzahl und eindeutige Leerzustände; eine ungerade Restzahl wird vor der Paarbildung
gekürzt. Es werden keine Gegner dupliziert und keine Engine-Freilose berechnet.
Die spätere DFB-Pokalansicht unter Übrige Spiele verwendet dieselbe gespeicherte
Reihenfolge, mit weiterhin leeren Ergebnissen.
## Fortsetzen und Fehlerfälle
Die UI schreibt einen eigenen Fortsetzungsvermerk unter
`userdata/ui-demo/<world-hash>/opening-progress.json`. Er enthält den Demostand,
die Ansicht und eine Manifestkennung. Eine Änderung wird zuerst vorbereitet
und atomar gesichert, dann in der Quelle veröffentlicht. Bei Schreibfehlern
bleibt der letzte Stand erhalten. Eine angehaltene Automatik erzeugt keine
Fehlermeldungsschleife; „Erneut versuchen“ ist eine bewusste neue Aktion.
Fokusverlust pausiert die Ziehung, ohne nachträglich Lose aufzuholen.
Beim nächsten Start derselben Modern-Welt wird eine offene Vorbereitung
fortgesetzt, einschließlich Pause und Reihenfolge. Der Vermerk zählt nicht
als manuelles Speichern und macht die Partie nicht sauber. Ein ausdrücklich
geladener Spielstand hat Vorrang vor einem älteren Fortsetzungsvermerk.
Die abgeschlossene Vorbereitung hinterlässt einen `done`-Vermerk, der beim
Start keine ältere offene Vorbereitung wieder aufleben lässt.
Alte Demo-Checkpoints ohne Flow werden migriert: `pending` beginnt die
Teilnehmerfolge, `complete` bleibt abgeschlossen. Bereits vorhandene
inkonsistente Flowdaten werden abgewiesen. Dies ist kein neues Engine- oder
OBS-Spielstandformat. Match-/Saison-Engine und Anstoß bleiben unverändert;
Anstoß ist weiterhin ohne Aktion.
## Nachweise
Die synthetische Suite `modern_opening_ui_tests` prüft deterministische
Reihenfolge, kleine Kataloge, Übergänge, veraltete Anfragen, pausierte
Rundreisen, Migration und Dirty-Restore. Der tatsächliche native Bedienlauf
prüft zusätzlich Neustart, Autosicherungsfehler mit Rücknahme und explizite
Wiederaufnahme sowie den Vorrang ausdrücklich geladener Checkpoints.
Bilder, Eingaben und UI-Zustände liegen privat unter
`docs/qa/opening-batch-2026-10-26`. Browser-Themes werden über die tatsächlichen
Optionen eingestellt und im DOM geprüft; ein URL-Parameter allein genügt nicht.
+19
View File
@@ -277,3 +277,22 @@ Start und die gemeinsame Managervalidierung. Private Quellen, Screenshots
und UI-Checkpoints liegen unter `docs/qa/entry-flow-batch-2026-10-26` im
Mockup-Repository. Die vorhandene Saisonvorbereitung wird nur durchlaufen;
eine neue Engine-Auslosung oder Matchabnahme wird nicht behauptet.
## Saisonvorbereitung und Fortsetzen · 26. Oktober 2026
Das [Saisonvorbereitungspaket](main-menu/opening/README.md) prüft den echten
Weg über drei Teilnehmerseiten, automatische Ziehung und Übersicht bis zum
Desktop. Die separate sechsfach erfasste Goldkohorte belegt das angewandte
Theme über tatsächliche Einstellungen, DOM und Preference. Ein URL-Parameter
allein wird nicht als Themebeleg verwendet. Die frühere Entry-Goldkohorte
hat dafür einen transparenten Nachtrag und getrennte korrigierte Themebilder.
Die native Prüfung umfasst gespeicherte IDs/Reihenfolge, Timer/Pause und
Sperre von Escape/Rechtsklick. Zusätzliche gerichtete Läufe prüfen normale
Neustartfortsetzung, den Vorrang expliziter Checkpoints sowie einen tatsächlichen
Autosicherungsfehler mit unverändertem Quellstand und explizitem Retry.
Der vorher reproduzierte Texturverlust der Standardansichts-Vorschau wird
vor/nach abgebrochener Managerwahl mit Quelle, Dirty-Marke, Layout und
pixelidentischer wiedergeöffneter Vorschau kontrolliert. Diese Protokolle
bleiben im privaten `docs/qa/opening-batch-2026-10-26`.
+12 -2
View File
@@ -134,5 +134,15 @@ korrekte Auswahl beziehungsweise kehren zum bisherigen Desktop zurück.
Sichtbefunde zu Auswahlglyphen, Bestätigungstitel und letzter Full-Identität
wurden im dedizierten Vergleich nachgeprüft. Die oben vermerkte Übertragung
des HTML-Popup-Unterbaus für Manager-Selects bleibt gesondert offen.
Die Saisonvorbereitung bleibt im bisherigen Demoablauf; ihre fortsetzbare
Phasen-/Ziehstandspeicherung und weitere Goldangleichung sind noch offen.
Die damaligen offenen Punkte der Saisonvorbereitung werden im folgenden
Paket separat behandelt.
Im [Saisonvorbereitungspaket](main-menu/opening/README.md) korrigiert:
fehlende eigene Vereinsmarkierungen, Phasen-/Saisonangaben, Ziehindikator,
Grafikrahmen und gespeicherte Losfolge. Die Fortsetzung bleibt eine UI-Demo
und bezeichnet keine Engine-Auslosung. Ein reproduzierter Fehler der
Standardansichts-Vorschau nach abgebrochener Managerwahl ist ebenfalls behoben:
beim Neubinden des Renderers wird das gehaltene Vorschaubild entwertet.
Die tatsächliche Nachprüfung erhält Quelle, Revision und Layout und zeigt
dieselbe Vorschau vor und nach Abbrechen.
+3 -3
View File
@@ -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 demo_reports.cpp demo_almanac.cpp demo_finance.cpp demo_environment.cpp demo_advertising.cpp demo_toto.cpp demo_lineup.cpp demo_transfer.cpp demo_career_reports.cpp demo_rankings.cpp demo_stadium.cpp demo_statistics.cpp demo_news.cpp demo_settings.cpp ui_preferences.cpp demo_widgets.cpp demo_files.cpp)
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 demo_almanac.cpp demo_finance.cpp demo_environment.cpp demo_advertising.cpp demo_toto.cpp demo_lineup.cpp demo_transfer.cpp demo_career_reports.cpp demo_rankings.cpp demo_stadium.cpp demo_statistics.cpp demo_news.cpp demo_settings.cpp ui_preferences.cpp demo_widgets.cpp demo_files.cpp demo_opening.cpp)
target_include_directories(bmh_modern_ui_core PUBLIC ../..)
target_link_libraries(bmh_modern_ui_core PUBLIC bmh_asset_io)
add_library(bmh_modern_ui_mods STATIC mod_library.cpp)
@@ -26,7 +26,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 reports.rcss report_details.rcss report_pickers.rcss indoor.rcss planning.rcss almanac.rcss finance.rcss bank.rcss contracts.rcss amount.rcss environment.rcss advertising.rcss toto.rcss lineup.rcss transfer.rcss career_reports.rcss rankings.rcss stadium.rcss statistics.rcss news.rcss settings.rcss widgets.rcss files.rcss front.rcss entry.rcss)
foreach(asset modern.rml theme.rcss ticket.rcss sports.rcss calendar.rcss reports.rcss report_details.rcss report_pickers.rcss indoor.rcss planning.rcss almanac.rcss finance.rcss bank.rcss contracts.rcss amount.rcss environment.rcss advertising.rcss toto.rcss lineup.rcss transfer.rcss career_reports.rcss rankings.rcss stadium.rcss statistics.rcss news.rcss settings.rcss widgets.rcss files.rcss front.rcss entry.rcss opening.rcss)
configure_file("${CMAKE_SOURCE_DIR}/assets/modern/${asset}" "${modern_assets}/${asset}" COPYONLY)
endforeach()
@@ -112,7 +112,7 @@ foreach(component environment advertising toto lineup transfer stadium)
add_test(NAME modern_${component}_ui_tests COMMAND modern_${component}_ui_tests)
endforeach()
foreach(component statistics news settings desktop files entry)
foreach(component statistics news settings desktop files entry opening)
add_executable(modern_${component}_ui_tests ../../../tests/modern_${component}_ui_tests.cpp)
target_link_libraries(modern_${component}_ui_tests PRIVATE bmh_modern_ui_core)
if(MSVC)
+14 -27
View File
@@ -149,6 +149,7 @@ void App::ProcessEvent(Rml::Event &event) try {
return;
if(front_event(event))return;
if (entry_event(event)) return;
if (opening_event(event)) return;
if (amount_event(event)) return;
if (popup_.empty() && settings_event(event)) return;
if (popup_.empty() && (files_event(event) || widget_event(event))) return;
@@ -464,6 +465,7 @@ void App::dispatch(const std::string &action, Rml::Element *target) {
target ? target->GetAttribute<Rml::String>("data-id", "") : std::string();
if(front_action(action,target))return;
if (entry_action(action, target)) return;
if (opening_action(action, target)) return;
if (settings_action(action,target)) return;
if (files_action(action,target) || widget_action(action,target)) return;
if (lineup_action(action, target) || transfer_action(action, target)) return;
@@ -674,33 +676,6 @@ void App::dispatch(const std::string &action, Rml::Element *target) {
entry_begin();
return;
}
if (action == "opening-play") {
draw_playing_ = !draw_playing_;
draw_at_ = SDL_GetTicks64() + 900;
refresh();
return;
}
if (action == "opening-next") {
++opening_page_;
if (opening_page_ == 3)
draw_at_ = SDL_GetTicks64() + 900;
refresh();
return;
}
if (action == "opening-all") {
draw_revealed_ = 64;
opening_page_ = 4;
refresh();
return;
}
if (action == "opening-finish") {
if (opening_page_ != 4)
return;
scene_ = "desktop";
apply("opening", "complete");
refresh();
return;
}
if (action == "desktop-context") {
context_menu({}, 0, 0);
return;
@@ -961,6 +936,18 @@ void App::script() {
(command.value("shift", false) ? Rml::Input::KM_SHIFT : 0);
context_->ProcessKeyDown(keys.at(name), mods);
context_->ProcessKeyUp(keys.at(name), mods);
} else if (type == "wait") {
const int milliseconds = command.at("milliseconds").get<int>();
if (milliseconds < 0 || milliseconds > 30000)
throw editor::Error("UI-Wartezeit muss zwischen 0 und 30000 ms liegen.");
const auto until = SDL_GetTicks64() + uint64_t(milliseconds);
while (!closed_ && SDL_GetTicks64() < until) {
pump_events();
front_poll();
opening_tick();
frame();
SDL_Delay(5);
}
} else if (type == "screenshot")
screenshot(editor::path(command.at("path").get<std::string>()));
else if (type == "checkpoint") {
+226
View File
@@ -0,0 +1,226 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "modern/ui/demo_opening.hpp"
#include <algorithm>
#include <cstdint>
#include <limits>
#include <set>
namespace bmh::modern_ui {
namespace {
bool integer(const Json &value, int low, int high) {
if (!value.is_number_integer())
return false;
if (value.is_number_unsigned())
return value.get<uint64_t>() >= uint64_t(low) &&
value.get<uint64_t>() <= uint64_t(high);
return value.get<int64_t>() >= low && value.get<int64_t>() <= high;
}
int tier(const Json *league) {
const auto value = league->value("tier", Json());
return integer(value, 0, 1000) ? value.get<int>()
: std::numeric_limits<int>::max();
}
struct Participants {
std::vector<std::string> pool;
Json entrants = {{"uefa", Json::array()},
{"champions", Json::array()},
{"winners", Json::array()}};
};
Participants participants(const Catalog &world) {
auto leagues = world.leagues("nation:de");
// Tier determines the top available league; equal/missing tiers retain the
// authored catalogue order, as do clubs within each league.
std::stable_sort(
leagues.begin(), leagues.end(),
[](const auto *a, const auto *b) { return tier(a) < tier(b); });
Participants result;
std::set<std::string> used;
bool top_found = false;
for (const auto *league : leagues) {
std::vector<std::string> clubs;
for (const auto *club : world.clubs(league->value("id", ""))) {
const auto id = club->value("id", "");
if (world.manageable(id) && used.insert(id).second)
clubs.push_back(id);
}
if (!top_found && !clubs.empty()) {
top_found = true;
for (size_t index = 0; index < clubs.size() && index < 6; ++index)
result
.entrants[index < 4 ? "uefa"
: index == 4 ? "champions"
: "winners"]
.push_back(clubs[index]);
}
for (const auto &id : clubs)
if (result.pool.size() < 64)
result.pool.push_back(id);
}
// A tiny world gets real pairs only: do not duplicate a team or invent a bye.
if (result.pool.size() % 2)
result.pool.pop_back();
return result;
}
bool valid(const Json &state, const Catalog &world) {
if (!state.is_object() || !state.contains("opening_flow") ||
!state.contains("opening") || !state.at("opening").is_string() ||
!state.contains("opening_created") ||
!state.at("opening_created").is_boolean())
return false;
const auto &flow = state.at("opening_flow");
if (!flow.is_object() || flow.size() != 7 ||
!integer(flow.at("schema"), 1, 1) || !flow.at("created").is_boolean() ||
!flow.at("phase").is_string() || !flow.at("playing").is_boolean() ||
!flow.at("order").is_array() || !flow.at("entrants").is_object())
return false;
const auto expected = participants(world);
const auto &order = flow.at("order");
if (order.size() != expected.pool.size() || order.size() > 64 ||
order.size() % 2 || !integer(flow.at("revealed"), 0, int(order.size())) ||
flow.at("entrants").size() != 3)
return false;
for (const auto *group : {"uefa", "champions", "winners"})
if (!flow.at("entrants").contains(group) ||
flow.at("entrants").at(group) != expected.entrants.at(group))
return false;
std::set<std::string> ids;
for (const auto &id : order) {
if (!id.is_string() || !ids.insert(id.get<std::string>()).second)
return false;
}
if (ids != std::set<std::string>(expected.pool.begin(), expected.pool.end()))
return false;
const auto phase = flow.at("phase").get<std::string>();
const bool created = flow.at("created").get<bool>(),
playing = flow.at("playing").get<bool>();
const int revealed = flow.at("revealed").get<int>();
if (phase == "uefa" || phase == "champions" || phase == "winners") {
if (revealed != 0 || playing)
return false;
} else if (phase == "draw") {
if (order.empty() || revealed >= int(order.size()))
return false;
} else if (phase == "overview" || phase == "done") {
if (revealed != int(order.size()) || playing)
return false;
} else
return false;
if (!created && phase != "done")
return false;
return state.at("opening").get<std::string>() ==
(phase == "done" ? "complete" : "pending") &&
state.at("opening_created").get<bool>() ==
(phase == "done" && created);
}
} // namespace
Json make_demo_opening(const Catalog &world, const Json & /*state*/,
bool created) {
auto data = participants(world);
uint32_t seed = 20270701u;
for (size_t count = data.pool.size(); count > 1; --count) {
seed = seed * 1664525u + 1013904223u;
std::swap(data.pool[count - 1], data.pool[size_t(seed) % count]);
}
return {{"schema", 1},
{"created", created},
{"phase", created ? "uefa" : "done"},
{"revealed", created ? size_t(0) : data.pool.size()},
{"playing", false},
{"order", data.pool},
{"entrants", data.entrants}};
}
bool migrate_demo_opening(Json &state, const Catalog &world) {
try {
if (!state.is_object())
return false;
auto next = state;
if (!next.contains("opening"))
next["opening"] = "complete";
if (!next.contains("opening_created"))
next["opening_created"] = false;
if (!next.at("opening").is_string() ||
!next.at("opening_created").is_boolean())
return false;
const auto phase = next.at("opening").get<std::string>();
if (phase != "pending" && phase != "complete")
return false;
if (!next.contains("opening_flow")) {
next["opening_flow"] = make_demo_opening(world, next, phase == "pending");
if (phase == "complete")
next["opening_flow"]["created"] = next.at("opening_created");
}
if (!valid(next, world))
return false;
state = std::move(next);
return true;
} catch (const std::exception &) {
return false;
}
}
std::string edit_demo_opening(Json &state, const Json &action,
const Catalog &world) {
try {
if (!action.is_object() || action.size() != 1 || !action.contains("kind") ||
!action.at("kind").is_string())
return "Ungültige Aktion der Saisonvorbereitung.";
auto next = state;
if (!migrate_demo_opening(next, world))
return "Die gespeicherte Saisonvorbereitung ist ungültig.";
auto &flow = next.at("opening_flow");
const auto kind = action.at("kind").get<std::string>(),
phase = flow.at("phase").get<std::string>();
const auto total = flow.at("order").size();
if (kind == "next") {
if (phase == "uefa")
flow["phase"] = "champions";
else if (phase == "champions")
flow["phase"] = "winners";
else if (phase == "winners") {
flow["phase"] = total ? "draw" : "overview";
flow["playing"] = total != 0;
} else
return "Weiter ist nur auf den ersten drei Vorbereitungsseiten "
"möglich.";
} else if (kind == "reveal") {
if (phase != "draw" || !flow.at("playing").get<bool>())
return "Die Auslosung läuft gerade nicht.";
const auto count = flow.at("revealed").get<size_t>() + 1;
flow["revealed"] = count;
if (count == total) {
flow["phase"] = "overview";
flow["playing"] = false;
}
} else if (kind == "toggle" || kind == "pause") {
if (phase != "draw")
return "Nur eine laufende Auslosung kann pausiert oder fortgesetzt "
"werden.";
flow["playing"] =
kind == "toggle" ? !flow.at("playing").get<bool>() : false;
} else if (kind == "skip") {
if (phase != "draw")
return "Paarungen können nur während der Auslosung eingeblendet "
"werden.";
flow["revealed"] = total;
flow["playing"] = false;
flow["phase"] = "overview";
} else if (kind == "finish") {
if (phase != "overview" && phase != "done")
return "Bitte zuerst die Paarungsübersicht öffnen.";
flow["created"] = true;
flow["phase"] = "done";
flow["revealed"] = total;
flow["playing"] = false;
} else
return "Unbekannte Aktion der Saisonvorbereitung.";
const bool done = flow.at("phase").get<std::string>() == "done";
next["opening"] = done ? "complete" : "pending";
next["opening_created"] = done && flow.at("created").get<bool>();
if (!valid(next, world))
return "Die neue Saisonvorbereitung ist inkonsistent.";
state = std::move(next);
return {};
} catch (const std::exception &) {
return "Die Aktion der Saisonvorbereitung konnte nicht übernommen werden.";
}
}
} // namespace bmh::modern_ui
+13
View File
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include "modern/ui/catalog.hpp"
namespace bmh::modern_ui {
// Fictional UI participants, derived solely from the immutable catalogue.
// No engine draw, actual qualification or gameplay random stream is involved.
Json make_demo_opening(const Catalog &, const Json &state, bool created);
// Missing legacy flows are migrated; existing inconsistent flows are rejected.
// Both migration and edits leave the input untouched on rejection.
bool migrate_demo_opening(Json &state, const Catalog &);
std::string edit_demo_opening(Json &state, const Json &action, const Catalog &);
} // namespace bmh::modern_ui
+8 -2
View File
@@ -448,9 +448,15 @@ Json report_match_rows(const Catalog &world, const Json &state, bool other) {
}
return result;
}
Json report_opening_pairs(const Catalog &world) {
Json report_opening_pairs(const Catalog &world, const Json &flow) {
std::vector<const Json *> pool;
for (const auto *league : world.leagues("nation:de"))
if (!flow.is_null()) {
for (const auto &id : flow.at("order")) {
const auto *club = world.find("clubs", id.get<std::string>());
if (!club) throw editor::Error("unknown_demo_draw_club");
pool.push_back(club);
}
} else 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);
+4 -3
View File
@@ -21,9 +21,10 @@ Json report_strength_rows(const Catalog &, const Json &);
// At most 16 clubs from the first German league, independent of report selection.
Json report_indoor_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 &);
// Presentation-only opening pairs. A supplied persisted flow retains its exact
// draw order; omitted flows preserve the legacy catalogue-order projection.
// Goals remain null until a future runtime owns them.
Json report_opening_pairs(const Catalog &, const Json &flow = Json());
// 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);
+6 -6
View File
@@ -81,7 +81,7 @@ void App::entry_begin() {
? "desktop"
: "main";
entry_catalog_ = std::move(next);
renderer_.world(entry_catalog_);
bind_world(entry_catalog_);
start_options_ = {{"duration", 5}, {"difficulty", 3}, {"players", 1},
{"mode", 3}, {"league", true}, {"world", true}};
adding_manager_ = false;
@@ -100,7 +100,7 @@ void App::entry_add() {
if (!source_)
return;
entry_catalog_.reset();
renderer_.world(world_);
bind_world(world_);
entry_source_ = source_.get();
entry_revision_ = snap().revision;
managers_draft_ = snap().state.at("managers");
@@ -125,7 +125,7 @@ void App::entry_add() {
}
void App::entry_cancel() {
entry_catalog_.reset();
renderer_.world(world_);
bind_world(world_);
manager_confirm_ = manager_success_ = manager_picker_ = false;
club_search_.clear();
scene_ = adding_manager_ ? "desktop" : entry_return_scene_;
@@ -200,6 +200,7 @@ void App::entry_confirm() {
result.error);
return;
}
opening_write(*catalog, demo->snapshot().state, valid_desktop(desktop_) ? desktop_ : default_desktop());
publish_world(catalog, std::move(demo));
saved_desktop_ = Json::object();
undo_.clear();
@@ -208,9 +209,8 @@ void App::entry_confirm() {
manager_confirm_ = false;
entry_catalog_.reset();
scene_ = start_options_.value("league", true) ? "opening" : "desktop";
opening_page_ = draw_revealed_ = 0;
draw_playing_ = true;
draw_at_ = 0;
opening_due_ = 0;
opening_io_blocked_ = false;
focus_after_render_.clear();
}
refresh();
+237
View File
@@ -0,0 +1,237 @@
// SPDX-License-Identifier: GPL-3.0-only
// Presentation-only automatic checkpoint. It neither replaces a user save nor
// marks the game clean. The next state is written before the in-memory action
// commits.
fs::path App::opening_progress_path(const Catalog &catalog) const {
const auto id = catalog.manifest().value("id", std::string("none"));
return (config_.userdata.empty() ? root_ / "userdata" : config_.userdata) /
"ui-demo" / content::sha256(id) / "opening-progress.json";
}
void App::opening_write(const Catalog &catalog, const Json &state,
const Json &layout) {
const auto path = opening_progress_path(catalog);
const Json data = {{"schema", "openbmh-ui-opening@1"},
{"world", catalog.manifest().value("id", "")},
{"manifest", content::sha256(catalog.manifest().dump())},
{"state", state},
{"desktop", layout}};
try {
fs::create_directories(path.parent_path());
editor::write_atomic(path, data.dump(2));
} catch (const std::exception &) {
throw editor::Error("Die Saisonvorbereitung konnte nicht gesichert werden. "
"Bitte Schreibrechte prüfen und erneut versuchen.");
}
}
bool App::opening_pending() const {
if (!source_)
return false;
const auto state = snap().state;
const auto &flow = state.at("opening_flow");
return flow.at("created").get<bool>() && flow.at("phase") != "done";
}
void App::opening_restore_startup() {
if (!gui_.available())
return;
if (!config_.state.empty()) {
// Explicit loads supersede an older unfinished preparation of this world.
if (source_ &&
(opening_pending() || fs::exists(opening_progress_path(*world_))))
opening_write(*world_, snap().state,
valid_desktop(desktop_) ? desktop_ : default_desktop());
if (opening_pending()) {
scene_ = "opening";
menu_.clear();
}
return;
}
if (scene_ != "main" && scene_ != "desktop" && scene_ != "opening")
return;
auto catalog = world_;
try {
if (!catalog) {
auto *m = mod(active_mod_);
if (!m || m->type != "Modern" || !m->error.empty())
return;
catalog = Catalog::open(m->file);
}
const auto path = opening_progress_path(*catalog);
if (!fs::exists(path))
return;
if (fs::file_size(path) > 32 * 1024 * 1024)
throw editor::Error("opening_progress_too_large");
const auto data = Json::parse(editor::read_file(path));
if (data.at("schema") != "openbmh-ui-opening@1" ||
data.at("world") != catalog->manifest().at("id") ||
data.at("manifest") != content::sha256(catalog->manifest().dump()) ||
!valid_desktop(data.at("desktop")))
throw editor::Error("invalid_opening_progress");
auto demo = std::make_unique<DemoSource>(catalog);
auto checkpoint = data.at("state");
checkpoint["desktop"] = data.at("desktop");
const auto layout = demo->load_data(std::move(checkpoint), false);
const auto flow = demo->snapshot().state.at("opening_flow");
if (!flow.at("created").get<bool>() || flow.at("phase") == "done")
return;
publish_world(catalog, std::move(demo));
desktop_ = saved_desktop_ = layout;
scene_ = "opening";
menu_.clear();
opening_due_ = 0;
} catch (const std::exception &) {
message("Die gesicherte Saisonvorbereitung konnte nicht geladen werden. "
"Du kannst eine neue Partie beginnen oder einen Spielstand laden.");
}
}
bool App::opening_change(const std::string &kind) {
if (!source_)
return false;
const auto before = snap();
auto next = before.state;
const Json action = {{"kind", kind}};
const auto error = edit_demo_opening(next, action, *world_);
if (!error.empty())
return false;
try {
opening_write(*world_, next,
valid_desktop(desktop_) ? desktop_ : default_desktop());
} catch (const std::exception &failure) {
opening_io_blocked_ = true;
opening_due_ = 0;
message(failure.what());
refresh();
return false;
}
const auto applied =
source_->apply({before.revision, "opening.flow", action});
if (!applied.ok) {
message("Die Vorbereitung hat sich geändert. Bitte erneut versuchen.");
return false;
}
opening_due_ = 0;
opening_io_blocked_ = false;
refresh();
return true;
}
bool App::opening_action(const std::string &action, Rml::Element *) {
if (scene_ != "opening" || !menu_.empty() || !popup_.empty())
return false;
if (action == "close")
return true;
std::string kind;
if (action == "opening-next")
kind = "next";
else if (action == "opening-play")
kind = opening_io_blocked_ &&
snap().state.at("opening_flow").at("playing").get<bool>()
? "reveal"
: "toggle";
else if (action == "opening-all")
kind = "skip";
else if (action == "opening-finish") {
const auto phase =
snap().state.at("opening_flow").at("phase").get<std::string>();
if (phase == "done") {
scene_ = "desktop";
opening_due_ = 0;
refresh();
return true;
}
kind = "finish";
} else
return false;
if (!opening_change(kind))
return true;
const auto phase =
snap().state.at("opening_flow").at("phase").get<std::string>();
if (phase == "done") {
scene_ = "desktop";
focus_after_render_.clear();
} else
focus_after_render_ = phase == "overview" ? "opening-finish"
: phase == "draw" ? "opening-play"
: "opening-next";
return true;
}
bool App::opening_event(Rml::Event &event) {
if (scene_ != "opening" || !menu_.empty() || !popup_.empty())
return false;
if ((event.GetType() == "keydown" &&
event.GetParameter<int>("key_identifier", 0) == Rml::Input::KI_ESCAPE) ||
event.GetType() == "contextmenu" ||
(event.GetType() == "mouseup" &&
event.GetParameter<int>("button", 0) == 1)) {
event.StopImmediatePropagation();
return true;
}
return false;
}
void App::opening_tick() {
if (scene_ != "opening" || !source_ || !menu_.empty() || !popup_.empty() ||
opening_io_blocked_)
return;
const auto flow = snap().state.at("opening_flow");
if (flow.at("phase") != "draw" || !flow.at("playing").get<bool>()) {
opening_due_ = 0;
return;
}
if (!(SDL_GetWindowFlags(video_.window) & SDL_WINDOW_INPUT_FOCUS)) {
opening_change("pause");
return;
}
const auto now = SDL_GetTicks64();
if (!opening_due_)
opening_due_ = now + 900;
if (now < opening_due_)
return;
if (opening_change("reveal")) {
if (snap().state.at("opening_flow").at("phase") == "overview")
focus_after_render_ = "opening-finish";
opening_due_ = SDL_GetTicks64() + 900;
}
}
void App::handle_event(SDL_Event &event) {
if (event.type == SDL_QUIT) {
if (front_busy_) {
front_feedback_ = "Bitte den laufenden Import abwarten.";
dirty_ = true;
} else if (source_ && scene_ != "main" && scene_ != "mods") {
quit_closes_app_ = true;
dispatch("context-quit", nullptr);
} else
closed_ = true;
return;
}
if (event.type == SDL_WINDOWEVENT) {
if (event.window.event == SDL_WINDOWEVENT_FOCUS_LOST) {
desktop_cancel_drag();
if (scene_ == "opening" && source_ && !opening_io_blocked_ &&
snap().state.at("opening_flow").at("phase") == "draw" &&
snap().state.at("opening_flow").at("playing").get<bool>())
opening_change("pause");
}
resize();
}
int w, h, pw, ph;
SDL_GetWindowSize(video_.window, &w, &h);
video_.drawable_size(pw, ph);
if (w > 0 && h > 0) {
if (event.type == SDL_MOUSEMOTION) {
event.motion.x = int(double(event.motion.x) * pw / w);
event.motion.y = int(double(event.motion.y) * ph / h);
}
if (event.type == SDL_MOUSEBUTTONDOWN || event.type == SDL_MOUSEBUTTONUP) {
event.button.x = int(double(event.button.x) * pw / w);
event.button.y = int(double(event.button.y) * ph / h);
context_->ProcessMouseMove(event.button.x, event.button.y,
RmlSDL::GetKeyModifierState());
}
}
RmlSDL::InputEventHandler(context_, video_.window, event);
dirty_ = true;
}
void App::pump_events() {
SDL_Event event;
while (SDL_PollEvent(&event))
handle_event(event);
}
+259
View File
@@ -0,0 +1,259 @@
// SPDX-License-Identifier: GPL-3.0-only
// Read-only presentation of canonical DemoSource opening_flow. No extra App
// API. Timer, phase changes, persistence, keyboard handling and completion
// belong to the controller. No participants or pairings are invented by the
// renderer.
std::string App::render_opening() {
const auto state = snap().state;
const auto &flow = state.at("opening_flow");
const auto phase = flow.at("phase").get<std::string>();
const bool playing = flow.value("playing", false) && !opening_io_blocked_;
std::set<std::string> own;
for (const auto &m : state.at("managers"))
own.insert(m.value("club", ""));
std::vector<const Json *> order;
std::set<std::string> seen;
for (const auto &id : flow.at("order")) {
if (!id.is_string())
continue;
const auto key = id.get<std::string>();
if (const auto *c = world_->find("clubs", key);
c && seen.insert(key).second)
order.push_back(c);
}
const int total = int(order.size()), pairs = total / 2;
const int revealed = std::clamp(flow.value("revealed", 0), 0, total);
const auto date = state.value(
"date", world_->manifest().value("start_date", std::string()));
std::string season = "–";
if (date.size() >= 4 &&
std::all_of(date.begin(), date.begin() + 4,
[](char c) { return c >= '0' && c <= '9'; })) {
const int year = std::stoi(date.substr(0, 4));
const int following = (year + 1) % 100;
season = std::to_string(year) + "/" + (following < 10 ? "0" : "") +
std::to_string(following);
}
const auto owned = [&](const Json *c) {
return c && own.contains(c->value("id", ""));
};
const auto heading = [&](const std::string &title,
const std::string &subtitle,
const std::string &detail) {
return "<header class=\"opening-heading\"><div><h2><span>" + esc(title) +
"</span></h2><p><span>" + esc(subtitle) +
"</span></p></div>"
"<span class=\"opening-heading-detail\">" +
esc(detail) + "</span></header>";
};
const auto note = [](const std::string &text) {
return "<span class=\"opening-demo-note\">" + esc(text) + "</span>";
};
const auto pair = [&](int index, int known, int logo_size,
const std::string &extra) {
if (index < 0 || index >= pairs)
return std::string();
const auto *home = order[size_t(index * 2)],
*away = order[size_t(index * 2 + 1)];
const auto side = [&](const Json *c, bool home_side, bool visible) {
const auto name = visible ? world_->name(*c)
: home_side ? "Heim"
: "Noch nicht gezogen";
const auto text = "<span class=\"opening-pair-name " +
std::string(visible ? "" : "opening-unknown") +
"\" title=\"" + esc(name) + "\"><span>" + esc(name) +
"</span></span>";
const auto logo = visible ? "<span class=\"opening-pair-crest\">" +
crest(c, logo_size) + "</span>"
: "";
return "<span class=\"opening-pair-side " +
std::string(home_side ? "home" : "away") + "\">" +
(home_side ? text + logo : logo + text) + "</span>";
};
return "<div class=\"opening-pair-row " + extra +
(owned(home) || owned(away) ? " own-pair" : "") +
"\" data-index=\"" + std::to_string(index) + "\" data-home=\"" +
esc(home->value("id", "")) + "\" data-away=\"" +
esc(away->value("id", "")) +
"\">"
"<span class=\"opening-pair-number\"><span>" +
std::to_string(index + 1) + "</span></span>" +
side(home, true, known > 0) +
"<span class=\"opening-pair-versus\"><span>–</span></span>" +
side(away, false, known > 1) +
"<span class=\"opening-pair-counter\" "
"aria-hidden=\"true\"></span></div>";
};
const bool entrants_page =
phase == "uefa" || phase == "champions" || phase == "winners";
std::string body, titlebar;
if (entrants_page) {
const int page = phase == "uefa" ? 0 : phase == "champions" ? 1 : 2;
const std::array<const char *, 3> titles = {"UEFA-Cup", "Champions League",
"Europapokal der Pokalsieger"};
std::vector<const Json *> entrants;
std::set<std::string> entered;
const auto &ids = flow.at("entrants").at(phase);
for (const auto &id : ids) {
if (!id.is_string())
continue;
const auto key = id.get<std::string>();
if (const auto *c = world_->find("clubs", key);
c && entered.insert(key).second)
entrants.push_back(c);
}
const bool german =
!entrants.empty() &&
std::all_of(entrants.begin(), entrants.end(), [](const auto *c) {
return c->value("nation", "") == "nation:de";
});
titlebar = german ? "Deutsche Teams" : "Teilnehmende Teams";
body = "<section class=\"opening-layout opening-entrants\" data-phase=\"" +
phase + "\">" +
heading(titles[size_t(page)], titlebar + " · Saison " + season,
std::to_string(page + 1) + " / 3") +
"<div class=\"opening-entrant-grid\" id=\"opening-entrants\">";
if (entrants.empty()) {
body += "<div class=\"opening-empty-entrants\"><h3><span>Keine "
"Teilnehmer eingetragen</span></h3>"
"<p><span>Für diesen Wettbewerb sind in dieser Demo-Welt keine "
"Vereine vorgesehen.</span></p></div>";
} else {
const bool single = entrants.size() == 1;
const auto card = [&](const Json *c) {
return "<article class=\"opening-entrant " +
std::string(single ? "single-entrant " : "") +
(owned(c) ? "own-entrant" : "") + "\" data-entrant-club=\"" +
esc(c->value("id", "")) + "\">" +
"<div class=\"opening-entrant-crest\">" +
crest(c, single ? 620 : 360) +
"</div>"
"<h3><span>" +
esc(world_->name(*c)) + "</span></h3>" +
(owned(c) ? "<p><span>Dein Verein</span></p>" : "") +
"</article>";
};
body += "<div class=\"opening-entrant-content " +
std::string(single ? "single-entrant-content" : "") + "\">";
if (single) {
body += card(entrants.front());
} else {
const size_t rows = std::max(size_t(2), (entrants.size() + 1) / 2);
for (size_t row = 0; row < rows; ++row) {
body += "<div class=\"opening-entrant-row\">";
for (size_t column = 0; column < 2; ++column) {
const size_t index = row * 2 + column;
body += index < entrants.size()
? card(entrants[index])
: "<div class=\"opening-entrant-spacer\" "
"aria-hidden=\"true\"></div>";
}
body += "</div>";
}
}
body += "</div>";
}
body += "</div><nav class=\"opening-actions\">" +
note("Fiktive Demo-Qualifikation") +
btn("opening-next", "Weiter", {}, "id=\"opening-next\"") +
"</nav></section>";
} else if (phase == "draw") {
titlebar = "DFB-Pokal";
body =
"<section class=\"opening-layout opening-draw\" data-phase=\"draw\">" +
heading("1. Runde", "DFB-Pokal · Saison " + season,
std::to_string(revealed) + " / " + std::to_string(total) +
" Mannschaften") +
"<div class=\"opening-draw-scene " +
std::string(playing ? "is-drawing" : "") + "\">";
const auto art = renderer_.image("art.cup-draw-v1.png", false, 1800);
if (!art.token.empty() && art.width > 0 && art.height > 0) {
const double ratio = double(art.width) / art.height;
const double width = std::min(2608.0, 846.0 * ratio),
height = width / ratio;
body += "<div class=\"opening-draw-art\" role=\"img\" "
"aria-label=\"Fiktive Pokal-Auslosung am Tisch mit Glaskugel, "
"Loszieher und Pressefotografen\" style=\"width:" +
scalar(width) + "dp;height:" + scalar(height) + "dp;\">" +
picture(art, width, height, false) + "</div>";
} else {
body += "<p class=\"opening-art-missing\"><span>Die Illustration der "
"Auslosung ist nicht verfügbar.</span></p>";
}
body +=
"<span id=\"opening-draw-indicator\" class=\"opening-draw-indicator " +
std::string(playing ? "is-playing" : "is-paused") +
"\" aria-hidden=\"true\"></span></div>"
"<div id=\"opening-current-pair\" class=\"opening-current-pair\" "
"aria-live=\"polite\" aria-atomic=\"true\">";
if (pairs) {
const int current = std::min(pairs - 1, std::max(0, (revealed - 1) / 2));
const int known = std::clamp(revealed - current * 2, 0, 2);
body += pair(current, known, 66, "current") +
"</div><section class=\"opening-recent\" aria-label=\"Zuletzt "
"gezogene Paarungen\">";
const int first = std::max(0, current - 3);
for (int i = first; i < current; ++i)
body += "<div class=\"opening-recent-row\" style=\"top:" +
std::to_string((i - first) * 181) + "dp;\">" +
pair(i, 2, 42, "recent") + "</div>";
body += "</section>";
} else {
body += "<p class=\"opening-no-pairs\"><span>Für diese Welt ist keine "
"vollständige Paarung vorhanden.</span></p></div>";
}
body +=
"<nav class=\"opening-actions\">" +
note(total % 2
? "Fiktive Demo-Auslosung · 1 Verein ohne vollständige Paarung"
: "Fiktive Demo-Auslosung") +
btn("opening-play",
opening_io_blocked_ ? "Erneut versuchen"
: playing ? "Pause"
: "Fortsetzen",
{},
"id=\"opening-play\" aria-pressed=\"" +
std::string(playing ? "true" : "false") + "\" " +
(revealed >= total ? "disabled" : "")) +
btn("opening-all", "Alle Paarungen anzeigen", {},
"id=\"opening-all\"") +
"</nav></section>";
} else {
titlebar = "DFB-Pokal";
body = "<section class=\"opening-layout opening-overview\" data-phase=\"" +
esc(phase) + "\">" +
heading("DFB-Pokal", "1. Runde · Saison " + season,
std::to_string(pairs) +
(pairs == 1 ? " Paarung" : " Paarungen")) +
"<div id=\"opening-overview\" class=\"opening-pair-columns\">";
if (!pairs) {
body += "<div class=\"opening-empty-overview\"><p><span>Für diese Welt "
"sind keine vollständigen Paarungen vorhanden.</span></p></div>";
} else {
const int columns = pairs > 1 ? 2 : 1,
per_column = (pairs + columns - 1) / columns;
for (int column = 0; column < columns; ++column) {
const int first = column * per_column,
last = std::min(pairs, first + per_column);
body += "<section class=\"opening-overview-column " +
std::string(columns == 1 ? "single-column" : "") +
"\" aria-label=\"Paarungen " + std::to_string(first + 1) +
" bis " + std::to_string(last) +
"\" style=\"left:" + std::to_string(column * 1323) +
"dp;\"><div class=\"opening-overview-list\">";
for (int i = first; i < last; ++i)
body += "<div class=\"opening-overview-row\">" +
pair(i, 2, 36, "compact") + "</div>";
body += "</div></section>";
}
}
body += "</div><nav class=\"opening-actions\">" +
note(total % 2 ? "Fiktive Demo-Auslosung · ohne Paarung: " +
world_->name(*order.back())
: "Fiktive Demo-Auslosung") +
btn("opening-finish", "Weiter zum Desktop", "primary",
"id=\"opening-finish\"") +
"</nav></section>";
}
return window(titlebar, body, false);
}
+5
View File
@@ -247,8 +247,13 @@ void App::files_load() {
if (!files_bound())
throw editor::Error("Die aktive Karriere wurde inzwischen geändert.");
const auto selected_id = files_entry_->id, selected_name = files_entry_->name;
if (next->snapshot().state.at("opening_flow").at("phase") != "done" ||
fs::exists(opening_progress_path(*world_)))
opening_write(*world_, next->snapshot().state, layout);
ticket_.reset();
source_ = std::move(next);
opening_due_ = 0;
opening_io_blocked_ = false;
desktop_ = std::move(layout);
saved_desktop_ = desktop_;
reset_files();
+1 -1
View File
@@ -3,7 +3,7 @@ void App::front_invalidate_world() {
ticket_.reset();
source_.reset();
world_.reset();
renderer_.world(nullptr);
bind_world(nullptr);
reset_files();
reset_settings();
reset_news();
+25 -6
View File
@@ -7,6 +7,7 @@
#include "modern/ui/demo_finance.hpp"
#include "modern/ui/demo_lineup.hpp"
#include "modern/ui/demo_news.hpp"
#include "modern/ui/demo_opening.hpp"
#include "modern/ui/demo_reports.hpp"
#include "modern/ui/demo_settings.hpp"
#include "modern/ui/demo_sports.hpp"
@@ -226,6 +227,8 @@ DemoSource::DemoSource(std::shared_ptr<const Catalog> catalog)
throw editor::Error("invalid_demo_news");
if (!migrate_demo_settings(state_))
throw editor::Error("invalid_demo_settings");
if (!migrate_demo_opening(state_, *catalog_))
throw editor::Error("Ungültige Saisonvorbereitung.");
saved_ = state_;
}
Snapshot DemoSource::snapshot() const { return {revision_, catalog_, state_}; }
@@ -294,6 +297,7 @@ ActionResult DemoSource::apply(const Action &action) {
? "pending"
: "complete";
next["opening_created"] = false;
next["opening_flow"] = make_demo_opening(*catalog_, next, action.value.at("setup").at("league").get<bool>());
}
} else if (action.kind == "environment" || action.kind == "advertising" ||
action.kind == "toto") {
@@ -364,12 +368,25 @@ 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") {
if (!action.value.is_string())
else if (action.kind == "opening.flow") {
const auto error = edit_demo_opening(next, action.value, *catalog_);
if (!error.empty()) return {false, revision_, error};
} else if (action.kind == "opening") {
if (!action.value.is_string() ||
(action.value.get<std::string>() != "complete" && action.value.get<std::string>() != "pending"))
return {false, revision_, "invalid_opening_state"};
next["opening"] = action.value;
if (action.value == "complete")
if (!migrate_demo_opening(next, *catalog_)) return {false, revision_, "Ungültige gespeicherte Saisonvorbereitung."};
if (action.value.get<std::string>() == "complete") {
// Old callers may finish directly, without stepping the new UI flow.
auto &flow = next.at("opening_flow");
flow["created"] = true; flow["phase"] = "done";
flow["revealed"] = flow.at("order").size(); flow["playing"] = false;
next["opening"] = "complete";
next["opening_created"] = true;
} else {
next["opening"] = "pending"; next["opening_created"] = false;
next["opening_flow"] = make_demo_opening(*catalog_, next, true);
}
} else if (action.kind == "preferences") {
if (!preferences(action.value))
return {false, revision_, "invalid_preferences"};
@@ -405,7 +422,7 @@ bool DemoSource::mark_saved(uint64_t expected_revision) {
saved_ = state_;
return true;
}
Json DemoSource::load_data(Json data) {
Json DemoSource::load_data(Json data, bool saved) {
if (data.value("schema", "") != "openbmh-ui-demo@1" ||
data.value("world", "") != catalog_->manifest().value("id", ""))
throw editor::Error("wrong_demo_world");
@@ -471,13 +488,15 @@ Json DemoSource::load_data(Json data) {
throw editor::Error("invalid_demo_news");
if (!migrate_demo_settings(data))
throw editor::Error("invalid_demo_settings");
if (!migrate_demo_opening(data, *catalog_))
throw editor::Error("Ungültige oder inkonsistente Saisonvorbereitung.");
auto next = data;
auto desktop = next.value("desktop", Json::object());
if (!migrate_desktop(desktop))
throw editor::Error("invalid_demo_desktop");
next.erase("desktop");
state_ = std::move(next);
saved_ = state_;
if (saved) saved_ = state_;
++revision_;
return desktop;
}
+2 -1
View File
@@ -49,7 +49,8 @@ public:
Json read_statistics(const Json &) const override;
void save(const fs::path &, const Json &desktop);
Json load(const fs::path &);
Json load_data(Json);
// UI continuation may retain the previous explicit-save clean baseline.
Json load_data(Json, bool saved = true);
bool mark_saved(uint64_t expected_revision);
bool dirty() const { return state_ != saved_; }
+1 -1
View File
@@ -39,7 +39,7 @@ std::string App::render_reports(const std::string &mode) {
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_)
const auto rows = matches ? (opening ? report_opening_pairs(*world_, snapshot.state.at("opening_flow"))
: report_match_rows(*world_, state, mode == "other"))
: strengths ? report_strength_rows(*world_, state)
: report_table_rows(*world_, state);
-102
View File
@@ -72,108 +72,6 @@ std::string App::render_desktop() {
}
return out + "</div>";
}
std::string App::render_opening() {
const std::array<const char *, 3> names = {"UEFA-Cup", "Champions League",
"Europapokal der Pokalsieger"};
const auto german = world_->clubs("comp:de-1");
std::vector<const Json *> pool;
for (auto *l : world_->leagues("nation:de"))
for (auto *c : world_->clubs(l->value("id", "")))
if (pool.size() < 64)
pool.push_back(c);
std::string body;
if (opening_page_ < 3) {
body = "<h2 style=\"font-size:46dp;\">" +
std::string(names[size_t(opening_page_)]) +
"</h2><p class=\"small\" style=\"margin-top:16dp;\">Deutsche Teams "
"· Saison " +
esc(snap().state.value("date", std::string()).substr(0, 4)) + "</p>";
const int count = opening_page_ == 0 ? 4 : 1;
for (int i = 0; i < count && size_t(i) < german.size(); ++i) {
const auto *c = german[size_t((i + opening_page_) % int(german.size()))];
const bool single = count == 1;
const int x = single ? 704 : 150 + (i % 2) * 1178,
y = single ? 360 : 180 + (i / 2) * 730;
body += "<div class=\"panel center\" style=\"position:absolute;" +
rect(x, y, single ? 1200 : 1128, single ? 1000 : 680) +
"padding:65dp;\">" + crest(c, single ? 620 : 360) +
"<h3 style=\"margin-top:26dp;font-size:" +
std::to_string(single ? 64 : 50) + "dp;font-weight:normal;\">" +
esc(world_->name(*c)) + "</h3></div>";
}
body +=
"<div class=\"bottom-controls\" style=\"justify-content:flex-end;\">" +
btn("opening-next", "Weiter", "primary",
"style=\"flex:none;width:390dp;\"") +
"</div>";
} else {
const auto pair = [&](int index, int known, int size) {
const size_t a = size_t(index * 2), b = a + 1;
if (b >= pool.size())
return std::string();
const auto label_for = [&](const Json *c, bool home, bool visible) {
const auto text = "<span class=\"opening-pair-name\">" +
(visible ? esc(world_->name(*c)) : home ? "Heim" : "Noch nicht gezogen") + "</span>";
const auto logo = visible ? crest(c, size) : "";
return "<span class=\"opening-pair-side " + std::string(home ? "home" : "away") + "\">" +
(home ? text + logo : logo + text) + "</span>";
};
return "<div class=\"opening-pair-row " + std::string(size == 36 ? "compact" : size == 66 ? "current" : "") +
"\"><span class=\"opening-pair-number\"><span>" + std::to_string(index + 1) + "</span></span>" +
label_for(pool[a], true, known > 0) + "<span class=\"opening-pair-versus\"><span>–</span></span>" +
label_for(pool[b], false, known > 1) + "<span class=\"opening-pair-counter\" aria-hidden=\"true\"></span></div>";
};
body = "<h2 style=\"font-size:46dp;\">" +
std::string(opening_page_ == 3 ? "1. Runde" : "DFB-Pokal") +
"</h2><p class=\"small\" style=\"margin-top:16dp;\">" +
(opening_page_ == 3 ? "DFB-Pokal · Saison " : "1. Runde · Saison ") +
esc(snap().state.value("date", std::string()).substr(0, 4)) + "</p>";
if (opening_page_ == 3) {
body += "<span class=\"small\" "
"style=\"position:absolute;right:0;top:20dp;\">" +
std::to_string(draw_revealed_) +
" / 64 Mannschaften</span><div style=\"position:absolute;" +
rect(0, 138, 2608, 850) + "\">" +
img("art.cup-draw-v1.png", 2608, 850, false, false, 1800) +
"</div>";
const int current = std::max(0, (draw_revealed_ - 1) / 2),
known = draw_revealed_ ? draw_revealed_ - current * 2 : 0;
body += "<div class=\"panel\" style=\"position:absolute;" +
rect(130, 1026, 2352, 126) +
"padding:10dp 28dp;font-size:38dp;\">" +
pair(current, known, 66) + "</div>";
for (int i = std::max(0, current - 3); i < current; ++i)
body +=
"<div style=\"position:absolute;" +
rect(158, 1190 + (i - std::max(0, current - 3)) * 155, 2296, 145) +
"border-bottom:2dp var(--border);\">" + pair(i, 2, 42) + "</div>";
body += "<div class=\"bottom-controls\" "
"style=\"justify-content:flex-end;\">" +
btn("opening-play", draw_playing_ ? "Pause" : "Fortsetzen", {},
"style=\"flex:none;width:390dp;\"") +
btn("opening-all", "Alle Paarungen anzeigen", {},
"style=\"flex:none;width:600dp;\"") +
"</div>";
} else {
for (int column = 0; column < 2; ++column) {
body += "<div class=\"panel\" style=\"position:absolute;" +
rect(column * 1323, 154, 1289, 1500) + "padding:12dp 18dp;\">";
for (int row = 0; row < 16; ++row)
body += "<div style=\"height:92dp;font-size:27dp;border-bottom:1dp "
"var(--border);\">" +
pair(column * 16 + row, 2, 36) + "</div>";
body += "</div>";
}
body += "<div class=\"bottom-controls\" "
"style=\"justify-content:flex-end;\">" +
btn("opening-finish", "Weiter zum Desktop", "primary",
"style=\"flex:none;width:550dp;\"") +
"</div>";
}
}
return window(opening_page_ < 3 ? "Deutsche Teams" : "DFB-Pokal", body,
false);
}
std::string App::render_camp() {
const auto index_file =
Json::parse(editor::read_file(gui_.root() / "gui-assets.json"));
+33 -44
View File
@@ -11,6 +11,7 @@
#include "modern/ui/demo_advertising.hpp"
#include "modern/ui/demo_toto.hpp"
#include "modern/ui/demo_reports.hpp"
#include "modern/ui/demo_opening.hpp"
#include "modern/ui/demo_sports.hpp"
#include "modern/ui/demo_lineup.hpp"
#include "modern/ui/demo_transfer.hpp"
@@ -428,10 +429,10 @@ class App final : public Rml::EventListener {
bool context_open_ = false, context_dirty_ = false;
std::string context_id_;
int context_x_ = 0, context_y_ = 0;
int opening_page_ = 0, draw_revealed_ = 0;
uint64_t opening_due_ = 0;
bool opening_io_blocked_ = false;
int last_tactic_ = 0;
bool draw_playing_ = true;
uint64_t draw_at_ = 0;
#include "modern/ui/settings_state.inc"
#include "modern/ui/widgets_state.inc"
#include "modern/ui/files_state.inc"
@@ -589,6 +590,12 @@ class App final : public Rml::EventListener {
return &m;
return nullptr;
}
void bind_world(std::shared_ptr<const Catalog> next) {
renderer_.world(std::move(next));
files_default_key_.clear();
files_default_picture_ = Picture();
files_default_pending_ = false;
}
void load_world(const fs::path &file) {
auto next = Catalog::open(file);
auto demo = std::make_unique<DemoSource>(next);
@@ -599,9 +606,11 @@ class App final : public Rml::EventListener {
reset_settings();
reset_files();
ticket_.reset();
renderer_.world(next);
bind_world(next);
world_ = std::move(next);
source_ = std::move(demo);
opening_due_ = 0;
opening_io_blocked_ = false;
lineup_drag_ = Json(); lineup_drag_world_.reset(); lineup_selected_.clear(); lineup_ignore_click_ = false;
lineup_pitch_ = true; lineup_data_ = lineup_page_ = 0; lineup_side_ = "formations";
transfer_view_ = Json::object(); transfer_draft_ = transfer_search_draft_ = Json();
@@ -756,6 +765,16 @@ class App final : public Rml::EventListener {
std::string render_newgame();
std::string render_manager();
std::string render_opening();
fs::path opening_progress_path(const Catalog &) const;
void opening_write(const Catalog &, const Json &, const Json &);
void opening_restore_startup();
bool opening_pending() const;
bool opening_change(const std::string &);
bool opening_action(const std::string &, Rml::Element *);
bool opening_event(Rml::Event &);
void opening_tick();
void handle_event(SDL_Event &);
void pump_events();
std::string render_menu(const std::string &);
void dispatch(const std::string &, Rml::Element *);
void change(Rml::Element *);
@@ -810,6 +829,11 @@ class App final : public Rml::EventListener {
needs_render_ = true;
}
void render() {
if (scene_ == "desktop" && !files_capturing_ && opening_pending()) {
scene_ = "opening";
menu_.clear();
opening_due_ = 0;
}
news_before_render();
fixture_half_width_ = -1.f;
almanac_list_width_ = -1.f;
@@ -1238,6 +1262,7 @@ public:
// A capture/CLI override is visual only and never edits a career.
ui_preferences_["theme"]=theme_;
}
opening_restore_startup();
if (scene_ == "manager" && selections_["manager-name"].empty())
selections_["manager-name"] = "Alex Berger";
doc_->Show();
@@ -1278,15 +1303,7 @@ public:
}
while (!closed_) {
front_poll();
if (scene_ == "opening" && opening_page_ == 3 && draw_revealed_ < 64 &&
draw_playing_ && SDL_GetTicks64() >= draw_at_ &&
(SDL_GetWindowFlags(video_.window) & SDL_WINDOW_INPUT_FOCUS)) {
++draw_revealed_;
draw_at_ = SDL_GetTicks64() + 900;
if (draw_revealed_ == 64)
opening_page_ = 4;
refresh();
}
opening_tick();
if (needs_render_ || dirty_)
frame();
SDL_Event event;
@@ -1294,37 +1311,7 @@ public:
int(std::clamp(context_->GetNextUpdateDelay(), 0.0, .2) * 1000);
bool got = SDL_WaitEventTimeout(&event, timeout) != 0;
while (got) {
if (event.type == SDL_QUIT) {
if(front_busy_){front_feedback_="Bitte den laufenden Import abwarten.";dirty_=true;}
else if (source_ && scene_ != "main" && scene_ != "mods") {
quit_closes_app_=true;
dispatch("context-quit", nullptr);
} else
closed_ = true;
} else {
if (event.type == SDL_WINDOWEVENT) {
if(event.window.event==SDL_WINDOWEVENT_FOCUS_LOST)desktop_cancel_drag();
resize();
}
int w, h, pw, ph;
SDL_GetWindowSize(video_.window, &w, &h);
video_.drawable_size(pw, ph);
if (w > 0 && h > 0) {
if (event.type == SDL_MOUSEMOTION) {
event.motion.x = int(double(event.motion.x) * pw / w);
event.motion.y = int(double(event.motion.y) * ph / h);
}
if (event.type == SDL_MOUSEBUTTONDOWN ||
event.type == SDL_MOUSEBUTTONUP) {
event.button.x = int(double(event.button.x) * pw / w);
event.button.y = int(double(event.button.y) * ph / h);
context_->ProcessMouseMove(event.button.x, event.button.y,
RmlSDL::GetKeyModifierState());
}
}
RmlSDL::InputEventHandler(context_, video_.window, event);
dirty_ = true;
}
handle_event(event);
got = SDL_PollEvent(&event) != 0;
}
if (context_->GetNextUpdateDelay() <= 0)
@@ -1335,6 +1322,8 @@ public:
};
#include "modern/ui/entry_controls.inc"
#include "modern/ui/entry_screens.inc"
#include "modern/ui/entry_opening_controls.inc"
#include "modern/ui/entry_opening_screens.inc"
#include "modern/ui/controls.inc"
#include "modern/ui/widgets_screens.inc"
#include "modern/ui/widgets_controls.inc"
+2
View File
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "modern/ui/desktop.hpp"
#include "modern/ui/model.hpp"
#include "modern/ui/demo_opening.hpp"
#include <iostream>
#include <stdexcept>
@@ -292,6 +293,7 @@ void club_migration(const Fixture &fixture) {
reference["edits"]["setup"] = setup();
reference["opening"] = "pending";
reference["opening_created"] = false;
reference["opening_flow"] = make_demo_opening(*fixture.world, reference, true);
require(
reference == actual,
"Start diverges from established club-change presentation migrations");
+395
View File
@@ -0,0 +1,395 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "modern/ui/demo_opening.hpp"
#include "modern/ui/demo_reports.hpp"
#include "modern/ui/desktop.hpp"
#include "modern/ui/model.hpp"
#include <array>
#include <iostream>
#include <set>
#include <stdexcept>
using namespace bmh::modern_ui;
namespace {
void require(bool value, const char *message) {
if (!value)
throw std::runtime_error(message);
}
struct Fixture {
fs::path root;
std::shared_ptr<const Catalog> world;
Fixture(int top, int lower)
: root(fs::temp_directory_path() /
bmh::editor::new_id("openbmh-opening-test-")) {
fs::create_directories(root / "world");
const auto write = [&](const char *name, const Json &data) {
bmh::editor::write_atomic(root / name, data.dump());
};
write("manifest.json", {{"format", "openbmh-world"},
{"kind", "world"},
{"format_version", "1.1"},
{"id", "world:synthetic-opening"},
{"start_date", "2032-07-01"},
{"requires", {"editor:world-v1"}},
{"x-editor", {{"profile", "editor-world-v1"}}}});
write("world/nations.json",
{{"items",
{{{"id", "nation:de"}, {"name", "Synthetic DE"}},
{{"id", "nation:es"}, {"name", "Synthetic ES"}}}}});
// Authored lower league first: top-tier selection must not guess from row0.
write("world/competitions.json", {{"items",
{{{"id", "league:lower"},
{"nation", "nation:de"},
{"type", "league"},
{"tier", 2}},
{{"id", "league:top"},
{"nation", "nation:de"},
{"type", "league"},
{"tier", 1}},
{{"id", "league:foreign"},
{"nation", "nation:es"},
{"type", "league"},
{"tier", 1}}}}});
Json clubs = Json::array();
for (const auto &[name, count] : std::vector<std::pair<std::string, int>>{
{"lower", lower}, {"top", top}})
for (int index = 0; index < count; ++index)
clubs.push_back(
{{"id", "club:" + name + "-" + std::to_string(index)},
{"name", "Synthetic " + name + " " + std::to_string(index)},
{"nation", "nation:de"},
{"competition", "league:" + name}});
clubs.push_back({{"id", "club:foreign"},
{"name", "Foreign"},
{"nation", "nation:es"},
{"competition", "league:foreign"}});
clubs.push_back({{"id", "club:de-in-foreign-league"},
{"name", "DE outside DE leagues"},
{"nation", "nation:de"},
{"competition", "league:foreign"}});
write("world/clubs.json", {{"items", clubs}});
write("world/players.json", {{"items", Json::array()}});
world = Catalog::open(root);
}
~Fixture() {
std::error_code error;
fs::remove_all(root, error);
}
};
Json state(const Catalog &world, bool created) {
Json result = {{"opening", created ? "pending" : "complete"},
{"opening_created", false},
{"unrelated", {1, 2, 3}}};
result["opening_flow"] = make_demo_opening(world, result, created);
return result;
}
void edit(Json &value, const char *kind, const Catalog &world) {
require(edit_demo_opening(value, {{"kind", kind}}, world).empty(),
"Valid preparation action rejected");
}
void rejected(Json &value, const Json &action, const Catalog &world) {
const auto before = value;
const auto error = edit_demo_opening(value, action, world);
require(!error.empty() && error.find(' ') != error.npos && value == before,
"Rejected flow edit mutated input or returned unreadable error");
}
void selection() {
Fixture fixture(18, 52);
const auto before_clubs = fixture.world->rows("clubs");
const auto first = make_demo_opening(*fixture.world, Json::object(), false);
require(first == make_demo_opening(*fixture.world, Json::object(), false),
"Opening order depends on runtime random state");
require(first.at("phase") == "done" && first.at("created") == false &&
first.at("playing") == false && first.at("revealed") == 64,
"Default preparation is not uncreated/completed");
const auto &order = first.at("order");
std::set<std::string> ids;
for (const auto &id : order)
require(fixture.world->manageable(id.get<std::string>()) &&
ids.insert(id.get<std::string>()).second,
"Draw has foreign/unknown/duplicate club");
require(ids.size() == 64 && !ids.contains("club:lower-46") &&
!ids.contains("club:foreign") &&
!ids.contains("club:de-in-foreign-league"),
"Draw pool does not respect max64 DE/DE-league membership");
// Independent expected Fisher-Yates result from the unchanged Gold seed/LCG.
const std::array<int, 64> expected = {
19, 57, 60, 61, 47, 37, 41, 33, 12, 21, 9, 35, 15, 28, 1, 31,
48, 4, 25, 32, 17, 52, 3, 27, 7, 14, 23, 51, 46, 54, 42, 8,
26, 56, 29, 44, 34, 10, 45, 24, 5, 22, 11, 49, 43, 18, 59, 63,
50, 0, 58, 55, 2, 30, 39, 16, 53, 6, 62, 20, 13, 36, 38, 40};
for (size_t index = 0; index < expected.size(); ++index) {
const int source = expected[index];
const auto id = source < 18 ? "club:top-" + std::to_string(source)
: "club:lower-" + std::to_string(source - 18);
require(order[index].get<std::string>() == id,
"LCG/Fisher-Yates order differs from Gold");
}
const auto &entrants = first.at("entrants");
std::set<std::string> roles;
require(entrants.at("uefa").size() == 4 &&
entrants.at("champions").size() == 1 &&
entrants.at("winners").size() == 1,
"Fictional top-league roles have wrong counts");
for (const auto &group : {"uefa", "champions", "winners"})
for (const auto &id : entrants.at(group))
require(roles.insert(id.get<std::string>()).second,
"Entrants appear in multiple roles");
require(entrants.at("uefa")[0] == "club:top-0" &&
entrants.at("champions")[0] == "club:top-4" &&
entrants.at("winners")[0] == "club:top-5",
"Entrants were inferred from a lower/foreign league");
require(fixture.world->rows("clubs") == before_clubs,
"Preparation changed immutable world IDs");
}
void tiny_worlds() {
for (int count : {0, 1, 2, 3, 5, 6}) {
Fixture fixture(count, 0);
auto current = state(*fixture.world, true);
const size_t expected = size_t(count / 2 * 2);
require(current.at("opening_flow").at("order").size() == expected,
"Tiny world invented or duplicated a draw club");
edit(current, "next", *fixture.world);
edit(current, "next", *fixture.world);
edit(current, "next", *fixture.world);
if (!expected)
require(current.at("opening_flow").at("phase") == "overview" &&
current.at("opening_flow").at("playing") == false,
"Zero-pair world entered an endless draw timer");
else {
require(current.at("opening_flow").at("phase") == "draw" &&
current.at("opening_flow").at("playing") == true,
"Real draw did not start playing");
edit(current, "skip", *fixture.world);
}
edit(current, "finish", *fixture.world);
require(current.at("opening") == "complete" &&
current.at("opening_created") == true,
"Tiny-world presentation cannot finish");
}
}
void actions_and_persistence() {
Fixture fixture(6, 4);
DemoSource source(fixture.world);
const auto base = source.snapshot();
const Json setup = {{"duration", 5}, {"difficulty", 3}, {"players", 1},
{"mode", 3}, {"league", true}, {"world", true}};
require(
source
.apply({base.revision,
"start",
{{"setup", setup}, {"managers", base.state.at("managers")}}})
.ok,
"League start rejected");
require(source.snapshot().state.at("opening_flow").at("phase") == "uefa",
"Start did not create fresh flow");
const auto ids = source.snapshot().state.at("opening_flow").at("order");
const auto act = [&](const char *kind) {
const auto before = source.snapshot();
auto predicted = before.state;
require(
edit_demo_opening(predicted, {{"kind", kind}}, *fixture.world).empty(),
"Precommit sidecar projection rejected");
const auto result =
source.apply({before.revision, "opening.flow", {{"kind", kind}}});
require(result.ok && source.snapshot().revision == before.revision + 1 &&
source.snapshot().state == predicted,
"Flow edit was not an exact single-revision publication of sidecar "
"projection");
require(source.snapshot().state.at("opening_flow").at("order") == ids,
"Flow action changed persisted draw IDs");
};
act("next");
act("next");
act("next");
act("reveal");
act("pause");
const auto paused = source.snapshot();
require(paused.state.at("opening_flow").at("revealed") == 1 &&
paused.state.at("opening_flow").at("playing") == false,
"Odd reveal/pause state was not retained");
const auto pairs =
report_opening_pairs(*fixture.world, paused.state.at("opening_flow"));
require(pairs.size() == ids.size() / 2,
"Reports show wrong persisted pair count");
for (size_t index = 0; index < pairs.size(); ++index)
require(pairs[index].at("home") == ids[index * 2] &&
pairs[index].at("away") == ids[index * 2 + 1] &&
pairs[index].at("home_goals").is_null() &&
pairs[index].at("away_goals").is_null(),
"Report opening pairs ignored saved IDs or invented results");
auto checkpoint = paused.state;
checkpoint["desktop"] = default_desktop();
checkpoint = Json::parse(checkpoint.dump());
const auto disk_checkpoint = fixture.root / "paused-opening.json";
source.save(disk_checkpoint, default_desktop());
DemoSource disk_restore(fixture.world);
disk_restore.load(disk_checkpoint);
require(disk_restore.snapshot().state == paused.state &&
!disk_restore.dirty(),
"Paused opening file save/load changed flow or clean marker");
DemoSource explicit_load(fixture.world);
explicit_load.load_data(checkpoint);
require(explicit_load.snapshot().state == paused.state &&
!explicit_load.dirty(),
"Explicit pending checkpoint did not roundtrip cleanly");
DemoSource resumed(fixture.world);
resumed.load_data(checkpoint, false);
require(resumed.snapshot().state == paused.state && resumed.dirty(),
"UI continuation incorrectly replaced explicit-save clean baseline");
const auto before_reject = resumed.snapshot();
const bool dirty = resumed.dirty();
auto result = resumed.apply(
{before_reject.revision, "opening.flow", {{"kind", "reveal"}}});
require(!result.ok && resumed.snapshot().state == before_reject.state &&
resumed.snapshot().revision == before_reject.revision &&
resumed.dirty() == dirty,
"Paused reveal changed state/revision/dirty");
result = resumed.apply(
{before_reject.revision - 1, "opening.flow", {{"kind", "toggle"}}});
require(!result.ok && result.error == "stale_revision" &&
resumed.snapshot().state == before_reject.state &&
resumed.dirty(),
"Stale flow request changed continuation");
act("toggle");
for (size_t count = 1; count < ids.size(); ++count)
act("reveal");
require(source.snapshot().state.at("opening_flow").at("phase") == "overview",
"Final reveal did not stop at overview");
act("finish");
require(source.snapshot().state.at("opening_flow").at("phase") == "done" &&
source.snapshot().state.at("opening_created") == true,
"Finish did not synchronize outer legacy fields");
// A valid saved permutation remains authoritative; load never reshuffles it.
std::swap(checkpoint["opening_flow"]["order"][0],
checkpoint["opening_flow"]["order"][1]);
resumed.load_data(checkpoint, false);
require(resumed.snapshot().state.at("opening_flow").at("order") ==
checkpoint.at("opening_flow").at("order"),
"Load silently changed saved IDs/order");
require(
resumed.apply({resumed.snapshot().revision, "opening", "complete"}).ok &&
resumed.snapshot().state.at("opening_flow").at("phase") == "done",
"Legacy opening complete is no longer compatible");
}
void rollback_and_migration() {
Fixture fixture(6, 0);
auto current = state(*fixture.world, true);
for (const auto &request : std::vector<Json>{Json(),
Json::array(),
Json::object(),
{{"kind", 9}},
{{"kind", "unknown"}},
{{"kind", "finish"}},
{{"kind", "reveal"}},
{{"kind", "skip"}},
{{"kind", "toggle"}},
{{"kind", "pause"}}})
rejected(current, request, *fixture.world);
edit(current, "next", *fixture.world);
edit(current, "next", *fixture.world);
edit(current, "next", *fixture.world);
rejected(current, {{"kind", "next"}}, *fixture.world);
edit(current, "toggle", *fixture.world);
rejected(current, {{"kind", "reveal"}}, *fixture.world);
edit(current, "toggle", *fixture.world);
edit(current, "reveal", *fixture.world);
edit(current, "pause", *fixture.world);
const auto good = current;
std::vector<Json> malformed;
for (const char *key : {"schema", "created", "phase", "revealed", "playing",
"order", "entrants"}) {
auto bad = good;
bad["opening_flow"].erase(key);
malformed.push_back(bad);
}
const auto alter = [&](const char *key, const Json &value) {
auto bad = good;
bad["opening_flow"][key] = value;
malformed.push_back(bad);
};
alter("schema", 2);
alter("schema", true);
alter("created", false);
alter("phase", "unknown");
alter("phase", "overview");
alter("phase", "done");
alter("revealed", -1);
alter("revealed", 6);
alter("revealed", 1.5);
alter("revealed", true);
auto bad = good;
bad["opening_flow"]["order"][1] = bad["opening_flow"]["order"][0];
malformed.push_back(bad);
bad = good;
bad["opening_flow"]["order"][0] = "club:foreign";
malformed.push_back(bad);
bad = good;
bad["opening_flow"]["order"].erase(0);
malformed.push_back(bad);
bad = good;
bad["opening_flow"]["entrants"]["champions"][0] = "club:top-0";
malformed.push_back(bad);
bad = good;
bad["opening_flow"]["extra"] = 1;
malformed.push_back(bad);
bad = good;
bad["opening"] = "complete";
malformed.push_back(bad);
bad = good;
bad["opening_created"] = true;
malformed.push_back(bad);
bad = good;
bad["opening_flow"]["phase"] = "uefa";
bad["opening_flow"]["revealed"] = 0;
bad["opening_flow"]["playing"] = true;
malformed.push_back(bad);
DemoSource stable(fixture.world);
require(stable.apply({0, "ticket", 17}).ok, "Synthetic dirty base failed");
const auto before = stable.snapshot();
for (auto value : malformed) {
const auto untouched = value;
require(!migrate_demo_opening(value, *fixture.world) && value == untouched,
"Invalid saved flow was repaired/partially migrated");
auto checkpoint = before.state;
for (const char *key : {"opening", "opening_created", "opening_flow"})
checkpoint[key] = untouched.at(key);
checkpoint["desktop"] = default_desktop();
bool failed = false;
try {
stable.load_data(checkpoint, false);
} catch (const std::exception &) {
failed = true;
}
require(failed && stable.snapshot().state == before.state &&
stable.snapshot().revision == before.revision && stable.dirty(),
"Invalid flow load partially published state/clean marker");
}
Json legacy = {{"opening", "pending"}, {"opening_created", false}};
require(migrate_demo_opening(legacy, *fixture.world) &&
legacy.at("opening_flow").at("phase") == "uefa",
"Legacy pending checkpoint not migrated to first phase");
const auto migrated = legacy;
require(migrate_demo_opening(legacy, *fixture.world) && legacy == migrated,
"Flow migration not idempotent");
legacy = {{"opening", "complete"}, {"opening_created", true}};
require(migrate_demo_opening(legacy, *fixture.world) &&
legacy.at("opening_flow").at("phase") == "done" &&
legacy.at("opening_flow").at("created") == true,
"Legacy completed checkpoint restarted opening");
}
} // namespace
int main() {
try {
selection();
tiny_worlds();
actions_and_persistence();
rollback_and_migration();
std::cout << "PASS UI opening: deterministic64/real tiny pools, entrants, "
"phase guards, odd paused continuation, saved IDs/reports, "
"stale rollback and legacy migration\n";
return 0;
} catch (const std::exception &error) {
std::cerr << error.what() << '\n';
return 1;
}
}