Port statistics and the news tablet to the Modern UI (by Codex)
This commit is contained in:
1 parent
349c416f3a
commit
a45217c362
32 files changed
+2493
-23
No files matched your search
@@ -52,9 +52,9 @@ jobs:
|
||||
- name: Configure opt-in UI without external assets
|
||||
run: cmake -S . -B build-ui -G Ninja -DCMAKE_BUILD_TYPE=Release -DOPENBMH_BUILD_MODERN_UI=ON -DOPENBMH_BUILD_EDITOR=OFF -DBMH_DATA=
|
||||
- name: Compile native frontend and synthetic checks
|
||||
run: cmake --build build-ui --target openbmh_play modern_ui_core_tests modern_ticket_document_tests modern_control_layout_tests modern_reports_tests modern_planning_tests modern_almanac_ui_tests modern_finance_ui_tests modern_environment_ui_tests modern_advertising_ui_tests modern_toto_ui_tests modern_lineup_ui_tests modern_transfer_ui_tests modern_career_reports_tests modern_rankings_tests modern_stadium_ui_tests --parallel 2
|
||||
run: cmake --build build-ui --target openbmh_play modern_ui_core_tests modern_ticket_document_tests modern_control_layout_tests modern_reports_tests modern_planning_tests modern_almanac_ui_tests modern_finance_ui_tests modern_environment_ui_tests modern_advertising_ui_tests modern_toto_ui_tests modern_lineup_ui_tests modern_transfer_ui_tests modern_career_reports_tests modern_rankings_tests modern_stadium_ui_tests modern_statistics_ui_tests modern_news_ui_tests --parallel 2
|
||||
- name: Check controls, fonts, density and draft cancellation
|
||||
run: ctest --test-dir build-ui -R "^modern_(ui_|ticket_|control_|reports_|planning_|almanac_ui_|finance_ui_|environment_ui_|advertising_ui_|toto_ui_|lineup_ui_|transfer_ui_|career_reports_|rankings_|stadium_ui_)" --output-on-failure --output-junit modern-ui-results.xml
|
||||
run: ctest --test-dir build-ui -R "^modern_(ui_|ticket_|control_|reports_|planning_|almanac_ui_|finance_ui_|environment_ui_|advertising_ui_|toto_ui_|lineup_ui_|transfer_ui_|career_reports_|rankings_|stadium_ui_|statistics_ui_|news_ui_)" --output-on-failure --output-junit modern-ui-results.xml
|
||||
- name: Upload test report
|
||||
if: always()
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
<!-- SPDX-License-Identifier: GPL-3.0-only -->
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#dceae7" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M9 5 4 10l5 5M4 10h10a6 6 0 0 1 0 12"/></svg>
|
||||
|
After Width: | Height: | Size: 257 B |
@@ -1,6 +1,6 @@
|
||||
<rml>
|
||||
<head><title>OpenBMH</title><link type="text/rcss" href="theme.rcss"/><link type="text/rcss" href="ticket.rcss"/><link type="text/rcss" href="sports.rcss"/><link type="text/rcss" href="calendar.rcss"/><link type="text/rcss" href="reports.rcss"/><link type="text/rcss" href="report_details.rcss"/><link type="text/rcss" href="report_pickers.rcss"/><link type="text/rcss" href="indoor.rcss"/><link type="text/rcss" href="planning.rcss"/><link type="text/rcss" href="almanac.rcss"/><link type="text/rcss" href="finance.rcss"/>
|
||||
<link type="text/rcss" href="bank.rcss"/><link type="text/rcss" href="contracts.rcss"/><link type="text/rcss" href="amount.rcss"/><link type="text/rcss" href="environment.rcss"/><link type="text/rcss" href="advertising.rcss"/><link type="text/rcss" href="toto.rcss"/><link type="text/rcss" href="lineup.rcss"/><link type="text/rcss" href="transfer.rcss"/><link type="text/rcss" href="career_reports.rcss"/><link type="text/rcss" href="rankings.rcss"/><link type="text/rcss" href="stadium.rcss"/></head>
|
||||
<link type="text/rcss" href="bank.rcss"/><link type="text/rcss" href="contracts.rcss"/><link type="text/rcss" href="amount.rcss"/><link type="text/rcss" href="environment.rcss"/><link type="text/rcss" href="advertising.rcss"/><link type="text/rcss" href="toto.rcss"/><link type="text/rcss" href="lineup.rcss"/><link type="text/rcss" href="transfer.rcss"/><link type="text/rcss" href="career_reports.rcss"/><link type="text/rcss" href="rankings.rcss"/><link type="text/rcss" href="stadium.rcss"/><link type="text/rcss" href="statistics.rcss"/><link type="text/rcss" href="news.rcss"/></head>
|
||||
<body class="midnight">
|
||||
<div id="background"></div>
|
||||
<div id="canvas"></div>
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-only */
|
||||
.window.news-tablet {border:16dp #101821;border-radius:74dp;box-shadow:0dp 50dp 130dp #000a;overflow:hidden;}
|
||||
.news-tablet>.titlebar {height:118dp;padding-top:14dp;border:0dp;border-radius:54dp 54dp 0dp 0dp;}
|
||||
.news-tablet>.content {left:58dp;right:58dp;top:150dp;bottom:126dp;}
|
||||
.news-camera {position:absolute;left:50%;margin-left:-7dp;top:18dp;width:14dp;height:14dp;border:3dp #111c25;border-radius:7dp;background-color:#526b83;z-index:5;}
|
||||
.news-homebar {position:absolute;left:50%;margin-left:-130dp;bottom:16dp;width:260dp;height:8dp;border-radius:6dp;background-color:var(--muted);opacity:0.5;}
|
||||
.news-screen-footer {position:absolute;left:58dp;right:58dp;bottom:42dp;height:60dp;display:flex;align-items:center;justify-content:space-between;border-top:2dp var(--border);font-size:24dp;color:var(--muted);}
|
||||
.news-layout {position:absolute;left:0;right:0;top:0;bottom:0;color:var(--text);}
|
||||
.news-masthead {position:absolute;left:6dp;right:6dp;top:0;height:180dp;padding-bottom:34dp;display:flex;align-items:center;justify-content:space-between;gap:36dp;}
|
||||
.news-brand {display:flex;align-items:center;gap:34dp;min-width:0;}
|
||||
.news-wordmark {padding:8dp 24dp 15dp;border:2dp #ff8c8c25;border-radius:15dp;background-color:#c92736;color:#fff6f4;font-size:86dp;font-weight:bold;font-style:italic;letter-spacing:-5dp;line-height:1;}
|
||||
.news-brand p {margin-bottom:12dp;color:var(--muted);font-size:22dp;letter-spacing:4dp;}
|
||||
.news-brand h2 {font-size:48dp;line-height:1.1;font-weight:normal;letter-spacing:-1dp;}
|
||||
.news-owner {display:flex;align-items:center;gap:24dp;min-width:0;}
|
||||
.news-owner>div {text-align:right;}
|
||||
.news-owner strong {font-size:32dp;font-weight:normal;}
|
||||
.news-owner p {margin-top:14dp;font-size:26dp;color:var(--muted);}
|
||||
.news-owner>.image-frame {flex-shrink:0;}
|
||||
.news-navigation {position:absolute;left:0;right:0;top:180dp;height:116dp;display:flex;align-items:center;gap:22dp;padding-bottom:28dp;border-bottom:2dp var(--border);}
|
||||
.news-tabs {display:flex;align-items:stretch;padding:7dp;border:2dp var(--border);border-radius:17dp;background-color:var(--panel);gap:5dp;flex-shrink:0;}
|
||||
.news-tabs .news-tab {display:flex;align-items:center;justify-content:center;gap:18dp;min-width:240dp;height:65dp;padding:12dp 22dp;border:0dp;border-radius:11dp;background-color:transparent;color:var(--muted);font-size:30dp;}
|
||||
.news-tabs .news-tab.active {background-color:var(--selected);color:var(--text);}
|
||||
.news-tab-count {min-width:40dp;padding:3dp 9dp;border-radius:8dp;background-color:var(--panel);color:var(--text);font-size:23dp;text-align:center;}
|
||||
.news-search {display:flex;align-items:center;gap:16dp;min-width:0;max-width:760dp;flex:1;margin-left:auto;padding:16dp 22dp;border:2dp var(--border);border-radius:13dp;background-color:var(--input);}
|
||||
.news-search input {min-width:0;width:100%;margin:0;padding:0;border:0dp;border-radius:0dp;background-color:transparent;color:var(--text);font-size:28dp;line-height:1.4;}
|
||||
.news-search-symbol {position:relative;width:27dp;height:27dp;flex-shrink:0;margin-right:9dp;border:3dp var(--muted);border-radius:14dp;}
|
||||
.news-search-symbol>span {position:absolute;left:21dp;top:21dp;width:13dp;height:3dp;transform:rotate(45deg);background-color:var(--muted);}
|
||||
.news-read-all {display:flex;align-items:center;justify-content:center;gap:16dp;min-height:78dp;padding:14dp 22dp;border:2dp var(--border);border-radius:13dp;background-color:var(--soft);color:var(--text);font-size:27dp;white-space:nowrap;flex-shrink:0;}
|
||||
.news-read-all .image-frame {flex-shrink:0;}
|
||||
.news-feed {position:absolute;left:0;right:0;top:296dp;bottom:80dp;overflow-y:auto;overflow-x:hidden;padding-right:20dp;}
|
||||
.news-message {position:relative;display:flex;align-items:center;gap:32dp;min-height:218dp;padding:28dp 16dp 28dp 18dp;border-bottom:2dp var(--border);}
|
||||
.news-message.is-unread {background-color:var(--soft);}
|
||||
.news-unread-dot {position:absolute;left:0;top:50%;margin-top:-5dp;width:10dp;height:10dp;border-radius:5dp;background-color:var(--accent);}
|
||||
.news-art {display:flex;align-items:center;justify-content:center;flex-shrink:0;border:2dp var(--border);border-radius:28dp;background-color:var(--soft);}
|
||||
.news-message-copy {flex:1;min-width:0;}
|
||||
.news-message-meta {display:flex;align-items:center;gap:20dp;margin-bottom:13dp;font-size:24dp;line-height:1.4;color:var(--muted);}
|
||||
.news-category {padding-left:20dp;border-left:2dp var(--border);}
|
||||
.news-new {padding:2dp 12dp;border:2dp var(--border);border-radius:7dp;background-color:var(--selected);color:var(--accent);font-size:20dp;}
|
||||
.news-message-title {display:flex;justify-content:flex-start;align-items:center;max-width:100%;padding:0;margin:0 0 12dp;border:0dp;border-radius:3dp;background-color:transparent;color:var(--text);font-size:35dp;font-weight:normal;line-height:1.3;text-align:left;}
|
||||
.news-message.is-unread .news-message-title {font-weight:bold;}
|
||||
.news-message-title:hover {background-color:transparent;color:var(--accent);}
|
||||
.news-excerpt {max-height:81dp;overflow:hidden;font-size:27dp;line-height:1.5;color:var(--muted);}
|
||||
.news-row-actions {display:flex;align-items:center;gap:10dp;width:136dp;flex-shrink:0;}
|
||||
.news-icon-button {display:flex;align-items:center;justify-content:center;width:62dp;height:68dp;padding:10dp;border:0dp;border-radius:10dp;background-color:transparent;color:var(--muted);}
|
||||
.news-icon-button:hover {background-color:var(--hover);color:var(--text);}
|
||||
.news-symbol.archive {position:relative;width:29dp;height:26dp;margin-top:7dp;border:2dp var(--muted);border-radius:1dp;}
|
||||
.news-symbol.archive>.news-archive-lid {position:absolute;left:-5dp;right:-5dp;top:-8dp;height:8dp;border:2dp var(--muted);background-color:var(--menu-top);}
|
||||
.news-symbol.archive>.news-archive-handle {position:absolute;left:8dp;top:7dp;width:9dp;border-top:2dp var(--muted);}
|
||||
.news-symbol.restore>.news-archive-handle {left:11dp;top:4dp;width:0;height:13dp;border-left:2dp var(--muted);}
|
||||
|
||||
.news-bottom {position:absolute;left:4dp;right:4dp;bottom:0;height:80dp;display:flex;align-items:center;justify-content:space-between;gap:25dp;padding-top:12dp;}
|
||||
.news-bottom>p {color:var(--muted);font-size:24dp;line-height:1.4;}
|
||||
.news-undo {display:flex;align-items:center;justify-content:center;gap:16dp;padding:10dp 20dp;border:2dp var(--border);border-radius:10dp;background-color:var(--soft);color:var(--text);font-size:26dp;}
|
||||
.news-undo-symbol {font-size:38dp;line-height:1;}
|
||||
.news-empty {height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24dp;text-align:center;color:var(--muted);padding:70dp;}
|
||||
.news-empty h3 {color:var(--text);font-size:42dp;font-weight:normal;}
|
||||
.news-empty p {max-width:1300dp;font-size:29dp;line-height:1.6;}
|
||||
.news-empty-art {position:relative;width:90dp;height:80dp;margin-bottom:10dp;border:3dp var(--muted);border-radius:5dp;}
|
||||
.news-empty-art>span {position:absolute;left:0;right:0;top:30dp;height:0;border-top:3dp var(--muted);}
|
||||
.news-detail-layer {position:absolute;left:0;right:0;top:0;bottom:0;z-index:20;}
|
||||
.news-detail-shade {position:absolute;left:0;right:0;top:0;bottom:0;background-color:#08101980;}
|
||||
.news-detail-box {position:absolute;left:64dp;right:64dp;top:50%;max-height:1552dp;overflow-y:auto;transform:translate(0,-50%);padding:40dp 52dp;border:2dp var(--border);border-radius:22dp;background-color:#283542f5;box-shadow:0dp 24dp 70dp #0007;font-size:36dp;}
|
||||
.news-detail-box h2 {font-size:42dp;font-weight:bold;letter-spacing:-0.4dp;text-align:center;line-height:1.2;margin-bottom:35dp;}
|
||||
.news-detail {padding-top:0;}
|
||||
.news-detail-meta {display:flex;align-items:center;gap:28dp;margin-bottom:38dp;}
|
||||
.news-detail-meta>div>p {margin-top:16dp;color:var(--muted);font-size:28dp;}
|
||||
.news-detail-body {font-size:34dp;line-height:1.7;color:var(--text);}
|
||||
.news-detail small {display:block;margin-top:34dp;color:var(--muted);font-size:24dp;}
|
||||
.news-detail-actions {display:flex;align-items:stretch;justify-content:space-evenly;gap:70dp;margin-top:45dp;}
|
||||
.news-detail-actions button {display:flex;align-items:center;justify-content:center;flex:1;min-width:0;padding:12dp 24dp;border:2dp var(--border);border-radius:12dp;font-size:32dp;}
|
||||
body.silver .news-message.is-unread {background-color:#42627d05;}
|
||||
|
||||
body.silver .news-detail-box {background-color:#eaf1f7fc;}
|
||||
body.matchday .news-detail-box {background-color:#2c2c32fc;}
|
||||
.news-message>.news-art {margin-right:6dp;}
|
||||
.news-detail-meta>div>p:first-child {margin-top:0;}
|
||||
/* Gold desktop journal: a quiet source-order preview, independent of tablet filters. */
|
||||
.news-widget-heading {position:absolute;left:0;right:0;top:0;height:70dp;display:flex;align-items:center;justify-content:space-between;gap:20dp;padding:22dp 30dp 12dp;border:0dp;border-radius:0dp;background-color:transparent;color:var(--muted);font-size:25dp;line-height:1.2;text-align:left;}
|
||||
.news-widget-heading:hover {background-color:var(--hover);}
|
||||
.news-widget-arrow {display:flex;align-items:center;justify-content:center;flex-shrink:0;}
|
||||
.news-widget-feed {position:absolute;left:0;right:0;top:70dp;bottom:8dp;padding:0 28dp 16dp;display:flex;flex-direction:column;gap:10dp;overflow:hidden;}
|
||||
.news-widget-row {display:flex;align-items:flex-start;gap:14dp;padding:10dp 0 18dp;border-bottom:1dp var(--border);}
|
||||
.news-widget-copy {display:flex;flex-direction:column;gap:8dp;min-width:0;flex:1;}
|
||||
.news-widget-date {font-size:21dp;color:var(--muted);}
|
||||
.news-widget-title {font-size:25dp;line-height:1.25;font-weight:normal;max-height:62.5dp;overflow:hidden;}
|
||||
.news-widget-dot {width:10dp;height:10dp;border-radius:5dp;background-color:transparent;flex-shrink:0;margin-top:8dp;}
|
||||
.news-widget-row.unread .news-widget-dot {background-color:var(--accent);}
|
||||
|
||||
/* The Modern Gold hides the legacy footer below the tablet content. */
|
||||
.news-screen-footer {display:none;}
|
||||
@@ -0,0 +1,109 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-only */
|
||||
.statistics-native {position:absolute;left:0;top:0;width:2612dp;height:1864dp;color:#d4e0e9;}
|
||||
.statistics-panel {position:absolute;left:0;top:0;width:2612dp;height:1724dp;border:2dp #c5d9e726;border-radius:18dp;background-color:#12243140;}
|
||||
.statistics-heading {position:absolute;left:30dp;top:30dp;width:2548dp;height:46dp;line-height:46dp;margin:0;font-size:38dp;font-weight:normal;color:#dce6ee;text-align:center;}
|
||||
.statistics-winner-note {position:absolute;left:30dp;top:88dp;width:2548dp;height:32dp;margin:0;font-size:25dp;line-height:32dp;text-align:center;color:#99b1c2;}
|
||||
.statistics-winner-note .statistics-cell-text {display:block;text-align:center;}
|
||||
.statistics-list {position:absolute;left:30dp;top:114dp;width:2548dp;height:1580dp;overflow-y:auto;overflow-x:hidden;}
|
||||
.statistics-list.statistics-winners {top:154dp;height:1540dp;}
|
||||
.statistics-table {width:2548dp;}
|
||||
.statistics-row {display:flex;align-items:center;width:2548dp;font-size:31dp;color:#d4e0e9;}
|
||||
.statistics-row.striped {background-color:#e3edf605;}
|
||||
.statistics-head {font-size:27dp;color:#a8bdcc;border-bottom:2dp #c5d9e72b;}
|
||||
.statistics-cell {display:flex;align-items:center;justify-content:flex-end;min-width:0;flex-shrink:0;padding:8dp 14dp;overflow:hidden;}
|
||||
.statistics-cell.statistics-col-0 {justify-content:flex-start;}
|
||||
.statistics-cell-text {display:block;flex-shrink:0;white-space:nowrap;}
|
||||
.statistics-cell>.statistics-cell-text {width:100%;text-align:right;}
|
||||
.statistics-cell.statistics-col-0>.statistics-cell-text {text-align:left;}
|
||||
.statistics-club {width:100%;max-width:100%;min-width:0;padding:2dp 0;font-size:31dp;color:var(--text);gap:14dp;}
|
||||
.statistics-club .report-club-name {flex:1;min-width:0;max-width:100%;text-align:left;}
|
||||
.statistics-club .image-frame {flex-shrink:0;}
|
||||
.statistics-club.current {color:#b8e1d1;}
|
||||
.statistics-winners .statistics-club.current {color:var(--text);}
|
||||
.statistics-club.name-first {justify-content:flex-end;}
|
||||
.statistics-club.name-first .report-club-name {text-align:right;flex:1;}
|
||||
.statistics-section-1 .statistics-col-2 {justify-content:flex-start;}
|
||||
.statistics-player-prefix {display:block;flex-shrink:0;white-space:nowrap;}
|
||||
.statistics-player-link {display:flex;align-items:center;justify-content:flex-start;min-width:0;max-width:100%;padding:0;border:0;border-radius:0;background-color:transparent;font-size:31dp;color:var(--text);}
|
||||
.statistics-player-link .statistics-cell-text {text-align:left;}
|
||||
.statistics-player-link:hover {background-color:transparent;color:#f3f7fa;}
|
||||
.statistics-player-link:focus-visible {background-color:var(--hover);}
|
||||
.statistics-winners .statistics-cell {padding:14dp 20dp;justify-content:flex-start;}
|
||||
.statistics-winners .statistics-cell>.statistics-cell-text {text-align:left;}
|
||||
.statistics-winners .statistics-head {font-size:29dp;color:#b2c5d3;font-weight:normal;}
|
||||
.statistics-winners .statistics-col-0 {font-size:29dp;color:#b8ccd9;}
|
||||
.statistics-winners .statistics-club {gap:20dp;padding:6dp 0;}
|
||||
.statistics-trophy-heading {display:flex;flex-direction:column;align-items:center;justify-content:center;width:100%;height:170dp;min-width:0;padding:6dp;border:0;border-radius:12dp;background-color:transparent;color:var(--text);font-size:29dp;font-weight:normal;}
|
||||
.statistics-trophy-heading:hover {background-color:transparent;color:#f3f7fa;}
|
||||
.statistics-trophy-heading:focus-visible {border:3dp var(--accent);}
|
||||
.statistics-trophy-heading:disabled {opacity:1;color:var(--text);}
|
||||
.statistics-trophy-icon {display:block;width:105dp;height:105dp;flex-shrink:0;}
|
||||
.statistics-trophy-label {display:block;width:100%;height:35dp;line-height:35dp;margin-top:10dp;text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
|
||||
.statistics-world-trophy {display:flex;align-items:center;justify-content:flex-start;max-width:100%;min-width:0;height:62dp;padding:0;border:0;background-color:transparent;color:var(--text);font-size:31dp;}
|
||||
.statistics-world-trophy:disabled {opacity:1;}
|
||||
.statistics-world-trophy-art {display:block;width:58dp;height:58dp;margin-right:20dp;flex-shrink:0;}
|
||||
.statistics-finals .statistics-cell {position:relative;}
|
||||
.statistics-finals .statistics-cell.statistics-col-0 {padding-left:280dp;justify-content:flex-end;}
|
||||
.statistics-finals .statistics-cell.statistics-col-0>.statistics-cell-text {text-align:right;}
|
||||
.statistics-finals .statistics-cell.statistics-col-1 {padding-left:8dp;padding-right:8dp;justify-content:center;}
|
||||
.statistics-finals .statistics-cell.statistics-col-1>.statistics-cell-text {text-align:center;}
|
||||
.statistics-finals .statistics-cell.statistics-col-2 {padding-right:280dp;justify-content:flex-start;}
|
||||
.statistics-finals .statistics-cell.statistics-col-2>.statistics-cell-text {text-align:left;}
|
||||
.statistics-fixture-round {position:absolute;left:28dp;top:0;width:230dp;height:100%;display:flex;align-items:center;justify-content:flex-start;color:#a8bdcc;}
|
||||
.statistics-fixture-round>span {display:block;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
|
||||
body.silver .statistics-fixture-round,body.matchday .statistics-fixture-round {color:var(--muted);}
|
||||
.statistics-empty {margin:0;padding:40dp;font-size:30dp;color:var(--muted);}
|
||||
.statistics-graph {position:absolute;left:30dp;top:104dp;width:2548dp;height:860dp;padding:22dp;border:2dp #c5d9e726;border-radius:16dp;background-color:#12233070;}
|
||||
.statistics-series {position:absolute;left:30dp;top:992dp;width:2548dp;height:182dp;}
|
||||
.statistics-action {border:2dp #d4e0ec29;border-radius:12dp;background-color:transparent;decorator:linear-gradient(180deg,#c1d1e31c,#869eb312);color:#e0e6ec;font-size:30dp;font-weight:normal;}
|
||||
.statistics-action:hover {decorator:none;background-color:var(--hover);}
|
||||
.statistics-action:focus-visible {border-color:var(--accent);}
|
||||
.statistics-series-button {position:absolute;display:flex;align-items:center;justify-content:center;padding:12dp 24dp;}
|
||||
.statistics-series-dot {display:block;width:18dp;height:18dp;margin-right:18dp;border-radius:9dp;flex-shrink:0;}
|
||||
.statistics-series-label {display:block;flex-shrink:0;white-space:nowrap;}
|
||||
.statistics-absolute>.statistics-cell-text {width:100%;text-align:center;}
|
||||
.statistics-series-button[aria-pressed=false] {color:#92a6b6;}
|
||||
.statistics-series-button[aria-pressed=false] .statistics-series-dot {opacity:0.35;}
|
||||
.statistics-absolute {position:absolute;display:flex;align-items:center;justify-content:center;}
|
||||
.statistics-absolute .statistics-cell-text {display:block;text-align:center;}
|
||||
.statistics-section-8 .statistics-list {top:190dp;height:1504dp;}
|
||||
.statistics-minutes .statistics-row {font-size:28dp;}
|
||||
.statistics-minutes .statistics-cell {justify-content:center;padding:8dp;}
|
||||
.statistics-minutes .statistics-cell>.statistics-cell-text {text-align:center;}
|
||||
.statistics-minutes .statistics-cell.statistics-col-0 {justify-content:flex-start;}
|
||||
.statistics-minutes .statistics-cell.statistics-col-0>.statistics-cell-text {text-align:left;}
|
||||
.statistics-minutes .statistics-row:not(.statistics-head) .statistics-cell:not(.statistics-col-0) {border:4dp #293c48;background-color:#46606b33;color:#bdd0dc;}
|
||||
.statistics-minutes .statistics-row:not(.statistics-head) .statistics-cell.good {background-color:#4c91774d;color:#c6ebd9;}
|
||||
.statistics-minutes .statistics-row:not(.statistics-head) .statistics-cell.bad {background-color:#b65b554d;color:#f2c1b8;}
|
||||
.statistics-trophy-layer {position:absolute;left:0;top:0;width:100%;height:100%;z-index:200000;overflow:hidden;background-color:var(--panel);color:var(--text);text-align:center;}
|
||||
.statistics-trophy-backdrop {position:absolute;left:0;top:0;width:100%;height:100%;filter:saturate(0.3) brightness(0.4) blur(5px);pointer-events:none;}
|
||||
.statistics-trophy-shade {position:absolute;left:0;top:0;width:100%;height:100%;background-color:var(--panel);pointer-events:none;}
|
||||
.statistics-trophy-large {position:absolute;filter:drop-shadow(#0005 0dp 23.76dp 38.88dp);pointer-events:none;}
|
||||
#statistics-trophy-title {position:absolute;margin:0;text-align:center;font-weight:normal;letter-spacing:0.02em;color:var(--text);}
|
||||
.statistics-trophy-winner {position:absolute;display:flex;align-items:center;justify-content:center;color:var(--text);}
|
||||
.statistics-trophy-winner .image-frame {margin-right:1.2em;flex-shrink:0;}
|
||||
.statistics-trophy-winner>span {display:block;flex-shrink:0;white-space:nowrap;letter-spacing:-0.025em;}
|
||||
.statistics-trophy-season {position:absolute;margin:0;text-align:center;color:var(--muted);}
|
||||
.statistics-trophy-season .statistics-cell-text {display:block;width:100%;text-align:center;}
|
||||
.statistics-trophy-close {position:absolute;display:flex;align-items:center;justify-content:center;padding:0;border:1px var(--border);background-color:transparent;decorator:linear-gradient(180deg,#daeaf316,#b9d6eb09);color:var(--text);}
|
||||
.statistics-trophy-close:hover {decorator:none;background-color:var(--hover);}
|
||||
.statistics-trophy-close:focus-visible {border-color:var(--accent);}
|
||||
.statistics-trophy-close>span {display:block;}
|
||||
body.silver .statistics-native,body.matchday .statistics-native,body.silver .statistics-row,body.matchday .statistics-row,body.silver .statistics-heading,body.matchday .statistics-heading,body.silver .statistics-winners .statistics-col-0,body.matchday .statistics-winners .statistics-col-0 {color:var(--text);}
|
||||
body.silver .statistics-panel,body.matchday .statistics-panel,body.silver .statistics-graph,body.matchday .statistics-graph {border-color:var(--border);background-color:var(--panel);}
|
||||
body.silver .statistics-head,body.matchday .statistics-head,body.silver .statistics-winners .statistics-head,body.matchday .statistics-winners .statistics-head,body.silver .statistics-winner-note,body.matchday .statistics-winner-note {border-color:var(--border);color:var(--muted);}
|
||||
body.silver .statistics-row.striped {background-color:#42627d09;}
|
||||
body.matchday .statistics-row.striped {background-color:#f8e7e00a;}
|
||||
body.silver .statistics-club,body.matchday .statistics-club,body.silver .statistics-player-link,body.matchday .statistics-player-link {color:var(--text);}
|
||||
body.silver .statistics-club.current,body.matchday .statistics-club.current {color:var(--accent);}
|
||||
body.silver .statistics-winners .statistics-club.current,body.matchday .statistics-winners .statistics-club.current {color:var(--text);}
|
||||
body.silver .statistics-action,body.matchday .statistics-action {border-color:var(--border);color:var(--text);}
|
||||
body.silver .statistics-action {decorator:linear-gradient(180deg,#ffffffb0,#bfd0e259);}
|
||||
body.matchday .statistics-action {decorator:linear-gradient(180deg,#e8d6dc12,#a1a0aa0d);}
|
||||
body.silver .statistics-series-button[aria-pressed=false],body.matchday .statistics-series-button[aria-pressed=false] {color:var(--muted);}
|
||||
body.silver .statistics-minutes .statistics-row:not(.statistics-head) .statistics-cell:not(.statistics-col-0),body.matchday .statistics-minutes .statistics-row:not(.statistics-head) .statistics-cell:not(.statistics-col-0) {border-color:var(--border);background-color:var(--panel);color:var(--text);}
|
||||
body.silver .statistics-minutes .statistics-row:not(.statistics-head) .statistics-cell.good,body.matchday .statistics-minutes .statistics-row:not(.statistics-head) .statistics-cell.good {background-color:var(--hover);color:var(--accent);}
|
||||
body.silver .statistics-minutes .statistics-row:not(.statistics-head) .statistics-cell.bad,body.matchday .statistics-minutes .statistics-row:not(.statistics-head) .statistics-cell.bad {background-color:#b65b554d;color:var(--danger);}
|
||||
|
||||
body.silver .statistics-trophy-close {background-color:transparent;decorator:linear-gradient(180deg,#ffffffb0,#bfd0e259);}
|
||||
body.silver .statistics-trophy-close:hover {decorator:none;background-color:var(--hover);}
|
||||
@@ -109,13 +109,28 @@ wird ausdrücklich mit `OPENBMH_BUILD_MODERN_UI=ON` gebaut.
|
||||
Eintrittspreis sind umgesetzt. Der Peripherieausbau bleibt ausdrücklich
|
||||
für das angekündigte Redesign zurückgestellt; das Panorama ist nur Ansicht.
|
||||
|
||||
- [Statistiken](desktop/statistics/README.md): neun Auswertungen mit
|
||||
Möglichkeiten, Transferhistorie, sechs Analytics-Kurven, ewigen Tabellen,
|
||||
sechs WM-Ansichten, Saisonfinanzen, Rekorden, Siegerlisten und Minutenraster.
|
||||
Nationale Sieger berücksichtigen alle fünf Länder; internationale Titel und
|
||||
Hallenmasters behalten ihre BMH-Struktur. Pokale öffnen ein Vollbild mit
|
||||
Vereins-/Ländername und Saison. Alle Filter bleiben lokale Ansichtsparameter.
|
||||
- [Nachrichten](desktop/news/README.md): Tablet mit zwölf fiktiven Meldungen,
|
||||
Postfach/Archiv, Suche, Lesen, Sammellesen, Archivierung, Papierkorb und
|
||||
Rückgängig. Nachrichtenzustände gehören zum separaten UI-Demostand und
|
||||
überstehen Speichern/Laden. Das Desktop-Widget zeigt zwei oder drei aktuelle
|
||||
Überschriften und den gemeinsamen Ungelesen-Zähler.
|
||||
|
||||
**Anstoß führt keine Aktion aus**, weder per Maus noch per Tastatur. Das gilt
|
||||
auch für die direkte Aktionsschnittstelle des Demoanbieters.
|
||||
|
||||
## Noch offen
|
||||
|
||||
Die übrigen Desktop-Untermenüs werden in zusammengehörigen Paketen vom
|
||||
HTML-Mockup übertragen. Für sie erscheinen derzeit keine vereinfachten Ersatzlayouts.
|
||||
Die verbleibenden Routen und Teilbereiche werden in zusammengehörigen Paketen
|
||||
vom HTML-Mockup übertragen. Für fehlende Ports erscheinen keine vereinfachten
|
||||
Ersatzlayouts. Der Katalog zählt jetzt 34 native und drei noch nicht separat
|
||||
zugeordnete Routen; diese Zahl bestätigt keine vollständige gestalterische
|
||||
Abnahme aller früheren Teilimplementierungen.
|
||||
Der Einstellungsdialog, die vollständigen Widgetinhalte,
|
||||
Mod-Importkomfort und dauerhafte globale Voreinstellungen sind noch nicht
|
||||
vollständig. Übersetzungen, echte Engine-Anbindung und Plattform-Abnahme
|
||||
|
||||
@@ -39,6 +39,8 @@ Implementierung in der Spiel-Engine.
|
||||
| Fairplay | [Strafpunkte, Karten und Vereinsprofile](desktop/fairplay/README.md) |
|
||||
| Highscore | [Manager-Rangliste und zentrierte Kennzahlen](desktop/highscore/README.md) |
|
||||
| Stadion | [Blöcke A–H, Ausstattung und Stadiondaten ohne Peripherieausbau](desktop/stadium/README.md) |
|
||||
| Statistiken | [Neun Auswertungen, Siegerlisten, Analytics und Pokalbilder](desktop/statistics/README.md) |
|
||||
| Nachrichten | [Tablet, Postfach, Archiv, Suche, Rückgängig und Desktopvorschau](desktop/news/README.md) |
|
||||
|
||||
Jeder Bereich nennt die geprüfte Quelle, bestehende Funktionen und offene
|
||||
Entscheidungen für die Engine-Anbindung. Die Architekturgrundlage bleibt der
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
<!-- SPDX-License-Identifier: GPL-3.0-only -->
|
||||
# Nachrichten / Tablet
|
||||
|
||||
Die native RmlUI-Ansicht auf Branch `0.3` überträgt den privaten HTML-Goldstand
|
||||
vom 25.10.2026 (Referenzrevision `ddd8cab7`; native Ausgangsrevision
|
||||
`349c416`; `desktop/news-menu.js`, `news-tablet.css`, gemeinsame Menüthemen
|
||||
und Information-Widget). Die privaten Bilddateien bleiben außerhalb des
|
||||
Repositorys. Die Implementierung verwendet die gemeinsame 3840×2160-Fläche:
|
||||
Das Tablet ist 2720×2040 groß; Schrift, Kamera, Rahmen und Homebar sind native
|
||||
UI-Elemente. Midnight, Silver und Matchday verwenden dieselben Themenvariablen.
|
||||
|
||||
Das Vereinsjournal zeigt Vereinswappen, aktuellen Vereinsnamen und Spieldatum,
|
||||
die kicker-Wortmarke, Postfach und Archiv mit Gesamtzahlen, Suche, „Alle gelesen“
|
||||
und die Zahl der angezeigten ungelesenen Meldungen. Zwölf ausdrücklich fiktive
|
||||
Meldungen beginnen mit neun Postfach- und drei Archivmeldungen, davon fünf
|
||||
ungelesen. Die Anfangsdaten entstehen relativ zum aktuellen Spieldatum, auch
|
||||
über Monats-, Jahres- und Schaltjahresgrenzen hinweg. Gespeicherte Vorlagen
|
||||
lösen `{{club}}` und `{{manager}}` erst in der Projektion gegen den aktuellen
|
||||
ersten Manager auf. Ein Managerwechsel behält deshalb keine alten Namen.
|
||||
Die sechs Kategorien verwenden vorhandene GUI-Bilder für Spielbetrieb,
|
||||
Verträge, Bargeld, Training und Stadion sowie das Vereinswappen aus dem OBW.
|
||||
Feste Kategorieillustrationen gehören zur externen GUI-Ressourcensammlung.
|
||||
Für die Wortmarke stehen passende kursive und fett-kursive Schriftvarianten
|
||||
zur Verfügung; die mitgelieferten Lato-Varianten ergänzen fehlende Systemfonts.
|
||||
Rückgängig benutzt ein natives SVG-Symbol statt eines vorausgesetzten
|
||||
Unicode-Zeichens. Der Tablet-Rahmen bleibt in allen Themes dunkel wie im Gold;
|
||||
der alte zusätzliche Bildschirmfooter ist ausgeblendet.
|
||||
|
||||
Das Desktop-Widget übernimmt den Gold-Aufbau mit „Postfach · N ungelesen“
|
||||
und einem Öffnungspfeil. Es zeigt im kleinen 2×2-Format die ersten zwei, sonst
|
||||
die ersten drei Postfachmeldungen in Quellreihenfolge: Lesepunkt, Datum und
|
||||
einen auf zwei Zeilen begrenzten Titel. Aktiver Tablet-Ordner und Suchbegriff
|
||||
beeinflussen weder Vorschau noch Gesamtzahl.
|
||||
|
||||
Ein Titel öffnet die vollständige Meldung und markiert sie als gelesen.
|
||||
Zeilenaktionen archivieren, holen eine Meldung ins Postfach zurück oder
|
||||
verschieben sie in den ausgeblendeten Papierkorb. Archivieren und Zurückholen
|
||||
markieren die Meldung zusätzlich als gelesen. „Alle gelesen“ betrifft den
|
||||
gesamten aktuellen Ordner, auch bei aktiver Suche. Die letzte Sammel-, Archiv-
|
||||
oder Löschaktion kann mit einem kleinen Patch aus ID, Lesestatus und Ordner
|
||||
zurückgenommen werden. Die Aktion prüft die beobachtete Revision und jeden
|
||||
betroffenen aktuellen Datensatz. Bei einem Konflikt bleibt der gesamte Zustand
|
||||
unverändert. Ein bloßes Lesen erzeugt keinen neuen Undo-Eintrag.
|
||||
|
||||
Suche berücksichtigt Titel, Text, Kategorie und deutsches Datum ohne
|
||||
Beachtung der Großschreibung, einschließlich deutscher Umlaute. Suche und
|
||||
Ordner sind reine lokale Ansichtsparameter; sie ändern weder Revision noch
|
||||
Speicherstatus. Die Eingabe aktualisiert nur die Liste und den Zähler und
|
||||
behält Fokus und Textauswahl bei; die Liste beginnt nach jeder Suche oben.
|
||||
Ein Ordnerwechsel löscht die Suche und beginnt ebenfalls oben. Leere Ordner und leere Suchergebnisse haben
|
||||
unterschiedliche Hinweise. Pfeil links/rechts sowie Pos1/Ende wechseln die
|
||||
Register; Tab bleibt im aktiven Fenster beziehungsweise Detaildialog. Escape
|
||||
und die rechte Maustaste schließen zuerst den Detaildialog. Rückkehrfokus und
|
||||
Scrollposition bleiben bei Aktionen erhalten. Schließen verwirft Detaildialog,
|
||||
Feedback, Scrollposition und Undo; der gewählte Ordner und die Suche bleiben beim
|
||||
erneuten Öffnen derselben Welt in der laufenden UI-Sitzung erhalten. Anders als
|
||||
im HTML-Prototyp gelangen diese reinen Ansichtsparameter nicht in einen
|
||||
Spielcheckpoint; Laden einer Welt beginnt mit dem Postfach ohne Suche.
|
||||
|
||||
Die Grenze zur Quelle liegt in `DataSource`/`DemoSource`: `news` enthält nur
|
||||
`version` und maximal 100 strikt validierte Meldungen. Ältere Demo-Checkpoints
|
||||
ohne `news` werden beim Laden ergänzt; vorhandene fehlerhafte Postfächer werden
|
||||
atomar abgewiesen. Aktionen schreiben ausschließlich diesen Präsentationsblock.
|
||||
Es gibt weder `GameState`-Zugriffe noch Änderungen an Geld, Kader, Kalender,
|
||||
Weltkatalog oder Zufallsströmen. Eine spätere Session-Quelle muss echte Meldungen
|
||||
und deren Zuständigkeit liefern; Ereigniserzeugung und Gameplay bleiben offen.
|
||||
|
||||
`modern_news_ui_tests` verwendet ausschließlich synthetische Kataloge und prüft
|
||||
Migration, dynamische Identität und Daten, Suche, Zähler, Lesen, Sammellesen,
|
||||
Archiv/Zurückholen/Löschen, kleine Undo-Patches, Konflikte, strikte Validierung,
|
||||
Revisionen sowie Save/Load und atomare Ablehnung fehlerhafter Checkpoints.
|
||||
Visuelle Prüfung und native Eingabereplays erfolgen zusätzlich bei 1280×720
|
||||
und 1920×1080 in allen drei Themen; konkrete Ergebnisse stehen im zugehörigen
|
||||
QA-Protokoll. Diese Tests ersetzen keine Prüfung einer späteren Engine-Quelle.
|
||||
@@ -0,0 +1,68 @@
|
||||
<!-- SPDX-License-Identifier: GPL-3.0-only -->
|
||||
# Statistiken
|
||||
|
||||
Referenz: privater HTML-Goldstand `ddd8cab7` vom 25.10.2026,
|
||||
`desktop/report-menus.js` (`stats`, `winners`, `statsBody`) sowie
|
||||
`table-window.css`, `trophies.css` und die drei Menüthemen. Die native
|
||||
Umsetzung verwendet RmlUI im gemeinsamen Fenster mit 2720 × 2040 logischen
|
||||
Pixeln. Das öffentliche Repository enthält keine Referenzbilder oder
|
||||
proprietären Datenbestände.
|
||||
|
||||
Der Einstieg zeigt **Sieger → National → Deutschland**. Die Hauptauswahl
|
||||
enthält Möglichkeiten, Transferhistorie, Analytics, Ewige Tabelle,
|
||||
WM-Statistiken, Saisonfinanzen, Serien u. Rekorde, Sieger und
|
||||
Minuten-Statistik. Nationale Sieger zeigen zwölf Saisons und drei Wettbewerbe
|
||||
für Deutschland, Spanien, Italien, Frankreich oder England. International
|
||||
bleiben Champions League, Pokalsieger und UEFA-Cup erhalten; Hallenmasters
|
||||
zeigt Sieger und Finalist. Die Ewige Tabelle übernimmt sämtliche Vereine der
|
||||
höchsten Liga des gewählten Landes, einschließlich einer zwanzigsten Zeile.
|
||||
|
||||
Analytics zeigt sechs einzeln schaltbare Kurven mit je 24 Punkten. REL./ABS.
|
||||
wechselt zwischen beiden Darstellungen. Die WM-Auswahl bietet Sieger,
|
||||
Gruppen, Torschützen, Finalrunde, Tabelle und Historie. Die Minutenansicht
|
||||
zeigt vier Ereignisse über 18 Fünfminutenintervalle mit den Farbmarkierungen
|
||||
des Goldstands. Dropdowns verwenden die gemeinsamen nativen Berichtspicker
|
||||
mit Maus, Pfeiltasten, Pos1/Ende, Eingabe, Escape und Fokuswiederherstellung.
|
||||
Vereine und Spieler öffnen die vorhandenen Profile. Ein Pokal öffnet sein
|
||||
Vollbild-Siegerbild vor dem abgedunkelten Stadion, wenn der
|
||||
Welt- oder GUI-Katalog das passende Bild bereitstellt. Escape, Rechtsklick und Weiter
|
||||
schließen das Bild und stellen den Fokus auf dem auslösenden Pokal wieder her.
|
||||
|
||||
Alle Zahlen und historischen Ergebnisse sind ausdrücklich fiktive,
|
||||
deterministische Darstellungsdaten nach dem HTML-Muster. Vereins-, Spieler-
|
||||
und Länderreferenzen stammen aus dem tatsächlich geöffneten OBW-Katalog.
|
||||
Managername und Bezugsdatum werden aus dem aktuellen vollständigen Snapshot
|
||||
gelesen; Saisonvergleiche enden bei der letzten abgeschlossenen Saison.
|
||||
Fehlende Identitäten erzeugen keine Ersatzvereine oder Ersatzspieler.
|
||||
|
||||
Die Datenquelle bietet ausschließlich `read_statistics(request)`. Filter,
|
||||
Kurvenschalter, Scrollpositionen und Bilddialoge gehören zum lokalen
|
||||
Ansichtszustand. Es gibt weder einen Statistik-Schreibbefehl noch einen
|
||||
Zugriff auf Engine, GameState oder Zufallsströme. Snapshot, gespeicherte
|
||||
Demo-Daten, Revisionsnummer und Dirty-Flag bleiben bei diesen Lesezugriffen
|
||||
unverändert. Die vorhandenen [Engine-Statistikabfragen](../../../new_engine/statistik.md)
|
||||
für Wettbewerbe, Titelträger und Spielerwerte werden damit noch nicht aufgerufen.
|
||||
Der spätere Session-Adapter muss diese Daten in die Ansicht übersetzen;
|
||||
weitere Auswertungen benötigen entsprechende Projektionen.
|
||||
|
||||
`modern_statistics_ui_tests` prüft alle neun Bereiche, sämtliche WM-Ansichten,
|
||||
Land-/Wettbewerbsfilter, die vollständige Zwanzigerliga, stabile Identitäten,
|
||||
Kurvendaten, ungültige Anfragen, leere Welten und die unveränderliche
|
||||
Datenquellengrenze. Native Bild- und Interaktionsprüfung wird separat im
|
||||
privaten QA-Lauf dokumentiert; ein bestandener Projektionstest allein ist
|
||||
keine visuelle Abnahme.
|
||||
|
||||
Die englische Fußballnation darf die stabile OBW-Kennung `nation:x-eng`
|
||||
anstelle von `nation:en` führen. Länderwahl, ewige Tabelle und WM-Darstellung
|
||||
verwenden dieselbe Auflösung; die Titel heißen weiterhin Premier League,
|
||||
FA Cup und League Cup. Der Katalog und seine IDs werden nicht verändert.
|
||||
Ein synthetischer Regressionstest deckt diese importierte Kennung und die
|
||||
vollständige zwanzigste englische Mannschaft ab.
|
||||
|
||||
Die Demo bevorzugt vorhandene logische Weltbilder unter
|
||||
`asset:comp/<Rolle>/trophy`. Die Darstellung akzeptiert außerdem ausdrücklich
|
||||
gelieferte Asset-Schlüssel und den generischen Weltpokal als Ersatz. Die
|
||||
abgestimmten GUI-Studien dienen nur als Vorschauersatz, falls die Welt die
|
||||
entsprechende Demorolle nicht enthält. Der spätere Session-Adapter liefert die
|
||||
wettbewerbsspezifischen Referenzen der tatsächlichen Historie. Auflösung und
|
||||
Seitenverhältnis bleiben vom Datensatz bestimmt; das OBW wird nicht bearbeitet.
|
||||
@@ -173,3 +173,36 @@ Der Katalog umfasst **32 native und 5 noch offene Routen**, zusätzlich zu
|
||||
bewusst zurückgestellten Teilbereichen wie der Stadionperipherie.
|
||||
|
||||
Der Stadionabschluss besteht 29 Regressionstests. Die unabhängige native Zusatzprüfung besteht 27/27 Fälle, zusätzlich zu 26 Gold-Browser-Behaviors und dem Abgleich aller 28 GUI-Stufenreferenzen. Korrigiert wurden der innere Facility-Bildbeschnitt, die Kapazitätsbeschriftung und die Home/End-Zuordnung nach Mausfokus. Die funktionalen Nachweise enthalten getrennte ursprüngliche und korrigierte Runtimekohorten sowie echte Speicher-Neustarts.
|
||||
|
||||
|
||||
Das Informationspaket ergänzt [Statistiken](desktop/statistics/README.md) und
|
||||
[Nachrichten](desktop/news/README.md). Der HTML-Goldstand bleibt `ddd8cab7`;
|
||||
222 Browserprüfungen dokumentieren die Referenzbedienung. Die nativen
|
||||
Ansichten wurden in allen drei Themes bei 720p und 1080p mit echten
|
||||
RmlUI-Ereignissen erfasst. 1.770 Zustandsprüfungen bestehen für sämtliche
|
||||
Statistikbereiche, Länder-/Wettbewerbsfilter, Kurven, Profile und
|
||||
Nachrichtenaktionen einschließlich Abbruch, Scrollen, Fokus, Undo,
|
||||
Speichern und vollständigem Prozessneustart. Vierzehn gerichtete Prüfungen
|
||||
ergänzen die tatsächliche Desktop-Widgetauswahl und eine Ultrawide-Pokalansicht.
|
||||
|
||||
Korrigiert wurden verschwindende intrinsische Flexbeschriftungen bei Analytics,
|
||||
Spieler-/Vereinsnamen, WM-Jahreszahlen und Pokalsiegern; außerdem die fehlende
|
||||
fett-kursive Wortmarkenschrift und die stabile englische Länderkennung
|
||||
`nation:x-eng`. Der vorhandene Control-Test lädt nun auch beide neuen
|
||||
Produktionsstylesheets und prüft ihre Beschriftungen in drei Themes bei
|
||||
vier Pixeldichten. Die lokale Meilenstein-Suite besteht **31/31 Tests**.
|
||||
|
||||
Die Abschlusskontrolle umfasst alle 17 tatsächlichen Weltpokalbilder,
|
||||
deren bytegleichen Bezug zu den freigegebenen Referenzen sowie gezielte
|
||||
Nachprüfungen der Siegerbeschriftungen, des Tablet-Rahmens, des Undo-Symbols
|
||||
und des Silver-Buttons. Alle 125 gerichteten Abschlussprüfungen bestehen.
|
||||
Die unabhängigen Runtimekohorten behalten jeweils ihre tatsächlichen
|
||||
Binary-/Stylesheet-Hashes. Der aktuelle Katalog umfasst **34 native und drei
|
||||
noch nicht separat zugeordnete Routen**, zusätzlich zu offenen Teilbereichen
|
||||
wie Einstellungen, Desktopdetails und zurückgestellter Stadionperipherie.
|
||||
Die privaten Screenshots, ladbaren UI-Demostände und Eingabeskripte liegen
|
||||
unter `bmh_4k_ui/docs/qa/information-batch-2026-10-25/`.
|
||||
|
||||
Die 31 lokalen Regressionstests und die Linux-/OpenGL-Bildkontrolle sind keine
|
||||
Behauptung einer Windows-/macOS-Laufzeitabnahme. Die gemeinsame CI baut die
|
||||
opt-in Oberfläche und ihre synthetischen Tests zusätzlich auf diesen Plattformen.
|
||||
@@ -33,7 +33,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 32 native Routen und 5 offene Ports.
|
||||
der aktuelle Runner erfasst 34 native und drei noch nicht separat zugeordnete Routen.
|
||||
Spätere Meilensteine erfassen denselben Gesamtkatalog erneut.
|
||||
|
||||
Siehe [QA-Ablauf](menu-qa.md), [Typografie](typography-qa.md) und
|
||||
@@ -80,3 +80,14 @@ Streifenfarben in allen Themes. Highscore und Vereinsgeschichte verwenden
|
||||
linke Vereinsnamen direkt neben den Wappen; die Kennzahlen bleiben
|
||||
zentriert. Kleine Unterschiede der Font-/Ziffernraster bei 720p sind im
|
||||
privaten Bildnachweis dokumentiert, keine verdeckten Geometriefehler.
|
||||
|
||||
|
||||
Im Informationspaket behoben: unsichtbare Flextexte in Analytics,
|
||||
Transferhistorie, WM-Titeln und Siegerbildern, fehlende fett-kursive
|
||||
Wortmarke und ein nicht vorhandenes Unicode-Undo-Zeichen. England verwendet
|
||||
seine tatsächliche stabile Weltkennung; beide Länder-Auswahlen und alle
|
||||
englischen Titel-/Pokalnamen bleiben damit korrekt. Tablet-Rahmen und
|
||||
Silver-Button übernehmen die Referenzfarben. Pokalbilder werden bevorzugt
|
||||
aus dem Weltindex geladen; die vorhandenen GUI-Studien bleiben ein
|
||||
unabhängiger Ersatz. Im geprüften Umfang dieser beiden Menüs besteht nach
|
||||
den gezielten Schlusskontrollen kein offener P1/P2-Befund.
|
||||
@@ -1,5 +1,5 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
add_library(bmh_modern_ui_core STATIC catalog.cpp model.cpp gui_assets.cpp desktop.cpp demo_sports.cpp demo_calendar.cpp demo_reports.cpp demo_almanac.cpp demo_finance.cpp demo_environment.cpp demo_advertising.cpp demo_toto.cpp demo_lineup.cpp demo_transfer.cpp demo_career_reports.cpp demo_rankings.cpp demo_stadium.cpp)
|
||||
add_library(bmh_modern_ui_core STATIC catalog.cpp model.cpp gui_assets.cpp desktop.cpp demo_sports.cpp demo_calendar.cpp demo_reports.cpp demo_almanac.cpp demo_finance.cpp demo_environment.cpp demo_advertising.cpp demo_toto.cpp demo_lineup.cpp demo_transfer.cpp demo_career_reports.cpp demo_rankings.cpp demo_stadium.cpp demo_statistics.cpp demo_news.cpp)
|
||||
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 environment.rcss advertising.rcss toto.rcss lineup.rcss transfer.rcss career_reports.rcss rankings.rcss stadium.rcss)
|
||||
foreach(asset modern.rml theme.rcss ticket.rcss sports.rcss calendar.rcss reports.rcss report_details.rcss report_pickers.rcss indoor.rcss planning.rcss almanac.rcss finance.rcss bank.rcss contracts.rcss amount.rcss environment.rcss advertising.rcss toto.rcss lineup.rcss transfer.rcss career_reports.rcss rankings.rcss stadium.rcss statistics.rcss news.rcss)
|
||||
configure_file("${CMAKE_SOURCE_DIR}/assets/modern/${asset}" "${modern_assets}/${asset}" COPYONLY)
|
||||
endforeach()
|
||||
|
||||
@@ -34,7 +34,7 @@ foreach(icon ${modern_icons})
|
||||
get_filename_component(icon_name "${icon}" NAME)
|
||||
configure_file("${icon}" "${modern_assets}/icons/${icon_name}" COPYONLY)
|
||||
endforeach()
|
||||
foreach(weight Regular Bold)
|
||||
foreach(weight Regular Bold Italic BoldItalic)
|
||||
configure_file("${rmlui_SOURCE_DIR}/Samples/assets/LatoLatin-${weight}.ttf"
|
||||
"${modern_assets}/LatoLatin-${weight}.ttf" COPYONLY)
|
||||
endforeach()
|
||||
@@ -99,3 +99,12 @@ foreach(component environment advertising toto lineup transfer stadium)
|
||||
endif()
|
||||
add_test(NAME modern_${component}_ui_tests COMMAND modern_${component}_ui_tests)
|
||||
endforeach()
|
||||
|
||||
foreach(component statistics news)
|
||||
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()
|
||||
@@ -133,7 +133,7 @@ void App::ProcessEvent(Rml::Event &event) try {
|
||||
const auto type = event.GetType();
|
||||
// Native widgets can emit intermediate selected values while their options
|
||||
// are being constructed. Opening a squad menu must stay read-only.
|
||||
if (setting_menu_markup_ && (menu_ == "lineup" || menu_ == "transfer") &&
|
||||
if (setting_menu_markup_ && (menu_ == "lineup" || menu_ == "transfer" || menu_ == "news") &&
|
||||
(type == "change" || type == "input")) return;
|
||||
if (type == "keydown")
|
||||
keyboard_navigation_ = true;
|
||||
@@ -168,6 +168,7 @@ void App::ProcessEvent(Rml::Event &event) try {
|
||||
if (report_detail_kind_.empty() && stadium_event(event)) return;
|
||||
if (popup_.empty() && contracts_event(event)) return;
|
||||
if (popup_.empty() && (advertising_event(event) || toto_event(event))) return;
|
||||
if (popup_.empty() && (statistics_event(event) || news_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";
|
||||
@@ -460,6 +461,7 @@ void App::dispatch(const std::string &action, Rml::Element *target) {
|
||||
target ? target->GetAttribute<Rml::String>("data-id", "") : std::string();
|
||||
if (lineup_action(action, target) || transfer_action(action, target)) return;
|
||||
if (career_report_action(action, target) || rankings_action(action, target)) return;
|
||||
if (statistics_action(action, target) || dispatch_news(action, target)) return;
|
||||
if (stadium_action(action, target)) return;
|
||||
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;
|
||||
@@ -1074,7 +1076,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", "environment", "advertising", "toto", "lineup", "transfer", "achievements", "scorers", "fairplay", "highscore", "stadium"};
|
||||
"save", "load", "training", "tactics", "calendar", "league", "other", "postpone", "friendlies", "indoor", "almanac", "bank", "balance", "contracts", "environment", "advertising", "toto", "lineup", "transfer", "achievements", "scorers", "fairplay", "highscore", "stadium", "statistics", "news"};
|
||||
if (!available.contains(route)) {
|
||||
message("Diese native Ansicht wird im nächsten Menüpaket übertragen.");
|
||||
return;
|
||||
@@ -1467,6 +1469,11 @@ void App::script() {
|
||||
{"transfer_view", transfer_view_}, {"transfer_dialog", transfer_dialog_}, {"transfer_draft", transfer_draft_},
|
||||
{"career_view", career_view_}, {"rankings_view", rankings_view_},
|
||||
{"stadium_view", stadium_view_},
|
||||
{"statistics_view", statistics_view_}, {"statistics_trophy", statistics_trophy_},
|
||||
{"statistics_scrolls", statistics_scrolls_},
|
||||
{"news_view", news_view_}, {"news_dialog", news_dialog_},
|
||||
{"news_undo", news_undo_}, {"news_scroll", element("news-feed") ? element("news-feed")->GetScrollTop() : news_scroll_},
|
||||
{"focus", context_->GetFocusElement() ? context_->GetFocusElement()->GetId() : ""},
|
||||
{"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()},
|
||||
|
||||
@@ -0,0 +1,366 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "modern/ui/demo_news.hpp"
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cctype>
|
||||
#include <chrono>
|
||||
#include <iomanip>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
|
||||
namespace bmh::modern_ui {
|
||||
namespace {
|
||||
bool news_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(),
|
||||
[&](auto *key) { return v.contains(key); });
|
||||
}
|
||||
bool news_text(const Json &v, size_t cap, bool nonempty = false) {
|
||||
if (!v.is_string())
|
||||
return false;
|
||||
const auto &s = v.get_ref<const std::string &>();
|
||||
return s.size() <= cap && s.find('\0') == s.npos &&
|
||||
(!nonempty || s.find_first_not_of(" \t\r\n") != s.npos);
|
||||
}
|
||||
bool news_id(const Json &v) {
|
||||
if (!news_text(v, 64, true))
|
||||
return false;
|
||||
const auto &s = v.get_ref<const std::string &>();
|
||||
return s.find_first_not_of("abcdefghijklmnopqrstuvwxyz0123456789-") == s.npos;
|
||||
}
|
||||
bool news_folder(const Json &v, bool trash = true) {
|
||||
return v == "inbox" || v == "archive" || (trash && v == "trash");
|
||||
}
|
||||
std::optional<std::chrono::sys_days> news_date(const std::string &value) {
|
||||
using namespace std::chrono;
|
||||
if (value.size() != 10 || value[4] != '-' || value[7] != '-')
|
||||
return {};
|
||||
for (size_t i = 0; i < value.size(); ++i)
|
||||
if (i != 4 && i != 7 && (value[i] < '0' || value[i] > '9'))
|
||||
return {};
|
||||
const int y = std::stoi(value.substr(0, 4)),
|
||||
m = std::stoi(value.substr(5, 2)),
|
||||
d = std::stoi(value.substr(8, 2));
|
||||
const year_month_day date{year{y}, month{unsigned(m)}, day{unsigned(d)}};
|
||||
if (y < 1 || y > 9999 || !date.ok())
|
||||
return {};
|
||||
return sys_days{date};
|
||||
}
|
||||
std::string news_iso(std::chrono::sys_days date) {
|
||||
const std::chrono::year_month_day d{date};
|
||||
std::ostringstream out;
|
||||
out << std::setfill('0') << std::setw(4) << int(d.year()) << '-'
|
||||
<< std::setw(2) << unsigned(d.month()) << '-' << std::setw(2)
|
||||
<< unsigned(d.day());
|
||||
return out.str();
|
||||
}
|
||||
std::string news_category(const std::string &kind) {
|
||||
if (kind == "club")
|
||||
return "Verein";
|
||||
if (kind == "fixture")
|
||||
return "Spielbetrieb";
|
||||
if (kind == "transfer")
|
||||
return "Personal";
|
||||
if (kind == "finance")
|
||||
return "Finanzen";
|
||||
if (kind == "training")
|
||||
return "Training";
|
||||
if (kind == "stadium")
|
||||
return "Stadion";
|
||||
return {};
|
||||
}
|
||||
std::string news_replace(std::string text, const std::string &key,
|
||||
const std::string &value) {
|
||||
size_t at = 0;
|
||||
while ((at = text.find(key, at)) != text.npos) {
|
||||
text.replace(at, key.size(), value);
|
||||
at += value.size();
|
||||
}
|
||||
return text;
|
||||
}
|
||||
std::string news_fold(std::string text) {
|
||||
for (auto &ch : text)
|
||||
if (static_cast<unsigned char>(ch) < 128)
|
||||
ch = char(std::tolower(static_cast<unsigned char>(ch)));
|
||||
for (const auto &[a, b] :
|
||||
std::array<std::pair<const char *, const char *>, 4>{
|
||||
{{"Ä", "ä"}, {"Ö", "ö"}, {"Ü", "ü"}, {"ẞ", "ß"}}})
|
||||
text = news_replace(std::move(text), a, b);
|
||||
return text;
|
||||
}
|
||||
Json news_pair(const Json &item) {
|
||||
return {{"read", item.at("read")}, {"folder", item.at("folder")}};
|
||||
}
|
||||
bool news_valid_pair(const Json &v) {
|
||||
return news_keys(v, {"read", "folder"}) && v.at("read").is_boolean() &&
|
||||
news_folder(v.at("folder"));
|
||||
}
|
||||
} // namespace
|
||||
|
||||
std::string news_display_date(const std::string &s) {
|
||||
return news_date(s)
|
||||
? s.substr(8, 2) + "." + s.substr(5, 2) + "." + s.substr(0, 4)
|
||||
: s;
|
||||
}
|
||||
Json demo_news(const Catalog &world, const Json &state) {
|
||||
const auto value =
|
||||
state.value("date", world.manifest().value("start_date", std::string()));
|
||||
const auto today = news_date(value);
|
||||
if (!today)
|
||||
throw editor::Error("invalid_news_date");
|
||||
struct Fixture {
|
||||
const char *id;
|
||||
int ago;
|
||||
const char *kind, *title, *body;
|
||||
bool read;
|
||||
const char *folder;
|
||||
};
|
||||
const std::array<Fixture, 12> fixtures{
|
||||
{{"season", 0, "club", "Die neue Saison kann kommen",
|
||||
"Willkommen zurück, {{manager}}. {{club}} startet in die "
|
||||
"Saisonvorbereitung. Mannschaft, Verein und Fans blicken voller "
|
||||
"Vorfreude auf die neue Spielzeit.",
|
||||
false, "inbox"},
|
||||
{"cup", 0, "fixture", "Der Pokal schreibt seine eigenen Geschichten",
|
||||
"64 Mannschaften, 32 Paarungen und ein gemeinsames Ziel: das Finale. "
|
||||
"Die erste Runde eröffnet die neue Pokalsaison.",
|
||||
false, "inbox"},
|
||||
{"contract", 1, "transfer", "Vertragsgespräche stehen an",
|
||||
"Nico Brandt möchte seine Zukunft frühzeitig klären. Die sportliche "
|
||||
"Leitung plant ein Gespräch mit dem Torwart über seine Rolle im Kader.",
|
||||
false, "inbox"},
|
||||
{"tickets", 1, "finance", "8.320 Dauerkarten für die neue Saison",
|
||||
"Der Vorverkauf läuft gut: 8.320 Fans haben sich bereits ihren "
|
||||
"Stammplatz gesichert. Die fiktiven Einnahmen aus dem "
|
||||
"Dauerkartenverkauf betragen 1.450.000 €.",
|
||||
false, "inbox"},
|
||||
{"camp", 2, "training", "Die Vorbereitung nimmt Fahrt auf",
|
||||
"Ein Trainingslager bietet Raum für Kondition, Technik und Teamgeist. "
|
||||
"Das Trainerteam hat erste Ziele für die gemeinsame Vorbereitung "
|
||||
"zusammengestellt.",
|
||||
false, "inbox"},
|
||||
{"shirt", 3, "finance", "Neue Optionen für die Trikotwerbung",
|
||||
"Mehrere Unternehmen interessieren sich für eine Partnerschaft mit "
|
||||
"{{club}}. Die Angebote können in Ruhe geprüft und verglichen werden.",
|
||||
true, "inbox"},
|
||||
{"friendly", 4, "fixture", "Ein erster Härtetest für die Mannschaft",
|
||||
"Ein Testspiel steht auf dem Vorbereitungsplan. Das Trainerteam möchte "
|
||||
"möglichst vielen Spielern Einsatzzeit geben.",
|
||||
true, "inbox"},
|
||||
{"pitch", 5, "stadium", "Der Rasen ist bereit für den Saisonstart",
|
||||
"Die Platzpflege hat die Sommerpause genutzt. Der Rasen präsentiert "
|
||||
"sich zum Trainingsauftakt in gutem Zustand.",
|
||||
true, "inbox"},
|
||||
{"fans", 6, "club", "Vorfreude auf den Rängen",
|
||||
"Die Fans von {{club}} stimmen sich auf die neue Saison ein. Zum "
|
||||
"Trainingsauftakt werden zahlreiche Besucher erwartet.",
|
||||
true, "inbox"},
|
||||
{"review", 7, "fixture", "Die Saison im Rückblick",
|
||||
"Spannende Spiele, große Gefühle und viele gemeinsame Momente: Eine "
|
||||
"ereignisreiche Spielzeit liegt hinter dem Verein.",
|
||||
true, "archive"},
|
||||
{"planning", 9, "transfer", "Sommerplanung mit klarem Kurs",
|
||||
"Die sportliche Leitung hat die Aufgaben für die Sommerpause "
|
||||
"zusammengestellt. Im Mittelpunkt stehen die Kaderplanung und die "
|
||||
"Entwicklung junger Spieler.",
|
||||
true, "archive"},
|
||||
{"together", 12, "club", "Gemeinsam in die nächste Spielzeit",
|
||||
"Vorstand und Trainerteam bedanken sich bei Mannschaft, Mitarbeitern "
|
||||
"und Fans für ihre Unterstützung.",
|
||||
true, "archive"}}};
|
||||
Json items = Json::array();
|
||||
for (const auto &f : fixtures) {
|
||||
const auto day = *today - std::chrono::days{f.ago};
|
||||
if (int(std::chrono::year_month_day{day}.year()) < 1)
|
||||
throw editor::Error("invalid_news_date");
|
||||
items.push_back({{"id", f.id},
|
||||
{"date", news_iso(day)},
|
||||
{"kind", f.kind},
|
||||
{"title", f.title},
|
||||
{"body", f.body},
|
||||
{"read", f.read},
|
||||
{"folder", f.folder}});
|
||||
}
|
||||
return {{"version", 1}, {"items", items}};
|
||||
}
|
||||
bool valid_demo_news(const Json &state) {
|
||||
try {
|
||||
const auto &news = state.at("news");
|
||||
if (!news_keys(news, {"version", "items"}) ||
|
||||
!news.at("version").is_number_integer() || news.at("version") != 1 ||
|
||||
!news.at("items").is_array() || news.at("items").size() > 100)
|
||||
return false;
|
||||
std::set<std::string> ids;
|
||||
for (const auto &m : news.at("items")) {
|
||||
if (!news_keys(
|
||||
m, {"id", "date", "kind", "title", "body", "read", "folder"}) ||
|
||||
!news_id(m.at("id")) ||
|
||||
!ids.insert(m.at("id").get<std::string>()).second ||
|
||||
!m.at("date").is_string() ||
|
||||
!news_date(m.at("date").get<std::string>()) ||
|
||||
!m.at("kind").is_string() ||
|
||||
news_category(m.at("kind").get<std::string>()).empty() ||
|
||||
!news_text(m.at("title"), 160, true) ||
|
||||
!news_text(m.at("body"), 1200) || !m.at("read").is_boolean() ||
|
||||
!news_folder(m.at("folder")))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} catch (const std::exception &) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
bool migrate_demo_news(Json &state, const Catalog &world) {
|
||||
try {
|
||||
if (!state.is_object())
|
||||
return false;
|
||||
if (state.contains("news"))
|
||||
return valid_demo_news(state);
|
||||
auto next = state;
|
||||
next["news"] = demo_news(world, state);
|
||||
if (!valid_demo_news(next))
|
||||
return false;
|
||||
state = std::move(next);
|
||||
return true;
|
||||
} catch (const std::exception &) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
std::string edit_demo_news(Json &state, const Json &action, const Catalog &) {
|
||||
if (!valid_demo_news(state))
|
||||
return "invalid_news_state";
|
||||
try {
|
||||
if (!action.is_object() || !action.contains("kind") ||
|
||||
!action.at("kind").is_string())
|
||||
return "invalid_news_action";
|
||||
const auto kind = action.at("kind").get<std::string>();
|
||||
auto next = state;
|
||||
auto &items = next["news"]["items"];
|
||||
if (kind == "read-all") {
|
||||
if (!news_keys(action, {"kind", "folder"}) ||
|
||||
!news_folder(action.at("folder"), false))
|
||||
return "invalid_news_action";
|
||||
for (auto &item : items)
|
||||
if (item.at("folder") == action.at("folder"))
|
||||
item["read"] = true;
|
||||
} else if (kind == "read" || kind == "move") {
|
||||
if (!(kind == "read" ? news_keys(action, {"kind", "id"})
|
||||
: news_keys(action, {"kind", "id", "folder"})) ||
|
||||
!news_id(action.at("id")) ||
|
||||
(kind == "move" && !news_folder(action.at("folder"))))
|
||||
return "invalid_news_action";
|
||||
auto found = std::find_if(items.begin(), items.end(), [&](const auto &m) {
|
||||
return m.at("id") == action.at("id");
|
||||
});
|
||||
if (found == items.end() || found->at("folder") == "trash")
|
||||
return "news_not_found";
|
||||
if (kind == "read")
|
||||
(*found)["read"] = true;
|
||||
else {
|
||||
(*found)["folder"] = action.at("folder");
|
||||
if (action.at("folder") != "trash")
|
||||
(*found)["read"] = true;
|
||||
}
|
||||
} else if (kind == "undo") {
|
||||
if (!news_keys(action, {"kind", "patch"}) ||
|
||||
!action.at("patch").is_array() || action.at("patch").empty() ||
|
||||
action.at("patch").size() > 100)
|
||||
return "invalid_news_action";
|
||||
std::set<std::string> ids;
|
||||
for (const auto &p : action.at("patch")) {
|
||||
if (!news_keys(p, {"id", "before", "after"}) || !news_id(p.at("id")) ||
|
||||
!ids.insert(p.at("id").get<std::string>()).second ||
|
||||
!news_valid_pair(p.at("before")) ||
|
||||
!news_valid_pair(p.at("after")) || p.at("before") == p.at("after"))
|
||||
return "invalid_news_action";
|
||||
auto found =
|
||||
std::find_if(items.begin(), items.end(), [&](const auto &m) {
|
||||
return m.at("id") == p.at("id");
|
||||
});
|
||||
if (found == items.end() || news_pair(*found) != p.at("after"))
|
||||
return "news_undo_conflict";
|
||||
(*found)["read"] = p.at("before").at("read");
|
||||
(*found)["folder"] = p.at("before").at("folder");
|
||||
}
|
||||
} else
|
||||
return "invalid_news_action";
|
||||
if (!valid_demo_news(next))
|
||||
return "invalid_news_state";
|
||||
state = std::move(next);
|
||||
return {};
|
||||
} catch (const std::exception &) {
|
||||
return "invalid_news_action";
|
||||
}
|
||||
}
|
||||
int demo_news_unread(const Json &state) {
|
||||
if (!valid_demo_news(state))
|
||||
return 0;
|
||||
int count = 0;
|
||||
for (const auto &m : state.at("news").at("items"))
|
||||
if (m.at("folder") == "inbox" && !m.at("read").get<bool>())
|
||||
++count;
|
||||
return count;
|
||||
}
|
||||
Json demo_news_view(const Catalog &world, const Json &state,
|
||||
const std::string &folder, const std::string &query) {
|
||||
if (!valid_demo_news(state) || (folder != "inbox" && folder != "archive") ||
|
||||
query.size() > 120)
|
||||
return {{"ok", false}, {"error", "invalid_news_view"}};
|
||||
std::string manager, club_id, club_name;
|
||||
if (state.contains("managers") && state.at("managers").is_array() &&
|
||||
!state.at("managers").empty()) {
|
||||
const auto &m = state.at("managers")[0];
|
||||
manager = m.value("name", "");
|
||||
club_id = m.value("club", "");
|
||||
if (const auto *c = world.find("clubs", club_id))
|
||||
club_name = world.name(*c);
|
||||
}
|
||||
const auto resolve = [&](const std::string &v) {
|
||||
return news_replace(news_replace(v, "{{club}}", club_name), "{{manager}}",
|
||||
manager);
|
||||
};
|
||||
Json shown = Json::array(), counts = {{"inbox", 0}, {"archive", 0}};
|
||||
bool can_read = false;
|
||||
for (auto m : state.at("news").at("items")) {
|
||||
const auto location = m.at("folder").get<std::string>();
|
||||
if (location == "trash")
|
||||
continue;
|
||||
counts[location] = counts.at(location).get<int>() + 1;
|
||||
if (location != folder)
|
||||
continue;
|
||||
if (!m.at("read").get<bool>())
|
||||
can_read = true;
|
||||
m["title"] = resolve(m.at("title").get<std::string>());
|
||||
m["body"] = resolve(m.at("body").get<std::string>());
|
||||
m["category"] = news_category(m.at("kind").get<std::string>());
|
||||
m["display_date"] = news_display_date(m.at("date").get<std::string>());
|
||||
const auto haystack = news_fold(m.at("title").get<std::string>() + " " +
|
||||
m.at("body").get<std::string>() + " " +
|
||||
m.at("category").get<std::string>() + " " +
|
||||
m.at("display_date").get<std::string>());
|
||||
if (query.empty() || haystack.find(news_fold(query)) != haystack.npos)
|
||||
shown.push_back(std::move(m));
|
||||
}
|
||||
std::stable_sort(shown.begin(), shown.end(),
|
||||
[](const auto &a, const auto &b) {
|
||||
return a.at("date").template get<std::string>() >
|
||||
b.at("date").template get<std::string>();
|
||||
});
|
||||
int unread = 0;
|
||||
for (const auto &m : shown)
|
||||
if (!m.at("read").get<bool>())
|
||||
++unread;
|
||||
return {{"ok", true},
|
||||
{"fictional", true},
|
||||
{"items", shown},
|
||||
{"counts", counts},
|
||||
{"unread", demo_news_unread(state)},
|
||||
{"shown_unread", unread},
|
||||
{"can_read", can_read},
|
||||
{"club", club_id},
|
||||
{"club_name", club_name},
|
||||
{"manager", manager},
|
||||
{"date", news_display_date(state.value("date", std::string()))}};
|
||||
}
|
||||
} // namespace bmh::modern_ui
|
||||
@@ -0,0 +1,23 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
#include "modern/ui/catalog.hpp"
|
||||
|
||||
namespace bmh::modern_ui {
|
||||
// Presentation-only journal. Templates remain persisted, then resolve against
|
||||
// the current snapshot's first manager/club. No catalogue or engine mutation.
|
||||
Json demo_news(const Catalog &, const Json &full_state);
|
||||
bool valid_demo_news(const Json &full_state);
|
||||
bool migrate_demo_news(Json &full_state, const Catalog &);
|
||||
// read{id}, read-all{folder}, move{id,folder}, undo{patch:[{id,before,after}]}.
|
||||
// Patches contain only {read,folder}; every expected after-value must match.
|
||||
// The DataSource owns the outer revision check and atomic publication.
|
||||
std::string edit_demo_news(Json &full_state, const Json &action,
|
||||
const Catalog &);
|
||||
int demo_news_unread(const Json &full_state);
|
||||
// Read-only projection: counts, unread, shown items, can_read, club, manager,
|
||||
// date. Query and folder belong to the view and never enter a checkpoint.
|
||||
Json demo_news_view(const Catalog &, const Json &full_state,
|
||||
const std::string &folder = "inbox",
|
||||
const std::string &query = {});
|
||||
std::string news_display_date(const std::string &);
|
||||
} // namespace bmh::modern_ui
|
||||
@@ -0,0 +1,242 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "modern/ui/demo_statistics.hpp"
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
#include <cmath>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
|
||||
namespace bmh::modern_ui {
|
||||
namespace {
|
||||
const std::array<const char *,9> sections{"Möglichkeiten","Transferhistorie","Analytics","Ewige Tabelle","WM-Statistiken","Saisonfinanzen","Serien u. Rekorde","Sieger","Minuten-Statistik"};
|
||||
const std::array<const char *,6> views{"Sieger","Gruppen","Torschützen","Finalrunde","Tabelle","Historie"};
|
||||
const std::array<const char *,6> curves{"Kontostand","Mannschaftsstärke","Zuschauer","Stimmung","Einnahmen","Ausgaben"};
|
||||
const std::array<const char *,6> colors{"#e3da6a","#79b5c8","#a9d67b","#e58a66","#ded9bd","#b295cd"};
|
||||
const std::array<std::array<int,3>,12> domestic{{{{0,0,1}},{{1,3,1}},{{3,1,3}},{{2,4,1}},{{1,1,4}},{{0,2,0}},{{3,3,1}},{{1,5,1}},{{2,1,2}},{{1,1,0}},{{3,0,3}},{{4,2,1}}}};
|
||||
const Json &field(const Json &value,const char *key) {
|
||||
static const Json missing;
|
||||
if(value.is_object())if(const auto i=value.find(key);i!=value.end())return *i;
|
||||
return missing;
|
||||
}
|
||||
std::string string(const Json &value,const std::string &fallback="") {
|
||||
return value.is_string()?value.get<std::string>():fallback;
|
||||
}
|
||||
std::optional<int> season_year(const Json &value) {
|
||||
if(!value.is_string())return {};
|
||||
const auto d=value.get<std::string>();
|
||||
if(d.size()!=10||d[4]!='-'||d[7]!='-')return {};
|
||||
for(size_t i=0;i<d.size();++i)if(i!=4&&i!=7&&(d[i]<'0'||d[i]>'9'))return {};
|
||||
const int y=std::stoi(d.substr(0,4)),m=std::stoi(d.substr(5,2)),day=std::stoi(d.substr(8,2));
|
||||
if(!std::chrono::year_month_day{std::chrono::year{y},std::chrono::month{unsigned(m)},std::chrono::day{unsigned(day)}}.ok())return {};
|
||||
return y-(m<7?1:0);
|
||||
}
|
||||
std::string season(int year) {
|
||||
auto end=std::to_string((year+1)%100);
|
||||
return std::to_string(year)+"/"+(end.size()<2?"0":"")+end;
|
||||
}
|
||||
Json cell(const std::string &text) {return {{"text",text}};}
|
||||
Json numeric(int value) {return {{"text",std::to_string(value)},{"value",value}};}
|
||||
Json club_cell(const Catalog &world,const Json *club) {
|
||||
if(!club)return cell("—");
|
||||
return {{"text",world.name(*club)},{"club",club->at("id")}};
|
||||
}
|
||||
Json nation_cell(const Catalog &world,const Json *nation) {
|
||||
return nation?Json{{"text",world.name(*nation)},{"nation",nation->at("id")}}:cell("—");
|
||||
}
|
||||
Json player_cell(const Catalog &world,const Json *player) {
|
||||
return player?Json{{"text",world.name(*player)},{"player",player->at("id")},{"club",player->value("team","")}}:cell("—");
|
||||
}
|
||||
void headings(Json &out,std::initializer_list<const char *> names) {
|
||||
for(const auto *name:names)out["columns"].push_back({{"text",name}});
|
||||
}
|
||||
void row(Json &out,Json cells) {out["rows"].push_back({{"cells",std::move(cells)}});}
|
||||
const Json *country_nation(const Catalog &world, const std::string &code) {
|
||||
if (const auto *nation = world.find("nations", "nation:" + code))
|
||||
return nation;
|
||||
// England has no ISO alpha-2 country of its own. OBW retains the stable
|
||||
// imported football-nation identity instead of replacing it with the UK.
|
||||
if (code == "en")
|
||||
for (const auto *id : {"nation:x-eng", "nation:eng"})
|
||||
if (const auto *nation = world.find("nations", id)) return nation;
|
||||
return nullptr;
|
||||
}
|
||||
std::string statistics_country_code(const Json *nation) {
|
||||
if (!nation) return {};
|
||||
const auto id = nation->value("id", "");
|
||||
const auto code = id.starts_with("nation:") ? id.substr(7) : id;
|
||||
return code == "x-eng" || code == "eng" ? "en" : code;
|
||||
}
|
||||
std::vector<const Json *> countries(const Catalog &world) {
|
||||
std::vector<const Json *> result;
|
||||
std::set<std::string> seen;
|
||||
// Match Gold's fixed domestic ordering; retain actual IDs and captions.
|
||||
for(const auto *code:{"de","es","it","fr","en"})
|
||||
if(const auto *nation=country_nation(world,code);nation&&!world.leagues(nation->at("id").get<std::string>()).empty()) {
|
||||
result.push_back(nation);seen.insert(nation->at("id").get<std::string>());
|
||||
}
|
||||
for(const auto *league:world.leagues()) {
|
||||
const auto id=league->value("nation","");
|
||||
if(const auto *nation=world.find("nations",id);nation&&seen.insert(id).second)result.push_back(nation);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
std::vector<const Json *> first_league_clubs(const Catalog &world,const Json *nation) {
|
||||
if(!nation)return {};
|
||||
const auto leagues=world.leagues(nation->at("id").get<std::string>());
|
||||
if(leagues.empty())return {};
|
||||
// Catalog order is canonical; lower-tier competitions are never mixed in.
|
||||
const Json *first=leagues.front();
|
||||
for(const auto *league:leagues)if(league->value("tier",1)<first->value("tier",1))first=league;
|
||||
return world.clubs(first->at("id").get<std::string>());
|
||||
}
|
||||
const Json *at(const std::vector<const Json *> &items,size_t index) {
|
||||
return items.empty()?nullptr:items[index%items.size()];
|
||||
}
|
||||
} // namespace
|
||||
|
||||
Json demo_statistics(const Catalog &world,const Json &state,const Json &request) {
|
||||
const auto reject=[](const std::string &error){return Json{{"ok",false},{"fictional",true},{"error",error}};};
|
||||
if(!request.is_object())return reject("invalid_statistics_request");
|
||||
for(const auto &[key,value]:request.items())if(key!="section"&&key!="category"&&key!="country"&&key!="winner_country"&&key!="absolute"&&key!="curves")return reject("unknown_statistics_filter");
|
||||
const auto integer=[&](const char *key,int fallback,int maximum)->std::optional<int>{
|
||||
if(!request.contains(key))return fallback;
|
||||
const auto &v=request.at(key);
|
||||
if(!v.is_number_integer()||v<0||v>maximum)return {};
|
||||
return v.get<int>();
|
||||
};
|
||||
const auto section=integer("section",7,8),category=integer("category",0,5),country=integer("country",0,5);
|
||||
if(!section||!category||!country||(*category!=0&&*category!=1&&*category!=5))return reject("invalid_statistics_filter");
|
||||
if(request.contains("absolute")&&!request.at("absolute").is_boolean())return reject("invalid_statistics_absolute");
|
||||
Json active=Json::array({true,true,true,true,true,true});
|
||||
if(request.contains("curves")) {
|
||||
const auto &value=request.at("curves");
|
||||
if(!value.is_array()||value.size()!=6||!std::all_of(value.begin(),value.end(),[](const Json &v){return v.is_boolean();}))return reject("invalid_statistics_curves");
|
||||
active=value;
|
||||
}
|
||||
const auto nations=countries(world);
|
||||
const auto winner=request.contains("winner_country")?string(request.at("winner_country")):nations.empty()?"":nations.front()->at("id").get<std::string>();
|
||||
if(request.contains("winner_country")&&(!request.at("winner_country").is_string()||std::none_of(nations.begin(),nations.end(),[&](const Json *n){return n->at("id")==winner;})))return reject("invalid_statistics_country");
|
||||
const Json *own=nullptr;std::string manager_name="—";
|
||||
const auto &managers=field(state,"managers");
|
||||
if(managers.is_array()&&!managers.empty()) {
|
||||
own=world.find("clubs",string(field(managers.front(),"club")));
|
||||
if(own&&own->value("type","club")!="club")own=nullptr;
|
||||
const auto name=string(field(managers.front(),"name"));if(!name.empty())manager_name=name;
|
||||
}
|
||||
int year=season_year(field(state,"date")).value_or(season_year(world.manifest().value("start_date",Json())).value_or(2027));
|
||||
const bool absolute=request.value("absolute",false);
|
||||
Json out={{"ok",true},{"fictional",true},{"available",true},{"section",*section},{"category",*category},{"country",*country},{"winner_country",winner},{"absolute",absolute},{"curves",active},{"title",sections[size_t(*section)]},{"season",season(year)},{"previous_season",season(year-1)},{"year",year},{"manager",manager_name},{"club",own?own->at("id"):Json()},{"columns",Json::array()},{"rows",Json::array()},{"countries",Json::array()},{"sections",sections},{"world_views",views},{"series",Json::array()}};
|
||||
for(const auto *n:nations)out["countries"].push_back({{"id",n->at("id")},{"name",world.name(*n)}});
|
||||
out["eternal_countries"] = Json::array();
|
||||
const std::array<const char *, 5> eternal_codes{"de", "es", "en", "fr", "it"};
|
||||
for (size_t i = 0; i < eternal_codes.size(); ++i)
|
||||
if (const auto *n = country_nation(world, eternal_codes[i]))
|
||||
out["eternal_countries"].push_back({{"value", i}, {"nation", n->at("id")}, {"name", world.name(*n)}});
|
||||
out["eternal_countries"].push_back({{"value", 5}, {"name", "Absolut"}});
|
||||
auto own_league=own?world.clubs(own->value("competition","")):std::vector<const Json *>{};
|
||||
if(own&&own_league.empty())own_league.push_back(own);
|
||||
if(!own&& !nations.empty())own_league=first_league_clubs(world,nations.front());
|
||||
// Gold uses one German/own-league cohort for possibilities and records.
|
||||
const auto clubs=own_league;
|
||||
const auto players=own?world.squad(own->at("id").get<std::string>()):std::vector<const Json *>{};
|
||||
if(*section==0) {
|
||||
headings(out,{"Verein","Meisterschaft","Pokal","Europapokal"});
|
||||
for(size_t i=0;i<std::min(size_t(14),clubs.size());++i)row(out,Json::array({club_cell(world,clubs[i]),cell(std::to_string(std::max(0,72-int(i)*5))+" %"),cell(std::to_string(std::max(0,35-int(i)*2))+" %"),cell(std::to_string(std::max(0,22-int(i)))+" %")}));
|
||||
} else if(*section==1) {
|
||||
headings(out,{"Saison / Spieler","Von","Nach","Ablöse"});
|
||||
for(size_t i=0;i<std::min(size_t(10),players.size());++i) {
|
||||
auto p=player_cell(world,players[i]);p["prefix"]=std::to_string(year-int(i%3))+" · ";
|
||||
row(out,Json::array({p,club_cell(world,at(clubs,i+1)),club_cell(world,own),{{"text",number(450000+int(i)*215000)+" €"},{"value",450000+int(i)*215000}}}));
|
||||
}
|
||||
} else if(*section==2) {
|
||||
for(size_t k=0;!clubs.empty()&&k<6;++k) {
|
||||
Json points=Json::array();
|
||||
for(int i=0;i<24;++i)points.push_back({50+i*140,absolute?700-(i*7+int(k)*22):650-(200+std::sin(i*.45+double(k))*145+i*6)});
|
||||
out["series"].push_back({{"name",curves[k]},{"color",colors[k]},{"active",active[k]},{"points",points}});
|
||||
}
|
||||
} else if(*section==3) {
|
||||
headings(out,{"Verein","Sp.","S","U","N","Punkte","Tore"});
|
||||
const auto selected=*country==5?clubs:first_league_clubs(world,country_nation(world,eternal_codes[size_t(*country)]));
|
||||
for(size_t i=0;i<selected.size();++i)row(out,Json::array({club_cell(world,selected[i]),numeric(158-int(i)*3-*country*4),numeric(91-int(i)*3),numeric(31+int(i%5)),numeric(36+int(i%7)),numeric(304-int(i)*12-*country*3),cell(std::to_string(219-int(i)*5)+":"+std::to_string(146+int(i)*4))}));
|
||||
} else if(*section==4) {
|
||||
std::vector<const Json *> ns;
|
||||
for(const auto *code:{"de","es","fr","it","en","nl","pt","be"})if(const auto *n=country_nation(world,code))ns.push_back(n);
|
||||
for(const auto &n:world.rows("nations"))if(ns.size()<8&&std::find(ns.begin(),ns.end(),&n)==ns.end())ns.push_back(&n);
|
||||
if(*country==0||*country==5) {
|
||||
headings(out,{"WM / EM","Sieger","Finalist","Finale"});
|
||||
for(size_t i=0;i<std::min(size_t(6),ns.size());++i) {
|
||||
auto tournament=cell(std::string(i%2?"EM ":"WM ")+std::to_string(year-1-int(i)*2));
|
||||
tournament["trophy"]=i%2?"european-championship":"world-cup";tournament["winner"]=ns[i]->at("id");tournament["season"]=std::to_string(year-1-int(i)*2);
|
||||
row(out,Json::array({tournament,nation_cell(world,ns[i]),nation_cell(world,at(ns,i+1)),cell(std::to_string(i%3+1)+":"+std::to_string(i%2))}));
|
||||
}
|
||||
} else if(*country==1) {
|
||||
headings(out,{"Gruppe","Mannschaft","Spiele","Punkte"});
|
||||
for(size_t i=0;i<ns.size();++i)row(out,Json::array({cell(std::string("Gruppe ")+char('A'+i/4)),nation_cell(world,ns[i]),numeric(3),numeric(9-int(i%4)*2)}));
|
||||
} else if(*country==2) {
|
||||
headings(out,{"Spieler","Land","Tore"});
|
||||
for(size_t i=0;i<std::min({size_t(8),players.size(),ns.size()});++i)row(out,Json::array({player_cell(world,players[i]),nation_cell(world,ns[i]),numeric(8-int(i))}));
|
||||
} else if(*country==3) {
|
||||
headings(out,{"Heim","Ergebnis","Auswärts"});out["columns"][0]["round"]="Runde";
|
||||
const std::array<const char *,4> rounds{"Finale","Halbfinale","Halbfinale","Viertelfinale"};
|
||||
for(size_t i=0;i<std::min(size_t(4),ns.size());++i) {
|
||||
auto home=nation_cell(world,ns[i]);home["round"]=rounds[i];
|
||||
row(out,Json::array({home,cell(std::to_string(i%3+1)+":"+std::to_string(i%2)),nation_cell(world,ns[ns.size()-1-i])}));
|
||||
}
|
||||
} else {
|
||||
headings(out,{"Land","Spiele","Siege","Punkte"});
|
||||
for(size_t i=0;i<ns.size();++i)row(out,Json::array({nation_cell(world,ns[i]),numeric(20-int(i)),numeric(15-int(i)),numeric(45-int(i)*3)}));
|
||||
}
|
||||
} else if(*section==5) {
|
||||
headings(out,{"Saison","Einnahmen","Ausgaben","Saldo"});
|
||||
if(own)for(int i=0;i<10;++i)row(out,Json::array({numeric(year-i),cell(number(14500000-i*125000)+" €"),cell(number(13800000-i*85000)+" €"),cell(number(700000-i*40000)+" €")}));
|
||||
} else if(*section==6) {
|
||||
headings(out,{"Serie / Rekord","Verein","Wert"});
|
||||
const std::array<const char *,8> names{"Ungeschlagen","Siege in Folge","Heimsiege","Auswärtssiege","Tore in einer Saison","Höchster Sieg","Längste Torserie","Meiste Zuschauer"};
|
||||
for(size_t i=0;i<std::min(size_t(8),clubs.size());++i)row(out,Json::array({cell(names[i]),club_cell(world,clubs[i]),cell(i<4?std::to_string(22-int(i)):i==5?"7 : 0":i==7?"48.500":std::to_string(75-int(i)))}));
|
||||
} else if(*section==7) {
|
||||
const auto *nation=world.find("nations",winner);const auto domestic_clubs=first_league_clubs(world,nation);
|
||||
const auto code=statistics_country_code(nation);
|
||||
std::vector<std::string> titles,trophies;
|
||||
if(*category==0) {
|
||||
if(code=="es"){titles={"Primera División","Copa del Rey","Supercopa"};trophies={"es-la-liga","es-copa-del-rey",""};}
|
||||
else if(code=="en"){titles={"Premier League","FA Cup","League Cup"};trophies={"en-premier-league","en-fa-cup",""};}
|
||||
else if(code=="fr"){titles={"Ligue 1","Coupe de France","Trophée des Champions"};trophies={"fr-ligue-1","fr-coupe-de-france",""};}
|
||||
else if(code=="it"){titles={"Serie A","Coppa Italia","Supercoppa"};trophies={"it-serie-a","it-coppa-italia",""};}
|
||||
else {titles={"Meisterschaft","DFB-Pokal","Supercup"};trophies={"championship","dfb-cup","supercup"};}
|
||||
out["note"]=(nation?world.name(*nation):"—")+" · Titelträger im Saisonvergleich";
|
||||
} else if(*category==1){titles={"Champions League","Pokalsieger","UEFA-Cup"};trophies={"champions-league","cup-winners","uefa-cup"};out["note"]="Europäische Titelträger im Saisonvergleich";}
|
||||
else {titles={"Sieger","Finalist"};trophies={"indoor-masters",""};out["note"]="Hallenmasters · Sieger und Finalisten";}
|
||||
headings(out,{"Saison"});
|
||||
std::vector<const Json *> international;
|
||||
const std::array<const char *,12> preferred{"club:es-real-madrid","club:en-manchester-city","club:it-ac-mailand","club:es-fc-barcelona","club:en-liverpool","club:de-bayern-muenchen","club:fr-paris-saint-germain","club:it-inter-mailand","club:de-borussia-dortmund","club:en-chelsea","club:it-juventus-turin","club:es-fc-sevilla"};
|
||||
for(const auto *id:preferred)if(const auto *club=world.find("clubs",id))international.push_back(club);
|
||||
if(international.empty())for(size_t i=0;i<12;++i) {
|
||||
if(nations.empty())break;
|
||||
const auto candidates=first_league_clubs(world,nations[i%nations.size()]);
|
||||
if(const auto *club=at(candidates,i/nations.size()))if(std::find(international.begin(),international.end(),club)==international.end())international.push_back(club);
|
||||
}
|
||||
for(size_t col=0;col<titles.size();++col)out["columns"].push_back({{"text",titles[col]},{"trophy",trophies[col]}});
|
||||
const bool available=*category==0?!domestic_clubs.empty():*category==1?!international.empty():!clubs.empty();
|
||||
if(available)for(size_t i=0;i<12;++i) {
|
||||
Json cells=Json::array({cell(season(year-1-int(i)))});
|
||||
for(size_t col=0;col<titles.size();++col) {
|
||||
const auto *club=*category==0?at(domestic_clubs,size_t(domestic[i][col])):*category==1?at(international,i+col*4):at(clubs,i*3+(col?7:2));
|
||||
cells.push_back(club_cell(world,club));
|
||||
if(i==0)out["columns"][col+1]["winner"]=club?club->at("id"):Json();
|
||||
}
|
||||
row(out,std::move(cells));
|
||||
}
|
||||
} else {
|
||||
headings(out,{"Ereignis"});for(int i=0;i<18;++i)out["columns"].push_back(cell(std::to_string(i*5)+"."));
|
||||
const std::array<const char *,4> names{"Tore","Chancen","Gelb","Rot"};
|
||||
if(own)for(int k=0;k<4;++k) {
|
||||
Json cells=Json::array({cell(names[size_t(k)])});
|
||||
for(int i=0;i<18;++i){auto c=numeric((i*3+k)%13);c["tone"]=(i+k)%5==0?"bad":(i+k)%3==0?"good":"";cells.push_back(c);}
|
||||
row(out,std::move(cells));
|
||||
}
|
||||
}
|
||||
out["available"]=*section==2?!clubs.empty():!out["rows"].empty();
|
||||
return out;
|
||||
}
|
||||
} // namespace bmh::modern_ui
|
||||
@@ -0,0 +1,13 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
#include "modern/ui/catalog.hpp"
|
||||
|
||||
namespace bmh::modern_ui {
|
||||
// Deterministic, presentation-only statistics. Request: section 0..8 (default
|
||||
// 7), category 0/1/5, country 0..5, winner_country an actual nation ID,
|
||||
// absolute boolean and curves an array of six booleans. No state is mutated.
|
||||
// Table cells carry text and optional actual club/player/nation references.
|
||||
// Unknown fields, malformed filters and unavailable countries are rejected.
|
||||
Json demo_statistics(const Catalog &, const Json &full_state,
|
||||
const Json &request = Json::object());
|
||||
} // namespace bmh::modern_ui
|
||||
+14
-1
@@ -11,6 +11,8 @@
|
||||
#include "modern/ui/demo_lineup.hpp"
|
||||
#include "modern/ui/demo_transfer.hpp"
|
||||
#include "modern/ui/demo_stadium.hpp"
|
||||
#include "modern/ui/demo_statistics.hpp"
|
||||
#include "modern/ui/demo_news.hpp"
|
||||
#include "modern/ui/desktop.hpp"
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
@@ -99,18 +101,27 @@ DemoSource::DemoSource(std::shared_ptr<const Catalog> catalog)
|
||||
throw editor::Error("invalid_demo_squad");
|
||||
if (!migrate_demo_stadium(state_, *catalog_, club))
|
||||
throw editor::Error("invalid_demo_stadium");
|
||||
if (!migrate_demo_news(state_, *catalog_))
|
||||
throw editor::Error("invalid_demo_news");
|
||||
saved_ = state_;
|
||||
}
|
||||
Snapshot DemoSource::snapshot() const { return {revision_, catalog_, state_}; }
|
||||
Json DemoSource::read_almanac(const Json &request) const {
|
||||
return query_demo_almanac(almanac_, request, state_.at("date"));
|
||||
}
|
||||
Json DemoSource::read_statistics(const Json &request) const {
|
||||
return demo_statistics(*catalog_, state_, request);
|
||||
}
|
||||
ActionResult DemoSource::apply(const Action &action) {
|
||||
if (action.revision != revision_)
|
||||
return {false, revision_, "stale_revision"};
|
||||
auto next = state_;
|
||||
try {
|
||||
if (action.kind == "ticket") {
|
||||
if (action.kind == "news") {
|
||||
const auto error = edit_demo_news(next, action.value, *catalog_);
|
||||
if (!error.empty())
|
||||
return {false, revision_, error};
|
||||
} else if (action.kind == "ticket") {
|
||||
if (!action.value.is_number_integer() || action.value < 0 ||
|
||||
action.value > 25)
|
||||
return {false, revision_, "invalid_demo_ticket"};
|
||||
@@ -289,6 +300,8 @@ Json DemoSource::load(const fs::path &file) {
|
||||
throw editor::Error("invalid_demo_squad");
|
||||
if (!migrate_demo_stadium(data, *catalog_, club))
|
||||
throw editor::Error("invalid_demo_stadium");
|
||||
if (!migrate_demo_news(data, *catalog_))
|
||||
throw editor::Error("invalid_demo_news");
|
||||
auto next = data;
|
||||
auto desktop = next.value("desktop", Json::object());
|
||||
if (!migrate_desktop(desktop))
|
||||
|
||||
@@ -29,6 +29,9 @@ public:
|
||||
virtual Json read_almanac(const Json &) const {
|
||||
return {{"ok", false}, {"error", "almanac_unavailable"}};
|
||||
}
|
||||
virtual Json read_statistics(const Json &) const {
|
||||
return {{"ok", false}, {"error", "statistics_unavailable"}};
|
||||
}
|
||||
};
|
||||
class DemoSource final : public DataSource {
|
||||
public:
|
||||
@@ -36,6 +39,7 @@ public:
|
||||
Snapshot snapshot() const override;
|
||||
ActionResult apply(const Action &) override;
|
||||
Json read_almanac(const Json &) const override;
|
||||
Json read_statistics(const Json &) const override;
|
||||
void save(const fs::path &, const Json &desktop);
|
||||
Json load(const fs::path &);
|
||||
bool dirty() const { return state_ != saved_; }
|
||||
|
||||
@@ -0,0 +1,301 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
void App::reset_news(bool preserve_view) {
|
||||
if (!preserve_view) {
|
||||
news_view_ = {{"folder", "inbox"}, {"query", ""}, {"feedback", ""}};
|
||||
news_world_.reset();
|
||||
news_source_ = nullptr;
|
||||
} else
|
||||
news_view_["feedback"] = "";
|
||||
news_dialog_.clear();
|
||||
news_return_focus_.clear();
|
||||
news_undo_ = Json();
|
||||
news_undo_revision_ = 0;
|
||||
news_scroll_ = 0;
|
||||
news_restore_scroll_ = false;
|
||||
}
|
||||
void App::news_before_render() {
|
||||
if (menu_ != "news") {
|
||||
if (last_rendered_menu_ == "news")
|
||||
reset_news(true);
|
||||
return;
|
||||
}
|
||||
if (last_rendered_menu_ != "news")
|
||||
return;
|
||||
if (auto *feed = element("news-feed"))
|
||||
news_scroll_ = feed->GetScrollTop();
|
||||
news_restore_scroll_ = true;
|
||||
if (focus_after_render_.empty()) {
|
||||
if (auto *focused = context_->GetFocusElement();
|
||||
focused && (focused->GetId().starts_with("news-") ||
|
||||
focused->GetId() == "window-close"))
|
||||
focus_after_render_ = focused->GetId();
|
||||
}
|
||||
}
|
||||
void App::news_after_render() {
|
||||
if (menu_ != "news")
|
||||
return;
|
||||
context_->Update();
|
||||
if (news_restore_scroll_) {
|
||||
if (auto *feed = element("news-feed"))
|
||||
feed->SetScrollTop(news_scroll_);
|
||||
news_restore_scroll_ = false;
|
||||
}
|
||||
if (!news_dialog_.empty()) {
|
||||
Rml::ElementList nodes;
|
||||
doc_->QuerySelectorAll(nodes, "#news-underlay button,#news-underlay "
|
||||
"input,.news-tablet>.titlebar button");
|
||||
for (auto *node : nodes) {
|
||||
node->SetProperty("pointer-events", "none");
|
||||
node->SetProperty("tab-index", "none");
|
||||
}
|
||||
}
|
||||
}
|
||||
void App::news_update_feed() {
|
||||
const auto s = snap();
|
||||
const auto data =
|
||||
demo_news_view(*s.world, s.state, news_view_.value("folder", "inbox"),
|
||||
news_view_.value("query", ""));
|
||||
if (!data.value("ok", false))
|
||||
return;
|
||||
if (auto *feed = element("news-feed")) {
|
||||
feed->SetInnerRML(render_news_feed(data));
|
||||
context_->Update();
|
||||
feed->SetScrollTop(0);
|
||||
news_scroll_ = 0;
|
||||
}
|
||||
if (auto *feedback = element("news-feedback"))
|
||||
feedback->SetInnerRML(esc(
|
||||
std::to_string(data.at("items").size()) +
|
||||
(data.at("items").size() == 1 ? " Nachricht" : " Nachrichten") + " · " +
|
||||
std::to_string(data.at("shown_unread").get<int>()) + " ungelesen"));
|
||||
dirty_ = true;
|
||||
}
|
||||
bool App::news_commit(const Json &action, const std::string &feedback,
|
||||
bool remember) {
|
||||
const auto before = snap();
|
||||
const auto result = source_->apply({before.revision, "news", action});
|
||||
if (!result.ok) {
|
||||
news_view_["feedback"] =
|
||||
"Änderung nicht gespeichert. Bitte erneut versuchen.";
|
||||
refresh();
|
||||
return false;
|
||||
}
|
||||
const auto after = snap();
|
||||
if (remember) {
|
||||
Json patch = Json::array();
|
||||
for (const auto &old : before.state.at("news").at("items")) {
|
||||
const auto &items = after.state.at("news").at("items");
|
||||
const auto found =
|
||||
std::find_if(items.begin(), items.end(), [&](const auto &m) {
|
||||
return m.at("id") == old.at("id");
|
||||
});
|
||||
if (found != items.end() && (old.at("read") != found->at("read") ||
|
||||
old.at("folder") != found->at("folder")))
|
||||
patch.push_back(
|
||||
{{"id", old.at("id")},
|
||||
{"before",
|
||||
{{"read", old.at("read")}, {"folder", old.at("folder")}}},
|
||||
{"after",
|
||||
{{"read", found->at("read")}, {"folder", found->at("folder")}}}});
|
||||
}
|
||||
if (!patch.empty())
|
||||
news_undo_ = std::move(patch);
|
||||
}
|
||||
// An article read can leave a prior undo patch usable. Its compare-before
|
||||
// guard still rejects a changed record, while the current revision binds UI.
|
||||
news_undo_revision_ = after.revision;
|
||||
news_view_["feedback"] = feedback;
|
||||
refresh();
|
||||
return true;
|
||||
}
|
||||
bool App::dispatch_news(const std::string &action, Rml::Element *target) {
|
||||
if (!action.starts_with("news-"))
|
||||
return false;
|
||||
if (menu_ != "news" || !popup_.empty() || amount_)
|
||||
return true;
|
||||
const auto id =
|
||||
target ? target->GetAttribute<Rml::String>("data-id", "") : std::string();
|
||||
if (action == "news-detail-close") {
|
||||
news_dialog_.clear();
|
||||
focus_after_render_ =
|
||||
news_return_focus_.empty()
|
||||
? "news-tab-" + news_view_.value("folder", "inbox")
|
||||
: news_return_focus_;
|
||||
news_return_focus_.clear();
|
||||
refresh();
|
||||
return true;
|
||||
}
|
||||
if (!news_dialog_.empty() && action != "news-detail-move")
|
||||
return true;
|
||||
if (action == "news-folder") {
|
||||
if (id != "inbox" && id != "archive")
|
||||
return true;
|
||||
news_view_["folder"] = id;
|
||||
news_view_["query"] = "";
|
||||
news_view_["feedback"] = "";
|
||||
news_scroll_ = 0;
|
||||
if (auto *feed = element("news-feed"))
|
||||
feed->SetScrollTop(0);
|
||||
focus_after_render_ = "news-tab-" + id;
|
||||
refresh();
|
||||
return true;
|
||||
}
|
||||
const auto before = snap();
|
||||
if (action == "news-undo") {
|
||||
if (!news_undo_.is_array() || news_undo_.empty())
|
||||
return true;
|
||||
if (news_world_ != before.world || news_source_ != source_.get() ||
|
||||
news_undo_revision_ != before.revision) {
|
||||
news_undo_ = Json();
|
||||
news_view_["feedback"] = "Die Nachricht wurde inzwischen geändert. "
|
||||
"Rückgängig ist nicht mehr möglich.";
|
||||
focus_after_render_ = "news-tab-" + news_view_.value("folder", "inbox");
|
||||
refresh();
|
||||
return true;
|
||||
}
|
||||
if (news_commit({{"kind", "undo"}, {"patch", news_undo_}},
|
||||
"Letzte Änderung rückgängig gemacht.", false))
|
||||
news_undo_ = Json();
|
||||
focus_after_render_ = "news-tab-" + news_view_.value("folder", "inbox");
|
||||
return true;
|
||||
}
|
||||
if (action == "news-read-all") {
|
||||
const auto folder = news_view_.value("folder", "inbox");
|
||||
news_commit(
|
||||
{{"kind", "read-all"}, {"folder", folder}},
|
||||
"Alle Nachrichten " +
|
||||
std::string(folder == "inbox" ? "im Postfach" : "im Archiv") +
|
||||
" als gelesen markiert.");
|
||||
focus_after_render_ = "news-tab-" + folder;
|
||||
return true;
|
||||
}
|
||||
const auto requested = action == "news-detail-move" ? news_dialog_ : id;
|
||||
const auto &items = before.state.at("news").at("items");
|
||||
const auto found =
|
||||
std::find_if(items.begin(), items.end(), [&](const auto &m) {
|
||||
return m.at("id") == requested && m.at("folder") != "trash";
|
||||
});
|
||||
if (found == items.end())
|
||||
return true;
|
||||
if (action == "news-open") {
|
||||
if (!found->at("read").get<bool>() &&
|
||||
!news_commit({{"kind", "read"}, {"id", requested}}, "", false))
|
||||
return true;
|
||||
news_dialog_ = requested;
|
||||
news_return_focus_ = "news-read-" + requested;
|
||||
focus_after_render_ = "news-detail-close";
|
||||
refresh();
|
||||
return true;
|
||||
}
|
||||
if (action == "news-move" || action == "news-delete" ||
|
||||
action == "news-detail-move") {
|
||||
const auto folder = action == "news-delete" ? "trash"
|
||||
: found->at("folder") == "archive" ? "inbox"
|
||||
: "archive";
|
||||
const auto feedback = std::string(folder) == "trash" ? "Nachricht gelöscht."
|
||||
: std::string(folder) == "inbox"
|
||||
? "Ins Postfach verschoben."
|
||||
: "Nachricht archiviert.";
|
||||
if (news_commit({{"kind", "move"}, {"id", requested}, {"folder", folder}},
|
||||
feedback)) {
|
||||
news_dialog_.clear();
|
||||
news_return_focus_.clear();
|
||||
focus_after_render_ = "news-tab-" + news_view_.value("folder", "inbox");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool App::news_event(Rml::Event &event) {
|
||||
if (menu_ != "news" || !popup_.empty() || amount_)
|
||||
return false;
|
||||
const auto type = event.GetType();
|
||||
auto *target = event.GetTargetElement();
|
||||
const auto key = type == "keydown"
|
||||
? Rml::Input::KeyIdentifier(
|
||||
event.GetParameter<int>("key_identifier", 0))
|
||||
: Rml::Input::KI_UNKNOWN;
|
||||
if (!news_dialog_.empty()) {
|
||||
if (key == Rml::Input::KI_ESCAPE ||
|
||||
(type == "mouseup" && event.GetParameter<int>("button", 0) == 1)) {
|
||||
dispatch_news("news-detail-close", nullptr);
|
||||
event.StopImmediatePropagation();
|
||||
return true;
|
||||
}
|
||||
bool inside = false;
|
||||
for (auto *n = target; n && n != doc_; n = n->GetParentNode())
|
||||
if (n->GetId() == "news-detail-layer")
|
||||
inside = true;
|
||||
if (!inside && (type == "click" || type == "dblclick" ||
|
||||
type == "mousedown" || type == "mouseup" ||
|
||||
(type == "keydown" && key != Rml::Input::KI_TAB))) {
|
||||
event.StopImmediatePropagation();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if ((type == "input" || type == "change") && target &&
|
||||
target->GetId() == "news-search" && news_dialog_.empty()) {
|
||||
if (auto *input = dynamic_cast<Rml::ElementFormControl *>(target)) {
|
||||
auto query = input->GetValue();
|
||||
if (query.size() > 120)
|
||||
query.resize(120);
|
||||
news_view_["query"] = query;
|
||||
news_view_["feedback"] = "";
|
||||
news_update_feed();
|
||||
}
|
||||
event.StopImmediatePropagation();
|
||||
return true;
|
||||
}
|
||||
if (type == "keydown" && news_dialog_.empty() && target &&
|
||||
target->GetId().starts_with("news-tab-") &&
|
||||
(key == Rml::Input::KI_LEFT || key == Rml::Input::KI_RIGHT ||
|
||||
key == Rml::Input::KI_HOME || key == Rml::Input::KI_END)) {
|
||||
const auto next = key == Rml::Input::KI_HOME ? "inbox"
|
||||
: key == Rml::Input::KI_END ? "archive"
|
||||
: news_view_.value("folder", "inbox") == "inbox"
|
||||
? "archive"
|
||||
: "inbox";
|
||||
dispatch_news("news-folder", element("news-tab-" + std::string(next)));
|
||||
event.StopImmediatePropagation();
|
||||
return true;
|
||||
}
|
||||
if (key == Rml::Input::KI_TAB) {
|
||||
Rml::ElementList controls;
|
||||
if (auto *root = element(news_dialog_.empty() ? "news-underlay"
|
||||
: "news-detail-layer"))
|
||||
root->QuerySelectorAll(controls, "button,input");
|
||||
if (news_dialog_.empty())
|
||||
if (auto *close = element("window-close"))
|
||||
controls.insert(controls.begin(), close);
|
||||
controls.erase(
|
||||
std::remove_if(controls.begin(), controls.end(),
|
||||
[](auto *n) {
|
||||
return !n->IsVisible(true) ||
|
||||
n->HasAttribute("disabled") ||
|
||||
n->template GetAttribute<Rml::String>(
|
||||
"tabindex", "") == "-1";
|
||||
}),
|
||||
controls.end());
|
||||
if (!controls.empty()) {
|
||||
const bool backwards = event.GetParameter<int>("shift_key", 0) != 0;
|
||||
const auto it = std::find(controls.begin(), controls.end(),
|
||||
context_->GetFocusElement());
|
||||
const int old = it == controls.end() ? (backwards ? 0 : -1)
|
||||
: int(it - controls.begin());
|
||||
auto *next =
|
||||
controls[size_t((old + (backwards ? -1 : 1) + int(controls.size())) %
|
||||
int(controls.size()))];
|
||||
next->Focus(true);
|
||||
for (auto *n = next; n && n != doc_; n = n->GetParentNode())
|
||||
if (n->GetId().starts_with("news-row-")) {
|
||||
n->ScrollIntoView(
|
||||
Rml::ScrollIntoViewOptions(Rml::ScrollAlignment::Nearest));
|
||||
break;
|
||||
}
|
||||
}
|
||||
event.StopImmediatePropagation();
|
||||
dirty_ = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,236 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
std::string App::render_news_art(const Json &message, double size) {
|
||||
const auto kind = message.at("kind").get<std::string>();
|
||||
std::string art;
|
||||
if (kind == "club")
|
||||
art = crest(club(snap()), size * .69);
|
||||
else {
|
||||
const auto key =
|
||||
kind == "fixture" ? "button.league"
|
||||
: kind == "transfer" ? "button.contracts"
|
||||
: kind == "finance"
|
||||
? (gui_.contains("news.cash") ? "news.cash" : "icon.coins")
|
||||
: kind == "training" ? "button.training"
|
||||
: "button.stadium";
|
||||
art = img(key, size * .76, size * .76, false, false, 256);
|
||||
}
|
||||
return "<div class=\"news-art news-art-" + esc(kind) +
|
||||
"\" style=\"width:" + scalar(size) + "dp;height:" + scalar(size) +
|
||||
"dp;\">" + art + "</div>";
|
||||
}
|
||||
std::string App::render_news_feed(const Json &data) {
|
||||
std::string out;
|
||||
for (const auto &m : data.at("items")) {
|
||||
const auto id = m.at("id").get<std::string>(),
|
||||
name = m.at("title").get<std::string>();
|
||||
const bool unread = !m.at("read").get<bool>(),
|
||||
archived = m.at("folder") == "archive";
|
||||
out += "<div id=\"news-row-" + id + "\" class=\"news-message" +
|
||||
(unread ? " is-unread" : "") + "\">";
|
||||
if (unread)
|
||||
out += "<span class=\"news-unread-dot\"></span>";
|
||||
out += render_news_art(m) +
|
||||
"<div class=\"news-message-copy\"><div "
|
||||
"class=\"news-message-meta\"><span>" +
|
||||
esc(m.at("display_date").get<std::string>()) +
|
||||
"</span><span class=\"news-category\">" +
|
||||
esc(m.at("category").get<std::string>()) + "</span>" +
|
||||
(unread ? "<span class=\"news-new\">Neu</span>" : "") + "</div>";
|
||||
out += btn("news-open", esc(name), "news-message-title",
|
||||
"id=\"news-read-" + id + "\" data-id=\"" + id +
|
||||
"\" aria-label=\"Nachricht lesen: " + esc(name) + "\"");
|
||||
out += "<p class=\"news-excerpt\">" + esc(m.at("body").get<std::string>()) +
|
||||
"</p></div><div class=\"news-row-actions\">";
|
||||
// Native CSS line-art has no private bitmap or SVG dependency.
|
||||
out += btn(
|
||||
"news-move",
|
||||
"<span class=\"news-symbol archive" +
|
||||
std::string(archived ? " restore" : "") +
|
||||
"\"><span class=\"news-archive-lid\"></span><span "
|
||||
"class=\"news-archive-handle\"></span></span>",
|
||||
"news-icon-button",
|
||||
"id=\"news-move-" + id + "\" data-id=\"" + id + "\" aria-label=\"" +
|
||||
std::string(archived ? "Ins Postfach verschieben: "
|
||||
: "Archivieren: ") +
|
||||
esc(name) + "\" title=\"" +
|
||||
std::string(archived ? "Ins Postfach verschieben" : "Archivieren") +
|
||||
"\"");
|
||||
out += btn("news-delete", glyph("trash", 36), "news-icon-button",
|
||||
"id=\"news-delete-" + id + "\" data-id=\"" + id +
|
||||
"\" aria-label=\"Löschen: " + esc(name) +
|
||||
"\" title=\"Löschen\"");
|
||||
out += "</div></div>";
|
||||
}
|
||||
if (out.empty()) {
|
||||
const bool query = !news_view_.value("query", "").empty(),
|
||||
archive = news_view_.value("folder", "inbox") == "archive";
|
||||
out = "<div class=\"news-empty\"><div "
|
||||
"class=\"news-empty-art\"><span></span></div><h3>" +
|
||||
std::string(query ? "Keine Nachrichten gefunden"
|
||||
: archive ? "Dein Archiv ist noch leer"
|
||||
: "Alles auf dem neuesten Stand") +
|
||||
"</h3><p>" +
|
||||
std::string(
|
||||
query ? "Versuche einen anderen Suchbegriff."
|
||||
: archive ? "Archivierte Meldungen bleiben hier zum Nachlesen."
|
||||
: "Hier erscheinen neue Meldungen aus deinem Verein.") +
|
||||
"</p></div>";
|
||||
}
|
||||
return out;
|
||||
}
|
||||
std::string App::render_news_detail(const Json &message) {
|
||||
const auto name = message.at("title").get<std::string>();
|
||||
return "<div id=\"news-detail-layer\" class=\"news-detail-layer\"><div "
|
||||
"class=\"news-detail-shade\"></div><div class=\"news-detail-box\" "
|
||||
"role=\"dialog\" aria-modal=\"true\" "
|
||||
"aria-labelledby=\"news-detail-title\"><h2 id=\"news-detail-title\">" +
|
||||
esc(name) +
|
||||
"</h2><div class=\"news-detail\"><div class=\"news-detail-meta\">" +
|
||||
render_news_art(message) + "<div><p>" +
|
||||
esc(message.at("category").get<std::string>()) + "</p><p>" +
|
||||
esc(message.at("display_date").get<std::string>()) +
|
||||
"</p></div></div><p class=\"news-detail-body\">" +
|
||||
esc(message.at("body").get<std::string>()) +
|
||||
"</p><small>Fiktive Meldung für den "
|
||||
"Oberflächen-Prototyp.</small></div><div "
|
||||
"class=\"news-detail-actions\">" +
|
||||
btn("news-detail-close", "Schließen", {}, "id=\"news-detail-close\"") +
|
||||
btn("news-detail-move",
|
||||
message.at("folder") == "archive" ? "Ins Postfach" : "Archivieren",
|
||||
{}, "id=\"news-detail-move\"") +
|
||||
"</div></div></div>";
|
||||
}
|
||||
std::string App::render_news() {
|
||||
const auto s = snap();
|
||||
if (news_world_ != s.world || news_source_ != source_.get()) {
|
||||
reset_news();
|
||||
news_world_ = s.world;
|
||||
news_source_ = source_.get();
|
||||
}
|
||||
const auto data =
|
||||
demo_news_view(*s.world, s.state, news_view_.value("folder", "inbox"),
|
||||
news_view_.value("query", ""));
|
||||
if (!data.value("ok", false))
|
||||
return window("Nachrichten",
|
||||
"<p>Das Nachrichtenpostfach ist nicht verfügbar.</p>");
|
||||
const auto folder = news_view_.value("folder", "inbox");
|
||||
std::string content =
|
||||
"<div id=\"news-underlay\" class=\"news-layout\"><div "
|
||||
"class=\"news-masthead\"><div class=\"news-brand\"><span "
|
||||
"class=\"news-wordmark\">kicker</span><div><p>DEIN "
|
||||
"VEREINSJOURNAL</p><h2>Nachrichten</h2></div></div><div "
|
||||
"class=\"news-owner\"><div><strong>" +
|
||||
esc(data.at("club_name").get<std::string>()) + "</strong><p>" +
|
||||
esc(data.at("date").get<std::string>()) + "</p></div>" +
|
||||
crest(club(s), 88) + "</div></div>";
|
||||
content += "<div class=\"news-navigation\"><div class=\"news-tabs\" "
|
||||
"role=\"tablist\" aria-label=\"Postfach und Archiv\">";
|
||||
for (const auto &f : {std::string("inbox"), std::string("archive")})
|
||||
content +=
|
||||
btn("news-folder",
|
||||
"<span>" + std::string(f == "inbox" ? "Postfach" : "Archiv") +
|
||||
"</span><span class=\"news-tab-count\">" +
|
||||
std::to_string(data.at("counts").at(f).get<int>()) + "</span>",
|
||||
std::string("news-tab ") + (folder == f ? "active" : ""),
|
||||
"id=\"news-tab-" + f + "\" data-id=\"" + f +
|
||||
"\" role=\"tab\" aria-controls=\"news-feed\" aria-selected=\"" +
|
||||
(folder == f ? "true" : "false") + "\" tabindex=\"" +
|
||||
(folder == f ? "0" : "-1") + "\"");
|
||||
content += "</div><div class=\"news-search\"><span "
|
||||
"class=\"news-search-symbol\"><span></span></span><input "
|
||||
"id=\"news-search\" maxlength=\"120\" type=\"text\" "
|
||||
"aria-label=\"Nachrichten durchsuchen\" placeholder=\"Nachrichten "
|
||||
"durchsuchen\" value=\"" +
|
||||
esc(news_view_.value("query", "")) + "\"/></div>";
|
||||
content +=
|
||||
btn("news-read-all", glyph("check", 36) + "<span>Alle gelesen</span>",
|
||||
"news-read-all",
|
||||
"id=\"news-read-all\" " +
|
||||
std::string(data.at("can_read").get<bool>() ? "" : "disabled"));
|
||||
content += "</div><div id=\"news-feed\" class=\"news-feed\" "
|
||||
"role=\"tabpanel\" aria-labelledby=\"news-tab-" +
|
||||
folder + "\">" + render_news_feed(data) +
|
||||
"</div><div class=\"news-bottom\"><p id=\"news-feedback\" "
|
||||
"role=\"status\">";
|
||||
const auto feedback = news_view_.value("feedback", "");
|
||||
content += esc(
|
||||
feedback.empty()
|
||||
? std::to_string(data.at("items").size()) +
|
||||
(data.at("items").size() == 1 ? " Nachricht" : " Nachrichten") +
|
||||
" · " + std::to_string(data.at("shown_unread").get<int>()) +
|
||||
" ungelesen"
|
||||
: feedback);
|
||||
content +=
|
||||
"</p>" +
|
||||
btn("news-undo",
|
||||
glyph("undo", 32) + "<span>Rückgängig</span>",
|
||||
"news-undo",
|
||||
"id=\"news-undo\" style=\"display:" +
|
||||
std::string(news_undo_.is_array() && !news_undo_.empty()
|
||||
? "flex"
|
||||
: "none") +
|
||||
";\"") +
|
||||
"</div></div>";
|
||||
if (!news_dialog_.empty()) {
|
||||
const auto all = demo_news_view(*s.world, s.state, folder, "");
|
||||
const auto &items = all.at("items");
|
||||
const auto found =
|
||||
std::find_if(items.begin(), items.end(),
|
||||
[&](const auto &m) { return m.at("id") == news_dialog_; });
|
||||
if (found != items.end())
|
||||
content += render_news_detail(*found);
|
||||
else
|
||||
news_dialog_.clear();
|
||||
}
|
||||
return "<div class=\"window news-tablet\"><div "
|
||||
"class=\"news-camera\"></div><div class=\"titlebar\">" +
|
||||
btn("close", "<span>×</span>", "close",
|
||||
"id=\"window-close\" aria-label=\"Fenster schließen\"") +
|
||||
"<h1>Nachrichten</h1></div><div class=\"content\">" + content +
|
||||
"</div><div class=\"news-screen-footer\"><span>Fiktive "
|
||||
"Vereinsmeldungen · Modern UI "
|
||||
"Demo</span><span>OpenBMH</span></div><div "
|
||||
"class=\"news-homebar\"></div></div>";
|
||||
}
|
||||
|
||||
std::string App::render_news_widget(const Json &object) {
|
||||
const auto s = snap();
|
||||
const auto data = demo_news_view(*s.world, s.state, "inbox", "");
|
||||
if (!data.value("ok", false))
|
||||
return "";
|
||||
const bool small =
|
||||
object.value("w", 472) <= 472 && object.value("h", 472) <= 472;
|
||||
const int limit = small ? 2 : 3;
|
||||
std::string out =
|
||||
btn("open:news",
|
||||
"<span>Postfach · " + std::to_string(data.at("unread").get<int>()) +
|
||||
" ungelesen</span><span class=\"news-widget-arrow\">" +
|
||||
glyph("arrow-diagonal", 26) + "</span>",
|
||||
"news-widget-heading",
|
||||
"id=\"desktop-news-open\" data-interactive=\"true\" "
|
||||
"aria-label=\"Nachrichten öffnen\"");
|
||||
out += "<div class=\"news-widget-feed\">";
|
||||
int count = 0;
|
||||
// Gold's widget uses source order, independently of the open tablet's folder,
|
||||
// search and sorted list. Resolve templates through the same read projection.
|
||||
for (const auto &raw : s.state.at("news").at("items")) {
|
||||
if (raw.at("folder") != "inbox")
|
||||
continue;
|
||||
const auto &shown = data.at("items");
|
||||
const auto found =
|
||||
std::find_if(shown.begin(), shown.end(),
|
||||
[&](const auto &m) { return m.at("id") == raw.at("id"); });
|
||||
if (found == shown.end())
|
||||
continue;
|
||||
out += "<div class=\"news-widget-row" +
|
||||
std::string(found->at("read").get<bool>() ? "" : " unread") +
|
||||
"\"><span class=\"news-widget-dot\"></span><div "
|
||||
"class=\"news-widget-copy\"><span class=\"news-widget-date\">" +
|
||||
esc(found->at("display_date").get<std::string>()) +
|
||||
"</span><span class=\"news-widget-title\">" +
|
||||
esc(found->at("title").get<std::string>()) + "</span></div></div>";
|
||||
if (++count == limit)
|
||||
break;
|
||||
}
|
||||
return out + "</div>";
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Included within App: navigation is transient and has no save authority.
|
||||
Json news_view_ = {{"folder", "inbox"}, {"query", ""}, {"feedback", ""}};
|
||||
std::string news_dialog_, news_return_focus_;
|
||||
Json news_undo_;
|
||||
uint64_t news_undo_revision_ = 0;
|
||||
std::shared_ptr<const Catalog> news_world_;
|
||||
const DataSource *news_source_ = nullptr;
|
||||
float news_scroll_ = 0.f;
|
||||
bool news_restore_scroll_ = false;
|
||||
std::string render_news();
|
||||
std::string render_news_widget(const Json &);
|
||||
std::string render_news_feed(const Json &);
|
||||
std::string render_news_art(const Json &, double size = 150);
|
||||
std::string render_news_detail(const Json &);
|
||||
bool dispatch_news(const std::string &, Rml::Element *);
|
||||
bool news_event(Rml::Event &);
|
||||
void reset_news(bool preserve_view = false);
|
||||
void news_before_render();
|
||||
void news_after_render();
|
||||
void news_update_feed();
|
||||
bool news_commit(const Json &, const std::string &, bool remember = true);
|
||||
@@ -2,11 +2,12 @@
|
||||
namespace {
|
||||
bool report_picker_menu(const std::string &menu) {
|
||||
return menu == "tables" || menu == "strengths" || menu == "league" ||
|
||||
menu == "other" || menu == "calendar" || menu == "friendlies" || menu == "almanac" || menu == "scorers";
|
||||
menu == "other" || menu == "calendar" || menu == "friendlies" || menu == "almanac" || menu == "scorers" || menu == "statistics";
|
||||
}
|
||||
bool report_picker_kind(const std::string &kind) {
|
||||
return kind == "country" || kind == "league" || kind == "filter" ||
|
||||
kind == "competition" || kind == "year" || kind == "scorer-scope";
|
||||
kind == "competition" || kind == "year" || kind == "scorer-scope" ||
|
||||
kind == "stat-section" || kind == "stat-category" || kind == "stat-country" || kind == "winner-country";
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -15,6 +16,8 @@ App::report_picker_items(const std::string &kind) const {
|
||||
std::vector<std::pair<std::string, std::string>> items;
|
||||
if (!world_ || !report_picker_kind(kind))
|
||||
return items;
|
||||
if (menu_ == "statistics")
|
||||
return statistics_picker_items(kind);
|
||||
if (kind == "scorer-scope") {
|
||||
if (menu_ == "scorers")
|
||||
items = {{"0", "Gesamte Liga"}, {"1", "Eigener Verein"}};
|
||||
@@ -70,6 +73,8 @@ App::report_picker_items(const std::string &kind) const {
|
||||
std::string App::report_picker_value(const std::string &kind) const {
|
||||
if (!world_ || !report_picker_kind(kind))
|
||||
return {};
|
||||
if (menu_ == "statistics")
|
||||
return statistics_picker_value(kind);
|
||||
if (kind == "year") return std::to_string(almanac_year_);
|
||||
if (menu_ == "scorers") {
|
||||
if (kind == "scorer-scope") return std::to_string(rankings_view_.value("scope", 0));
|
||||
@@ -104,7 +109,11 @@ std::string App::report_picker(const std::string &kind, double left,
|
||||
const bool open = report_picker_ == kind;
|
||||
const std::string menu_label = kind == "country" ? "Land"
|
||||
: kind == "league" ? "Liga"
|
||||
: kind == "filter" ? "Spiele" : kind == "year" ? "Kalenderjahr" : kind == "scorer-scope" ? "Bereich" : "Wettbewerb";
|
||||
: kind == "filter" ? "Spiele" : kind == "year" ? "Kalenderjahr" : kind == "scorer-scope" ? "Bereich"
|
||||
: kind == "stat-section" ? "Statistik"
|
||||
: kind == "stat-category" ? "Wettbewerbsgruppe"
|
||||
: kind == "winner-country" ? "Land"
|
||||
: kind == "stat-country" ? "Statistikbereich" : "Wettbewerb";
|
||||
std::string out =
|
||||
"<div class=\"report-picker-wrapper\" data-report-picker=\"" + kind +
|
||||
"\" style=\"left:" + scalar(left) + "dp;width:" + scalar(width) + "dp;\">" +
|
||||
@@ -198,7 +207,9 @@ bool App::report_picker_action(const std::string &action, Rml::Element *target)
|
||||
? Json(std::stoi(value)) : Json(value);
|
||||
close_report_picker(false);
|
||||
// Commit even an unchanged country: the Gold resets its first league.
|
||||
if (kind == "year" && menu_ == "almanac") {
|
||||
if (menu_ == "statistics") {
|
||||
statistics_picker_select(kind, value);
|
||||
} else if (kind == "year" && menu_ == "almanac") {
|
||||
almanac_year_ = std::stoi(value);
|
||||
almanac_day_.clear();
|
||||
almanac_match_.clear();
|
||||
|
||||
@@ -154,9 +154,7 @@ std::string App::widget(const std::string &id, const Json &o) {
|
||||
"style=\"font-size:80dp;padding-top:85dp;\">" +
|
||||
std::to_string(s.state.value("fans", 67)) + " %</p>";
|
||||
if (id == "news")
|
||||
return heading("Nachrichten") +
|
||||
"<p style=\"padding:90dp 30dp;font-size:34dp;\">Willkommen zur "
|
||||
"neuen Saison.</p>";
|
||||
return render_news_widget(o);
|
||||
if (id == "results")
|
||||
return heading("Letzte sechs Spiele") +
|
||||
"<div class=\"row\" style=\"padding:100dp "
|
||||
@@ -872,6 +870,8 @@ std::string App::render_save(bool save) {
|
||||
"</div>";
|
||||
}
|
||||
std::string App::render_menu(const std::string &key) {
|
||||
if (key == "news")
|
||||
return "<div class=\"fill\" style=\"z-index:100;\">" + render_news() + "</div>";
|
||||
std::string body;
|
||||
if (key == "tables" || key == "strengths" || key == "league" || key == "other")
|
||||
body = render_reports(key);
|
||||
@@ -897,6 +897,8 @@ std::string App::render_menu(const std::string &key) {
|
||||
body = render_highscore();
|
||||
else if (key == "stadium")
|
||||
body = render_stadium();
|
||||
else if (key == "statistics")
|
||||
body = render_statistics();
|
||||
else if (key == "environment")
|
||||
body = render_environment();
|
||||
else if (key == "advertising")
|
||||
@@ -933,5 +935,6 @@ std::string App::render_menu(const std::string &key) {
|
||||
if (labels.contains(bank_view_)) heading += " · " + labels.at(bank_view_);
|
||||
}
|
||||
return "<div class=\"fill\" style=\"z-index:100;\">" +
|
||||
window(heading, body) + "</div>";
|
||||
window(heading, body) +
|
||||
(key == "statistics" ? render_statistics_trophy() : "") + "</div>";
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
bool App::statistics_picker_select(const std::string &kind,const std::string &value) {
|
||||
if(menu_!="statistics"||!source_||statistics_trophy_.contains("asset"))return false;
|
||||
const auto items=statistics_picker_items(kind);
|
||||
if(std::none_of(items.begin(),items.end(),[&](const auto &item){return item.first==value;}))return false;
|
||||
statistics_remember_scroll();
|
||||
if(kind=="winner-country")statistics_view_["winner_country"]=value;
|
||||
else {
|
||||
const auto field=kind=="stat-section"?"section":kind=="stat-category"?"category":"country";
|
||||
statistics_view_[field]=std::stoi(value);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool App::statistics_action(const std::string &action,Rml::Element *target) {
|
||||
if(!action.starts_with("statistics-"))return false;
|
||||
if(menu_!="statistics"||!source_)return true;
|
||||
if(action=="statistics-trophy-close") {
|
||||
if(statistics_trophy_.contains("asset")) {
|
||||
focus_after_render_=statistics_trophy_.value("return_focus","");statistics_trophy_=Json::object();refresh();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if(!target||statistics_trophy_.contains("asset")||!report_detail_kind_.empty()||!report_picker_.empty())return true;
|
||||
const auto data=source_->read_statistics(statistics_view_);
|
||||
if(!data.value("ok",false))return true;
|
||||
statistics_remember_scroll();
|
||||
if(action=="statistics-absolute"&&data.at("section")==2)statistics_view_["absolute"]=!data.at("absolute").get<bool>();
|
||||
else if(action=="statistics-curve"&&data.at("section")==2) {
|
||||
const int index=target->GetAttribute<int>("data-index",-1);if(index<0||index>=6)return true;
|
||||
auto curves=data.at("curves");curves[size_t(index)]=!curves[size_t(index)].get<bool>();statistics_view_["curves"]=curves;
|
||||
} else if(action=="statistics-trophy") {
|
||||
const int r=target->GetAttribute<int>("data-row",-2),c=target->GetAttribute<int>("data-column",-1);
|
||||
if(c<0||c>=int(data.at("columns").size()))return true;
|
||||
Json entry;
|
||||
if(r==-1&&data.at("section")==7)entry=data.at("columns")[size_t(c)];
|
||||
else if(r>=0&&r<int(data.at("rows").size())&&data.at("section")==4)entry=data.at("rows")[size_t(r)].at("cells")[size_t(c)];
|
||||
else return true;
|
||||
const auto trophy=entry.value("trophy","");const auto asset=statistics_trophy_asset(trophy);
|
||||
if(asset.empty()||!entry.contains("winner")||!entry.at("winner").is_string())return true;
|
||||
const auto winner=entry.at("winner").get<std::string>();
|
||||
if(!world_||(!world_->find("clubs",winner)&&!world_->find("nations",winner)))return true;
|
||||
const std::map<std::string,std::string> captions{{"championship","Deutscher Meister"},{"dfb-cup","DFB-Pokalsieger"},{"supercup","Supercup-Sieger"},{"champions-league","Champions-League-Sieger"},{"cup-winners","Europapokalsieger"},{"uefa-cup","UEFA-Cup-Sieger"},{"world-cup","Weltmeister"},{"european-championship","Europameister"},{"indoor-masters","Hallenmasters-Sieger"},{"en-premier-league","Englischer Meister"},{"en-fa-cup","FA-Cup-Sieger"},{"fr-ligue-1","Französischer Meister"},{"fr-coupe-de-france","Coupe-de-France-Sieger"},{"it-serie-a","Italienischer Meister"},{"it-coppa-italia","Coppa-Italia-Sieger"},{"es-la-liga","Spanischer Meister"},{"es-copa-del-rey","Copa-del-Rey-Sieger"}};
|
||||
const auto title=captions.contains(trophy)?captions.at(trophy):entry.value("text","Sieger");
|
||||
statistics_trophy_={{"asset",asset},{"title",title},{"winner",winner},{"season",entry.value("season",data.value("previous_season",""))},{"return_focus",target->GetId()}};
|
||||
focus_after_render_="statistics-trophy-close";
|
||||
} else return true;
|
||||
if(action!="statistics-trophy")focus_after_render_=target->GetId();
|
||||
refresh();return true;
|
||||
}
|
||||
bool App::statistics_event(Rml::Event &event) {
|
||||
if(menu_!="statistics")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;
|
||||
if(statistics_trophy_.contains("asset")) {
|
||||
if((keyboard&&key==Rml::Input::KI_ESCAPE)||(type=="mouseup"&&event.GetParameter<int>("button",0)==1)) {
|
||||
statistics_action("statistics-trophy-close",nullptr);event.StopImmediatePropagation();return true;
|
||||
}
|
||||
if(keyboard&&key==Rml::Input::KI_TAB) {
|
||||
if(auto *close=element("statistics-trophy-close"))close->Focus(true);
|
||||
event.StopImmediatePropagation();return true;
|
||||
}
|
||||
bool inside=false;
|
||||
for(auto *node=event.GetTargetElement();node&&node!=doc_;node=node->GetParentNode())if(node->GetId()=="statistics-trophy-layer")inside=true;
|
||||
if(!inside&&(type=="click"||type=="dblclick"||type=="mousedown"||type=="mouseup"||keyboard)) {event.StopImmediatePropagation();return true;}
|
||||
return false;
|
||||
}
|
||||
if(!keyboard||key!=Rml::Input::KI_TAB||!report_detail_kind_.empty()||!report_picker_.empty())return false;
|
||||
Rml::ElementList controls;
|
||||
if(auto *canvas=element("canvas"))canvas->QuerySelectorAll(controls,".window button,.window input,.window select");
|
||||
std::erase_if(controls,[](auto *node){return !node->IsVisible(true)||node->HasAttribute("disabled");});
|
||||
if(!controls.empty()) {
|
||||
const auto found=std::find(controls.begin(),controls.end(),context_->GetFocusElement());
|
||||
const int old=found==controls.end()?-1:int(found-controls.begin()),count=int(controls.size());
|
||||
const bool back=event.GetParameter<int>("shift_key",0)!=0;
|
||||
const int next=old<0?(back?count-1:0):(old+(back?-1:1)+count)%count;
|
||||
controls[size_t(next)]->Focus(true);controls[size_t(next)]->ScrollIntoView({Rml::ScrollAlignment::Nearest});dirty_=true;
|
||||
}
|
||||
event.StopImmediatePropagation();return true;
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
namespace {
|
||||
std::string statistics_text(const std::string &text) {
|
||||
return "<span class=\"statistics-cell-text\">"+esc(text)+"</span>";
|
||||
}
|
||||
std::string statistics_scroll_key(const Json &data) {
|
||||
return std::to_string(data.value("section",7))+":"+std::to_string(data.value("category",0))+":"+std::to_string(data.value("country",0))+":"+data.value("winner_country","");
|
||||
}
|
||||
} // namespace
|
||||
|
||||
std::vector<std::pair<std::string,std::string>> App::statistics_picker_items(const std::string &kind) const {
|
||||
std::vector<std::pair<std::string,std::string>> result;
|
||||
if(!source_)return result;
|
||||
const auto data=source_->read_statistics(statistics_view_);
|
||||
if(!data.value("ok",false))return result;
|
||||
const int section=data.at("section").get<int>();
|
||||
if(kind=="stat-section") {
|
||||
const auto &names=data.at("sections");
|
||||
for(size_t i=0;i<names.size();++i)result.emplace_back(std::to_string(i),names[i].get<std::string>());
|
||||
} else if(kind=="stat-category"&§ion==7)result={{"0","National"},{"1","International"},{"5","Hallenmasters"}};
|
||||
else if(kind=="winner-country"&§ion==7&&data.at("category")==0) {
|
||||
for(const auto &nation:data.at("countries"))result.emplace_back(nation.at("id").get<std::string>(),nation.at("name").get<std::string>());
|
||||
} else if(kind=="stat-country"&§ion==3) {
|
||||
for(const auto &nation:data.at("eternal_countries"))
|
||||
result.emplace_back(std::to_string(nation.at("value").get<int>()),nation.at("name").get<std::string>());
|
||||
} else if(kind=="stat-country"&§ion==4) {
|
||||
const auto &names=data.at("world_views");
|
||||
for(size_t i=0;i<names.size();++i)result.emplace_back(std::to_string(i),names[i].get<std::string>());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
std::string App::statistics_picker_value(const std::string &kind) const {
|
||||
if(!source_)return {};
|
||||
const auto data=source_->read_statistics(statistics_view_);
|
||||
if(!data.value("ok",false))return {};
|
||||
if(kind=="winner-country")return data.value("winner_country","");
|
||||
const auto key=kind=="stat-section"?"section":kind=="stat-category"?"category":"country";
|
||||
return std::to_string(data.value(key,0));
|
||||
}
|
||||
void App::statistics_remember_scroll() {
|
||||
if(auto *list=element("statistics-list")) {
|
||||
const auto key=list->GetAttribute<Rml::String>("data-scroll-key","");
|
||||
if(!key.empty())statistics_scrolls_[key]=list->GetScrollTop();
|
||||
}
|
||||
}
|
||||
void App::statistics_restore_scroll() {
|
||||
if(menu_!="statistics"||!statistics_restore_pending_)return;
|
||||
statistics_restore_pending_=false;
|
||||
if(auto *list=element("statistics-list")) {
|
||||
const auto key=list->GetAttribute<Rml::String>("data-scroll-key","");
|
||||
if(const auto i=statistics_scrolls_.find(key);i!=statistics_scrolls_.end()&&i->is_number())list->SetScrollTop(i->get<float>());
|
||||
}
|
||||
}
|
||||
std::string App::statistics_trophy_asset(const std::string &id) const {
|
||||
if(id.empty())return {};
|
||||
// Competition pictures belong to world content. The deterministic demo uses
|
||||
// semantic trophy roles; an engine adapter can supply a logical asset key.
|
||||
// Fixed prototype artwork is only a fallback, never an OBW requirement.
|
||||
if (world_) {
|
||||
if (id.starts_with("asset:")) {
|
||||
if (world_->find("assets", id)) return id;
|
||||
if (world_->find("assets", "asset:comp/generic/trophy"))
|
||||
return "asset:comp/generic/trophy";
|
||||
return {};
|
||||
}
|
||||
const auto key = "asset:comp/" + id + "/trophy";
|
||||
if (world_->find("assets", key)) return key;
|
||||
}
|
||||
if(gui_.contains("trophy."+id))return "trophy."+id;
|
||||
for(const auto &[key,item]:gui_.items().items()) {
|
||||
if(!item.is_object())continue;
|
||||
const auto file=item.value("file","");
|
||||
const auto base=fs::path(file).filename().string();
|
||||
if(base==id+"-v1.png"||base==id+"-v2.png")return key;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
std::string App::render_statistics() {
|
||||
statistics_remember_scroll();
|
||||
if(!source_||!world_)return "<p>Statistiken sind nicht verfügbar.</p>";
|
||||
const auto data=source_->read_statistics(statistics_view_);
|
||||
if(!data.value("ok",false))return "<p>Statistiken sind nicht verfügbar.</p>";
|
||||
const int section=data.at("section").get<int>(),category=data.at("category").get<int>();
|
||||
const bool winners=section==7,minutes=section==8,finals=section==4&&data.at("country")==3;
|
||||
std::string out="<section class=\"statistics-native statistics-section-"+std::to_string(section)+(finals?" statistics-finals":"")+"\"><div class=\"statistics-panel\"><h2 class=\"statistics-heading\">"+esc(data.at("title").get<std::string>())+"</h2>";
|
||||
if(winners)out+="<p class=\"statistics-winner-note\">"+statistics_text(data.value("note",""))+"</p>";
|
||||
if(section==2) {
|
||||
std::string svg="<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 3400 780' width='2496' height='812' preserveAspectRatio='none'><path d='M30 10V730H3380' fill='none' stroke='"+std::string(theme_=="silver"?"#627c8f":"#7d9aae")+"' stroke-width='3'/>";
|
||||
const auto &series=data.at("series");
|
||||
for(const auto &curve:series)if(curve.at("active")==true) {
|
||||
svg+="<polyline points='";
|
||||
for(const auto &point:curve.at("points"))svg+=scalar(point[0].get<double>())+","+scalar(point[1].get<double>())+" ";
|
||||
svg+="' fill='none' stroke='"+curve.at("color").get<std::string>()+"' stroke-width='7'/>";
|
||||
}
|
||||
svg+="</svg>";
|
||||
out+="<div class=\"statistics-graph\" role=\"img\" aria-label=\"Sechs fiktive Verlaufsreihen · "+std::string(data.at("absolute")==true?"absolut":"relativ")+"\">"+picture(renderer_.diagram("statistics-analytics",svg,5100),2496,812)+"</div><div class=\"statistics-series\">";
|
||||
for(size_t k=0;k<series.size();++k) {
|
||||
const auto &curve=series[k];const bool active=curve.at("active").get<bool>();
|
||||
out+=btn("statistics-curve","<span class=\"statistics-series-dot\" style=\"background-color:"+curve.at("color").get<std::string>()+";\"></span><span class=\"statistics-series-label\">"+esc(curve.at("name").get<std::string>())+"</span>","statistics-action statistics-series-button",
|
||||
"id=\"statistics-curve-"+std::to_string(k)+"\" data-index=\""+std::to_string(k)+"\" aria-pressed=\""+(active?"true":"false")+"\" style=\""+rect(double(k%3)*854.666666667,double(k/3)*100,836.666666667,82)+"\"");
|
||||
}
|
||||
out+="</div>";
|
||||
} else {
|
||||
const auto &columns=data.at("columns"),&rows=data.at("rows");
|
||||
const size_t count=columns.size();
|
||||
const double table_width=2548;
|
||||
const double first=minutes?table_width*.12:winners?190:table_width*.4;
|
||||
const double rest=count>1?(table_width-first)/double(count-1):0;
|
||||
const auto width=[&](size_t column){return finals?(column==1?160:1194):column?rest:first;};
|
||||
const bool trophies=winners&&std::any_of(columns.begin(),columns.end(),[](const Json &column){return !column.value("trophy","").empty();});
|
||||
const double head_height=trophies?200:winners?78:66;
|
||||
out+="<div id=\"statistics-list\" class=\"statistics-list "+std::string(winners?"statistics-winners ":"")+(minutes?"statistics-minutes ":"")+"\" data-scroll-key=\""+esc(statistics_scroll_key(data))+"\"><div class=\"statistics-table\" role=\"table\"><div class=\"statistics-row statistics-head\" role=\"row\" style=\"height:"+scalar(head_height)+"dp;\">";
|
||||
for(size_t c=0;c<count;++c) {
|
||||
const auto &column=columns[c];
|
||||
const auto trophy=column.value("trophy","");const auto asset=statistics_trophy_asset(trophy);
|
||||
std::string heading=statistics_text(column.at("text").get<std::string>());
|
||||
if(column.contains("round"))heading="<span class=\"statistics-fixture-round\"><span>"+esc(column.at("round").get<std::string>())+"</span></span>"+heading;
|
||||
if(!trophy.empty()) {
|
||||
const auto art=asset.empty()?std::string():"<span class=\"statistics-trophy-icon\">"+img(asset,105,105,asset.starts_with("asset:"),false,320)+"</span>";
|
||||
heading=btn("statistics-trophy",art+"<span class=\"statistics-trophy-label\">"+esc(column.at("text").get<std::string>())+"</span>","statistics-trophy-heading",
|
||||
"id=\"statistics-trophy-heading-"+std::to_string(c)+"\" data-column=\""+std::to_string(c)+"\" data-row=\"-1\" aria-label=\""+esc(column.at("text").get<std::string>()+" · Siegerbild ansehen")+"\" "+(asset.empty()||!column.contains("winner")?"disabled":""));
|
||||
}
|
||||
out+="<div class=\"statistics-cell statistics-col-"+std::to_string(c)+"\" role=\"columnheader\" style=\"width:"+scalar(width(c))+"dp;height:"+scalar(head_height)+"dp;\">"+heading+"</div>";
|
||||
}
|
||||
out+="</div>";
|
||||
for(size_t r=0;r<rows.size();++r) {
|
||||
const auto &cells=rows[r].at("cells");
|
||||
const bool world_trophies=section==4&&(data.at("country")==0||data.at("country")==5);
|
||||
const double row_height=minutes?200:winners?100:world_trophies?78:66;
|
||||
out+="<div class=\"statistics-row "+std::string(r%2==0?"striped":"")+"\" role=\"row\" style=\"height:"+scalar(row_height)+"dp;\">";
|
||||
for(size_t c=0;c<cells.size();++c) {
|
||||
const auto &value=cells[c];const auto title=value.value("text","");const auto token=std::to_string(r)+"-"+std::to_string(c);
|
||||
std::string content;
|
||||
if(value.contains("player")) {
|
||||
content="<span class=\"statistics-player-prefix\">"+esc(value.value("prefix",""))+"</span>"+btn("player-detail",statistics_text(title),"statistics-player-link","id=\"statistics-player-"+token+"\" data-id=\""+esc(value.at("player").get<std::string>())+"\" data-club=\""+esc(value.value("club",""))+"\" title=\""+esc(title)+"\"");
|
||||
} else if(value.contains("club")) {
|
||||
const auto id=value.at("club").get<std::string>();const auto *club=world_->find("clubs",id);const bool reverse=section==1&&c==1;
|
||||
const auto name="<span class=\"report-club-name\">"+esc(title)+"</span>",badge=crest(club,42);
|
||||
content=btn("club-detail",reverse?name+badge:badge+name,"report-club-button statistics-club "+std::string(reverse?"name-first ":"")+(data.at("club")==id?"current":""),"id=\"statistics-club-"+token+"\" data-id=\""+esc(id)+"\" title=\""+esc(title)+"\"");
|
||||
} else if(value.contains("trophy")) {
|
||||
const auto asset=statistics_trophy_asset(value.at("trophy").get<std::string>());
|
||||
content=btn("statistics-trophy",(asset.empty()?std::string():"<span class=\"statistics-world-trophy-art\">"+img(asset,58,58,asset.starts_with("asset:"),false,192)+"</span>")+statistics_text(title),"statistics-world-trophy","id=\"statistics-trophy-row-"+token+"\" data-row=\""+std::to_string(r)+"\" data-column=\""+std::to_string(c)+"\" "+(asset.empty()?"disabled":""));
|
||||
} else content=statistics_text(value.value("prefix","")+title);
|
||||
if(value.contains("round"))content="<span class=\"statistics-fixture-round\"><span>"+esc(value.at("round").get<std::string>())+"</span></span>"+content;
|
||||
out+="<div class=\"statistics-cell statistics-col-"+std::to_string(c)+" "+esc(value.value("tone",""))+"\" role=\"cell\" style=\"width:"+scalar(width(c))+"dp;height:"+scalar(row_height)+"dp;\">"+content+"</div>";
|
||||
}
|
||||
out+="</div>";
|
||||
}
|
||||
if(rows.empty())out+="<p class=\"statistics-empty\">"+statistics_text("Keine Statistikdaten für diese Auswahl vorhanden.")+"</p>";
|
||||
out+="</div></div>";
|
||||
}
|
||||
out+="</div><nav class=\"report-footer statistics-footer\" aria-label=\"Statistik und Auswahl\">";
|
||||
const bool extra=winners||section==2||section==3||section==4;
|
||||
const bool three=winners&&category==0;
|
||||
const double width=three?854.666666667:extra?1294:2612;
|
||||
out+=report_picker("stat-section",0,width);
|
||||
if(winners) {
|
||||
out+=report_picker("stat-category",three?878.666666667:1318,width);
|
||||
if(three)out+=report_picker("winner-country",1757.333333333,width);
|
||||
} else if(section==3||section==4)out+=report_picker("stat-country",1318,1294);
|
||||
else if(section==2)out+=btn("statistics-absolute",statistics_text(data.at("absolute")==true?"ABS.":"REL."),"statistics-action statistics-absolute","id=\"statistics-absolute\" aria-label=\""+std::string(data.at("absolute")==true?"Absolute":"Relative")+" Darstellung; zum Umschalten klicken\" style=\""+rect(1318,0,1294,94)+"\"");
|
||||
statistics_restore_pending_=true;
|
||||
return out+"</nav></section>"+render_report_detail();
|
||||
}
|
||||
|
||||
std::string App::render_statistics_trophy() {
|
||||
if(!statistics_trophy_.contains("asset"))return {};
|
||||
const auto asset=statistics_trophy_.at("asset").get<std::string>();
|
||||
const bool world_image = asset.starts_with("asset:");
|
||||
if(world_image ? (!world_ || !world_->find("assets", asset)) : !gui_.contains(asset))return {};
|
||||
const auto winner=statistics_trophy_.value("winner","");
|
||||
const auto *club=world_?world_->find("clubs",winner):nullptr;
|
||||
const auto name=club?world_->name(*club):world_?world_->nation_name(winner):"—";
|
||||
const auto viewport=context_->GetDimensions();
|
||||
const double w=viewport.x/scale_,h=viewport.y/scale_,stage=std::min(w,h*16/9);
|
||||
const double art=std::min({h*.61,1200/scale_,w*.82});
|
||||
const double heading=std::clamp(h*.022,17/scale_,48/scale_),team=std::clamp(h*.035,25/scale_,76/scale_);
|
||||
const double season_font=std::clamp(h*.0145,13/scale_,30/scale_),button_font=std::clamp(h*.0165,14/scale_,36/scale_);
|
||||
const double heading_h=heading*1.25,team_h=team*1.5,season_h=season_font*1.25;
|
||||
const double button_h=std::max(h*.046,button_font*1.25+h*.018+2/scale_);
|
||||
const double gap=h*.018,copy_gap=h*.012;
|
||||
const double total=art+heading_h+team_h+season_h+2*copy_gap+button_h+2*gap+h*.008;
|
||||
const double top=(h-total)/2,heading_top=top+art+gap,team_top=heading_top+heading_h+copy_gap;
|
||||
const double season_top=team_top+team_h+copy_gap,button_top=season_top+season_h+gap+h*.008;
|
||||
return "<div id=\"statistics-trophy-layer\" class=\"statistics-trophy-layer\" style=\""+rect(-canvas_left_/scale_,-canvas_top_/scale_,w,h)+"\" role=\"dialog\" aria-modal=\"true\" aria-labelledby=\"statistics-trophy-title\"><div class=\"statistics-trophy-backdrop\">"+img("background",w,h,false,true,2048)+"</div><div class=\"statistics-trophy-shade\"></div><div class=\"statistics-trophy-large\" style=\""+rect((w-art)/2,top,art,art)+"\">"+img(asset,art,art,world_image,false,1600)+"</div><h2 id=\"statistics-trophy-title\" style=\""+rect((w-stage)/2,heading_top,stage,heading_h)+"font-size:"+scalar(heading)+"dp;line-height:"+scalar(heading_h)+"dp;\">"+esc(statistics_trophy_.value("title","Sieger"))+"</h2><div class=\"statistics-trophy-winner\" style=\""+rect((w-stage)/2,team_top,stage,team_h)+"font-size:"+scalar(team)+"dp;\">"+(club?crest(club,team_h):"")+"<span>"+esc(name)+"</span></div><p class=\"statistics-trophy-season\" style=\""+rect((w-stage)/2,season_top,stage,season_h)+"font-size:"+scalar(season_font)+"dp;line-height:"+scalar(season_h)+"dp;\">"+statistics_text(statistics_trophy_.value("season",""))+"</p>"+btn("statistics-trophy-close","<span>Weiter</span>","statistics-trophy-close","id=\"statistics-trophy-close\" style=\""+rect((w-h*.17)/2,button_top,h*.17,button_h)+"font-size:"+scalar(button_font)+"dp;border-radius:"+scalar(h*.011)+"dp;\"")+"</div>";
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
Json statistics_view_ = Json::object();
|
||||
Json statistics_trophy_ = Json::object();
|
||||
Json statistics_scrolls_ = Json::object();
|
||||
bool statistics_restore_pending_ = false;
|
||||
std::string render_statistics();
|
||||
std::vector<std::pair<std::string, std::string>> statistics_picker_items(const std::string &) const;
|
||||
std::string statistics_picker_value(const std::string &) const;
|
||||
bool statistics_picker_select(const std::string &, const std::string &);
|
||||
bool statistics_action(const std::string &, Rml::Element *);
|
||||
bool statistics_event(Rml::Event &);
|
||||
void statistics_remember_scroll();
|
||||
void statistics_restore_scroll();
|
||||
std::string statistics_trophy_asset(const std::string &) const;
|
||||
std::string render_statistics_trophy();
|
||||
+49
-2
@@ -17,6 +17,8 @@
|
||||
#include "modern/ui/demo_career_reports.hpp"
|
||||
#include "modern/ui/demo_rankings.hpp"
|
||||
#include "modern/ui/demo_stadium.hpp"
|
||||
#include "modern/ui/demo_statistics.hpp"
|
||||
#include "modern/ui/demo_news.hpp"
|
||||
#include "modern/ui/desktop.hpp"
|
||||
#include "modern/ui/gui_assets.hpp"
|
||||
#include "modern/ui/model.hpp"
|
||||
@@ -374,6 +376,8 @@ class App final : public Rml::EventListener {
|
||||
uint64_t stadium_revision_ = 0;
|
||||
std::shared_ptr<const Catalog> stadium_world_;
|
||||
const DataSource *stadium_source_ = nullptr;
|
||||
#include "modern/ui/statistics_state.inc"
|
||||
#include "modern/ui/news_state.inc"
|
||||
float device_ratio_ = 1.f;
|
||||
Json desktop_ = Json::object(), saved_desktop_ = Json::object(),
|
||||
options_ = Json::object();
|
||||
@@ -593,6 +597,9 @@ class App final : public Rml::EventListener {
|
||||
transfer_dialog_.clear(); transfer_picker_.clear(); transfer_notice_.clear(); transfer_return_focus_.clear();
|
||||
transfer_poach_league_.clear(); transfer_poach_club_.clear(); transfer_world_.reset(); transfer_revision_ = 0;
|
||||
career_view_ = Json::object(); rankings_view_ = Json::object();
|
||||
statistics_view_ = Json::object(); statistics_trophy_ = Json::object();
|
||||
statistics_scrolls_ = Json::object();
|
||||
reset_news();
|
||||
stadium_view_ = Json::object(); stadium_revision_ = 0;
|
||||
stadium_world_.reset(); stadium_source_ = nullptr;
|
||||
advertising_selected_ = -1; advertising_offer_ = 0; advertising_revision_ = 0; advertising_world_.reset();
|
||||
@@ -836,13 +843,17 @@ class App final : public Rml::EventListener {
|
||||
ticket_->resize(device_ratio_);
|
||||
scale_chalk_shadow();
|
||||
dirty_ = true;
|
||||
if (statistics_trophy_.contains("asset"))
|
||||
needs_render_ = true;
|
||||
}
|
||||
void render() {
|
||||
news_before_render();
|
||||
fixture_half_width_ = -1.f;
|
||||
almanac_list_width_ = -1.f;
|
||||
// A window-close save prompt can leave a menu while its local dialog is
|
||||
// open. Never keep that menu's modal/input gate in the destination view.
|
||||
if (menu_ != last_rendered_menu_) {
|
||||
statistics_trophy_ = Json::object();
|
||||
planning_dialog_.clear();
|
||||
career_view_["dialog"] = ""; career_view_["return_focus"] = "";
|
||||
stadium_view_["dialog"] = ""; stadium_view_["draft"] = Json();
|
||||
@@ -901,7 +912,9 @@ class App final : public Rml::EventListener {
|
||||
markup += render_menu(menu_);
|
||||
setting_menu_markup_ = true;
|
||||
element("canvas")->SetInnerRML(markup);
|
||||
element("canvas")->SetProperty("overflow", statistics_trophy_.contains("asset") ? "visible" : "hidden");
|
||||
setting_menu_markup_ = false;
|
||||
news_after_render();
|
||||
if (!report_detail_kind_.empty() || !planning_dialog_.empty() || !contracts_dialog_.empty() || !toto_dialog_.empty() || !transfer_dialog_.empty() || !career_view_.value("dialog", "").empty() || !stadium_view_.value("dialog", "").empty()) {
|
||||
Rml::ElementList behind;
|
||||
doc_->QuerySelectorAll(behind,
|
||||
@@ -1058,6 +1071,7 @@ class App final : public Rml::EventListener {
|
||||
}
|
||||
if (menu_ == "transfer") transfer_restore_scroll();
|
||||
if (menu_ == "scorers" || menu_ == "fairplay") rankings_restore_scroll();
|
||||
if (menu_ == "statistics") statistics_restore_scroll();
|
||||
if (!report_option_to_scroll_.empty()) {
|
||||
if (auto *node = element(report_option_to_scroll_))
|
||||
node->ScrollIntoView(Rml::ScrollIntoViewOptions(Rml::ScrollAlignment::Nearest));
|
||||
@@ -1079,7 +1093,7 @@ class App final : public Rml::EventListener {
|
||||
editor::images::encode_png({w, h, std::move(bytes)}));
|
||||
}
|
||||
void load_fonts() {
|
||||
bool regular = false, bold = false;
|
||||
bool regular = false, bold = false, italic = false, bold_italic = false;
|
||||
#ifdef _WIN32
|
||||
const char *base = std::getenv("WINDIR");
|
||||
if (base) {
|
||||
@@ -1090,6 +1104,12 @@ class App final : public Rml::EventListener {
|
||||
bold = Rml::LoadFontFace(rml::asset_path(folder / "segoeuib.ttf"),
|
||||
"Modern", Rml::Style::FontStyle::Normal,
|
||||
Rml::Style::FontWeight::Bold);
|
||||
italic = Rml::LoadFontFace(rml::asset_path(folder / "segoeuii.ttf"),
|
||||
"Modern", Rml::Style::FontStyle::Italic,
|
||||
Rml::Style::FontWeight::Normal);
|
||||
bold_italic = Rml::LoadFontFace(rml::asset_path(folder / "segoeuiz.ttf"),
|
||||
"Modern", Rml::Style::FontStyle::Italic,
|
||||
Rml::Style::FontWeight::Bold);
|
||||
}
|
||||
#elif defined(__APPLE__)
|
||||
const fs::path system = "/System/Library/Fonts/SFNS.ttf";
|
||||
@@ -1100,6 +1120,15 @@ class App final : public Rml::EventListener {
|
||||
bold = Rml::LoadFontFace(rml::asset_path(system), "Modern",
|
||||
Rml::Style::FontStyle::Normal,
|
||||
Rml::Style::FontWeight::Bold);
|
||||
const fs::path slanted = "/System/Library/Fonts/SFNSItalic.ttf";
|
||||
if (fs::exists(slanted)) {
|
||||
italic = Rml::LoadFontFace(rml::asset_path(slanted), "Modern",
|
||||
Rml::Style::FontStyle::Italic,
|
||||
Rml::Style::FontWeight::Normal);
|
||||
bold_italic = Rml::LoadFontFace(rml::asset_path(slanted), "Modern",
|
||||
Rml::Style::FontStyle::Italic,
|
||||
Rml::Style::FontWeight::Bold);
|
||||
}
|
||||
}
|
||||
#else
|
||||
const fs::path fonts = fs::exists("/usr/share/fonts/truetype/liberation2")
|
||||
@@ -1112,6 +1141,12 @@ class App final : public Rml::EventListener {
|
||||
bold = Rml::LoadFontFace(
|
||||
rml::asset_path(fonts / "LiberationSans-Bold.ttf"), "Modern",
|
||||
Rml::Style::FontStyle::Normal, Rml::Style::FontWeight::Bold);
|
||||
italic = Rml::LoadFontFace(
|
||||
rml::asset_path(fonts / "LiberationSans-Italic.ttf"), "Modern",
|
||||
Rml::Style::FontStyle::Italic, Rml::Style::FontWeight::Normal);
|
||||
bold_italic = Rml::LoadFontFace(
|
||||
rml::asset_path(fonts / "LiberationSans-BoldItalic.ttf"), "Modern",
|
||||
Rml::Style::FontStyle::Italic, Rml::Style::FontWeight::Bold);
|
||||
}
|
||||
#endif
|
||||
if (!regular)
|
||||
@@ -1122,6 +1157,14 @@ class App final : public Rml::EventListener {
|
||||
bold = Rml::LoadFontFace(rml::asset_path(assets_ / "LatoLatin-Bold.ttf"),
|
||||
"Modern", Rml::Style::FontStyle::Normal,
|
||||
Rml::Style::FontWeight::Bold);
|
||||
if (!italic)
|
||||
italic = Rml::LoadFontFace(rml::asset_path(assets_ / "LatoLatin-Italic.ttf"),
|
||||
"Modern", Rml::Style::FontStyle::Italic,
|
||||
Rml::Style::FontWeight::Normal);
|
||||
if (!bold_italic)
|
||||
bold_italic = Rml::LoadFontFace(
|
||||
rml::asset_path(assets_ / "LatoLatin-BoldItalic.ttf"), "Modern",
|
||||
Rml::Style::FontStyle::Italic, Rml::Style::FontWeight::Bold);
|
||||
std::vector<fs::path> chalk_fonts;
|
||||
#ifdef _WIN32
|
||||
if (const char *windir = std::getenv("WINDIR")) {
|
||||
@@ -1143,7 +1186,7 @@ class App final : public Rml::EventListener {
|
||||
Rml::Style::FontStyle::Normal,
|
||||
Rml::Style::FontWeight::Normal))
|
||||
break;
|
||||
if (!regular || !bold)
|
||||
if (!regular || !bold || !italic || !bold_italic)
|
||||
throw std::runtime_error(
|
||||
"GUI-Schriften fehlen. Bitte das vollständige Paket entpacken.");
|
||||
}
|
||||
@@ -1334,6 +1377,10 @@ public:
|
||||
#include "modern/ui/rankings_controls.inc"
|
||||
#include "modern/ui/stadium_screens.inc"
|
||||
#include "modern/ui/stadium_controls.inc"
|
||||
#include "modern/ui/statistics_screens.inc"
|
||||
#include "modern/ui/statistics_controls.inc"
|
||||
#include "modern/ui/news_screens.inc"
|
||||
#include "modern/ui/news_controls.inc"
|
||||
} // namespace
|
||||
bool is_modern_world(const fs::path &file) {
|
||||
try {
|
||||
|
||||
@@ -80,6 +80,15 @@ void centered_text(Rml::Element &text_root, Rml::Element &control,
|
||||
text_centers(text_root, p.x + s.x / 2, p.y + s.y / 2, horizontal, lines);
|
||||
require(lines == 1, "A control label disappeared or wrapped");
|
||||
}
|
||||
size_t visible_text_lines(Rml::Element &node) {
|
||||
size_t count = 0;
|
||||
if (auto *text = dynamic_cast<Rml::ElementText *>(&node))
|
||||
for (const auto &line : text->GetLines())
|
||||
if (!line.text.empty() && line.width > 0) ++count;
|
||||
for (int i = 0; i < node.GetNumChildren(); ++i)
|
||||
count += visible_text_lines(*node.GetChild(i));
|
||||
return count;
|
||||
}
|
||||
} // namespace
|
||||
int main(int argc, char **argv) try {
|
||||
require(argc == 2, "Pass the Modern asset directory");
|
||||
@@ -97,10 +106,14 @@ int main(int argc, char **argv) try {
|
||||
Rml::Style::FontStyle::Normal,
|
||||
Rml::Style::FontWeight::Bold),
|
||||
"Bold font missing");
|
||||
require(Rml::LoadFontFace((root / "LatoLatin-BoldItalic.ttf").string(), "Modern",
|
||||
Rml::Style::FontStyle::Italic,
|
||||
Rml::Style::FontWeight::Bold),
|
||||
"Bold italic font missing");
|
||||
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", "environment.rcss", "advertising.rcss", "toto.rcss", "lineup.rcss", "transfer.rcss", "career_reports.rcss", "rankings.rcss", "stadium.rcss"}) {
|
||||
"report_pickers.rcss", "indoor.rcss", "planning.rcss", "almanac.rcss", "finance.rcss", "bank.rcss", "contracts.rcss", "amount.rcss", "environment.rcss", "advertising.rcss", "toto.rcss", "lineup.rcss", "transfer.rcss", "career_reports.rcss", "rankings.rcss", "stadium.rcss", "statistics.rcss", "news.rcss"}) {
|
||||
std::ifstream input(root / name);
|
||||
require(bool(input), "Production stylesheet missing");
|
||||
css << input.rdbuf() << '\n';
|
||||
@@ -138,6 +151,24 @@ int main(int argc, char **argv) try {
|
||||
"id='rich' "
|
||||
"style='position:absolute;left:700dp;top:40dp;width:250dp;height:"
|
||||
"260dp;' ");
|
||||
content +=
|
||||
"<div style='position:absolute;left:1200dp;top:40dp;width:1294dp;height:94dp;'>" +
|
||||
button_markup("statistics-absolute", "<span id='stats-scale-label' class='statistics-cell-text'>REL.</span>",
|
||||
"statistics-action statistics-absolute", "style='left:0;top:0;width:100%;height:94dp;'") + "</div>" +
|
||||
"<div class='statistics-cell statistics-col-0' style='position:absolute;left:1200dp;top:160dp;width:1000dp;height:80dp;'>" +
|
||||
button_markup("player-detail", "<span id='stats-player-label' class='statistics-cell-text'>Synthetic player</span>",
|
||||
"statistics-player-link") + "</div>" +
|
||||
"<div class='statistics-cell statistics-col-0' style='position:absolute;left:1200dp;top:260dp;width:1000dp;height:80dp;'>" +
|
||||
button_markup("statistics-trophy", "<span class='statistics-world-trophy-art'></span><span id='stats-world-label' class='statistics-cell-text'>WM 2098</span>",
|
||||
"statistics-world-trophy") + "</div>" +
|
||||
"<div style='position:absolute;left:2300dp;top:160dp;width:1000dp;height:80dp;'>" +
|
||||
button_markup("club-detail", "<span id='stats-from-label' class='report-club-name'>Synthetic source club</span><span style='width:42dp;height:42dp;'></span>",
|
||||
"report-club-button statistics-club name-first") + "</div>" +
|
||||
"<span id='news-brand-test' class='news-wordmark' style='position:absolute;left:2700dp;top:280dp;'>kicker</span>" +
|
||||
"<div class='statistics-trophy-winner' style='left:2700dp;top:430dp;width:900dp;height:100dp;font-size:70dp;'>" +
|
||||
"<div class='image-frame' style='width:100dp;height:100dp;'></div><span id='stats-winner-label'>Sample winner</span></div>" +
|
||||
button_markup("statistics-curve", "<span class='statistics-series-dot'></span><span id='stats-legend-label' class='statistics-series-label'>Mannschaftsstärke</span>",
|
||||
"statistics-action statistics-series-button", "style='left:2700dp;top:580dp;width:836dp;height:82dp;'");
|
||||
content +=
|
||||
"<div "
|
||||
"style='position:absolute;left:40dp;top:400dp;width:2608dp;height:"
|
||||
@@ -165,6 +196,11 @@ int main(int argc, char **argv) try {
|
||||
context->Render();
|
||||
}
|
||||
require(!center_selects(*doc), "Control centering does not settle");
|
||||
for (const auto *id : {"stats-scale-label", "stats-legend-label", "stats-player-label", "stats-world-label", "stats-from-label", "stats-winner-label", "news-brand-test"}) {
|
||||
auto *label = doc->GetElementById(id);
|
||||
require(label && label->GetBox().GetSize(Rml::BoxArea::Content).x > 0 && visible_text_lines(*label) > 0,
|
||||
"A production statistics/news label has collapsed or lost its font face");
|
||||
}
|
||||
for (const auto *id : {"step", "region", "footer"}) {
|
||||
auto *button = doc->GetElementById(id);
|
||||
require(button, "Button missing");
|
||||
|
||||
@@ -0,0 +1,304 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "modern/ui/demo_news.hpp"
|
||||
#include "modern/ui/desktop.hpp"
|
||||
#include "modern/ui/model.hpp"
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <set>
|
||||
#include <stdexcept>
|
||||
using namespace bmh::modern_ui;
|
||||
namespace {
|
||||
void require(bool yes, const char *why) {
|
||||
if (!yes)
|
||||
throw std::runtime_error(why);
|
||||
}
|
||||
struct Fixture {
|
||||
fs::path root;
|
||||
std::shared_ptr<const Catalog> world;
|
||||
Fixture() {
|
||||
root = fs::temp_directory_path() /
|
||||
("openbmh-news-ui-" +
|
||||
std::to_string(
|
||||
std::chrono::steady_clock::now().time_since_epoch().count()));
|
||||
fs::create_directories(root / "world");
|
||||
const auto write = [&](const std::string &name, const Json &data) {
|
||||
bmh::editor::write_atomic(root / name, data.dump());
|
||||
};
|
||||
write("manifest.json", {{"format", "openbmh-world"},
|
||||
{"kind", "world"},
|
||||
{"format_version", "1.1"},
|
||||
{"id", "world:synthetic-news"},
|
||||
{"start_date", "2032-07-01"},
|
||||
{"requires", {"editor:world-v1"}},
|
||||
{"x-editor", {{"profile", "editor-world-v1"}}}});
|
||||
write("world/nations.json",
|
||||
{{"items", {{{"id", "nation:de"}, {"name", "Synthetic nation"}}}}});
|
||||
write("world/competitions.json", {{"items",
|
||||
{{{"id", "competition:news-test"},
|
||||
{"type", "league"},
|
||||
{"nation", "nation:de"},
|
||||
{"name", "Synthetic league"}}}}});
|
||||
Json clubs = Json::array();
|
||||
for (int i = 0; i < 2; ++i)
|
||||
clubs.push_back({{"id", "club:news-" + std::to_string(i)},
|
||||
{"name", "Synthetic Club " + std::to_string(i)},
|
||||
{"nation", "nation:de"},
|
||||
{"competition", "competition:news-test"}});
|
||||
write("world/clubs.json", {{"items", clubs}});
|
||||
write("world/players.json", {{"items", Json::array()}});
|
||||
world = Catalog::open(root);
|
||||
}
|
||||
~Fixture() {
|
||||
std::error_code ec;
|
||||
fs::remove_all(root, ec);
|
||||
}
|
||||
};
|
||||
Json state() {
|
||||
return {
|
||||
{"date", "2032-03-01"},
|
||||
{"managers", {{{"name", "Synthetic Manager"}, {"club", "club:news-0"}}}},
|
||||
{"cash", 123456},
|
||||
{"other", {{"kept", true}}}};
|
||||
}
|
||||
void reject(Json &s, const Json &a, const Catalog &w) {
|
||||
const auto before = s;
|
||||
require(!edit_demo_news(s, a, w).empty() && s == before,
|
||||
"Rejected news action altered state");
|
||||
}
|
||||
void provider(Fixture &f) {
|
||||
auto s = state();
|
||||
const auto unrelated = s, clubs = f.world->rows("clubs");
|
||||
require(migrate_demo_news(s, *f.world) && valid_demo_news(s),
|
||||
"Old checkpoint migration failed");
|
||||
const auto initial = s;
|
||||
require(migrate_demo_news(s, *f.world) && s == initial,
|
||||
"Existing mailbox was reinitialized");
|
||||
auto rest = s;
|
||||
rest.erase("news");
|
||||
require(rest == unrelated, "News migration changed unrelated fields");
|
||||
const auto view = demo_news_view(*f.world, s);
|
||||
require(view.at("items").size() == 9 && view.at("counts").at("inbox") == 9 &&
|
||||
view.at("counts").at("archive") == 3 && view.at("unread") == 5,
|
||||
"Initial mailbox counts wrong");
|
||||
require(view.at("date") == "01.03.2032" &&
|
||||
s.at("news").at("items")[2].at("date") == "2032-02-29" &&
|
||||
s.at("news").at("items")[11].at("date") == "2032-02-18",
|
||||
"Relative fixture dates or leap day wrong");
|
||||
require(view.at("items")[0].at("body").get<std::string>().find(
|
||||
"Synthetic Manager. Synthetic Club 0") != std::string::npos,
|
||||
"Current manager and club not interpolated");
|
||||
auto changed = s;
|
||||
changed["managers"][0] = {{"name", "Other Manager"}, {"club", "club:news-1"}};
|
||||
require(demo_news_view(*f.world, changed)
|
||||
.at("items")[0]
|
||||
.at("body")
|
||||
.get<std::string>()
|
||||
.find("Other Manager. Synthetic Club 1") != std::string::npos,
|
||||
"Manager change retained stale template identity");
|
||||
require(demo_news_view(*f.world, s, "inbox", "FINANZEN").at("items").size() ==
|
||||
2 &&
|
||||
demo_news_view(*f.world, s, "inbox", "VERTRAGSGESPRÄCHE")
|
||||
.at("items")
|
||||
.size() == 1,
|
||||
"German case-insensitive category/title search failed");
|
||||
require(demo_news_view(*f.world, s, "inbox", "unmatchable-search")
|
||||
.at("items")
|
||||
.empty() &&
|
||||
demo_news_view(*f.world, s, "inbox", "01.03.2032")
|
||||
.at("items")
|
||||
.size() == 2,
|
||||
"Search empty/date projection failed");
|
||||
require(s == initial && f.world->rows("clubs") == clubs,
|
||||
"Read-only projection mutated state or catalogue");
|
||||
require(
|
||||
edit_demo_news(s, {{"kind", "read-all"}, {"folder", "inbox"}}, *f.world)
|
||||
.empty() &&
|
||||
demo_news_unread(s) == 0,
|
||||
"Read-all must mark the entire folder, including hidden results");
|
||||
s = initial;
|
||||
require(edit_demo_news(s, {{"kind", "read"}, {"id", "season"}}, *f.world)
|
||||
.empty() &&
|
||||
demo_news_unread(s) == 4,
|
||||
"Open read action failed");
|
||||
s = initial;
|
||||
require(edit_demo_news(
|
||||
s, {{"kind", "move"}, {"id", "season"}, {"folder", "archive"}},
|
||||
*f.world)
|
||||
.empty() &&
|
||||
demo_news_unread(s) == 4,
|
||||
"Archive must also mark read");
|
||||
const Json patch =
|
||||
Json::array({{{"id", "season"},
|
||||
{"before", {{"read", false}, {"folder", "inbox"}}},
|
||||
{"after", {{"read", true}, {"folder", "archive"}}}}});
|
||||
const auto archived = s;
|
||||
require(edit_demo_news(s, {{"kind", "undo"}, {"patch", patch}}, *f.world)
|
||||
.empty() &&
|
||||
s == initial,
|
||||
"Undo failed to restore the small read/folder patch");
|
||||
reject(s, {{"kind", "undo"}, {"patch", patch}}, *f.world);
|
||||
s = archived;
|
||||
require(edit_demo_news(
|
||||
s, {{"kind", "move"}, {"id", "season"}, {"folder", "inbox"}},
|
||||
*f.world)
|
||||
.empty() &&
|
||||
s.at("news").at("items")[0].at("read") == true,
|
||||
"Restore must retain read state");
|
||||
require(edit_demo_news(
|
||||
s, {{"kind", "move"}, {"id", "season"}, {"folder", "trash"}},
|
||||
*f.world)
|
||||
.empty() &&
|
||||
demo_news_view(*f.world, s).at("counts").at("inbox") == 8,
|
||||
"Delete did not remove item from visible folders");
|
||||
reject(s, {{"kind", "read"}, {"id", "season"}}, *f.world);
|
||||
s = archived;
|
||||
auto multi = patch;
|
||||
multi.push_back({{"id", "missing"},
|
||||
{"before", {{"read", false}, {"folder", "inbox"}}},
|
||||
{"after", {{"read", true}, {"folder", "inbox"}}}});
|
||||
reject(s, {{"kind", "undo"}, {"patch", multi}}, *f.world);
|
||||
multi = patch;
|
||||
multi.push_back(patch[0]);
|
||||
reject(s, {{"kind", "undo"}, {"patch", multi}}, *f.world);
|
||||
for (const auto &a : std::vector<Json>{
|
||||
nullptr, Json::array(), Json{{"kind", 4}},
|
||||
Json{{"kind", "move"}, {"id", "season"}, {"folder", "lost"}},
|
||||
Json{{"kind", "read"}, {"id", 4}},
|
||||
Json{{"kind", "read"}, {"id", "season"}, {"unexpected", true}},
|
||||
Json{{"kind", "read-all"}, {"folder", "trash"}},
|
||||
Json{{"kind", "undo"}, {"patch", Json::array()}},
|
||||
Json{{"kind", "unknown"}}})
|
||||
reject(s, a, *f.world);
|
||||
std::vector<Json> bad;
|
||||
auto invalid = initial;
|
||||
invalid["news"]["items"].push_back(invalid["news"]["items"][0]);
|
||||
bad.push_back(invalid);
|
||||
for (const auto &[key, value] : std::vector<std::pair<std::string, Json>>{
|
||||
{"id", "BAD-ID"},
|
||||
{"id", ""},
|
||||
{"date", "2031-02-29"},
|
||||
{"date", "2032-13-01"},
|
||||
{"kind", 4},
|
||||
{"kind", "unsupported"},
|
||||
{"title", " "},
|
||||
{"title", std::string(161, 'x')},
|
||||
{"body", std::string(1201, 'x')},
|
||||
{"read", 1},
|
||||
{"folder", "removed"}}) {
|
||||
invalid = initial;
|
||||
invalid["news"]["items"][0][key] = value;
|
||||
bad.push_back(invalid);
|
||||
}
|
||||
invalid = initial;
|
||||
invalid["news"]["version"] = 1.0;
|
||||
bad.push_back(invalid);
|
||||
invalid = initial;
|
||||
invalid["news"]["query"] = "must-be-local";
|
||||
bad.push_back(invalid);
|
||||
invalid = initial;
|
||||
for (int i = 12; i < 101; ++i) {
|
||||
auto m = invalid["news"]["items"][0];
|
||||
m["id"] = "test-" + std::to_string(i);
|
||||
invalid["news"]["items"].push_back(m);
|
||||
}
|
||||
bad.push_back(invalid);
|
||||
for (auto invalid : bad) {
|
||||
const auto before = invalid;
|
||||
require(!valid_demo_news(invalid) &&
|
||||
!migrate_demo_news(invalid, *f.world) && invalid == before,
|
||||
"Malformed imported mailbox was repaired or accepted");
|
||||
reject(invalid, {{"kind", "read-all"}, {"folder", "inbox"}}, *f.world);
|
||||
}
|
||||
auto empty = initial;
|
||||
empty["news"]["items"] = Json::array();
|
||||
require(valid_demo_news(empty) &&
|
||||
demo_news_view(*f.world, empty).at("items").empty() &&
|
||||
demo_news_unread(empty) == 0,
|
||||
"Valid empty mailbox rejected");
|
||||
}
|
||||
void source(Fixture &f) {
|
||||
DemoSource source(f.world);
|
||||
auto initial = source.snapshot();
|
||||
require(valid_demo_news(initial.state) && !source.dirty(),
|
||||
"Default source mailbox missing or dirty");
|
||||
const auto clean = initial.state;
|
||||
demo_news_view(*f.world, initial.state, "archive", "search");
|
||||
require(source.snapshot().revision == initial.revision && !source.dirty(),
|
||||
"Navigation dirtied source");
|
||||
require(
|
||||
source
|
||||
.apply(
|
||||
{initial.revision, "news", {{"kind", "read"}, {"id", "season"}}})
|
||||
.ok,
|
||||
"Source rejected news action");
|
||||
auto current = source.snapshot();
|
||||
require(source.dirty() && current.revision == initial.revision + 1,
|
||||
"News action did not advance source revision");
|
||||
require(
|
||||
!source.apply({initial.revision,
|
||||
"news",
|
||||
{{"kind", "move"}, {"id", "season"}, {"folder", "trash"}}})
|
||||
.ok &&
|
||||
source.snapshot().state == current.state,
|
||||
"Stale news action changed source");
|
||||
require(!source.apply({current.revision,
|
||||
"news",
|
||||
{{"kind", "move"}, {"id", "season"}, {"folder", 9}}})
|
||||
.ok &&
|
||||
source.snapshot().state == current.state &&
|
||||
source.snapshot().revision == current.revision,
|
||||
"Malformed source action was not atomic");
|
||||
const auto save = f.root / "checkpoint.json";
|
||||
source.save(save, default_desktop());
|
||||
require(!source.dirty(), "Saving news did not clear dirty");
|
||||
require(
|
||||
source
|
||||
.apply({source.snapshot().revision,
|
||||
"news",
|
||||
{{"kind", "move"}, {"id", "season"}, {"folder", "trash"}}})
|
||||
.ok,
|
||||
"Delete source action failed");
|
||||
source.load(save);
|
||||
require(source.snapshot().state.at("news") == current.state.at("news") &&
|
||||
!source.dirty(),
|
||||
"Saved mailbox did not reload");
|
||||
auto data = Json::parse(bmh::editor::read_file(save));
|
||||
data.erase("news");
|
||||
bmh::editor::write_atomic(save, data.dump());
|
||||
source.load(save);
|
||||
require(valid_demo_news(source.snapshot().state) &&
|
||||
demo_news_unread(source.snapshot().state) == 5 && !source.dirty(),
|
||||
"Old checkpoint did not initialize clean news");
|
||||
source.save(save, default_desktop());
|
||||
data = Json::parse(bmh::editor::read_file(save));
|
||||
data["news"]["items"][0]["kind"] = 44;
|
||||
bmh::editor::write_atomic(save, data.dump());
|
||||
const auto before = source.snapshot();
|
||||
bool rejected = false;
|
||||
try {
|
||||
source.load(save);
|
||||
} catch (const std::exception &) {
|
||||
rejected = true;
|
||||
}
|
||||
require(rejected && source.snapshot().state == before.state &&
|
||||
source.snapshot().revision == before.revision && !source.dirty(),
|
||||
"Malformed checkpoint replaced state or advanced revision");
|
||||
auto rest = before.state;
|
||||
rest.erase("news");
|
||||
auto base = clean;
|
||||
base.erase("news");
|
||||
require(rest == base, "Mailbox actions modified unrelated presentation data");
|
||||
}
|
||||
} // namespace
|
||||
int main() {
|
||||
try {
|
||||
Fixture f;
|
||||
provider(f);
|
||||
source(f);
|
||||
std::cout << "modern news UI tests passed\n";
|
||||
return 0;
|
||||
} catch (const std::exception &e) {
|
||||
std::cerr << e.what() << '\n';
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "modern/ui/demo_statistics.hpp"
|
||||
#include "modern/ui/model.hpp"
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <set>
|
||||
#include <stdexcept>
|
||||
|
||||
using namespace bmh::modern_ui;
|
||||
namespace {
|
||||
void require(bool value,const char *message) {if(!value)throw std::runtime_error(message);}
|
||||
const std::array<std::string,8> nations{"de","es","en","fr","it","nl","pt","be"};
|
||||
std::string club(const std::string &country,int index) {return "club:statistics-"+country+"-"+std::to_string(index);}
|
||||
struct Fixture {
|
||||
fs::path root;std::shared_ptr<const Catalog> world;
|
||||
explicit Fixture(bool empty=false, bool english_subnation=false) {
|
||||
root=fs::temp_directory_path()/("openbmh-statistics-ui-"+std::to_string(std::chrono::steady_clock::now().time_since_epoch().count()));
|
||||
fs::create_directories(root/"world");
|
||||
const auto write=[&](const std::string &file,const Json &value){bmh::editor::write_atomic(root/file,value.dump());};
|
||||
write("manifest.json",{{"format","openbmh-world"},{"kind","world"},{"format_version","1.1"},{"id","world:synthetic-statistics"},{"start_date","2026-07-01"},{"requires",{"editor:world-v1"}},{"x-editor",{{"profile","editor-world-v1"}}}});
|
||||
Json ns=Json::array(),leagues=Json::array(),clubs=Json::array(),players=Json::array();
|
||||
if(!empty)for(size_t n=0;n<nations.size();++n) {
|
||||
const auto &code=nations[n];
|
||||
const auto nation_id = code == "en" && english_subnation ? "nation:x-eng" : "nation:" + code;
|
||||
ns.push_back({{"id",nation_id},{"name","Synthetic nation "+code}});
|
||||
if(n>=5)continue;
|
||||
const auto league="competition:statistics-"+code;
|
||||
leagues.push_back({{"id",league},{"type","league"},{"nation",nation_id},{"tier",1},{"name","Synthetic league "+code}});
|
||||
leagues.push_back({{"id",league+"-lower"},{"type","league"},{"nation",nation_id},{"tier",2},{"name","Synthetic lower league "+code}});
|
||||
for(int i=0;i<20;++i) {
|
||||
const auto id=club(code,i);
|
||||
clubs.push_back({{"id",id},{"name","Synthetic club "+code+" "+std::to_string(i)},{"competition",league},{"nation",nation_id},{"crest","asset:synthetic-crest"}});
|
||||
for(int p=0;p<12;++p)players.push_back({{"id","player:statistics-"+code+"-"+std::to_string(i)+"-"+std::to_string(p)},{"name","Synthetic player "+std::to_string(i*12+p)},{"team",id},{"nation",nation_id},{"positions",{p==0?"gk":"mid"}}});
|
||||
}
|
||||
clubs.push_back({{"id",club(code,20)},{"name","Synthetic lower club"},{"competition",league+"-lower"},{"nation",nation_id}});
|
||||
}
|
||||
write("world/nations.json",{{"items",ns}});write("world/competitions.json",{{"items",leagues}});write("world/clubs.json",{{"items",clubs}});write("world/players.json",{{"items",players}});
|
||||
world=Catalog::open(root);
|
||||
}
|
||||
~Fixture(){std::error_code ec;fs::remove_all(root,ec);}
|
||||
};
|
||||
Json state() {return {{"date","2027-07-07"},{"managers",{{{"name","Synthetic manager"},{"club",club("de",4)}}}},{"cash",123456},{"reports",{{"league","competition:statistics-es"},{"filter",4}}}};}
|
||||
void identities(const Catalog &world,const Json &data) {
|
||||
for(const auto &r:data.at("rows"))for(const auto &c:r.at("cells")) {
|
||||
if(c.contains("club"))require(world.find("clubs",c.at("club").get<std::string>()),"Statistics contains an unknown club identity");
|
||||
if(c.contains("player"))require(world.find("players",c.at("player").get<std::string>()),"Statistics contains an unknown player identity");
|
||||
if(c.contains("nation"))require(world.find("nations",c.at("nation").get<std::string>()),"Statistics contains an unknown nation identity");
|
||||
}
|
||||
}
|
||||
void projections() {
|
||||
Fixture f;const auto s=state(),before=s,clubs=f.world->rows("clubs"),players=f.world->rows("players");
|
||||
const auto initial=demo_statistics(*f.world,s);
|
||||
require(initial.at("ok")==true&&initial.at("fictional")==true&&initial.at("section")==7&&initial.at("category")==0&&initial.at("winner_country")=="nation:de","Default must open national German winners");
|
||||
require(initial.at("rows").size()==12&&initial.at("columns").size()==4,"National winners lost their three title columns or twelve seasons");
|
||||
require(initial.at("rows")[0].at("cells")[0].at("text")=="2026/27"&&initial.at("rows")[11].at("cells")[0].at("text")=="2015/16","Winners must end with last completed season");
|
||||
require(initial.at("manager")=="Synthetic manager"&&initial.at("club")==club("de",4),"Statistics has stale own-manager identity");
|
||||
const std::array<std::string,5> winner_order{"de","es","it","fr","en"};
|
||||
for(size_t i=0;i<winner_order.size();++i)require(initial.at("countries")[i].at("id")=="nation:"+winner_order[i],"Winner-country order differs from Gold");
|
||||
for(int section=0;section<9;++section) {
|
||||
const auto data=demo_statistics(*f.world,s,{{"section",section}});
|
||||
require(data.at("ok")==true&&data.at("title")==data.at("sections")[size_t(section)],"A statistics section is unavailable or mislabeled");
|
||||
identities(*f.world,data);
|
||||
if(section==1)require(data.at("rows").size()==10,"Transfer history must show ten distinct actual players when available");
|
||||
}
|
||||
for(int country=0;country<5;++country) {
|
||||
const auto data=demo_statistics(*f.world,s,{{"section",3},{"country",country}});
|
||||
const std::array<std::string,5> order{"de","es","en","fr","it"};
|
||||
require(data.at("rows").size()==20,"Eternal table silently lost twentieth team or mixed lower leagues");
|
||||
require(data.at("rows")[0].at("cells")[0].at("club")==club(order[size_t(country)],0),"Eternal country selector uses wrong nation cohort");
|
||||
require(data.at("rows")[19].at("cells")[0].at("club")==club(order[size_t(country)],19),"Eternal table truncated final actual club");
|
||||
identities(*f.world,data);
|
||||
}
|
||||
require(demo_statistics(*f.world,s,{{"section",3},{"country",5}}).at("rows").size()==20,"Absolute eternal table lost own-league cohort");
|
||||
for(const auto &nation:initial.at("countries")) {
|
||||
const auto id=nation.at("id").get<std::string>();const auto code=id.substr(7);
|
||||
const auto data=demo_statistics(*f.world,s,{{"winner_country",id}});
|
||||
require(data.at("rows")[0].at("cells")[1].at("club")==club(code,0)&&data.at("rows")[0].at("cells")[3].at("club")==club(code,1),"National winners must use selected country's actual clubs");
|
||||
require(data.at("columns")[1].at("winner")==data.at("rows")[0].at("cells")[1].at("club"),"Trophy detail winner differs from latest visible winner");
|
||||
identities(*f.world,data);
|
||||
}
|
||||
const auto international=demo_statistics(*f.world,s,{{"category",1}}),indoor=demo_statistics(*f.world,s,{{"category",5}});
|
||||
require(international.at("columns").size()==4&&international.at("columns")[2].at("text")=="Pokalsieger"&&international.at("columns")[3].at("text")=="UEFA-Cup","International competition structure differs from BMH Gold");
|
||||
require(indoor.at("columns").size()==3&&indoor.at("rows")[0].at("cells").size()==3&&indoor.at("columns")[1].at("text")=="Sieger"&&indoor.at("columns")[2].at("text")=="Finalist","Indoor winners need exactly two title columns");
|
||||
identities(*f.world,international);identities(*f.world,indoor);
|
||||
for(int view=0;view<6;++view) {
|
||||
const auto data=demo_statistics(*f.world,s,{{"section",4},{"country",view}});identities(*f.world,data);
|
||||
const size_t expected=view==0||view==5?6:view==3?4:8;
|
||||
require(data.at("rows").size()==expected,"A world-statistics subview is missing");
|
||||
if(view==3)require(data.at("columns")[0].at("round")=="Runde"&&data.at("rows")[0].at("cells")[0].at("round")=="Finale"&&!data.at("rows")[0].at("cells")[0].contains("prefix"),"World final-round metadata was flattened into the team label");
|
||||
}
|
||||
const auto relative=demo_statistics(*f.world,s,{{"section",2}}),absolute=demo_statistics(*f.world,s,{{"section",2},{"absolute",true},{"curves",{false,true,false,true,false,true}}});
|
||||
require(relative.at("series").size()==6&&relative.at("series")[0].at("points").size()==24,"Analytics needs six 24-point curves");
|
||||
require(relative.at("series")[0].at("points")!=absolute.at("series")[0].at("points")&&absolute.at("series")[0].at("active")==false&&absolute.at("series")[1].at("active")==true,"Curve toggles or relative/absolute data do not work");
|
||||
const auto minutes=demo_statistics(*f.world,s,{{"section",8}});
|
||||
require(minutes.at("columns").size()==19&&minutes.at("rows").size()==4&&minutes.at("rows")[0].at("cells")[1].at("tone")=="bad"&&minutes.at("rows")[0].at("cells")[4].at("tone")=="good","Minute grid must retain eighteen intervals and meaningful colors");
|
||||
auto changed=s;changed["cash"]=0;changed["reports"]={{"league","elsewhere"}};
|
||||
require(demo_statistics(*f.world,changed)==initial,"Statistics depends on unrelated wallet or report filters");
|
||||
changed=s;changed["managers"][0]["name"]="Changed manager";changed["managers"][0]["club"]=club("de",7);
|
||||
require(demo_statistics(*f.world,changed).at("manager")=="Changed manager"&&demo_statistics(*f.world,changed).at("club")==club("de",7),"Statistics retains stale manager after switch");
|
||||
changed=s;changed["date"]="2027-06-30";
|
||||
require(demo_statistics(*f.world,changed).at("rows")[0].at("cells")[0].at("text")=="2025/26","June date falsely completed current season");
|
||||
require(s==before&&f.world->rows("clubs")==clubs&&f.world->rows("players")==players&&demo_statistics(*f.world,s)==initial,"Read projection changed input/catalogue or became nondeterministic");
|
||||
// This boundary check also proves all UI filters remain outside saved state.
|
||||
DemoSource source(f.world);const auto snapshot=source.snapshot();const bool dirty=source.dirty();
|
||||
for(int section=0;section<9;++section)require(source.read_statistics({{"section",section}}).at("ok")==true,"Data-source read boundary does not expose statistics");
|
||||
require(source.snapshot().revision==snapshot.revision&&source.snapshot().state==snapshot.state&&source.dirty()==dirty,"Statistics reads changed checkpoint state, revision or dirty flag");
|
||||
}
|
||||
void invalid_and_empty() {
|
||||
Fixture f;
|
||||
for(const auto &request:std::vector<Json>{nullptr,Json::array(),Json{{"section",-1}},Json{{"section",9}},Json{{"section","7"}},Json{{"category",2}},Json{{"country",6}},Json{{"winner_country","nation:missing"}},Json{{"winner_country",0}},Json{{"absolute",1}},Json{{"curves",{true,false}}},Json{{"curves",{true,true,true,true,true,1}}},Json{{"page",1}}})require(demo_statistics(*f.world,state(),request).at("ok")==false,"Malformed statistics filter was accepted");
|
||||
Fixture empty(true);for(int section=0;section<9;++section) {
|
||||
const auto data=demo_statistics(*empty.world,Json::object(),{{"section",section}});
|
||||
require(data.at("ok")==true&&data.at("available")==false&&data.at("rows").empty()&&data.at("series").empty()&&data.at("club").is_null(),"Empty world fabricated statistics identities or rows");
|
||||
}
|
||||
for(const auto &s:std::vector<Json>{nullptr,Json::array(),Json::object(),Json{{"managers",Json::array()}},Json{{"managers",{{{"club","club:missing"}}}}}}) {
|
||||
const auto data=demo_statistics(*f.world,s);require(data.at("ok")==true&&data.at("club").is_null(),"Malformed manager snapshot threw or invented own identity");
|
||||
}
|
||||
}
|
||||
void english_subnation() {
|
||||
Fixture f(false, true);
|
||||
const auto initial = demo_statistics(*f.world, state());
|
||||
require(initial.at("countries").size() == 5 && initial.at("countries")[4].at("id") == "nation:x-eng",
|
||||
"Stable England identity disappeared from the country picker");
|
||||
require(initial.at("eternal_countries").size() == 6 && initial.at("eternal_countries")[2].at("nation") == "nation:x-eng",
|
||||
"Eternal table omitted England or changed its Gold index");
|
||||
const auto eternal = demo_statistics(*f.world, state(), {{"section",3},{"country",2}});
|
||||
require(eternal.at("rows").size() == 20 && eternal.at("rows")[19].at("cells")[0].at("club") == club("en",19),
|
||||
"England's twentieth club is absent from its eternal table");
|
||||
const auto winner = demo_statistics(*f.world, state(), {{"winner_country","nation:x-eng"}});
|
||||
require(winner.at("columns")[1].at("text") == "Premier League" && winner.at("columns")[2].at("text") == "FA Cup" &&
|
||||
winner.at("columns")[1].at("trophy") == "en-premier-league",
|
||||
"England incorrectly uses German title or trophy names");
|
||||
const auto world = demo_statistics(*f.world, state(), {{"section",4},{"country",1}});
|
||||
require(world.at("rows")[4].at("cells")[1].at("nation") == "nation:x-eng",
|
||||
"World statistics replaced England with an unrelated country");
|
||||
require(!f.world->find("nations","nation:en"), "Projection changed stable nation IDs");
|
||||
}
|
||||
} // namespace
|
||||
int main()try{projections();invalid_and_empty();english_subnation();std::cout<<"Modern statistics UI checks passed\n";return 0;}catch(const std::exception &error){std::cerr<<error.what()<<'\n';return 1;}
|
||||
@@ -74,6 +74,15 @@ def main():
|
||||
add('button.' + route, button['src'].removeprefix('../'))
|
||||
add('button.news', 'assets/vector/desktop-news.svg')
|
||||
add('button.almanac', 'assets/vector/desktop-almanac.svg')
|
||||
add('news.cash', 'assets/studies/desktop-objects/cash-v2.png')
|
||||
# Prototype trophy fallbacks; competition pictures prefer world asset keys.
|
||||
for trophy in ('championship', 'dfb-cup', 'supercup', 'champions-league',
|
||||
'cup-winners', 'uefa-cup', 'indoor-masters', 'world-cup',
|
||||
'european-championship', 'es-la-liga', 'es-copa-del-rey',
|
||||
'en-premier-league', 'en-fa-cup', 'fr-ligue-1',
|
||||
'fr-coupe-de-france', 'it-serie-a', 'it-coppa-italia'):
|
||||
version = 2 if trophy == 'fr-coupe-de-france' else 1
|
||||
add('trophy.' + trophy, f'assets/studies/trophies/{trophy}-v{version}.png')
|
||||
for key, crop in [('normal', [0, 0, .5, .5]),
|
||||
('selected', [.5, .5, .5, .5]),
|
||||
('ghost', [.5, 0, .5, .5])]:
|
||||
|
||||
Reference in new issue
Block a user