Complete Modern desktop widgets and file libraries (by Codex)
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 modern_statistics_ui_tests modern_news_ui_tests modern_settings_ui_tests --parallel 2
|
||||
run: cmake --build build-ui --target openbmh_play modern_ui_core_tests modern_ticket_document_tests modern_control_layout_tests modern_reports_tests modern_planning_tests modern_almanac_ui_tests modern_finance_ui_tests modern_environment_ui_tests modern_advertising_ui_tests modern_toto_ui_tests modern_lineup_ui_tests modern_transfer_ui_tests modern_career_reports_tests modern_rankings_tests modern_stadium_ui_tests modern_statistics_ui_tests modern_news_ui_tests modern_settings_ui_tests modern_desktop_ui_tests modern_files_ui_tests --parallel 2
|
||||
- name: Check controls, fonts, density and draft cancellation
|
||||
run: ctest --test-dir build-ui -R "^modern_(ui_|ticket_|control_|reports_|planning_|almanac_ui_|finance_ui_|environment_ui_|advertising_ui_|toto_ui_|lineup_ui_|transfer_ui_|career_reports_|rankings_|stadium_ui_|statistics_ui_|news_ui_|settings_ui_)" --output-on-failure --output-junit modern-ui-results.xml
|
||||
run: ctest --test-dir build-ui -R "^modern_(ui_|ticket_|control_|reports_|planning_|almanac_ui_|finance_ui_|environment_ui_|advertising_ui_|toto_ui_|lineup_ui_|transfer_ui_|career_reports_|rankings_|stadium_ui_|statistics_ui_|news_ui_|settings_ui_|desktop_ui_|files_ui_)" --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,104 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-only */
|
||||
/* Native geometry follows the private HTML save/load reference at 3840x2160. */
|
||||
.files-layout {position:absolute;left:0;right:0;top:0;bottom:190dp;}
|
||||
.files-layout.files-views {bottom:0;}
|
||||
.files-views .files-browser {width:720dp;border-radius:24dp;}
|
||||
.files-views .files-details {left:774dp;display:block;padding:20dp 0;border-width:0;background-color:transparent;overflow-x:hidden;}
|
||||
.files-browser {position:absolute;left:0;top:0;bottom:0;width:1161dp;padding:0;border-radius:18dp;overflow:hidden;}
|
||||
.files-browser-header {position:absolute;left:0;right:0;top:0;height:110dp;padding:24dp 32dp;box-sizing:border-box;border-bottom:2dp #c5d9e726;display:flex;align-items:center;justify-content:space-between;}
|
||||
.files-browser-header h2 {font-size:32dp;font-weight:normal;}
|
||||
.files-browser-header>span {padding:6dp 18dp;border-radius:10dp;background-color:#c5d9e712;font-size:26dp;}
|
||||
.files-list {position:absolute;left:0;right:0;top:110dp;bottom:0;overflow-y:auto;overflow-x:hidden;}
|
||||
.files-entry {display:flex;align-items:center;width:100%;min-height:134dp;height:auto;padding:24dp 30dp;box-sizing:border-box;border-width:0 0 2dp 0;border-color:#c5d9e712;border-radius:0;background-color:transparent;text-align:left;}
|
||||
.files-entry:hover {background-color:#bad5f20d;}
|
||||
.files-entry.selected {background-color:#6286a82e;border-left:5dp #a9dccb;padding-left:25dp;}
|
||||
.files-entry-icon {display:block;width:64dp;height:70dp;line-height:66dp;text-align:center;flex-shrink:0;border:2dp #c5d9e729;border-radius:12dp;font-size:46dp;margin-right:24dp;}
|
||||
.files-entry-icon .image-frame {margin:13dp auto 0;}
|
||||
.files-entry-copy {display:flex;flex-direction:column;flex-grow:1;min-width:0;}
|
||||
.files-entry-copy strong {font-size:32dp;font-weight:normal;margin-bottom:12dp;white-space:normal;}
|
||||
.files-entry-copy>span {font-size:24dp;opacity:.72;white-space:normal;}
|
||||
.files-details {position:absolute;left:1193dp;right:0;top:0;bottom:0;display:flex;flex-direction:column;gap:36dp;padding:40dp;box-sizing:border-box;overflow:auto;border-radius:18dp;}
|
||||
.files-detail-heading {display:flex;align-items:center;min-height:148dp;flex-shrink:0;}
|
||||
.files-detail-heading>.image-frame {margin-right:30dp;flex-shrink:0;}
|
||||
.files-crest {display:flex;align-items:center;justify-content:center;width:140dp;height:140dp;flex-shrink:0;margin-right:30dp;border:2dp var(--border);border-radius:18dp;background-color:#e7edf3;}
|
||||
.files-detail-heading p,.files-intro {font-size:24dp;opacity:.75;margin:0 0 12dp;}
|
||||
.files-detail-heading h2,.files-heading {font-size:42dp;margin:0 0 14dp;font-weight:bold;}
|
||||
.files-detail-heading span {font-size:30dp;}
|
||||
.files-name-label {display:flex;flex-direction:column;font-size:28dp;flex-shrink:0;margin:0;}
|
||||
.files-name-label>span {display:block;}
|
||||
.files-name-label input {width:100%;height:86dp;box-sizing:border-box;padding:16dp 22dp;font-size:32dp;margin-top:14dp;border-radius:12dp;}
|
||||
.files-metadata {display:flex;flex-wrap:wrap;gap:22dp;flex-shrink:0;margin:0;}
|
||||
.files-metadata-cell {display:block;min-width:0;flex-basis:45%;flex-grow:1;box-sizing:border-box;margin:0;padding:26dp;border:2dp #c5d9e71a;border-radius:14dp;background-color:#c5d9e705;}
|
||||
.files-metadata-cell span {display:block;font-size:26dp;opacity:.72;margin-bottom:18dp;}
|
||||
.files-metadata-cell strong {display:block;font-size:40dp;font-weight:normal;}
|
||||
.files-managers {flex-shrink:0;}
|
||||
.files-managers h3 {font-size:28dp;font-weight:normal;opacity:.75;margin-bottom:22dp;}
|
||||
.files-managers>div {display:flex;justify-content:space-between;margin-bottom:22dp;}
|
||||
.files-managers strong {font-size:30dp;font-weight:normal;}
|
||||
.files-managers span {font-size:26dp;opacity:.75;text-align:right;margin-left:24dp;}
|
||||
.files-timestamp {font-size:24dp;opacity:.65;line-height:1.4;flex-shrink:0;margin:auto 0 0;}
|
||||
.files-empty-list {margin:40dp;font-size:30dp;opacity:.72;line-height:1.5;}
|
||||
.files-empty-details {padding:130dp 40dp;text-align:center;}
|
||||
.files-empty-details h2 {font-size:36dp;font-weight:normal;margin-bottom:30dp;}
|
||||
.files-empty-details p {font-size:28dp;opacity:.75;line-height:1.5;}
|
||||
.files-error {color:#edb4ac;}
|
||||
.files-feedback {position:absolute;left:0;right:0;bottom:122dp;min-height:36dp;margin:0;color:#a9dccb;font-size:28dp;}
|
||||
.files-actions {position:absolute;left:0;right:0;bottom:0;display:flex;align-items:center;justify-content:space-between;height:94dp;}
|
||||
.files-actions>div {display:flex;}
|
||||
.files-actions button {min-width:224dp;height:94dp;font-size:28dp;margin-right:16dp;}
|
||||
.files-confirm-actions button:last-child {margin-right:0;}
|
||||
.files-thumbnail {width:100%;margin:36dp 0 0;border:2dp var(--border);border-radius:20dp;background-color:#0f1c2b;overflow:hidden;}
|
||||
.files-thumbnail .image-frame {max-width:100%;}
|
||||
.files-save-illustration {padding:90dp 40dp;text-align:center;font-size:30dp;opacity:.75;}
|
||||
.files-save-illustration .image-frame {margin:0 auto 40dp;}
|
||||
.files-no-preview {font-size:28dp;opacity:.7;margin:70dp 0;}
|
||||
.files-views .files-browser-header {height:90dp;padding:26dp 30dp;}
|
||||
.files-views .files-browser-header>span {padding:0;background-color:transparent;font-size:27dp;color:var(--muted);}
|
||||
.files-views .files-list {top:90dp;padding:18dp;}
|
||||
.files-views .files-entry {min-height:136dp;padding:22dp;border:2dp transparent;border-radius:16dp;margin-bottom:10dp;}
|
||||
.files-views .files-entry.selected {padding-left:22dp;border-color:#a5e2cf66;background-color:#a5e2cf1a;}
|
||||
.files-views .files-entry-icon {width:42dp;height:42dp;line-height:1.2;margin-right:22dp;border:0dp;border-radius:0;}
|
||||
.files-views .files-entry-icon .image-frame {margin:0;}
|
||||
.files-views .files-entry-copy strong {font-size:31dp;margin-bottom:10dp;}
|
||||
.files-views .files-entry-copy>span {font-size:22dp;line-height:1.3;color:var(--muted);opacity:1;}
|
||||
.files-standard-badge {flex-shrink:0;font-size:19dp;border:2dp var(--border);border-radius:10dp;padding:7dp 10dp;margin-left:14dp;color:var(--muted);}
|
||||
.files-views .files-heading {font-size:46dp;margin:0 0 18dp;}
|
||||
.files-views .files-intro {font-size:29dp;line-height:1.4;color:var(--muted);opacity:1;margin:0 0 36dp;}
|
||||
.files-views .files-name-label {margin:70dp 0 50dp;}
|
||||
.files-views .files-name-label input {height:104dp;padding:24dp 28dp;font-size:34dp;margin-top:18dp;border-radius:16dp;}
|
||||
.files-views .files-save-illustration {display:flex;flex-direction:column;align-items:center;justify-content:center;gap:42dp;min-height:570dp;padding:60dp;border:2dp var(--border);border-radius:24dp;background-color:var(--soft);opacity:1;}
|
||||
.files-views .files-save-illustration .image-frame {margin:0;}
|
||||
.files-views .files-save-illustration p {max-width:760dp;margin:0;font-size:31dp;line-height:1.5;color:var(--muted);}
|
||||
.files-views .files-metadata {gap:30dp 46dp;margin:40dp 0 0;padding:30dp;border:2dp var(--border);border-radius:20dp;background-color:var(--soft);}
|
||||
.files-views .files-metadata-cell {padding:0;border:0dp;border-radius:0;background-color:transparent;}
|
||||
.files-views .files-metadata-cell span {font-size:25dp;color:var(--muted);opacity:1;margin-bottom:10dp;}
|
||||
.files-views .files-metadata-cell strong {font-size:32dp;}
|
||||
.files-view-record-actions {display:flex;gap:18dp;margin-right:20dp;}
|
||||
.silver .files-views .files-entry.selected {border-color:#235e7866;background-color:#235e781a;}
|
||||
.matchday .files-views .files-entry.selected {border-color:#f1a99e66;background-color:#f1a99e1a;}
|
||||
/* Component paint follows Gold's menu-themes.css; geometry stays shared. */
|
||||
.silver .files-browser-header {border-bottom-color:#6c879c4a;}
|
||||
.silver .files-browser-header>span {background-color:#42627d09;}
|
||||
.silver .files-entry {border-bottom-color:#6c879c28;}
|
||||
.silver .files-entry-icon {border-color:#6c879c4a;}
|
||||
.silver .files-metadata-cell {border-color:#6c879c4a;background-color:#42627d09;}
|
||||
.silver .files-feedback {color:#25617a;}
|
||||
.silver .files-entry.selected,.silver .files-entry.selected:hover {background-color:#a3c3dd54;border-left-color:#a9dccb;color:#193b52;}
|
||||
.silver .files-entry:hover {background-color:#9eb9d43b;}
|
||||
.silver .files-error {color:#a23f45;}
|
||||
.matchday .files-browser-header {border-bottom-color:#ead9da29;}
|
||||
.matchday .files-browser-header>span {background-color:#f8e7e00a;}
|
||||
.matchday .files-entry {border-bottom-color:#ead9da16;}
|
||||
.matchday .files-entry-icon {border-color:#ead9da29;}
|
||||
.matchday .files-metadata-cell {border-color:#ead9da29;background-color:#f8e7e00a;}
|
||||
.matchday .files-entry.selected,.matchday .files-entry.selected:hover {background-color:#d48c7b26;color:#ffe5de;}
|
||||
.matchday .files-entry:hover {background-color:#d5b3b423;}
|
||||
.matchday .files-feedback {color:#efb2aa;}
|
||||
.matchday .files-error {color:#f0a6a7;}
|
||||
.silver .files-views .files-browser-header>span,.matchday .files-views .files-browser-header>span {background-color:transparent;}
|
||||
.silver .files-views .files-entry,.matchday .files-views .files-entry {border-color:transparent;}
|
||||
.silver .files-views .files-entry.selected {border-color:#235e7866;background-color:#235e781a;}
|
||||
.matchday .files-views .files-entry.selected {border-color:#f1a99e66;background-color:#f1a99e1a;}
|
||||
.silver .files-views .files-metadata-cell,.matchday .files-views .files-metadata-cell {background-color:transparent;}
|
||||
.files-empty-details {position:absolute;left:40dp;right:40dp;top:50%;transform:translateY(-50%);padding:0;}
|
||||
.files-empty-details>.image-frame {margin:0 auto 36dp;}
|
||||
@@ -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="M12 3l10 18H2zM12 9v5M12 17v1"/></svg>
|
||||
|
After Width: | Height: | Size: 250 B |
@@ -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="M3 7h7l3 3h8v11H3zM3 7V4h7l3 3h7v3"/></svg>
|
||||
|
After Width: | Height: | Size: 255 B |
@@ -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="M3 3h7v7H3zM14 3h7v7h-7zM3 14h7v7H3zM14 14h7v7h-7z"/></svg>
|
||||
|
After Width: | Height: | Size: 271 B |
@@ -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="M3 3h18v18H3zM3 17l6-7 5 5 3-3 4 5M15 7h1"/></svg>
|
||||
|
After Width: | Height: | Size: 262 B |
@@ -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="M12 4v16M4 12h16"/></svg>
|
||||
|
After Width: | Height: | Size: 237 B |
@@ -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="M12 2v10M6 5a9 9 0 1 0 12 0"/></svg>
|
||||
|
After Width: | Height: | Size: 248 B |
@@ -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="M3 6h18v5a2 2 0 0 0 0 4v5H3v-5a2 2 0 0 0 0-4zM15 6v3M15 12v3M15 18v2"/></svg>
|
||||
|
After Width: | Height: | Size: 289 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"/><link type="text/rcss" href="statistics.rcss"/><link type="text/rcss" href="news.rcss"/><link type="text/rcss" href="settings.rcss"/></head>
|
||||
<link type="text/rcss" href="bank.rcss"/><link type="text/rcss" href="contracts.rcss"/><link type="text/rcss" href="amount.rcss"/><link type="text/rcss" href="environment.rcss"/><link type="text/rcss" href="advertising.rcss"/><link type="text/rcss" href="toto.rcss"/><link type="text/rcss" href="lineup.rcss"/><link type="text/rcss" href="transfer.rcss"/><link type="text/rcss" href="career_reports.rcss"/><link type="text/rcss" href="rankings.rcss"/><link type="text/rcss" href="stadium.rcss"/><link type="text/rcss" href="statistics.rcss"/><link type="text/rcss" href="news.rcss"/><link type="text/rcss" href="settings.rcss"/><link type="text/rcss" href="widgets.rcss"/><link type="text/rcss" href="files.rcss"/></head>
|
||||
<body class="midnight">
|
||||
<div id="background"></div>
|
||||
<div id="canvas"></div>
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-only */
|
||||
.info-bar {z-index:1000;}
|
||||
.desk-card {cursor:pointer;}
|
||||
.desk-card:focus-visible {border-color:var(--accent);}
|
||||
.desk-card-heading {height:70dp;display:flex;align-items:center;justify-content:space-between;gap:20dp;padding:22dp 30dp 12dp;font-size:25dp;line-height:1.2;color:var(--muted);}
|
||||
.desk-card-heading>span {display:block;min-width:0;flex:1;white-space:nowrap;overflow:hidden;}
|
||||
.desk-card-heading>.image-frame {flex-shrink:0;}
|
||||
.desk-calendar-month {position:absolute;left:0;right:0;top:0;height:116dp;background-color:#a45254;color:#fff4ee;display:flex;align-items:center;justify-content:center;font-size:38dp;}
|
||||
body.silver .desk-calendar-month {background-color:#b76264;}body.matchday .desk-calendar-month {background-color:#a24143;}
|
||||
.desk-calendar-body {position:absolute;left:0;right:0;top:116dp;bottom:90dp;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8dp;}
|
||||
.desk-calendar-body>span {display:block;font-size:38dp;color:var(--muted);}
|
||||
.desk-calendar-body>strong {display:block;font-size:240dp;line-height:1.02;font-weight:normal;letter-spacing:-14dp;}
|
||||
.desk-calendar-body>small {display:block;font-size:27dp;color:var(--muted);}
|
||||
.desk-calendar-foot {position:absolute;left:0;right:0;bottom:0;height:90dp;display:flex;align-items:center;gap:18dp;border-top:2dp var(--border);padding:18dp 28dp;color:var(--muted);font-size:25dp;}
|
||||
.desk-calendar-foot>span {display:block;flex-shrink:0;}.desk-calendar-foot .calendar-arrow {margin-left:auto;}
|
||||
[data-widget=calendar][data-size=s] .desk-calendar-month {height:82dp;font-size:29dp;}
|
||||
[data-widget=calendar][data-size=s] .desk-calendar-body {top:82dp;bottom:60dp;gap:0;}
|
||||
[data-widget=calendar][data-size=s] .desk-calendar-body>span {font-size:29dp;}
|
||||
[data-widget=calendar][data-size=s] .desk-calendar-body>strong {font-size:140dp;letter-spacing:-6dp;}
|
||||
[data-widget=calendar][data-size=s] .desk-calendar-body>small {font-size:20dp;}
|
||||
[data-widget=calendar][data-size=s] .desk-calendar-foot {height:60dp;font-size:20dp;gap:10dp;padding:8dp 18dp;}
|
||||
.desk-account-main {padding:16dp 34dp 20dp;display:flex;flex-direction:column;gap:10dp;}
|
||||
.desk-account-main>span {display:block;font-size:25dp;color:var(--muted);}
|
||||
.desk-account-main>strong {display:block;font-size:65dp;letter-spacing:-2dp;font-weight:normal;line-height:1.1;color:var(--accent);}
|
||||
.desk-account-bottom {position:absolute;bottom:0;left:0;right:0;height:132dp;display:flex;align-items:center;justify-content:space-between;gap:30dp;padding:20dp 34dp;border-top:2dp var(--border);background-color:var(--soft);}
|
||||
.desk-account-bottom>div {display:flex;flex-direction:column;gap:8dp;}
|
||||
.desk-account-bottom span {display:block;font-size:24dp;color:var(--muted);}
|
||||
.desk-account-bottom strong {display:block;font-size:34dp;font-weight:normal;color:var(--text);}
|
||||
.desk-account-bottom button {display:flex;align-items:center;justify-content:flex-start;gap:20dp;padding:10dp 20dp;border:0dp;border-radius:18dp;background-color:var(--soft);text-align:left;}
|
||||
.desk-account-bottom button>span {display:flex;flex-direction:column;gap:4dp;}
|
||||
[data-widget=account][data-size=s] .desk-account-main>strong {font-size:48dp;}
|
||||
[data-widget=account][data-size=s] .desk-account-bottom {gap:12dp;padding:16dp 24dp;}
|
||||
[data-widget=account][data-size=s] .desk-account-bottom button>.image-frame {display:none;}
|
||||
[data-widget=account][data-size=s] .desk-account-bottom strong {font-size:28dp;}
|
||||
.desk-fixture {position:absolute;left:22dp;right:22dp;top:76dp;bottom:24dp;display:flex;align-items:center;justify-content:space-between;gap:18dp;text-align:center;}
|
||||
.desk-fixture>div {display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8dp;min-width:0;flex:1;}
|
||||
.desk-fixture>div.desk-fixture-centre {flex:1.25;}
|
||||
.desk-fixture>div>span {display:block;font-size:23dp;white-space:nowrap;max-width:100%;overflow:hidden;}
|
||||
.desk-fixture-centre>small {display:block;font-size:24dp;color:var(--muted);}
|
||||
.desk-fixture-centre>strong {display:block;font-size:54dp;font-weight:normal;}
|
||||
.desk-fixture-centre>span {color:var(--muted);}
|
||||
[data-widget=competition][data-size=s] .desk-fixture {gap:4dp;left:14dp;right:14dp;}
|
||||
[data-widget=competition][data-size=s] .desk-fixture>div>span {font-size:18dp;}
|
||||
[data-widget=competition][data-size=s] .desk-fixture-centre>strong {font-size:40dp;}
|
||||
[data-widget=competition][data-size=s] .desk-fixture-centre>small {font-size:20dp;}
|
||||
.desk-portrait-caption {position:absolute;bottom:0;left:0;right:0;display:flex;flex-direction:column;gap:8dp;padding:48dp 30dp 28dp;decorator:linear-gradient(0deg,#0d1928ed,#0d19287a,#0d192800);color:#eff4f8;}
|
||||
.desk-portrait-caption small,.desk-logo-caption small {display:block;opacity:0.72;font-size:24dp;}
|
||||
.desk-portrait-caption strong {display:block;font-size:34dp;font-weight:bold;overflow:hidden;white-space:nowrap;}
|
||||
.desk-logo-surface {position:absolute;left:24dp;right:24dp;top:28dp;bottom:110dp;display:flex;align-items:center;justify-content:center;}
|
||||
.desk-logo-caption {position:absolute;left:20dp;right:20dp;bottom:30dp;text-align:center;display:flex;flex-direction:column;gap:10dp;}
|
||||
.desk-logo-caption strong {display:block;font-size:28dp;font-weight:normal;}
|
||||
.desk-warning-grid {position:absolute;left:0;right:0;top:76dp;bottom:0;}
|
||||
.desk-warning {position:absolute;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:7dp;padding:0;border:0dp;background-color:transparent;}
|
||||
.status-lamp {position:relative;display:flex;align-items:center;justify-content:center;width:64dp;height:64dp;flex-shrink:0;border-radius:32dp;border:2dp #9ddbc653;decorator:linear-gradient(145deg,#8acbb5,#40776c);color:#edfff6;}
|
||||
.status-lamp.attention {decorator:linear-gradient(145deg,#e0a28d,#aa514d);border-color:#f6bea18c;}
|
||||
.warning-caption {display:block;font-size:18dp;color:var(--muted);max-width:100%;white-space:nowrap;overflow:hidden;}
|
||||
[data-widget=warnings][data-size=s] .warning-caption {font-size:13dp;}
|
||||
[data-widget=warnings][data-size=l] .warning-caption {font-size:25dp;}
|
||||
[data-widget=warnings][data-size=l] .status-lamp {width:90dp;height:90dp;border-radius:45dp;}
|
||||
.desk-mood {position:absolute;left:30dp;right:30dp;top:70dp;bottom:22dp;display:flex;gap:22dp;align-items:center;}
|
||||
.desk-mood>div {flex:1;min-width:100dp;}.desk-mood strong {display:block;font-size:42dp;font-weight:normal;}.desk-mood small {font-size:27dp;}
|
||||
.desk-mood>span {display:block;font-size:24dp;color:var(--muted);}
|
||||
.mood-track {position:relative;display:block;margin-top:14dp;height:14dp;border-radius:7dp;background-color:var(--soft);}
|
||||
.mood-track i {display:block;height:100%;border-radius:7dp;background-color:var(--accent);}
|
||||
.desk-curve-picture {position:relative;margin:0 21dp;}.desk-curve-picture>.image-frame {position:absolute;left:0;top:0;}
|
||||
.curve-start,.curve-end {position:absolute;bottom:0;display:block;font-size:22dp;color:var(--muted);}.curve-start {left:3%;}.curve-end {right:3%;}
|
||||
.desk-curve-legend {height:110dp;padding:16dp 30dp 26dp;display:flex;align-items:center;justify-content:center;flex-wrap:wrap;gap:14dp 28dp;font-size:24dp;line-height:1.25;}
|
||||
.desk-curve-legend>span {display:flex;align-items:center;gap:12dp;min-width:0;}.desk-curve-legend span>span {display:block;min-width:0;}
|
||||
.desk-curve-legend i {display:block;width:40dp;border-top:5dp var(--accent);flex-shrink:0;}
|
||||
.desk-curve-legend .curve-opponent i {border-top-color:#f2b286;}body.silver .desk-curve-legend .curve-opponent i {border-top-color:#a04b30;}body.matchday .desk-curve-legend .curve-opponent i {border-top-color:#91cce8;}
|
||||
.desk-summary {position:absolute;left:0;right:0;top:70dp;bottom:10dp;display:flex;align-items:center;text-align:center;}
|
||||
.desk-summary>div {display:flex;flex-direction:column;gap:6dp;flex:1;}.desk-summary small {display:block;font-size:23dp;color:var(--muted);}.desk-summary strong {display:block;font-size:46dp;font-weight:normal;}.desk-summary>div+div {border-left:2dp var(--border);}
|
||||
.desk-form {position:absolute;left:24dp;right:24dp;top:90dp;bottom:54dp;display:flex;align-items:center;justify-content:space-evenly;gap:12dp;}
|
||||
.desk-form>div {display:flex;flex-direction:column;align-items:center;gap:18dp;}.desk-form>div>span {display:flex;align-items:center;justify-content:center;border-radius:100dp;color:#f3f7f8;background-color:#587588;flex-shrink:0;}
|
||||
.desk-form>div>span>span {display:block;}.desk-form .form-S {background-color:#527f73;}.desk-form .form-N {background-color:#a96059;}.desk-form strong {display:block;font-weight:normal;}
|
||||
.desk-card-note {position:absolute;left:24dp;right:24dp;bottom:22dp;text-align:center;font-size:25dp;color:var(--muted);}
|
||||
.desk-duels {position:absolute;left:20dp;right:20dp;top:70dp;bottom:24dp;display:flex;align-items:center;text-align:center;}
|
||||
.desk-duels>div {display:flex;flex-direction:column;align-items:center;gap:10dp;flex:1;}.desk-duels strong {display:block;font-size:56dp;line-height:1;font-weight:normal;}.desk-duels small {display:block;font-size:20dp;color:var(--muted);}
|
||||
.desk-card.desk-utility {border:0dp;border-radius:0dp;decorator:none;backdrop-filter:none;overflow:visible;display:flex;flex-direction:column;align-items:center;gap:12dp;color:#f1f6f9;}
|
||||
.desktop-utility-icon {height:178dp;width:80%;display:flex;align-items:center;justify-content:center;border:2dp #c5d9ed59;border-radius:28dp;decorator:linear-gradient(135deg,#dce5ef40,#829bb12b);}
|
||||
.desk-utility>strong {display:block;font-size:23dp;font-weight:normal;}
|
||||
[data-size=wide] .desk-card-heading {height:54dp;padding:16dp 26dp 8dp;font-size:23dp;}
|
||||
[data-widget=account][data-size=wide] .desk-account-main {position:absolute;left:0;top:54dp;bottom:0;width:48%;padding:10dp 24dp 18dp;justify-content:center;}
|
||||
[data-widget=account][data-size=wide] .desk-account-main>strong {font-size:43dp;white-space:nowrap;}
|
||||
[data-widget=account][data-size=wide] .desk-account-bottom {left:48%;top:54dp;height:auto;gap:16dp;padding:12dp 24dp 18dp;border-top:0dp;border-left:2dp var(--border);background-color:transparent;}
|
||||
[data-widget=account][data-size=wide] .desk-account-bottom strong {font-size:29dp;}
|
||||
[data-widget=account][data-size=wide] .desk-account-bottom button {padding:10dp 14dp;gap:12dp;}
|
||||
[data-widget=warnings][data-size=wide] .desk-warning-grid {top:54dp;}
|
||||
[data-widget=results][data-size=wide] .desk-form {top:56dp;bottom:20dp;gap:12dp;}
|
||||
[data-widget=results][data-size=wide] .desk-form>div {flex-direction:row;gap:12dp;}
|
||||
.desktop-window {position:absolute;border-radius:36dp;background-color:var(--strong);decorator:none;backdrop-filter:blur(50dp);}
|
||||
.desktop-window-titlebar {position:absolute;left:0;right:0;top:0;height:108dp;display:flex;align-items:center;padding:0 28dp;border-bottom:2dp var(--border);background-color:var(--soft);}
|
||||
.desktop-window-titlebar h1 {position:absolute;left:104dp;right:104dp;text-align:center;margin:0;font-size:40dp;font-weight:bold;}
|
||||
.desktop-window-close {width:52dp;height:52dp;padding:0;border:2dp #ffaba359;border-radius:26dp;background-color:#f17d73;color:#542622;font-size:36dp;}
|
||||
.desktop-window-content {position:absolute;left:52dp;right:52dp;top:148dp;bottom:154dp;}
|
||||
.desktop-window-footer {position:absolute;left:0;right:0;bottom:0;height:116dp;padding:18dp 46dp;display:flex;align-items:center;gap:22dp;border-top:2dp var(--border);background-color:var(--soft);}
|
||||
.desktop-window-footer>p {display:block;flex:1;min-width:0;font-size:26dp;color:var(--muted);line-height:1.35;}
|
||||
.desktop-window-footer button {height:76dp;font-size:31dp;padding:18dp 30dp;}
|
||||
.modern-gallery-toolbar {height:122dp;display:flex;align-items:center;justify-content:space-between;gap:30dp;}.modern-gallery-toolbar>p {font-size:42dp;margin:0;}
|
||||
.modern-search {display:flex;align-items:center;gap:16dp;border:2dp var(--border);border-radius:18dp;background-color:var(--soft);padding:16dp 22dp;width:660dp;}
|
||||
.modern-search input {border:0dp;background-color:transparent;width:100%;min-width:0;flex:1;font-size:30dp;}
|
||||
.modern-widget-gallery {position:absolute;left:0;right:0;top:146dp;bottom:0;overflow:auto;}
|
||||
.widget-gallery-item {position:absolute;width:784dp;height:660dp;padding:24dp;border:2dp var(--border);border-radius:26dp;background-color:var(--soft);}
|
||||
.gallery-widget-preview {position:relative;width:100%;height:320dp;overflow:hidden;background-color:var(--soft);border-radius:18dp;}
|
||||
.gallery-preview-card {position:absolute;transform-origin:50% 50%;pointer-events:none;backdrop-filter:none;}
|
||||
.gallery-description {padding:22dp 6dp 16dp;}.gallery-description>small {display:block;font-size:21dp;color:var(--muted);}.gallery-description h2 {font-size:31dp;font-weight:bold;margin:10dp 0;}.gallery-description p {font-size:24dp;color:var(--muted);margin:0;line-height:1.3;}
|
||||
.gallery-actions {position:absolute;left:24dp;right:24dp;bottom:24dp;display:flex;align-items:center;justify-content:space-between;gap:14dp;}
|
||||
.gallery-actions select {width:200dp;font-size:25dp;padding:14dp 18dp;height:64dp;}
|
||||
.gallery-actions button {display:flex;align-items:center;justify-content:center;gap:12dp;width:420dp;padding:14dp 18dp;font-size:25dp;height:64dp;}
|
||||
.gallery-actions button>span {display:block;flex-shrink:0;}
|
||||
.widget-gallery-empty {padding:180dp 50dp;text-align:center;font-size:34dp;color:var(--muted);}
|
||||
.modern-intro {text-align:center;font-size:45dp;margin:0 0 60dp;}
|
||||
.background-choice {position:relative;width:100%;display:block;text-align:left;padding:0;overflow:hidden;border-radius:26dp;}
|
||||
.background-choice>span {display:flex;flex-direction:column;gap:14dp;padding:30dp 36dp;}
|
||||
.background-choice strong {display:block;font-size:38dp;}.background-choice small {display:block;font-size:27dp;color:var(--muted);}.background-choice>i {position:absolute;right:44dp;bottom:138dp;}
|
||||
.background-note {text-align:center;font-size:28dp;color:var(--muted);margin-top:36dp;}
|
||||
.desktop-message {position:absolute;left:48dp;right:48dp;top:8dp;bottom:16dp;display:flex;flex-direction:column;align-items:center;justify-content:center;}
|
||||
.desktop-warning-symbol {width:150dp;height:150dp;display:flex;align-items:center;justify-content:center;border:2dp var(--border);border-radius:38dp;background-color:var(--soft);margin-bottom:40dp;}
|
||||
.desktop-message h2 {font-size:46dp;font-weight:bold;margin:0 0 25dp;text-align:center;}
|
||||
.desktop-message p {font-size:32dp;color:var(--muted);line-height:1.6;text-align:center;max-width:1250dp;}
|
||||
#desktop-context {width:270px;padding:6px;border:1px #cadce440;border-radius:12px;background-color:#263442f7;color:#e9eff4;font-size:14px;}
|
||||
body.silver #desktop-context {background-color:#edf3f8f7;color:#263d50;border-color:#ffffff99;}body.matchday #desktop-context {background-color:#282b30fa;}
|
||||
#desktop-context button {display:flex;align-items:center;gap:12px;width:100%;height:41px;padding:11px 12px;border:0px;border-radius:7px;background-color:transparent;text-align:left;font-size:14px;}
|
||||
#desktop-context button>span {display:block;flex-shrink:0;}
|
||||
#desktop-context .context-label {padding:12px 12px 3px;font-size:11px;color:#a6b6c4;border-top:1px #ffffff22;margin-top:6px;}
|
||||
.desktop-grid-dot {position:absolute;width:4dp;height:4dp;background-color:#d9eff21f;border-radius:2dp;pointer-events:none;}
|
||||
.desktop-layer {position:absolute;left:0;top:0;width:3840dp;height:2160dp;z-index:1;}
|
||||
.desk-calendar-month>span {display:block;flex-shrink:0;}
|
||||
.desk-fixture>div>span,.warning-caption {width:100%;flex-shrink:0;}
|
||||
.desktop-window-titlebar h1 {top:0;bottom:0;display:flex;align-items:center;justify-content:center;}
|
||||
.desktop-window-titlebar h1>span {display:block;flex-shrink:0;}
|
||||
.desktop-modal-layer {background-color:#06101c80;}
|
||||
.desktop-window-content {overflow:hidden;}
|
||||
.background-choice>i {display:block;width:48dp;height:48dp;z-index:2;}
|
||||
.desk-mood>.image-frame {flex:0;min-width:36dp;}
|
||||
.modern-widget-gallery {height:1392dp;max-height:1392dp;overflow-x:hidden;overflow-y:auto;}
|
||||
#desktop-context button:focus-visible {background-color:#95bfd52b;}
|
||||
.desktop-app:focus-visible .app-tile {border-color:var(--accent);}
|
||||
.gallery-preview-card button:disabled {opacity:1;}
|
||||
#desktop-context .context-check {margin-left:auto;}
|
||||
@@ -1,6 +1,6 @@
|
||||
# Native Modern UI · erster Umsetzungsstand
|
||||
|
||||
Stand: 25. Oktober 2026. **Experimenteller RmlUI-Unterbau und erster
|
||||
Stand: 26. Oktober 2026. **Experimenteller RmlUI-Unterbau und erster
|
||||
bedienbarer Durchlauf. Noch keine vollständige Umsetzung des HTML-Mockups.**
|
||||
Die normale Classic-Konfiguration bleibt unverändert; die neue Oberfläche
|
||||
wird ausdrücklich mit `OPENBMH_BUILD_MODERN_UI=ON` gebaut.
|
||||
@@ -21,13 +21,15 @@ wird ausdrücklich mit `OPENBMH_BUILD_MODERN_UI=ON` gebaut.
|
||||
und Übersicht; in dieser Folge gibt es keinen Schließen-Knopf.
|
||||
- Desktop mit Statusleiste, Buttons, fixierter Standardanordnung, Raster und
|
||||
freiem Verschieben, Rechtsklickmenü, gemeinsamer Fixierung, Rückgängig,
|
||||
Widgetauswahl und den vorgesehenen Widgetgrößen. Kurven-/Statistikinhalte
|
||||
und die Widgetvorschauen benötigen noch den detaillierten Mockup-Abgleich.
|
||||
[vollständigem Widgetkatalog](desktop/widgets/README.md), Größenwahl und
|
||||
echten Vorschauen. Kurven, Form, direkte Duelle und Platz-/Stärkewidgets
|
||||
verwenden die vorgegebenen HTML-Pseudodaten; Warnlampen lesen gemeinsame UI-Werte.
|
||||
- Eintrittspreis-Popover: 330 × 196 Punkte, Entwurf, gesonderte Bestätigung,
|
||||
Abbrechen, Fehler-/Revisionsschutz und Tastaturbedienung.
|
||||
- Trainingslager: drei Karten, 18 Angebote, eigene GUI-Bilder und lokale
|
||||
Vormerkung. Speichern/Laden sind als erste native Ansichten vorhanden;
|
||||
ihr vollständiger Bedienungsabgleich bleibt offen.
|
||||
Vormerkung. [Speichern/Laden](desktop/save-load/README.md) zeigen tatsächliche
|
||||
Dateimetadaten, getrennte Ansichts- und Karrierebibliotheken, Import/Export
|
||||
sowie bestätigtes Umbenennen, Löschen und Überschreiben.
|
||||
- Separate UI-Demostände und Desktopansichten. Ansichten speichern zusätzlich
|
||||
einen Screenshot; die Standardansicht kann nicht gelöscht werden.
|
||||
- [Training](desktop/training/README.md): neun Übungen, vier Arten, Kader mit
|
||||
@@ -136,8 +138,7 @@ 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.
|
||||
Die vollständigen Widgetinhalte und der Mod-Importkomfort sind noch nicht
|
||||
vollständig. Bildschirmkonfiguration und Audioausgabe benötigen noch die
|
||||
Der Mod-Importkomfort ist noch nicht vollständig. Bildschirmkonfiguration und Audioausgabe benötigen noch die
|
||||
Plattform-/Engine-Anbindung der nun gespeicherten UI-Voreinstellungen. Übersetzungen, echte Engine-Anbindung und Plattform-Abnahme
|
||||
unter Windows/macOS folgen später. Dies ist kein freigegebenes Test-Release.
|
||||
Die [QA-Befundliste](qa-findings.md) hält die noch offenen Abweichungen nach.
|
||||
@@ -178,7 +179,7 @@ Quellcode verteilt. Ohne externe GUI-Ressourcen kann das Hauptmenü den bereits
|
||||
mitgelieferten Launcher-Hintergrund verwenden.
|
||||
|
||||
Entwicklungsoptionen: `--gui-assets`, `--ui-scene`, `--ui-theme`, `--ui-size`,
|
||||
`--ui-state`, `--ui-preferences`, `--ui-screenshot` und `--ui-script`. Das zeilenweise JSON-
|
||||
`--ui-state`, `--ui-userdata`, `--ui-preferences`, `--ui-file-import`, `--ui-file-export`, `--ui-screenshot` und `--ui-script`. Das zeilenweise JSON-
|
||||
Eingabeskript führt Maus-/Tastaturaktionen durch RmlUI aus; es ersetzt keine
|
||||
Sessionaktionen durch direkte Zustandsmanipulation. `checkpoint` schreibt einen
|
||||
wiederherstellbaren Demostand passend zu den Bildschirmaufnahmen.
|
||||
|
||||
@@ -14,6 +14,8 @@ Implementierung in der Spiel-Engine.
|
||||
| QA-Befunde | [Offene Abweichungen zur HTML-Referenz](qa-findings.md) |
|
||||
| Ressourcen | [GUI-Assets, Weltbilder und spätere Paketbereinigung](assets.md) |
|
||||
| Desktop | [Statusleiste, Gestaltung und Fenster](desktop/README.md) |
|
||||
| Widgets | [17 Typen, 48 Größen, Raster, Fixierung und Arbeitsanordnung](desktop/widgets/README.md) |
|
||||
| Dateiverwaltung | [Spielstände und Desktopansichten mit Vorschauen](desktop/save-load/README.md) |
|
||||
| Eintrittspreis | [Kompakter Schieberegler im Konto-Widget](desktop/entry-price/README.md) |
|
||||
| Trainingslager | [Alle 18 Angebote, Qualitätswerte und Bedienung](desktop/trainingcamp/README.md) |
|
||||
| Training | [Übungen, Kader, Intensität und Demo-Automatik](desktop/training/README.md) |
|
||||
|
||||
@@ -80,3 +80,10 @@ Privates Repository `bmh_4k_ui`, Commit `19969d430e38eadae7ff7a9d1fb381ab02c395d
|
||||
[Transfers: Ablöse-Kasten und Abstand der Positionsfilter](transfers/README.md).
|
||||
|
||||
[Eintrittspreis: kompakter Schieberegler mit Bestätigung](entry-price/README.md).
|
||||
|
||||
## Native Umsetzung
|
||||
|
||||
Die [Widgetdokumentation](widgets/README.md) beschreibt den nativen Katalog,
|
||||
Raster und Arbeitsanordnung; die [Dateiverwaltung](save-load/README.md) die
|
||||
getrennten Karriere- und Ansichtsdateien. Beide lesen weiterhin Demodaten und
|
||||
bestätigen keine Engine-Spielbarkeit.
|
||||
@@ -0,0 +1,138 @@
|
||||
<!-- SPDX-License-Identifier: GPL-3.0-only -->
|
||||
# Speichern, Laden und Desktopansichten
|
||||
|
||||
Die native RmlUI-Fassung überträgt den privaten HTML-Goldstand der Dateien
|
||||
`desktop/save-load-menu.js`, `desktop/save-load-window.css`,
|
||||
`desktop/modern-dialogs.js` und `desktop/desktop-views.js`. Referenzrevision:
|
||||
`4b1c3b61ccd7b19351cd0b2dfac1006918103c97`. Die Referenz bleibt privat und
|
||||
unverändert; diese öffentliche Implementierung enthält keine Originalgrafiken
|
||||
oder Originalspielstände. Ausgangsstand der nativen Umsetzung ist `db89d88`.
|
||||
|
||||
## Sichtbare Ansichten
|
||||
|
||||
Spielstände verwenden den gemeinsamen Untermenürahmen mit 2720 × 2040
|
||||
Entwurfseinheiten. Die Desktopansichten verwenden das eigenständige
|
||||
Desktopdialogfenster mit 2560 × 1840 Einheiten. Beide haben eine unbegrenzt
|
||||
scrollbare Liste, eine getrennte Detailansicht und bestätigte Aktionen für
|
||||
Überschreiben, Umbenennen und Löschen. „Neuer Speicherstand“ beziehungsweise
|
||||
„Neue Ansicht“ erscheint nur beim Speichern. Fehlende oder beschädigte Dateien
|
||||
bleiben mit einer Fehlermeldung erkennbar.
|
||||
|
||||
Die Karriereübersicht zeigt Saison, Spieltag, Spieldatum, Manager und Vereine
|
||||
aus dem ausgewählten Dokument. Nur ein neuer Eintrag zeigt die aktuelle
|
||||
Karriere. Die Demo befindet sich ohne gesonderte gespeicherte
|
||||
`game_info.matchday`-Angabe in der Vorbereitung; hier wird kein zukünftiger
|
||||
Engine-Spieltag erfunden. Die Saison folgt dem gespeicherten Spieldatum und
|
||||
beginnt im Juli. Speicherdatum, Dateigröße und Änderungsdatum stammen aus dem
|
||||
Dateianbieter. Namen werden vor der Anzeige als RmlUI-Text maskiert.
|
||||
|
||||
Die Ansicht „Standard“ ist eine unveränderliche, immer verfügbare Vorlage.
|
||||
Sie verwendet beim Laden den aktuellen Look. Ihre Vorschau wird unmittelbar
|
||||
aus der Standardgeometrie gezeichnet; sie ist kein Screenshot einer heimlich
|
||||
auf die aktive Karriere angewendeten Ansicht. Eigene Ansichten enthalten den
|
||||
tatsächlichen Desktop-Screenshot zum Speicherzeitpunkt sowie Anordnung,
|
||||
Widgetgrößen, Sichtbarkeit, Fixierungen und Look. Der Screenshot entsteht ohne
|
||||
Dateidialog und ohne das darüberliegende Verwaltungsfenster.
|
||||
|
||||
## Lokale Dateitransaktionen
|
||||
|
||||
`DemoFiles` speichert ausschließlich UI-Demostände; es liest und schreibt keine
|
||||
OBS-/Engine-Karriere. Die Ablage liegt unter dem weltbezogenen
|
||||
`userdata/ui-demo/<world-hash>/saves` beziehungsweise `layouts`. Der explizite
|
||||
Parameter `--ui-userdata` erlaubt eine vollständig isolierte QA-Ablage.
|
||||
Globale Anzeige-, Sound- und Themenpräferenzen bleiben in ihrer eigenen Datei.
|
||||
|
||||
Ein Datensatz ist ein Dokument mit Schema `openbmh-ui-file@1`. Es enthält
|
||||
Bezeichnung, Art, Zeitstempel, Payload, Welt-ID, Hash der Weltmanifestrevision,
|
||||
PNG-Vorschau und separate Inhaltsprüfsummen. Die PNG-Bytes werden verlustfrei
|
||||
hexadezimal eingebettet. Deshalb werden Layout und Screenshot mit **einem**
|
||||
atomaren Dateiaustausch veröffentlicht. Die Dateinamen sind opake IDs und
|
||||
werden nicht aus Benutzernamen zusammengesetzt. Eine umbenannte Ansicht
|
||||
behält Identität, ursprünglichen Speicherzeitpunkt und Vorschau.
|
||||
|
||||
Vor der Veröffentlichung werden Karriere und Desktop in isolierten Objekten
|
||||
validiert. Karriereprüfungen nutzen die bestehenden `DemoSource`-Regeln. Die
|
||||
aktive Quelle wird erst nach erfolgreicher Validierung ersetzt. Entwürfe
|
||||
binden sich an Welt, Source-Objekt und Source-Revision. Bestätigungen tragen
|
||||
zusätzlich den SHA-256-Token der ausgewählten Dateiversion. Ein inzwischen
|
||||
geänderter, gelöschter oder fremder Datensatz wird zurückgewiesen.
|
||||
|
||||
Ein kurzlebiges Transaktionsverzeichnis serialisiert Anbieteroperationen.
|
||||
Fehlgeschlagene Schreibvorgänge behalten den bisherigen Datensatz. Löschen
|
||||
verwendet eine atomare Umbenennung; bei einem unterbrochenen Aufräumen bleibt
|
||||
die Datei als versteckter, wiederherstellbarer Rest erhalten. Ein nach einem
|
||||
Prozessabsturz verbliebenes Transaktionsverzeichnis wird nicht ungeprüft
|
||||
entfernt: Nach Beenden aller beteiligten Prozesse muss es geprüft werden.
|
||||
Symlinks und Pfadwechsel aus der Ablage werden zurückgewiesen. Abgeleitete
|
||||
PNG-Vorschaudateien unter `.previews` sind nur ein durch Hash identifizierter
|
||||
Cache; sie sind nie die autoritative gespeicherte Vorschau.
|
||||
|
||||
Namen besitzen 1 bis 64 Unicode-Zeichen und keine Steuerzeichen. Der
|
||||
plattformunabhängige Vergleich berücksichtigt Groß-/Kleinschreibung,
|
||||
deutsches ß, Ö/ö und komponierte/dekomponierte lateinische Tastaturakzente.
|
||||
Ansichten berücksichtigen zusätzlich vollbreite ASCII-Kompatibilitätszeichen;
|
||||
„Standard“ bleibt dabei reserviert. Speichernamen verwenden diesen
|
||||
Kompatibilitätsschritt nicht. Die kleine portable Hilfe ist kein vollständiger
|
||||
Unicode-NFC-/NFKC-Normalisierer: Seltene kombinierte Schriftzeichen außerhalb
|
||||
der dokumentierten lateinischen Akzente bleiben bytegenau unterscheidbar.
|
||||
Diese Grenze betrifft die Namen, nicht die Dateiinhalte oder Spielvalidierung.
|
||||
|
||||
Ältere rohe Demo-JSON-Spielstände und Layoutdateien werden gelesen, aber beim
|
||||
Navigieren nicht umgeschrieben. Vorhandene PNG-Seitendateien können in ein
|
||||
neues konsistentes Dokument übernommen werden. Alte Ansichten ohne Vorschau
|
||||
zeigen einen ausdrücklichen Hinweis; vor der Veröffentlichung einer neuen
|
||||
Ansichtsdatei ist eine gültige Vorschau erforderlich.
|
||||
|
||||
## Aktionen und Zustandsgrenzen
|
||||
|
||||
Import und Export sind ausdrückliche Buttonaktionen. Erst dann öffnet NFD
|
||||
einen Betriebssystemdialog. QA kann mit `--ui-file-import` und
|
||||
`--ui-file-export` konkrete Pfade bereitstellen; die Parameter lösen allein
|
||||
keine Dateiaktion aus. Import validiert das Dokument vollständig und legt
|
||||
einen neuen, bei Namenskonflikten umbenannten Eintrag an. Es wird kein
|
||||
bestehender lokaler Stand überschrieben und keine Karriere automatisch
|
||||
geladen. Export enthält Payload und Vorschau gemeinsam; ein vorhandenes
|
||||
Ziel benötigt eine separate Überschreibbestätigung.
|
||||
|
||||
Karriere-Save setzt Source und Karriere-Desktop erst nach erfolgreicher
|
||||
Veröffentlichung auf „gespeichert“. Karriere-Load setzt den ausgewählten
|
||||
validierten Stand samt Layout auf „gespeichert“. Ansichts-Save verändert diese
|
||||
Karrieremarkierungen nicht. Ansichts-Load erzeugt einen Desktop-Undo-Schritt,
|
||||
speichert die globale Themenpräferenz zuerst und übernimmt anschließend
|
||||
Layout und Look. Andere Anzeige- oder Soundwerte werden dabei nicht aus dem
|
||||
Spielstand übernommen.
|
||||
|
||||
Die Root-Glue-Hooks `files_saved_success(bool)` und `files_loaded_success()`
|
||||
verantworten den Rücksprung ins Hauptmenü, die Fortsetzung eines bestätigten
|
||||
Beenden-Ablaufs und das Zurücksetzen sourceabhängiger Presenter. Abbrechen
|
||||
und Escape verwerfen nur lokale Dateifensterentwürfe und die ausstehende
|
||||
Beenden-nach-Speichern-Absicht. Navigation, Auswahl und Vorschau verändern die
|
||||
aktive Karriere nicht.
|
||||
|
||||
## Prüfung und offene Enginefragen
|
||||
|
||||
`tests/modern_files_ui_tests.cpp` verwendet nur eine synthetische Welt und
|
||||
temporäre QA-Dateien. Es prüft Namenskonflikte, atomare Payload-/PNG-Rundläufe,
|
||||
veraltete Tokens, beschädigte Importe, fehlgeschlagene Überschreibungen,
|
||||
Transaktionskonflikte, ausgewählte Dateimetadaten, Exportkollisionen, getrennte
|
||||
UI-Präferenzen und den Rollback fehlgeschlagener Karrierevalidierung.
|
||||
Ein Build und native Screenshot-/Interaktionsprüfungen müssen separat
|
||||
ausgeführt werden; die Testquelle allein belegt kein Plattformverhalten.
|
||||
|
||||
Die spätere Engineanbindung muss den gemeinsamen Karriere-/Sessionanbieter
|
||||
verwenden. OBS-Migration, Managerbesitz, Engine-Revisionen, RNG-Zustände,
|
||||
Autosaves und echte Saisonfortschritte werden hier ausdrücklich nicht als
|
||||
implementiert behauptet. Sie gehören nicht in diesen UI-Demodateianbieter.
|
||||
|
||||
## Bewusste Abgrenzungen zum Browser-POC
|
||||
|
||||
Ansichten und Arbeitsanordnung liegen in dieser nativen Demo im weltbezogenen
|
||||
UI-Verzeichnis; vorhandene ältere native Layouts bleiben so erreichbar. Der
|
||||
Browser-POC speichert diese Bibliothek browserglobal. Anzeige und Sound bleiben
|
||||
nativ unabhängig von der Welt gespeichert. Das Laden einer Karriere setzt
|
||||
diese globalen Präferenzen nicht zurück; eine benannte Ansicht darf dagegen
|
||||
ihre ausdrücklich gespeicherte Gestaltung wiederherstellen.
|
||||
|
||||
Erfolgreiches Speichern und Laden einer Karriere lässt das Dateifenster mit
|
||||
Auswahl und Rückmeldung offen. Ansichts-Speichern und -Laden kehren zum Desktop
|
||||
zurück. Arbeitsanordnungen lösen keinen Spielstand-Speicherbedarf aus.
|
||||
@@ -0,0 +1,54 @@
|
||||
# Desktop und Widgets · native Umsetzung
|
||||
|
||||
Stand: 26. Oktober 2026. Referenz ist der unveränderte private HTML-Goldstand
|
||||
`4b1c3b61`, insbesondere modern-layout.js, modern-desktop.js/.css und
|
||||
modern-dialogs.js. Die bisherige HD-Oberfläche bleibt erhalten.
|
||||
|
||||
Der Desktop enthält 32 Appbuttons und 17 Widgettypen mit insgesamt 48
|
||||
Größenvarianten. Die Standardansicht zeigt acht Widgets; sämtliche Elemente
|
||||
sind zunächst fixiert. Das Raster verwendet 224-Punkte-Zellen, 24 Punkte
|
||||
Abstand und einen Ursprung bei 64/224 im logischen 3840×2160-Raum.
|
||||
Alle drei Themes und der proportional skalierte Desktop bleiben erhalten.
|
||||
|
||||
Kalender, Konto/Eintritt, nächste Begegnung, Managerporträt und Vereinswappen
|
||||
übernehmen die Referenzgeometrie. Warnlampen zeigen zehn Zustände; die breite
|
||||
4×1-Variante fasst Sondertraining/Erschöpfung und Startelf/Ersatzspieler zu
|
||||
acht Lampen zusammen. Sie lassen sich für einen erklärenden Hinweis anklicken.
|
||||
Konto, Werbeverträge, Aktien und Trainings-/Kaderdaten stammen aus dem gemeinsamen
|
||||
UI-Demostand. Fan-Stimmung, Saisonkurven, Form, Platz/Stärke und direkte Duelle
|
||||
bleiben klar benannte Pseudodaten. Diagramme verwenden die Pfade und Werte der
|
||||
HTML-Referenz; sie berechnen keine Ergebnisse oder Tabellenregeln.
|
||||
|
||||
Die Widgetgalerie bietet Vorschauen, Suche und jede freigegebene Größe. Ein
|
||||
hinzugefügtes Widget wird als vorhanden markiert; die Galerie bleibt offen.
|
||||
Im Raster führt Platzmangel zu vollständigem Rollback. Frei platzierte Widgets
|
||||
können sich überlagern. Eine gemeinsame Größenbasis lässt 4×1 und 3×3 exakt an
|
||||
Appbutton-Zellen anschließen. Hintergründe haben einen eigenen Auswahldialog;
|
||||
bisher ist ausschließlich das vorhandene Nachtstadion freigegeben.
|
||||
|
||||
Das Rechtsklickmenü folgt dem Goldlayout und bleibt unabhängig von der
|
||||
Desktopskalierung 270 physische Pixel breit. Es unterscheidet Desktop- und
|
||||
Objektaktionen. Fixierte Elemente lassen sich weder verschieben, verkleinern
|
||||
noch entfernen. Rasterumschalten und Anordnen erhalten fixierte Positionen;
|
||||
fehlender Platz übernimmt keine Teilanordnung. Rückgängig hält bis zu 40 Stände.
|
||||
Bewegliche Widgets können auf den Papierkorb gezogen werden; Appbuttons bleiben
|
||||
erhalten. Escape verwirft eine laufende Bewegung. Pfeiltasten bewegen im Raster
|
||||
um eine Zelle, frei um 24 Punkte beziehungsweise mit Umschalt um 96 Punkte.
|
||||
|
||||
Die Arbeitsanordnung wird atomar als `working-desktop.json` im weltbezogenen
|
||||
UI-Demoverzeichnis gespeichert. Sie verändert weder Quellenrevision noch
|
||||
Spiel-Dirty. Ein ausdrücklich angegebener `--ui-state` hat Vorrang; kaputte
|
||||
Arbeitsanordnungen werden gemeldet und bis zur bewussten Änderung erhalten.
|
||||
Benannte Ansichten sind davon unabhängig und werden mit Theme und tatsächlicher
|
||||
PNG-Vorschau in der [Dateiverwaltung](../save-load/README.md) gespeichert.
|
||||
|
||||
Spiel beenden bietet eine eigene Rückfrage. Nur geänderte Spielwerte erzeugen
|
||||
Speicherbedarf; Änderungen an Layout oder globalen UI-Präferenzen zählen nicht
|
||||
dazu. Nach Speichern/Verwerfen geht es zum Hauptmenü, beim OS-Schließen endet
|
||||
die Anwendung. Abbrechen lässt die laufende Partie offen. Anstoß bleibt ohne
|
||||
Aktion; Match-Engine, Audiosystem und Stadionperipherie gehören nicht zum Paket.
|
||||
|
||||
Native Bildnachweise, Eingabeskripte und passende UI-Democheckpoints liegen privat
|
||||
unter `bmh_4k_ui/docs/qa/desktop-files-batch-2026-10-25/`. Öffentliche Tests verwenden
|
||||
synthetische Kataloge. Build-/Control-CI ist von einer tatsächlichen nativen
|
||||
Windows-/macOS-Spielabnahme zu unterscheiden.
|
||||
@@ -219,3 +219,19 @@ Eingabeskripte liegen unter `bmh_4k_ui/docs/qa/settings-batch-2026-10-25/`.
|
||||
Die Runtimekohorten behalten ihre tatsächlichen Binär-/Stylesheet-Hashes;
|
||||
Bildkontrollen laufen unter Linux/OpenGL. Das Paket schließt keine Engine-,
|
||||
Audio- oder Windows-/macOS-Laufzeitabnahme ein.
|
||||
|
||||
|
||||
Die Pakete Dateiverwaltung und Desktop/Widgets werden gemeinsam als Meilenstein
|
||||
geprüft. Die lokale Suite besteht **34/34 Tests**. Zusätzliche öffentliche
|
||||
Tests decken atomare Dateibibliotheken, Überschreibschutz, Pfadaliasse,
|
||||
In-Memory-Laden, Bestätigung gespeicherter Revisionen, Widgetmetadaten,
|
||||
Raster-/Fixierungsschutz und tatsächlich berechneten Galerie-Scrollbereich ab.
|
||||
Die Schriftprüfung lädt beide Produktionsstylesheets und kontrolliert zusätzlich
|
||||
Monatsname, Warnbeschriftungen und Begegnungsnamen in drei Themes/vier Dichten.
|
||||
|
||||
Die privaten Belege liegen unter
|
||||
`bmh_4k_ui/docs/qa/desktop-files-batch-2026-10-25/`. Karriere- und Ansichtsdateien
|
||||
bleiben UI-Demodaten. Die vertieften Dateitests enthalten tatsächliche
|
||||
GUI-Eingaben und externe Änderungen eigener QA-Dateien zwischen Auswahl und
|
||||
Bestätigung; es werden keine Produktzustände in den laufenden Prozess injiziert.
|
||||
Separate Runtimekohorten bewahren ihre ursprünglichen Fingerprints.
|
||||
@@ -101,3 +101,14 @@ Inhaltsabstand berücksichtigt. Anzeige und Sound werden unabhängig vom
|
||||
OBW gespeichert; reine globale Änderungen verändern keinen Demostand.
|
||||
Die Einstellungen verwenden weiterhin den nativen Select-Unterbau;
|
||||
die bereits oben vermerkte vollständige Pickerangleichung bleibt offen.
|
||||
|
||||
|
||||
In den Paketen Dateiverwaltung und Desktop/Widgets behoben: aktuelle statt
|
||||
ausgewählter Speicherstanddaten, getrennte atomare Layout-/PNG-Transaktionen,
|
||||
fehlende Widgetinhalte und Vorschauen, nicht zur Scrollhöhe beitragende
|
||||
Galeriekarten, anonyme Flexbeschriftungen, der fehlende Eintrittspreisanker
|
||||
sowie verlorener Dateizeilenfokus. Galerie-Vorschauen sind auch per Tastatur
|
||||
inert. Kontextmenüs verwenden ihre Borderbox zur Randbegrenzung und zeigen
|
||||
Fixierungs-/Rasterzustände. Exporte dürfen keine verwalteten Slots ersetzen.
|
||||
Die native Ansichts-/Arbeitsablage bleibt bewusst weltbezogen, während Gold
|
||||
browserglobal speichert; diese Abgrenzung ist in der Dateiverwaltung dokumentiert.
|
||||
@@ -134,6 +134,12 @@ int main(int argc, char** argv) {
|
||||
modern_config.state = launch::path_from_utf8(args[++i]);
|
||||
} else if (is("--ui-preferences") && value) {
|
||||
modern_config.preferences = launch::path_from_utf8(args[++i]);
|
||||
} else if (is("--ui-userdata") && value) {
|
||||
modern_config.userdata = launch::path_from_utf8(args[++i]);
|
||||
} else if (is("--ui-file-import") && value) {
|
||||
modern_config.file_import = launch::path_from_utf8(args[++i]);
|
||||
} else if (is("--ui-file-export") && value) {
|
||||
modern_config.file_export = launch::path_from_utf8(args[++i]);
|
||||
} else if (is("--ui-size") && value) {
|
||||
const auto size = args[++i];
|
||||
const auto separator = size.find('x');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
add_library(bmh_modern_ui_core STATIC catalog.cpp model.cpp gui_assets.cpp desktop.cpp demo_sports.cpp demo_calendar.cpp demo_reports.cpp demo_almanac.cpp demo_finance.cpp demo_environment.cpp demo_advertising.cpp demo_toto.cpp demo_lineup.cpp demo_transfer.cpp demo_career_reports.cpp demo_rankings.cpp demo_stadium.cpp demo_statistics.cpp demo_news.cpp demo_settings.cpp ui_preferences.cpp)
|
||||
add_library(bmh_modern_ui_core STATIC catalog.cpp model.cpp gui_assets.cpp desktop.cpp demo_sports.cpp demo_calendar.cpp demo_reports.cpp demo_almanac.cpp demo_finance.cpp demo_environment.cpp demo_advertising.cpp demo_toto.cpp demo_lineup.cpp demo_transfer.cpp demo_career_reports.cpp demo_rankings.cpp demo_stadium.cpp demo_statistics.cpp demo_news.cpp demo_settings.cpp ui_preferences.cpp demo_widgets.cpp demo_files.cpp)
|
||||
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 statistics.rcss news.rcss settings.rcss)
|
||||
foreach(asset modern.rml theme.rcss ticket.rcss sports.rcss calendar.rcss reports.rcss report_details.rcss report_pickers.rcss indoor.rcss planning.rcss almanac.rcss finance.rcss bank.rcss contracts.rcss amount.rcss environment.rcss advertising.rcss toto.rcss lineup.rcss transfer.rcss career_reports.rcss rankings.rcss stadium.rcss statistics.rcss news.rcss settings.rcss widgets.rcss files.rcss)
|
||||
configure_file("${CMAKE_SOURCE_DIR}/assets/modern/${asset}" "${modern_assets}/${asset}" COPYONLY)
|
||||
endforeach()
|
||||
|
||||
@@ -100,7 +100,7 @@ foreach(component environment advertising toto lineup transfer stadium)
|
||||
add_test(NAME modern_${component}_ui_tests COMMAND modern_${component}_ui_tests)
|
||||
endforeach()
|
||||
|
||||
foreach(component statistics news settings)
|
||||
foreach(component statistics news settings desktop files)
|
||||
add_executable(modern_${component}_ui_tests ../../../tests/modern_${component}_ui_tests.cpp)
|
||||
target_link_libraries(modern_${component}_ui_tests PRIVATE bmh_modern_ui_core)
|
||||
if(MSVC)
|
||||
|
||||
@@ -14,52 +14,41 @@ void App::render_context() {
|
||||
root->SetProperty("display", context_open_ ? "block" : "none");
|
||||
if (!context_open_ || !context_dirty_)
|
||||
return;
|
||||
std::string body;
|
||||
if (!context_id_.empty()) {
|
||||
const auto &o = desktop_["objects"].at(context_id_);
|
||||
body += btn("context-pin",
|
||||
o.value("pinned", true) ? "Fixierung lösen" : "Fixieren");
|
||||
if (o.value("widget", false)) {
|
||||
body += btn("context-remove", "Widget entfernen");
|
||||
for (const auto &d : widget_definitions())
|
||||
if (d.id == context_id_)
|
||||
for (auto [w, h] : d.sizes)
|
||||
body += btn("context-size",
|
||||
std::to_string(w) + " × " + std::to_string(h), {},
|
||||
"data-id=\"" + std::to_string(w) + "x" +
|
||||
std::to_string(h) + "\"");
|
||||
const auto item=[&](const std::string &action,const std::string &label,const std::string &symbol,const std::string &extra=std::string()){
|
||||
return btn(action,glyph(symbol,19./scale_)+"<span>"+esc(label)+"</span>"+((extra.find("aria-checked=\"true\"")!=std::string::npos||extra.find("data-checked=\"true\"")!=std::string::npos)?"<span class=\"context-check\">"+glyph("check",14./scale_)+"</span>":""),"context-action",extra);
|
||||
};
|
||||
std::string body=item("context-undo","Rückgängig","undo",undo_.empty()?"disabled":"");
|
||||
if(!context_id_.empty()){
|
||||
const auto &o=desktop_.at("objects").at(context_id_);
|
||||
const bool pinned=o.value("pinned",true);
|
||||
body+=item("context-pin",pinned?"Fixierung lösen":"Fixieren","lock");
|
||||
if(o.value("widget",false)){
|
||||
body+="<div class=\"context-label\">Widgetgröße</div>";
|
||||
for(const auto &d:widget_definitions())if(d.id==context_id_)for(const auto &[w,h]:d.sizes){
|
||||
const bool selected=o.at("w")==w*248-24 && o.at("h")==h*248-24;
|
||||
body+=item("context-size",std::to_string(w)+" × "+std::to_string(h),"grid","data-id=\""+std::to_string(w)+"x"+std::to_string(h)+"\" "+(pinned?"disabled":"")+(selected?" data-checked=\"true\"":""));
|
||||
}
|
||||
body+=item("context-remove","Widget entfernen","trash",pinned?"disabled":"");
|
||||
}
|
||||
body += "<div class=\"separator\"></div>";
|
||||
}else{
|
||||
bool pinned=true;for(const auto &[id,o]:desktop_.at("objects").items())if(o.at("visible")==true&&o.at("pinned")==false)pinned=false;
|
||||
body+=item("context-pin-all","Alles fixieren","lock",std::string("role=\"menuitemcheckbox\" aria-checked=\"")+(pinned?"true":"false")+"\"");
|
||||
body+=item("context-arrange","Am Raster anordnen","grid");
|
||||
body+=item("context-grid",desktop_.value("grid",true)?"Raster deaktivieren":"Raster aktivieren","grid",std::string("role=\"menuitemcheckbox\" aria-checked=\"")+(desktop_.value("grid",true)?"true":"false")+"\"");
|
||||
body+=item("context-widgets","Widget hinzufügen","plus")+item("context-view-save","Ansicht speichern","save")+item("context-view-load","Ansicht laden","folder")+item("context-background","Hintergrundbild ändern","image")+item("context-quit","Spiel beenden","power");
|
||||
}
|
||||
bool all_pinned = true;
|
||||
for (const auto &[id, o] : desktop_["objects"].items()) {
|
||||
(void)id;
|
||||
if (o.value("visible", false) && !o.value("pinned", true))
|
||||
all_pinned = false;
|
||||
}
|
||||
body +=
|
||||
btn("context-undo", "Rückgängig", {}, undo_.empty() ? "disabled" : "") +
|
||||
btn("context-pin-all", all_pinned ? "Alles lösen" : "Alles fixieren") +
|
||||
btn("context-grid", desktop_.value("grid", true) ? "Raster ausschalten"
|
||||
: "Raster einschalten") +
|
||||
btn("context-arrange", "Am Raster anordnen") +
|
||||
"<div class=\"separator\"></div>" +
|
||||
btn("context-widgets", "Widget hinzufügen") +
|
||||
btn("context-view-save", "Ansicht speichern") +
|
||||
btn("context-view-load", "Ansicht laden") +
|
||||
btn("context-background", "Hintergrundbild ändern") +
|
||||
"<div class=\"separator\"></div>" + btn("context-quit", "Spiel beenden");
|
||||
root->SetInnerRML(body);
|
||||
context_->Update();
|
||||
const auto size = context_->GetDimensions();
|
||||
root->SetProperty(
|
||||
"left",
|
||||
scalar(std::clamp(context_x_, 4, std::max(4, size.x - 288))) + "px");
|
||||
scalar(std::clamp(context_x_, 8, std::max(8, size.x - 278))) + "px");
|
||||
root->SetProperty(
|
||||
"top", scalar(std::clamp(
|
||||
context_y_, 4,
|
||||
std::max(4, size.y - int(root->GetBox().GetSize().y) - 8))) +
|
||||
context_y_, 8,
|
||||
std::max(8, size.y - int(root->GetBox().GetSize(Rml::BoxArea::Border).y) - 8))) +
|
||||
"px");
|
||||
Rml::ElementList buttons;root->QuerySelectorAll(buttons,"button");for(auto *button:buttons)if(!button->HasAttribute("disabled")){button->Focus(true);break;}
|
||||
context_dirty_ = false;
|
||||
}
|
||||
void App::drag_event(Rml::Event &event) {
|
||||
@@ -80,9 +69,8 @@ void App::drag_event(Rml::Event &event) {
|
||||
return;
|
||||
const auto id = n->GetAttribute<Rml::String>("data-object", "");
|
||||
const auto &o = desktop_["objects"].at(id);
|
||||
if (o.value("pinned", true))
|
||||
return;
|
||||
drag_ = {true, false, id, x, y, o.value("x", 0.0), o.value("y", 0.0)};
|
||||
drag_.pinned=o.value("pinned",true);drag_undo_size_=undo_.size();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -92,10 +80,10 @@ void App::drag_event(Rml::Event &event) {
|
||||
if (type == "mousemove") {
|
||||
if (!drag_.moved && std::hypot(x - drag_.x, y - drag_.y) < 6)
|
||||
return;
|
||||
if(drag_.pinned){drag_.moved=true;return;}
|
||||
if (!drag_.moved) {
|
||||
undo_.push_back(desktop_);
|
||||
if (undo_.size() > 40)
|
||||
undo_.erase(undo_.begin());
|
||||
desktop_checkpoint(desktop_);
|
||||
desktop_raise(drag_.id);
|
||||
drag_.moved = true;
|
||||
}
|
||||
auto &o = desktop_["objects"][drag_.id];
|
||||
@@ -114,15 +102,19 @@ void App::drag_event(Rml::Event &event) {
|
||||
dirty_ = true;
|
||||
}
|
||||
if (type == "mouseup") {
|
||||
if(drag_.pinned){suppress_click_=drag_.moved;drag_.active=false;return;}
|
||||
if (drag_.moved) {
|
||||
suppress_click_ = true;
|
||||
auto &o = desktop_["objects"][drag_.id];
|
||||
auto proposed = undo_.back();
|
||||
const int x = o.value("x", 64), y = o.value("y", 224);
|
||||
if (place_desktop_object(proposed, drag_.id, x, y))
|
||||
desktop_ = std::move(proposed);
|
||||
else
|
||||
desktop_ = undo_.back();
|
||||
const auto &trash=desktop_.at("objects").at("trash");
|
||||
const auto px=(event.GetParameter<float>("mouse_x",0)-canvas_left_)/scale_,py=(event.GetParameter<float>("mouse_y",0)-canvas_top_)/scale_;
|
||||
const bool remove=drag_.id!="trash"&&o.value("widget",false)&&trash.at("visible")==true&&px>=trash.at("x").get<int>()&&px<=trash.at("x").get<int>()+trash.at("w").get<int>()&&py>=trash.at("y").get<int>()&&py<=trash.at("y").get<int>()+trash.at("h").get<int>();
|
||||
if(remove){proposed["objects"][drag_.id]["visible"]=false;desktop_=std::move(proposed);}
|
||||
else if (place_desktop_object(proposed, drag_.id, x, y))
|
||||
{desktop_ = std::move(proposed);desktop_raise(drag_.id);}
|
||||
else {desktop_ = undo_.back();if(undo_.size()>drag_undo_size_){undo_.pop_back();if(!undo_themes_.empty())undo_themes_.pop_back();}}
|
||||
|
||||
refresh();
|
||||
}
|
||||
@@ -133,7 +125,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" || menu_ == "news" || menu_ == "settings") &&
|
||||
if (setting_menu_markup_ && (menu_ == "lineup" || menu_ == "transfer" || menu_ == "news" || menu_ == "settings" || menu_=="widgets" || menu_=="save" || menu_=="load" || menu_=="view-save" || menu_=="view-load") &&
|
||||
(type == "change" || type == "input")) return;
|
||||
if (type == "keydown")
|
||||
keyboard_navigation_ = true;
|
||||
@@ -155,6 +147,7 @@ void App::ProcessEvent(Rml::Event &event) try {
|
||||
return;
|
||||
if (amount_event(event)) return;
|
||||
if (popup_.empty() && settings_event(event)) return;
|
||||
if (popup_.empty() && (files_event(event) || widget_event(event))) return;
|
||||
if ((menu_ == "lineup" || menu_ == "transfer") && (type == "change" || type == "input")) {
|
||||
if (auto *select = dynamic_cast<Rml::ElementFormControlSelect *>(event.GetTargetElement());
|
||||
select && select->IsSelectBoxVisible()) {
|
||||
@@ -247,6 +240,8 @@ void App::ProcessEvent(Rml::Event &event) try {
|
||||
if (type == "mouseup" && event.GetParameter<int>("button", 0) == 1) {
|
||||
if (scene_ == "desktop" && !menu_.empty() && popup_.empty()) {
|
||||
menu_.clear();
|
||||
quit_after_save_=false;
|
||||
quit_closes_app_=false;
|
||||
reset_settings();
|
||||
refresh();
|
||||
} else if (scene_ == "desktop" && menu_.empty() && popup_.empty()) {
|
||||
@@ -364,6 +359,8 @@ void App::ProcessEvent(Rml::Event &event) try {
|
||||
dirty_ = true;
|
||||
} else if (!menu_.empty()) {
|
||||
menu_.clear();
|
||||
quit_after_save_=false;
|
||||
quit_closes_app_=false;
|
||||
reset_settings();
|
||||
refresh();
|
||||
} else if (scene_ == "manager") {
|
||||
@@ -461,6 +458,7 @@ void App::dispatch(const std::string &action, Rml::Element *target) {
|
||||
const auto id =
|
||||
target ? target->GetAttribute<Rml::String>("data-id", "") : std::string();
|
||||
if (settings_action(action,target)) return;
|
||||
if (files_action(action,target) || widget_action(action,target)) return;
|
||||
if (lineup_action(action, target) || transfer_action(action, target)) return;
|
||||
if (career_report_action(action, target) || rankings_action(action, target)) return;
|
||||
if (statistics_action(action, target) || dispatch_news(action, target)) return;
|
||||
@@ -557,6 +555,7 @@ void App::dispatch(const std::string &action, Rml::Element *target) {
|
||||
}
|
||||
return;
|
||||
}
|
||||
focus_after_render_=context_id_.empty()?"desktop-identity":"object-"+context_id_;
|
||||
auto before = desktop_;
|
||||
bool ok = true;
|
||||
if (action == "context-pin")
|
||||
@@ -588,97 +587,16 @@ void App::dispatch(const std::string &action, Rml::Element *target) {
|
||||
std::stoi(id.substr(split + 1)));
|
||||
}
|
||||
if (ok && desktop_ != before) {
|
||||
undo_.push_back(std::move(before));
|
||||
desktop_checkpoint(before);
|
||||
refresh();
|
||||
} else if (!ok)
|
||||
message("Kein freier Platz. Fixierte Widgets zuerst lösen oder andere "
|
||||
"Elemente entfernen.");
|
||||
return;
|
||||
}
|
||||
if (action == "widget-add") {
|
||||
auto before = desktop_;
|
||||
auto &o = desktop_["objects"].at(id);
|
||||
o["pinned"] = false;
|
||||
if (place_desktop_object(desktop_, id, 64, 224)) {
|
||||
undo_.push_back(before);
|
||||
menu_.clear();
|
||||
refresh();
|
||||
} else {
|
||||
desktop_ = before;
|
||||
message("Für dieses Widget ist kein freier Platz vorhanden.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (action == "view-default") {
|
||||
undo_.push_back(desktop_);
|
||||
desktop_ = default_desktop();
|
||||
menu_.clear();
|
||||
refresh();
|
||||
return;
|
||||
}
|
||||
if (action == "view-save-confirm") {
|
||||
const auto name = field("view-name");
|
||||
launch::ModLibrary::validate_name(name);
|
||||
const auto file = user_dir() / "layouts" / editor::path(name + ".json");
|
||||
const auto save = [this, file] {
|
||||
const auto old_menu = menu_;
|
||||
menu_.clear();
|
||||
refresh();
|
||||
frame();
|
||||
auto image = file;
|
||||
image.replace_extension(".png");
|
||||
try {
|
||||
screenshot(image);
|
||||
editor::write_atomic(file, desktop_.dump(2));
|
||||
menu_.clear();
|
||||
refresh();
|
||||
} catch (...) {
|
||||
menu_ = old_menu;
|
||||
refresh();
|
||||
throw;
|
||||
}
|
||||
};
|
||||
if (fs::exists(file))
|
||||
confirmation("Gespeicherte Ansicht überschreiben?", save);
|
||||
else
|
||||
save();
|
||||
return;
|
||||
}
|
||||
if (action == "view-select") {
|
||||
selections_["view"] = id;
|
||||
refresh();
|
||||
return;
|
||||
}
|
||||
if (action == "view-load-confirm") {
|
||||
launch::ModLibrary::validate_name(selections_["view"]);
|
||||
const auto file =
|
||||
user_dir() / "layouts" / editor::path(selections_["view"] + ".json");
|
||||
auto next = Json::parse(editor::read_file(file));
|
||||
if (!migrate_desktop(next))
|
||||
throw editor::Error("Ungültige Desktopansicht oder kein freier Platz für den Almanach.");
|
||||
undo_.push_back(desktop_);
|
||||
desktop_ = std::move(next);
|
||||
menu_.clear();
|
||||
refresh();
|
||||
return;
|
||||
}
|
||||
if (action == "view-delete") {
|
||||
const auto name = selections_["view"];
|
||||
if (name.empty())
|
||||
return;
|
||||
launch::ModLibrary::validate_name(name);
|
||||
confirmation("Ansicht „" + name + "“ löschen?", [this, name] {
|
||||
const auto file = user_dir() / "layouts" / editor::path(name + ".json");
|
||||
fs::remove(file);
|
||||
auto image = file;
|
||||
image.replace_extension(".png");
|
||||
fs::remove(image);
|
||||
selections_["view"].clear();
|
||||
refresh();
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (action == "close") {
|
||||
quit_after_save_=false;
|
||||
quit_closes_app_=false;
|
||||
menu_.clear();
|
||||
reset_settings();
|
||||
if (scene_ != "desktop")
|
||||
@@ -1157,92 +1075,6 @@ void App::dispatch(const std::string &action, Rml::Element *target) {
|
||||
message("Trainingslager für die Demo vorgemerkt.");
|
||||
return;
|
||||
}
|
||||
if (action == "save-select") {
|
||||
selections_["save"] = id;
|
||||
refresh();
|
||||
return;
|
||||
}
|
||||
if (action == "save-new") {
|
||||
selections_["save"].clear();
|
||||
refresh();
|
||||
return;
|
||||
}
|
||||
if (action == "save-confirm") {
|
||||
auto name =
|
||||
selections_["save"].empty() ? field("save-name") : selections_["save"];
|
||||
try {
|
||||
launch::ModLibrary::validate_name(name);
|
||||
const auto file = user_dir() / "saves" / editor::path(name + ".json");
|
||||
fs::create_directories(file.parent_path());
|
||||
const auto save = [this, file] {
|
||||
init_desktop();
|
||||
source_->save(file, desktop_);
|
||||
saved_desktop_ = desktop_;
|
||||
menu_.clear();
|
||||
if (quit_after_save_)
|
||||
closed_ = true;
|
||||
refresh();
|
||||
};
|
||||
if (fs::exists(file))
|
||||
confirmation("Vorhandenen Demo-Spielstand überschreiben?", save);
|
||||
else
|
||||
save();
|
||||
} catch (const std::exception &e) {
|
||||
message(e.what());
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (action == "load-confirm") {
|
||||
const auto name = selections_["save"];
|
||||
if (name.empty())
|
||||
return;
|
||||
try {
|
||||
launch::ModLibrary::validate_name(name);
|
||||
desktop_ =
|
||||
source_->load(user_dir() / "saves" / editor::path(name + ".json"));
|
||||
saved_desktop_ = desktop_;
|
||||
if(!ui_preferences_loaded_){ui_preferences_=legacy_ui_preferences(snap().state.at("preferences"));theme_=ui_preferences_.at("theme").get<std::string>();}
|
||||
menu_.clear();
|
||||
scene_ = "desktop";
|
||||
refresh();
|
||||
} catch (const std::exception &e) {
|
||||
message(e.what());
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (action == "save-rename") {
|
||||
const auto previous = selections_["save"];
|
||||
if (previous.empty())
|
||||
return;
|
||||
text_dialog(
|
||||
"Speicherstand umbenennen", previous,
|
||||
[this, previous](const std::string &name) {
|
||||
launch::ModLibrary::validate_name(name);
|
||||
if (name == previous)
|
||||
return;
|
||||
const auto folder = user_dir() / "saves",
|
||||
old_file = folder / editor::path(previous + ".json"),
|
||||
new_file = folder / editor::path(name + ".json");
|
||||
if (fs::exists(new_file))
|
||||
throw editor::Error("Diese Bezeichnung ist bereits vorhanden.");
|
||||
fs::rename(old_file, new_file);
|
||||
selections_["save"] = name;
|
||||
refresh();
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (action == "save-delete") {
|
||||
const auto name = selections_["save"];
|
||||
if (name.empty())
|
||||
return;
|
||||
confirmation("Demo-Spielstand „" + name + "“ löschen?", [this, name] {
|
||||
launch::ModLibrary::validate_name(name);
|
||||
fs::remove(user_dir() / "saves" / editor::path(name + ".json"));
|
||||
selections_["save"].clear();
|
||||
refresh();
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (action == "squad-tactics") {
|
||||
menu_ = "tactics";
|
||||
refresh();
|
||||
@@ -1250,7 +1082,7 @@ void App::dispatch(const std::string &action, Rml::Element *target) {
|
||||
}
|
||||
}
|
||||
void App::change(Rml::Element *target) {
|
||||
if(settings_change(target))return;
|
||||
if(files_change(target) || widget_change(target) || settings_change(target))return;
|
||||
const auto kind = target->GetAttribute<Rml::String>("data-change", "");
|
||||
auto *control = dynamic_cast<Rml::ElementFormControl *>(target);
|
||||
if (!control)
|
||||
@@ -1314,7 +1146,7 @@ void App::change(Rml::Element *target) {
|
||||
}
|
||||
}
|
||||
void App::input(Rml::Element *target) {
|
||||
if(settings_change(target))return;
|
||||
if(files_change(target) || widget_change(target) || settings_change(target))return;
|
||||
const auto kind = target->GetAttribute<Rml::String>("data-input", "");
|
||||
auto *control = dynamic_cast<Rml::ElementFormControl *>(target);
|
||||
if (!control)
|
||||
@@ -1385,6 +1217,11 @@ void App::script() {
|
||||
context_->ProcessMouseMove(point.x, point.y, 0);
|
||||
context_->ProcessMouseButtonDown(button, 0);
|
||||
context_->ProcessMouseButtonUp(button, 0);
|
||||
} else if(type=="pointer-down"||type=="pointer-move"||type=="pointer-up"){
|
||||
const auto point=locate(command);context_->ProcessMouseMove(point.x,point.y,0);
|
||||
const int button=command.value("button",0);
|
||||
if(type=="pointer-down")context_->ProcessMouseButtonDown(button,0);
|
||||
if(type=="pointer-up")context_->ProcessMouseButtonUp(button,0);
|
||||
} else if (type == "drag") {
|
||||
const auto point = locate(command),
|
||||
end = Rml::Vector2i{command.at("to_x"), command.at("to_y")};
|
||||
@@ -1404,7 +1241,7 @@ void App::script() {
|
||||
{"LEFT", Rml::Input::KI_LEFT}, {"RIGHT", Rml::Input::KI_RIGHT},
|
||||
{"UP", Rml::Input::KI_UP}, {"DOWN", Rml::Input::KI_DOWN},
|
||||
{"A", Rml::Input::KI_A}, {"Z", Rml::Input::KI_Z}, {"V", Rml::Input::KI_V},
|
||||
{"BACKSPACE", Rml::Input::KI_BACK}, {"DELETE", Rml::Input::KI_DELETE}, {"F4", Rml::Input::KI_F4},
|
||||
{"BACKSPACE", Rml::Input::KI_BACK}, {"DELETE", Rml::Input::KI_DELETE}, {"F4", Rml::Input::KI_F4}, {"F10", Rml::Input::KI_F10}, {"CONTEXT", Rml::Input::KI_APPS},
|
||||
{"0", Rml::Input::KI_0}, {"1", Rml::Input::KI_1}, {"2", Rml::Input::KI_2}, {"3", Rml::Input::KI_3},
|
||||
{"4", Rml::Input::KI_4}, {"5", Rml::Input::KI_5}, {"6", Rml::Input::KI_6}, {"7", Rml::Input::KI_7},
|
||||
{"8", Rml::Input::KI_8}, {"9", Rml::Input::KI_9}};
|
||||
@@ -1437,7 +1274,7 @@ 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_},
|
||||
{"ui_preferences",ui_preferences_}, {"settings_draft",settings_draft_}, {"settings_category",settings_category_}, {"settings_query",settings_query_}, {"settings_notice",settings_notice_},
|
||||
{"files_view",{{"mode",files_mode_},{"selected",files_selected_},{"name",files_name_},{"feedback",files_feedback_}}}, {"widget_view",{{"query",widget_query_},{"notice",widget_notice_}}}, {"ui_preferences",ui_preferences_}, {"settings_draft",settings_draft_}, {"settings_category",settings_category_}, {"settings_query",settings_query_}, {"settings_notice",settings_notice_},
|
||||
{"statistics_view", statistics_view_}, {"statistics_trophy", statistics_trophy_},
|
||||
{"statistics_scrolls", statistics_scrolls_},
|
||||
{"news_view", news_view_}, {"news_dialog", news_dialog_},
|
||||
@@ -1455,6 +1292,11 @@ void App::script() {
|
||||
{"desktop", desktop_},
|
||||
{"demo", source_ ? snap().state : Json()}}
|
||||
.dump(2));
|
||||
else if(type=="metrics"){
|
||||
context_->Update();Json rows=Json::array();
|
||||
for(const auto &selector:command.at("selectors")){Rml::ElementList nodes;doc_->QuerySelectorAll(nodes,selector.get<std::string>());for(auto *node:nodes){auto at=node->GetAbsoluteOffset(Rml::BoxArea::Border),size=node->GetBox().GetSize(Rml::BoxArea::Border);rows.push_back({{"selector",selector},{"id",node->GetId()},{"x",at.x},{"y",at.y},{"width",size.x},{"height",size.y},{"scroll_top",node->GetScrollTop()},{"scroll_height",node->GetScrollHeight()},{"client_height",node->GetClientHeight()},{"visible",node->IsVisible(true)}});}}
|
||||
editor::write_atomic(editor::path(command.at("path").get<std::string>()),rows.dump(2));
|
||||
}
|
||||
else if (type == "dom")
|
||||
editor::write_atomic(
|
||||
editor::path(command.at("path").get<std::string>()),
|
||||
|
||||
@@ -0,0 +1,344 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "modern/ui/demo_files.hpp"
|
||||
#include "modern/ui/desktop.hpp"
|
||||
#include "editor/images.hpp"
|
||||
#include "content/digest.hpp"
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
|
||||
namespace bmh::modern_ui {
|
||||
namespace {
|
||||
constexpr uint64_t file_limit = 64 * 1024 * 1024;
|
||||
std::string stamp(std::chrono::system_clock::time_point time = std::chrono::system_clock::now()) {
|
||||
const auto days = std::chrono::floor<std::chrono::days>(time);
|
||||
const std::chrono::year_month_day date{days};
|
||||
const std::chrono::hh_mm_ss clock{std::chrono::floor<std::chrono::seconds>(time - days)};
|
||||
std::ostringstream out;
|
||||
out << std::setfill('0') << std::setw(4) << int(date.year()) << '-'
|
||||
<< std::setw(2) << unsigned(date.month()) << '-' << std::setw(2) << unsigned(date.day())
|
||||
<< ' ' << std::setw(2) << clock.hours().count() << ':' << std::setw(2) << clock.minutes().count()
|
||||
<< ':' << std::setw(2) << clock.seconds().count() << " UTC";
|
||||
return out.str();
|
||||
}
|
||||
void safe_directory(const fs::path &path, bool create = false) {
|
||||
fs::path current;
|
||||
for (const auto &part : fs::absolute(path).lexically_normal()) {
|
||||
current /= part;
|
||||
const auto status = fs::symlink_status(current);
|
||||
if (fs::is_symlink(status) || (fs::exists(status) && !fs::is_directory(status)))
|
||||
throw editor::Error("Dateiablage verweist auf einen unsicheren Pfad.");
|
||||
}
|
||||
if (create) fs::create_directories(path);
|
||||
}
|
||||
struct Lock {
|
||||
fs::path path;
|
||||
explicit Lock(const fs::path &root) : path(root / ".files-transaction") {
|
||||
safe_directory(root, true);
|
||||
if (!fs::create_directory(path))
|
||||
throw editor::Error("Die Dateiablage ist gerade belegt. Bitte erneut versuchen.");
|
||||
}
|
||||
~Lock() { std::error_code error; fs::remove(path, error); }
|
||||
};
|
||||
std::vector<uint32_t> codepoints(const std::string &name) {
|
||||
std::vector<uint32_t> out;
|
||||
for (size_t i = 0; i < name.size();) {
|
||||
const uint8_t first = uint8_t(name[i++]);
|
||||
uint32_t value = first;
|
||||
int remaining = 0;
|
||||
if (first >= 0xc2 && first <= 0xdf) { value &= 31; remaining = 1; }
|
||||
else if (first >= 0xe0 && first <= 0xef) { value &= 15; remaining = 2; }
|
||||
else if (first >= 0xf0 && first <= 0xf4) { value &= 7; remaining = 3; }
|
||||
else if (first >= 0x80) throw editor::Error("Die Bezeichnung enthält ungültigen Text.");
|
||||
const int count = remaining;
|
||||
while (remaining--) {
|
||||
if (i == name.size() || (uint8_t(name[i]) & 0xc0) != 0x80)
|
||||
throw editor::Error("Die Bezeichnung enthält ungültigen Text.");
|
||||
value = value * 64 + (uint8_t(name[i++]) & 63);
|
||||
}
|
||||
if ((count == 1 && value < 0x80) || (count == 2 && value < 0x800) ||
|
||||
(count == 3 && value < 0x10000) || value > 0x10ffff ||
|
||||
(value >= 0xd800 && value <= 0xdfff))
|
||||
throw editor::Error("Die Bezeichnung enthält ungültigen Text.");
|
||||
out.push_back(value);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
void utf8(std::string &out, uint32_t value) {
|
||||
if (value < 128) out += char(value);
|
||||
else if (value < 2048) { out += char(0xc0 | value >> 6); out += char(0x80 | (value & 63)); }
|
||||
else if (value < 65536) { out += char(0xe0 | value >> 12); out += char(0x80 | ((value >> 6) & 63)); out += char(0x80 | (value & 63)); }
|
||||
else { out += char(0xf0 | value >> 18); out += char(0x80 | ((value >> 12) & 63)); out += char(0x80 | ((value >> 6) & 63)); out += char(0x80 | (value & 63)); }
|
||||
}
|
||||
std::string hex(const std::string &data) {
|
||||
constexpr char digits[] = "0123456789abcdef";
|
||||
std::string out; out.reserve(data.size() * 2);
|
||||
for (uint8_t value : data) { out += digits[value >> 4]; out += digits[value & 15]; }
|
||||
return out;
|
||||
}
|
||||
std::string unhex(const std::string &data) {
|
||||
if (data.size() % 2 || data.size() > 32 * 1024 * 1024)
|
||||
throw editor::Error("Ungültige Vorschau.");
|
||||
const auto digit = [](char c) -> int {
|
||||
if (c >= '0' && c <= '9') return c - '0';
|
||||
if (c >= 'a' && c <= 'f') return c - 'a' + 10;
|
||||
throw editor::Error("Ungültige Vorschau.");
|
||||
};
|
||||
std::string out; out.reserve(data.size() / 2);
|
||||
for (size_t i = 0; i < data.size(); i += 2) out += char(digit(data[i]) * 16 + digit(data[i + 1]));
|
||||
return out;
|
||||
}
|
||||
void validate_png(const std::string &bytes, bool required) {
|
||||
if (bytes.empty()) {
|
||||
if (required) throw editor::Error("Die Desktop-Vorschau fehlt.");
|
||||
return;
|
||||
}
|
||||
if (bytes.size() < 24 || bytes.size() > 16 * 1024 * 1024 ||
|
||||
bytes.substr(0, 8) != std::string("\x89PNG\r\n\x1a\n", 8))
|
||||
throw editor::Error("Die Vorschau ist keine gültige PNG-Datei.");
|
||||
const auto integer = [&](size_t at) {
|
||||
uint32_t n = 0; for (size_t i = at; i < at + 4; ++i) n = n * 256 + uint8_t(bytes[i]); return n;
|
||||
};
|
||||
const uint64_t width = integer(16), height = integer(20);
|
||||
if (!width || !height || width > 8192 || height > 8192 || width * height > 32 * 1024 * 1024)
|
||||
throw editor::Error("Die Desktop-Vorschau ist zu groß.");
|
||||
const auto decoded = editor::images::decode(bytes, ".png");
|
||||
if (uint64_t(decoded.width) != width || uint64_t(decoded.height) != height)
|
||||
throw editor::Error("Die Desktop-Vorschau ist beschädigt.");
|
||||
}
|
||||
std::string read_regular(const fs::path &path) {
|
||||
if (fs::is_symlink(fs::symlink_status(path)) || !fs::is_regular_file(path))
|
||||
throw editor::Error("Die ausgewählte Datei ist nicht mehr vorhanden oder unsicher.");
|
||||
return editor::read_file(path, file_limit);
|
||||
}
|
||||
bool path_inside(const fs::path &directory, const fs::path &candidate) {
|
||||
auto parent = directory.begin();
|
||||
auto child = candidate.begin();
|
||||
for (; parent != directory.end(); ++parent, ++child)
|
||||
if (child == candidate.end() || *parent != *child) return false;
|
||||
return true;
|
||||
}
|
||||
void validate_export_destination(const fs::path &root, const fs::path &destination) {
|
||||
const auto lexical = fs::absolute(destination).lexically_normal();
|
||||
const auto resolved = fs::weakly_canonical(destination);
|
||||
for (const char *name : {"saves", "layouts"}) {
|
||||
const auto directory = root / name;
|
||||
const auto lexical_directory = fs::absolute(directory).lexically_normal();
|
||||
const auto resolved_directory = fs::weakly_canonical(directory);
|
||||
if (path_inside(lexical_directory, lexical) || path_inside(resolved_directory, resolved))
|
||||
throw editor::Error("Bitte außerhalb der verwalteten Spielstand- und Ansichtsablage exportieren.");
|
||||
// Filesystem equivalence also covers Windows case aliases and directory
|
||||
// junctions without relying on lexical casing of the supplied path.
|
||||
for (auto ancestor = resolved; !ancestor.empty();) {
|
||||
std::error_code error;
|
||||
if (fs::equivalent(directory, ancestor, error) && !error)
|
||||
throw editor::Error("Bitte außerhalb der verwalteten Spielstand- und Ansichtsablage exportieren.");
|
||||
const auto parent = ancestor.parent_path();
|
||||
if (parent == ancestor) break;
|
||||
ancestor = parent;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
DemoFiles::DemoFiles(fs::path root, DemoFileKind kind, std::shared_ptr<const Catalog> world)
|
||||
: root_(fs::weakly_canonical(std::move(root))), directory_(root_ / (kind == DemoFileKind::career ? "saves" : "layouts")), kind_(kind), world_(std::move(world)) {}
|
||||
std::string DemoFiles::clean_name(const std::string &raw) {
|
||||
const auto first = raw.find_first_not_of(" "), last = raw.find_last_not_of(" ");
|
||||
if (first == raw.npos) throw editor::Error("Bitte eine Bezeichnung mit 1 bis 64 Zeichen eingeben.");
|
||||
const auto name = raw.substr(first, last - first + 1);
|
||||
const auto points = codepoints(name);
|
||||
if (points.empty() || points.size() > 64 || std::any_of(points.begin(), points.end(), [](uint32_t c) { return c < 32 || (c >= 127 && c < 160); }))
|
||||
throw editor::Error("Bitte eine Bezeichnung mit 1 bis 64 Zeichen ohne Steuerzeichen eingeben.");
|
||||
return name;
|
||||
}
|
||||
std::string DemoFiles::name_key(const std::string &name, bool compatibility) {
|
||||
const auto points = codepoints(clean_name(name));
|
||||
std::string result;
|
||||
for (size_t i = 0; i < points.size(); ++i) {
|
||||
auto c = points[i];
|
||||
if (compatibility && c >= 0xff01 && c <= 0xff5e) c -= 0xfee0;
|
||||
if (c >= 'A' && c <= 'Z') c += 32;
|
||||
if ((c >= 0xc0 && c <= 0xd6) || (c >= 0xd8 && c <= 0xde)) c += 32;
|
||||
if (c == 0x1e9e || c == 0xdf) { result += "ss"; continue; }
|
||||
// Compose Latin keyboard accent sequences without depending on the
|
||||
// current OS locale or filesystem's normalization rules.
|
||||
if (i + 1 < points.size()) {
|
||||
const auto accent = points[i + 1]; uint32_t composed = 0;
|
||||
const std::string letters = "aeiou";
|
||||
const auto index = letters.find(char(c));
|
||||
if (c < 128 && index != letters.npos) {
|
||||
const std::array<uint32_t, 5> grave{0xe0,0xe8,0xec,0xf2,0xf9}, acute{0xe1,0xe9,0xed,0xf3,0xfa}, circumflex{0xe2,0xea,0xee,0xf4,0xfb}, diaeresis{0xe4,0xeb,0xef,0xf6,0xfc};
|
||||
if (accent == 0x300) composed = grave[index];
|
||||
if (accent == 0x301) composed = acute[index];
|
||||
if (accent == 0x302) composed = circumflex[index];
|
||||
if (accent == 0x308) composed = diaeresis[index];
|
||||
}
|
||||
if (accent == 0x303) composed = c == 'a' ? 0xe3 : c == 'n' ? 0xf1 : c == 'o' ? 0xf5 : 0;
|
||||
if (accent == 0x30a && c == 'a') composed = 0xe5;
|
||||
if (accent == 0x327 && c == 'c') composed = 0xe7;
|
||||
if (accent == 0x301 && c == 'y') composed = 0xfd;
|
||||
if (accent == 0x308 && c == 'y') composed = 0xff;
|
||||
if (composed) { c = composed; ++i; }
|
||||
}
|
||||
if (c >= 0x410 && c <= 0x42f) c += 32;
|
||||
if (c >= 0x391 && c <= 0x3ab && c != 0x3a2) c += 32;
|
||||
utf8(result, c);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
fs::path DemoFiles::path(const std::string &id) const {
|
||||
if (id.empty() || id.size() > 255 || id.find_first_of("/\\:") != id.npos ||
|
||||
id.front() == '.' || editor::path(id).extension() != ".json")
|
||||
throw editor::Error("Ungültige Dateiauswahl.");
|
||||
safe_directory(directory_);
|
||||
return directory_ / editor::path(id);
|
||||
}
|
||||
void DemoFiles::validate(const Json &data) const {
|
||||
if (kind_ == DemoFileKind::desktop) {
|
||||
if (!data.is_object() || data.size() != 2 || !data.contains("layout") || !valid_desktop(data.at("layout")) ||
|
||||
(data.value("theme", "") != "midnight" && data.value("theme", "") != "silver" && data.value("theme", "") != "matchday"))
|
||||
throw editor::Error("Ungültige Desktopansicht.");
|
||||
} else {
|
||||
if (!world_) throw editor::Error("Bitte zuerst eine Welt auswählen.");
|
||||
DemoSource staged(world_);
|
||||
staged.load_data(data);
|
||||
}
|
||||
}
|
||||
DemoFileEntry DemoFiles::decode(const fs::path &file, const std::string &raw) const {
|
||||
DemoFileEntry row;
|
||||
row.id = editor::utf8(file.filename()); row.token = content::sha256(raw); row.bytes = raw.size();
|
||||
row.modified = stamp(std::chrono::file_clock::to_sys(fs::last_write_time(file)));
|
||||
const auto value = Json::parse(raw);
|
||||
if (value.value("schema", "") == "openbmh-ui-file@1") {
|
||||
const auto expected_kind = kind_ == DemoFileKind::career ? "career" : "desktop";
|
||||
if (value.at("kind") != expected_kind) throw editor::Error("Die Datei gehört nicht zu dieser Ansicht.");
|
||||
if (kind_ == DemoFileKind::career && (!world_ || value.at("world") != world_->manifest().value("id", "") || value.at("world_revision") != content::sha256(world_->manifest().dump())))
|
||||
throw editor::Error("Die Datei gehört zu einer anderen Welt oder Quellrevision.");
|
||||
row.name = clean_name(value.at("name")); row.created = value.at("created").get<std::string>();
|
||||
if (row.created.size() > 64) throw editor::Error("Ungültige Dateimetadaten.");
|
||||
row.data = value.at("data"); row.preview_png = unhex(value.at("preview_png"));
|
||||
if (value.at("data_sha256") != content::sha256(row.data.dump()) || value.at("preview_sha256") != content::sha256(row.preview_png))
|
||||
throw editor::Error("Datei und Vorschau sind beschädigt.");
|
||||
} else {
|
||||
row.legacy = true; row.name = clean_name(editor::utf8(file.stem())); row.created = row.modified;
|
||||
row.data = kind_ == DemoFileKind::career ? value : Json{{"layout", value}, {"theme", "midnight"}};
|
||||
if (kind_ == DemoFileKind::desktop && !migrate_desktop(row.data["layout"]))
|
||||
throw editor::Error("Ungültige ältere Desktopansicht.");
|
||||
auto image = file; image.replace_extension(".png");
|
||||
if (fs::exists(image)) row.preview_png = read_regular(image);
|
||||
}
|
||||
validate_png(row.preview_png, kind_ == DemoFileKind::desktop && !row.legacy);
|
||||
return row;
|
||||
}
|
||||
std::vector<DemoFileEntry> DemoFiles::list() const {
|
||||
safe_directory(directory_);
|
||||
std::vector<DemoFileEntry> rows;
|
||||
if (!fs::exists(directory_)) return rows;
|
||||
for (const auto &file : fs::directory_iterator(directory_)) {
|
||||
if (file.path().extension() != ".json" || editor::utf8(file.path().filename()).starts_with('.')) continue;
|
||||
DemoFileEntry row;
|
||||
try { row = decode(file.path(), read_regular(file.path())); }
|
||||
catch (const std::exception &e) {
|
||||
row.id = editor::utf8(file.path().filename()); row.name = editor::utf8(file.path().stem()); row.error = e.what();
|
||||
try {
|
||||
if (!file.is_symlink() && file.is_regular_file()) { const auto bytes = editor::read_file(file.path(), file_limit); row.token = content::sha256(bytes); row.bytes = bytes.size(); }
|
||||
} catch (...) { /* Keep the explicit unreadable row without a delete token. */ }
|
||||
}
|
||||
rows.push_back(std::move(row));
|
||||
}
|
||||
std::sort(rows.begin(), rows.end(), [](const auto &a, const auto &b) { return a.name < b.name; });
|
||||
return rows;
|
||||
}
|
||||
DemoFileEntry DemoFiles::read(const std::string &id, const std::string &expected) const {
|
||||
const auto file = path(id);
|
||||
const auto raw = read_regular(file);
|
||||
if (!expected.empty() && content::sha256(raw) != expected)
|
||||
throw editor::Error("Diese Datei wurde inzwischen geändert. Bitte erneut auswählen.");
|
||||
auto row = decode(file, raw); validate(row.data); return row;
|
||||
}
|
||||
std::string DemoFiles::free_name(const std::string &base) const {
|
||||
const auto clean = clean_name(base); const auto rows = list();
|
||||
const bool compatibility = kind_ == DemoFileKind::desktop;
|
||||
const auto used = [&](const std::string &n) { const auto key = name_key(n, compatibility); return std::any_of(rows.begin(), rows.end(), [&](const auto &r) { try { return name_key(r.name, compatibility) == key; } catch (...) { return false; } }); };
|
||||
if (!used(clean) && !(kind_ == DemoFileKind::desktop && name_key(clean, compatibility) == "standard")) return clean;
|
||||
auto points = codepoints(clean); if (points.size() > 50) points.resize(50);
|
||||
std::string prefix; for (auto c : points) utf8(prefix, c);
|
||||
for (uint64_t number = 2;; ++number) { const auto n = prefix + " (" + std::to_string(number) + ")"; if (!used(n)) return n; }
|
||||
}
|
||||
DemoFileEntry DemoFiles::commit(const std::string &raw_name, const Json &data, const std::string &png, const std::string &id, const std::string &expected, const std::string &created) {
|
||||
const auto name = clean_name(raw_name), key = name_key(name, kind_ == DemoFileKind::desktop);
|
||||
if (kind_ == DemoFileKind::desktop && key == "standard") throw editor::Error("Die Standardansicht bleibt unveränderlich.");
|
||||
validate(data); validate_png(png, kind_ == DemoFileKind::desktop);
|
||||
if (!id.empty() && expected.empty()) throw editor::Error("Die Bestätigung der Dateiversion fehlt.");
|
||||
for (const auto &row : list()) {
|
||||
bool duplicate = false;
|
||||
try { duplicate = row.id != id && name_key(row.name, kind_ == DemoFileKind::desktop) == key; } catch (...) {}
|
||||
if (duplicate) throw editor::Error("Diese Bezeichnung wird bereits verwendet.");
|
||||
}
|
||||
if (!id.empty()) read(id, expected);
|
||||
static std::atomic<uint64_t> serial{0};
|
||||
const auto stamp_now = stamp();
|
||||
const auto selected = id.empty() ? "entry-" + content::sha256(name + stamp_now + std::to_string(++serial) + data.dump()).substr(0, 32) + ".json" : id;
|
||||
const Json envelope = {{"schema", "openbmh-ui-file@1"}, {"kind", kind_ == DemoFileKind::career ? "career" : "desktop"},
|
||||
{"name", name}, {"created", created.empty() ? stamp_now : created}, {"world", world_ ? world_->manifest().value("id", "") : ""},
|
||||
{"world_revision", world_ ? content::sha256(world_->manifest().dump()) : ""}, {"data", data},
|
||||
{"data_sha256", content::sha256(data.dump())}, {"preview_png", hex(png)}, {"preview_sha256", content::sha256(png)}};
|
||||
const auto bytes = envelope.dump(2); if (bytes.size() > file_limit) throw editor::Error("Die Datei ist zu groß.");
|
||||
safe_directory(directory_, true);
|
||||
const auto destination = path(selected);
|
||||
editor::write_atomic(destination, bytes, !id.empty());
|
||||
return decode(destination, bytes);
|
||||
}
|
||||
DemoFileEntry DemoFiles::put(const std::string &name, const Json &data, const std::string &png, const std::string &id, const std::string &expected) {
|
||||
Lock lock(root_); return commit(name, data, png, id, expected);
|
||||
}
|
||||
DemoFileEntry DemoFiles::rename(const std::string &id, const std::string &expected, const std::string &name) {
|
||||
Lock lock(root_); const auto previous = read(id, expected);
|
||||
return commit(name, previous.data, previous.preview_png, id, previous.token, previous.created);
|
||||
}
|
||||
void DemoFiles::remove(const std::string &id, const std::string &expected) {
|
||||
Lock lock(root_); const auto file = path(id); const auto raw = read_regular(file);
|
||||
if (expected.empty() || content::sha256(raw) != expected) throw editor::Error("Diese Datei wurde inzwischen geändert. Bitte erneut auswählen.");
|
||||
// Rename is the atomic removal point. An interrupted cleanup retains the
|
||||
// recoverable original bytes in a hidden tombstone, never a half record.
|
||||
const auto trash = directory_ / (".deleted-" + content::sha256(raw) + "-" + content::sha256(id).substr(0, 12));
|
||||
if (fs::exists(trash)) throw editor::Error("Eine frühere Löschung muss erst geprüft werden.");
|
||||
fs::rename(file, trash); std::error_code error; fs::remove(trash, error);
|
||||
}
|
||||
DemoFileEntry DemoFiles::import_file(const fs::path &file) {
|
||||
auto imported = decode(file, read_regular(file)); validate(imported.data);
|
||||
// Import always creates a new record; an existing local save is never lost.
|
||||
return put(free_name(imported.name), imported.data, imported.preview_png);
|
||||
}
|
||||
void DemoFiles::export_file(const std::string &id, const std::string &expected, const fs::path &destination, bool overwrite) const {
|
||||
const auto entry = read(id, expected);
|
||||
validate_export_destination(root_, destination);
|
||||
safe_directory(destination.has_parent_path() ? destination.parent_path() : fs::path("."));
|
||||
const Json envelope = {{"schema", "openbmh-ui-file@1"}, {"kind", kind_ == DemoFileKind::career ? "career" : "desktop"},
|
||||
{"name", entry.name}, {"created", entry.created}, {"world", world_ ? world_->manifest().value("id", "") : ""},
|
||||
{"world_revision", world_ ? content::sha256(world_->manifest().dump()) : ""}, {"data", entry.data},
|
||||
{"data_sha256", content::sha256(entry.data.dump())}, {"preview_png", hex(entry.preview_png)}, {"preview_sha256", content::sha256(entry.preview_png)}};
|
||||
editor::write_atomic(destination, envelope.dump(2), overwrite);
|
||||
}
|
||||
fs::path DemoFiles::preview_file(const DemoFileEntry &entry) const {
|
||||
if (entry.preview_png.empty()) return {};
|
||||
validate_png(entry.preview_png, true);
|
||||
const auto folder = root_ / ".previews"; safe_directory(folder, true);
|
||||
const auto output = folder / (content::sha256(entry.preview_png) + ".png");
|
||||
if (!fs::exists(output) || content::sha256(read_regular(output)) != content::sha256(entry.preview_png)) editor::write_atomic(output, entry.preview_png);
|
||||
return output;
|
||||
}
|
||||
Json DemoFiles::career_metadata(const Json &data) {
|
||||
const auto date = data.at("date").get<std::string>();
|
||||
if (date.size() != 10) throw editor::Error("Ungültiges Spieldatum.");
|
||||
const int season = std::stoi(date.substr(0, 4)) - (date.substr(5, 2) < "07" ? 1 : 0);
|
||||
int matchday = 0;
|
||||
if (data.contains("game_info")) matchday = data.at("game_info").value("matchday", 0);
|
||||
return {{"season", std::to_string(season) + "/" + std::to_string(season + 1).substr(2)},
|
||||
{"matchday", matchday > 0 ? std::to_string(matchday) + ". Spieltag" : "Vorbereitung"},
|
||||
{"date", date}, {"managers", data.at("managers")}};
|
||||
}
|
||||
} // namespace bmh::modern_ui
|
||||
@@ -0,0 +1,50 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
#include "modern/ui/model.hpp"
|
||||
|
||||
namespace bmh::modern_ui {
|
||||
enum class DemoFileKind { career, desktop };
|
||||
struct DemoFileEntry {
|
||||
std::string id, name, token, created, modified, preview_png, error;
|
||||
uint64_t bytes = 0;
|
||||
Json data;
|
||||
bool legacy = false;
|
||||
bool valid() const { return error.empty(); }
|
||||
};
|
||||
// Presentation-only files, deliberately separate from OBS careers and global
|
||||
// UI preferences. A single atomic document owns payload and preview together.
|
||||
class DemoFiles {
|
||||
public:
|
||||
DemoFiles(fs::path userdata, DemoFileKind,
|
||||
std::shared_ptr<const Catalog> world);
|
||||
static std::string clean_name(const std::string &);
|
||||
static std::string name_key(const std::string &, bool compatibility = false);
|
||||
static Json career_metadata(const Json &);
|
||||
std::vector<DemoFileEntry> list() const;
|
||||
DemoFileEntry read(const std::string &id,
|
||||
const std::string &expected = {}) const;
|
||||
std::string free_name(const std::string &base) const;
|
||||
DemoFileEntry put(const std::string &name, const Json &data,
|
||||
const std::string &preview_png = {},
|
||||
const std::string &id = {},
|
||||
const std::string &expected = {});
|
||||
DemoFileEntry rename(const std::string &id, const std::string &expected,
|
||||
const std::string &name);
|
||||
void remove(const std::string &id, const std::string &expected);
|
||||
DemoFileEntry import_file(const fs::path &);
|
||||
void export_file(const std::string &id, const std::string &expected,
|
||||
const fs::path &, bool overwrite = false) const;
|
||||
fs::path preview_file(const DemoFileEntry &) const;
|
||||
void validate(const Json &) const;
|
||||
fs::path directory() const { return directory_; }
|
||||
private:
|
||||
fs::path root_, directory_;
|
||||
DemoFileKind kind_;
|
||||
std::shared_ptr<const Catalog> world_;
|
||||
fs::path path(const std::string &) const;
|
||||
DemoFileEntry decode(const fs::path &, const std::string &) const;
|
||||
DemoFileEntry commit(const std::string &, const Json &, const std::string &,
|
||||
const std::string &, const std::string &,
|
||||
const std::string &created = {});
|
||||
};
|
||||
} // namespace bmh::modern_ui
|
||||
@@ -0,0 +1,117 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "modern/ui/demo_widgets.hpp"
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
namespace bmh::modern_ui {
|
||||
const Json &widget_catalogue() {
|
||||
static const Json catalogue = Json::parse(R"widgets([
|
||||
{"id":"calendar","label":"Kalender","group":"Spieltag","description":"Spieldatum und nächster Termin","spans":{"s":[2,2],"m":[2,3],"l":[3,3]},"size":"m","route":"calendar"},
|
||||
{"id":"account","label":"Konto & Eintritt","group":"Verein","description":"Guthaben, Sparbuch und Eintrittspreis","spans":{"wide":[4,1],"s":[2,2],"m":[4,2],"l":[4,3]},"size":"m","route":"bank"},
|
||||
{"id":"competition","label":"Wettbewerb & Gegner","group":"Spieltag","description":"Das nächste Spiel auf einen Blick","spans":{"s":[2,2],"m":[4,2],"l":[4,3]},"size":"m","route":"league"},
|
||||
{"id":"portrait","label":"Managerporträt","group":"Verein","description":"Dein gewähltes Managerporträt","spans":{"s":[2,2],"m":[3,3]},"size":"s","route":"newplayer"},
|
||||
{"id":"crest","label":"Vereinswappen","group":"Verein","description":"Das Wappen deines Vereins","spans":{"s":[2,2],"m":[3,3]},"size":"s","route":"achievements"},
|
||||
{"id":"opponent-crest","label":"Gegnerwappen","group":"Spieltag","description":"Der nächste Gegner","spans":{"s":[2,2],"m":[3,3]},"size":"s","route":"league"},
|
||||
{"id":"warnings","label":"Warnlampen","group":"Verein","description":"Vereinsstatus, kompakt mit acht Lampen","spans":{"wide":[4,1],"s":[2,2],"m":[4,2],"l":[4,3]},"size":"m"},
|
||||
{"id":"fans","label":"Fan-Stimmung","group":"Verein","description":"Die aktuelle Stimmung der Fans","spans":{"s":[2,1],"m":[4,1]},"size":"s","route":"environment"},
|
||||
{"id":"own-curve","label":"Tabellenplatz · eigener Verein","group":"Statistik","description":"Deine Platzierungen im Saisonverlauf","spans":{"s":[2,2],"square":[3,3],"m":[4,2],"l":[4,4]},"size":"m","route":"tables"},
|
||||
{"id":"opponent-curve","label":"Tabellenplatz · Gegner","group":"Statistik","description":"Der Saisonverlauf deines nächsten Gegners","spans":{"s":[2,2],"square":[3,3],"m":[4,2],"l":[4,4]},"size":"m","route":"tables"},
|
||||
{"id":"comparison-curve","label":"Tabellenplätze · Vergleich","group":"Statistik","description":"Dein Verein und dein Gegner in einer gemeinsamen Grafik","spans":{"square":[3,3],"m":[4,2],"l":[4,4]},"size":"square","route":"tables"},
|
||||
{"id":"results","label":"Letzte sechs Spiele","group":"Statistik","description":"Ergebnisse und Formkurve","spans":{"wide":[4,1],"s":[2,2],"m":[4,2],"l":[4,4]},"size":"m","route":"league"},
|
||||
{"id":"duels","label":"Direkter Vergleich","group":"Statistik","description":"Die letzten Begegnungen mit dem Gegner","spans":{"s":[2,2],"m":[4,2]},"size":"s","route":"statistics"},
|
||||
{"id":"own-summary","label":"Platz & Stärke · eigener Verein","group":"Statistik","description":"Deine Mannschaft im Überblick","spans":{"s":[2,1],"m":[4,1]},"size":"s","route":"strengths"},
|
||||
{"id":"opponent-summary","label":"Platz & Stärke · Gegner","group":"Statistik","description":"Die nächste Mannschaft im Überblick","spans":{"s":[2,1],"m":[4,1]},"size":"s","route":"strengths"},
|
||||
{"id":"news","label":"Nachrichten","group":"Verein","description":"Postfach, Schlagzeilen und ungelesene Meldungen","spans":{"s":[2,2],"m":[4,2],"l":[4,4]},"size":"s","route":"news"},
|
||||
{"id":"trash","label":"Papierkorb","group":"Desktop","description":"Widgets zum Entfernen hier ablegen","spans":{"s":[1,1],"m":[2,2]},"size":"s"}
|
||||
])widgets");
|
||||
return catalogue;
|
||||
}
|
||||
Json demo_desktop_widgets(const Catalog &world, const Json &state) {
|
||||
const auto own = state.at("managers")[0].at("club").get<std::string>();
|
||||
const auto *club = world.find("clubs", own);
|
||||
const auto clubs = world.clubs(club ? club->value("competition", "") : "");
|
||||
std::string opponent = own;
|
||||
for (const auto *c : clubs)
|
||||
if (c->at("id") != own) {
|
||||
opponent = c->at("id").get<std::string>();
|
||||
break;
|
||||
}
|
||||
const auto date = state.at("date").get<std::string>();
|
||||
const int year = std::stoi(date.substr(0, 4)),
|
||||
month = std::stoi(date.substr(5, 2)),
|
||||
day = std::stoi(date.substr(8, 2));
|
||||
const auto ymd = std::chrono::year_month_day{
|
||||
std::chrono::year{year}, std::chrono::month{unsigned(month)},
|
||||
std::chrono::day{unsigned(day)}};
|
||||
if (!ymd.ok())
|
||||
throw editor::Error("invalid_widget_date");
|
||||
const std::array<const char *, 12> months{
|
||||
"Januar", "Februar", "März", "April", "Mai", "Juni",
|
||||
"Juli", "August", "September", "Oktober", "November", "Dezember"};
|
||||
const std::array<const char *, 7> weekdays{
|
||||
"Sonntag", "Montag", "Dienstag", "Mittwoch",
|
||||
"Donnerstag", "Freitag", "Samstag"};
|
||||
const auto week =
|
||||
std::chrono::weekday{std::chrono::sys_days{ymd}}.c_encoding();
|
||||
const int season = year - (month < 7 ? 1 : 0);
|
||||
Json result = {{"own", own},
|
||||
{"opponent", opponent},
|
||||
{"month", std::string(months[size_t(month - 1)]) + " " +
|
||||
std::to_string(year)},
|
||||
{"weekday", weekdays[week]},
|
||||
{"day", day},
|
||||
{"season", std::to_string(season) + "/" +
|
||||
std::to_string(season + 1).substr(2)},
|
||||
{"matchday", state.value("matchday", 0)},
|
||||
{"fans", state.value("fans", 67)},
|
||||
{"own_curve", {9, 11, 8, 8, 6, 9, 7, 5, 7, 6, 4, 5}},
|
||||
{"opponent_curve", {4, 5, 2, 3, 6, 4, 3, 5, 3, 2, 3, 2}},
|
||||
{"form", {"S", "S", "U", "N", "S", "U"}},
|
||||
{"scores", {"2:0", "3:1", "1:1", "0:2", "2:1", "0:0"}},
|
||||
{"own_rank", 5},
|
||||
{"opponent_rank", 2},
|
||||
{"own_strength", 78},
|
||||
{"opponent_strength", 83}};
|
||||
std::array<bool, 10> flags{};
|
||||
for (const auto &n : state.at("finance").at("stocks"))
|
||||
if (n > 0)
|
||||
flags[0] = true;
|
||||
flags[1] = state.at("cash") < 100000;
|
||||
for (const auto &n : state.at("advertising").at("contracts"))
|
||||
if (n.at("sponsor") == -1)
|
||||
flags[2] = true;
|
||||
const auto count = state.at("lineup").at("order").size();
|
||||
flags[5] = count < 11;
|
||||
flags[6] = count < 16;
|
||||
flags[7] = state.at("tactics").at("values")[7] > 8;
|
||||
for (const auto &[id, c] : state.at("contracts").at("players").items())
|
||||
if (c.at("months") < 4)
|
||||
flags[8] = true;
|
||||
const std::array<const char *, 10> names{
|
||||
"Aktiengewinn", "Kontostand", "Freie Werbeflächen",
|
||||
"Sondertraining", "Erschöpfung", "Startaufstellung",
|
||||
"Ersatzspieler", "Taktischer Einsatz", "Auslaufende Verträge",
|
||||
"Lizenz"};
|
||||
const std::array<const char *, 10> icons{"chart", "coins", "shirt", "star",
|
||||
"heart", "person", "person", "chart",
|
||||
"save", "check"};
|
||||
const std::array<const char *, 10> notes{
|
||||
"Aktien im Bestand können mit Gewinn verkauft werden.",
|
||||
"Das verfügbare Guthaben wird knapp.",
|
||||
"Mindestens eine Werbefläche ist noch nicht vermietet.",
|
||||
"Ein spezieller Trainingsbedarf sollte geprüft werden.",
|
||||
"Die Belastung einzelner Spieler ist zu hoch.",
|
||||
"Die Startaufstellung ist noch unvollständig.",
|
||||
"Es stehen weniger als fünf Ersatzspieler bereit.",
|
||||
"Der eingestellte Einsatz ist sehr hoch.",
|
||||
"Mindestens ein Vertrag läuft in weniger als vier Monaten aus.",
|
||||
"Die Voraussetzungen für die Lizenz müssen geprüft werden."};
|
||||
result["warnings"] = Json::array();
|
||||
for (size_t i = 0; i < flags.size(); ++i)
|
||||
result["warnings"].push_back({{"name", names[i]},
|
||||
{"icon", icons[i]},
|
||||
{"attention", flags[i]},
|
||||
{"description", notes[i]}});
|
||||
return result;
|
||||
}
|
||||
} // namespace bmh::modern_ui
|
||||
@@ -0,0 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
#include "modern/ui/catalog.hpp"
|
||||
namespace bmh::modern_ui {
|
||||
const Json &widget_catalogue();
|
||||
Json demo_desktop_widgets(const Catalog &, const Json &state);
|
||||
} // namespace bmh::modern_ui
|
||||
@@ -74,7 +74,7 @@ const std::vector<std::string> &desktop_routes() {
|
||||
"camp", "training", "transfer", "tactics", "settings",
|
||||
"scorers", "advertising", "stadium", "statistics", "environment",
|
||||
"fairplay", "highscore", "contracts", "balance", "newplayer",
|
||||
"news", "almanac"};
|
||||
"news", "almanac"};
|
||||
return value;
|
||||
}
|
||||
const std::vector<WidgetDefinition> &widget_definitions() {
|
||||
@@ -144,6 +144,9 @@ bool valid_desktop(const Json &layout) {
|
||||
for (const auto *key : {"x", "y", "w", "h"})
|
||||
if (!o.at(key).is_number_integer() || o.at(key) < 0 || o.at(key) > 3840)
|
||||
return false;
|
||||
if (o.contains("z") &&
|
||||
(!o.at("z").is_number_integer() || o.at("z") < 0 || o.at("z") > 9999))
|
||||
return false;
|
||||
if (!o.at("visible").is_boolean() || !o.at("pinned").is_boolean() ||
|
||||
o.at("widget") != widget)
|
||||
return false;
|
||||
@@ -229,6 +232,7 @@ bool arrange_desktop(Json &layout) {
|
||||
if (!valid_desktop(layout))
|
||||
return false;
|
||||
auto next = layout;
|
||||
const bool original_grid = next.at("grid");
|
||||
next["grid"] = true;
|
||||
std::vector<std::string> loose;
|
||||
for (auto &[id, o] : next["objects"].items())
|
||||
@@ -248,6 +252,48 @@ bool arrange_desktop(Json &layout) {
|
||||
return false;
|
||||
o["visible"] = true;
|
||||
}
|
||||
next["grid"] = original_grid;
|
||||
layout = std::move(next);
|
||||
return true;
|
||||
}
|
||||
bool set_desktop_grid(Json &layout, bool enabled) {
|
||||
if (!valid_desktop(layout))
|
||||
return false;
|
||||
auto next = layout;
|
||||
next["grid"] = enabled;
|
||||
if (enabled && !arrange_desktop(next))
|
||||
return false;
|
||||
layout = std::move(next);
|
||||
return true;
|
||||
}
|
||||
bool add_desktop_widget(Json &layout, const std::string &id, int columns,
|
||||
int rows) {
|
||||
if (!valid_desktop(layout))
|
||||
return false;
|
||||
const auto it =
|
||||
std::find_if(widget_definitions().begin(), widget_definitions().end(),
|
||||
[&](const auto &d) { return d.id == id; });
|
||||
if (it == widget_definitions().end() ||
|
||||
layout.at("objects").at(id).at("visible") == true ||
|
||||
std::find(it->sizes.begin(), it->sizes.end(), std::pair{columns, rows}) ==
|
||||
it->sizes.end())
|
||||
return false;
|
||||
auto next = layout;
|
||||
auto &o = next["objects"][id];
|
||||
o["w"] = columns * pitch - gap;
|
||||
o["h"] = rows * pitch - gap;
|
||||
o["x"] = left;
|
||||
o["y"] = top;
|
||||
o["pinned"] = false;
|
||||
if (!find_space(next, id, left, top, false)) {
|
||||
if (next.at("grid") == true)
|
||||
return false;
|
||||
o["x"] = (3840 - o.at("w").get<int>()) / 2;
|
||||
o["y"] = (2160 - o.at("h").get<int>()) / 2;
|
||||
}
|
||||
o["visible"] = true;
|
||||
if (!valid_desktop(next))
|
||||
return false;
|
||||
layout = std::move(next);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -19,4 +19,6 @@ bool place_desktop_object(Json &, const std::string &, int x, int y,
|
||||
bool nearest = true);
|
||||
bool resize_desktop_widget(Json &, const std::string &, int columns, int rows);
|
||||
bool arrange_desktop(Json &);
|
||||
bool set_desktop_grid(Json &, bool);
|
||||
bool add_desktop_widget(Json &, const std::string &, int columns, int rows);
|
||||
} // namespace bmh::modern_ui
|
||||
@@ -0,0 +1,491 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
DemoFiles App::files_store() const {
|
||||
return DemoFiles(user_dir(),
|
||||
files_mode_.starts_with("view-") ? DemoFileKind::desktop
|
||||
: DemoFileKind::career,
|
||||
world_);
|
||||
}
|
||||
bool App::files_bound() const {
|
||||
return source_ && files_source_ == source_.get() && files_world_ == world_ &&
|
||||
files_revision_ == snap().revision &&
|
||||
files_desktop_base_ == desktop_ && files_theme_base_ == theme_;
|
||||
}
|
||||
void App::reset_files() {
|
||||
files_mode_.clear();
|
||||
files_selected_.clear();
|
||||
files_name_.clear();
|
||||
files_feedback_.clear();
|
||||
files_rows_.clear();
|
||||
files_entry_.reset();
|
||||
files_world_.reset();
|
||||
files_source_ = nullptr;
|
||||
files_desktop_base_ = Json();
|
||||
files_theme_base_.clear();
|
||||
files_revision_ = 0;
|
||||
files_scroll_ = 0;
|
||||
files_restore_scroll_ = false;
|
||||
files_reveal_selected_ = false;
|
||||
}
|
||||
void App::files_begin(const std::string &mode) {
|
||||
reset_files();
|
||||
files_mode_ = mode;
|
||||
files_world_ = world_;
|
||||
files_source_ = source_.get();
|
||||
files_desktop_base_ = desktop_;
|
||||
files_theme_base_ = theme_;
|
||||
if (source_)
|
||||
files_revision_ = snap().revision;
|
||||
const bool layouts = mode.starts_with("view-");
|
||||
files_selected_ = mode == "view-load" ? "standard" : "";
|
||||
try {
|
||||
files_name_ =
|
||||
files_store().free_name(layouts ? "Meine Ansicht" : "Spielstand 1");
|
||||
files_reload();
|
||||
if (mode == "load" && !files_rows_.empty())
|
||||
files_select(files_rows_.front().id);
|
||||
} catch (const std::exception &e) {
|
||||
files_feedback_ = e.what();
|
||||
}
|
||||
}
|
||||
void App::files_reload(const std::string &selected) {
|
||||
files_rows_ = files_store().list();
|
||||
if (!selected.empty())
|
||||
files_selected_ = selected;
|
||||
files_entry_.reset();
|
||||
if (files_selected_.empty() || files_selected_ == "standard")
|
||||
return;
|
||||
const auto found =
|
||||
std::find_if(files_rows_.begin(), files_rows_.end(),
|
||||
[&](const auto &row) { return row.id == files_selected_; });
|
||||
if (found == files_rows_.end()) {
|
||||
files_selected_.clear();
|
||||
return;
|
||||
}
|
||||
files_entry_ = *found;
|
||||
if (!found->valid())
|
||||
return;
|
||||
try {
|
||||
files_entry_ = files_store().read(found->id, found->token);
|
||||
} catch (const std::exception &e) {
|
||||
files_entry_->error = e.what();
|
||||
}
|
||||
}
|
||||
void App::files_select(const std::string &selected) {
|
||||
files_selected_ = selected;
|
||||
files_feedback_.clear();
|
||||
files_reload();
|
||||
focus_after_render_ = selected.empty() ? "files-new"
|
||||
: selected == "standard" ? "files-standard"
|
||||
: "";
|
||||
for (size_t i = 0; i < files_rows_.size(); ++i)
|
||||
if (files_rows_[i].id == selected)
|
||||
focus_after_render_ = "files-entry-" + std::to_string(i);
|
||||
files_reveal_selected_ = true;
|
||||
refresh();
|
||||
}
|
||||
void App::files_before_render() {
|
||||
if (files_capturing_)
|
||||
return;
|
||||
const bool relevant = menu_ == "save" || menu_ == "load" ||
|
||||
menu_ == "view-save" || menu_ == "view-load";
|
||||
if (!relevant) {
|
||||
if (!files_mode_.empty())
|
||||
reset_files();
|
||||
return;
|
||||
}
|
||||
if (files_mode_ != menu_) {
|
||||
files_begin(menu_);
|
||||
return;
|
||||
}
|
||||
if (auto *list = element("files-list")) {
|
||||
files_scroll_ = list->GetScrollTop();
|
||||
files_restore_scroll_ = true;
|
||||
}
|
||||
}
|
||||
void App::files_after_render() {
|
||||
if (files_capturing_ || files_mode_ != menu_)
|
||||
return;
|
||||
context_->Update();
|
||||
if (files_restore_scroll_)
|
||||
if (auto *list = element("files-list"))
|
||||
list->SetScrollTop(files_scroll_);
|
||||
files_restore_scroll_ = false;
|
||||
if (files_reveal_selected_) {
|
||||
Rml::Element *row = nullptr;
|
||||
if (files_selected_.empty())
|
||||
row = element("files-new");
|
||||
else if (files_selected_ == "standard")
|
||||
row = element("files-standard");
|
||||
else
|
||||
for (size_t i = 0; i < files_rows_.size(); ++i)
|
||||
if (files_rows_[i].id == files_selected_)
|
||||
row = element("files-entry-" + std::to_string(i));
|
||||
if (row)
|
||||
row->ScrollIntoView(
|
||||
Rml::ScrollIntoViewOptions(Rml::ScrollAlignment::Nearest));
|
||||
if (auto *list = element("files-list"))
|
||||
files_scroll_ = list->GetScrollTop();
|
||||
files_reveal_selected_ = false;
|
||||
}
|
||||
}
|
||||
std::string App::files_capture_preview() {
|
||||
const auto old_menu = menu_, old_scene = scene_;
|
||||
files_capturing_ = true;
|
||||
menu_.clear();
|
||||
scene_ = "desktop";
|
||||
refresh();
|
||||
try {
|
||||
frame();
|
||||
int width = 0, height = 0;
|
||||
auto pixels = video_.capture(width, height);
|
||||
using Surface = std::unique_ptr<SDL_Surface, decltype(&SDL_FreeSurface)>;
|
||||
Surface original(SDL_CreateRGBSurfaceWithFormatFrom(pixels.data(), width,
|
||||
height, 32, width * 4,
|
||||
SDL_PIXELFORMAT_RGBA32),
|
||||
SDL_FreeSurface);
|
||||
Surface thumb(SDL_CreateRGBSurfaceWithFormat(0, 1280, 720, 32,
|
||||
SDL_PIXELFORMAT_RGBA32),
|
||||
SDL_FreeSurface);
|
||||
if (!original || !thumb)
|
||||
throw editor::Error(
|
||||
"Die Desktop-Vorschau konnte nicht aufgenommen werden.");
|
||||
SDL_Rect crop{int(std::lround(canvas_left_)), int(std::lround(canvas_top_)),
|
||||
int(std::lround(3840 * scale_)),
|
||||
int(std::lround(2160 * scale_))};
|
||||
crop.w = std::min(crop.w, width - crop.x);
|
||||
crop.h = std::min(crop.h, height - crop.y);
|
||||
if (SDL_SoftStretchLinear(original.get(), &crop, thumb.get(), nullptr) != 0)
|
||||
throw editor::Error("Die Desktop-Vorschau konnte nicht skaliert werden.");
|
||||
editor::images::Raster image{1280, 720,
|
||||
std::vector<uint8_t>(1280 * 720 * 4)};
|
||||
for (int y = 0; y < 720; ++y)
|
||||
std::memcpy(image.pixels.data() + y * 1280 * 4,
|
||||
static_cast<const uint8_t *>(thumb->pixels) +
|
||||
y * thumb->pitch,
|
||||
1280 * 4);
|
||||
auto png = editor::images::encode_png(image);
|
||||
menu_ = old_menu;
|
||||
scene_ = old_scene;
|
||||
files_capturing_ = false;
|
||||
refresh();
|
||||
return png;
|
||||
} catch (...) {
|
||||
menu_ = old_menu;
|
||||
scene_ = old_scene;
|
||||
files_capturing_ = false;
|
||||
refresh();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
void App::files_save(const std::string &name, const std::string &id,
|
||||
const std::string &token) {
|
||||
if (!files_bound())
|
||||
throw editor::Error("Die aktive Karriere wurde inzwischen geändert. Bitte "
|
||||
"das Fenster neu öffnen.");
|
||||
const bool layouts = files_mode_.starts_with("view-");
|
||||
const auto revision = snap().revision;
|
||||
Json payload =
|
||||
layouts ? Json{{"layout", desktop_}, {"theme", theme_}} : snap().state;
|
||||
if (!layouts)
|
||||
payload["desktop"] = desktop_;
|
||||
// Validate before the capture and before publishing any file.
|
||||
auto store = files_store();
|
||||
store.validate(payload);
|
||||
const auto png = files_capture_preview();
|
||||
if (!files_bound() || snap().revision != revision)
|
||||
throw editor::Error("Die Karriere wurde während der Aufnahme geändert.");
|
||||
const auto saved = store.put(name, payload, png, id, token);
|
||||
files_selected_ = saved.id;
|
||||
files_feedback_ =
|
||||
layouts ? "Ansicht mit Vorschau gespeichert." : "Spielstand gespeichert.";
|
||||
if (!layouts) {
|
||||
if (!source_->mark_saved(revision))
|
||||
throw editor::Error(
|
||||
"Gespeichert; die inzwischen geänderte Karriere bleibt ungesichert.");
|
||||
saved_desktop_ = desktop_;
|
||||
}
|
||||
files_saved_success(!layouts);
|
||||
refresh();
|
||||
}
|
||||
void App::files_load() {
|
||||
if (!files_bound())
|
||||
throw editor::Error("Die aktive Karriere wurde inzwischen geändert. Bitte "
|
||||
"das Fenster neu öffnen.");
|
||||
const bool layouts = files_mode_.starts_with("view-");
|
||||
if (layouts) {
|
||||
Json layout, preferences = ui_preferences_;
|
||||
std::string theme = theme_;
|
||||
if (files_selected_ == "standard")
|
||||
layout = default_desktop();
|
||||
else {
|
||||
if (!files_entry_ || !files_entry_->valid())
|
||||
return;
|
||||
const auto record =
|
||||
files_store().read(files_entry_->id, files_entry_->token);
|
||||
layout = record.data.at("layout");
|
||||
theme = record.data.at("theme").get<std::string>();
|
||||
}
|
||||
// Persist the global theme successfully before publishing either layout
|
||||
// or theme. Other global display and sound preferences remain untouched.
|
||||
preferences["theme"] = theme;
|
||||
save_ui_preferences(ui_preferences_file(), preferences);
|
||||
desktop_checkpoint(desktop_);
|
||||
desktop_ = std::move(layout);
|
||||
theme_ = theme;
|
||||
ui_preferences_ = std::move(preferences);
|
||||
ui_preferences_loaded_ = true;
|
||||
menu_.clear();
|
||||
reset_files();
|
||||
refresh();
|
||||
return;
|
||||
}
|
||||
if (!files_entry_ || !files_entry_->valid())
|
||||
return;
|
||||
const auto record = files_store().read(files_entry_->id, files_entry_->token);
|
||||
auto next = std::make_unique<DemoSource>(world_);
|
||||
auto layout = next->load_data(record.data);
|
||||
if (!files_bound())
|
||||
throw editor::Error("Die aktive Karriere wurde inzwischen geändert.");
|
||||
const auto selected_id = files_entry_->id, selected_name = files_entry_->name;
|
||||
ticket_.reset();
|
||||
source_ = std::move(next);
|
||||
desktop_ = std::move(layout);
|
||||
saved_desktop_ = desktop_;
|
||||
reset_files();
|
||||
files_loaded_success();
|
||||
menu_ = "load";
|
||||
files_begin("load");
|
||||
files_select(selected_id);
|
||||
files_feedback_ = "Spielstand „" + selected_name + "“ geladen.";
|
||||
focus_after_render_ = "files-confirm";
|
||||
refresh();
|
||||
}
|
||||
bool App::files_action(const std::string &action, Rml::Element *target) {
|
||||
if (!action.starts_with("files-"))
|
||||
return false;
|
||||
const auto id =
|
||||
target ? target->GetAttribute<Rml::String>("data-id", "") : std::string();
|
||||
try {
|
||||
if (action == "files-close") {
|
||||
quit_after_save_ = false;
|
||||
menu_.clear();
|
||||
reset_files();
|
||||
if (scene_ != "desktop")
|
||||
scene_ = "main";
|
||||
refresh();
|
||||
return true;
|
||||
}
|
||||
if (action == "files-select") {
|
||||
files_select(id);
|
||||
return true;
|
||||
}
|
||||
if (action == "files-new") {
|
||||
files_select("");
|
||||
focus_after_render_ = "files-name";
|
||||
return true;
|
||||
}
|
||||
if (action == "files-standard") {
|
||||
files_select("standard");
|
||||
return true;
|
||||
}
|
||||
if (action == "files-load") {
|
||||
files_load();
|
||||
return true;
|
||||
}
|
||||
if (!files_bound())
|
||||
throw editor::Error("Die aktive Karriere wurde inzwischen geändert. "
|
||||
"Bitte das Fenster neu öffnen.");
|
||||
auto store = files_store();
|
||||
if (action == "files-save") {
|
||||
const auto name = files_entry_ ? files_entry_->name
|
||||
: DemoFiles::clean_name(files_name_);
|
||||
auto chosen = files_entry_;
|
||||
if (!chosen)
|
||||
for (const auto &row : files_rows_) {
|
||||
bool duplicate = false;
|
||||
try {
|
||||
duplicate =
|
||||
DemoFiles::name_key(row.name,
|
||||
files_mode_.starts_with("view-")) ==
|
||||
DemoFiles::name_key(name, files_mode_.starts_with("view-"));
|
||||
} catch (...) {
|
||||
}
|
||||
if (duplicate) {
|
||||
chosen = row;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (chosen) {
|
||||
const auto row = *chosen;
|
||||
confirmation(
|
||||
(files_mode_.starts_with("view-") ? "Ansicht" : "Spielstand") +
|
||||
std::string(" „") + row.name +
|
||||
"“ durch den aktuellen Stand ersetzen?",
|
||||
[this, name, row] { files_save(name, row.id, row.token); });
|
||||
popup_accept_ = "Überschreiben";
|
||||
} else
|
||||
files_save(name, "", "");
|
||||
return true;
|
||||
}
|
||||
if (action == "files-rename" && files_entry_ && files_entry_->valid()) {
|
||||
const auto row = *files_entry_;
|
||||
text_dialog(files_mode_.starts_with("view-") ? "Ansicht umbenennen"
|
||||
: "Spielstand umbenennen",
|
||||
row.name, [this, row](const std::string &name) {
|
||||
if (!files_bound())
|
||||
throw editor::Error(
|
||||
"Die aktive Karriere wurde inzwischen geändert.");
|
||||
const auto renamed =
|
||||
files_store().rename(row.id, row.token, name);
|
||||
files_select(renamed.id);
|
||||
files_feedback_ = "Bezeichnung geändert.";
|
||||
refresh();
|
||||
});
|
||||
popup_accept_ = "Umbenennen";
|
||||
return true;
|
||||
}
|
||||
if (action == "files-delete" && files_entry_ &&
|
||||
!files_entry_->token.empty()) {
|
||||
const auto row = *files_entry_;
|
||||
confirmation("„" + row.name + "“ mit Vorschau wirklich löschen?", [this,
|
||||
row] {
|
||||
if (!files_bound())
|
||||
throw editor::Error("Die aktive Karriere wurde inzwischen geändert.");
|
||||
files_store().remove(row.id, row.token);
|
||||
files_selected_ = files_mode_ == "view-load" ? "standard" : "";
|
||||
files_reload();
|
||||
files_feedback_ = "Datei gelöscht.";
|
||||
refresh();
|
||||
});
|
||||
popup_accept_ = "Löschen";
|
||||
return true;
|
||||
}
|
||||
if (action == "files-import") {
|
||||
fs::path selected = config_.file_import;
|
||||
if (selected.empty()) {
|
||||
NFD::Guard guard;
|
||||
NFD::UniquePath chosen;
|
||||
const nfdfilteritem_t filters[] = {{"OpenBMH UI-Demodatei", "json"}};
|
||||
const auto result = NFD::OpenDialog(chosen, filters, 1);
|
||||
if (result == NFD_CANCEL)
|
||||
return true;
|
||||
if (result != NFD_OKAY)
|
||||
throw editor::Error("Die Dateiauswahl konnte nicht geöffnet werden.");
|
||||
selected = editor::path(chosen.get());
|
||||
}
|
||||
const auto imported = store.import_file(selected);
|
||||
files_select(imported.id);
|
||||
files_feedback_ =
|
||||
"Datei importiert; die aktive Karriere bleibt unverändert.";
|
||||
refresh();
|
||||
return true;
|
||||
}
|
||||
if (action == "files-export" && files_entry_ && files_entry_->valid()) {
|
||||
const auto row = *files_entry_;
|
||||
fs::path destination = config_.file_export;
|
||||
if (destination.empty()) {
|
||||
NFD::Guard guard;
|
||||
NFD::UniquePath chosen;
|
||||
const nfdfilteritem_t filters[] = {{"OpenBMH UI-Demodatei", "json"}};
|
||||
const auto result = NFD::SaveDialog(chosen, filters, 1, nullptr,
|
||||
"openbmh-ui-demo.json");
|
||||
if (result == NFD_CANCEL)
|
||||
return true;
|
||||
if (result != NFD_OKAY)
|
||||
throw editor::Error("Die Dateiauswahl konnte nicht geöffnet werden.");
|
||||
destination = editor::path(chosen.get());
|
||||
}
|
||||
const auto export_record = [this, row, destination] {
|
||||
if (!files_bound())
|
||||
throw editor::Error("Die aktive Karriere wurde inzwischen geändert.");
|
||||
files_store().export_file(row.id, row.token, destination, true);
|
||||
files_feedback_ = "Datei exportiert.";
|
||||
refresh();
|
||||
};
|
||||
if (fs::exists(destination)) {
|
||||
confirmation("Vorhandene Exportdatei ersetzen?", export_record);
|
||||
popup_accept_ = "Überschreiben";
|
||||
} else {
|
||||
store.export_file(row.id, row.token, destination);
|
||||
files_feedback_ = "Datei exportiert.";
|
||||
refresh();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} catch (const std::exception &e) {
|
||||
message("Dateiaktion nicht möglich: " + std::string(e.what()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool App::files_change(Rml::Element *target) {
|
||||
if (!target || target->GetId() != "files-name")
|
||||
return false;
|
||||
const auto *input = dynamic_cast<Rml::ElementFormControl *>(target);
|
||||
if (input)
|
||||
files_name_ = input->GetValue();
|
||||
if (auto *button = element("files-confirm")) {
|
||||
bool valid = true;
|
||||
try {
|
||||
DemoFiles::clean_name(files_name_);
|
||||
} catch (...) {
|
||||
valid = false;
|
||||
}
|
||||
if (valid && files_mode_.starts_with("view-") &&
|
||||
DemoFiles::name_key(files_name_, true) == "standard")
|
||||
valid = false;
|
||||
if (valid)
|
||||
button->RemoveAttribute("disabled");
|
||||
else
|
||||
button->SetAttribute("disabled", "disabled");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool App::files_event(Rml::Event &event) {
|
||||
if (files_mode_.empty() || !popup_.empty())
|
||||
return false;
|
||||
if (event.GetType() == "input" || event.GetType() == "change")
|
||||
return files_change(event.GetTargetElement());
|
||||
if (event.GetType() != "keydown")
|
||||
return false;
|
||||
const auto key = event.GetParameter<int>("key_identifier", 0);
|
||||
auto *target = event.GetTargetElement();
|
||||
if (key == Rml::Input::KI_ESCAPE) {
|
||||
event.StopPropagation();
|
||||
return files_action("files-close", target);
|
||||
}
|
||||
if (target && target->GetId() == "files-name" &&
|
||||
(key == Rml::Input::KI_RETURN || key == Rml::Input::KI_NUMPADENTER)) {
|
||||
event.StopPropagation();
|
||||
return files_action("files-save", target);
|
||||
}
|
||||
if (!target || !target->HasAttribute("data-file-row"))
|
||||
return false;
|
||||
if (key != Rml::Input::KI_UP && key != Rml::Input::KI_DOWN &&
|
||||
key != Rml::Input::KI_HOME && key != Rml::Input::KI_END)
|
||||
return false;
|
||||
std::vector<std::pair<std::string, std::string>> ids;
|
||||
if (files_mode_ == "save" || files_mode_ == "view-save")
|
||||
ids.emplace_back("", "files-new");
|
||||
if (files_mode_ == "view-load")
|
||||
ids.emplace_back("standard", "files-standard");
|
||||
for (size_t i = 0; i < files_rows_.size(); ++i)
|
||||
ids.emplace_back(files_rows_[i].id, "files-entry-" + std::to_string(i));
|
||||
if (ids.empty())
|
||||
return false;
|
||||
size_t index = 0;
|
||||
for (size_t i = 0; i < ids.size(); ++i)
|
||||
if (ids[i].first == files_selected_)
|
||||
index = i;
|
||||
if (key == Rml::Input::KI_HOME)
|
||||
index = 0;
|
||||
else if (key == Rml::Input::KI_END)
|
||||
index = ids.size() - 1;
|
||||
else if (key == Rml::Input::KI_DOWN)
|
||||
index = std::min(index + 1, ids.size() - 1);
|
||||
else if (index)
|
||||
--index;
|
||||
files_select(ids[index].first);
|
||||
focus_after_render_ = ids[index].second;
|
||||
event.StopPropagation();
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
std::string App::files_standard_preview() {
|
||||
// Root captures the immutable template without publishing a live layout.
|
||||
return picture(files_default_thumbnail(), 1678, 943.875);
|
||||
}
|
||||
|
||||
std::string App::files_details(bool layouts, bool save) {
|
||||
const bool standard = layouts && files_selected_ == "standard";
|
||||
const bool fresh = save && files_selected_.empty();
|
||||
if (files_entry_ && !files_entry_->valid())
|
||||
return "<div class=\"files-empty-details\"><h2>" + esc(files_entry_->name) + "</h2><p>Diese Datei kann nicht geöffnet werden.</p><p class=\"files-error\">" + esc(files_entry_->error) + "</p></div>";
|
||||
if (!fresh && !standard && !files_entry_)
|
||||
return "<div class=\"files-empty-details\">" + glyph("folder",144) + "<h2>" + std::string(layouts ? "Keine Ansicht" : "Kein Spielstand") + " ausgewählt</h2><p>Wähle links einen Eintrag aus.</p></div>";
|
||||
std::string out;
|
||||
const auto input = [&]() {
|
||||
return "<label class=\"files-name-label\"><span>Bezeichnung</span><input id=\"files-name\" data-change=\"files-name\" maxlength=\"64\" value=\"" + esc(files_name_) + "\"/></label>";
|
||||
};
|
||||
if (layouts) {
|
||||
const auto heading = standard ? "Standard" : fresh ? "Neue Ansicht" : files_entry_->name;
|
||||
out = "<h2 class=\"files-heading\">" + esc(heading) + "</h2><p class=\"files-intro\">" +
|
||||
(standard ? "Unveränderliche Vorlage nach dem ursprünglichen BMH-Desktop." : "Dein Look und deine gesamte Anordnung.") + "</p>";
|
||||
if (fresh) return out + input() + "<div class=\"files-save-illustration\">" + glyph("save", 140) + "<p>Eine Desktop-Vorschau wird beim Speichern automatisch aufgenommen.</p></div>";
|
||||
const auto payload = standard ? Json{{"layout", default_desktop()}, {"theme", theme_}} : files_entry_->data;
|
||||
if (standard) out += "<div class=\"files-thumbnail\">" + files_standard_preview() + "</div>";
|
||||
else if (!files_entry_->preview_png.empty()) {
|
||||
const auto preview = files_store().preview_file(*files_entry_);
|
||||
out += "<div class=\"files-thumbnail\">" + picture(renderer_.local_image(preview, 1920), 1678, 943.875) + "</div>";
|
||||
} else out += "<p class=\"files-no-preview\">Für diese ältere Ansicht ist keine Vorschau vorhanden.</p>";
|
||||
int widgets = 0, apps = 0;
|
||||
for (const auto &[id, object] : payload.at("layout").at("objects").items())
|
||||
if (object.value("visible", false)) { if (object.value("widget", false)) ++widgets; else ++apps; }
|
||||
const auto look = payload.at("theme").get<std::string>();
|
||||
const std::vector<std::pair<std::string, std::string>> meta = {{"Gestaltung", look == "silver" ? "Silver Glass" : look == "matchday" ? "Matchday" : "Midnight Glass"}, {"Widgets", std::to_string(widgets)}, {"Buttons", std::to_string(apps)}, {"Hintergrund", "Stadion bei Nacht"}};
|
||||
out += "<div class=\"files-metadata\">";
|
||||
for (const auto &[label, value] : meta) out += "<div class=\"files-metadata-cell\"><span>" + esc(label) + "</span><strong>" + esc(value) + "</strong></div>";
|
||||
return out + "</div>";
|
||||
}
|
||||
const auto data = fresh ? snap().state : files_entry_->data;
|
||||
const auto meta = DemoFiles::career_metadata(data);
|
||||
const auto &managers = meta.at("managers");
|
||||
const Json *own = managers.empty() ? nullptr : world_->find("clubs", managers.at(0).value("club", ""));
|
||||
out = "<div class=\"files-detail-heading\"><div class=\"files-crest\">" + crest(own, 108) + "</div><div><p>" + std::string(fresh ? "Aktuelles Spiel" : "Gespeicherter Spielstand") + "</p><h2>" + esc(fresh ? "Neuer Speicherstand" : files_entry_->name) + "</h2><span>" + esc(own ? world_->name(*own) : "") + "</span></div></div>";
|
||||
if (fresh) out += input();
|
||||
out += "<div class=\"files-metadata\">";
|
||||
const auto iso_date = meta.at("date").get<std::string>();
|
||||
const auto display_date = iso_date.substr(8, 2) + "." + iso_date.substr(5, 2) + "." + iso_date.substr(0, 4);
|
||||
const std::vector<std::pair<std::string, std::string>> cells = {{"Saison", meta.at("season")}, {"Spieltag", meta.at("matchday")}, {"Spieldatum", display_date}, {"Spieler", std::to_string(managers.size())}};
|
||||
for (const auto &[label, value] : cells) out += "<div class=\"files-metadata-cell\"><span>" + esc(label) + "</span><strong>" + esc(value) + "</strong></div>";
|
||||
out += "</div><section class=\"files-managers\"><h3>Mitspieler</h3>";
|
||||
for (const auto &manager : managers) {
|
||||
const auto *managed = world_->find("clubs", manager.value("club", ""));
|
||||
out += "<div><strong>" + esc(manager.value("name", "")) + "</strong><span>" + esc(managed ? world_->name(*managed) : "") + "</span></div>";
|
||||
}
|
||||
return out + "</section><p class=\"files-timestamp\">" + (fresh ? "Diese Angaben werden mit dem Spielstand gespeichert." : "Gespeichert am " + esc(files_entry_->created) + "<br/>Geändert am " + esc(files_entry_->modified) + " · " + std::to_string(files_entry_->bytes) + " Bytes") + "</p>";
|
||||
}
|
||||
std::string App::render_files(bool layouts, bool save) {
|
||||
if (files_mode_ != menu_) files_begin(menu_);
|
||||
std::string entries;
|
||||
const auto row = [&](const std::string &action, const std::string &id, const std::string &label, const std::string &subtitle, bool selected, const std::string &identity, bool fresh = false) {
|
||||
const auto icon = fresh ? "plus" : id == "standard" ? "grid" : layouts ? "image" : "save";
|
||||
return btn(action, "<span class=\"files-entry-icon\">" + glyph(icon, 40) + "</span><span class=\"files-entry-copy\"><strong>" + esc(label) + "</strong><span>" + esc(subtitle) + "</span></span>" + (id == "standard" ? "<span class=\"files-standard-badge\">Standard</span>" : ""), std::string("files-entry ") + (selected ? "selected" : ""), "id=\"" + identity + "\" role=\"option\" data-id=\"" + esc(id) + "\" data-file-row=\"true\" aria-selected=\"" + (selected ? "true" : "false") + "\"");
|
||||
};
|
||||
if (save) entries += row("files-new", "", layouts ? "Neue Ansicht" : "Neuer Speicherstand", layouts ? "Aktuellen Desktop mit Vorschau sichern" : "Aktuellen Spielstand neu speichern", files_selected_.empty(), "files-new", true);
|
||||
if (layouts && !save) entries += row("files-standard", "standard", "Standard", "Nach dem Original von BMH · immer verfügbar", files_selected_ == "standard", "files-standard");
|
||||
for (size_t i = 0; i < files_rows_.size(); ++i) {
|
||||
const auto &entry = files_rows_[i];
|
||||
entries += row("files-select", entry.id, entry.name, entry.valid() ? "Gespeichert am " + entry.created : "Datei kann nicht geöffnet werden", files_selected_ == entry.id, "files-entry-" + std::to_string(i));
|
||||
}
|
||||
if (entries.empty()) entries = "<p class=\"files-empty-list\">Noch keine Spielstände vorhanden.</p>";
|
||||
std::string details;
|
||||
try { details = files_details(layouts, save); }
|
||||
catch (const std::exception &e) { details = "<div class=\"files-empty-details\"><h2>Datei nicht verfügbar</h2><p>" + esc(e.what()) + "</p></div>"; }
|
||||
const bool selected = files_entry_ && files_entry_->valid();
|
||||
bool can_save = save && (!files_entry_ || selected);
|
||||
if (save && !selected) try { DemoFiles::clean_name(files_name_); } catch (...) { can_save = false; }
|
||||
const auto disabled = selected ? "" : "disabled";
|
||||
std::string footer = "<div class=\"files-file-actions\">";
|
||||
if (!layouts) footer += btn("files-import", "Importieren") + btn("files-export", "Exportieren", {}, disabled);
|
||||
footer += "</div><div class=\"files-record-actions\">" + btn("files-rename", "Umbenennen", {}, disabled) + btn("files-delete", "Löschen", {}, files_entry_ && !files_entry_->token.empty() ? "" : "disabled") + "</div><div class=\"files-confirm-actions\">" + btn("files-close", "Abbrechen") + btn(save ? "files-save" : "files-load", save ? "Speichern" : "Laden", "primary", "id=\"files-confirm\" " + std::string((save ? can_save : selected || (layouts && files_selected_ == "standard")) ? "" : "disabled")) + "</div>";
|
||||
const auto content = "<div class=\"files-layout" + std::string(layouts ? " files-views" : "") + "\"><section class=\"files-browser panel\"><div class=\"files-browser-header\"><h2>" + std::string(layouts ? "Ansichten" : "Spielstände") + "</h2><span>" + std::to_string(files_rows_.size()) + "</span></div><div id=\"files-list\" class=\"files-list\" role=\"listbox\" aria-label=\"" + (layouts ? "Ansicht" : "Spielstand") + " auswählen\">" + entries + "</div></section><section class=\"files-details panel\">" + details + "</section></div>";
|
||||
if (layouts) {
|
||||
const auto feedback = files_feedback_.empty() ? (save ? "Look, Widgets, Größen und Fixierungen werden gemeinsam gespeichert." : "Die Standardansicht ist fixiert und bleibt immer verfügbar.") : files_feedback_;
|
||||
const auto view_actions = "<p id=\"files-feedback\" role=\"status\">" + esc(feedback) + "</p><div class=\"files-view-record-actions\">" + btn("files-rename", "Umbenennen", {}, disabled) + btn("files-delete", "Löschen", {}, files_entry_ && !files_entry_->token.empty() ? "" : "disabled") + "</div>" + btn("files-close", "Abbrechen") + btn(save ? "files-save" : "files-load", save ? "Speichern" : "Laden", "primary", "id=\"files-confirm\" " + std::string((save ? can_save : selected || files_selected_ == "standard") ? "" : "disabled"));
|
||||
return desktop_dialog(save ? "Ansicht speichern" : "Ansicht laden", content, view_actions);
|
||||
}
|
||||
const auto actions = "<footer class=\"files-actions\">" + footer + "</footer>";
|
||||
return content + "<p id=\"files-feedback\" class=\"files-feedback\" role=\"status\">" + esc(files_feedback_) + "</p>" + actions;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// App-local browser drafts have no authority over the active career.
|
||||
std::string files_mode_, files_selected_, files_name_, files_feedback_;
|
||||
Json files_desktop_base_;
|
||||
std::string files_theme_base_;
|
||||
std::vector<DemoFileEntry> files_rows_;
|
||||
std::optional<DemoFileEntry> files_entry_;
|
||||
std::shared_ptr<const Catalog> files_world_;
|
||||
const DataSource *files_source_ = nullptr;
|
||||
uint64_t files_revision_ = 0;
|
||||
float files_scroll_ = 0.f;
|
||||
bool files_restore_scroll_ = false, files_capturing_ = false;
|
||||
DemoFiles files_store() const;
|
||||
bool files_bound() const;
|
||||
void reset_files();
|
||||
void files_begin(const std::string &);
|
||||
void files_reload(const std::string &selected = {});
|
||||
void files_select(const std::string &);
|
||||
void files_before_render();
|
||||
void files_after_render();
|
||||
std::string render_files(bool layouts, bool save);
|
||||
std::string files_details(bool layouts, bool save);
|
||||
std::string files_standard_preview();
|
||||
bool files_action(const std::string &, Rml::Element *);
|
||||
bool files_change(Rml::Element *);
|
||||
bool files_event(Rml::Event &);
|
||||
std::string files_capture_preview();
|
||||
void files_save(const std::string &, const std::string &, const std::string &);
|
||||
void files_load();
|
||||
void files_saved_success(
|
||||
bool career); // Root owns main-menu / quit continuation.
|
||||
void files_loaded_success(); // Root resets source-dependent presenters.
|
||||
|
||||
bool files_reveal_selected_ = false;
|
||||
@@ -250,7 +250,14 @@ void DemoSource::save(const fs::path &file, const Json &desktop) {
|
||||
saved_ = state_;
|
||||
}
|
||||
Json DemoSource::load(const fs::path &file) {
|
||||
auto data = Json::parse(editor::read_file(file));
|
||||
return load_data(Json::parse(editor::read_file(file)));
|
||||
}
|
||||
bool DemoSource::mark_saved(uint64_t expected_revision) {
|
||||
if (revision_ != expected_revision) return false;
|
||||
saved_ = state_;
|
||||
return true;
|
||||
}
|
||||
Json DemoSource::load_data(Json data) {
|
||||
if (data.value("schema", "") != "openbmh-ui-demo@1" ||
|
||||
data.value("world", "") != catalog_->manifest().value("id", ""))
|
||||
throw editor::Error("wrong_demo_world");
|
||||
|
||||
@@ -42,6 +42,8 @@ public:
|
||||
Json read_statistics(const Json &) const override;
|
||||
void save(const fs::path &, const Json &desktop);
|
||||
Json load(const fs::path &);
|
||||
Json load_data(Json);
|
||||
bool mark_saved(uint64_t expected_revision);
|
||||
bool dirty() const { return state_ != saved_; }
|
||||
|
||||
private:
|
||||
|
||||
@@ -1,210 +1,49 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Included in the native UI implementation's anonymous namespace.
|
||||
void App::init_desktop() {
|
||||
if (!desktop_.contains("objects")) {
|
||||
desktop_ = default_desktop();
|
||||
saved_desktop_ = desktop_;
|
||||
if(!desktop_.contains("objects"))desktop_=default_desktop();
|
||||
if(!working_desktop_initialized_){
|
||||
working_desktop_initialized_=true;
|
||||
const auto file=user_dir()/"working-desktop.json";
|
||||
if(config_.state.empty()&&fs::is_regular_file(file)){
|
||||
try{auto next=Json::parse(editor::read_file(file));if(!migrate_desktop(next))throw editor::Error("Ungültige Desktopanordnung.");desktop_=std::move(next);}
|
||||
catch(const std::exception &){message("Die gespeicherte Desktopanordnung konnte nicht geladen werden. Die Standardansicht wird verwendet.");}
|
||||
}
|
||||
working_desktop_base_=desktop_;saved_desktop_=desktop_;
|
||||
}
|
||||
}
|
||||
|
||||
std::string App::widget(const std::string &id, const Json &o) {
|
||||
const auto s = snap();
|
||||
const auto *own = club(s);
|
||||
const auto w = o.value("w", 472), h = o.value("h", 472);
|
||||
const auto row = world_->clubs(own ? own->value("competition", "") : league_);
|
||||
const auto *opponent =
|
||||
row.size() > 1 ? (row[0] == own ? row[1] : row[0]) : own;
|
||||
auto heading = [&](const std::string &name) {
|
||||
return "<div class=\"card-heading\">" + esc(name) + "</div>";
|
||||
};
|
||||
if (id == "calendar") {
|
||||
const auto date = s.state.value("date", std::string("2026-07-01"));
|
||||
const auto year = date.substr(0, 4), day = date.substr(8, 2);
|
||||
const int month = std::stoi(date.substr(5, 2));
|
||||
const std::array<const char *, 12> months = {
|
||||
"Januar", "Februar", "März", "April", "Mai", "Juni",
|
||||
"Juli", "August", "September", "Oktober", "November", "Dezember"};
|
||||
return "<div "
|
||||
"style=\"height:116dp;background-color:#a45254;color:white;text-"
|
||||
"align:center;padding-top:30dp;font-size:38dp;\">" +
|
||||
std::string(months[size_t(std::clamp(month, 1, 12) - 1)]) + " " +
|
||||
year +
|
||||
"</div><div class=\"center\" style=\"padding-top:66dp;\"><p "
|
||||
"class=\"muted\" style=\"font-size:38dp;\">Saisonvorbereitung</p><p "
|
||||
"style=\"font-size:240dp;line-height:1.1;\">" +
|
||||
std::to_string(std::stoi(day)) + "</p><p class=\"small\">" +
|
||||
esc(date) + "</p></div>" +
|
||||
btn("open:calendar",
|
||||
glyph("calendar", 32) +
|
||||
"<span>Kalender öffnen</span><span "
|
||||
"class=\"calendar-arrow\">" +
|
||||
glyph("arrow-diagonal", 30) + "</span>",
|
||||
"card-button calendar-link",
|
||||
"style=\"left:0;bottom:0;width:100%;height:90dp;border-top:2dp "
|
||||
"var(--border);font-size:25dp;color:var(--muted);\"");
|
||||
}
|
||||
if (id == "account") {
|
||||
if (h < 300)
|
||||
return "<div style=\"padding:18dp 28dp;\"><span "
|
||||
"class=\"small\">Konto</span><p "
|
||||
"style=\"font-size:46dp;color:var(--accent);\">" +
|
||||
cash(s.state.value("cash", int64_t(0))) + "</p></div>" +
|
||||
btn("ticket",
|
||||
"Eintritt " +
|
||||
std::to_string(s.state.value("ticket", 13)) + " €",
|
||||
"card-button",
|
||||
"id=\"desktop-ticket\" data-interactive=\"true\" "
|
||||
"style=\"right:20dp;top:45dp;font-size:32dp;\"");
|
||||
return heading("Vereinskasse") +
|
||||
"<div style=\"position:absolute;left:34dp;top:90dp;\"><p "
|
||||
"class=\"small\">Guthaben</p><p style=\"font-size:" +
|
||||
std::to_string(w < 600 ? 48 : 65) +
|
||||
"dp;letter-spacing:-2dp;color:var(--accent);margin-top:10dp;\">" +
|
||||
cash(s.state.value("cash", int64_t(0))) +
|
||||
"</p></div><div "
|
||||
"style=\"position:absolute;left:0;right:0;bottom:0;height:132dp;"
|
||||
"border-top:2dp var(--border);padding:22dp 34dp;\"><span "
|
||||
"class=\"small\">Sparbuch</span><p style=\"font-size:34dp;\">" +
|
||||
cash(s.state.value("deposit", int64_t(0))) + "</p></div>" +
|
||||
btn("ticket",
|
||||
"<span class=\"small\">Eintritt</span><br/>" +
|
||||
std::to_string(s.state.value("ticket", 13)) + " € ›",
|
||||
"card-button",
|
||||
"id=\"desktop-ticket\" data-interactive=\"true\" "
|
||||
"style=\"right:30dp;bottom:20dp;min-width:200dp;padding:12dp "
|
||||
"24dp;font-size:34dp;background-color:var(--soft);border-radius:"
|
||||
"18dp;\"");
|
||||
}
|
||||
if (id == "portrait")
|
||||
return img(std::string(manager(s).value("portrait_style", "photo") ==
|
||||
"painted"
|
||||
? "manager-painted."
|
||||
: "manager.") +
|
||||
std::to_string(manager(s).value("portrait", 0)),
|
||||
w, h, false, true, 800) +
|
||||
"<div "
|
||||
"style=\"position:absolute;left:0;right:0;bottom:0;padding:50dp "
|
||||
"30dp "
|
||||
"28dp;decorator:linear-gradient(0deg,#0d1928ed,#0d192800);color:#"
|
||||
"eff4f8;\"><small>Manager</small><p style=\"font-size:34dp;\">" +
|
||||
esc(manager(s).value("name", "")) + "</p></div>";
|
||||
if (id == "crest" || id == "opponent-crest")
|
||||
return "<div class=\"center\" style=\"padding:35dp 30dp;\">" +
|
||||
crest(id == "crest" ? own : opponent, std::min(w - 60, h - 150)) +
|
||||
"</div><div "
|
||||
"style=\"position:absolute;left:15dp;right:15dp;bottom:28dp;text-"
|
||||
"align:center;font-size:28dp;\"><p class=\"small\">" +
|
||||
(id == "crest" ? "Dein Verein" : "Nächster Gegner") + "</p><p>" +
|
||||
esc(world_->name(*(id == "crest" ? own : opponent))) + "</p></div>";
|
||||
if (id == "competition")
|
||||
return heading("Nächste Begegnung") +
|
||||
"<div class=\"row\" "
|
||||
"style=\"position:absolute;left:30dp;right:30dp;top:180dp;justify-"
|
||||
"content:space-around;text-align:center;\"><div>" +
|
||||
crest(own, 80) + "<p style=\"font-size:23dp;margin-top:14dp;\">" +
|
||||
esc(own ? world_->name(*own) : "") +
|
||||
"</p></div><div><p class=\"small\">Freundschaftsspiel</p><p "
|
||||
"style=\"font-size:54dp;\">19:00</p><p class=\"small\">Heim · "
|
||||
"Samstag</p></div><div>" +
|
||||
crest(opponent, 80) +
|
||||
"<p style=\"font-size:23dp;margin-top:14dp;\">" +
|
||||
esc(opponent ? world_->name(*opponent) : "") + "</p></div></div>";
|
||||
if (id == "warnings") {
|
||||
const std::array<const char *, 10> names = {
|
||||
"Aktiengewinn", "Kontostand", "Freie Werbeflächen",
|
||||
"Sondertraining", "Erschöpfung", "Startaufstellung",
|
||||
"Ersatzspieler", "Taktischer Einsatz", "Auslaufende Verträge",
|
||||
"Lizenz"};
|
||||
const std::array<const char *, 10> icons = {
|
||||
"chart", "coins", "shirt", "star", "heart",
|
||||
"person", "person", "chart", "save", "check"};
|
||||
const std::array<int, 8> wide_members = {0, 1, 2, 3, 5, 7, 8, 9};
|
||||
const bool wide = h < 300;
|
||||
const int columns = wide ? 8 : 5, count = wide ? 8 : 10;
|
||||
std::string out = heading("Vereinsstatus");
|
||||
for (int i = 0; i < count; ++i) {
|
||||
const int member = wide ? wide_members[size_t(i)] : i;
|
||||
const int cell_w = (w - 52) / columns;
|
||||
const int x = 26 + cell_w * (i % columns),
|
||||
y = wide ? 90 : 95 + (i / columns) * 175;
|
||||
out += "<div style=\"position:absolute;" +
|
||||
rect(x, y, cell_w, wide ? 110 : 160) +
|
||||
"\"><div style=\"position:absolute;left:" +
|
||||
std::to_string((cell_w - 64) / 2) +
|
||||
"dp;top:0;width:64dp;height:64dp;border:2dp "
|
||||
"#9ddbc653;border-radius:32dp;padding:12dp;background-color:" +
|
||||
std::string(member == 2 ? "#c57c67" : "#65a58d") + ";\">" +
|
||||
glyph(icons[size_t(member)], 36) + "</div>" +
|
||||
(wide ? ""
|
||||
: "<p class=\"center\" "
|
||||
"style=\"position:absolute;left:0;right:0;top:80dp;font-"
|
||||
"size:18dp;line-height:1.15;\">" +
|
||||
std::string(names[size_t(member)]) + "</p>") +
|
||||
"</div>";
|
||||
}
|
||||
return out;
|
||||
}
|
||||
if (id == "trash")
|
||||
return "<div class=\"center\" style=\"padding-top:35dp;\">" +
|
||||
glyph("trash", 100) +
|
||||
"</div><p class=\"center small\">Papierkorb</p>";
|
||||
if (id == "fans")
|
||||
return heading("Fan-Stimmung") +
|
||||
"<p class=\"center accent\" "
|
||||
"style=\"font-size:80dp;padding-top:85dp;\">" +
|
||||
std::to_string(s.state.value("fans", 67)) + " %</p>";
|
||||
if (id == "news")
|
||||
return render_news_widget(o);
|
||||
if (id == "results")
|
||||
return heading("Letzte sechs Spiele") +
|
||||
"<div class=\"row\" style=\"padding:100dp "
|
||||
"30dp;justify-content:space-around;font-size:40dp;\"><span>–</"
|
||||
"span><span>–</span><span>–</span><span>–</span><span>–</"
|
||||
"span><span>–</span></div>";
|
||||
if (id == "own-summary" || id == "opponent-summary")
|
||||
return heading(id == "own-summary" ? "Platz & Stärke · eigener Verein"
|
||||
: "Platz & Stärke · Gegner") +
|
||||
"<div class=\"row\" style=\"padding:80dp "
|
||||
"30dp;justify-content:space-around;font-size:56dp;\"><span>–</"
|
||||
"span><span>–</span></div>";
|
||||
const auto caption = id == "duels" ? "Direkter Vergleich"
|
||||
: id == "comparison-curve" ? "Tabellenplätze · Vergleich"
|
||||
: id == "own-curve" ? "Tabellenplatz · eigener Verein"
|
||||
: "Tabellenplatz · Gegner";
|
||||
return heading(caption) +
|
||||
"<div "
|
||||
"style=\"position:absolute;left:50dp;right:30dp;top:95dp;bottom:45dp;"
|
||||
"border-left:2dp var(--muted);border-bottom:2dp var(--muted);\"><p "
|
||||
"class=\"center muted\" "
|
||||
"style=\"padding-top:80dp;\">Saisonvorbereitung</p></div>";
|
||||
}
|
||||
std::string App::render_desktop() {
|
||||
init_desktop();
|
||||
const auto s = snap();
|
||||
widget_data_ = demo_desktop_widgets(*world_, s.state);
|
||||
const auto *c = club(s);
|
||||
std::string out =
|
||||
"<div class=\"info-bar\">" +
|
||||
"<div class=\"desktop-layer\"><div class=\"info-bar\">" +
|
||||
btn("desktop-context",
|
||||
crest(c, 82) + "<span><strong>" + esc(c ? world_->name(*c) : "") +
|
||||
"</strong><small>" + esc(manager(s).value("name", "")) +
|
||||
"</small></span>",
|
||||
"identity") +
|
||||
"<div class=\"info-date\">Saisonvorbereitung<small>" +
|
||||
esc(s.state.value("date", std::string())) +
|
||||
"identity", "id=\"desktop-identity\"") +
|
||||
"<div class=\"info-date\">" + std::string(widget_data_.at("matchday")==0?"Saisonvorbereitung":std::to_string(widget_data_.at("matchday").get<int>())+". Spieltag") + "<small>" +
|
||||
esc(widget_data_.at("season").get<std::string>()) +
|
||||
"</small></div><div class=\"info-cash\"><small>Guthaben</small><strong>" +
|
||||
cash(s.state.value("cash", int64_t(0))) + "</strong></div></div>";
|
||||
if(desktop_.value("grid",true))for(int row=0;row<7;++row)for(int col=0;col<15;++col)out+="<span class=\"desktop-grid-dot\" style=\"left:"+std::to_string(64+col*248)+"dp;top:"+std::to_string(224+row*248)+"dp;\"></span>";
|
||||
for (const auto &[id, o] : desktop_["objects"].items()) {
|
||||
if (!o.value("visible", false))
|
||||
continue;
|
||||
const auto style = rect(o.value("x", 0), o.value("y", 0), o.value("w", 224),
|
||||
o.value("h", 224));
|
||||
if (o.value("widget", false))
|
||||
out += "<div id=\"object-" + esc(id) + "\" data-object=\"" + esc(id) +
|
||||
"\" class=\"desktop-card\" style=\"" + style + "\">" +
|
||||
o.value("h", 224)) + "z-index:" + std::to_string(o.value("z", 1)) + ";";
|
||||
if (o.value("widget", false)) {
|
||||
std::string size="s",route;
|
||||
for(const auto &d:widget_catalogue())if(d.at("id")==id){route=d.value("route","");for(const auto &[key,span]:d.at("spans").items())if(o.at("w")==span[0].get<int>()*248-24&&o.at("h")==span[1].get<int>()*248-24)size=key;}
|
||||
out += "<div tabindex=\"0\" data-widget=\""+esc(id)+"\" data-size=\""+size+"\" data-pinned=\""+(o.value("pinned",true)?"true":"false")+"\" "+(route.empty()?"":"data-action=\"open:"+route+"\" ")+"id=\"object-" + esc(id) + "\" data-object=\"" + esc(id) +
|
||||
"\" class=\"desktop-card desk-card "+std::string(id=="trash"?"desk-utility":"")+"\" style=\"" + style + "\">" +
|
||||
widget(id, o) +
|
||||
(o.value("pinned", true) ? "<div class=\"pin-dot\"></div>" : "") +
|
||||
"</div>";
|
||||
else {
|
||||
} else {
|
||||
const auto route = id.substr(4);
|
||||
const std::array<std::string, 32> colors = {
|
||||
"#3d789b", "#375a83", "#477c73", "#42846b", "#a58a49", "#586ba0",
|
||||
@@ -226,12 +65,12 @@ std::string App::render_desktop() {
|
||||
"style=\"decorator:linear-gradient(140deg," +
|
||||
top + "," + bottom + ");\">" +
|
||||
img("button." + route, 146, 146, false, false, 256) +
|
||||
"</div><span class=\"app-name\">" + esc(title(route)) + "</span>" +
|
||||
"</div><span class=\"app-name\">" + esc(route=="transfer"?"Transfer":title(route)) + "</span>" +
|
||||
(o.value("pinned", true) ? "<div class=\"pin-dot\"></div>" : "") +
|
||||
"</button>";
|
||||
}
|
||||
}
|
||||
return out;
|
||||
return out + "</div>";
|
||||
}
|
||||
std::string App::render_newgame() {
|
||||
std::string body = "<h2>Grundeinstellungen</h2><p class=\"small\" "
|
||||
@@ -711,56 +550,9 @@ std::string App::render_camp() {
|
||||
btn("camp-remember", "Vormerken", "primary") + "</div></div>";
|
||||
return body;
|
||||
}
|
||||
std::string App::render_save(bool save) {
|
||||
const auto directory = user_dir() / "saves";
|
||||
std::string body = "<div class=\"panel list\" "
|
||||
"style=\"position:absolute;left:0;top:0;width:1120dp;"
|
||||
"bottom:145dp;padding:24dp;\">";
|
||||
if (save)
|
||||
body += btn("save-new", "Neuer Speicherstand", "choice",
|
||||
"style=\"width:100%;text-align:left;min-height:100dp;margin-"
|
||||
"bottom:14dp;\"");
|
||||
if (fs::exists(directory))
|
||||
for (const auto &file : fs::directory_iterator(directory))
|
||||
if (file.path().extension() == ".json") {
|
||||
const auto name = editor::utf8(file.path().stem());
|
||||
body += btn("save-select", esc(name),
|
||||
std::string("choice ") +
|
||||
(selections_["save"] == name ? "selected" : ""),
|
||||
"data-id=\"" + esc(name) +
|
||||
"\" "
|
||||
"style=\"width:100%;min-height:110dp;text-align:left;"
|
||||
"margin-bottom:14dp;\"");
|
||||
}
|
||||
body += "</div><div class=\"panel\" "
|
||||
"style=\"position:absolute;left:1160dp;right:0;top:0;bottom:145dp;"
|
||||
"padding:50dp;\"><h2>" +
|
||||
esc(selections_["save"].empty() ? "Speicherstand auswählen"
|
||||
: selections_["save"]) +
|
||||
"</h2>";
|
||||
const auto s = snap();
|
||||
body +=
|
||||
"<div style=\"margin:40dp 0;\">" + crest(club(s), 340) +
|
||||
"</div><div class=\"field-row\"><span>Saison</span><strong>" +
|
||||
esc(s.state.value("date", std::string()).substr(0, 4)) +
|
||||
"</strong></div><div "
|
||||
"class=\"field-row\"><span>Spieltag</span><strong>Saisonvorbereitung</"
|
||||
"strong></div><div class=\"field-row\"><span>Datum</span><strong>" +
|
||||
esc(s.state.value("date", std::string())) +
|
||||
"</strong></div><div "
|
||||
"class=\"field-row\"><span>Mitspieler</span><strong>" +
|
||||
std::to_string(s.state.at("managers").size()) + "</strong></div>";
|
||||
if (save && selections_["save"].empty())
|
||||
body += "<div class=\"field-row\"><label>Bezeichnung</label><input "
|
||||
"id=\"save-name\" value=\"Meine Karriere\"/></div>";
|
||||
return body + "</div><div class=\"bottom-controls\">" +
|
||||
btn("save-delete", "Löschen") + btn("save-rename", "Umbenennen") +
|
||||
btn("close", "Abbrechen") +
|
||||
btn(save ? "save-confirm" : "load-confirm",
|
||||
save ? "Speichern" : "Laden", "primary") +
|
||||
"</div>";
|
||||
}
|
||||
std::string App::render_menu(const std::string &key) {
|
||||
if(key=="view-save"||key=="view-load")return render_files(true,key=="view-save");
|
||||
if (key == "widgets" || key == "background" || key == "warning" || key == "quit") return render_widget_dialog(key);
|
||||
if (key == "news")
|
||||
return "<div class=\"fill\" style=\"z-index:100;\">" + render_news() + "</div>";
|
||||
std::string body;
|
||||
@@ -813,10 +605,7 @@ std::string App::render_menu(const std::string &key) {
|
||||
else if (key == "settings")
|
||||
body = render_settings();
|
||||
else if (key == "save" || key == "load")
|
||||
body = render_save(key == "save");
|
||||
else if (key == "widgets" || key == "view-save" || key == "view-load" ||
|
||||
key == "background")
|
||||
body = render_desktop_tools(key);
|
||||
body = render_files(false,key == "save");
|
||||
else
|
||||
throw editor::Error("Diese native Ansicht ist noch nicht verfügbar.");
|
||||
std::string heading = key == "postpone" ? "Spiel verlegen" : title(key);
|
||||
|
||||
@@ -247,6 +247,7 @@ void App::settings_commit() {
|
||||
settings_sync();
|
||||
return;
|
||||
}
|
||||
if(scene_=="desktop"&&global.at("theme")!=theme_)desktop_checkpoint(desktop_);
|
||||
ui_preferences_ = global;
|
||||
theme_ = global.at("theme").get<std::string>();
|
||||
if (changed_global)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
bool App::settings_global_only() const { return scene_ == "main" || !source_; }
|
||||
fs::path App::ui_preferences_file() const {
|
||||
return config_.preferences.empty()
|
||||
? root_ / "userdata" / "modern-ui-preferences.json"
|
||||
? (config_.userdata.empty() ? root_ / "userdata" : config_.userdata) / "modern-ui-preferences.json"
|
||||
: config_.preferences;
|
||||
}
|
||||
void App::reset_settings() {
|
||||
|
||||
@@ -22,12 +22,15 @@
|
||||
#include "modern/ui/demo_settings.hpp"
|
||||
#include "modern/ui/ui_preferences.hpp"
|
||||
#include "modern/ui/desktop.hpp"
|
||||
#include "modern/ui/demo_widgets.hpp"
|
||||
#include "modern/ui/demo_files.hpp"
|
||||
#include "modern/ui/gui_assets.hpp"
|
||||
#include "modern/ui/model.hpp"
|
||||
#include "modern/ui/ticket_popover.hpp"
|
||||
#include "modern/ui/view.hpp"
|
||||
#include "version.hpp"
|
||||
#include <RmlUi/Core.h>
|
||||
#include <cstring>
|
||||
#include <RmlUi/Core/Elements/ElementFormControl.h>
|
||||
#include <RmlUi/Core/Elements/ElementFormControlInput.h>
|
||||
#include <RmlUi/Core/Elements/ElementFormControlSelect.h>
|
||||
@@ -171,6 +174,15 @@ public:
|
||||
const auto &r = entries_.at(token).raster;
|
||||
return {token, r.width, r.height};
|
||||
}
|
||||
Picture generated_png(const std::string &slot,const std::string &png){
|
||||
const auto token="modern-generated-"+slot+".png",digest=content::sha256(png);
|
||||
auto found=entries_.find(token);
|
||||
if(found==entries_.end()||found->second.key!=digest){
|
||||
if(auto loaded=loaded_sources_.find(token);loaded!=loaded_sources_.end()){Rml::ReleaseTexture(loaded->second,this);loaded_sources_.erase(loaded);}
|
||||
entries_[token]={digest,false,1280,editor::images::decode(png,".png")};
|
||||
}
|
||||
const auto &r=entries_.at(token).raster;return {token,r.width,r.height};
|
||||
}
|
||||
Picture local_image(const fs::path &file, int pixels) {
|
||||
const auto identity =
|
||||
editor::utf8(file) + ":" +
|
||||
@@ -393,6 +405,7 @@ class App final : public Rml::EventListener {
|
||||
std::string id;
|
||||
float x = 0, y = 0;
|
||||
double left = 0, top = 0;
|
||||
bool pinned=false;
|
||||
};
|
||||
Drag drag_;
|
||||
bool suppress_click_ = false;
|
||||
@@ -411,6 +424,8 @@ class App final : public Rml::EventListener {
|
||||
bool draw_playing_ = true;
|
||||
uint64_t draw_at_ = 0;
|
||||
#include "modern/ui/settings_state.inc"
|
||||
#include "modern/ui/widgets_state.inc"
|
||||
#include "modern/ui/files_state.inc"
|
||||
std::map<std::string, std::string> selections_;
|
||||
Rml::Element *element(const std::string &id) const {
|
||||
return doc_->GetElementById(id);
|
||||
@@ -438,7 +453,7 @@ class App final : public Rml::EventListener {
|
||||
fs::path user_dir() const {
|
||||
const auto id = world_ ? world_->manifest().value("id", std::string("none"))
|
||||
: std::string("none");
|
||||
return root_ / "userdata" / "ui-demo" / content::sha256(id);
|
||||
return (config_.userdata.empty() ? root_ / "userdata" : config_.userdata) / "ui-demo" / content::sha256(id);
|
||||
}
|
||||
std::string img(const std::string &key, double w, double h,
|
||||
bool world = false, bool cover = false, int pixels = 512) {
|
||||
@@ -587,6 +602,7 @@ class App final : public Rml::EventListener {
|
||||
}
|
||||
void load_world(const fs::path &file) {
|
||||
reset_settings();
|
||||
reset_files();
|
||||
auto next = Catalog::open(file);
|
||||
auto demo = std::make_unique<DemoSource>(next);
|
||||
ticket_.reset();
|
||||
@@ -621,6 +637,8 @@ class App final : public Rml::EventListener {
|
||||
almanac_match_.clear();
|
||||
almanac_tab_ = "lineups";
|
||||
desktop_ = Json::object();
|
||||
working_desktop_initialized_=false;working_desktop_base_=Json();
|
||||
files_default_key_.clear();files_default_picture_=Picture();files_default_pending_=false;
|
||||
ticket_ =
|
||||
std::make_unique<TicketPopover>(*context_, *doc_, *source_, [this] {
|
||||
focus_ticket_ = true;
|
||||
@@ -787,8 +805,6 @@ class App final : public Rml::EventListener {
|
||||
const std::string &player = {}, int size = 56,
|
||||
int gap = 10, bool overtraining = false);
|
||||
std::string render_settings();
|
||||
std::string render_save(bool save);
|
||||
std::string render_desktop_tools(const std::string &);
|
||||
void render_context();
|
||||
void context_menu(const std::string &id, int x, int y);
|
||||
void drag_event(Rml::Event &);
|
||||
@@ -854,6 +870,8 @@ class App final : public Rml::EventListener {
|
||||
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_=="widgets" && last_rendered_menu_=="widgets")widget_remember_scroll();
|
||||
files_before_render();
|
||||
if (menu_ != last_rendered_menu_) {
|
||||
if(last_rendered_menu_=="settings")reset_settings();
|
||||
statistics_trophy_ = Json::object();
|
||||
@@ -1042,6 +1060,8 @@ class App final : public Rml::EventListener {
|
||||
ticket_->update();
|
||||
if (needs_render_)
|
||||
render();
|
||||
if(files_default_pending_&&!files_capturing_){update_files_default_thumbnail();render();}
|
||||
persist_working_desktop();
|
||||
render_popup();
|
||||
render_context();
|
||||
context_->Update();
|
||||
@@ -1076,6 +1096,8 @@ class App final : public Rml::EventListener {
|
||||
if (menu_ == "scorers" || menu_ == "fairplay") rankings_restore_scroll();
|
||||
if (menu_ == "statistics") statistics_restore_scroll();
|
||||
if (menu_ == "settings") settings_after_render();
|
||||
files_after_render();
|
||||
if(menu_=="widgets" && widget_restore_scroll_){if(auto *gallery=element("widget-gallery"))gallery->SetScrollTop(widget_gallery_scroll_);widget_restore_scroll_=false;}
|
||||
if (!report_option_to_scroll_.empty()) {
|
||||
if (auto *node = element(report_option_to_scroll_))
|
||||
node->ScrollIntoView(Rml::ScrollIntoViewOptions(Rml::ScrollAlignment::Nearest));
|
||||
@@ -1085,7 +1107,7 @@ class App final : public Rml::EventListener {
|
||||
renderer_.BeginFrame();
|
||||
context_->Render();
|
||||
renderer_.EndFrame();
|
||||
video_.present();
|
||||
if(!files_capturing_)video_.present();
|
||||
dirty_ = false;
|
||||
}
|
||||
void screenshot(const fs::path &file) {
|
||||
@@ -1320,12 +1342,15 @@ public:
|
||||
while (got) {
|
||||
if (event.type == SDL_QUIT) {
|
||||
if (source_ && scene_ != "main") {
|
||||
quit_closes_app_=true;
|
||||
dispatch("context-quit", nullptr);
|
||||
} else
|
||||
closed_ = true;
|
||||
} else {
|
||||
if (event.type == SDL_WINDOWEVENT)
|
||||
if (event.type == SDL_WINDOWEVENT) {
|
||||
if(event.window.event==SDL_WINDOWEVENT_FOCUS_LOST)desktop_cancel_drag();
|
||||
resize();
|
||||
}
|
||||
int w, h, pw, ph;
|
||||
SDL_GetWindowSize(video_.window, &w, &h);
|
||||
video_.drawable_size(pw, ph);
|
||||
@@ -1354,7 +1379,10 @@ public:
|
||||
}
|
||||
};
|
||||
#include "modern/ui/controls.inc"
|
||||
#include "modern/ui/desktop_screens.inc"
|
||||
#include "modern/ui/widgets_screens.inc"
|
||||
#include "modern/ui/widgets_controls.inc"
|
||||
#include "modern/ui/files_screens.inc"
|
||||
#include "modern/ui/files_controls.inc"
|
||||
#include "modern/ui/screens.inc"
|
||||
#include "modern/ui/sports_screens.inc"
|
||||
#include "modern/ui/calendar_screen.inc"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
namespace bmh::modern_ui {
|
||||
struct Config {
|
||||
std::filesystem::path world, gui_assets, screenshot, commands, state, preferences;
|
||||
std::filesystem::path world, gui_assets, screenshot, commands, state, preferences, userdata, file_import, file_export;
|
||||
std::string scene = "main", theme;
|
||||
int width = 1280, height = 720;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,461 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
void App::desktop_checkpoint(const Json &before) {
|
||||
if (undo_.empty() || undo_.back() != before ||
|
||||
(!undo_themes_.empty() && undo_themes_.back() != theme_)) {
|
||||
undo_.push_back(before);
|
||||
undo_themes_.push_back(theme_);
|
||||
}
|
||||
if (undo_.size() > 40) {
|
||||
undo_.erase(undo_.begin());
|
||||
undo_themes_.erase(undo_themes_.begin());
|
||||
}
|
||||
}
|
||||
void App::desktop_cancel_drag() {
|
||||
if (!drag_.active)
|
||||
return;
|
||||
if (drag_.moved && !drag_.pinned && !undo_.empty()) {
|
||||
desktop_ = undo_.back();
|
||||
if (undo_.size() > drag_undo_size_) {
|
||||
undo_.pop_back();
|
||||
if (!undo_themes_.empty())
|
||||
undo_themes_.pop_back();
|
||||
}
|
||||
}
|
||||
drag_ = {};
|
||||
suppress_click_ = true;
|
||||
refresh();
|
||||
}
|
||||
void App::desktop_raise(const std::string &id) {
|
||||
int highest = 0;
|
||||
for (const auto &[key, o] : desktop_.at("objects").items())
|
||||
highest = std::max(highest, o.value("z", 1));
|
||||
if (highest >= 9900) {
|
||||
int index = 0;
|
||||
for (auto &[key, o] : desktop_["objects"].items())
|
||||
o["z"] = ++index;
|
||||
highest = index;
|
||||
}
|
||||
desktop_["objects"][id]["z"] = highest + 1;
|
||||
}
|
||||
void App::widget_remember_scroll() {
|
||||
if (auto *pane = element("widget-gallery"))
|
||||
widget_gallery_scroll_ = pane->GetScrollTop();
|
||||
}
|
||||
bool App::widget_change(Rml::Element *target) {
|
||||
if (menu_ != "widgets" || !target)
|
||||
return false;
|
||||
if (target->GetId() == "widget-search") {
|
||||
widget_query_ = field("widget-search");
|
||||
widget_gallery_scroll_ = 0;
|
||||
setting_menu_markup_ = true;
|
||||
if (auto *gallery = element("widget-gallery"))
|
||||
gallery->SetInnerRML(render_widget_gallery_items());
|
||||
setting_menu_markup_ = false;
|
||||
context_->Update();
|
||||
center_selects(*doc_);
|
||||
context_->Update();
|
||||
if (auto *gallery = element("widget-gallery"))
|
||||
gallery->SetScrollTop(0);
|
||||
dirty_ = true;
|
||||
return true;
|
||||
}
|
||||
if (target->HasAttribute("data-widget-size")) {
|
||||
const auto id = target->GetAttribute<Rml::String>("data-widget-size", "");
|
||||
const auto value = field(target->GetId());
|
||||
const auto at = value.find('x');
|
||||
if (at != value.npos)
|
||||
widget_choices_[id] = {std::stoi(value.substr(0, at)),
|
||||
std::stoi(value.substr(at + 1))};
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool App::widget_action(const std::string &action, Rml::Element *target) {
|
||||
if (action == "context-undo") {
|
||||
focus_after_render_ =
|
||||
context_id_.empty() ? "desktop-identity" : "object-" + context_id_;
|
||||
desktop_undo();
|
||||
context_open_ = false;
|
||||
return true;
|
||||
}
|
||||
if (action == "widget-add") {
|
||||
if (menu_ != "widgets" || !target)
|
||||
return true;
|
||||
widget_remember_scroll();
|
||||
const auto id = target->GetAttribute<Rml::String>("data-id", "");
|
||||
std::pair<int, int> span{0, 0};
|
||||
for (const auto &d : widget_catalogue())
|
||||
if (d.at("id") == id) {
|
||||
const auto &v = d.at("spans").at(d.at("size").get<std::string>());
|
||||
span = {v[0], v[1]};
|
||||
}
|
||||
if (widget_choices_.contains(id))
|
||||
span = widget_choices_.at(id);
|
||||
auto before = desktop_;
|
||||
if (add_desktop_widget(desktop_, id, span.first, span.second)) {
|
||||
desktop_raise(id);
|
||||
desktop_checkpoint(before);
|
||||
widget_notice_ = "Widget hinzugefügt. Du kannst es direkt auf dem "
|
||||
"Desktop verschieben.";
|
||||
} else
|
||||
widget_notice_ = "Kein freier Rasterplatz. Entferne ein Widget oder "
|
||||
"wähle eine kleinere Größe.";
|
||||
focus_after_render_ = "widget-size-" + id;
|
||||
refresh();
|
||||
return true;
|
||||
}
|
||||
if (action == "widget-warning" && target) {
|
||||
widget_warning_ = target->GetAttribute<Rml::String>("data-id", "");
|
||||
menu_ = "warning";
|
||||
refresh();
|
||||
return true;
|
||||
}
|
||||
if (action == "widget-background") {
|
||||
widget_notice_ = "Stadion bei Nacht ist ausgewählt.";
|
||||
refresh();
|
||||
return true;
|
||||
}
|
||||
if (action == "context-grid") {
|
||||
focus_after_render_ = "desktop-identity";
|
||||
auto before = desktop_;
|
||||
if (set_desktop_grid(desktop_, !desktop_.value("grid", true))) {
|
||||
desktop_checkpoint(before);
|
||||
refresh();
|
||||
} else
|
||||
message("Nicht genug freier Platz. Die Anordnung bleibt erhalten.");
|
||||
context_open_ = false;
|
||||
return true;
|
||||
}
|
||||
if (action == "context-widgets") {
|
||||
widget_query_.clear();
|
||||
widget_notice_.clear();
|
||||
widget_gallery_scroll_ = 0;
|
||||
widget_choices_.clear();
|
||||
return false;
|
||||
}
|
||||
if (action == "context-background") {
|
||||
widget_notice_.clear();
|
||||
return false;
|
||||
}
|
||||
if (action == "context-quit") {
|
||||
desktop_cancel_drag();
|
||||
context_open_ = false;
|
||||
quit_origin_menu_ = menu_;
|
||||
menu_ = "quit";
|
||||
refresh();
|
||||
return true;
|
||||
}
|
||||
if (action == "desktop-quit-cancel") {
|
||||
quit_after_save_ = false;
|
||||
quit_closes_app_ = false;
|
||||
menu_ = quit_origin_menu_;
|
||||
refresh();
|
||||
return true;
|
||||
}
|
||||
if (action == "desktop-quit-save") {
|
||||
quit_after_save_ = true;
|
||||
reset_files();
|
||||
menu_ = "save";
|
||||
refresh();
|
||||
return true;
|
||||
}
|
||||
if (action == "desktop-quit-discard" || action == "desktop-quit-confirm") {
|
||||
finish_desktop_quit();
|
||||
return true;
|
||||
}
|
||||
if (action == "context-remove" &&
|
||||
desktop_.at("objects").at(context_id_).at("pinned") == true)
|
||||
return true;
|
||||
if (action == "close" && menu_ == "quit") {
|
||||
widget_action("desktop-quit-cancel", nullptr);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool App::widget_event(Rml::Event &event) {
|
||||
if (!popup_.empty() || amount_)
|
||||
return false;
|
||||
const auto type = event.GetType();
|
||||
auto *target = event.GetTargetElement();
|
||||
if (menu_ == "widgets") {
|
||||
if (type == "input" || type == "change") {
|
||||
if (auto *select = dynamic_cast<Rml::ElementFormControlSelect *>(target);
|
||||
select && select->IsSelectBoxVisible()) {
|
||||
pending_selects_.insert(select->GetId());
|
||||
dirty_ = true;
|
||||
return true;
|
||||
}
|
||||
return widget_change(target);
|
||||
}
|
||||
}
|
||||
if (type != "keydown" || scene_ != "desktop")
|
||||
return false;
|
||||
const auto key =
|
||||
Rml::Input::KeyIdentifier(event.GetParameter<int>("key_identifier", 0));
|
||||
const bool shift = event.GetParameter<int>("shift_key", 0) != 0,
|
||||
control = event.GetParameter<int>("ctrl_key", 0) ||
|
||||
event.GetParameter<int>("meta_key", 0);
|
||||
if (context_open_) {
|
||||
if (key == Rml::Input::KI_UP || key == Rml::Input::KI_DOWN ||
|
||||
key == Rml::Input::KI_HOME || key == Rml::Input::KI_END) {
|
||||
Rml::ElementList buttons;
|
||||
if (auto *root = element("desktop-context"))
|
||||
root->QuerySelectorAll(buttons, "button");
|
||||
std::erase_if(buttons, [](auto *button) {
|
||||
return button->HasAttribute("disabled");
|
||||
});
|
||||
if (!buttons.empty()) {
|
||||
auto it = std::find(buttons.begin(), buttons.end(),
|
||||
context_->GetFocusElement());
|
||||
int n = int(buttons.size()),
|
||||
index = it == buttons.end() ? 0 : int(it - buttons.begin());
|
||||
index = key == Rml::Input::KI_HOME ? 0
|
||||
: key == Rml::Input::KI_END
|
||||
? n - 1
|
||||
: (index + (key == Rml::Input::KI_UP ? -1 : 1) + n) % n;
|
||||
buttons[size_t(index)]->Focus(true);
|
||||
}
|
||||
event.StopImmediatePropagation();
|
||||
return true;
|
||||
}
|
||||
if (key == Rml::Input::KI_ESCAPE || key == Rml::Input::KI_TAB) {
|
||||
context_open_ = false;
|
||||
if (auto *opener = context_id_.empty() ? doc_->QuerySelector(".identity")
|
||||
: element("object-" + context_id_))
|
||||
opener->Focus(true);
|
||||
dirty_ = true;
|
||||
event.StopImmediatePropagation();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (key == Rml::Input::KI_ESCAPE && drag_.active) {
|
||||
desktop_cancel_drag();
|
||||
event.StopImmediatePropagation();
|
||||
return true;
|
||||
}
|
||||
if (key == Rml::Input::KI_ESCAPE && menu_ == "quit") {
|
||||
widget_action("desktop-quit-cancel", nullptr);
|
||||
event.StopImmediatePropagation();
|
||||
return true;
|
||||
}
|
||||
if (!menu_.empty())
|
||||
return false;
|
||||
if (control && key == Rml::Input::KI_Z) {
|
||||
desktop_undo();
|
||||
event.StopImmediatePropagation();
|
||||
return true;
|
||||
}
|
||||
std::string id;
|
||||
for (auto *n = target; n && n != doc_; n = n->GetParentNode())
|
||||
if (n->HasAttribute("data-object")) {
|
||||
id = n->GetAttribute<Rml::String>("data-object", "");
|
||||
break;
|
||||
}
|
||||
if (key == Rml::Input::KI_APPS || (shift && key == Rml::Input::KI_F10)) {
|
||||
const auto at = target->GetAbsoluteOffset(Rml::BoxArea::Border);
|
||||
context_menu(id, int(at.x + 30), int(at.y + 30));
|
||||
event.StopImmediatePropagation();
|
||||
return true;
|
||||
}
|
||||
if (id.empty())
|
||||
return false;
|
||||
const auto &o = desktop_.at("objects").at(id);
|
||||
const bool widget = o.at("widget"), pinned = o.at("pinned");
|
||||
if (key == Rml::Input::KI_RETURN || key == Rml::Input::KI_SPACE) {
|
||||
if (widget) {
|
||||
for (const auto &d : widget_catalogue())
|
||||
if (d.at("id") == id && !d.value("route", "").empty()) {
|
||||
dispatch("open:" + d.at("route").get<std::string>(), target);
|
||||
break;
|
||||
}
|
||||
event.StopImmediatePropagation();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (key == Rml::Input::KI_DELETE) {
|
||||
if (widget && !pinned) {
|
||||
desktop_checkpoint(desktop_);
|
||||
desktop_["objects"][id]["visible"] = false;
|
||||
refresh();
|
||||
}
|
||||
event.StopImmediatePropagation();
|
||||
return true;
|
||||
}
|
||||
const int dx = key == Rml::Input::KI_LEFT ? -1
|
||||
: key == Rml::Input::KI_RIGHT ? 1
|
||||
: 0,
|
||||
dy = key == Rml::Input::KI_UP ? -1
|
||||
: key == Rml::Input::KI_DOWN ? 1
|
||||
: 0;
|
||||
if (!dx && !dy)
|
||||
return false;
|
||||
if (!pinned) {
|
||||
auto before = desktop_;
|
||||
const int step = desktop_.value("grid", true) ? 248 : shift ? 96 : 24;
|
||||
if (place_desktop_object(desktop_, id, o.at("x").get<int>() + dx * step,
|
||||
o.at("y").get<int>() + dy * step)) {
|
||||
desktop_raise(id);
|
||||
desktop_checkpoint(before);
|
||||
focus_after_render_ = "object-" + id;
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
event.StopImmediatePropagation();
|
||||
return true;
|
||||
}
|
||||
void App::files_loaded_success() {
|
||||
ticket_.reset();
|
||||
reset_settings();
|
||||
reset_news();
|
||||
pending_selects_.clear();
|
||||
undo_.clear();
|
||||
undo_themes_.clear();
|
||||
drag_ = {};
|
||||
context_open_ = false;
|
||||
lineup_drag_ = Json();
|
||||
lineup_drag_world_.reset();
|
||||
lineup_selected_.clear();
|
||||
lineup_ignore_click_ = false;
|
||||
lineup_pitch_ = true;
|
||||
lineup_data_ = lineup_page_ = 0;
|
||||
lineup_side_ = "formations";
|
||||
transfer_view_ = Json::object();
|
||||
transfer_draft_ = transfer_search_draft_ = Json();
|
||||
transfer_dialog_.clear();
|
||||
transfer_picker_.clear();
|
||||
transfer_world_.reset();
|
||||
career_view_ = Json::object();
|
||||
rankings_view_ = Json::object();
|
||||
statistics_view_ = Json::object();
|
||||
statistics_trophy_ = Json::object();
|
||||
statistics_scrolls_ = Json::object();
|
||||
stadium_view_ = Json::object();
|
||||
stadium_world_.reset();
|
||||
stadium_source_ = nullptr;
|
||||
advertising_world_.reset();
|
||||
advertising_selected_ = -1;
|
||||
toto_dialog_.clear();
|
||||
amount_.reset();
|
||||
contracts_dialog_.clear();
|
||||
contract_draft_ = Json();
|
||||
contracts_world_.reset();
|
||||
bank_view_ = "entrance";
|
||||
bank_hint_.clear();
|
||||
balance_future_ = false;
|
||||
report_detail_kind_.clear();
|
||||
report_detail_player_.clear();
|
||||
report_detail_club_.clear();
|
||||
report_picker_.clear();
|
||||
planning_dialog_.clear();
|
||||
almanac_year_ = 0;
|
||||
almanac_day_.clear();
|
||||
almanac_match_.clear();
|
||||
almanac_tab_ = "lineups";
|
||||
widget_data_ = Json();
|
||||
ticket_ = std::make_unique<TicketPopover>(*context_, *doc_, *source_, [this] {
|
||||
focus_ticket_ = true;
|
||||
refresh();
|
||||
});
|
||||
menu_.clear();
|
||||
scene_ = "desktop";
|
||||
quit_after_save_ = false;
|
||||
quit_closes_app_ = false;
|
||||
refresh();
|
||||
}
|
||||
void App::files_saved_success(bool career) {
|
||||
if (career && quit_after_save_) {
|
||||
finish_desktop_quit();
|
||||
return;
|
||||
}
|
||||
if (career) {
|
||||
files_revision_ = snap().revision;
|
||||
files_desktop_base_ = desktop_;
|
||||
files_theme_base_ = theme_;
|
||||
files_reload(files_selected_);
|
||||
focus_after_render_ = "files-confirm";
|
||||
refresh();
|
||||
return;
|
||||
}
|
||||
menu_.clear();
|
||||
reset_files();
|
||||
}
|
||||
void App::finish_desktop_quit() {
|
||||
const bool exit = quit_closes_app_;
|
||||
quit_after_save_ = false;
|
||||
quit_closes_app_ = false;
|
||||
if (exit) {
|
||||
closed_ = true;
|
||||
return;
|
||||
}
|
||||
ticket_.reset();
|
||||
source_ = std::make_unique<DemoSource>(world_);
|
||||
saved_desktop_ = desktop_;
|
||||
files_loaded_success();
|
||||
scene_ = "main";
|
||||
menu_.clear();
|
||||
refresh();
|
||||
}
|
||||
|
||||
void App::persist_working_desktop() {
|
||||
if (!source_ || scene_ != "desktop" || files_capturing_ || drag_.active ||
|
||||
!working_desktop_initialized_ || desktop_ == working_desktop_base_)
|
||||
return;
|
||||
try {
|
||||
fs::create_directories(user_dir());
|
||||
editor::write_atomic(user_dir() / "working-desktop.json", desktop_.dump(2));
|
||||
} catch (const std::exception &) {
|
||||
message("Die Desktopanordnung bleibt in dieser Sitzung erhalten, konnte "
|
||||
"aber nicht gespeichert werden.");
|
||||
}
|
||||
working_desktop_base_ = desktop_;
|
||||
}
|
||||
|
||||
void App::desktop_undo() {
|
||||
if (undo_.empty())
|
||||
return;
|
||||
const auto theme = undo_themes_.empty() ? theme_ : undo_themes_.back();
|
||||
if (theme != theme_) {
|
||||
auto preferences = ui_preferences_;
|
||||
preferences["theme"] = theme;
|
||||
try {
|
||||
save_ui_preferences(ui_preferences_file(), preferences);
|
||||
} catch (const std::exception &) {
|
||||
message("Die Gestaltung konnte nicht wiederhergestellt werden.");
|
||||
return;
|
||||
}
|
||||
ui_preferences_ = std::move(preferences);
|
||||
theme_ = theme;
|
||||
ui_preferences_loaded_ = true;
|
||||
}
|
||||
desktop_ = undo_.back();
|
||||
undo_.pop_back();
|
||||
if (!undo_themes_.empty())
|
||||
undo_themes_.pop_back();
|
||||
refresh();
|
||||
}
|
||||
|
||||
Picture App::files_default_thumbnail() {
|
||||
const auto key = content::sha256(snap().state.dump() + theme_);
|
||||
if (key != files_default_key_) {
|
||||
files_default_request_ = key;
|
||||
files_default_pending_ = true;
|
||||
}
|
||||
return key == files_default_key_ ? files_default_picture_ : Picture();
|
||||
}
|
||||
void App::update_files_default_thumbnail() {
|
||||
const auto layout = desktop_;
|
||||
files_default_pending_ = false;
|
||||
try {
|
||||
desktop_ = default_desktop();
|
||||
const auto png = files_capture_preview();
|
||||
desktop_ = layout;
|
||||
files_default_picture_ = renderer_.generated_png("default-desktop", png);
|
||||
files_default_key_ = files_default_request_;
|
||||
} catch (const std::exception &) {
|
||||
desktop_ = layout;
|
||||
files_default_key_ = files_default_request_;
|
||||
files_default_picture_ = Picture();
|
||||
files_feedback_ = "Die Standardvorschau konnte nicht aufgenommen werden.";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,426 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
std::string App::widget_heading(const std::string &name, bool link) {
|
||||
return "<header class=\"desk-card-heading\"><span>" + esc(name) + "</span>" +
|
||||
(link ? glyph("arrow-diagonal", 28) : "") + "</header>";
|
||||
}
|
||||
std::string App::widget_curve(const std::string &id, const Json &o, int w,
|
||||
int h) {
|
||||
const bool compare = id == "comparison-curve",
|
||||
square = (w == 720 || h == 968);
|
||||
const int height = square ? 600 : 330, range = height - 76;
|
||||
const auto accent = theme_ == "silver" ? "#235e78"
|
||||
: theme_ == "matchday" ? "#f1a99e"
|
||||
: "#a5e2cf";
|
||||
const auto other = theme_ == "silver" ? "#a04b30"
|
||||
: theme_ == "matchday" ? "#91cce8"
|
||||
: "#f2b286";
|
||||
const auto muted = theme_ == "silver" ? "#586d80"
|
||||
: theme_ == "matchday" ? "#b4b5b7"
|
||||
: "#afbfcd";
|
||||
std::string svg =
|
||||
"<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"1000\" height=\"" +
|
||||
std::to_string(height) + "\" viewBox=\"0 0 1000 " +
|
||||
std::to_string(height) + "\"><path d=\"M32 38h936M32 " +
|
||||
scalar(38 + range / 2.) + "h936M32 " + std::to_string(38 + range) +
|
||||
"h936\" stroke=\"" + muted +
|
||||
"\" stroke-opacity=\"0.22\" fill=\"none\" stroke-width=\"2\"/>";
|
||||
const auto series = [&](const Json &values, const char *color, bool dash) {
|
||||
std::string path, dots;
|
||||
for (size_t i = 0; i < values.size(); ++i) {
|
||||
const auto x = 32 + i * 936. / (values.size() - 1),
|
||||
y = 38 + (values[i].get<int>() - 1) / 17. * range;
|
||||
path += (i ? "L" : "M") + scalar(x) + " " + scalar(y);
|
||||
dots += "<circle cx=\"" + scalar(x) + "\" cy=\"" + scalar(y) +
|
||||
"\" r=\"7\" fill=\"" + color + "\"/>";
|
||||
}
|
||||
return "<path d=\"" + path + "\" stroke=\"" + color +
|
||||
"\" fill=\"none\" stroke-width=\"5\" stroke-linecap=\"round\" "
|
||||
"stroke-linejoin=\"round\" " +
|
||||
(dash ? "stroke-dasharray=\"18 12\"" : "") + "/>" + dots;
|
||||
};
|
||||
svg += series(
|
||||
widget_data_.at(id == "opponent-curve" ? "opponent_curve" : "own_curve"),
|
||||
accent, false);
|
||||
if (compare)
|
||||
svg += series(widget_data_.at("opponent_curve"), other, true);
|
||||
svg += "</svg>";
|
||||
const int ch = h - (compare ? 180 : 96);
|
||||
std::string out =
|
||||
"<div class=\"desk-curve-picture\" style=\"height:" + std::to_string(ch) +
|
||||
"dp;\">" +
|
||||
picture(renderer_.diagram("widget-" + id + "-" + std::to_string(w) + "-" +
|
||||
std::to_string(h),
|
||||
svg, 1600),
|
||||
w - 42, ch) +
|
||||
"<span class=\"curve-start\">Saisonstart</span><span "
|
||||
"class=\"curve-end\">Heute</span></div>";
|
||||
if (compare)
|
||||
out +=
|
||||
"<div class=\"desk-curve-legend\"><span><i></i><span>" +
|
||||
esc(world_->name(*world_->find("clubs", widget_data_.at("own")))) +
|
||||
"</span></span><span class=\"curve-opponent\"><i></i><span>" +
|
||||
esc(world_->name(*world_->find("clubs", widget_data_.at("opponent")))) +
|
||||
"</span></span></div>";
|
||||
(void)o;
|
||||
return out;
|
||||
}
|
||||
std::string App::widget(const std::string &id, const Json &o) {
|
||||
const auto s = snap();
|
||||
if (!widget_data_.is_object())
|
||||
widget_data_ = demo_desktop_widgets(*world_, s.state);
|
||||
const auto *own = world_->find("clubs", widget_data_.at("own")),
|
||||
*opponent = world_->find("clubs", widget_data_.at("opponent"));
|
||||
const int w = o.at("w"), h = o.at("h");
|
||||
const bool wide = h == 224, compact = w == 472;
|
||||
const auto heading = [&](const std::string &name, bool link = true) {
|
||||
return widget_heading(name, link);
|
||||
};
|
||||
if (id == "calendar")
|
||||
return "<div class=\"desk-calendar-month\"><span>" +
|
||||
esc(widget_data_.at("month").get<std::string>()) +
|
||||
"</span></div><div class=\"desk-calendar-body\"><span>" +
|
||||
esc(widget_data_.at("weekday").get<std::string>()) +
|
||||
"</span><strong>" +
|
||||
std::to_string(widget_data_.at("day").get<int>()) +
|
||||
"</strong><small>" +
|
||||
(widget_data_.at("matchday") == 0
|
||||
? "Saisonvorbereitung"
|
||||
: std::to_string(widget_data_.at("matchday").get<int>()) +
|
||||
". Spieltag") +
|
||||
"</small></div><div class=\"desk-calendar-foot\">" +
|
||||
glyph("calendar", 30) +
|
||||
"<span>Kalender öffnen</span><span class=\"calendar-arrow\">" +
|
||||
glyph("arrow-diagonal", 26) + "</span></div>";
|
||||
if (id == "account")
|
||||
return heading("Vereinskasse") +
|
||||
"<div class=\"desk-account-main\"><span>Guthaben</span><strong>" +
|
||||
cash(s.state.at("cash")) +
|
||||
"</strong></div><div "
|
||||
"class=\"desk-account-bottom\"><div><span>Sparbuch</span><strong>" +
|
||||
cash(s.state.at("deposit")) + "</strong></div>" +
|
||||
btn("ticket",
|
||||
glyph("ticket", 36) + "<span><span>Eintritt</span><strong>" +
|
||||
std::to_string(s.state.at("ticket").get<int>()) + " " +
|
||||
money_unit() + " ›</strong></span>",
|
||||
"desk-ticket",
|
||||
"id=\"account-ticket\" data-interactive=\"true\"") +
|
||||
"</div>";
|
||||
if (id == "competition")
|
||||
return heading("Nächste Begegnung") + "<div class=\"desk-fixture\"><div>" +
|
||||
crest(own, compact ? 68 : 80) + "<span>" +
|
||||
esc(own ? own->value("short_name", world_->name(*own)) : "") +
|
||||
"</span></div><div "
|
||||
"class=\"desk-fixture-centre\"><small>Freundschaftsspiel</"
|
||||
"small><strong>19:00</strong><span>Heim · "
|
||||
"Samstag</span></div><div>" +
|
||||
crest(opponent, compact ? 68 : 80) + "<span>" +
|
||||
esc(opponent ? opponent->value("short_name", world_->name(*opponent))
|
||||
: "") +
|
||||
"</span></div></div>";
|
||||
if (id == "portrait")
|
||||
return img(std::string(manager(s).value("portrait_style",
|
||||
std::string("photo")) == "painted"
|
||||
? "manager-painted."
|
||||
: "manager.") +
|
||||
std::to_string(manager(s).value("portrait", 0)),
|
||||
w, h, false, true, 768) +
|
||||
"<div "
|
||||
"class=\"desk-portrait-caption\"><small>Manager</small><strong>" +
|
||||
esc(manager(s).value("name", "")) + "</strong></div>";
|
||||
if (id == "crest" || id == "opponent-crest") {
|
||||
const auto *c = id == "crest" ? own : opponent;
|
||||
return "<div class=\"desk-logo-surface\">" +
|
||||
crest(c, std::min(int((w - 48) * .78), int((h - 138) * .9))) +
|
||||
"</div><div class=\"desk-logo-caption\"><small>" +
|
||||
(id == "crest" ? std::string("Dein Verein") : "Nächster Gegner") +
|
||||
"</small><strong>" + esc(c ? world_->name(*c) : "") +
|
||||
"</strong></div>";
|
||||
}
|
||||
if (id == "warnings") {
|
||||
const std::vector<std::vector<int>> groups =
|
||||
wide ? std::vector<std::vector<int>>{{0}, {1}, {2}, {3, 4},
|
||||
{5, 6}, {7}, {8}, {9}}
|
||||
: std::vector<std::vector<int>>{{0}, {1}, {2}, {3}, {4},
|
||||
{5}, {6}, {7}, {8}, {9}};
|
||||
std::string out =
|
||||
heading("Vereinsstatus", false) + "<div class=\"desk-warning-grid\">";
|
||||
const int cols = wide ? 8 : 5,
|
||||
cw = (w - (wide ? 56 : 52) - (wide ? 7 * 18 : 4 * 14)) / cols,
|
||||
rh = wide ? h - 76 : (h - 120) / 2;
|
||||
for (size_t i = 0; i < groups.size(); ++i) {
|
||||
std::string label, key;
|
||||
bool attention = false;
|
||||
for (int n : groups[i]) {
|
||||
const auto &v = widget_data_.at("warnings")[size_t(n)];
|
||||
if (!label.empty()) {
|
||||
label += " & ";
|
||||
key += ",";
|
||||
}
|
||||
label += v.at("name").get<std::string>();
|
||||
key += std::to_string(n);
|
||||
attention = attention || v.at("attention") == true;
|
||||
}
|
||||
const auto &v = widget_data_.at("warnings")[size_t(groups[i][0])];
|
||||
out += btn("widget-warning",
|
||||
"<span class=\"status-lamp " +
|
||||
std::string(attention ? "attention" : "okay") + "\">" +
|
||||
glyph(v.at("icon"), h == 720 ? 42 : 28) + "</span>" +
|
||||
(wide ? ""
|
||||
: "<span class=\"warning-caption\">" + esc(label) +
|
||||
"</span>"),
|
||||
"desk-warning",
|
||||
"data-id=\"" + key + "\" data-interactive=\"true\" title=\"" +
|
||||
esc(label) + "\" aria-label=\"" + esc(label) + ": " +
|
||||
(attention ? "Handlungsbedarf" : "In Ordnung") +
|
||||
"\" style=\"left:" +
|
||||
std::to_string((wide ? 28 : 26) +
|
||||
(int(i) % cols) * (cw + (wide ? 18 : 14))) +
|
||||
"dp;top:" + std::to_string(int(i) / cols * (rh + 20)) +
|
||||
"dp;width:" + std::to_string(cw) +
|
||||
"dp;height:" + std::to_string(rh) + "dp;\"");
|
||||
}
|
||||
return out + "</div>";
|
||||
}
|
||||
if (id == "fans")
|
||||
return heading("Fan-Stimmung") + "<div class=\"desk-mood\">" +
|
||||
glyph("heart", 36) + "<div><strong>" +
|
||||
std::to_string(widget_data_.at("fans").get<int>()) +
|
||||
" <small>%</small></strong><span class=\"mood-track\"><i "
|
||||
"style=\"width:" +
|
||||
std::to_string(widget_data_.at("fans").get<int>()) +
|
||||
"%;\"></i></span></div><span>Zuversichtlich</span></div>";
|
||||
if (id == "news")
|
||||
return render_news_widget(o);
|
||||
if (id == "own-curve" || id == "opponent-curve" || id == "comparison-curve")
|
||||
return heading(id == "comparison-curve"
|
||||
? "Tabellenplätze"
|
||||
: world_->name(*(id == "own-curve" ? own : opponent))) +
|
||||
widget_curve(id, o, w, h);
|
||||
if (id == "own-summary" || id == "opponent-summary") {
|
||||
bool self = id == "own-summary";
|
||||
return heading(world_->name(*(self ? own : opponent))) +
|
||||
"<div "
|
||||
"class=\"desk-summary\"><div><small>Tabellenplatz</small><strong>" +
|
||||
std::to_string(widget_data_.at(self ? "own_rank" : "opponent_rank")
|
||||
.get<int>()) +
|
||||
".</strong></div><div><small>Teamstärke</small><strong>" +
|
||||
std::to_string(
|
||||
widget_data_.at(self ? "own_strength" : "opponent_strength")
|
||||
.get<int>()) +
|
||||
"</strong></div></div>";
|
||||
}
|
||||
if (id == "results") {
|
||||
std::string out =
|
||||
heading("Die letzten sechs Spiele") + "<div class=\"desk-form\">";
|
||||
for (size_t i = 0; i < 6; ++i)
|
||||
out += "<div><span class=\"form-" +
|
||||
widget_data_.at("form")[i].get<std::string>() +
|
||||
"\" style=\"width:" + scalar(wide ? 50 : w * .08) +
|
||||
"dp;height:" + scalar(wide ? 50 : w * .08) +
|
||||
"dp;font-size:" + scalar(wide ? 26 : w * .04) + "dp;\"><span>" +
|
||||
widget_data_.at("form")[i].get<std::string>() +
|
||||
"</span></span><strong style=\"font-size:" +
|
||||
scalar(wide ? 29 : w * .035) + "dp;\">" +
|
||||
widget_data_.at("scores")[i].get<std::string>() +
|
||||
"</strong></div>";
|
||||
return out + "</div>" +
|
||||
(wide ? ""
|
||||
: "<p class=\"desk-card-note\">3 Siege · 2 Unentschieden · 1 "
|
||||
"Niederlage</p>");
|
||||
}
|
||||
if (id == "duels")
|
||||
return heading("Direkter Vergleich") + "<div class=\"desk-duels\"><div>" +
|
||||
crest(own, 75) +
|
||||
"<strong>2</strong><small>Siege</small></div><div><strong>1</"
|
||||
"strong><small>Unentschieden</small></div><div>" +
|
||||
crest(opponent, 75) +
|
||||
"<strong>3</strong><small>Siege</small></div></div>";
|
||||
if (id == "trash")
|
||||
return "<div class=\"desktop-utility-icon\">" + glyph("trash", 100) +
|
||||
"</div><strong>Papierkorb</strong>";
|
||||
return {};
|
||||
}
|
||||
std::string App::desktop_dialog(const std::string &heading,
|
||||
const std::string &body,
|
||||
const std::string &footer, int width,
|
||||
int height) {
|
||||
return "<div class=\"fill desktop-modal-layer\" "
|
||||
"style=\"z-index:100;\"><section class=\"window "
|
||||
"desktop-window\" style=\"left:" +
|
||||
std::to_string((3840 - width) / 2) +
|
||||
"dp;top:" + std::to_string((2160 - height) / 2) +
|
||||
"dp;width:" + std::to_string(width) +
|
||||
"dp;height:" + std::to_string(height) +
|
||||
"dp;\"><header class=\"desktop-window-titlebar\">" +
|
||||
btn("close", "×", "desktop-window-close",
|
||||
"id=\"window-close\" aria-label=\"Schließen\"") +
|
||||
"<h1><span>" + esc(heading) +
|
||||
"</span></h1></header><div class=\"desktop-window-content\" "
|
||||
"style=\"width:" +
|
||||
std::to_string(width - 104) +
|
||||
"dp;height:" + std::to_string(height - 302) + "dp;\">" + body +
|
||||
"</div><footer class=\"desktop-window-footer\">" + footer +
|
||||
"</footer></section></div>";
|
||||
}
|
||||
std::string App::render_widget_gallery_items() {
|
||||
std::string out;
|
||||
int index = 0;
|
||||
const auto query = settings_search_key(widget_query_);
|
||||
for (const auto &d : widget_catalogue()) {
|
||||
const auto id = d.at("id").get<std::string>();
|
||||
if (!query.empty() &&
|
||||
settings_search_key(d.at("label").get<std::string>() + " " +
|
||||
d.at("description").get<std::string>() + " " +
|
||||
d.at("group").get<std::string>())
|
||||
.find(query) == std::string::npos)
|
||||
continue;
|
||||
auto preview = desktop_.at("objects").at(id);
|
||||
const auto span = d.at("spans").at(d.at("size").get<std::string>());
|
||||
const int w = span[0].get<int>() * 248 - 24,
|
||||
h = span[1].get<int>() * 248 - 24;
|
||||
preview["w"] = w;
|
||||
preview["h"] = h;
|
||||
const auto factor = std::min(620. / w, 300. / h);
|
||||
std::string dimensions;
|
||||
for (const auto &def : widget_definitions())
|
||||
if (def.id == id) {
|
||||
auto chosen = widget_choices_.contains(id)
|
||||
? widget_choices_[id]
|
||||
: std::pair<int, int>{span[0], span[1]};
|
||||
for (const auto &[cols, rows] : def.sizes) {
|
||||
const auto key = std::to_string(cols) + "x" + std::to_string(rows);
|
||||
dimensions += "<option value=\"" + key + "\" " +
|
||||
(chosen == std::pair{cols, rows} ? "selected" : "") +
|
||||
">" + std::to_string(cols) + " × " +
|
||||
std::to_string(rows) + "</option>";
|
||||
}
|
||||
}
|
||||
auto preview_markup = widget(id, preview);
|
||||
for (size_t at = 0;
|
||||
(at = preview_markup.find("<button", at)) != std::string::npos;
|
||||
at += 40)
|
||||
preview_markup.insert(at + 7, " disabled tabindex=\"-1\"");
|
||||
for (size_t at = 0;
|
||||
(at = preview_markup.find(" id=\"", at)) != std::string::npos;) {
|
||||
at += 5;
|
||||
const auto prefix = "preview-" + id + "-";
|
||||
preview_markup.insert(at, prefix);
|
||||
at += prefix.size();
|
||||
}
|
||||
const bool present = desktop_.at("objects").at(id).at("visible");
|
||||
out +=
|
||||
"<article class=\"widget-gallery-item\" data-gallery=\"" + id +
|
||||
"\" style=\"left:" + std::to_string(6 + index % 3 * 814) +
|
||||
"dp;top:" + std::to_string(8 + index / 3 * 690) +
|
||||
"dp;\"><div class=\"gallery-widget-preview\"><div class=\"desktop-card "
|
||||
"desk-card gallery-preview-card\" data-widget=\"" +
|
||||
id + "\" data-size=\"" + d.at("size").get<std::string>() +
|
||||
"\" style=\"width:" + std::to_string(w) +
|
||||
"dp;height:" + std::to_string(h) + "dp;left:" + scalar((732 - w) / 2.) +
|
||||
"dp;top:" + scalar((320 - h) / 2.) + "dp;transform:scale(" +
|
||||
scalar(factor) + ");\">" + preview_markup +
|
||||
"</div></div><div class=\"gallery-description\"><small>" +
|
||||
esc(d.at("group").get<std::string>()) + "</small><h2>" +
|
||||
esc(d.at("label").get<std::string>()) + "</h2><p>" +
|
||||
esc(d.at("description").get<std::string>()) +
|
||||
"</p></div><div class=\"gallery-actions\"><select id=\"widget-size-" +
|
||||
id + "\" data-widget-size=\"" + id + "\">" + dimensions + "</select>" +
|
||||
btn("widget-add",
|
||||
(present ? glyph("check", 28) : "") + "<span>" +
|
||||
(present ? "Auf dem Desktop" : "Hinzufügen") + "</span>",
|
||||
"widget-add-button",
|
||||
"data-id=\"" + id + "\" " + (present ? "disabled" : "")) +
|
||||
"</div></article>";
|
||||
++index;
|
||||
}
|
||||
return index
|
||||
? "<div class=\"widget-gallery-space\" "
|
||||
"style=\"position:relative;height:" +
|
||||
std::to_string(8 + ((index + 2) / 3 - 1) * 690 + 660 + 30) +
|
||||
"dp;\">" + out + "</div>"
|
||||
: "<p class=\"widget-gallery-empty\">Keine Widgets gefunden.</p>";
|
||||
}
|
||||
std::string App::render_widget_dialog(const std::string &key) {
|
||||
init_desktop();
|
||||
widget_data_ = demo_desktop_widgets(*world_, snap().state);
|
||||
if (key == "widgets") {
|
||||
widget_restore_scroll_ = true;
|
||||
return desktop_dialog(
|
||||
"Widget hinzufügen",
|
||||
"<div class=\"modern-gallery-toolbar\"><p>Dein Verein. Auf einen "
|
||||
"Blick.</p><label class=\"modern-search\">" +
|
||||
glyph("plus", 30) +
|
||||
"<input type=\"text\" id=\"widget-search\" maxlength=\"80\" "
|
||||
"value=\"" +
|
||||
esc(widget_query_) +
|
||||
"\" placeholder=\"Widget suchen\"/></label></div><div "
|
||||
"id=\"widget-gallery\" class=\"modern-widget-gallery\" "
|
||||
"tabindex=\"0\">" +
|
||||
render_widget_gallery_items() + "</div>",
|
||||
"<p id=\"widget-feedback\">" + esc(widget_notice_) + "</p>" +
|
||||
btn("close", "Fertig"));
|
||||
}
|
||||
if (key == "background")
|
||||
return desktop_dialog(
|
||||
"Hintergrundbild ändern",
|
||||
"<p class=\"modern-intro\">Ein Ort. Dein Spieltag.</p>" +
|
||||
btn("widget-background",
|
||||
img("background", 1972, 820, false, true, 2000) +
|
||||
"<span><strong>Stadion bei Nacht</strong><small>Auf die "
|
||||
"aktuelle Desktopgestaltung abgestimmt</small></span><i>" +
|
||||
glyph("check", 48) + "</i>",
|
||||
"background-choice", "aria-pressed=\"true\"") +
|
||||
"<p class=\"background-note\">Weitere Hintergründe folgen.</p>",
|
||||
"<p>" + esc(widget_notice_) + "</p>" + btn("close", "Fertig"), 2080,
|
||||
1680);
|
||||
if (key == "warning") {
|
||||
std::string label, description;
|
||||
bool attention = false;
|
||||
std::istringstream in(widget_warning_);
|
||||
std::string bit;
|
||||
while (std::getline(in, bit, ',')) {
|
||||
const int i = std::stoi(bit);
|
||||
if (i < 0 || i >= 10)
|
||||
continue;
|
||||
const auto &v = widget_data_.at("warnings")[size_t(i)];
|
||||
if (!label.empty())
|
||||
label += " & ";
|
||||
label += v.at("name").get<std::string>();
|
||||
if (v.at("attention") == true) {
|
||||
attention = true;
|
||||
description += v.at("description").get<std::string>() + " ";
|
||||
}
|
||||
}
|
||||
return desktop_dialog("Vereinsstatus",
|
||||
"<div class=\"desktop-message\"><div "
|
||||
"class=\"desktop-warning-symbol\">" +
|
||||
glyph(attention ? "alert" : "check", 80) +
|
||||
"</div><h2>" + esc(label) + "</h2><p>" +
|
||||
esc(attention
|
||||
? description
|
||||
: "Hier ist derzeit alles in Ordnung.") +
|
||||
"</p></div>",
|
||||
"<p></p>" + btn("close", "Fertig"), 1800, 1000);
|
||||
}
|
||||
if (key == "quit") {
|
||||
const bool dirty = source_->dirty();
|
||||
return desktop_dialog(
|
||||
"Spiel beenden",
|
||||
"<div class=\"desktop-message\"><div "
|
||||
"class=\"desktop-warning-symbol\">" +
|
||||
glyph("power", 80) + "</div><h2>" +
|
||||
std::string(dirty ? "Noch nicht gespeichert" : "Spiel beenden?") +
|
||||
"</h2><p>" +
|
||||
(dirty ? "Deine Änderungen wurden noch nicht gespeichert. Möchtest "
|
||||
"du vor dem Beenden speichern?"
|
||||
: "Möchtest du das Spiel beenden und zum Hauptmenü "
|
||||
"zurückkehren?") +
|
||||
"</p></div>",
|
||||
"<p></p>" + btn("desktop-quit-cancel", "Abbrechen") +
|
||||
(dirty ? btn("desktop-quit-discard", "Nicht speichern") +
|
||||
btn("desktop-quit-save", "Speichern", "primary")
|
||||
: btn("desktop-quit-confirm", "Beenden", "primary")),
|
||||
1800, 1000);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
Json widget_data_;
|
||||
std::string widget_query_, widget_notice_, widget_warning_, quit_origin_menu_;
|
||||
std::map<std::string, std::pair<int, int>> widget_choices_;
|
||||
float widget_gallery_scroll_ = 0;
|
||||
bool quit_closes_app_ = false, widget_restore_scroll_ = false;
|
||||
std::string desktop_dialog(const std::string &, const std::string &,
|
||||
const std::string &, int width = 2560,
|
||||
int height = 1840);
|
||||
std::string widget_heading(const std::string &, bool link = true);
|
||||
std::string widget_curve(const std::string &, const Json &, int, int);
|
||||
std::string render_widget_gallery_items();
|
||||
std::string render_widget_dialog(const std::string &);
|
||||
bool widget_action(const std::string &, Rml::Element *);
|
||||
bool widget_event(Rml::Event &);
|
||||
bool widget_change(Rml::Element *);
|
||||
void widget_remember_scroll();
|
||||
void desktop_checkpoint(const Json &);
|
||||
void desktop_cancel_drag();
|
||||
void desktop_raise(const std::string &);
|
||||
void finish_desktop_quit();
|
||||
|
||||
Json working_desktop_base_;
|
||||
bool working_desktop_initialized_ = false;
|
||||
void persist_working_desktop();
|
||||
|
||||
std::vector<std::string> undo_themes_;
|
||||
void desktop_undo();
|
||||
|
||||
size_t drag_undo_size_ = 0;
|
||||
|
||||
Picture files_default_thumbnail();
|
||||
void update_files_default_thumbnail();
|
||||
Picture files_default_picture_;
|
||||
std::string files_default_key_, files_default_request_;
|
||||
bool files_default_pending_ = false;
|
||||
@@ -113,7 +113,7 @@ int main(int argc, char **argv) try {
|
||||
std::ostringstream css;
|
||||
for (const auto *name : {"theme.rcss", "ticket.rcss", "sports.rcss",
|
||||
"calendar.rcss", "reports.rcss", "report_details.rcss",
|
||||
"report_pickers.rcss", "indoor.rcss", "planning.rcss", "almanac.rcss", "finance.rcss", "bank.rcss", "contracts.rcss", "amount.rcss", "environment.rcss", "advertising.rcss", "toto.rcss", "lineup.rcss", "transfer.rcss", "career_reports.rcss", "rankings.rcss", "stadium.rcss", "statistics.rcss", "news.rcss", "settings.rcss"}) {
|
||||
"report_pickers.rcss", "indoor.rcss", "planning.rcss", "almanac.rcss", "finance.rcss", "bank.rcss", "contracts.rcss", "amount.rcss", "environment.rcss", "advertising.rcss", "toto.rcss", "lineup.rcss", "transfer.rcss", "career_reports.rcss", "rankings.rcss", "stadium.rcss", "statistics.rcss", "news.rcss", "settings.rcss", "widgets.rcss", "files.rcss"}) {
|
||||
std::ifstream input(root / name);
|
||||
require(bool(input), "Production stylesheet missing");
|
||||
css << input.rdbuf() << '\n';
|
||||
@@ -188,6 +188,14 @@ int main(int argc, char **argv) try {
|
||||
"<option>3840 × 2160</option></select></div>"
|
||||
"<div class='settings-jump-label'><select id='settings-jump-test' class='settings-select'>"
|
||||
"<option selected>Spielablauf und Wettbewerbe</option><option>Ergebnisse</option></select></div></div>";
|
||||
content += "<div class='desktop-card desk-card' style='left:40dp;top:1500dp;width:472dp;height:472dp;'>"
|
||||
"<div id='month-box' class='desk-calendar-month'><span id='month-label'>Juli 2032</span></div></div>"
|
||||
"<button class='desk-warning' style='left:700dp;top:1500dp;width:180dp;height:176dp;'><span class='status-lamp'></span>"
|
||||
"<span id='warning-label' class='warning-caption'>Kontostand</span></button>"
|
||||
"<div class='desk-card' style='position:absolute;left:1100dp;top:1500dp;width:968dp;height:472dp;'>"
|
||||
"<div class='desk-fixture'><div><span id='fixture-label'>Synthetic Club</span></div></div></div>";
|
||||
content += "<div id='gallery-scroll-test' class='modern-widget-gallery' style='left:2700dp;top:1500dp;width:900dp;height:200dp;max-height:200dp;'>"
|
||||
"<div style='position:relative;height:1000dp;'><article class='widget-gallery-item' style='top:600dp;'></article></div></div>";
|
||||
auto *doc = context->LoadDocumentFromMemory(
|
||||
"<rml><head><style>" + css.str() + "</style></head><body class='" +
|
||||
theme + "'>" + content + "</body></rml>");
|
||||
@@ -202,8 +210,9 @@ int main(int argc, char **argv) try {
|
||||
context->Update();
|
||||
context->Render();
|
||||
}
|
||||
require(doc->GetElementById("gallery-scroll-test")->GetScrollHeight() > doc->GetElementById("gallery-scroll-test")->GetClientHeight()*2,"Gallery content does not contribute to scroll extent");
|
||||
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", "settings-row-label", "settings-row-help"}) {
|
||||
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", "settings-row-label", "settings-row-help", "month-label", "warning-label", "fixture-label"}) {
|
||||
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");
|
||||
@@ -213,6 +222,7 @@ int main(int argc, char **argv) try {
|
||||
require(button, "Button missing");
|
||||
centered_text(*button, *button);
|
||||
}
|
||||
centered_text(*doc->GetElementById("month-label"), *doc->GetElementById("month-box"));
|
||||
auto *list = doc->GetElementById("list");
|
||||
centered_text(*list, *list, false);
|
||||
auto *rich = doc->GetElementById("rich");
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "modern/ui/demo_widgets.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-desktop-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-desktop"},
|
||||
{"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:desktop-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:desktop-" + std::to_string(i)},
|
||||
{"name", "Synthetic Club " + std::to_string(i)},
|
||||
{"nation", "nation:de"},
|
||||
{"competition", "competition:desktop-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);
|
||||
}
|
||||
};
|
||||
void test(Fixture &f) {
|
||||
DemoSource source(f.world);
|
||||
const auto initial = source.snapshot();
|
||||
auto layout = default_desktop();
|
||||
require(valid_desktop(layout) && widget_definitions().size() == 17 &&
|
||||
widget_catalogue().size() == 17,
|
||||
"Widget catalogue incomplete");
|
||||
int visible = 0;
|
||||
for (const auto &[id, o] : layout.at("objects").items()) {
|
||||
require(o.at("pinned") == true, "Standard must be fixed");
|
||||
if (o.at("widget") == true && o.at("visible") == true)
|
||||
++visible;
|
||||
}
|
||||
require(visible == 8 && desktop_routes().size() == 32,
|
||||
"Default desktop counts wrong");
|
||||
for (const auto &d : widget_catalogue()) {
|
||||
bool found = false;
|
||||
for (const auto &def : widget_definitions())
|
||||
if (def.id == d.at("id").get<std::string>()) {
|
||||
found = true;
|
||||
require(def.sizes.size() == d.at("spans").size(),
|
||||
"Widget size metadata mismatch");
|
||||
}
|
||||
require(found, "Unknown catalogue widget");
|
||||
}
|
||||
const auto projected = demo_desktop_widgets(*f.world, initial.state);
|
||||
require(projected.at("warnings").size() == 10 &&
|
||||
projected.at("own_curve").size() == 12 &&
|
||||
projected.at("form").size() == 6,
|
||||
"Widget projection incomplete");
|
||||
require(source.snapshot().state == initial.state && !source.dirty(),
|
||||
"Read-only widget data changed source");
|
||||
auto altered = initial.state;
|
||||
altered["cash"] = 0;
|
||||
altered["finance"]["stocks"][0] = 1;
|
||||
altered["contracts"]["players"] = Json::object();
|
||||
auto warnings = demo_desktop_widgets(*f.world, altered).at("warnings");
|
||||
require(warnings[0].at("attention") == true &&
|
||||
warnings[1].at("attention") == true,
|
||||
"Warnings do not reflect shared state");
|
||||
const auto original = layout;
|
||||
require(!resize_desktop_widget(layout, "account", 4, 1) && layout == original,
|
||||
"Pinned widget resized");
|
||||
require(!add_desktop_widget(layout, "calendar", 2, 2) && layout == original,
|
||||
"Visible widget added twice");
|
||||
require(!add_desktop_widget(layout, "fans", 8, 8) && layout == original,
|
||||
"Unsupported size accepted");
|
||||
require(set_desktop_grid(layout, false), "Free placement failed");
|
||||
require(add_desktop_widget(layout, "fans", 2, 1) &&
|
||||
!layout.at("objects").at("fans").at("pinned").get<bool>(),
|
||||
"Optional widget not added movable");
|
||||
require(layout.at("objects").at("fans").at("visible") == true,
|
||||
"Added widget hidden");
|
||||
require(arrange_desktop(layout) && layout.at("grid") == false,
|
||||
"Arrange must preserve free/grid choice");
|
||||
const auto before = layout;
|
||||
require(set_desktop_grid(layout, true) && valid_desktop(layout),
|
||||
"Snap mode failed");
|
||||
for (const auto &[id, o] : original.at("objects").items())
|
||||
if (o.at("visible") == true)
|
||||
require(layout.at("objects").at(id) == o, "Snap moved a pinned object");
|
||||
auto bad = layout;
|
||||
bad["objects"]["fans"]["z"] = -1;
|
||||
require(!valid_desktop(bad), "Invalid z order accepted");
|
||||
auto changed = initial.state.at("settings");
|
||||
changed["cells"][0] = 1 - changed["cells"][0].get<int>();
|
||||
require(source.apply({initial.revision, "settings", changed}).ok,
|
||||
"Cannot dirty source fixture");
|
||||
const auto revision = source.snapshot().revision;
|
||||
require(!source.mark_saved(revision - 1) && source.dirty(),
|
||||
"Stale save acknowledgment cleared dirty state");
|
||||
require(source.mark_saved(revision) && !source.dirty() &&
|
||||
source.snapshot().revision == revision,
|
||||
"Save acknowledgment changed revision");
|
||||
const auto saved = f.root / "desktop.ui.json";
|
||||
source.save(saved, layout);
|
||||
auto data = Json::parse(bmh::editor::read_file(saved));
|
||||
const auto restored = source.load_data(data);
|
||||
require(restored == layout && !source.dirty(),
|
||||
"In-memory load differs from file load");
|
||||
const auto good = source.snapshot();
|
||||
data["desktop"]["objects"]["calendar"]["x"] = -1;
|
||||
bool rejected = false;
|
||||
try {
|
||||
source.load_data(data);
|
||||
} catch (const std::exception &) {
|
||||
rejected = true;
|
||||
}
|
||||
require(rejected && source.snapshot().state == good.state &&
|
||||
source.snapshot().revision == good.revision,
|
||||
"Failed in-memory load was not atomic");
|
||||
}
|
||||
} // namespace
|
||||
int main() {
|
||||
try {
|
||||
Fixture f;
|
||||
test(f);
|
||||
std::cout << "modern desktop UI tests passed\n";
|
||||
return 0;
|
||||
} catch (const std::exception &e) {
|
||||
std::cerr << e.what() << '\n';
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,217 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "modern/ui/demo_files.hpp"
|
||||
#include "modern/ui/desktop.hpp"
|
||||
#include "modern/ui/ui_preferences.hpp"
|
||||
#include "editor/images.hpp"
|
||||
#include "content/digest.hpp"
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
using namespace bmh::modern_ui;
|
||||
namespace {
|
||||
void require(bool value, const char *message) {
|
||||
if (!value) throw std::runtime_error(message);
|
||||
}
|
||||
template<class F> void rejected(F operation, const char *message) {
|
||||
bool failed = false;
|
||||
try { operation(); } catch (const std::exception &) { failed = true; }
|
||||
require(failed, message);
|
||||
}
|
||||
struct Fixture {
|
||||
fs::path root;
|
||||
std::shared_ptr<const Catalog> world;
|
||||
Fixture() {
|
||||
root = fs::temp_directory_path() / ("openbmh-files-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 &value) {
|
||||
bmh::editor::write_atomic(root / name, value.dump());
|
||||
};
|
||||
write("manifest.json", {{"format", "openbmh-world"}, {"kind", "world"}, {"format_version", "1.1"},
|
||||
{"id", "world:synthetic-files"}, {"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:files"}, {"type", "league"}, {"nation", "nation:de"}, {"name", "Synthetic league"}}}}});
|
||||
Json clubs = Json::array();
|
||||
for (int i = 0; i < 2; ++i) clubs.push_back({{"id", "club:files-" + std::to_string(i)}, {"name", "Synthetic Club " + std::to_string(i)}, {"nation", "nation:de"}, {"competition", "competition:files"}});
|
||||
write("world/clubs.json", {{"items", clubs}});
|
||||
write("world/players.json", {{"items", Json::array()}});
|
||||
world = Catalog::open(root);
|
||||
}
|
||||
~Fixture() { std::error_code error; fs::remove_all(root, error); }
|
||||
};
|
||||
void names() {
|
||||
require(DemoFiles::clean_name(" Saison 1 ") == "Saison 1", "Name trimming failed");
|
||||
require(DemoFiles::name_key("Öffnung") == DemoFiles::name_key("o\xcc\x88" "FFNUNG"), "German composed/decomposed case conflict missed");
|
||||
require(DemoFiles::name_key("Straße") == DemoFiles::name_key("STRASSE"), "Sharp-s casefold conflict missed");
|
||||
require(DemoFiles::name_key("Café") == DemoFiles::name_key("CAFE\xcc\x81"), "Latin keyboard normalization missed");
|
||||
require(DemoFiles::name_key("ABC", true) == "abc", "View compatibility normalization missed");
|
||||
require(DemoFiles::name_key("ABC") != "abc", "Career names incorrectly use compatibility normalization");
|
||||
require(DemoFiles::clean_name(std::string(64, 'x')).size() == 64, "64 character name rejected");
|
||||
rejected([] { DemoFiles::clean_name(std::string(65, 'x')); }, "Long name accepted");
|
||||
rejected([] { DemoFiles::clean_name("line\nbreak"); }, "Control character accepted");
|
||||
rejected([] { DemoFiles::clean_name("\xc0\xaf"); }, "Invalid UTF8 accepted");
|
||||
rejected([] { DemoFiles::clean_name(" \t\n"); }, "Empty name accepted");
|
||||
}
|
||||
void files() {
|
||||
Fixture fixture;
|
||||
const auto directory = fixture.root / "isolated-userdata";
|
||||
DemoSource active(fixture.world);
|
||||
auto payload = active.snapshot().state;
|
||||
payload["desktop"] = default_desktop();
|
||||
const auto png = bmh::editor::images::encode_png({2, 2, {255,0,0,255, 0,255,0,255, 0,0,255,255, 255,255,255,255}});
|
||||
DemoFiles saves(directory, DemoFileKind::career, fixture.world);
|
||||
require(saves.list().empty() && !fs::exists(directory), "Browsing created mutable storage");
|
||||
const auto changed = active.apply({active.snapshot().revision, "ticket", 17});
|
||||
require(changed.ok && active.dirty(), "Synthetic active edit failed");
|
||||
const auto active_before = active.snapshot();
|
||||
const auto first = saves.put("Öffnung", payload, png);
|
||||
require(active.dirty() && active.snapshot().state == active_before.state && active.snapshot().revision == active_before.revision,
|
||||
"Provider save altered active source or marked it clean before publication hook");
|
||||
require(!active.mark_saved(active_before.revision + 1) && active.dirty(), "Stale save acknowledgement marked active career clean");
|
||||
require(active.mark_saved(active_before.revision) && !active.dirty(), "Valid publication acknowledgement did not mark source clean");
|
||||
const auto raw_before = bmh::editor::read_file(saves.directory() / bmh::editor::path(first.id));
|
||||
const auto read = saves.read(first.id, first.token);
|
||||
require(read.data == payload && read.preview_png == png && read.bytes == raw_before.size(), "Payload/preview/metadata roundtrip differs");
|
||||
require(fs::exists(saves.preview_file(read)), "Derived preview cache missing");
|
||||
rejected([&] { saves.put("o\xcc\x88" "FFNUNG", payload, png); }, "Case-insensitive duplicate save accepted");
|
||||
auto invalid = payload; invalid["ticket"] = 999;
|
||||
rejected([&] { saves.put("Bad", invalid, png); }, "Invalid career was published");
|
||||
rejected([&] { saves.put(first.name, invalid, png, first.id, first.token); }, "Invalid overwrite was published");
|
||||
rejected([&] { saves.put("Bad image", payload, "not PNG"); }, "Invalid preview was published");
|
||||
rejected([&] { saves.read("../escape.json"); }, "Traversal selection accepted");
|
||||
require(bmh::editor::read_file(saves.directory() / bmh::editor::path(first.id)) == raw_before, "Rejected mutation damaged existing save");
|
||||
const auto renamed = saves.rename(first.id, first.token, "Neue Saison");
|
||||
require(renamed.id == first.id && renamed.preview_png == png && renamed.data == payload && renamed.created == first.created,
|
||||
"Rename lost payload, preview, identity or timestamp");
|
||||
rejected([&] { saves.remove(first.id, first.token); }, "Stale deletion accepted");
|
||||
rejected([&] { saves.put("Replace", payload, png, first.id, first.token); }, "Stale overwrite accepted");
|
||||
require(saves.read(renamed.id, renamed.token).name == "Neue Saison", "Stale action changed selected record");
|
||||
const auto exported = fixture.root / "export.json";
|
||||
saves.export_file(renamed.id, renamed.token, exported);
|
||||
const auto export_before = bmh::editor::read_file(exported);
|
||||
rejected([&] { saves.export_file(renamed.id, renamed.token, exported); }, "Export silently overwrote an existing file");
|
||||
require(bmh::editor::read_file(exported) == export_before, "Failed export damaged destination");
|
||||
const auto imported = saves.import_file(exported);
|
||||
require(imported.id != renamed.id && imported.name != renamed.name && imported.data == payload && imported.preview_png == png,
|
||||
"Import replaced original or lost preview");
|
||||
const auto selected_path = saves.directory() / bmh::editor::path(renamed.id);
|
||||
const auto other_path = saves.directory() / bmh::editor::path(imported.id);
|
||||
const auto selected_bytes = bmh::editor::read_file(selected_path);
|
||||
const auto other_bytes = bmh::editor::read_file(other_path);
|
||||
const auto original_names = std::make_pair(renamed.name, imported.name);
|
||||
const auto unchanged_slots = [&] {
|
||||
require(bmh::editor::read_file(selected_path) == selected_bytes && bmh::editor::read_file(other_path) == other_bytes,
|
||||
"Rejected managed export changed either slot's bytes");
|
||||
const auto selected_record = saves.read(renamed.id, renamed.token);
|
||||
const auto other_record = saves.read(imported.id, imported.token);
|
||||
require(selected_record.id == renamed.id && other_record.id == imported.id &&
|
||||
std::make_pair(selected_record.name, other_record.name) == original_names,
|
||||
"Rejected managed export changed slot IDs or names");
|
||||
};
|
||||
rejected([&] { saves.export_file(renamed.id, renamed.token, other_path, true); }, "Export overwrote another managed slot");
|
||||
unchanged_slots();
|
||||
rejected([&] { saves.export_file(renamed.id, renamed.token, selected_path, true); }, "Export overwrote its own managed slot");
|
||||
unchanged_slots();
|
||||
rejected([&] { saves.export_file(renamed.id, renamed.token, saves.directory() / ".." / "saves" / bmh::editor::path(imported.id), true); }, "Dot-dot alias bypassed managed export guard");
|
||||
unchanged_slots();
|
||||
rejected([&] { saves.export_file(renamed.id, renamed.token, saves.directory() / "new-export.json", true); }, "Export created an untracked managed slot");
|
||||
require(!fs::exists(saves.directory() / "new-export.json"), "Rejected managed export left a new record");
|
||||
fs::create_directories(directory / "layouts");
|
||||
rejected([&] { saves.export_file(renamed.id, renamed.token, directory / "layouts" / "new-export.json", true); }, "Career export entered managed layouts");
|
||||
std::error_code alias_error;
|
||||
const auto alias = fixture.root / "export-save-alias";
|
||||
fs::create_directory_symlink(saves.directory(), alias, alias_error);
|
||||
if (!alias_error) {
|
||||
rejected([&] { saves.export_file(renamed.id, renamed.token, alias / bmh::editor::path(imported.id), true); }, "Directory symlink bypassed managed export guard");
|
||||
unchanged_slots(); fs::remove(alias);
|
||||
}
|
||||
alias_error.clear();
|
||||
const auto file_alias = fixture.root / "export-slot-alias.json";
|
||||
fs::create_symlink(other_path, file_alias, alias_error);
|
||||
if (!alias_error) {
|
||||
rejected([&] { saves.export_file(renamed.id, renamed.token, file_alias, true); }, "File symlink bypassed managed export guard");
|
||||
unchanged_slots(); fs::remove(file_alias);
|
||||
}
|
||||
// Operating-system base-path aliases (not managed subdirectories) are valid.
|
||||
const auto base_alias=fixture.root/"base-folder-alias";
|
||||
std::error_code base_alias_error;
|
||||
fs::create_directory_symlink(directory,base_alias,base_alias_error);
|
||||
if(!base_alias_error){DemoFiles aliased(base_alias,DemoFileKind::career,fixture.world);require(aliased.read(renamed.id,renamed.token).data==payload,"Base directory alias failed");fs::remove(base_alias);}
|
||||
saves.export_file(renamed.id, renamed.token, exported, true);
|
||||
require(bmh::editor::read_file(exported) == export_before, "Confirmed external export no longer works");
|
||||
auto damaged = Json::parse(export_before); damaged["data"]["cash"] = 123;
|
||||
bmh::editor::write_atomic(fixture.root / "damaged.json", damaged.dump());
|
||||
const auto before_count = saves.list().size();
|
||||
rejected([&] { saves.import_file(fixture.root / "damaged.json"); }, "Hash-mismatched import accepted");
|
||||
damaged = Json::parse(export_before); damaged["world_revision"] = "other source revision";
|
||||
bmh::editor::write_atomic(fixture.root / "damaged.json", damaged.dump());
|
||||
rejected([&] { saves.import_file(fixture.root / "damaged.json"); }, "Foreign source revision accepted");
|
||||
require(saves.list().size() == before_count, "Rejected import changed local records");
|
||||
const auto legacy_path = saves.directory() / "Legacy.json";
|
||||
bmh::editor::write_atomic(legacy_path, payload.dump());
|
||||
bmh::editor::write_atomic(saves.directory() / "Legacy.png", png);
|
||||
const auto legacy_raw = bmh::editor::read_file(legacy_path);
|
||||
const auto legacy = saves.read("Legacy.json");
|
||||
require(legacy.legacy && legacy.data == payload && legacy.preview_png == png && bmh::editor::read_file(legacy_path) == legacy_raw,
|
||||
"Legacy browsing rewrote source or separated screenshot");
|
||||
std::error_code symlink_error;
|
||||
fs::create_symlink(saves.directory() / bmh::editor::path(renamed.id), saves.directory() / "unsafe.json", symlink_error);
|
||||
if (!symlink_error) {
|
||||
rejected([&] { saves.read("unsafe.json"); }, "Symlink source accepted");
|
||||
fs::remove(saves.directory() / "unsafe.json");
|
||||
require(saves.read(renamed.id, renamed.token).data == payload, "Symlink rejection damaged target");
|
||||
}
|
||||
fs::create_directory(fixture.root / "export-is-directory.json");
|
||||
rejected([&] { saves.export_file(renamed.id, renamed.token, fixture.root / "export-is-directory.json", true); }, "Export replaced a directory");
|
||||
require(saves.read(renamed.id, renamed.token).data == payload, "Failed export IO changed source");
|
||||
fs::create_directory(directory / ".files-transaction");
|
||||
rejected([&] { saves.rename(renamed.id, renamed.token, "Busy"); }, "Concurrent transaction lock ignored");
|
||||
fs::remove(directory / ".files-transaction");
|
||||
require(saves.read(renamed.id, renamed.token).name == renamed.name, "Failed busy transaction changed original");
|
||||
const auto loaded_before = active.snapshot();
|
||||
rejected([&] { active.load_data(invalid); }, "Invalid load_data accepted");
|
||||
require(active.snapshot().revision == loaded_before.revision && active.snapshot().state == loaded_before.state,
|
||||
"Failed load partially published career");
|
||||
auto layout = active.load_data(read.data);
|
||||
require(layout == default_desktop() && !active.dirty() && active.snapshot().state.at("ticket") == payload.at("ticket"),
|
||||
"Validated load did not publish selected saved state cleanly");
|
||||
auto info = payload; info["date"] = "2033-02-12"; info["game_info"] = {{"matchday", 19}};
|
||||
const auto meta = DemoFiles::career_metadata(info);
|
||||
require(meta["season"] == "2032/33" && meta["date"] == "2033-02-12" && meta["matchday"] == "19. Spieltag",
|
||||
"Metadata uses current career instead of selected document");
|
||||
DemoFiles views(directory, DemoFileKind::desktop, fixture.world);
|
||||
const Json view = {{"layout", default_desktop()}, {"theme", "silver"}};
|
||||
const auto preferences_file = directory / "ui-preferences.json";
|
||||
auto preferences = default_ui_preferences(); preferences["sound"]["volume"] = 31;
|
||||
save_ui_preferences(preferences_file, preferences);
|
||||
const auto preferences_before = bmh::editor::read_file(preferences_file);
|
||||
rejected([&] { views.put("Standard", view, png); }, "Immutable standard view overwritten");
|
||||
rejected([&] { views.put("STANDARD", view, png); }, "Compatibility spelling overwrote standard view");
|
||||
rejected([&] { views.put("No preview", view); }, "Layout committed without atomic preview");
|
||||
const auto plan = views.put("Plan / Süd", view, png);
|
||||
require(plan.id.find('/') == plan.id.npos && plan.data == view, "Logical name escaped storage directory or theme was lost");
|
||||
auto invalid_view = view; invalid_view["layout"]["objects"]["calendar"]["x"] = -100;
|
||||
rejected([&] { views.put(plan.name, invalid_view, png, plan.id, plan.token); }, "Invalid layout overwrite accepted");
|
||||
const auto new_name = views.rename(plan.id, plan.token, "Wochenende");
|
||||
require(new_name.preview_png == png && new_name.data == view, "View rename separated layout and screenshot");
|
||||
rejected([&] { views.export_file(new_name.id, new_name.token, selected_path, true); }, "View export overwrote a managed career slot");
|
||||
unchanged_slots();
|
||||
require(views.read(new_name.id, new_name.token).name == new_name.name, "Rejected cross-kind export changed source view");
|
||||
require(bmh::editor::read_file(preferences_file) == preferences_before && load_ui_preferences(preferences_file) == preferences,
|
||||
"View provider modified global UI preferences");
|
||||
views.remove(new_name.id, new_name.token);
|
||||
require(views.list().empty(), "Confirmed view deletion left visible half record");
|
||||
for (int i = 0; i < 12; ++i) saves.put("Growing slot " + std::to_string(i), payload);
|
||||
require(saves.list().size() > 10, "Save provider has an artificial ten-slot limit");
|
||||
bmh::editor::write_atomic(saves.directory() / "broken.json", "{broken");
|
||||
const auto broken = saves.list();
|
||||
require(std::any_of(broken.begin(), broken.end(), [](const auto &r) { return r.id == "broken.json" && !r.valid(); }),
|
||||
"Malformed local file silently disappeared from browser");
|
||||
saves.remove(imported.id, imported.token);
|
||||
require(saves.read(renamed.id, renamed.token).data == payload, "Deleting another slot damaged original");
|
||||
}
|
||||
} // namespace
|
||||
int main() {
|
||||
try { names(); files(); std::cout << "PASS synthetic UI files: atomic payload/PNG, stale guards, Unicode names, selected metadata, import/export, isolated preferences and rollback\n"; return 0; }
|
||||
catch (const std::exception &e) { std::cerr << e.what() << '\n'; return 1; }
|
||||
}
|
||||