Port environment, advertising and Toto menus to native Modern UI (by Codex)

This commit is contained in:
Codex committed 2026-10-24 11:12:25 +02:00
1 parent 0aa0ed68ca
commit d92cfc3110
36 files changed
+1805 -13

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 --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 --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_)" --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_)" --output-on-failure --output-junit modern-ui-results.xml
- name: Upload test report
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
+64
View File
@@ -0,0 +1,64 @@
/* SPDX-License-Identifier: GPL-3.0-only */
.advertising-page {position:absolute;left:0;right:0;top:0;bottom:0;}
.advertising-boards {position:absolute;left:0;right:0;top:0;height:310dp;border:2dp var(--border);border-radius:18dp;background-color:#13232e40;}
.advertising-board {position:absolute;min-width:0;min-height:0;padding:16dp 12dp 40dp;border:2dp var(--border);border-radius:12dp;background-color:transparent;decorator:linear-gradient(180deg,#90a6b51c,#6b83950d);color:var(--text);font-size:28dp;display:flex;align-items:center;justify-content:center;}
.advertising-board:hover {background-color:#c5d9e726;}
.advertising-board small {position:absolute;left:0;right:0;width:100%;bottom:10dp;text-align:center;font-size:22dp;line-height:25dp;color:var(--muted);}
.advertising-board small>span,.advertising-free {display:block;width:100%;text-align:center;white-space:nowrap;}
.advertising-free {font-size:27dp;line-height:31dp;color:#bdcdd8;}
.advertising-board.selected,.advertising-card.selected {border-color:var(--accent);}
.ad-brand {display:flex;align-items:center;justify-content:center;min-width:0;max-width:100%;background-color:#f5efdc;color:#12334b;padding:10dp 16dp;font-size:38dp;font-weight:bold;line-height:1.2;letter-spacing:1dp;overflow:hidden;}
.ad-brand>span {display:block;width:100%;text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.ad-brand-1 {background-color:#154c7b;color:#fcf6c9;}
.ad-brand-2 {background-color:#f4cc55;color:#3e3630;}
.ad-brand-3 {background-color:#daddce;color:#ab2d2d;}
.ad-brand-4 {background-color:#c73529;color:#ffebc5;}
.advertising-board .ad-brand {width:100%;min-height:62dp;padding:8dp;border-radius:5dp;font-size:26dp;letter-spacing:.5dp;}
.advertising-card {position:absolute;min-width:0;padding:0;border:2dp var(--border);border-radius:18dp;background-color:#11263266;color:var(--text);font-size:30dp;overflow:hidden;}
.advertising-card:hover {background-color:#20374380;}
.advertising-card>strong {position:absolute;left:0;right:0;top:0;height:64dp;border-bottom:2dp var(--border);background-color:#90a8b410;font-size:30dp;font-weight:normal;display:flex;align-items:center;justify-content:center;}
.advertising-card>strong>span {display:block;width:100%;text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.advertising-art {position:absolute;left:61.25dp;top:65dp;width:510dp;height:510dp;}
.advertising-shirt .advertising-art {top:100dp;}
.advertising-card>output {position:absolute;left:0;right:0;bottom:0;height:70dp;border-top:2dp var(--border);background-color:#10232e66;color:#b8dfd0;font-size:33dp;display:flex;align-items:center;justify-content:center;}
.advertising-card>output>span {display:block;width:100%;text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.advertising-shirt>.ad-brand {position:absolute;left:35%;top:52%;width:30%;max-height:94dp;padding:4dp;font-size:21dp;border-radius:4dp;}
.advertising-tv {left:0;top:1032dp;width:596dp;height:638dp;}
.advertising-tv-art {position:absolute;left:26dp;top:79dp;width:540dp;height:540dp;}
.advertising-tv>.ad-brand {position:absolute;left:14%;top:26%;width:35%;height:20%;padding:4dp;font-size:22dp;border-radius:8dp;}
.advertising-details {position:absolute;left:636dp;right:0;top:1032dp;bottom:4dp;border:2dp var(--border);border-radius:18dp;background-color:#13232e40;}
.advertising-hint {position:absolute;left:60dp;right:60dp;top:88dp;font-size:29dp;line-height:46.4dp;text-align:left;color:#a4bacb;}
.advertising-hint h2 {margin:0 0 30dp;font-size:38dp;line-height:60.8dp;font-weight:normal;color:var(--text);}
.advertising-hint p {margin:12dp 0;}
.advertising-offer {position:absolute;left:32dp;right:32dp;top:28dp;height:310dp;}
.ad-offer-mark {position:absolute;left:0;top:70dp;width:430dp;height:170dp;}
.ad-offer-mark .ad-brand {width:430dp;height:170dp;padding:16dp;border-radius:12dp;font-size:38dp;}
.ad-offer-arrows {position:absolute;left:458dp;top:70dp;width:84dp;height:170dp;display:flex;flex-direction:column;gap:18dp;}
.ad-offer-arrow {width:84dp;height:76dp;flex-shrink:0;padding:0;border-radius:12dp;font-size:52dp;line-height:52dp;display:flex;align-items:center;justify-content:center;color:#bfd5e4;}
.ad-offer-arrow>span {display:block;width:100%;text-align:center;}
.ad-offer-facts {position:absolute;left:570dp;right:0;top:82dp;height:146dp;font-size:30dp;line-height:34dp;}
.ad-offer-facts>div {height:56dp;display:flex;gap:28dp;}
.ad-offer-facts>div>span {display:block;width:200dp;flex-shrink:0;color:#9fb7c9;white-space:nowrap;}
.ad-offer-facts>div:first-child>span {color:var(--text);}
.ad-offer-facts>div>strong {display:block;flex:1;min-width:0;font-weight:normal;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.advertising-actions {position:absolute;left:32dp;right:32dp;top:356dp;height:82dp;display:flex;gap:24dp;}
.advertising-control {flex:1;min-width:0;height:82dp;padding:12dp 24dp;border-radius:12dp;font-size:30dp;background-color:transparent;decorator:linear-gradient(180deg,#c1d1e31c,#869eb312);}
.advertising-totals {position:absolute;left:32dp;right:32dp;bottom:28dp;height:105dp;border-top:2dp var(--border);padding-top:24dp;display:flex;gap:24dp;font-size:25dp;line-height:29dp;}
.advertising-totals>div {flex:1;min-width:0;}
.advertising-totals>div>span {display:block;width:100%;color:#a0b7c8;white-space:nowrap;}
.advertising-totals output {display:block;width:100%;margin-top:12dp;font-size:33dp;line-height:38dp;white-space:nowrap;color:var(--text);}
.advertising-totals>div:last-child>output {color:#b8dfd0;}
body.silver .advertising-boards,body.silver .advertising-details,body.silver .advertising-card,body.silver .advertising-card>output {background-color:#f1f6fa80;}
body.silver .advertising-board {decorator:linear-gradient(180deg,#ffffffb0,#bfd0e259);}
body.silver .advertising-board:hover,body.silver .advertising-card:hover {background-color:#ffffff80;}
body.silver .advertising-free,body.silver .advertising-hint,body.silver .ad-offer-facts>div>span,body.silver .advertising-totals>div>span {color:#526779;}
body.silver .ad-offer-arrow {color:#233443;}
body.silver .advertising-card>output,body.silver .advertising-totals>div:last-child>output {color:#25617a;}
body.silver .advertising-control {decorator:linear-gradient(180deg,#ffffffb0,#bfd0e259);}
body.matchday .advertising-boards,body.matchday .advertising-details,body.matchday .advertising-card,body.matchday .advertising-card>output {background-color:#1d1e2466;}
body.matchday .advertising-board {decorator:linear-gradient(180deg,#e8d6dc12,#a1a0aa0d);}
body.matchday .advertising-board:hover,body.matchday .advertising-card:hover {background-color:#ffffff12;}
body.matchday .advertising-free,body.matchday .advertising-hint,body.matchday .ad-offer-facts>div>span,body.matchday .advertising-totals>div>span {color:#b7b4b9;}
body.matchday .ad-offer-arrow {color:#efeded;}
body.matchday .advertising-card>output,body.matchday .advertising-totals>div:last-child>output {color:#efb2aa;}
body.matchday .advertising-control {decorator:linear-gradient(180deg,#e8d6dc12,#a1a0aa0d);}
+36
View File
@@ -0,0 +1,36 @@
/* SPDX-License-Identifier: GPL-3.0-only */
/* Diamond 3.6: six budgets surrounding the club's crest, no additional footer. */
.environment-ring {position:absolute;left:0;top:0;width:2612dp;height:1864dp;}
.environment-card {position:absolute;padding:18dp;border:2dp var(--border);border-radius:20dp;background-color:var(--panel);color:var(--text);text-align:center;box-shadow:0dp 10dp 28dp #0002;}
.environment-card h2 {position:absolute;left:18dp;right:18dp;top:18dp;height:36dp;margin:0;font-size:30dp;line-height:36dp;font-weight:normal;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.environment-stars {position:absolute;left:18dp;right:18dp;top:66dp;height:58dp;padding:4dp;border:2dp var(--border);border-radius:12dp;background-color:var(--panel);display:flex;align-items:center;justify-content:center;}
.environment-level {position:relative;display:flex;align-items:center;justify-content:center;flex:1;min-width:0;height:46dp;margin:0;padding:0;border:0dp;border-radius:7dp;background-color:transparent;font-size:40dp;}
.environment-level.zero {flex:0.65;font-size:30dp;color:var(--muted);}
.environment-level-icon {display:block;flex-shrink:0;width:40dp;height:40dp;}
.environment-level-icon .image-frame {width:40dp;height:40dp;}
.environment-zero-label {display:block;min-width:0;width:100%;max-width:100%;font-size:30dp;line-height:30dp;white-space:nowrap;text-align:center;}
.environment-level.selected {background-color:var(--selected);}
.environment-level:hover {background-color:var(--hover);}
.environment-level:focus-visible {border:2dp var(--accent);}
.environment-selection-line {position:absolute;left:0;right:0;bottom:0;height:2dp;display:block;pointer-events:none;background-color:#e5cd8c;}
.environment-picture {position:absolute;overflow:hidden;border-radius:12dp;}
.environment-caption {position:absolute;left:18dp;right:18dp;display:flex;flex-direction:column;align-items:center;justify-content:center;color:var(--text);}
.environment-cost {display:block;min-width:0;width:100%;max-width:100%;height:37.8dp;font-size:28dp;line-height:37.8dp;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-align:center;}
.environment-standing {display:block;min-width:0;width:100%;max-width:100%;height:36.75dp;padding-top:3dp;line-height:33.75dp;font-size:25dp;white-space:nowrap;text-align:center;color:var(--muted);}
.environment-card.youth-a .environment-standing {color:var(--danger);}
.environment-emblem {position:absolute;left:1106dp;top:640dp;width:400dp;height:400dp;pointer-events:none;}
.environment-ball {position:absolute;left:0;top:0;width:400dp;height:400dp;filter:drop-shadow(#0005 0dp 12dp 18dp);}
.environment-crest {position:absolute;left:112dp;top:112dp;width:176dp;height:176dp;padding:7dp;border:0dp;border-radius:88dp;background-color:#ffffff;overflow:hidden;display:flex;align-items:center;justify-content:center;}
.environment-crest .image-frame {flex-shrink:0;}
.environment-crest>span {display:block;font-size:30dp;line-height:36dp;color:#526779;}
.environment-unavailable {position:absolute;left:40dp;right:40dp;top:700dp;font-size:32dp;line-height:46dp;text-align:center;color:var(--muted);}
body.midnight .environment-card {border-color:#c5d9e726;background-color:#12243166;color:#dce6ee;}
body.midnight .environment-stars {border-color:#c5d9e726;background-color:#111e2b66;}
body.midnight .environment-level.zero {color:#a2b5c5;}
body.midnight .environment-level.selected {background-color:#9cb9c52b;}
body.midnight .environment-level:hover {background-color:#bfd6e32b;}
body.midnight .environment-cost {color:#bad7df;}
body.midnight .environment-standing {color:#a1b7c8;}
body.midnight .environment-card.youth-a .environment-standing {color:#dfa69d;}
body.silver .environment-card,body.silver .environment-stars {background-color:#f1f6fa80;}
body.matchday .environment-card,body.matchday .environment-stars {background-color:#1d1e2466;}
+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"/></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"/></head>
<body class="midnight">
<div id="background"></div>
<div id="canvas"></div>
+100
View File
@@ -0,0 +1,100 @@
/* SPDX-License-Identifier: GPL-3.0-only */
.toto-native {position:absolute;left:0;top:0;right:0;bottom:0;}
.toto-program {position:absolute;left:0;top:0;width:1116.265625dp;height:1614dp;padding:28dp;border:2dp var(--border);border-radius:18dp;background-color:var(--panel);overflow:hidden;}
.toto-program>header {position:absolute;left:28dp;right:28dp;top:28dp;height:176dp;padding:8dp 10dp;border-bottom:2dp var(--border);}
.toto-program>header>p {margin:0 0 8dp;font-size:24dp;line-height:28dp;color:var(--muted);}
.toto-program h2 {margin:0 0 14dp;font-size:42dp;font-weight:bold;line-height:48dp;}
.toto-program>header>span {font-size:27dp;line-height:31dp;}
.toto-program-head {position:absolute;left:28dp;right:28dp;top:204dp;height:94dp;padding:0 12dp 16dp;border-bottom:2dp var(--border);display:flex;align-items:flex-end;gap:20dp;color:var(--muted);font-size:24dp;}
.toto-program-head>span {width:90dp;flex-shrink:0;line-height:28dp;}
.toto-program-head>span:nth-child(2) {flex:1;width:auto;text-align:center;}
.toto-program-head>span:last-child {text-align:right;}
.toto-match-row {position:absolute;left:28dp;right:28dp;height:82dp;padding:5dp 12dp;border-bottom:2dp var(--border);display:flex;align-items:center;gap:20dp;}
.toto-match-row.striped {background-color:var(--soft);}
.toto-match-number {width:90dp;flex-shrink:0;font-size:28dp;}
.toto-match-league {width:90dp;flex-shrink:0;font-size:23dp;text-align:right;color:var(--muted);white-space:nowrap;}
.toto-match-teams {display:flex;align-items:center;gap:10dp;flex:1;min-width:0;}
.toto-match-teams>div {display:flex;align-items:center;flex:1;min-width:0;}
.toto-home {justify-content:flex-end;}
.toto-away {justify-content:flex-start;}
.toto-versus {width:32dp;flex-shrink:0;text-align:center;font-size:28dp;color:var(--muted);}
.toto-club-label {display:flex;align-items:center;gap:10dp;max-width:100%;min-width:0;font-size:26dp;line-height:34dp;}
.toto-club-label .image-frame {flex-shrink:0;}
.toto-club-name {display:block;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.toto-home .toto-club-name {text-align:right;}
.toto-program-note {position:absolute;left:38dp;right:38dp;top:1228dp;font-size:24dp;line-height:36dp;color:var(--muted);margin:0;}
.toto-coupon {position:absolute;left:1152.265625dp;top:0;width:1459.734375dp;height:1614dp;padding:28dp;border:2dp #dfc9b9;border-radius:4dp;background-color:#fff8ed;color:#bd302c;overflow:hidden;box-shadow:0dp 18dp 40dp #0004;}
.toto-print-mark {position:absolute;left:8dp;width:5dp;height:40dp;background-color:#bd302c;}
.toto-print-mark.top {top:30dp;}.toto-print-mark.bottom {bottom:30dp;}
.toto-paper-heading {position:absolute;left:28dp;right:28dp;top:28dp;height:154dp;border-bottom:3dp #bd302c;display:flex;align-items:center;justify-content:space-between;}
.toto-paper-brand {width:40%;}
.toto-paper-brand>strong {display:block;font-size:76dp;font-weight:bold;letter-spacing:-6dp;line-height:68.4dp;transform:skewX(-8deg);}
.toto-paper-brand h2 {margin:12dp 0 0;font-size:28dp;font-weight:bold;letter-spacing:3dp;line-height:33.6dp;color:#bd302c;}
.toto-paper-caption {display:flex;flex-direction:column;gap:12dp;align-items:flex-end;width:55%;}
.toto-paper-caption>strong,.toto-paper-caption>span,.toto-paper-caption>small {display:block;width:100%;text-align:right;}
.toto-paper-caption>strong {font-size:35dp;line-height:42dp;font-weight:normal;}
.toto-paper-caption>span {font-size:25dp;line-height:30dp;}
.toto-paper-caption>small {font-size:22dp;line-height:26.4dp;}
.toto-field {position:absolute;top:182dp;width:221.619792dp;height:1066dp;}
.toto-column-heading {position:absolute;left:0;top:0;width:100%;height:74dp;padding:0 12dp;border:0dp;border-bottom:3dp transparent;border-radius:0dp;background-color:transparent;color:#bd302c;display:flex;align-items:center;justify-content:space-between;gap:8dp;}
.toto-column-heading>span {display:block;font-size:23dp;white-space:nowrap;}
.toto-column-heading>strong {display:block;width:34dp;height:36dp;line-height:36dp;text-align:center;flex-shrink:0;font-size:26dp;font-weight:normal;background-color:#bd302c;color:#fff8ed;}
.selected-column .toto-column-heading {border-bottom-color:#bd302c;background-color:#bd302c0a;}
.toto-column-heading:hover {background-color:#bd302c13;}
.toto-pick-head {position:absolute;left:0;top:74dp;width:100%;height:42dp;border-bottom:2dp #bd302c;font-size:24dp;text-align:center;}
.toto-pick-head>span {position:absolute;top:0;height:40dp;line-height:40dp;}
.toto-pick-head>span:first-child {font-size:17dp;}
.toto-pick-row {position:absolute;left:0;width:100%;height:82dp;border-bottom:1dp #d1554f55;}
.toto-row-number {position:absolute;left:0;top:8.5dp;width:28dp;height:64dp;line-height:64dp;text-align:center;background-color:#bd302c;color:#fff8ed;font-size:24dp;}
.toto-pick {position:absolute;top:8.5dp;height:64dp;display:flex;align-items:center;justify-content:center;padding:0;border:2dp #cd4740;border-radius:0dp;background-color:transparent;color:#c0443d;font-size:28dp;}
.toto-pick:hover {background-color:#bd302c0c;}.toto-pick[aria-pressed=true] {color:#c06a63;}
.toto-pick:focus-visible,.toto-column-heading:focus-visible {box-shadow:0dp 0dp 0dp 3dp #253e62;background-color:#253e6210;}
.toto-pick-value {display:block;width:100%;line-height:34dp;text-align:center;}
.toto-cross {position:absolute;left:-2dp;top:-2dp;width:59.53993dp;height:64dp;pointer-events:none;}
.toto-field-progress {position:absolute;top:1018dp;left:0;width:100%;height:48dp;line-height:48dp;text-align:center;margin:0;font-size:19dp;color:#a53a33;}
.toto-paper-footer {position:absolute;left:28dp;right:28dp;top:1248dp;padding-top:16dp;border-top:2dp #bd302c;}
.toto-paper-footer p {margin:0 0 10dp;font-size:23dp;line-height:27.6dp;text-align:center;}
.toto-paper-footer strong {font-weight:bold;}.toto-paper-footer b {font-weight:normal;margin:0 12dp;}
.toto-paper-footer>span {display:block;font-size:22dp;line-height:30.8dp;}
.toto-paper-footer>small {display:block;margin-top:12dp;padding-top:10dp;border-top:2dp #bd302c66;font-size:18dp;line-height:21.6dp;letter-spacing:.6dp;}
.toto-status {position:absolute;left:0;right:0;top:1644dp;height:92dp;display:flex;align-items:center;justify-content:space-between;gap:30dp;font-size:28dp;color:var(--muted);}
.toto-status>div {display:flex;flex-direction:column;gap:12dp;width:60%;}
.toto-status>div>strong {display:block;width:100%;font-size:30dp;font-weight:normal;color:var(--text);line-height:35dp;}
.toto-status>div>span {display:block;width:100%;font-size:25dp;line-height:29dp;}
.toto-status>p {margin:0;white-space:nowrap;}.toto-status>p>strong {margin-left:24dp;font-size:34dp;font-weight:normal;color:var(--accent);}
.toto-nav {position:absolute;left:0;right:0;bottom:0;height:94dp;display:flex;gap:20dp;}
.toto-control {display:flex;align-items:center;justify-content:center;flex:1;min-width:0;padding:8dp 15dp;border:2dp var(--border);border-radius:12dp;background-color:transparent;decorator:linear-gradient(180deg,#c1d1e31c,#869eb312);font-size:30dp;}
.toto-control>span {display:block;width:100%;white-space:nowrap;text-align:center;}
.toto-layer {position:absolute;left:0;right:0;top:0;bottom:0;display:flex;align-items:center;justify-content:center;background-color:#08101980;z-index:30;}
.toto-dialog {width:2484dp;padding:40dp 52dp;border:2dp var(--border);border-radius:22dp;background-color:#283542f5;font-size:36dp;box-shadow:0dp 24dp 70dp #0007;}
.toto-dialog h2 {width:100%;font-size:42dp;line-height:48dp;font-weight:bold;letter-spacing:-.4dp;text-align:center;margin:0 0 35dp;}
.toto-dialog.receipt {height:1172dp;background-color:#283542;}
.toto-receipt {width:100%;height:820dp;overflow-y:auto;}
.toto-receipt-row {display:flex;height:64dp;width:100%;font-size:34dp;}
.toto-receipt-row>span {display:block;flex-shrink:0;height:64dp;line-height:64dp;text-align:center;}
.toto-receipt-row.head {color:var(--muted);border-bottom:2dp var(--border);}
.toto-receipt-row.striped {background-color:#38706b19;}
.toto-receipt-total {margin:30dp 0 0;font-size:30dp;line-height:45dp;text-align:right;color:var(--accent);}
.toto-notice {margin:36dp 0;line-height:54dp;}
.toto-dialog-actions {display:flex;height:65dp;width:100%;margin-top:45dp;}
.toto-dialog-actions .toto-control {font-size:32dp;}
body.midnight .toto-program {background-color:#12243140;border-color:#c5d9e726;}
body.midnight .toto-program>header>p {color:#97afc2;}
body.midnight .toto-program h2 {color:#e5edf3;}
body.midnight .toto-program>header>span {color:#b4c7d6;}
body.midnight .toto-match-row.striped {background-color:#c5d9e704;}
body.midnight .toto-match-row {border-color:#c5d9e717;}
body.midnight .toto-club-label {color:#d7e3ec;}
body.midnight .toto-away .toto-club-label {color:#a9bfce;}
body.midnight .toto-program-note {color:#91aabb;}
body.midnight .toto-status {color:#9eb7c8;}
body.midnight .toto-status>div>strong {color:#d1e3ec;}
body.midnight .toto-status>p>strong,body.midnight .toto-receipt-total {color:#cce5dc;}
body.silver .toto-control {decorator:linear-gradient(180deg,#ffffffb0,#bfd0e259);}
body.matchday .toto-control {decorator:linear-gradient(180deg,#e8d6dc12,#a1a0aa0d);}
body.silver .toto-dialog,body.silver .toto-dialog.receipt {background-color:#eaf1f7fc;}
body.matchday .toto-dialog,body.matchday .toto-dialog.receipt {background-color:#2c2c32fc;}
.toto-dialog.notice {position:relative;height:332dp;}
.toto-dialog.notice .toto-notice {position:absolute;left:52dp;right:52dp;top:124dp;height:54dp;margin:0;}
.toto-dialog.notice .toto-dialog-actions {position:absolute;left:52dp;right:52dp;top:223dp;width:auto;height:65dp;margin:0;}
.toto-program>header>span {position:absolute;left:10dp;top:125.5dp;height:31dp;line-height:31dp;}
+2 -2
View File
@@ -1,8 +1,8 @@
# Abfragen für die neue Oberfläche (M6)
Michaels Entscheidung: Die neue Oberfläche wird **je Menü** an die Modern-Engine angebunden. Jedes Menü bekommt feste Abfragen (und später Aktionen), die die Engine baut und hier dokumentiert; Codex stellt Menü für Menü vom Demo auf die Abfrage um. Die Demo bleibt nutzbar.
Vereinbarter Ablauf: Die neue Oberfläche wird **je Menü** an die Modern-Engine angebunden. Jedes Menü bekommt feste Abfragen (und später Aktionen), die die Engine baut und hier dokumentiert; Codex stellt Menü für Menü vom Demo auf die Abfrage um. Die Demo bleibt nutzbar.
**Reihenfolge (Michael):** Zuerst wird die GUI mit Demodaten fertig gebaut. Danach legt Codex je Menü fest, welche Daten es braucht, und die Engine liefert die passende Abfrage. Später soll alles auf ein durchgehendes JSON-Format umgestellt werden; die Antworten verwenden deshalb schon jetzt überall dieselben Teilobjekte, damit sie sich zu einem gemeinsamen JSON-Zustand zusammensetzen lassen.
**Reihenfolge:** Zuerst wird die GUI mit Demodaten fertig gebaut. Danach legt Codex je Menü fest, welche Daten es braucht, und die Engine liefert die passende Abfrage. Später soll alles auf ein durchgehendes JSON-Format umgestellt werden; die Antworten verwenden deshalb schon jetzt überall dieselben Teilobjekte, damit sie sich zu einem gemeinsamen JSON-Zustand zusammensetzen lassen.
## Vertrag
+7
View File
@@ -69,6 +69,13 @@ wird ausdrücklich mit `OPENBMH_BUILD_MODERN_UI=ON` gebaut.
Die gemeinsame Zahleneingabe bietet sechs Vorschlagswerte, Tastaturbedienung,
lokale Entwürfe und eine zweite Bestätigung vor Geldänderungen.
- [Umfeld](desktop/environment/README.md): sechs Förderbereiche mit jeweils
0–6 Sternen, Monatskostenvorschau, Jugendständen und eigenem Vereinswappen.
- [Werbung](desktop/advertising/README.md): 14 Banden, Trikot- und TV-Verträge,
je drei Angebotsvarianten, drei Budgets und Vorschau der Gesamtsummen.
- [TOTO](desktop/toto/README.md): roter Elferwette-Schein mit sechs unabhängigen
Spalten, Gesamteinsatz, Tippvorschlag, Vormerkung und letztem Schein.
**Anstoß führt keine Aktion aus**, weder per Maus noch per Tastatur. Das gilt
auch für die direkte Aktionsschnittstelle des Demoanbieters.
+3
View File
@@ -20,6 +20,9 @@ Implementierung in der Spiel-Engine.
| Taktik | [Interaktive Diagramme und Einsatzregler](desktop/tactics/README.md) |
| Kalender | [Zwölf Monate, transponierte Wochen und Ligavorschau](desktop/calendar/README.md) |
| Zahleneingabe | [Entwurf, Vorschläge und Bestätigung](desktop/number-entry/README.md) |
| Umfeld | [Förderstufen, Betreuung und Jugend](desktop/environment/README.md) |
| Werbung | [Banden, Trikot, TV und Budgets](desktop/advertising/README.md) |
| TOTO | [Sechs Tipp-Spalten und Vormerkung](desktop/toto/README.md) |
| Bank | [Sparbuch, Immobilien, Aktien und Kredit](desktop/bank/README.md) |
| Bilanz | [Aktuelle Bilanz und Zukunftsplanung](desktop/balance/README.md) |
| Verträge | [Kaderdaten, Angebote, Versicherung und Prämien](desktop/contracts/README.md) |
+142
View File
@@ -0,0 +1,142 @@
# Werbung und Vereinsausgaben · native Modern UI
Stand: 24. Oktober 2026. Die native Ansicht übernimmt das private
HTML-Mockup `bmh_4k_ui`, Referenzrevision
`9db6926d7f3d89a7c4219ae38f274766f060783a`. Maßgeblich sind
`desktop/finance-menus.js`, `finance-menus.css`,
`advertising-friendlies-window.css` und `menu-themes.css`.
Native Quellen:
[advertising_screens.inc](../../../../src/modern/ui/advertising_screens.inc),
[advertising_controls.inc](../../../../src/modern/ui/advertising_controls.inc),
[advertising.rcss](../../../../assets/modern/advertising.rcss) und
[demo_advertising.hpp](../../../../src/modern/ui/demo_advertising.hpp).
Private Referenzbilder und Weltdaten werden nicht öffentlich mitgeliefert.
## Aufbau und Bedienung
Oben stehen vierzehn Werbebanden in zwei Reihen mit sieben Spalten. Jede
Bande zeigt „Platz frei“ oder ihren vereinbarten Sponsor sowie ihre
Bandennummer. Darunter folgen die vier Bildkarten Trikotwerbung,
Fanartikel, Öffentlichkeitsarbeit und Fanbetreuung. TV-Rechte liegen
links unten, der Angebots- und Summenbereich rechts daneben. Banden,
Trikot und TV sind als Vertragsplätze auswählbar; die drei übrigen
Bildkarten öffnen die jeweilige Budgeteingabe.
Die Auswahl eines freien Platzes zeigt ein fiktives Angebot mit Sponsor,
Dauer und Monatsbetrag. Zwei Pfeile blättern zyklisch durch drei Angebote
mit zwölf, vierundzwanzig und sechsunddreißig Monaten Laufzeit. Erst
„Annehmen“ speichert die Vereinbarung. Bei einem belegten Platz erscheinen
der laufende Sponsor und Vertrag; Pfeile und Annahme sind gesperrt.
„Schließen“ beziehungsweise „Abbrechen“ hebt nur die lokale Auswahl auf,
eine bestehende Vereinbarung bleibt erhalten.
Escape und Rechtsklick heben zunächst eine offene Vertragsauswahl auf.
Im Budgeteditor schließt Escape zuerst die Zahleneingabe. Die
Schließen-Schaltfläche des Fensters beendet wie in der HTML-Vorlage das
Menü. Die Bedienelemente behalten eindeutige IDs und zugängliche Namen;
Beschriftungen verwenden begrenzte Textbreiten.
Die drei Ausgabenfelder erlauben ganze angezeigte Währungseinheiten von
0 bis 99.999.999. Vorschläge steigen bei Fanartikeln um 50.000 und bei
Öffentlichkeitsarbeit beziehungsweise Fanbetreuung um 5.000. Dies sind
Vorschlagsabstände, keine Beschränkung auf solche Vielfachen. Die
Zahleneingabe enthält acht Rohziffern, MAX und C; sie ist kein
arithmetischer Taschenrechner. „Übernehmen“ führt zur zweiten
Bestätigung. Ändern oder Abbrechen verändert keinen gespeicherten Wert.
Einnahmen sind die Summe der sechzehn Vertragsbeträge, Ausgaben die Summe
der drei Budgets, Saldo deren Differenz. Es handelt sich um fiktive
Monatswerte. Annahme und Budgetänderung buchen keine Ein- oder Auszahlungen
auf das gemeinsame Konto.
## Datenvertrag und Revisionsschutz
Der Provider arbeitet auf dem vollständigen Präsentationszustand und
besitzt ausschließlich dessen oberstes Feld `advertising`:
```text
advertising:
spending: [Fanartikel, Öffentlichkeitsarbeit, Fanbetreuung]
contracts: 16 × {sponsor, months, amount}
```
Alle gespeicherten Geldwerte sind Minor Units von `manifest.currency`.
Bei null Nachkommastellen entspricht eine gespeicherte Einheit einer
angezeigten Einheit, bei zwei Nachkommastellen sind es hundert. Der
Budgeteditor übergibt ganze Anzeigeeinheiten; der Provider multipliziert
sie genau einmal mit diesem Faktor. Vorhandene gültige Centwerte werden
beim Laden nicht still gerundet.
Die Plätze 0 bis 13 bezeichnen Banden, 14 Trikotwerbung und 15 TV-Rechte.
Ein freier Vertrag hat `sponsor: -1`, `months: 0`, `amount: 0`. Aktive
Verträge haben einen bekannten Anbieterindex, 12/24/36 Monate und einen
positiven Betrag innerhalb des Geldlimits. Für Banden und Trikot gibt es
zehn fiktive Sponsoren, für TV fünf Sender. Die Auswahlformel folgt der
HTML-Referenz; sie verwendet weder Zufall noch aktuelle Engineangebote.
`migrate_demo_advertising()` ergänzt bei älteren UI-Demoständen das
vollständig fehlende Werbefeld mit freien Plätzen und den Startbudgets
50.000 / 15.000 / 10.000. Ein vorhandenes Werbefeld wird streng validiert:
fehlerhafte Typen, unbekannte Felder, unzulässige Indizes und beschädigte
Verträge führen zur atomaren Ablehnung. Es werden keine teilweise
beschädigten Bestände repariert.
`edit_demo_advertising()` unterstützt zwei Änderungen:
- `{kind: "accept", slot, offer}` berechnet das gewählte Angebot erneut
und übernimmt es nur in einen weiterhin freien Platz.
- `{kind: "spending", index, value}` bestätigt genau eines der drei
Budgets in ganzen Anzeigeeinheiten.
Beide Aktionen validieren den gesamten Werbezustand und publizieren erst
dann die vollständige Kopie. `demo_advertising_quote()` und
`demo_advertising_view()` liefern ausschließlich Leseprojektionen.
**OpenBMH deviates from the original:** Auswahl und Angebotsnummer bleiben
flüchtige App-Felder und ersetzen die gespeicherten Navigationsfelder
des HTML-Prototyps.
Eine sichtbare Quote und jeder Budgetentwurf sind an Welt und beobachtete
Source-Revision gebunden. Veraltete Bestätigungen werden nicht auf einen
inzwischen veränderten Stand angewandt.
## Referenzgeometrie und Ressourcen
Die logische Inhaltsfläche beträgt 2612 × 1864. Der Bandenbereich ist
310 hoch, mit 16 Einheiten Abstand zwischen den Knöpfen. Die vier
636,5 × 650 großen Bildkarten beginnen bei y346 und haben 22 Einheiten
Abstand. TV liegt bei `(0,1032,596,638)`, der Detailbereich bei
`(636,1032,1976,828)`. Im Angebot sind Sponsorbild, Pfeile und Fakten in
430 / 84 / verbleibende Breite aufgeteilt. Drei Summenspalten stehen am
unteren Rand. Midnight, Silver und Matchday verwenden dieselbe Anordnung.
Die GUI-Schlüssel `advertising.panel.0` bis `.3` referenzieren die vier
unveränderten Quadranten des vorhandenen Bilderatlas. TV verwendet
`art.advertising-tv-v1.png`. Diese festen GUI-Bilder gehören zum
GUI-Ressourcenpaket, nicht in die OBW-Welt oder deren Assetindex. Es werden
keine neuen Originalbilder in öffentliche Tests oder Dokumente kopiert.
## Prüfstand und Enginegrenze
Die synthetischen Komponententests in
[modern_advertising_ui_tests.cpp](../../../../tests/modern_advertising_ui_tests.cpp)
prüfen beide Währungspräzisionen, die drei Angebotsarten, aktive
Vertragssperren, alle sechzehn Plätze, Betragsgrenzen und große Summen,
Nullwerte, ungültige Eingaben, atomare Migration sowie unveränderte
Konten und Katalogdaten.
Die native Linuxprüfung ist mit Midnight, Silver und Matchday jeweils bei
1920 × 1080 und 1280 × 720 erfolgreich ausgeführt. Defaultansicht,
Angebot und aktiver Vertrag wurden gegen die HTML-Vorlage geprüft;
Bildpositionen, Bandenbeschriftungen und Hinweiszeilen sind abgeglichen.
Der Interaktionslauf prüft Null und MAX, Entwurf/Review/Ändern/Abbruch,
Trikot und TV, aktuelle Angebotsbindung nach einer Budgetänderung sowie
unveränderte Konten. Escape, Rechtsklick und Fensterschließen sind mit
unveränderten Modell- und Revisionswerten geprüft. Ein durch den nativen
`checkpoint`-Befehl geschriebener UI-Demostand wurde in einer zweiten
Appinstanz mit exakt gleichem Modell wieder geladen; die lokale Auswahl
startet dort bei `-1`. Dies dokumentiert Linux-Ergebnisse und keine
Laufzeitprüfung anderer Plattformen.
Es gibt keine Anbindung an Engine, Classic-Initialisierung, Session,
Spielzeit oder Zufallsströme. Vereinbarungen laufen in dieser Demo nicht
monatlich ab und erzeugen keine echten Buchungen. Ein späterer
Sessionadapter muss verbindliche Werbeverträge und Ausgabenregeln liefern.
+38
View File
@@ -0,0 +1,38 @@
# Umfeld
Stand: 24. Oktober 2026. Die native Ansicht übernimmt die Diamond-3.6-
Anordnung des privaten HTML-Golds `bmh_4k_ui`, Revision `9db6926d`:
`desktop/submenus.js`, `submenus.css` und `table-window.css`. Sechs Karten
stehen um Ball und Vereinswappen: drei Nachwuchsstufen, Co-Trainer,
Vereinsarzt und Masseur. Alle drei Glas-Themen behalten diese Anordnung.
Jede Karte bietet eine Nulltaste und **sechs** Sterne. Ein Klick wählt den
Budgetwert unmittelbar; erneut gewählte Werte bleiben bestehen. Gold sieht
hier keinen Ausgabenentwurf oder Bestätigungsdialog vor. Der neue
Präsentationszustand `environment.levels` enthält sechs Ganzzahlen von
0 bis 6; seine Startwerte sind `2,3,4,3,4,2`. Die OBW-Tabelle `staff` bleibt
schreibgeschützt und wird nicht als zweite Budgetquelle verwendet.
Die fiktiven Monatsgrundpreise betragen 2.000/3.000/5.000 für Nachwuchs und
7.500/6.000/4.500 für Personal. Der Kartenbetrag ist Grundpreis mal Sternzahl,
in der internen kleinsten Währungseinheit. Null Sterne ergeben echte
Vorschaukosten von null; sechs Sterne bleiben vollständig verfügbar.
Die Jugendplätze 11./1. Liga, 3./2. Liga und 7./1. Liga sind feste
Demobeispiele. Sie entstehen weder aus Spielen noch aus den Sternen.
Die Auswahl bucht kein Guthaben ab, ändert keine Mitarbeiterverträge und
simuliert weder Nachwuchs noch Training, Zeit oder Zufall. Classic und
Engine bleiben unverändert. Der geladene erste Manager liefert lediglich
das tatsächliche Vereinswappen; es werden keine Mitarbeiternamen erfunden.
Die Bilder gehören zum separaten GUI-Ressourcensatz, nicht zur OBW-Welt;
Sterne sind native SVG-Formen und benötigen kein besonderes Schriftglyph.
Migration ergänzt nur einen fehlenden Umfeldzustand. Vorhandene ungültige
Werte werden atomar abgewiesen. Synthetische Prüfungen stehen in
`tests/modern_environment_ui_tests.cpp`. Gemeinsamer Build und alle 24
Regressionstests sind erfolgreich. Die native Abnahme umfasst alle drei
Themen bei 1280×720 und 1920×1080: sechs Karten und 42 Bedientasten, Budgets
0/6 samt Kosten, Tastatur/Fokus, vollständige Grafiken, Wappen und einen
echten Prozessneustart aus gespeichertem UI-Checkpoint. Die übrigen
Zustandsfelder einschließlich Guthaben bleiben dabei unverändert. Es
besteht kein offener P1/P2-Befund für diese Ansicht.
+53
View File
@@ -0,0 +1,53 @@
# TOTO · Elferwette
Stand: 24. Oktober 2026. Native RmlUI-Übertragung der HTML-Vorlage
`desktop/toto-menu.js` und `toto-window.css`, Referenzrevision `9db6926d`
im privaten Mockup-Repository. Roter Druck, warmer Papiergrund und blaue
Kreuze bleiben in allen drei Themes erhalten. Grafiken und Bedienung
werden nicht durch einen alternativen Wettbildschirm ersetzt.
## Sichtbare Daten
Links steht ein festes Vorschauprogramm aus neun Partien der ersten und
zwei Partien der zweiten deutschen Liga. Vereinsnamen und Wappen stammen
aus dem schreibgeschützten OBW-Katalog. Paarungen kommen aus derselben
synthetischen Spielplanprojektion wie die Berichte; aktuelle Berichtfilter
ändern das TOTO-Programm nicht. Die Vorschau verwendet Runde 27 und das
Startjahr der geladenen Welt. Fehlende Vereine werden nicht erfunden;
bei unvollständigem Programm bleibt die Vormerkung gesperrt.
Rechts enthält der Schein sechs unabhängige Spalten mit je elf Reihen.
Jede Reihe erlaubt genau eine Auswahl aus 1/0/2; erneutes Anklicken entfernt
das Kreuz. Die erste Spalte ist vorbelegt, weitere Spalten sind leer.
Der Tippvorschlag und das Leeren wirken nur auf die ausgewählte Spalte.
Der Gesamteinsatz wird über die gemeinsame Zahleneingabe bearbeitet:
0–99.999.999 ganze Anzeigeeinheiten, Vorschläge 1.000–6.000 und gesonderte
Betragsbestätigung. Eine Vormerkung braucht einen positiven Einsatz,
mindestens eine vollständige Spalte und keine teilweise ausgefüllte Spalte.
„Letzter Schein“ liest eine unabhängige Kopie der zuletzt übernommenen
Spalten und des Einsatzes. Spätere Eingaben ändern diese Kopie nicht.
## Bedienung und Zustand
Tab führt zu den Spaltenköpfen, jeweils einer Tippzelle pro Spalte sowie
den normalen Fenster-/Aktionsbuttons. Pfeile navigieren über alle 18 Zellen
je Spiel beziehungsweise elf Reihen. Home/End springen zur ersten/letzten
Zelle, mit Ctrl zusätzlich zur ersten/letzten Reihe. Fokussieren verändert
weder Tipps noch ausgewählte Spalte. Escape schließt zunächst den Dialog
und stellt den vorherigen Fokus wieder her.
`DemoSource.state.toto` enthält die sechs Spalten, den Einsatz in kleinster
Währungseinheit und den letzten Schein. Lokale Dialog-/Fokusflags sind kein
Spielstand. Aktionen sind revisionsgebunden; abgewiesene Eingaben und
fehlerhafte alte Checkpoints lassen den Zustand unverändert. Nur fehlende
TOTO-Felder werden beim Laden ergänzt. Screenshots werden zusammen mit
UI-Checkpoints und JSONL-Bedienschritten gesichert.
Es gibt keine Auszahlung, Auswertung oder Geldbuchung. Die Vorschau ruft
keine Match-, Saison- oder Zufallsfunktion auf. Ein späterer Engineadapter
muss Spielprogramm, Annahmeschluss und tatsächliche Buchungsregeln liefern.
Classic und OBW-Format bleiben davon unberührt. Die synthetischen Tests
prüfen unabhängige Spalten, leere/teilweise Scheine, tiefe Ergebniskopien,
Geldpräzision, Revisionsschutz und Wiederherstellung. Renderer-/HTML-Vergleich:
[gemeinsame Menü-QA](../../menu-qa.md).
+16 -1
View File
@@ -87,7 +87,22 @@ deshalb nicht ins öffentliche Quellcode-Repository. Öffentliche Zusammenfassun
Die 20 ausgewählten Regressionstests bestehen nach Übernahme der parallel
eingetroffenen Engineänderungen. Screenshots, UI-Demostände und Eingabeskripte
liegen privat unter `docs/qa/finance-batch-2026-10-24/`.
Aktueller Katalog: **22 native und 15 noch offene Routen**.
Nach diesem Paket: **22 native und 15 noch offene Routen**.
Die Finanzprüfung umfasst echte Linux-/OpenGL-Aufnahmen. Windows-/macOS-
Laufzeitdarstellung wird dadurch nicht als abgenommen ausgegeben.
- [Umfeld](desktop/environment/README.md), [Werbung](desktop/advertising/README.md)
und [TOTO](desktop/toto/README.md): weiteres gemeinsames Paket mit drei
Themes bei 720p/1080p. Direkte Förderstufen, Angebotsannahme, Geldentwürfe,
TOTO-Spalten und letzter Schein wurden durch die native Ereignisverarbeitung
geprüft. TOTO: 138 erfolgreiche Zustandsprüfungen, 18 vermessene
Layoutzustände und gezielte Schlussaufnahmen der korrigierten Elemente.
Echte Checkpoints und Neustarts ergänzen die Browser-/Rendererprüfung.
Die 24 Regressionstests bestehen. Private Nachweise:
`docs/qa/club-batch-2026-10-24/`.
Aktueller Katalog: **25 native und 12 noch offene Routen**.
CSS-Hintergrundbilder werden in der HTML-QA zusätzlich vollständig dekodiert,
bevor Screenshots entstehen. Das verhindert falsche Meldungen über fehlende
oder abgeschnittene Atlaskacheln im Umfeld beziehungsweise in Werbung.
+7 -1
View File
@@ -32,7 +32,7 @@ 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;
der aktuelle Runner erfasst 22 native Routen und 15 offene Ports.
der aktuelle Runner erfasst 25 native Routen und 12 offene Ports.
Spätere Meilensteine erfassen denselben Gesamtkatalog erneut.
Siehe [QA-Ablauf](menu-qa.md), [Typografie](typography-qa.md) und
@@ -45,3 +45,9 @@ Das immobilienspezifische HTML-Seitenverhältnis war verzerrt und wurde auf
die ursprüngliche 2×3-Atlaskachel korrigiert. Native Bilder bleiben proportional;
der HTML-Randbeschnitt von 1 % ist als kleine verbleibende Bildabweichung
im privaten Nachweis dokumentiert.
Das Paket Umfeld/Werbung/TOTO wurde mit 24 Regressionstests sowie den drei
Themes bei 720p/1080p geprüft. Korrigiert sind die Bandennummernausrichtung,
der Abstand der Werbehinweise, die TOTO-Saisonzeile und die Bildbox der
Kreuze. Die Referenzaufnahme wartet jetzt auch auf vollständig dekodierte
CSS-Hintergrundbilder; frühe Teilbilder gelten nicht als Produktabweichung.
+11 -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 demo_calendar.cpp demo_reports.cpp demo_almanac.cpp demo_finance.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)
target_include_directories(bmh_modern_ui_core PUBLIC ../..)
target_link_libraries(bmh_modern_ui_core PUBLIC bmh_asset_io)
add_library(bmh_modern_ui STATIC view.cpp ticket_popover.cpp)
@@ -14,7 +14,7 @@ endif()
set(modern_assets "${CMAKE_BINARY_DIR}/assets/modern")
FetchContent_GetProperties(rmlui)
file(MAKE_DIRECTORY "${modern_assets}")
foreach(asset modern.rml theme.rcss ticket.rcss sports.rcss calendar.rcss reports.rcss report_details.rcss report_pickers.rcss indoor.rcss planning.rcss almanac.rcss finance.rcss bank.rcss contracts.rcss amount.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)
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")
@@ -79,3 +79,12 @@ if(MSVC)
target_compile_options(modern_control_layout_tests PRIVATE /utf-8)
endif()
add_test(NAME modern_control_layout_tests COMMAND modern_control_layout_tests "${modern_assets}")
foreach(component environment advertising toto)
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)
target_compile_options(modern_${component}_ui_tests PRIVATE /utf-8)
endif()
add_test(NAME modern_${component}_ui_tests COMMAND modern_${component}_ui_tests)
endforeach()
+95
View File
@@ -0,0 +1,95 @@
// SPDX-License-Identifier: GPL-3.0-only
bool App::advertising_action(const std::string &action, Rml::Element *target) {
if (!action.starts_with("ad-")) return false;
if (menu_ != "advertising" || !source_ || !world_) return true;
if (action == "ad-contract" && target) {
const int slot = target->GetAttribute<int>("data-id", -1);
if (slot < 0 || slot > 15) return true;
advertising_selected_ = slot;
advertising_offer_ = 0;
advertising_revision_ = snap().revision;
advertising_world_ = world_;
focus_after_render_ = "ad-contract-" + std::to_string(slot);
refresh();
return true;
}
if (action == "ad-cancel") {
const int slot = advertising_selected_;
advertising_selected_ = -1;
advertising_offer_ = 0;
advertising_world_.reset();
if (slot >= 0 && slot <= 15) focus_after_render_ = "ad-contract-" + std::to_string(slot);
refresh();
return true;
}
if (action == "ad-offer" && target) {
const int step = target->GetAttribute<int>("data-step", 0);
if ((step != -1 && step != 1) || advertising_selected_ < 0 || advertising_selected_ > 15 ||
advertising_world_ != world_ || snap().revision != advertising_revision_) return true;
const auto q = demo_advertising_quote(snap().state, advertising_selected_, advertising_offer_, *world_);
if (!q.value("ok", false) || q.at("active") == true) return true;
advertising_offer_ = (advertising_offer_ + step + 3) % 3;
focus_after_render_ = target->GetId();
refresh();
return true;
}
if (action == "ad-accept") {
if (advertising_selected_ < 0 || advertising_selected_ > 15 || advertising_world_ != world_) return true;
const auto result = source_->apply({advertising_revision_, "advertising",
{{"kind", "accept"}, {"slot", advertising_selected_}, {"offer", advertising_offer_}}});
if (!result.ok) {
message("Das Angebot konnte nicht übernommen werden. Bitte den aktuellen Stand erneut auswählen. (" + result.error + ")");
return true;
}
advertising_revision_ = result.revision;
focus_after_render_ = "ad-cancel";
refresh();
return true;
}
if (action == "ad-spending" && target) {
const int index = target->GetAttribute<int>("data-id", -1);
const auto snapshot = snap();
const auto view = demo_advertising_view(snapshot.state, *world_);
if (!view.value("ok", false) || index < 0 || index > 2) return true;
const auto &row = view.at("spending")[size_t(index)];
const auto world = world_;
const auto *source = source_.get();
const auto revision = snapshot.revision;
AmountRequest request;
request.title = row.at("name").get<std::string>();
request.unit = money_unit();
request.return_focus = target->GetId();
request.value = row.at("amount").get<int64_t>() / finance_currency_factor(*world_);
request.min = 0;
request.max = 99999999;
request.step = 1;
request.suggestion_step = row.at("suggestion_step");
request.review = true;
request.accept = [this, world, source, revision, index](int64_t amount) {
if (menu_ != "advertising" || world_ != world || source_.get() != source) return false;
const auto result = source_->apply({revision, "advertising", {{"kind", "spending"}, {"index", index}, {"value", amount}}});
if (!result.ok) {
message("Das Budget konnte nicht übernommen werden. Bitte den aktuellen Stand prüfen. (" + result.error + ")");
return false;
}
if (advertising_selected_ >= 0 && advertising_world_ == world && advertising_revision_ == revision)
advertising_revision_ = result.revision;
refresh();
return true;
};
open_amount(std::move(request));
return true;
}
return true;
}
bool App::advertising_event(Rml::Event &event) {
if (menu_ != "advertising" || advertising_selected_ < 0 || amount_ || !popup_.empty()) return false;
const auto type = event.GetType();
if ((type == "keydown" && event.GetParameter<int>("key_identifier", 0) == Rml::Input::KI_ESCAPE) ||
(type == "mouseup" && event.GetParameter<int>("button", 0) == 1)) {
advertising_action("ad-cancel", nullptr);
event.StopImmediatePropagation();
return true;
}
return false;
}
+60
View File
@@ -0,0 +1,60 @@
// SPDX-License-Identifier: GPL-3.0-only
std::string App::render_advertising() {
const auto snapshot = snap();
const auto view = demo_advertising_view(snapshot.state, *world_);
if (!view.value("ok", false)) return {};
const auto brand = [&](const Json &c) {
if (c.at("sponsor") == -1) return std::string();
return "<span class=\"ad-brand ad-brand-" + std::to_string(c.at("sponsor").get<int>() % 5) +
"\"><span>" + esc(c.at("name").get<std::string>()) + "</span></span>";
};
std::string out = "<div class=\"advertising-page\"><div class=\"advertising-boards\" role=\"group\" aria-label=\"Vierzehn Werbebanden\">";
for (int i = 0; i < 14; ++i) {
const auto &c = view.at("slots")[size_t(i)];
out += btn("ad-contract", (c.at("active") == true ? brand(c) : "<span class=\"advertising-free\">Platz frei</span>") +
"<small><span>Bande " + std::to_string(i + 1) + "</span></small>", "advertising-board " + std::string(advertising_selected_ == i ? "selected" : ""),
"id=\"ad-contract-" + std::to_string(i) + "\" data-ad-contract=\"" + std::to_string(i) + "\" data-id=\"" + std::to_string(i) +
"\" aria-pressed=\"" + (advertising_selected_ == i ? "true" : "false") + "\" aria-label=\"Bande " + std::to_string(i + 1) + ", " +
esc(c.at("name").get<std::string>()) + "\" style=\"" + rect(16 + (i % 7) * (354.285714 + 16), 16 + (i / 7) * 145, 354.285714, 129) + "\"");
}
out += "</div>";
const std::array<const char *, 4> headings{"Trikotwerbung", "Fanartikel", "Öffentlichkeitsarbeit", "Fanbetreuung"};
for (int i = 0; i < 4; ++i) {
std::string body = "<strong><span>" + std::string(headings[size_t(i)]) + "</span></strong><div class=\"advertising-art\">" +
img("advertising.panel." + std::to_string(i), 510, 510, false, false, 1000) + "</div>";
if (i == 0) body += brand(view.at("slots")[14]);
else body += "<output><span>" + esc(cash(view.at("spending")[size_t(i - 1)].at("amount").get<int64_t>())) + "</span></output>";
out += btn(i == 0 ? "ad-contract" : "ad-spending", body,
"advertising-card advertising-panel " + std::string(i == 0 ? "advertising-shirt " : "") + (i == 0 && advertising_selected_ == 14 ? "selected" : ""),
"id=\"" + std::string(i == 0 ? "ad-contract-14" : "ad-spending-" + std::to_string(i - 1)) + "\" data-id=\"" + std::to_string(i == 0 ? 14 : i - 1) +
"\" " + (i == 0 ? "data-ad-contract=\"14\" aria-pressed=\"" + std::string(advertising_selected_ == 14 ? "true" : "false") + "\" "
: "data-ad-spending=\"" + std::to_string(i - 1) + "\" ") +
"style=\"" + rect(i * 658.5, 346, 636.5, 650) + "\"");
}
out += btn("ad-contract", "<strong><span>TV-Rechte</span></strong><div class=\"advertising-tv-art\">" +
img("art.advertising-tv-v1.png", 540, 540, false, false, 1000) + "</div>" + brand(view.at("slots")[15]),
"advertising-card advertising-tv " + std::string(advertising_selected_ == 15 ? "selected" : ""),
"id=\"ad-contract-15\" data-ad-contract=\"15\" data-id=\"15\" aria-pressed=\"" + std::string(advertising_selected_ == 15 ? "true" : "false") + "\"");
out += "<section class=\"advertising-details\" aria-label=\"Vertrag und Vorschau\" aria-live=\"polite\">";
if (advertising_selected_ < 0 || advertising_selected_ > 15) {
out += "<div class=\"advertising-hint\"><h2>Werbung und Vereinsausgaben</h2>"
"<p>Bande, Trikot oder TV-Rechte auswählen.</p><p>Die drei Ausgabenbilder öffnen die Zahleneingabe.</p></div>";
} else {
const auto quote = demo_advertising_quote(snapshot.state, advertising_selected_, advertising_offer_, *world_);
const bool active = quote.at("active");
out += "<div class=\"advertising-offer\"><div class=\"ad-offer-mark\">" + brand(quote) +
"</div><div class=\"ad-offer-arrows\">" +
btn("ad-offer", "<span>‹</span>", "ad-offer-arrow", "id=\"ad-offer-previous\" data-step=\"-1\" aria-label=\"Vorheriges Angebot\" " + std::string(active ? "disabled" : "")) +
btn("ad-offer", "<span>›</span>", "ad-offer-arrow", "id=\"ad-offer-next\" data-step=\"1\" aria-label=\"Nächstes Angebot\" " + std::string(active ? "disabled" : "")) +
"</div><div class=\"ad-offer-facts\"><div><span>" + esc(quote.at("label").get<std::string>()) + "</span><strong>" +
esc(quote.at("name").get<std::string>()) + "</strong></div><div><span>Dauer</span><strong>" + std::to_string(quote.at("months").get<int>()) +
" Monate</strong></div><div><span>" + (active ? "Vertrag" : "Angebot") + "</span><strong>" +
esc(cash(quote.at("amount").get<int64_t>())) + " / Monat</strong></div></div></div><nav class=\"advertising-actions\">" +
btn("ad-cancel", active ? "Schließen" : "Abbrechen", "advertising-control", "id=\"ad-cancel\"") +
btn("ad-accept", active ? "Vertrag läuft" : "Annehmen", "advertising-control", "id=\"ad-accept\" " + std::string(active ? "disabled" : "")) + "</nav>";
}
out += "<div class=\"advertising-totals\">";
for (const auto &[label, key] : std::array<std::pair<const char *, const char *>, 3>{{{"Einnahmen", "income"}, {"Ausgaben", "expenses"}, {"Saldo", "balance"}}})
out += "<div><span>" + std::string(label) + "</span><output>" + esc(cash(view.at(key).get<int64_t>())) + "</output></div>";
return out + "</div></section></div>";
}
+5 -1
View File
@@ -152,6 +152,7 @@ void App::ProcessEvent(Rml::Event &event) try {
if (amount_event(event)) return;
if (popup_.empty() && amount_trigger_event(event)) return;
if (popup_.empty() && contracts_event(event)) return;
if (popup_.empty() && (advertising_event(event) || toto_event(event))) return;
if (popup_.empty() && (bank_event(event) || finance_event(event))) return;
if (!planning_dialog_.empty() && popup_.empty()) {
const bool key_event = type == "keydown";
@@ -435,6 +436,7 @@ void App::ProcessEvent(Rml::Event &event) try {
void App::dispatch(const std::string &action, Rml::Element *target) {
const auto id =
target ? target->GetAttribute<Rml::String>("data-id", "") : std::string();
if (environment_action(action, target) || advertising_action(action, target) || toto_action(action, target)) return;
if (amount_action(action, target) || bank_action(action, target) || finance_action(action, target) || contracts_action(action, target)) return;
if (almanac_action(action, target) || planning_action(action, target) || indoor_action(action, target)) return;
if (report_detail_action(action, target)) {
@@ -1047,7 +1049,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", "calendar", "league", "other", "postpone", "friendlies", "indoor", "almanac", "bank", "balance", "contracts"};
"save", "load", "training", "tactics", "calendar", "league", "other", "postpone", "friendlies", "indoor", "almanac", "bank", "balance", "contracts", "environment", "advertising", "toto"};
if (!available.contains(route)) {
message("Diese native Ansicht wird im nächsten Menüpaket übertragen.");
return;
@@ -1434,6 +1436,8 @@ void App::script() {
{"planning_dialog", planning_dialog_},
{"bank_view", bank_view_}, {"bank_property", bank_property_}, {"bank_stock", bank_stock_},
{"balance_future", balance_future_},
{"advertising_view", {{"selected", advertising_selected_}, {"offer", advertising_offer_}}},
{"toto_view", {{"column", toto_column_}, {"dialog", toto_dialog_}}},
{"contracts_view", {{"dialog", contracts_dialog_}, {"player", contracts_player_}, {"tab", contracts_tab_}, {"draft", contract_draft_}}},
{"amount_editor", amount_ ? Json{{"title", amount_->request.title}, {"raw", amount_->raw}, {"review", amount_->review}, {"error", amount_error()}} : Json()},
{"source_revision", source_ ? Json(snap().revision) : Json()},
+123
View File
@@ -0,0 +1,123 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "modern/ui/demo_advertising.hpp"
#include "modern/ui/demo_finance.hpp"
#include <algorithm>
#include <array>
namespace bmh::modern_ui {
namespace {
constexpr int64_t cap = 99999999;
constexpr std::array<const char *, 10> sponsors{"MAINWERK", "BALLWERK", "NORDLICHT", "FELDPUNKT", "RHEINWERK",
"SPORTNETZ", "WESTBAHN", "HAFENWERK", "BERGSTROM", "STADTFUNK"};
constexpr std::array<const char *, 5> broadcasters{"SPORTKANAL", "FUSSBALL TV", "SPIELTAG TV", "ARENA PLUS", "LIGA LIVE"};
constexpr std::array<const char *, 3> spending_names{"Fanartikel", "Öffentlichkeitsarbeit", "Fanbetreuung"};
bool keys(const Json &v, std::initializer_list<const char *> expected) {
return v.is_object() && v.size() == expected.size() && std::all_of(expected.begin(), expected.end(),
[&](const auto *key) { return v.contains(key); });
}
bool integer(const Json &v, int64_t low, int64_t high) {
if (v.is_number_unsigned())
return high >= 0 && v.get<uint64_t>() <= uint64_t(high) &&
(low <= 0 || v.get<uint64_t>() >= uint64_t(low));
return v.is_number_integer() && v.get<int64_t>() >= low && v.get<int64_t>() <= high;
}
Json error(const char *code) { return {{"ok", false}, {"error", code}}; }
std::string label(int slot) {
return slot < 14 ? "Bande " + std::to_string(slot + 1) : slot == 14 ? "Trikotwerbung" : "TV-Rechte";
}
std::string name(int slot, int sponsor) {
return sponsor < 0 ? "frei" : slot == 15 ? broadcasters[size_t(sponsor)] : sponsors[size_t(sponsor)];
}
Json offer(int slot, int choice, int64_t factor) {
return {{"sponsor", (slot * 3 + choice) % (slot == 15 ? 5 : 10)},
{"months", (choice + 1) * 12},
{"amount", ((slot == 15 ? 85000 : slot == 14 ? 110000 : 7000) +
(slot == 15 ? 18000 : slot == 14 ? 24000 : 1800) * choice + (slot % 7) * 1200) * factor}};
}
} // namespace
bool valid_demo_advertising(const Json &state, const Catalog &world) {
try {
if (!state.is_object()) return false;
const auto factor = finance_currency_factor(world);
const auto &a = state.at("advertising");
if (!keys(a, {"spending", "contracts"}) || !a.at("spending").is_array() || a.at("spending").size() != 3 ||
!a.at("contracts").is_array() || a.at("contracts").size() != 16) return false;
for (const auto &value : a.at("spending")) if (!integer(value, 0, cap * factor)) return false;
for (size_t slot = 0; slot < 16; ++slot) {
const auto &c = a.at("contracts")[slot];
if (!keys(c, {"sponsor", "months", "amount"}) || !integer(c.at("sponsor"), -1, slot == 15 ? 4 : 9) ||
!integer(c.at("months"), 0, 36) || !integer(c.at("amount"), 0, cap * factor)) return false;
if (c.at("sponsor") == -1) {
if (c.at("months") != 0 || c.at("amount") != 0) return false;
} else if (!(c.at("months") == 12 || c.at("months") == 24 || c.at("months") == 36) ||
c.at("amount") == 0) return false;
}
return true;
} catch (const std::exception &) { return false; }
}
bool migrate_demo_advertising(Json &state, const Catalog &world) {
try {
if (!state.is_object()) return false;
if (state.contains("advertising")) return valid_demo_advertising(state, world);
const auto factor = finance_currency_factor(world);
auto next = state;
Json contracts = Json::array();
for (int slot = 0; slot < 16; ++slot) contracts.push_back({{"sponsor", -1}, {"months", 0}, {"amount", 0}});
next["advertising"] = {{"spending", {50000 * factor, 15000 * factor, 10000 * factor}}, {"contracts", contracts}};
if (!valid_demo_advertising(next, world)) return false;
state = std::move(next);
return true;
} catch (const std::exception &) { return false; }
}
Json demo_advertising_quote(const Json &state, int slot, int choice, const Catalog &world) {
if (!valid_demo_advertising(state, world)) return error("invalid_advertising_state");
if (slot < 0 || slot > 15 || choice < 0 || choice > 2) return error("invalid_advertising_selection");
const auto &saved = state.at("advertising").at("contracts")[size_t(slot)];
const bool active = saved.at("sponsor") != -1;
const auto c = active ? saved : offer(slot, choice, finance_currency_factor(world));
return {{"ok", true}, {"slot", slot}, {"offer", choice}, {"active", active}, {"label", label(slot)},
{"name", name(slot, c.at("sponsor").get<int>())},
{"sponsor", c.at("sponsor")}, {"months", c.at("months")}, {"amount", c.at("amount")}};
}
std::string edit_demo_advertising(Json &state, const Json &action, const Catalog &world) {
if (!valid_demo_advertising(state, world)) return "invalid_advertising_state";
try {
if (!action.is_object() || !action.contains("kind") || !action.at("kind").is_string()) return "invalid_advertising_action";
const auto kind = action.at("kind").get<std::string>();
auto next = state;
if (kind == "accept") {
if (!keys(action, {"kind", "slot", "offer"}) || !integer(action.at("slot"), 0, 15) ||
!integer(action.at("offer"), 0, 2)) return "invalid_advertising_selection";
const auto slot = action.at("slot").get<size_t>();
if (state.at("advertising").at("contracts")[slot].at("sponsor") != -1) return "advertising_contract_active";
next["advertising"]["contracts"][slot] = offer(int(slot), action.at("offer").get<int>(), finance_currency_factor(world));
} else if (kind == "spending") {
if (!keys(action, {"kind", "index", "value"}) || !integer(action.at("index"), 0, 2) ||
!integer(action.at("value"), 0, cap)) return "invalid_advertising_value";
next["advertising"]["spending"][action.at("index").get<size_t>()] = action.at("value").get<int64_t>() * finance_currency_factor(world);
} else return "unknown_advertising_action";
if (!valid_demo_advertising(next, world)) return "invalid_advertising_state";
state = std::move(next);
return {};
} catch (const std::exception &) { return "invalid_advertising_action"; }
}
Json demo_advertising_view(const Json &state, const Catalog &world) {
if (!valid_demo_advertising(state, world)) return error("invalid_advertising_state");
Json slots = Json::array(), spending = Json::array();
int64_t income = 0, expenses = 0;
const auto &a = state.at("advertising");
for (int i = 0; i < 16; ++i) {
const auto &c = a.at("contracts")[size_t(i)];
const auto sponsor = c.at("sponsor").get<int>();
slots.push_back({{"slot", i}, {"label", label(i)}, {"name", name(i, sponsor)}, {"sponsor", sponsor},
{"months", c.at("months")}, {"amount", c.at("amount")}, {"active", sponsor >= 0}});
income += c.at("amount").get<int64_t>();
}
for (int i = 0; i < 3; ++i) {
const auto value = a.at("spending")[size_t(i)].get<int64_t>();
spending.push_back({{"index", i}, {"name", spending_names[size_t(i)]}, {"amount", value}, {"suggestion_step", i == 0 ? 50000 : 5000}});
expenses += value;
}
return {{"ok", true}, {"slots", slots}, {"spending", spending}, {"income", income}, {"expenses", expenses}, {"balance", income - expenses}};
}
} // namespace bmh::modern_ui
+19
View File
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include "modern/ui/catalog.hpp"
namespace bmh::modern_ui {
// Only state.advertising is owned here. Monetary model/projection values are
// currency minor units; the spending editor action uses whole display units.
// Selection and offer navigation belong to the App, never the saved state.
bool migrate_demo_advertising(Json &state, const Catalog &);
bool valid_demo_advertising(const Json &state, const Catalog &);
std::string edit_demo_advertising(Json &state, const Json &action, const Catalog &);
// {kind:"accept",slot:0..15,offer:0..2} recomputes the deterministic offer.
// {kind:"spending",index:0..2,value:0..99999999} changes only that budget.
// Sources bind commits to the observed revision; queries never mutate it.
Json demo_advertising_quote(const Json &state, int slot, int offer, const Catalog &);
// {ok,slots:[{slot,label,name,sponsor,months,amount,active}],
// spending:[{index,name,amount,suggestion_step}],income,expenses,balance}.
Json demo_advertising_view(const Json &state, const Catalog &);
} // namespace bmh::modern_ui
+74
View File
@@ -0,0 +1,74 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "modern/ui/demo_environment.hpp"
#include "modern/ui/demo_finance.hpp"
#include <array>
#include <set>
namespace bmh::modern_ui {
namespace {
constexpr std::array<int, 6> defaults{2, 3, 4, 3, 4, 2};
constexpr std::array<int64_t, 6> rates{2000, 3000, 5000, 7500, 6000, 4500};
constexpr std::array<const char *, 6> ids{"youth-a", "youth-b", "youth-c", "coach", "doctor", "physio"};
constexpr std::array<const char *, 6> names{"Nachwuchs · Jüngste", "Nachwuchs · Mittlere",
"Nachwuchs · Ältere", "Co-Trainer", "Vereinsarzt", "Masseur"};
constexpr std::array<int, 3> ranks{11, 3, 7}, leagues{1, 2, 1};
bool integer(const Json &value, int lo, int hi) {
return value.is_number_integer() && value >= lo && value <= hi;
}
bool keys(const Json &value, std::initializer_list<const char *> expected) {
if (!value.is_object() || value.size() != expected.size()) return false;
for (const auto *key : expected) if (!value.contains(key)) return false;
return true;
}
} // namespace
bool valid_demo_environment(const Json &state, const Catalog &world) {
try {
if (!state.is_object() || !state.contains("environment") ||
!keys(state.at("environment"), {"levels"})) return false;
const auto &levels = state.at("environment").at("levels");
if (!levels.is_array() || levels.size() != defaults.size()) return false;
for (const auto &level : levels) if (!integer(level, 0, 6)) return false;
(void)finance_currency_factor(world);
return true;
} catch (const std::exception &) { return false; }
}
bool migrate_demo_environment(Json &state, const Catalog &world) {
if (!state.is_object()) return false;
auto next = state;
if (!next.contains("environment")) next["environment"] = {{"levels", defaults}};
if (!valid_demo_environment(next, world)) return false;
state = std::move(next);
return true;
}
std::string edit_demo_environment(Json &state, const Json &action, const Catalog &world) {
if (!valid_demo_environment(state, world)) return "invalid_environment_state";
if (!keys(action, {"kind", "index", "value"}) || !action.at("kind").is_string())
return "invalid_environment_action";
if (action.at("kind") != "level") return "unknown_environment_action";
if (!integer(action.at("index"), 0, 5) || !integer(action.at("value"), 0, 6))
return "invalid_environment_level";
auto next = state;
next["environment"]["levels"][action.at("index").get<size_t>()] = action.at("value");
if (!valid_demo_environment(next, world)) return "invalid_environment_state";
state = std::move(next);
return {};
}
Json demo_environment_rows(const Json &state, const Catalog &world) {
if (!valid_demo_environment(state, world))
return {{"ok", false}, {"error", "invalid_environment_state"}};
const auto factor = finance_currency_factor(world);
Json rows = Json::array();
int64_t total = 0;
for (size_t i = 0; i < defaults.size(); ++i) {
const int level = state.at("environment").at("levels")[i].get<int>();
const int64_t rate = rates[i] * factor, cost = rate * level;
total += cost;
rows.push_back({{"id", ids[i]}, {"name", names[i]}, {"level", level},
{"rate", rate}, {"cost", cost}, {"image", i < 3 ? "youth" : "staff"},
{"cell", i < 3 ? int(i) : int(i - 3)},
{"rank", i < 3 ? Json(ranks[i]) : Json()},
{"league", i < 3 ? Json(leagues[i]) : Json()}});
}
return {{"ok", true}, {"rows", rows}, {"total", total}};
}
} // namespace bmh::modern_ui
+18
View File
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include "modern/ui/catalog.hpp"
namespace bmh::modern_ui {
// FULL demo state, canonical environment={levels:[six integers 0..6]}.
// Only an absent environment is initialized. Rejections are atomic; unrelated
// state and the OBW staff table are never rewritten or interpreted as budgets.
bool migrate_demo_environment(Json &, const Catalog &);
bool valid_demo_environment(const Json &, const Catalog &);
// {kind:"level",index:0..5,value:0..6}; selection is immediate, with no cash
// booking, salary changes, time advancement or engine/RNG access.
std::string edit_demo_environment(Json &, const Json &, const Catalog &);
// {ok,rows:[{id,name,level,rate,cost,image,cell,rank,league}],total}.
// Rates, costs and total use raw currency minor units. Youth places are explicit
// fictional presentation fixtures, independent of any league/report selection.
Json demo_environment_rows(const Json &, const Catalog &);
} // namespace bmh::modern_ui
+132
View File
@@ -0,0 +1,132 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "modern/ui/demo_toto.hpp"
#include "modern/ui/demo_finance.hpp"
#include "modern/ui/demo_reports.hpp"
#include <algorithm>
#include <array>
namespace bmh::modern_ui {
namespace {
constexpr int column_count = 6, row_count = 11;
constexpr int64_t stake_cap = 99999999;
constexpr std::array<int, 3> picks{1, 0, 2};
bool whole(const Json &v, int64_t lo, int64_t hi) {
if (v.is_number_unsigned()) return v.get<uint64_t>() <= uint64_t(hi) && (lo <= 0 || v.get<uint64_t>() >= uint64_t(lo));
return v.is_number_integer() && v.get<int64_t>() >= lo && v.get<int64_t>() <= hi;
}
bool keys(const Json &v, std::initializer_list<const char *> names) {
return v.is_object() && v.size() == names.size() &&
std::all_of(names.begin(), names.end(), [&](const auto *name) { return v.contains(name); });
}
bool columns_valid(const Json &v) {
return v.is_array() && v.size() == column_count && std::all_of(v.begin(), v.end(), [](const auto &col) {
return col.is_array() && col.size() == row_count && std::all_of(col.begin(), col.end(), [](const auto &p) { return whole(p, -1, 2); });
});
}
int filled(const Json &col) {
return int(std::count_if(col.begin(), col.end(), [](const auto &p) { return p != -1; }));
}
bool ready(const Json &cols) {
bool any = false;
for (const auto &col : cols) {
const int n = filled(col);
if (n && n != row_count) return false;
any |= n == row_count;
}
return any;
}
bool stake_valid(const Json &v, int64_t factor, bool positive = false) {
return whole(v, positive ? factor : 0, stake_cap * factor) && v.get<int64_t>() % factor == 0;
}
Json initial(int64_t factor) {
auto cols = Json::array();
for (int c = 0; c < column_count; ++c) {
auto col = Json::array();
for (int r = 0; r < row_count; ++r) col.push_back(c ? -1 : picks[size_t(r % 3)]);
cols.push_back(col);
}
return {{"columns", cols}, {"stake", 1000 * factor}, {"coupon", nullptr}};
}
} // namespace
bool valid_demo_toto(const Json &state, const Catalog &world) {
try {
const auto factor = finance_currency_factor(world);
if (!state.is_object() || !state.contains("toto")) return false;
const auto &v = state.at("toto");
if (!keys(v, {"columns", "stake", "coupon"}) || !columns_valid(v.at("columns")) || !stake_valid(v.at("stake"), factor)) return false;
const auto &coupon = v.at("coupon");
return coupon.is_null() || (keys(coupon, {"columns", "stake"}) && columns_valid(coupon.at("columns")) &&
ready(coupon.at("columns")) && stake_valid(coupon.at("stake"), factor, true));
} catch (const std::exception &) { return false; }
}
bool migrate_demo_toto(Json &state, const Catalog &world) {
try {
if (!state.is_object()) return false;
auto next = state;
if (!next.contains("toto")) next["toto"] = initial(finance_currency_factor(world));
if (!valid_demo_toto(next, world)) return false;
state = std::move(next);
return true;
} catch (const std::exception &) { return false; }
}
Json demo_toto_programme(const Catalog &world) {
Json rows = Json::array();
const auto leagues = world.leagues("nation:de");
auto reports = demo_reports(world);
for (size_t i = 0; i < std::min<size_t>(2, leagues.size()); ++i) {
if (!edit_demo_reports(reports, {{"kind", "league"}, {"value", leagues[i]->at("id")}}, world).empty()) continue;
reports["round"] = std::min(26, report_round_count(world, reports) - 1);
const auto matches = report_match_rows(world, reports, false);
const size_t limit = i == 0 ? 9 : 2;
for (size_t n = 0; n < std::min(matches.size(), limit); ++n)
rows.push_back({{"home", matches[n].at("home")}, {"away", matches[n].at("away")},
{"league", leagues[i]->at("id")}, {"tier", i + 1}, {"round", reports.at("round").get<int>() + 1}});
}
auto start = world.manifest().value("start_date", std::string(""));
std::string season = "—";
if (start.size() >= 4 && std::all_of(start.begin(), start.begin() + 4, [](char c) { return c >= '0' && c <= '9'; })) {
const auto year = std::stoi(start.substr(0, 4));
const auto next = std::to_string((year + 1) % 100);
season = start.substr(0, 4) + "/" + (next.size() == 1 ? "0" : "") + next;
}
return {{"rows", rows}, {"complete", rows.size() == row_count}, {"round", 27}, {"season", season}};
}
std::string edit_demo_toto(Json &state, const Json &action, const Catalog &world) {
if (!valid_demo_toto(state, world)) return "invalid_toto_state";
if (!action.is_object() || !action.contains("kind") || !action.at("kind").is_string()) return "invalid_toto_action";
const auto kind = action.at("kind").get<std::string>();
auto next = state.at("toto");
if (kind == "pick" || kind == "auto" || kind == "clear") {
if (!action.contains("column") || !whole(action.at("column"), 0, 5)) return "invalid_toto_column";
auto &col = next["columns"][action.at("column").get<size_t>()];
if (kind == "pick") {
if (!action.contains("row") || !whole(action.at("row"), 0, 10) ||
!action.contains("pick") || !whole(action.at("pick"), 0, 2)) return "invalid_toto_pick";
auto &value = col[action.at("row").get<size_t>()];
value = value == action.at("pick") ? Json(-1) : action.at("pick");
} else for (int r = 0; r < row_count; ++r)
col[size_t(r)] = kind == "clear" ? -1 : picks[size_t((r + action.at("column").get<int>() + 1) % 3)];
} else if (kind == "stake") {
if (!action.contains("value") || !whole(action.at("value"), 0, stake_cap)) return "invalid_toto_stake";
next["stake"] = action.at("value").get<int64_t>() * finance_currency_factor(world);
} else if (kind == "submit") {
if (!ready(next.at("columns")) || next.at("stake") == 0) return "incomplete_toto_coupon";
if (!demo_toto_programme(world).at("complete").get<bool>()) return "unavailable_toto_programme";
next["coupon"] = {{"columns", next.at("columns")}, {"stake", next.at("stake")}};
} else return "unsupported_toto_action";
auto candidate = state;
candidate["toto"] = std::move(next);
if (!valid_demo_toto(candidate, world)) return "invalid_toto_action";
state = std::move(candidate);
return {};
}
Json demo_toto_summary(const Json &state, const Catalog &world) {
if (!valid_demo_toto(state, world)) return {{"ok", false}};
Json counts = Json::array(); int complete = 0, partial = 0;
for (const auto &col : state.at("toto").at("columns")) {
const auto n = filled(col); counts.push_back(n); complete += n == row_count; partial += n && n != row_count;
}
return {{"ok", true}, {"counts", counts}, {"complete", complete}, {"partial", partial},
{"can_submit", complete && !partial && state.at("toto").at("stake") != 0}};
}
} // namespace bmh::modern_ui
+14
View File
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include "modern/ui/catalog.hpp"
namespace bmh::modern_ui {
// Presentation-only coupon: six independent columns, eleven games, raw money.
// These helpers accept the full UI state and never debit the shared wallet.
bool migrate_demo_toto(Json &, const Catalog &);
bool valid_demo_toto(const Json &, const Catalog &);
std::string edit_demo_toto(Json &, const Json &, const Catalog &);
Json demo_toto_summary(const Json &, const Catalog &);
// Fixed programme independent of report filters: 9 first-tier + 2 second-tier
// matches. Missing clubs yield an incomplete projection, never invented teams.
Json demo_toto_programme(const Catalog &);
} // namespace bmh::modern_ui
+19
View File
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: GPL-3.0-only
bool App::environment_action(const std::string &action, Rml::Element *target) {
if (action != "environment-level") return false;
if (menu_ != "environment" || !source_ || !target) return true;
const auto index = target->GetAttribute<Rml::String>("data-index", "");
const auto value = target->GetAttribute<Rml::String>("data-id", "");
if (index.size() != 1 || index[0] < '0' || index[0] > '5' ||
value.size() != 1 || value[0] < '0' || value[0] > '6') return true;
const auto snapshot = snap();
const auto result = source_->apply({snapshot.revision, "environment",
{{"kind", "level"}, {"index", index[0] - '0'}, {"value", value[0] - '0'}}});
if (!result.ok) {
message("Das Umfeldbudget konnte nicht übernommen werden. Bitte die Ansicht mit dem aktuellen Stand erneut öffnen.");
return true;
}
focus_after_render_ = target->GetId();
refresh();
return true;
}
+64
View File
@@ -0,0 +1,64 @@
// SPDX-License-Identifier: GPL-3.0-only
std::string App::render_environment() {
const auto snapshot = snap();
if (!snapshot.world) return "<p class=\"environment-unavailable\">Die Umfeldvorschau ist derzeit nicht verfügbar.</p>";
const auto view = demo_environment_rows(snapshot.state, *snapshot.world);
if (!view.value("ok", false)) return "<p class=\"environment-unavailable\">Die Umfeldvorschau ist derzeit nicht verfügbar.</p>";
const auto funded = theme_ == "silver" ? "#805b18" : theme_ == "matchday" ? "#e1c68b" : "#e5cd8c";
const auto unfunded = theme_ == "silver" ? "#526779" : theme_ == "matchday" ? "#b7b4b9" : "#6f8595";
const auto star = [&](bool active) {
const auto color = active ? funded : unfunded;
const std::string svg = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"48\" height=\"48\" viewBox=\"0 0 48 48\">"
"<path fill=\"" + std::string(color) + "\" d=\"m24 3 6 13 15 2-11 11 3 15-13-7-13 7 3-15L3 18l15-2Z\"/></svg>";
return picture(renderer_.diagram("environment-star-" + theme_ + (active ? "-funded" : "-unfunded"), svg, 96), 40, 40);
};
struct Panel { double x, y, w, h, image_h; };
const std::array<Panel, 6> panels{{
{1912,970,600,623.328125,374.78125}, {1056,1060,500,556.40625,307.859375},
{100,970,600,623.328125,374.78125}, {100,160,600,694.375,460.375},
{1056,0,500,612.171875,378.171875}, {1912,160,600,694.375,460.375}}};
std::string out = "<div class=\"environment-ring\" id=\"environment-ring\">";
const auto &rows = view.at("rows");
for (size_t i = 0; i < rows.size(); ++i) {
const auto &row = rows[i];
const auto &panel = panels[i];
const auto name = row.at("name").get<std::string>(), id = row.at("id").get<std::string>();
const auto level = row.at("level").get<int>();
const auto inner = panel.w - 40;
out += "<section class=\"environment-card " + id + "\" style=\"" + rect(panel.x, panel.y, panel.w, panel.h) +
"\" aria-labelledby=\"environment-title-" + std::to_string(i) + "\"><h2 id=\"environment-title-" +
std::to_string(i) + "\">" + esc(name) + "</h2><div class=\"environment-stars\" role=\"group\" aria-label=\"" +
esc(name + " Budget") + "\">";
for (int value = 0; value <= 6; ++value) {
const bool selected = value == level;
const auto label = value ? "<span class=\"environment-level-icon\">" + star(value <= level) + "</span>"
: std::string("<span class=\"environment-zero-label\">×</span>");
out += btn("environment-level", label + (selected ? "<span class=\"environment-selection-line\"></span>" : ""),
"environment-level " + std::string(value == 0 ? "zero " : "") + (selected ? "selected" : ""),
"id=\"environment-level-" + std::to_string(i) + "-" + std::to_string(value) +
"\" data-index=\"" + std::to_string(i) + "\" data-id=\"" + std::to_string(value) +
"\" aria-pressed=\"" + (selected ? "true" : "false") + "\" aria-label=\"" +
esc(name + ": " + std::to_string(value) + (value == 1 ? " Stern" : " Sterne")) +
"\" title=\"" + (value ? std::to_string(value) + (value == 1 ? " Stern" : " Sterne") : "Budget auf null setzen") + "\"");
}
out += "</div><div class=\"environment-picture\" style=\"" + rect(18, 138, inner, panel.image_h) + "\">" +
img("environment." + row.at("image").get<std::string>() + "." + std::to_string(row.at("cell").get<int>()),
inner, panel.image_h, false, false, 1024) +
"</div><div class=\"environment-caption\" style=\"top:" + scalar(152 + panel.image_h) + "dp;height:" +
scalar(i < 3 ? 74.546875 : 60) + "dp;\"><span class=\"environment-cost\" id=\"environment-cost-" + std::to_string(i) +
"\" aria-label=\"" + esc(name + " Monatskosten") + "\">" +
esc(money(row.at("cost").get<int64_t>(), snapshot.world->manifest().value("currency", Json::object())) + " / Monat") + "</span>";
if (i < 3)
out += "<span class=\"environment-standing\">" + std::to_string(row.at("rank").get<int>()) + ". / " +
std::to_string(row.at("league").get<int>()) + ". Liga</span>";
out += "</div></section>";
}
out += "<div class=\"environment-emblem\"><div class=\"environment-ball\">" +
img("art.environment-ball-v1.png", 400, 400, false, false, 640) + "</div>";
const auto &managers = snapshot.state.at("managers");
const auto managed = managers.is_array() && !managers.empty() ? managers[0].value("club", "") : "";
const auto *club = snapshot.world->find("clubs", managed);
out += "<div class=\"environment-crest\" aria-label=\"" + esc(club ? snapshot.world->name(*club) : "Vereinswappen nicht verfügbar") + "\">" +
(club ? img(club->value("crest", ""), 162, 162, true) : "<span>—</span>") + "</div></div></div>";
return out;
}
+12
View File
@@ -2,6 +2,9 @@
#include "modern/ui/model.hpp"
#include "modern/ui/demo_almanac.hpp"
#include "modern/ui/demo_finance.hpp"
#include "modern/ui/demo_environment.hpp"
#include "modern/ui/demo_advertising.hpp"
#include "modern/ui/demo_toto.hpp"
#include "modern/ui/demo_calendar.hpp"
#include "modern/ui/demo_reports.hpp"
#include "modern/ui/demo_sports.hpp"
@@ -87,6 +90,8 @@ DemoSource::DemoSource(std::shared_ptr<const Catalog> catalog)
state_["reports"] = demo_reports(*catalog_);
if (!migrate_demo_finance(state_, *catalog_, club))
throw editor::Error("invalid_demo_finance");
if (!migrate_demo_environment(state_, *catalog_) || !migrate_demo_advertising(state_, *catalog_) || !migrate_demo_toto(state_, *catalog_))
throw editor::Error("invalid_demo_club");
saved_ = state_;
}
Snapshot DemoSource::snapshot() const { return {revision_, catalog_, state_}; }
@@ -131,6 +136,11 @@ ActionResult DemoSource::apply(const Action &action) {
{{"kind", "league"}, {"value", next["calendar"]["league"]}}, *catalog_);
if (!error.empty()) return {false, revision_, error};
}
} else if (action.kind == "environment" || action.kind == "advertising" || action.kind == "toto") {
const auto error = action.kind == "environment" ? edit_demo_environment(next, action.value, *catalog_)
: action.kind == "advertising" ? edit_demo_advertising(next, action.value, *catalog_)
: edit_demo_toto(next, action.value, *catalog_);
if (!error.empty()) return {false, revision_, error};
} else if (action.kind == "finance") {
const auto error = edit_demo_finance(next, action.value, *catalog_, next["managers"][0]["club"]);
if (!error.empty()) return {false, revision_, error};
@@ -255,6 +265,8 @@ Json DemoSource::load(const fs::path &file) {
throw editor::Error("invalid_focus");
if (!migrate_demo_finance(data, *catalog_, club))
throw editor::Error("invalid_demo_finance");
if (!migrate_demo_environment(data, *catalog_) || !migrate_demo_advertising(data, *catalog_) || !migrate_demo_toto(data, *catalog_))
throw editor::Error("invalid_demo_club");
auto next = data;
auto desktop = next.value("desktop", Json::object());
if (!migrate_desktop(desktop))
+6
View File
@@ -883,6 +883,12 @@ std::string App::render_menu(const std::string &key) {
body = render_friendlies();
else if (key == "indoor")
body = render_indoor();
else if (key == "environment")
body = render_environment();
else if (key == "advertising")
body = render_advertising();
else if (key == "toto")
body = render_toto();
else if (key == "bank")
body = render_bank();
else if (key == "balance")
+111
View File
@@ -0,0 +1,111 @@
// SPDX-License-Identifier: GPL-3.0-only
bool App::toto_action(const std::string &action, Rml::Element *target) {
if (menu_ != "toto" || !action.starts_with("toto-")) return false;
if (action == "toto-dialog-close") {
toto_dialog_.clear(); focus_after_render_ = toto_return_focus_; refresh(); return true;
}
if (!toto_dialog_.empty()) return true;
if (action == "toto-column") {
const auto col = target ? target->GetAttribute<int>("data-column", -1) : -1;
if (col < 0 || col > 5) return true;
toto_column_ = col; focus_after_render_ = "toto-column-" + std::to_string(col); refresh(); return true;
}
if (action == "toto-stake") {
const auto revision = snap().revision; const auto world = world_;
AmountRequest request;
request.title = "TOTO · Gesamteinsatz"; request.unit = money_unit();
request.suggestion_step = 1000;
request.value = snap().state.at("toto").at("stake").get<int64_t>() / finance_currency_factor(*world_);
request.return_focus = "toto-stake";
request.accept = [this, revision, world](int64_t value) {
if (!source_ || world_ != world || menu_ != "toto") return false;
const auto result = source_->apply({revision, "toto", {{"kind", "stake"}, {"value", value}}});
if (!result.ok) { message("Der Einsatz konnte nicht übernommen werden: " + result.error); return false; }
refresh(); return true;
};
open_amount(std::move(request)); return true;
}
if (action == "toto-last") {
if (snap().state.at("toto").at("coupon").is_null()) return true;
toto_dialog_ = "receipt"; toto_return_focus_ = "toto-last";
focus_after_render_ = "toto-dialog-close"; refresh(); return true;
}
Json change;
if (action == "toto-pick" && target) {
const auto col = target->GetAttribute<int>("data-column", -1), row = target->GetAttribute<int>("data-row", -1), pick = target->GetAttribute<int>("data-pick", -1);
if (col < 0 || col > 5 || row < 0 || row > 10 || pick < 0 || pick > 2) return true;
change = {{"kind", "pick"}, {"column", col}, {"row", row}, {"pick", pick}};
if (apply("toto", change)) {
toto_column_ = col; toto_focus_[size_t(col)] = {row, pick};
focus_after_render_ = toto_pick_id(col, row, pick); refresh();
}
return true;
}
if (action == "toto-auto" || action == "toto-clear") change = {{"kind", action == "toto-auto" ? "auto" : "clear"}, {"column", toto_column_}};
else if (action == "toto-submit") change = {{"kind", "submit"}};
else return false;
if (apply("toto", change)) {
if (action == "toto-submit") {
toto_dialog_ = "notice"; toto_return_focus_ = "toto-submit"; focus_after_render_ = "toto-dialog-close";
} else {
const auto value = snap().state.at("toto").at("columns")[size_t(toto_column_)][0].get<int>();
toto_focus_[size_t(toto_column_)] = {0, value < 0 ? 1 : value};
focus_after_render_ = action == "toto-clear" ? "toto-column-" + std::to_string(toto_column_) : "toto-auto";
}
refresh();
}
return true;
}
bool App::toto_event(Rml::Event &event) {
if (menu_ != "toto" || amount_ || !popup_.empty()) return false;
const auto type = event.GetType(); const bool keyboard = type == "keydown";
const auto key = keyboard ? Rml::Input::KeyIdentifier(event.GetParameter<int>("key_identifier", 0)) : Rml::Input::KI_UNKNOWN;
auto *target = event.GetTargetElement();
if (!toto_dialog_.empty()) {
if ((keyboard && key == Rml::Input::KI_ESCAPE) || (type == "mouseup" && event.GetParameter<int>("button", 0) == 1)) {
toto_action("toto-dialog-close", nullptr); event.StopImmediatePropagation(); return true;
}
bool inside = false;
for (auto *n = target; n && n != doc_; n = n->GetParentNode()) if (n->GetId() == "toto-layer") inside = true;
if (keyboard && key == Rml::Input::KI_TAB) {
if (auto *button = element("toto-dialog-close")) button->Focus(true);
event.StopImmediatePropagation(); return true;
}
if (!inside && (keyboard || type == "click" || type == "dblclick" || type == "mousedown" || type == "mouseup")) {
event.StopImmediatePropagation(); return true;
}
return false;
}
if (!keyboard) return false;
if (key == Rml::Input::KI_TAB) {
Rml::ElementList fields; doc_->QuerySelectorAll(fields, ".window button");
std::erase_if(fields, [](Rml::Element *n) { return !n->IsVisible(true) || n->HasAttribute("disabled") || n->GetAttribute<Rml::String>("data-tabstop", "true") == "false"; });
const auto found = std::find(fields.begin(), fields.end(), context_->GetFocusElement());
if (!fields.empty()) {
const int count = int(fields.size()), old = found == fields.end() ? -1 : int(found - fields.begin());
const bool back = event.GetParameter<int>("shift_key", 0);
const int next = old < 0 ? back ? count - 1 : 0 : (old + (back ? -1 : 1) + count) % count;
fields[size_t(next)]->Focus(true);
}
event.StopImmediatePropagation(); return true;
}
if (!target->HasAttribute("data-row") ||
(key != Rml::Input::KI_LEFT && key != Rml::Input::KI_RIGHT && key != Rml::Input::KI_UP &&
key != Rml::Input::KI_DOWN && key != Rml::Input::KI_HOME && key != Rml::Input::KI_END)) return false;
constexpr std::array<int, 3> picks{1, 0, 2};
int row = target->GetAttribute<int>("data-row", 0);
const int column = target->GetAttribute<int>("data-column", 0), pick = target->GetAttribute<int>("data-pick", 1);
int cell = column * 3 + int(std::find(picks.begin(), picks.end(), pick) - picks.begin());
if (key == Rml::Input::KI_UP || key == Rml::Input::KI_DOWN) row = std::clamp(row + (key == Rml::Input::KI_UP ? -1 : 1), 0, 10);
else if (key == Rml::Input::KI_LEFT || key == Rml::Input::KI_RIGHT) cell = std::clamp(cell + (key == Rml::Input::KI_LEFT ? -1 : 1), 0, 17);
else { cell = key == Rml::Input::KI_HOME ? 0 : 17; if (event.GetParameter<int>("ctrl_key", 0) || event.GetParameter<int>("meta_key", 0)) row = key == Rml::Input::KI_HOME ? 0 : 10; }
const auto col = cell / 3, next = picks[size_t(cell % 3)];
toto_focus_[size_t(col)] = {row, next};
Rml::ElementList fields; doc_->QuerySelectorAll(fields, ".toto-pick");
for (auto *n : fields) if (n->GetAttribute<int>("data-column", -1) == col) {
const bool active = n->GetId() == toto_pick_id(col, row, next);
n->SetAttribute("data-tabstop", active ? "true" : "false"); n->SetProperty("tab-index", active ? "auto" : "none");
}
if (auto *button = element(toto_pick_id(col, row, next))) button->Focus(true);
dirty_ = true; event.StopImmediatePropagation(); return true;
}
+96
View File
@@ -0,0 +1,96 @@
// SPDX-License-Identifier: GPL-3.0-only
namespace {
std::string toto_pick_id(int col, int row, int pick) {
return "toto-pick-" + std::to_string(col) + "-" + std::to_string(row) + "-" + std::to_string(pick);
}
}
std::string App::render_toto() {
const auto state = snap().state;
const auto &t = state.at("toto");
const auto summary = demo_toto_summary(state, *world_), programme = demo_toto_programme(*world_);
const bool available = programme.at("complete").get<bool>();
const auto &games = programme.at("rows");
const std::array<int, 3> picks{1, 0, 2};
std::string out = "<div id=\"toto-underlay\" class=\"toto-native\"><section class=\"toto-program\">"
"<header><p>Die Begegnungen</p><h2>Spielprogramm</h2><span>Spielrunde 27 · Saison " + esc(programme.at("season").get<std::string>()) +
"</span></header><div class=\"toto-program-head\"><span>Nr.</span><span>Heim – Gast</span><span>Liga</span></div>";
const auto club_name = [&](const Json *club, bool home) {
if (!club) return std::string("<span class=\"toto-club-name\">—</span>");
const auto name = "<span class=\"toto-club-name\">" + esc(world_->name(*club)) + "</span>", logo = crest(club, 34);
return "<span class=\"toto-club-label\" title=\"" + esc(world_->name(*club)) + "\">" +
(home ? name + logo : logo + name) + "</span>";
};
for (int r = 0; r < 11; ++r) {
const bool has = size_t(r) < games.size();
const auto *home = has ? world_->find("clubs", games[size_t(r)].at("home")) : nullptr;
const auto *away = has ? world_->find("clubs", games[size_t(r)].at("away")) : nullptr;
out += "<div class=\"toto-match-row" + std::string(r % 2 == 0 ? " striped" : "") + "\" style=\"top:" + scalar(298 + r * 82) + "dp;\">"
"<span class=\"toto-match-number\">" + std::to_string(r + 1) + "</span><div class=\"toto-match-teams\"><div class=\"toto-home\">" +
club_name(home, true) + "</div><span class=\"toto-versus\">–</span><div class=\"toto-away\">" + club_name(away, false) +
"</div></div><span class=\"toto-match-league\">" + (has ? std::to_string(games[size_t(r)].at("tier").get<int>()) + ". BL" : "—") + "</span></div>";
}
out += "<p class=\"toto-program-note\">" + std::string(available ? "Heim links · Gast rechts<br/>Die Spielnummer steht in jeder Tipp-Spalte."
: "Das Spielprogramm ist unvollständig.<br/>Ein Schein kann derzeit nicht vorgemerkt werden.") + "</p></section>"
"<article class=\"toto-coupon\"><span class=\"toto-print-mark top\"></span><span class=\"toto-print-mark bottom\"></span>"
"<header class=\"toto-paper-heading\"><div class=\"toto-paper-brand\"><strong>TOTO</strong><h2>ELFERWETTE</h2></div>"
"<div class=\"toto-paper-caption\"><strong>Spielschein</strong><span>11 Spiele · 6 Tipp-Spalten</span><small>Spielprogramm 27</small></div></header>";
const auto cross = renderer_.diagram("toto-ink-cross", "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"60\" height=\"80\" viewBox=\"0 0 60 80\"><path d=\"M10 14L49 66M48 12L12 69\" fill=\"none\" stroke=\"#253e62\" stroke-width=\"5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg>", 160);
constexpr double col_width = 221.619792, gap = 14, pick_width = (col_width - 43) / 3;
for (int c = 0; c < 6; ++c) {
const auto count = summary.at("counts")[size_t(c)].get<int>();
out += "<section class=\"toto-field" + std::string(c == toto_column_ ? " selected-column" : "") + "\" style=\"left:" + scalar(28 + c * (col_width + gap)) +
"dp;\" aria-label=\"Tipp-Spalte " + std::to_string(c + 1) + "\">" +
btn("toto-column", "<span>Spalte</span><strong>" + std::to_string(c + 1) + "</strong>", "toto-column-heading",
"id=\"toto-column-" + std::to_string(c) + "\" data-column=\"" + std::to_string(c) + "\" aria-pressed=\"" + (c == toto_column_ ? "true" : "false") + "\"") +
"<div class=\"toto-pick-head\"><span style=\"left:0;width:28dp;\">Nr.</span>";
for (int p = 0; p < 3; ++p)
out += "<span style=\"left:" + scalar(33 + p * (pick_width + 5)) + "dp;width:" + scalar(pick_width) + "dp;\">" + std::to_string(picks[size_t(p)]) + "</span>";
out += "</div>";
for (int r = 0; r < 11; ++r) {
out += "<div class=\"toto-pick-row\" style=\"top:" + std::to_string(116 + r * 82) + "dp;\"><span class=\"toto-row-number\">" + std::to_string(r + 1) + "</span>";
for (int p = 0; p < 3; ++p) {
const auto pick = picks[size_t(p)]; const bool chosen = t.at("columns")[size_t(c)][size_t(r)] == pick;
const bool tabstop = toto_focus_[size_t(c)] == std::pair(r, pick);
out += btn("toto-pick", "<span class=\"toto-pick-value\">" + std::to_string(pick) + "</span>" + (chosen ?
"<span class=\"toto-cross\" style=\"transform:rotate(" + std::to_string(((c + r) % 3 - 1) * 3) + "deg);\">" + picture(cross, pick_width, 64) + "</span>" : ""),
"toto-pick", "id=\"" + toto_pick_id(c, r, pick) + "\" data-column=\"" + std::to_string(c) + "\" data-row=\"" + std::to_string(r) +
"\" data-pick=\"" + std::to_string(pick) + "\" aria-pressed=\"" + (chosen ? "true" : "false") + "\" aria-label=\"Spalte " + std::to_string(c + 1) +
", Spiel " + std::to_string(r + 1) + ", " + (pick == 1 ? "Heimsieg" : pick == 0 ? "Unentschieden" : "Auswärtssieg") +
"\" style=\"left:" + scalar(33 + p * (pick_width + 5)) + "dp;width:" + scalar(pick_width) + "dp;tab-index:" + (tabstop ? "auto" : "none") + ";\" data-tabstop=\"" + (tabstop ? "true" : "false") + "\"");
}
out += "</div>";
}
out += "<p class=\"toto-field-progress\">" + (count == 0 ? "Leer" : count == 11 ? "Vollständig" : std::to_string(count) + " / 11") + "</p></section>";
}
out += "<footer class=\"toto-paper-footer\"><p><strong>1</strong> Heimsieg <b>·</b> <strong>0</strong> Unentschieden <b>·</b> <strong>2</strong> Auswärtssieg</p>"
"<span>Pro Spiel und Spalte ein Kreuz. Leere Spalten bleiben unberücksichtigt.</span><small>OpenBMH · Musterschein · Grafik-POC</small></footer></article>";
const int complete = summary.at("complete"), partial = summary.at("partial");
out += "<div class=\"toto-status\"><div><strong>" + std::to_string(complete) + (complete == 1 ? " vollständige Spalte" : " vollständige Spalten") +
"</strong><span>" + (partial ? std::to_string(partial) + (partial == 1 ? " Spalte noch unvollständig" : " Spalten noch unvollständig") :
"Spalte " + std::to_string(toto_column_ + 1) + " für Tippvorschlag und Leeren ausgewählt") + "</span></div><p>Einsatz gesamt <strong>" + esc(cash(t.at("stake"))) + "</strong></p></div>";
out += "<nav class=\"toto-nav\">" + btn("toto-stake", "Einsatz", "toto-control", "id=\"toto-stake\"") +
btn("toto-auto", "Tippvorschlag", "toto-control", "id=\"toto-auto\"") +
btn("toto-clear", "Spalte leeren", "toto-control", "id=\"toto-clear\" " + std::string(summary.at("counts")[size_t(toto_column_)] == 0 ? "disabled" : "")) +
btn("toto-submit", "Übernehmen", "toto-control", "id=\"toto-submit\" " + std::string(available && summary.at("can_submit").get<bool>() ? "" : "disabled")) +
btn("toto-last", "Letzter Schein", "toto-control", "id=\"toto-last\" " + std::string(t.at("coupon").is_null() ? "disabled" : "")) + "</nav></div>";
if (toto_dialog_.empty()) return out;
const auto &coupon = t.at("coupon");
if (coupon.is_null()) { toto_dialog_.clear(); return out; }
std::vector<int> active;
for (int c = 0; c < 6; ++c) if (coupon.at("columns")[size_t(c)][0] != -1) active.push_back(c);
out += "<div id=\"toto-layer\" class=\"toto-layer\"><section class=\"toto-dialog " + toto_dialog_ + "\" role=\"dialog\" aria-modal=\"true\" aria-labelledby=\"toto-dialog-title\">"
"<h2 id=\"toto-dialog-title\">" + std::string(toto_dialog_ == "receipt" ? "Letzter vorgemerkter Schein" : "Tippschein vorgemerkt") + "</h2>";
const auto caption = std::to_string(active.size()) + (active.size() == 1 ? " Spalte" : " Spalten");
if (toto_dialog_ == "receipt") {
out += "<div class=\"toto-receipt\">";
for (int row = -1; row < 11; ++row) {
out += "<div class=\"toto-receipt-row " + std::string(row == -1 ? "head" : row % 2 == 0 ? "striped" : "") + "\"><span style=\"width:16%;\">" + (row == -1 ? "Spiel" : std::to_string(row + 1)) + "</span>";
for (const auto c : active) out += "<span style=\"width:" + scalar(84.0 / active.size()) + "%;\">" +
(row == -1 ? "Spalte " + std::to_string(c + 1) : std::to_string(coupon.at("columns")[size_t(c)][size_t(row)].get<int>())) + "</span>";
out += "</div>";
}
out += "</div><p class=\"toto-receipt-total\">" + caption + " · Einsatz gesamt " + esc(cash(coupon.at("stake"))) + "</p>";
} else out += "<p class=\"toto-notice\">" + caption + " · " + std::to_string(active.size() * 11) + " Tipps · Einsatz gesamt " + esc(cash(coupon.at("stake"))) + "</p>";
out += "<nav class=\"toto-dialog-actions\">" + btn("toto-dialog-close", toto_dialog_ == "receipt" ? "Schließen" : "Verstanden", "toto-control", "id=\"toto-dialog-close\"") + "</nav></section></div>";
return out;
}
+34 -2
View File
@@ -7,6 +7,9 @@
#include "modern/ui/controls.hpp"
#include "modern/ui/demo_calendar.hpp"
#include "modern/ui/demo_finance.hpp"
#include "modern/ui/demo_environment.hpp"
#include "modern/ui/demo_advertising.hpp"
#include "modern/ui/demo_toto.hpp"
#include "modern/ui/demo_reports.hpp"
#include "modern/ui/demo_sports.hpp"
#include "modern/ui/desktop.hpp"
@@ -343,6 +346,12 @@ class App final : public Rml::EventListener {
int contracts_tab_ = 2;
uint64_t contracts_revision_ = 0;
std::shared_ptr<const Catalog> contracts_world_;
int advertising_selected_ = -1, advertising_offer_ = 0;
uint64_t advertising_revision_ = 0;
std::shared_ptr<const Catalog> advertising_world_;
int toto_column_ = 0;
std::array<std::pair<int, int>, 6> toto_focus_{{{0,1},{0,1},{0,1},{0,1},{0,1},{0,1}}};
std::string toto_dialog_, toto_return_focus_;
float device_ratio_ = 1.f;
Json desktop_ = Json::object(), saved_desktop_ = Json::object(),
options_ = Json::object();
@@ -556,6 +565,9 @@ class App final : public Rml::EventListener {
renderer_.world(next);
world_ = std::move(next);
source_ = std::move(demo);
advertising_selected_ = -1; advertising_offer_ = 0; advertising_revision_ = 0; advertising_world_.reset();
toto_column_ = 0; toto_dialog_.clear();
for (auto &focus : toto_focus_) focus = {0, 1};
amount_.reset();
amount_select_all_ = amount_caret_end_ = false;
contracts_dialog_.clear();
@@ -694,6 +706,14 @@ class App final : public Rml::EventListener {
bool contracts_action(const std::string &, Rml::Element *);
bool contracts_event(Rml::Event &);
void close_contracts(bool restore = true);
std::string render_environment();
bool environment_action(const std::string &, Rml::Element *);
std::string render_advertising();
bool advertising_action(const std::string &, Rml::Element *);
bool advertising_event(Rml::Event &);
std::string render_toto();
bool toto_action(const std::string &, Rml::Element *);
bool toto_event(Rml::Event &);
std::string render_almanac();
bool almanac_action(const std::string &, Rml::Element *);
std::string render_indoor();
@@ -763,6 +783,12 @@ class App final : public Rml::EventListener {
// open. Never keep that menu's modal/input gate in the destination view.
if (menu_ != last_rendered_menu_) {
planning_dialog_.clear();
toto_dialog_.clear();
if (menu_ == "toto" && source_)
for (size_t c = 0; c < toto_focus_.size(); ++c) {
const int pick = snap().state.at("toto").at("columns")[c][0];
toto_focus_[c] = {0, pick < 0 ? 1 : pick};
}
amount_.reset();
contracts_dialog_.clear();
contract_draft_ = Json();
@@ -799,10 +825,10 @@ class App final : public Rml::EventListener {
if (!menu_.empty())
markup += render_menu(menu_);
element("canvas")->SetInnerRML(markup);
if (!report_detail_kind_.empty() || !planning_dialog_.empty() || !contracts_dialog_.empty()) {
if (!report_detail_kind_.empty() || !planning_dialog_.empty() || !contracts_dialog_.empty() || !toto_dialog_.empty()) {
Rml::ElementList behind;
doc_->QuerySelectorAll(behind,
"#report-underlay button,#report-underlay input,#report-underlay select,#contracts-underlay button,.window .titlebar button");
"#report-underlay button,#report-underlay input,#report-underlay select,#contracts-underlay button,#toto-underlay button,.window .titlebar button");
for (auto *node : behind)
node->SetProperty("pointer-events", "none");
}
@@ -1206,6 +1232,12 @@ public:
#include "modern/ui/finance_controls.inc"
#include "modern/ui/contracts_screens.inc"
#include "modern/ui/contracts_controls.inc"
#include "modern/ui/environment_screens.inc"
#include "modern/ui/environment_controls.inc"
#include "modern/ui/advertising_screens.inc"
#include "modern/ui/advertising_controls.inc"
#include "modern/ui/toto_screens.inc"
#include "modern/ui/toto_controls.inc"
} // namespace
bool is_modern_world(const fs::path &file) {
try {
+155
View File
@@ -0,0 +1,155 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "modern/ui/demo_advertising.hpp"
#include <chrono>
#include <fstream>
#include <iostream>
#include <stdexcept>
using namespace bmh::modern_ui;
namespace {
void require(bool condition, const char *message) {
if (!condition) throw std::runtime_error(message);
}
struct Fixture {
fs::path root;
std::shared_ptr<const Catalog> world;
explicit Fixture(Json precision) {
root = fs::temp_directory_path() / ("openbmh-advertising-ui-" +
std::to_string(std::chrono::steady_clock::now().time_since_epoch().count()));
fs::create_directories(root / "world");
const auto write = [&](const fs::path &file, const Json &value) {
std::ofstream out(file); out << value.dump();
require(bool(out), "Cannot write synthetic catalogue");
};
write(root / "manifest.json", {{"format", "openbmh-world"}, {"kind", "world"},
{"format_version", "1.1"}, {"id", "world:synthetic-advertising"},
{"currency", {{"code", "EUR"}, {"minor_units", precision}}},
{"requires", {"editor:world-v1"}}, {"x-editor", {{"profile", "editor-world-v1"}}}});
for (const auto *table : {"clubs", "players", "competitions"})
write(root / "world" / (std::string(table) + ".json"), {{"items", Json::array()}});
world = Catalog::open(root);
}
~Fixture() { std::error_code ec; fs::remove_all(root, ec); }
};
void reject(Json &state, const Json &action, const Catalog &world) {
const auto before = state;
require(!edit_demo_advertising(state, action, world).empty() && state == before,
"Rejected advertising action mutated state or was accepted");
}
void edit(Json &state, const Json &action, const Catalog &world) {
const auto error = edit_demo_advertising(state, action, world);
if (!error.empty()) throw std::runtime_error("Unexpected advertising rejection: " + error);
require(valid_demo_advertising(state, world), "Accepted action produced invalid advertising state");
}
Json without_ads(Json state) { state.erase("advertising"); return state; }
void check_currency(int precision) {
Fixture fixture(precision);
const auto &world = *fixture.world;
const int64_t factor = precision == 2 ? 100 : 1;
Json state = {{"cash", 12450000 * factor}, {"deposit", 600000 * factor}, {"debt", 0}, {"ticket", 13},
{"training", {{"untouched", true}}}, {"contracts", {{"unrelated", {4, 5, 6}}}}};
const auto original = state, manifest = world.manifest(), clubs = world.rows("clubs");
require(!valid_demo_advertising(state, world) && migrate_demo_advertising(state, world) &&
valid_demo_advertising(state, world) && without_ads(state) == original,
"Migration lost unrelated fields or failed to add defaults");
const auto defaults = state;
const auto view = demo_advertising_view(state, world);
require(view.at("slots").size() == 16 && view.at("spending").size() == 3 &&
view.at("income") == 0 && view.at("expenses") == 75000 * factor &&
view.at("balance") == -75000 * factor && view.at("spending")[0].at("suggestion_step") == 50000 &&
view.at("spending")[1].at("suggestion_step") == 5000, "Default budgets or aggregate projection incorrect");
const auto board = demo_advertising_quote(state, 0, 0, world), shirt = demo_advertising_quote(state, 14, 2, world), tv = demo_advertising_quote(state, 15, 1, world);
require(board.at("amount") == 7000 * factor && board.at("name") == "MAINWERK" && board.at("months") == 12 &&
shirt.at("amount") == 158000 * factor && shirt.at("months") == 36 && shirt.at("sponsor") == 4 &&
tv.at("amount") == 104200 * factor && tv.at("name") == "FUSSBALL TV" && tv.at("months") == 24 &&
demo_advertising_quote(state, 13, 2, world).at("amount") == 17800 * factor,
"Pinned fictional offer prices, issuer or terms changed");
auto copied = board; copied["amount"] = 1;
require(demo_advertising_quote(state, 0, 0, world) == board && state == defaults,
"Query result aliases state or projection mutates state");
for (const auto &pair : {std::pair{-1, 0}, {16, 0}, {0, -1}, {0, 3}})
require(demo_advertising_quote(state, pair.first, pair.second, world).at("ok") == false && state == defaults,
"Out-of-range offer query accepted or mutated state");
edit(state, {{"kind", "accept"}, {"slot", 15}, {"offer", 1}}, world);
require(state.at("advertising").at("contracts")[15] == Json({{"sponsor", 1}, {"months", 24}, {"amount", 104200 * factor}}) &&
demo_advertising_view(state, world).at("income") == 104200 * factor && without_ads(state) == original,
"Acceptance booked cash, stored the wrong offer or failed totals");
const auto active = demo_advertising_quote(state, 15, 2, world);
require(active.at("active") == true && active.at("amount") == tv.at("amount") && active.at("months") == 24,
"Viewing another offer replaced an active contract");
reject(state, {{"kind", "accept"}, {"slot", 15}, {"offer", 2}}, world);
for (int slot = 0; slot < 15; ++slot) edit(state, {{"kind", "accept"}, {"slot", slot}, {"offer", slot % 3}}, world);
int64_t sum = 0;
for (const auto &c : state.at("advertising").at("contracts")) sum += c.at("amount").get<int64_t>();
require(demo_advertising_view(state, world).at("income") == sum && without_ads(state) == original,
"Full contract projection lost an income or changed wallet");
edit(state, {{"kind", "spending"}, {"index", 0}, {"value", 0}}, world);
edit(state, {{"kind", "spending"}, {"index", 1}, {"value", 12345}}, world);
edit(state, {{"kind", "spending"}, {"index", 2}, {"value", 99999999}}, world);
require(state["advertising"]["spending"][0] == 0 && state["advertising"]["spending"][1] == 12345 * factor &&
demo_advertising_view(state, world).at("expenses") == (99999999LL + 12345) * factor && without_ads(state) == original,
"Budget editor unit conversion or monetary isolation failed");
const auto preserved = state;
require(migrate_demo_advertising(state, world) && state == preserved &&
valid_demo_advertising(Json::parse(state.dump()), world), "Migration changed a valid saved agreement");
for (const auto &action : std::vector<Json>{nullptr, Json::array(), "bad", Json::object(), {{"kind", 1}},
{{"kind", "unknown"}}, {{"kind", "accept"}}, {{"kind", "accept"}, {"slot", 16}, {"offer", 0}},
{{"kind", "accept"}, {"slot", 0}, {"offer", 3}}, {{"kind", "accept"}, {"slot", 0}, {"offer", true}},
{{"kind", "accept"}, {"slot", uint64_t(-1)}, {"offer", 0}},
{{"kind", "accept"}, {"slot", 0}, {"offer", 0}, {"amount", 1}},
{{"kind", "spending"}}, {{"kind", "spending"}, {"index", 3}, {"value", 1}},
{{"kind", "spending"}, {"index", 0}, {"value", -1}}, {{"kind", "spending"}, {"index", 0}, {"value", 100000000}},
{{"kind", "spending"}, {"index", 0}, {"value", uint64_t(-1)}},
{{"kind", "spending"}, {"index", 0}, {"value", 1.0}}, {{"kind", "spending"}, {"index", 0}, {"value", true}},
{{"kind", "spending"}, {"index", 0}, {"value", 1}, {"cash", 0}}}) reject(state, action, world);
std::vector<Json> invalid;
auto bad = state; bad["advertising"] = nullptr; invalid.push_back(bad);
bad = state; bad["advertising"]["selected"] = 0; invalid.push_back(bad);
bad = state; bad["advertising"].erase("spending"); invalid.push_back(bad);
bad = state; bad["advertising"]["spending"].push_back(0); invalid.push_back(bad);
bad = state; bad["advertising"]["spending"][0] = uint64_t(-1); invalid.push_back(bad);
bad = state; bad["advertising"]["spending"][0] = 100000000LL * factor; invalid.push_back(bad);
bad = state; bad["advertising"]["contracts"][0]["sponsor"] = uint64_t(-1); invalid.push_back(bad);
bad = state; bad["advertising"]["contracts"][0]["sponsor"] = 10; invalid.push_back(bad);
bad = state; bad["advertising"]["contracts"][15]["sponsor"] = 5; invalid.push_back(bad);
bad = state; bad["advertising"]["contracts"][0]["months"] = 6; invalid.push_back(bad);
bad = state; bad["advertising"]["contracts"][0]["amount"] = 0; invalid.push_back(bad);
bad = state; bad["advertising"]["contracts"][0]["extra"] = true; invalid.push_back(bad);
bad = defaults; bad["advertising"]["contracts"][0]["months"] = 12; invalid.push_back(bad);
bad = defaults; bad["advertising"]["contracts"][0]["amount"] = 1; invalid.push_back(bad);
bad = defaults; bad["advertising"]["contracts"].erase(bad["advertising"]["contracts"].end() - 1); invalid.push_back(bad);
for (auto &v : invalid) {
require(!valid_demo_advertising(v, world), "Malformed stored advertising accepted");
const auto before = v;
require(!migrate_demo_advertising(v, world) && before == v, "Migration repaired present malformed data");
reject(v, {{"kind", "spending"}, {"index", 0}, {"value", 0}}, world);
require(demo_advertising_view(v, world).at("ok") == false, "Malformed state projected as valid");
}
auto maximum = state;
for (auto &c : maximum["advertising"]["contracts"]) c["amount"] = 99999999LL * factor;
for (auto &s : maximum["advertising"]["spending"]) s = 99999999LL * factor;
const auto totals = demo_advertising_view(maximum, world);
require(totals.at("income") == 16 * 99999999LL * factor && totals.at("expenses") == 3 * 99999999LL * factor &&
totals.at("balance") == 13 * 99999999LL * factor, "Aggregate overflow or unsafe money scaling");
auto cents = defaults;
if (precision == 2) {
cents["advertising"]["spending"][0] = 12345;
const auto original_cents = cents;
require(migrate_demo_advertising(cents, world) && cents == original_cents,
"Migration silently changed saved fractional currency values");
}
require(world.manifest() == manifest && world.rows("clubs") == clubs, "Advertising altered immutable world");
}
} // namespace
int main() try {
check_currency(0); check_currency(2);
for (const auto &precision : std::vector<Json>{1, 3, true, "2", nullptr, uint64_t(-1)}) {
Fixture invalid_currency(precision); Json state = {{"cash", 5}}; const auto before = state;
require(!migrate_demo_advertising(state, *invalid_currency.world) && state == before,
"Unsupported precision was silently substituted");
}
std::cout << "Modern UI advertising checks passed\n";
return 0;
} catch (const std::exception &error) {
std::cerr << error.what() << '\n'; return 1;
}
+1 -1
View File
@@ -100,7 +100,7 @@ int main(int argc, char **argv) try {
std::ostringstream css;
for (const auto *name : {"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"}) {
"report_pickers.rcss", "indoor.rcss", "planning.rcss", "almanac.rcss", "finance.rcss", "bank.rcss", "contracts.rcss", "amount.rcss", "environment.rcss", "advertising.rcss", "toto.rcss"}) {
std::ifstream input(root / name);
require(bool(input), "Production stylesheet missing");
css << input.rdbuf() << '\n';
+128
View File
@@ -0,0 +1,128 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "modern/ui/demo_environment.hpp"
#include <array>
#include <chrono>
#include <iostream>
#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;
explicit Fixture(Json precision = 0) {
root = fs::temp_directory_path() / ("openbmh-environment-ui-" +
std::to_string(std::chrono::steady_clock::now().time_since_epoch().count()));
fs::create_directories(root / "world");
bmh::editor::write_atomic(root / "manifest.json", Json({{"format", "openbmh-world"},
{"kind", "world"}, {"format_version", "1.1"}, {"id", "world:synthetic-environment"},
{"requires", {"editor:world-v1"}}, {"x-editor", {{"profile", "editor-world-v1"}}},
{"currency", {{"code", "EUR"}, {"minor_units", precision}}}}).dump());
for (const auto *table : {"nations", "clubs", "players", "competitions"})
bmh::editor::write_atomic(root / "world" / (std::string(table) + ".json"),
Json({{"items", Json::array()}}).dump());
bmh::editor::write_atomic(root / "world/staff.json", Json({{"items", Json::array({
{{"id", "staff:synthetic"}, {"name", "Synthetic catalogue staff"}, {"role", "doctor"}}})}}).dump());
world = Catalog::open(root);
}
~Fixture() { std::error_code ec; fs::remove_all(root, ec); }
};
void currency_case(int precision, int64_t factor) {
Fixture f(precision);
const auto staff = f.world->rows("staff");
const auto staff_file = bmh::editor::read_file(f.root / "world/staff.json");
Json state = {{"cash", 123456 * factor}, {"deposit", 750 * factor}, {"debt", 0},
{"staff", {{"unrelated_legacy_marker", "preserved"}}}, {"edits", {{"other", 17}}}};
const auto legacy = state;
require(migrate_demo_environment(state, *f.world) && valid_demo_environment(state, *f.world),
"Missing environment budgets did not migrate");
require(state.at("environment").at("levels") == Json::array({2,3,4,3,4,2}),
"Diamond 3.6 initial budgets changed");
auto without_environment = state;
without_environment.erase("environment");
require(without_environment == legacy, "Migration changed wallet, staff or unrelated legacy fields");
const auto initial = state;
require(migrate_demo_environment(state, *f.world) && state == initial,
"Environment migration is not idempotent");
const auto projection = demo_environment_rows(state, *f.world);
require(projection.value("ok", false) && projection.at("rows").size() == 6 &&
projection.at("total") == 88500 * factor && state == initial,
"Default monthly preview or read-only projection changed");
const std::array<int64_t, 6> rates{2000,3000,5000,7500,6000,4500};
for (size_t i = 0; i < rates.size(); ++i) {
const auto &row = projection.at("rows")[i];
require(row.at("rate") == rates[i] * factor &&
row.at("cost") == rates[i] * factor * initial.at("environment").at("levels")[i].get<int>(),
"Environment preview double-converted currency or changed its Gold rate");
require(i < 3 ? row.at("rank").is_number_integer() && row.at("league").is_number_integer()
: row.at("rank").is_null() && row.at("league").is_null(),
"Staff inherited a fictional youth standing");
}
for (int i = 0; i < 6; ++i)
require(edit_demo_environment(state, {{"kind", "level"}, {"index", i}, {"value", 0}}, *f.world).empty(),
"Zero budget was rejected");
require(demo_environment_rows(state, *f.world).at("total") == 0,
"Disabled budgets invented ongoing preview costs");
for (int i = 0; i < 6; ++i)
require(edit_demo_environment(state, {{"kind", "level"}, {"index", i}, {"value", 6}}, *f.world).empty(),
"Sixth star was unavailable");
require(demo_environment_rows(state, *f.world).at("total") == 168000 * factor,
"Six-star monthly total or raw currency precision is wrong");
const auto funded = state;
require(edit_demo_environment(state, {{"kind", "level"}, {"index", 0}, {"value", 6}}, *f.world).empty() && state == funded,
"Selecting the current budget toggled it off");
require(migrate_demo_environment(state, *f.world) && state == funded,
"Checkpoint migration reset existing budget choices");
auto unrelated = state;
unrelated.erase("environment");
require(unrelated == legacy && f.world->rows("staff") == staff &&
bmh::editor::read_file(f.root / "world/staff.json") == staff_file,
"Environment selection booked cash or modified catalogue staff");
const std::vector<Json> invalid_actions = {nullptr, Json::array(), Json::object(),
{{"kind", "other"}, {"index", 0}, {"value", 1}},
{{"kind", "level"}, {"index", -1}, {"value", 1}},
{{"kind", "level"}, {"index", 6}, {"value", 1}},
{{"kind", "level"}, {"index", true}, {"value", 1}},
{{"kind", "level"}, {"index", 0}, {"value", -1}},
{{"kind", "level"}, {"index", 0}, {"value", 7}},
{{"kind", "level"}, {"index", 0}, {"value", 6.0}},
{{"kind", "level"}, {"index", 0}, {"value", false}},
{{"kind", "level"}, {"index", 0}, {"value", uint64_t(-1)}},
{{"kind", "level"}, {"index", 0}, {"value", 2}, {"cash", 0}}};
for (const auto &action : invalid_actions) {
const auto before = state;
require(!edit_demo_environment(state, action, *f.world).empty() && state == before,
"Invalid environment action threw or changed state");
}
std::vector<Json> invalid_states{nullptr, Json::array(), Json{{"environment", nullptr}},
Json{{"environment", {{"levels", {0,0,0,0,0}}}}},
Json{{"environment", {{"levels", {0,0,0,0,0,7}}}}},
Json{{"environment", {{"levels", {0,0,0,0,0,true}}}}},
Json{{"environment", {{"levels", {0,0,0,0,0,1.0}}}}},
Json{{"environment", {{"levels", {0,0,0,0,0,0}}, {"extra", 1}}}}};
for (auto invalid : invalid_states) {
const auto before = invalid;
require(!valid_demo_environment(invalid, *f.world) &&
!migrate_demo_environment(invalid, *f.world) && invalid == before &&
!edit_demo_environment(invalid, {{"kind", "level"}, {"index", 0}, {"value", 1}}, *f.world).empty() &&
invalid == before && !demo_environment_rows(invalid, *f.world).value("ok", true),
"Malformed environment data was partially repaired or projected");
}
}
} // namespace
int main() try {
currency_case(0, 1);
currency_case(2, 100);
Fixture unsupported(1);
Json state = Json::object();
require(!migrate_demo_environment(state, *unsupported.world) && state.empty(),
"Unsupported currency precision initialized a misleading environment budget");
std::cout << "Modern environment preview checks passed\n";
return 0;
} catch (const std::exception &error) {
std::cerr << error.what() << '\n';
return 1;
}
+109
View File
@@ -0,0 +1,109 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "modern/ui/demo_toto.hpp"
#include "modern/ui/demo_reports.hpp"
#include "modern/ui/model.hpp"
#include "modern/ui/desktop.hpp"
#include <chrono>
#include <fstream>
#include <iostream>
#include <set>
#include <stdexcept>
using namespace bmh::modern_ui;
namespace {
void require(bool ok, const char *message) { if (!ok) throw std::runtime_error(message); }
struct Fixture {
fs::path path; std::shared_ptr<const Catalog> world;
Fixture(int precision = 0, bool full = true) {
path = fs::temp_directory_path() / ("openbmh-toto-ui-" + std::to_string(std::chrono::steady_clock::now().time_since_epoch().count()));
fs::create_directories(path / "world");
auto write = [&](const char *name, const Json &data) { std::ofstream out(path / name); out << data.dump(); require(bool(out), "Cannot write fixture"); };
write("manifest.json", {{"format", "openbmh-world"}, {"kind", "world"}, {"format_version", "1.1"},
{"id", "world:synthetic-toto"}, {"start_date", "2026-07-01"}, {"currency", {{"code", "EUR"}, {"minor_units", precision}}},
{"requires", {"editor:world-v1"}}, {"x-editor", {{"profile", "editor-world-v1"}}}});
write("world/nations.json", {{"items", {{{"id", "nation:de"}, {"name", "Synthetic nation"}}}}});
Json leagues = Json::array(), clubs = Json::array();
for (int tier = 1; tier <= 2; ++tier) {
auto id = "league:synthetic-" + std::to_string(tier);
leagues.push_back({{"id", id}, {"name", "Synthetic league " + std::to_string(tier)},
{"nation", "nation:de"}, {"type", "league"}, {"tier", tier}});
for (int c = 0; c < (full ? 18 : 2); ++c)
clubs.push_back({{"id", "club:synthetic-" + std::to_string(tier) + "-" + std::to_string(c)},
{"name", "Synthetic club " + std::to_string(tier) + "-" + std::to_string(c)},
{"competition", id}, {"nation", "nation:de"}, {"order", c}});
}
write("world/competitions.json", {{"items", leagues}}); write("world/clubs.json", {{"items", clubs}});
write("world/players.json", {{"items", Json::array()}});
world = Catalog::open(path);
}
~Fixture() { std::error_code ec; fs::remove_all(path, ec); }
};
void successful(Json &s, const Json &a, const Catalog &w) { require(edit_demo_toto(s, a, w).empty(), "Expected valid Toto action"); }
void rejected(Json &s, const Json &a, const Catalog &w) {
const auto before = s; require(!edit_demo_toto(s, a, w).empty(), "Invalid Toto action accepted"); require(s == before, "Rejected action mutated state");
}
void exercise(int precision) {
Fixture fixture(precision); const auto &world = *fixture.world;
const int64_t factor = precision == 2 ? 100 : 1;
Json state = {{"cash", 900000 * factor}, {"deposit", 400000 * factor}, {"other", {"untouched"}}};
require(migrate_demo_toto(state, world), "Legacy migration failed");
const auto initial = state;
require(migrate_demo_toto(state, world) && state == initial, "Migration changed existing state");
require(state["toto"]["stake"] == 1000 * factor && demo_toto_summary(state, world)["complete"] == 1, "Initial stakes/columns differ");
auto programme = demo_toto_programme(world);
require(programme["complete"] == true && programme["rows"].size() == 11, "No complete 9+2 programme");
std::set<std::string> sides;
for (size_t i = 0; i < 11; ++i) {
const auto &m = programme["rows"][i]; require(m["tier"] == (i < 9 ? 1 : 2), "Wrong league mixture");
require(m["home"] != m["away"] && world.find("clubs", m["home"]) && world.find("clubs", m["away"]), "Invented opponent");
require(sides.insert(m["home"]).second && sides.insert(m["away"]).second, "Duplicate team in programme");
}
successful(state, {{"kind", "submit"}}, world);
const auto receipt = state["toto"]["coupon"];
successful(state, {{"kind", "pick"}, {"column", 1}, {"row", 4}, {"pick", 2}}, world);
require(demo_toto_summary(state, world)["partial"] == 1 && state["toto"]["columns"][0] == initial["toto"]["columns"][0], "Columns not independent");
rejected(state, {{"kind", "submit"}}, world);
successful(state, {{"kind", "pick"}, {"column", 1}, {"row", 4}, {"pick", 2}}, world);
require(demo_toto_summary(state, world)["partial"] == 0, "Clicking cross again does not clear");
for (int c = 1; c < 6; ++c) successful(state, {{"kind", "auto"}, {"column", c}}, world);
require(demo_toto_summary(state, world)["complete"] == 6 && state["toto"]["coupon"] == receipt, "Working picks mutated receipt");
successful(state, {{"kind", "stake"}, {"value", 0}}, world); rejected(state, {{"kind", "submit"}}, world);
successful(state, {{"kind", "stake"}, {"value", 99999999}}, world);
require(state["toto"]["stake"] == 99999999 * factor, "Money precision changed twice");
successful(state, {{"kind", "submit"}}, world);
const auto full = state["toto"]["coupon"];
for (int c = 0; c < 6; ++c) successful(state, {{"kind", "clear"}, {"column", c}}, world);
rejected(state, {{"kind", "submit"}}, world);
require(state["toto"]["coupon"] == full, "Clearing picks altered the receipt");
for (auto a : {Json{{"kind", "pick"}, {"column", -1}, {"row", 0}, {"pick", 1}},
Json{{"kind", "pick"}, {"column", 0}, {"row", 11}, {"pick", 1}},
Json{{"kind", "pick"}, {"column", 0}, {"row", 0}, {"pick", 3}},
Json{{"kind", "stake"}, {"value", 100000000}}, Json{{"kind", "stake"}, {"value", 1.5}},
Json{{"kind", "auto"}, {"column", uint64_t(-1)}}, Json{{"kind", "unrecognized"}}}) rejected(state, a, world);
auto rest = state; rest.erase("toto"); auto original = initial; original.erase("toto");
require(rest == original && demo_toto_programme(world) == programme, "Toto booked money or changed programme");
auto bad = state; bad["toto"]["columns"][0].push_back(0); auto before = bad;
require(!migrate_demo_toto(bad, world) && bad == before, "Invalid existing state repaired");
bad = state; bad["toto"]["coupon"]["columns"][0][3] = -1;
require(!valid_demo_toto(bad, world), "Partial saved coupon accepted");
DemoSource source(fixture.world); const auto old = source.snapshot();
require(source.apply({old.revision, "toto", {{"kind", "stake"}, {"value", 2100}}}).ok, "DataSource cannot edit stake");
require(!source.apply({old.revision, "toto", {{"kind", "submit"}}}).ok, "Stale revision accepted");
auto accepted = source.snapshot();
require(!source.apply({accepted.revision, "toto", {{"kind", "stake"}, {"value", -1}}}).ok && source.snapshot().state == accepted.state, "Failed action partially committed");
auto file = fixture.path / "state.json"; source.save(file, default_desktop());
source.apply({source.snapshot().revision, "toto", {{"kind", "clear"}, {"column", 0}}});
source.load(file); require(source.snapshot().state == accepted.state && !source.dirty(), "Checkpoint roundtrip failed");
auto legacy = accepted.state; legacy.erase("toto"); legacy["desktop"] = default_desktop();
{ std::ofstream out(file); out << legacy.dump(); } source.load(file);
require(source.snapshot().state["toto"] == initial["toto"] && source.snapshot().state["cash"] == accepted.state["cash"], "Legacy load altered wallet");
}
} // namespace
int main() try {
exercise(0); exercise(2);
Fixture partial(0, false); Json state = Json::object();
require(migrate_demo_toto(state, *partial.world), "Incomplete world migration failed");
require(demo_toto_programme(*partial.world)["complete"] == false, "Incomplete programme masked");
rejected(state, {{"kind", "submit"}}, *partial.world);
std::cout << "Modern Toto UI tests passed\n";
return 0;
} catch (const std::exception &e) { std::cerr << e.what() << '\n'; return 1; }
+41
View File
@@ -6,7 +6,11 @@
#include "modern/ui/desktop.hpp"
#include "modern/ui/gui_assets.hpp"
#include "modern/ui/model.hpp"
#include "modern/ui/demo_environment.hpp"
#include "modern/ui/demo_advertising.hpp"
#include "modern/ui/demo_toto.hpp"
#include <chrono>
#include <fstream>
#include <iostream>
#include <stdexcept>
@@ -25,6 +29,42 @@ void table(const fs::path &root, const std::string &name, const Json &rows) {
name == "assets" ? "assets/index.json" : "world/" + name + ".json",
{{"schema", name + "@1.0"}, {"items", rows}});
}
void check_club_views(const fs::path &root, std::shared_ptr<const Catalog> world) {
DemoSource source(world);
auto initial = source.snapshot();
require(valid_demo_environment(initial.state, *world) && valid_demo_advertising(initial.state, *world) && valid_demo_toto(initial.state, *world), "Club preview initialization invalid");
require(source.apply({initial.revision, "environment", {{"kind", "level"}, {"index", 0}, {"value", 6}}}).ok, "Environment action failed");
auto changed = source.snapshot();
int slot = -1;
for (int i = 0; i < 16; ++i) if (changed.state["advertising"]["contracts"][size_t(i)]["sponsor"] == -1) {slot=i;break;}
require(slot >= 0, "No test offer slot");
const Json offer = {{"kind", "accept"}, {"slot", slot}, {"offer", 2}};
require(!source.apply({initial.revision, "advertising", offer}).ok && source.snapshot().state == changed.state && source.snapshot().revision == changed.revision, "Stale advertising quote changed source");
require(source.apply({changed.revision, "advertising", offer}).ok, "Valid advertising offer rejected");
changed = source.snapshot();
require(!source.apply({changed.revision, "advertising", offer}).ok && source.snapshot().state == changed.state, "Active advertising contract overwritten");
require(source.apply({changed.revision, "advertising", {{"kind", "spending"}, {"index", 2}, {"value", 7000}}}).ok, "Advertising budget rejected");
changed = source.snapshot();
for (const auto *key : {"cash", "deposit", "debt", "training", "tactics", "calendar", "reports", "finance", "contracts"})
require(changed.state.at(key) == initial.state.at(key), "Club previews changed unrelated state");
const auto saved = root / "club-preview-checkpoint.json";
source.save(saved, default_desktop());
source.apply({source.snapshot().revision, "environment", {{"kind", "level"}, {"index", 0}, {"value", 0}}});
source.load(saved);
require(source.snapshot().state == changed.state && !source.dirty(), "Club preview checkpoint did not roundtrip");
auto malformed = changed.state; malformed["desktop"] = default_desktop();
malformed["advertising"]["spending"][0] = "invalid";
{std::ofstream out(saved);out << malformed.dump();}
const auto before = source.snapshot(); bool threw = false;
try {source.load(saved);} catch (const std::exception &) {threw = true;}
require(threw && source.snapshot().state == before.state && source.snapshot().revision == before.revision, "Malformed club checkpoint partially loaded");
auto legacy = changed.state; legacy["desktop"] = default_desktop();
legacy.erase("environment"); legacy.erase("advertising"); legacy.erase("toto");
{std::ofstream out(saved);out << legacy.dump();}
source.load(saved); const auto migrated = source.snapshot().state;
require(migrated["environment"] == initial.state["environment"] && migrated["advertising"] == initial.state["advertising"] && migrated["toto"] == initial.state["toto"], "Legacy club fields not initialized");
require(migrated["cash"] == changed.state["cash"] && migrated["finance"] == changed.state["finance"], "Legacy migration reset wallet");
}
void check_finance_source(const fs::path &root,
const std::shared_ptr<const Catalog> &base) {
const auto folder = root / "finance-source";
@@ -579,6 +619,7 @@ int main(int argc, char **argv) try {
restored_planning.snapshot().state["reports"]["sorts"]["indoor"]["key"] == "points",
"Old checkpoint lost league preview or failed planning/indoor migration");
check_finance_source(root, world);
check_club_views(root, world);
GuiAssets absent(root / "missing-gui");
require(!absent.available(),
"World resources were mistaken for GUI resources");
+7
View File
@@ -56,6 +56,13 @@ def main():
add('button.' + route, button['src'].removeprefix('../'))
add('button.news', 'assets/vector/desktop-news.svg')
add('button.almanac', 'assets/vector/desktop-almanac.svg')
for i in range(4):
add('advertising.panel.' + str(i), 'assets/studies/submenus/advertising-panels-v1.png',
[(i % 2) / 2, (i // 2) / 2, .5, .5])
for group in ['staff', 'youth']:
for i in range(3):
add('environment.' + group + '.' + str(i), 'assets/studies/submenus/environment-' + group + '-v1.png',
[(i % 2) / 2, (i // 2) / 2, .5, .5])
for i in range(6):
add('bank.property.' + str(i), 'assets/studies/submenus/bank-properties-v1.png',
[(i % 2) / 2, (i // 2) / 3, .5, 1 / 3])