Port native season calendar and harden menu input QA (by Codex)

This commit is contained in:
Codex committed 2026-10-23 21:21:31 +02:00
1 parent 79bf38aa78
commit de8b53fce2
19 files changed
+582 -14

No files matched your search

+3
View File
@@ -23,6 +23,9 @@ on:
workflow_dispatch:
permissions:
contents: read
concurrency:
group: modern-ui-${{ github.ref }}
cancel-in-progress: true
jobs:
controls:
strategy:
+32
View File
@@ -0,0 +1,32 @@
/* SPDX-License-Identifier: GPL-3.0-only */
.calendar-month {position:absolute;border:2dp var(--border);border-radius:16dp;background-color:var(--soft);}
.calendar-month h2 {position:absolute;left:12dp;right:12dp;top:14dp;height:34dp;font-size:30dp;text-align:center;}
.calendar-weekday {position:absolute;display:flex;align-items:center;font-size:24dp;font-weight:normal;color:var(--muted);}
.calendar-weekday.sunday {color:var(--danger);}
.calendar-day {position:absolute;display:flex;align-items:center;justify-content:center;padding:0;border:0dp;border-radius:8dp;background-color:transparent;font-size:30dp;}
.calendar-day:hover {background-color:var(--hover);}
.calendar-day.has-match {color:#e9cb86;}
.calendar-day.selected-day {background-color:#7d9eb83b;color:#ffffff;}
.calendar-outline {position:absolute;left:3dp;right:3dp;top:3dp;bottom:3dp;border:2dp #a8cde7;border-radius:8dp;pointer-events:none;}
.calendar-day:focus-visible {font-effect:shadow(1dp 0dp var(--accent));}
.calendar-info {position:absolute;left:0;right:0;bottom:140dp;height:34dp;line-height:34dp;text-align:center;font-size:30dp;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
#calendar-country,#calendar-league {padding:12dp 24dp;padding-right:45dp;background-color:transparent;decorator:linear-gradient(180deg,#c1d1e31c,#869eb312);}
body.midnight .calendar-month {border-color:#c5d9e71a;background-color:#101d2826;}
body.midnight .calendar-month h2 {color:#dce5ee;}
body.midnight .calendar-weekday {color:#97a8b7;}
body.midnight .calendar-weekday.sunday {color:#eb9f98;}
body.midnight .calendar-day {color:#c6d2dc;}
body.midnight .calendar-day.has-match {color:#e9cb86;}
body.midnight .calendar-day.selected-day {color:#ffffff;}
body.midnight .calendar-info {color:#c6d2dc;}
body.midnight #calendar-country,body.midnight #calendar-league {color:#e0e6ec;border-color:#d4e0ec29;}
body.silver .calendar-month {background-color:#42627d09;}
body.silver .calendar-day.has-match {color:#805b18;}
body.silver .calendar-day.selected-day {background-color:#a3c3dd54;color:#193b52;}
body.silver .calendar-outline {border-color:#356f966e;}
body.silver #calendar-country,body.silver #calendar-league {decorator:linear-gradient(180deg,#ffffffb0,#bfd0e259);}
body.matchday .calendar-month {background-color:#f8e7e00a;}
body.matchday .calendar-day.has-match {color:#e1c68b;}
body.matchday .calendar-day.selected-day {background-color:#d48c7b26;color:#ffe5de;}
body.matchday .calendar-outline {border-color:#e5a19770;}
body.matchday #calendar-country,body.matchday #calendar-league {decorator:linear-gradient(180deg,#e8d6dc12,#a1a0aa0d);}
+1 -1
View File
@@ -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"/></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"/></head>
<body class="midnight">
<div id="background"></div>
<div id="canvas"></div>
+3 -3
View File
@@ -21,20 +21,20 @@
.training-row>div {flex-shrink:0;}
.training-header {height:62dp;font-size:31dp;color:var(--muted);border-bottom:2dp var(--border);}
.training-position {font-size:30dp;color:var(--muted);}
.training-name {overflow:hidden;white-space:nowrap;text-overflow:ellipsis;padding-right:10dp;}
.training-name {overflow:hidden;white-space:nowrap;text-overflow:ellipsis;max-width:290dp;margin-right:10dp;}
.training-row.striped {background-color:var(--soft);}
.training-roster select {width:490dp;height:62dp;padding:10dp 12dp;border:2dp var(--border);border-radius:8dp;font-size:32dp;}
.training-roster select selectbox {width:490dp;max-height:480dp;margin-top:8dp;padding:10dp;border-radius:16dp;}
.training-roster select option {min-height:72dp;padding:10dp 14dp;line-height:1.3;}
.tactics-board {position:absolute;left:76dp;top:0;width:2300dp;height:100%;}
.tactics-surface {position:absolute;left:0;right:0;top:0;bottom:100dp;border:2dp var(--border);border-radius:28dp;decorator:linear-gradient(130deg,#bfd9e40a,#9ecbb809);}
.tactics-board>.image-frame {filter:drop-shadow(0dp 0dp 1dp #e0edbc);}
.tactics-board>.image-frame {filter:drop-shadow(#e0edbc 0dp 0dp 1dp);}
.tactic-hotspot {padding:0;border:0dp;background-color:transparent;}
.tactic-hotspot:hover,.tactic-hotspot:active {background-color:transparent;}
.tactic-hotspot:focus-visible {border:3dp var(--accent);}
.tactic-effort {position:absolute;left:1021.188dp;top:1021.469dp;width:1012dp;height:316.875dp;color:#d4e6b3;}
body.silver .tactic-effort {color:#536f66;}
.tactic-effort-label {display:flex;align-items:baseline;gap:18dp;font-family:Chalk;font-size:60dp;line-height:1.2;letter-spacing:4dp;font-effect:shadow(2dp 2dp #386824);}
.tactic-effort-label {display:flex;align-items:baseline;gap:18dp;font-family:Chalk;font-size:60dp;line-height:1.2;letter-spacing:4dp;}
.tactic-effort-marks {font-size:52dp;letter-spacing:1dp;line-height:1.2;}
.tactic-effort input {position:absolute;left:2dp;top:96dp;width:96%;height:20dp;}
.tactic-effort input slidertrack {margin:8dp 0;height:4dp;}
+5
View File
@@ -35,6 +35,9 @@ wird ausdrücklich mit `OPENBMH_BUILD_MODERN_UI=ON` gebaut.
- [Taktik](desktop/tactics/README.md): sieben interaktive Diagrammflächen,
zyklische Einstellungen und Einsatzregler. Die Grafik aktualisiert sich
unmittelbar und speichert ausschließlich UI-Vorschaueinstellungen.
- [Kalender](desktop/calendar/README.md): zwölf Monate mit der originalen
Wochentagsanordnung, Tageswahl und Länder-/Ligavorschau; 18/20 Vereine,
Schaltjahre und gespeicherte Auswahl werden berücksichtigt.
**Anstoß führt keine Aktion aus**, weder per Maus noch per Tastatur. Das gilt
auch für die direkte Aktionsschnittstelle des Demoanbieters.
@@ -47,6 +50,8 @@ Der Einstellungsdialog, die vollständigen Widgetinhalte, Sortierung/Details,
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.
## Architekturgrenze für die Engine
+2
View File
@@ -11,12 +11,14 @@ Implementierung in der Spiel-Engine.
| Nativer Stand | [Unterbau, erster Durchlauf und noch offene Übertragungen](NATIVE_STATUS.md) |
| Schrift-QA | [Button-/Dropdown-Ausrichtung und unabhängiger Vergleich](typography-qa.md) |
| Menü-QA | [Wiederholbarer Gesamtkatalog und Meilenstein-Abnahme](menu-qa.md) |
| QA-Befunde | [Offene Abweichungen zur HTML-Referenz](qa-findings.md) |
| Ressourcen | [GUI-Assets, Weltbilder und spätere Paketbereinigung](assets.md) |
| Desktop | [Statusleiste, Gestaltung und Fenster](desktop/README.md) |
| Eintrittspreis | [Kompakter Schieberegler im Konto-Widget](desktop/entry-price/README.md) |
| Trainingslager | [Alle 18 Angebote, Qualitätswerte und Bedienung](desktop/trainingcamp/README.md) |
| 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) |
| Transfers | [Ablöse-Kasten und Positionsfilter](desktop/transfers/README.md) |
Jeder Bereich nennt die geprüfte Quelle, bestehende Funktionen und offene
+64
View File
@@ -0,0 +1,64 @@
# Kalender · native Modern UI
Stand: 23. Oktober 2026. Quelle ist das unveränderte private HTML-Mockup
`bmh_4k_ui`, Produktrevision `0bf0f2afd2ff8d5dabb96c795db2a5d0abaaf278`:
`desktop/management-menus.js`, `league-preview.js`, `table-window.css` und
`menu-themes.css`. Native Ansicht: `src/modern/ui/calendar_screen.inc`.
## Gestaltung und Bedienung
Zwölf Monatskarten von Juli bis Juni stehen in einem Raster mit vier Spalten
und drei Reihen. Innerhalb jedes Monats stehen **die Wochentage in sieben
Zeilen**, die Wochen in sechs Spalten. Diese transponierte Originalanordnung
wird beibehalten. Leere Randplätze enthalten keine künstlichen Datumsknöpfe.
Monatsnamen und Tageszahlen verwenden 30 logische Pixel, Wochentage 24.
Sonntagsbeschriftungen sind rot, Ligatermine gelb. Der gewählte Tag erhält
den thematischen Hintergrund und einen vollständigen inneren Rahmen.
Unter dem Kalender steht genau eine Terminzeile; darunter liegen die
gleich großen Auswahlfelder Land und Liga. Es gibt keinen zusätzlichen Footer.
Maus, Leertaste und Enter wählen einen Tag. Fokus bleibt beim neu gerenderten
Tagesknopf. Pfeiltasten verschieben das Datum nicht eigenmächtig. Länder- und
Ligawechsel erhalten den Tag und ändern ausschließlich die Vorschau.
Escape schließt zunächst die geöffnete Auswahl, danach das Menü. Rechtsklick
schließt das Untermenü wie im HTML. Datums- und Ligawahl bleiben nach
Wiederöffnen und Laden eines UI-Demostands erhalten.
## Daten und Enginegrenze
Der Demoanbieter liefert `calendar` mit Saisonbeginn, gewähltem Tagesindex,
Liga-ID und reservierten leeren Projektionen für Freundschaftsspiele und
Verlegungen. `calendar`-Aktionen erlauben nur `select` und `league`.
Unbekannte Ligen, ungültige Tagesindizes und nicht ganzzahlige Eingaben
werden atomar abgewiesen. Die Saison stammt aus dem Demodatum; sie ist
nicht auf das Jahr der HTML-Vorschau festgelegt.
Die Vorschautermine sind deterministische Dummydaten: zwei Begegnungen je
Gegner, erste Runde am Saisonindex 30, danach sieben Tage Abstand. 18 Vereine
ergeben 34, 20 Vereine 38 Spieltage. Ist der verwaltete Verein in der Liga,
zeigt die Vorschau dessen Termine; ansonsten die des ersten Vereins der
angezeigten Liga. Die Manageridentität wird dadurch nicht geändert.
**Dies ist keine Spielplanerzeugung für die Engine.** Es gibt weder Zufall
noch Sessionzugriffe. Der spätere Sessionadapter ersetzt die Terminvorschau
durch echte Spieltage, Pokale, Verlegungen und Freundschaftsspiele. Die
zugehörigen nativen Planungsmenüs und farbigen Freundschaftsmarkierungen sind
in diesem Meilenstein noch nicht angebunden; deren gespeicherte Aktionen
werden nicht stillschweigend vorgetäuscht.
## QA
Der unabhängige Vergleich nutzt alle drei Themes bei 1280 × 720 und
1920 × 1080. Für den Datumsvergleich wurde ein isolierter Demostand auf
2027/28 gesetzt, damit auch der 29. Februar aus der HTML-Referenz prüfbar ist.
Die ursprüngliche Weltdatei bleibt unverändert. Abweichende Vereinsnamen aus
Diamond gegenüber der HTML-Demo werden ausdrücklich als Datenunterschied
behandelt.
Synthetische Regression prüft Gregorianische Schaltjahre einschließlich
2100, Wochentagspositionen, zwei Begegnungen je Gegner, 18-/20-Vereinsgrößen,
atomare Ablehnung und Wiederherstellung. Die Renderer-QA prüft zusätzlich
sichtbare Wochentage, Auswahlrahmen, Terminzeilen, Tastatur/Fokus und
Länder-/Ligawechsel. Gemeinsame Dropdown-Optik bleibt in der
[Befundliste](../../qa-findings.md) erfasst.
+32
View File
@@ -0,0 +1,32 @@
# Offene native UI-Befunde
Stand: 23. Oktober 2026. Diese Liste betrifft die ausdrücklich aktivierte,
noch unfertige Modern-Vorschau. Sie ist keine Abnahme der kompletten UI.
Verbindliche Quelle ist das private HTML-Mockup; echte Rendererbilder und
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. |
| 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`. |
Bereits korrigiert wurden vertikale Button-/Dropdownbeschriftungen,
Pfeilausrichtung, Escape/Fokus nach Auswahl, Training-Scrollposition,
Budgetumbrüche, lange Spielernamen neben Stärkewerten sowie Taktik-Schatten.
Das Verwerfen offener Auswahllisten und die Tastaturbedienung werden bei
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.
Siehe [QA-Ablauf](menu-qa.md), [Typografie](typography-qa.md) und
[aktuellen nativen Stand](NATIVE_STATUS.md).
+8
View File
@@ -28,6 +28,9 @@ Ausrichtungen waren überwiegend bereits korrekt.
Der übergeordnete Dialog bleibt offen. Pfeiltasten dürfen mehrere Optionen
durchlaufen; erst beim Schließen wird die Auswahl an die Ansicht übergeben.
Anschließend kehrt der Fokus zum Auswahlfeld zurück.
- Die Pfeiltasten öffnen eine geschlossene Auswahl wie HTML. Home/End in
der geöffneten Liste, Übernahme mit Enter/Leertaste und Verwerfen beim
Verlassen werden vor dem RmlUI-Standardverhalten behandelt.
- Die Manager-Auswahlfelder entsprechen mit 88 logischen Pixeln Höhe und
30 Pixeln Schrift der Referenz. Das Stärke-Feld nutzt die volle Spaltenbreite.
- Das fehlende Kalendersymbol für den diagonalen Pfeil wird durch ein eigenes
@@ -48,6 +51,11 @@ das Produktions-RCSS mit synthetischen Daten. Der Test misst Text-/Pfeilmitten,
prüft sichtbare Textzeilen, unveränderte Bildkarten und Popup-Schriftgrößen in
drei Themes bei vier Pixeldichten. Er ergänzt den echten Renderer-/HTML-
Vergleich und ersetzt ihn nicht.
Der Test liest alle Produktions-Stylesheets und weist Parserfehler zurück.
Ein negativer Test mit einer tatsächlich ungültigen Rml-Schattenangabe
bestätigt diesen Schutz. Rml erwartet beim Diagrammfilter die Farbe zuerst;
Fontschatten benötigen in der gepinnten Version ausdrücklich skalierte
physische Pixel statt einer unverändert übernommenen `dp`-Angabe.
Screenshots, DOM-Ausgaben, Messdaten und Wiederholungsabläufe liegen im privaten
Mockup-Repository unter `docs/qa/native-rmlui-2026-10-23`. Die native Abnahme
+2 -2
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)
add_library(bmh_modern_ui_core STATIC catalog.cpp model.cpp gui_assets.cpp desktop.cpp demo_sports.cpp demo_calendar.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)
foreach(asset modern.rml theme.rcss ticket.rcss sports.rcss calendar.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")
+93
View File
@@ -0,0 +1,93 @@
// SPDX-License-Identifier: GPL-3.0-only
std::string App::render_calendar() {
const auto snapshot = snap();
const auto &calendar = snapshot.state.at("calendar");
const auto days = calendar_days(calendar.at("start").get<std::string>());
const auto fixtures = calendar_fixtures(calendar, *world_,
manager(snapshot).value("club", ""));
const int selected = calendar.at("selected").get<int>();
const auto league_id = calendar.at("league").get<std::string>();
const auto *league = world_->find("competitions", league_id);
const auto nation = league ? league->value("nation", "") : "";
const std::array<const char *, 12> months = {
"Januar", "Februar", "März", "April", "Mai", "Juni",
"Juli", "August", "September", "Oktober", "November", "Dezember"};
const std::array<const char *, 7> weekdays = {"MO", "DI", "MI", "DO",
"FR", "SA", "SO"};
std::string body;
int first = 0;
for (int panel = 0; panel < 12; ++panel) {
const int month = days[size_t(first)].month;
const int offset = days[size_t(first)].weekday;
body += "<section class=\"calendar-month\" style=\"" +
rect((panel % 4) * 660, (panel / 4) * 556, 632, 528) +
"\"><h2>" + months[size_t(month - 1)] + "</h2>";
constexpr double cell_width = (604.0 - 65) / 6, cell_height = 438.0 / 7;
for (int row = 0; row < 7; ++row) {
body += "<span class=\"calendar-weekday " +
std::string(row == 6 ? "sunday" : "") + "\" style=\"" +
rect(12, 66 + row * cell_height, 65, cell_height) + "\">" +
"<span>" + weekdays[size_t(row)] + "</span></span>";
for (int col = 0; col < 6; ++col) {
const int number = col * 7 + row - offset + 1;
const int index = first + number - 1;
if (number < 1 || index >= int(days.size()) ||
days[size_t(index)].month != month)
continue;
const bool match = std::any_of(fixtures.begin(), fixtures.end(),
[&](const auto &f) {
return f.day == index;
});
const bool chosen = selected == index;
const auto &iso = days[size_t(index)].iso;
const auto date = iso.substr(8, 2) + "." + iso.substr(5, 2) + "." +
iso.substr(0, 4);
body += btn(
"calendar-select",
(chosen ? "<span class=\"calendar-outline\" style=\"" +
rect(3, 3, cell_width - 6, cell_height - 6) +
"\"></span>"
: "") +
std::string("<span class=\"control-label\">") +
std::to_string(number) + "</span>",
std::string("calendar-day ") + (match ? "has-match " : "") +
(chosen ? "selected-day" : ""),
"id=\"calendar-day-" + std::to_string(index) + "\" data-id=\"" +
std::to_string(index) + "\" aria-pressed=\"" +
(chosen ? "true" : "false") + "\" aria-label=\"" + date +
(match ? ", belegt" : ", frei") + "\" style=\"" +
rect(77 + col * cell_width, 66 + row * cell_height,
cell_width, cell_height) + "\"");
}
}
body += "</section>";
while (first < int(days.size()) && days[size_t(first)].month == month)
++first;
}
const auto &iso = days[size_t(selected)].iso;
std::string info = iso.substr(8, 2) + "." + iso.substr(5, 2) + "." +
iso.substr(0, 4) + " · spielfrei";
for (const auto &f : fixtures)
if (f.day == selected) {
const auto *home = world_->find("clubs", f.home),
*away = world_->find("clubs", f.away);
info = iso.substr(8, 2) + "." + iso.substr(5, 2) + "." + iso.substr(0, 4) +
" · " + std::to_string(f.round + 1) + ". Spieltag · " +
(home ? world_->name(*home) : "") + " – " +
(away ? world_->name(*away) : "");
}
body += "<p id=\"calendar-info\" class=\"calendar-info\">" + esc(info) +
"</p><nav class=\"bottom-controls\">";
std::vector<std::pair<std::string, std::string>> countries, leagues;
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 == nation)
leagues.emplace_back(l->value("id", ""), world_->name(*l));
}
return body + select("calendar-country", countries, nation, "calendar-country") +
select("calendar-league", leagues, league_id, "calendar-league") +
"</nav>";
}
+74 -2
View File
@@ -135,12 +135,25 @@ void App::ProcessEvent(Rml::Event &event) try {
keyboard_navigation_ = true;
else if (type == "mousedown")
keyboard_navigation_ = false;
if (type == "blur") {
if (auto *select = dynamic_cast<Rml::ElementFormControlSelect *>(
event.GetTargetElement());
select && select->IsSelectBoxVisible()) {
select->CancelSelectBox();
dirty_ = true;
}
return;
}
for (auto *n = event.GetTargetElement(); n && n != doc_;
n = n->GetParentNode())
if (n->GetId() == "native-ticket-layer")
return;
if (type == "mouseup" && event.GetParameter<int>("button", 0) == 1) {
if (scene_ == "desktop" && menu_.empty() && popup_.empty()) {
if (scene_ == "desktop" && !menu_.empty() && popup_.empty()) {
menu_.clear();
draft_preferences_ = nullptr;
refresh();
} else if (scene_ == "desktop" && menu_.empty() && popup_.empty()) {
std::string id;
for (auto *n = event.GetTargetElement(); n && n != doc_;
n = n->GetParentNode())
@@ -190,6 +203,38 @@ void App::ProcessEvent(Rml::Event &event) try {
if (type == "keydown") {
const auto key =
Rml::Input::KeyIdentifier(event.GetParameter<int>("key_identifier", 0));
Rml::ElementFormControlSelect *select = nullptr;
for (auto *n = target; n && n != doc_; n = n->GetParentNode())
if ((select = dynamic_cast<Rml::ElementFormControlSelect *>(n)))
break;
if (select && !select->HasAttribute("disabled")) {
const bool open = select->IsSelectBoxVisible();
if (open && key == Rml::Input::KI_TAB) {
select->CancelSelectBox();
dirty_ = true;
}
if ((!open && (key == Rml::Input::KI_DOWN || key == Rml::Input::KI_UP)) ||
key == Rml::Input::KI_RETURN || key == Rml::Input::KI_SPACE) {
if (open)
select->HideSelectBox();
else {
select->ShowSelectBox();
if (key == Rml::Input::KI_UP)
select->SetSelection(select->GetNumOptions() - 1);
}
event.StopImmediatePropagation();
dirty_ = true;
return;
}
if (open && (key == Rml::Input::KI_HOME || key == Rml::Input::KI_END)) {
select->SetSelection(key == Rml::Input::KI_HOME
? 0
: select->GetNumOptions() - 1);
event.StopImmediatePropagation();
dirty_ = true;
return;
}
}
if (key == Rml::Input::KI_RETURN || key == Rml::Input::KI_SPACE) {
for (auto *n = target; n && n != doc_; n = n->GetParentNode())
if (n->GetTagName() == "button") {
@@ -887,7 +932,7 @@ 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"};
"save", "load", "training", "tactics", "calendar"};
if (!available.contains(route)) {
message("Diese native Ansicht wird im nächsten Menüpaket übertragen.");
return;
@@ -922,6 +967,13 @@ void App::dispatch(const std::string &action, Rml::Element *target) {
}
return;
}
if (action == "calendar-select") {
if (apply("calendar", {{"kind", "select"}, {"value", std::stoi(id)}})) {
focus_after_render_ = target->GetId();
refresh();
}
return;
}
if (action == "tactic-cycle") {
const int i = std::stoi(id);
if (i < 0 || i > 6)
@@ -1102,6 +1154,26 @@ void App::change(Rml::Element *target) {
pending_selects_.insert(target->GetId());
return;
}
if (kind == "calendar-country" || kind == "calendar-league") {
std::string league = value;
if (kind == "calendar-country") {
const auto current = snap().state.at("calendar").at("league").get<std::string>();
const auto *competition = world_->find("competitions", current);
if (competition && competition->value("nation", "") == value)
return;
const auto leagues = world_->leagues(value);
if (leagues.empty())
return;
league = leagues.front()->value("id", "");
}
if (snap().state.at("calendar").at("league") == league)
return;
if (apply("calendar", {{"kind", "league"}, {"value", league}})) {
focus_after_render_ = target->GetId();
refresh();
}
return;
}
if (kind == "training-focus") {
const auto player = target->GetAttribute<Rml::String>("data-player", "");
const int focus = std::stoi(value);
+120
View File
@@ -0,0 +1,120 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "modern/ui/demo_calendar.hpp"
#include <algorithm>
#include <chrono>
#include <iomanip>
#include <numeric>
#include <sstream>
namespace bmh::modern_ui {
std::vector<CalendarDay> calendar_days(const std::string &start) {
using namespace std::chrono;
if (start.size() != 10 || start.substr(4) != "-07-01" ||
!std::all_of(start.begin(), start.begin() + 4,
[](char c) { return c >= '0' && c <= '9'; }))
return {};
const int y = std::stoi(start.substr(0, 4));
if (y < 1 || y > 9998)
return {};
const sys_days first = year{y} / July / 1, last = year{y + 1} / July / 1;
std::vector<CalendarDay> result;
for (auto date = first; date < last; date += days{1}) {
const year_month_day parts{date};
const int month = unsigned(parts.month()), day = unsigned(parts.day());
std::ostringstream iso;
iso.imbue(std::locale::classic());
iso << std::setfill('0') << std::setw(4) << int(parts.year()) << '-'
<< std::setw(2) << month << '-' << std::setw(2) << day;
result.push_back({iso.str(), int(parts.year()), month, day,
int((weekday{date}.c_encoding() + 6) % 7)});
}
return result;
}
Json demo_calendar(const Catalog &world, const std::string &date) {
auto year = std::stoi(date.substr(0, 4));
if (date.substr(5, 2) < "07")
--year;
const auto leagues = world.leagues("nation:de");
std::ostringstream start;
start.imbue(std::locale::classic());
start << std::setfill('0') << std::setw(4) << year << "-07-01";
if (calendar_days(start.str()).empty())
throw editor::Error("invalid_demo_calendar");
return {{"start", start.str()},
{"selected", 6},
{"league", leagues.empty() ? "" : leagues.front()->value("id", "")},
{"friendlies", Json::array()},
{"moves", Json::array()}};
}
bool valid_demo_calendar(const Json &v, const Catalog &world) {
try {
const auto days = calendar_days(v.at("start").get<std::string>());
if (days.empty() || !v.at("selected").is_number_integer() ||
v["selected"] < 0 || v["selected"] >= days.size())
return false;
const auto league = v.at("league").get<std::string>();
const auto leagues = world.leagues();
if (std::none_of(leagues.begin(), leagues.end(), [&](auto *r) {
return r->value("id", "") == league;
}))
return false;
// Reserved projections for later native planning menus; no unimplemented
// booking or rescheduling action is silently accepted by this preview.
return v.at("friendlies").is_array() && v["friendlies"].empty() &&
v.at("moves").is_array() && v["moves"].empty();
} catch (const Json::exception &) {
return false;
}
}
std::string edit_demo_calendar(Json &state, const Json &action,
const Catalog &world) {
const auto kind = action.at("kind").get<std::string>();
auto next = state;
if (kind == "select")
next["selected"] = action.at("value");
else if (kind == "league")
next["league"] = action.at("value");
else
return "unknown_calendar_action";
if (!valid_demo_calendar(next, world))
return "invalid_calendar_selection";
state = std::move(next);
return {};
}
std::vector<CalendarFixture> calendar_fixtures(const Json &state,
const Catalog &world,
const std::string &managed_club) {
const auto clubs = world.clubs(state.at("league").get<std::string>());
if (clubs.size() < 2)
return {};
const auto found = std::find_if(clubs.begin(), clubs.end(), [&](auto *c) {
return c->value("id", "") == managed_club;
});
const int followed = found == clubs.end() ? 0 : int(found - clubs.begin());
const int count = int(clubs.size()) + int(clubs.size() % 2);
std::vector<int> ring(size_t(count), 0);
std::iota(ring.begin(), ring.end(), 0);
std::vector<CalendarFixture> first, result;
for (int round = 0; round < count - 1; ++round) {
for (int pair = 0; pair < count / 2; ++pair) {
auto home = ring[size_t(pair)], away = ring[size_t(count - 1 - pair)];
if ((pair == 0 ? round : pair) % 2)
std::swap(home, away);
if ((home != followed && away != followed) ||
home >= int(clubs.size()) || away >= int(clubs.size()))
continue;
first.push_back({30 + round * 7, round,
clubs[size_t(home)]->value("id", ""),
clubs[size_t(away)]->value("id", "")});
}
std::rotate(ring.begin() + 1, ring.end() - 1, ring.end());
}
result = first;
for (const auto &fixture : first)
result.push_back({fixture.day + (count - 1) * 7,
fixture.round + count - 1, fixture.away, fixture.home});
const auto days = calendar_days(state.at("start").get<std::string>()).size();
std::erase_if(result, [&](const auto &f) { return size_t(f.day) >= days; });
return result;
}
} // namespace bmh::modern_ui
+21
View File
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include "modern/ui/catalog.hpp"
namespace bmh::modern_ui {
struct CalendarDay {
std::string iso;
int year, month, day, weekday;
};
struct CalendarFixture {
int day, round;
std::string home, away;
};
// Presentation fixtures only. No scheduler, RNG, session or match is called.
std::vector<CalendarDay> calendar_days(const std::string &start);
Json demo_calendar(const Catalog &, const std::string &date);
bool valid_demo_calendar(const Json &, const Catalog &);
std::string edit_demo_calendar(Json &, const Json &, const Catalog &);
std::vector<CalendarFixture> calendar_fixtures(const Json &, const Catalog &,
const std::string &managed_club);
} // namespace bmh::modern_ui
+12 -1
View File
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "modern/ui/model.hpp"
#include "modern/ui/demo_calendar.hpp"
#include "modern/ui/demo_sports.hpp"
#include "modern/ui/desktop.hpp"
#include <algorithm>
@@ -76,9 +77,10 @@ DemoSource::DemoSource(std::shared_ptr<const Catalog> catalog)
{"edits", Json::object()}};
state_["training"] = demo_training(*catalog_, club);
state_["tactics"] = demo_tactics();
saved_ = state_;
if (!valid_date(state_.at("date")))
throw editor::Error("invalid_demo_date");
state_["calendar"] = demo_calendar(*catalog_, state_.at("date"));
saved_ = state_;
}
Snapshot DemoSource::snapshot() const { return {revision_, catalog_, state_}; }
ActionResult DemoSource::apply(const Action &action) {
@@ -122,6 +124,11 @@ ActionResult DemoSource::apply(const Action &action) {
const auto error = edit_demo_tactics(next["tactics"], action.value);
if (!error.empty())
return {false, revision_, error};
} else if (action.kind == "calendar") {
const auto error = edit_demo_calendar(next["calendar"], action.value,
*catalog_);
if (!error.empty())
return {false, revision_, error};
} else if (action.kind == "camp.select") {
if (!camp_id(action.value))
return {false, revision_, "camp_unknown"};
@@ -189,6 +196,10 @@ Json DemoSource::load(const fs::path &file) {
!data.at("edits").is_object() || !data.at("opening").is_string() ||
!camp_id(data.at("camp").at("selected")))
throw editor::Error("invalid_demo_state");
if (!data.contains("calendar"))
data["calendar"] = demo_calendar(*catalog_, data.at("date"));
if (!valid_demo_calendar(data.at("calendar"), *catalog_))
throw editor::Error("invalid_demo_calendar");
const auto &focus = data.at("camp").at("focus");
if (!focus.is_array() || focus.size() != 3)
throw editor::Error("invalid_focus");
+2
View File
@@ -967,6 +967,8 @@ std::string App::render_menu(const std::string &key) {
body = render_training();
else if (key == "tactics")
body = render_tactics();
else if (key == "calendar")
body = render_calendar();
else if (key == "camp")
body = render_camp();
else if (key == "settings")
+17 -2
View File
@@ -5,6 +5,7 @@
#include "launch/rml_path.hpp"
#include "launch/rml_video.hpp"
#include "modern/ui/controls.hpp"
#include "modern/ui/demo_calendar.hpp"
#include "modern/ui/demo_sports.hpp"
#include "modern/ui/desktop.hpp"
#include "modern/ui/gui_assets.hpp"
@@ -598,6 +599,7 @@ class App final : public Rml::EventListener {
std::string render_camp();
std::string render_training();
std::string render_tactics();
std::string render_calendar();
std::string training_balls(const std::string &, int, int, bool,
const std::string &player = {}, int size = 56,
int gap = 10, bool overtraining = false);
@@ -627,6 +629,15 @@ class App final : public Rml::EventListener {
}
}
void input(Rml::Element *);
void scale_chalk_shadow() {
// Pinned RmlUI font effects read integer pixels even for dp properties.
// Match the HTML's two logical pixels at the current stage density.
if (auto *label = doc_->QuerySelector(".tactic-effort-label")) {
const auto offset = std::to_string(int(std::round(2 * scale_)));
label->SetProperty("font-effect",
"shadow(" + offset + "px " + offset + "px #386824)");
}
}
void resize() {
int w, h, pw, ph;
SDL_GetWindowSize(video_.window, &w, &h);
@@ -644,6 +655,7 @@ class App final : public Rml::EventListener {
element("canvas")->SetProperty("top", scalar(canvas_top_) + "px");
if (ticket_)
ticket_->resize(device_ratio_);
scale_chalk_shadow();
dirty_ = true;
}
void render() {
@@ -685,6 +697,7 @@ class App final : public Rml::EventListener {
: "saturate(0.34) brightness(0.70)");
needs_render_ = false;
last_rendered_menu_ = menu_;
scale_chalk_shadow();
dirty_ = true;
if (focus_ticket_) {
if (auto *n = element("desktop-ticket"))
@@ -856,9 +869,10 @@ public:
if (!doc_)
throw std::runtime_error("Modern UI layout missing");
for (const char *event :
{"click", "dblclick", "change", "input", "keydown", "mousedown",
{"click", "dblclick", "change", "input", "keydown", "blur", "mousedown",
"mouseup", "mousemove", "contextmenu"})
doc_->AddEventListener(event, this);
doc_->AddEventListener(event, this, Rml::String(event) == "keydown" ||
Rml::String(event) == "blur");
if (!config_.theme.empty())
theme_ = config_.theme;
if (theme_ != "midnight" && theme_ != "silver" && theme_ != "matchday")
@@ -980,6 +994,7 @@ public:
#include "modern/ui/desktop_screens.inc"
#include "modern/ui/screens.inc"
#include "modern/ui/sports_screens.inc"
#include "modern/ui/calendar_screen.inc"
} // namespace
bool is_modern_world(const fs::path &file) {
try {
+22 -3
View File
@@ -36,6 +36,19 @@ struct Renderer final : Rml::RenderInterface {
void EnableScissorRegion(bool) override {}
void SetScissorRegion(Rml::Rectanglei) override {}
};
struct System final : Rml::SystemInterface {
size_t stylesheet_errors = 0;
bool LogMessage(Rml::Log::Type type, const Rml::String &message) override {
if ((type == Rml::Log::LT_WARNING || type == Rml::Log::LT_ERROR) &&
(message.find("property") != message.npos ||
message.find("style") != message.npos ||
message.find("Syntax error") != message.npos)) {
++stylesheet_errors;
std::cerr << message << '\n';
}
return true;
}
};
void text_centers(Rml::Element &node, float cx, float cy, bool horizontal,
size_t &lines) {
if (auto *text = dynamic_cast<Rml::ElementText *>(&node)) {
@@ -72,7 +85,7 @@ int main(int argc, char **argv) try {
require(argc == 2, "Pass the Modern asset directory");
const auto root = std::filesystem::path(argv[1]);
Renderer renderer;
Rml::SystemInterface system;
System system;
Rml::SetRenderInterface(&renderer);
Rml::SetSystemInterface(&system);
require(Rml::Initialise(), "Rml initialization");
@@ -84,9 +97,13 @@ int main(int argc, char **argv) try {
Rml::Style::FontStyle::Normal,
Rml::Style::FontWeight::Bold),
"Bold font missing");
std::ifstream input(root / "theme.rcss");
std::ostringstream css;
css << input.rdbuf();
for (const auto *name : {"theme.rcss", "ticket.rcss", "sports.rcss",
"calendar.rcss"}) {
std::ifstream input(root / name);
require(bool(input), "Production stylesheet missing");
css << input.rdbuf() << '\n';
}
for (const auto *theme : {"midnight", "silver", "matchday"})
for (float density : {1.f / 3, .5f, 1.f, 2.f}) {
auto *context = Rml::CreateContext(
@@ -136,6 +153,8 @@ int main(int argc, char **argv) try {
"<rml><head><style>" + css.str() + "</style></head><body class='" +
theme + "'>" + content + "</body></rml>");
require(doc, "Document missing");
require(system.stylesheet_errors == 0,
"Rml rejected a production stylesheet declaration");
doc->Show();
context->Update();
context->Render();
+69
View File
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "modern/ui/demo_sports.hpp"
#include "modern/ui/demo_calendar.hpp"
#include "modern/ui/desktop.hpp"
#include "modern/ui/gui_assets.hpp"
#include "modern/ui/model.hpp"
@@ -251,17 +252,85 @@ int main(int argc, char **argv) try {
auto legacy = Json::parse(bmh::editor::read_file(root / "sports.ui.json"));
legacy.erase("training");
legacy.erase("tactics");
legacy.erase("calendar");
write(root, "legacy-ui.json", legacy);
restored_sports.load(root / "legacy-ui.json");
require(valid_demo_training(restored_sports.snapshot().state["training"],
*world, "club:a"),
"Older UI checkpoint did not migrate safely");
require(valid_demo_calendar(restored_sports.snapshot().state["calendar"],
*world),
"Older UI checkpoint lost its season calendar");
for (const auto *theme : {"midnight", "silver", "matchday"}) {
const auto diagram = bmh::editor::images::decode(
tactics_diagram(demo_tactics(), theme), ".svg", 256);
require(diagram.width == 256 && diagram.height > 0,
"Tactic SVG failed to decode");
}
const auto leap_days = calendar_days("2027-07-01");
require(leap_days.size() == 366 && leap_days.front().weekday == 3 &&
leap_days.back().iso == "2028-06-30" &&
std::count_if(leap_days.begin(), leap_days.end(), [](const auto &d) {
return d.iso == "2028-02-29";
}) == 1,
"Season dates lost weekday alignment or leap day");
require(calendar_days("2026-07-01").size() == 365 &&
calendar_days("2099-07-01").size() == 365 &&
calendar_days("0000-07-01").empty() &&
calendar_days("2027-06-01").empty(),
"Season date validation or Gregorian century handling failed");
auto calendar_clubs = world->rows("clubs");
for (int i = 1; i < 20; ++i) {
if (i < 18)
calendar_clubs.push_back({{"id", "club:home" + std::to_string(i)},
{"name", "Home " + std::to_string(i)},
{"nation", "nation:de"},
{"competition", "comp:home"}});
calendar_clubs.push_back({{"id", "club:other" + std::to_string(i)},
{"name", "Other " + std::to_string(i)},
{"nation", "nation:other"},
{"competition", "comp:other"}});
}
table(root, "clubs", calendar_clubs);
auto calendar_world = Catalog::open(root);
DemoSource calendar_source(calendar_world);
auto calendar = calendar_source.snapshot().state.at("calendar");
const auto fixtures = calendar_fixtures(calendar, *calendar_world, "club:a");
require(fixtures.size() == 34, "Eighteen-team season needs 34 preview rounds");
std::map<std::string, int> opponents;
std::set<int> occupied;
for (const auto &fixture : fixtures) {
require(fixture.home == "club:a" || fixture.away == "club:a",
"Calendar fixture belongs to another career club");
require(fixture.home != fixture.away && occupied.insert(fixture.day).second,
"Preview generated self match or duplicate date");
++opponents[fixture.home == "club:a" ? fixture.away : fixture.home];
}
require(opponents.size() == 17 &&
std::all_of(opponents.begin(), opponents.end(), [](const auto &p) {
return p.second == 2;
}),
"Preview must show two meetings per opponent");
const auto original_calendar = calendar_source.snapshot();
require(!calendar_source.apply({0, "calendar", {{"kind", "select"}, {"value", -1}}}).ok &&
!calendar_source.apply({0, "calendar", {{"kind", "select"}, {"value", 365}}}).ok &&
!calendar_source.apply({0, "calendar", {{"kind", "select"}, {"value", 1.5}}}).ok &&
calendar_source.snapshot().state == original_calendar.state &&
calendar_source.snapshot().revision == 0,
"Invalid calendar selection mutated the demo");
require(calendar_source.apply({0, "calendar", {{"kind", "select"}, {"value", 30}}}).ok &&
calendar_source.apply({1, "calendar", {{"kind", "league"}, {"value", "comp:other"}}}).ok,
"Calendar day or foreign preview league selection failed");
calendar = calendar_source.snapshot().state.at("calendar");
require(calendar_fixtures(calendar, *calendar_world, "club:a").size() == 38 &&
calendar["selected"] == 30 &&
calendar_source.snapshot().state["managers"] == original_calendar.state["managers"],
"Foreign calendar preview changed selection or career identity");
calendar_source.save(root / "calendar.ui.json", default_desktop());
DemoSource restored_calendar(calendar_world);
restored_calendar.load(root / "calendar.ui.json");
require(restored_calendar.snapshot().state["calendar"] == calendar,
"Calendar selection was lost on process restoration");
GuiAssets absent(root / "missing-gui");
require(!absent.available(),
"World resources were mistaken for GUI resources");