Compare commits
1
Commits
v0.2.1
...
editor-v0.5.4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fe307dea41 |
No files matched your search
@@ -1,8 +1,8 @@
|
||||
# OpenBMH
|
||||
|
||||
The separate [OpenBMH Editor 0.5.3](docs/EDITOR.md) uses native RmlUI,
|
||||
The separate [OpenBMH Editor 0.5.4](docs/EDITOR.md) uses native RmlUI,
|
||||
supports German/English, three themes, image editing and a local MCP server.
|
||||
Download its own `editor-v0.5.3` release or build with
|
||||
Download its own `editor-v0.5.4` release or build with
|
||||
`-DOPENBMH_BUILD_EDITOR=ON`. Edited worlds are independent of the Classic runtime.
|
||||
|
||||
A modern and faithful open source rebuild of the *Bundesliga Manager Hattrick* engine.
|
||||
|
||||
@@ -11,4 +11,5 @@
|
||||
<footer><div id="state"></div><div id="status-message"></div><div id="bottom-actions"></div></footer>
|
||||
</div>
|
||||
<div id="overlay"><div id="modal"><div class="modal-head"><h2 id="modal-title"></h2><button data-action="cancel-modal" class="close">×</button></div><div id="modal-content"></div><div id="modal-error"></div><div id="modal-buttons"></div></div></div>
|
||||
<div id="history-overlay" data-action="history-close"><div id="history-menu"></div></div>
|
||||
</body></rml>
|
||||
@@ -161,12 +161,21 @@ input[type=checkbox]:checked { background-color: var(--toggle-on); decorator: no
|
||||
input[type=range] { height: 24dp; padding: 0; }
|
||||
input[type=range] track { height: 4dp; background-color: var(--scrollbar); margin: 9dp 0; border-radius: 2dp; }
|
||||
input[type=range] bar { width: 16dp; height: 16dp; border-radius: 8dp; background-color: var(--accent); margin-top: 3dp; }
|
||||
select { padding-right: 25dp; }
|
||||
/* Modern Desktop pickers, in density-independent editor dimensions. The
|
||||
native RmlUI controls retain their values, input and change events. */
|
||||
select { padding-right: 30dp; cursor: pointer; background-color: transparent; decorator: linear-gradient(var(--control-top), var(--control-bottom)); box-shadow: inset 0 1dp #eff6fc12, 0 1dp 2dp #0002; }
|
||||
select:hover { background-color: var(--hover); decorator: none; }
|
||||
select selectvalue { padding: 0; }
|
||||
select selectarrow { width: 9dp; height: 9dp; margin-right: 9dp; margin-top: 11dp; decorator: none; border-bottom: 2dp var(--muted); border-right: 2dp var(--muted); transform: rotate(45deg); }
|
||||
select selectbox { background-color: var(--popup); color: var(--text); border: 1dp var(--border); border-radius: 8dp; padding: 5dp; max-height: 290dp; overflow-y: auto; }
|
||||
select option { font-size: 14dp; padding: 8dp; border-radius: 4dp; }
|
||||
select option:hover, select option:checked { background-color: var(--selected); color: var(--selected-text); }
|
||||
select selectarrow { width: 8dp; height: 8dp; margin-right: 13dp; margin-top: 11dp; decorator: none; border-bottom: 1.5dp var(--muted); border-right: 1.5dp var(--muted); transform: rotate(45deg); }
|
||||
select selectbox { width: 100%; min-width: 180dp; background-color: var(--popup); color: var(--text); border: 1dp var(--border); border-radius: 9dp; padding: 5dp; margin-top: 7dp; margin-bottom: 7dp; max-height: 320dp; overflow-y: auto; box-shadow: 0 9dp 28dp #0008; }
|
||||
select option { display: flex; align-items: center; min-height: 34dp; padding: 5dp 7dp; border-radius: 5dp; white-space: nowrap; cursor: pointer; }
|
||||
select option:hover { background-color: var(--hover); }
|
||||
select option:disabled { opacity: 0.35; cursor: unavailable; }
|
||||
.option-check { width: 6dp; height: 10dp; margin: 0 12dp 3dp 3dp; flex-shrink: 0; border-right: 1.5dp var(--accent); border-bottom: 1.5dp var(--accent); transform: rotate(45deg); opacity: 0; }
|
||||
option:checked .option-check { opacity: 1; }
|
||||
selectvalue .option-check { display: none; }
|
||||
.option-label { overflow: hidden; text-overflow: ellipsis; }
|
||||
.option-label, .option-check { pointer-events: none; focus: none; }
|
||||
#search { width: 250dp; margin-right: auto; }
|
||||
#filter-nation, #filter-league { width: 205dp; }
|
||||
#filter-team { width: 240dp; }
|
||||
@@ -220,6 +229,7 @@ select option:hover, select option:checked { background-color: var(--selected);
|
||||
textarea { height: 110dp; font-size: 12dp; line-height: 1.5; }
|
||||
.form-section { padding-top: 8dp; margin-bottom: 15dp; font-size: 12dp; font-weight: bold; color: var(--accent); }
|
||||
.form-help { font-size: 11dp; color: var(--muted); line-height: 1.5; margin-top: 6dp; }
|
||||
.connection-actions { margin-top: 20dp; }
|
||||
.inspector-actions { padding: 16dp 20dp; border-top: 1dp var(--divider); display: flex; gap: 8dp; flex-shrink: 0; }
|
||||
.inspector-actions button { flex: 1; }
|
||||
.empty { margin: auto; padding: 45dp; text-align: center; color: var(--muted); line-height: 1.7; }
|
||||
@@ -262,6 +272,12 @@ footer { height: 57dp; padding: 0 28dp; display: flex; align-items: center; gap:
|
||||
#modal-content { overflow-y: auto; line-height: 1.6; }
|
||||
#modal-buttons { margin-top: 23dp; display: flex; justify-content: flex-end; gap: 9dp; flex-shrink: 0; }
|
||||
#modal-error { color: var(--danger); font-size: 13dp; margin-top: 10dp; }
|
||||
#history-overlay { display: none; position: absolute; left: 0; top: 0; width: 100%; height: 100%; z-index: 10; }
|
||||
#history-menu { position: absolute; width: 248dp; padding: 6dp; border: 1dp var(--border); border-radius: 10dp; background-color: var(--popup); }
|
||||
#history-menu button { width: 100%; display: flex; align-items: center; text-align: left; padding: 10dp; border-color: transparent; decorator: none; font-size: 15dp; }
|
||||
.history-arrow { width: 28dp; flex-shrink: 0; display: flex; align-items: center; }
|
||||
.history-arrow .glyph { width: 20dp; height: 20dp; }
|
||||
#history-menu small { margin: 0 0 0 auto; padding-left: 16dp; }
|
||||
.image-layout { display: flex; gap: 24dp; }
|
||||
.image-stage { flex: 1; min-height: 360dp; background-color: var(--image-stage); border: 1dp var(--border); border-radius: 10dp; display: flex; align-items: center; justify-content: center; overflow: hidden; }
|
||||
.hero-image, .mini-logo { cursor: pointer; }
|
||||
|
||||
+38
-5
@@ -1,6 +1,6 @@
|
||||
# OpenBMH Editor 0.5.3
|
||||
# OpenBMH Editor 0.5.4
|
||||
|
||||
Der eigenständige, native Editor verwendet **RmlUI und SDL2**, unter Windows mit Direct3D 11, unter Linux/macOS mit OpenGL. Er bearbeitet Startdatenbanken, keine laufenden Spielstände. Das Spiel und seine Classic-Prüfung bleiben unverändert. Editor 0.5.3 hat eine eigene Versionsreihe und den Release-Tag `editor-v0.5.3`; die Spielversion ist 0.2.1.
|
||||
Der eigenständige, native Editor verwendet **RmlUI und SDL2**, unter Windows mit Direct3D 11, unter Linux/macOS mit OpenGL. Er bearbeitet Startdatenbanken, keine laufenden Spielstände. Das Spiel und seine Classic-Prüfung bleiben unverändert. Editor 0.5.4 hat eine eigene Versionsreihe und den Release-Tag `editor-v0.5.4`; die Spielversion ist 0.2.1.
|
||||
|
||||
## Windows-Start und Diagnose
|
||||
|
||||
@@ -17,7 +17,7 @@ MCP-Aufrufe zeigen keinen modalen Fehlerdialog und behalten ihre Prozesscodes.
|
||||
|
||||
## Starten und Daten öffnen
|
||||
|
||||
Das vollständige Paket `OpenBMHEditor-0.5.3-<plattform>.zip` entpacken und `OpenBMHEditor.exe` (Windows) beziehungsweise `OpenBMHEditor` (Linux/macOS) starten. `assets/editor` muss beim Programm bleiben. Auf macOS kann die unsignierte Anwendung über **Rechtsklick → Öffnen** gestartet werden. Eine Signatur/Notarisierung ist nicht Bestandteil dieser Version. `OpenBMHEditor --version` zeigt die Editorversion ohne Grafikstart.
|
||||
Das vollständige Paket `OpenBMHEditor-0.5.4-<plattform>.zip` entpacken und `OpenBMHEditor.exe` (Windows) beziehungsweise `OpenBMHEditor` (Linux/macOS) starten. `assets/editor` muss beim Programm bleiben. Auf macOS kann die unsignierte Anwendung über **Rechtsklick → Öffnen** gestartet werden. Eine Signatur/Notarisierung ist nicht Bestandteil dieser Version. `OpenBMHEditor --version` zeigt die Editorversion ohne Grafikstart.
|
||||
|
||||
**Öffnen** bietet OBW-Dateien und entpackte Welten an. **BMH / FLTD importieren** liest einen Ordner mit einer unterstützten BMH- oder Football-Limited-Installation durch den bestehenden Konverter. Das Original wird nicht überschrieben. Eine bestehende Classic-OBW wird zunächst überprüft und dann in eine bearbeitbare Editorwelt übernommen.
|
||||
|
||||
@@ -40,6 +40,39 @@ Das vollständige Paket `OpenBMHEditor-0.5.3-<plattform>.zip` entpacken und `Ope
|
||||
|
||||
Shortcuts: Ctrl/Cmd+O, Ctrl/Cmd+S, Shift+Ctrl/Cmd+S, Ctrl/Cmd+Z und Shift+Ctrl/Cmd+Z. In Textfeldern gilt die lokale Text-Rückgängig-Funktion.
|
||||
|
||||
## Zurück und Vorwärts
|
||||
|
||||
Ein **Rechtsklick** an beliebiger Stelle öffnet **Zurück / Vorwärts**. Dieselbe
|
||||
Navigation funktioniert mit **Alt+Links / Alt+Rechts** und den beiden seitlichen
|
||||
Maustasten. Nicht verfügbare Richtungen sind ausgegraut. Escape oder ein Klick
|
||||
außerhalb schließt das Menü.
|
||||
|
||||
Der Verlauf merkt Datenbereiche, Doppelklick-Absprünge, Vergleichsansichten und
|
||||
Asset-Verknüpfungen. Beim Zurückkehren werden Filter, Suche, Sortierung,
|
||||
Datensatzauswahl, Tabellenseite und Scrollpositionen wiederhergestellt.
|
||||
Filtereingaben und einfache Zeilenauswahl erzeugen keine einzelnen Verlaufsschritte.
|
||||
Offene Formulareingaben werden weiterhin vor dem Wechsel abgefragt; Abbrechen
|
||||
lässt die Position im Verlauf unverändert. Ein neuer Absprung nach Zurück ersetzt
|
||||
den bisherigen Vorwärtszweig. Das Öffnen einer anderen Welt, auch über MCP,
|
||||
setzt den Verlauf zurück. **Zurück** ist unabhängig von **Rückgängig** und ändert
|
||||
keine Daten.
|
||||
|
||||
Die Dropdowns verwenden die Gestaltung der Modern-Desktop-Untermenüs:
|
||||
leichte Verläufe, runde Popup-Listen, ein Häkchen am gewählten Wert und dieselbe
|
||||
Schriftgröße in geschlossenem Feld und Auswahlliste. Escape schließt zuerst die
|
||||
offene Auswahlliste. [Native Vergleichsbilder](qa/editor-navigation/README.md)
|
||||
zeigen die Darstellung in allen drei Themes.
|
||||
|
||||
## CPU im Leerlauf
|
||||
|
||||
Ab 0.5.4 zeichnet der Editor nur bei Eingaben, sichtbaren Änderungen oder von
|
||||
RmlUI angeforderten Zeitereignissen. Ein unveränderter Bildschirm benötigt keine
|
||||
fortlaufenden Frames. Textcursor, Animationen, Scrollen und externe MCP-Änderungen
|
||||
bleiben aktiv; minimierte Fenster zeichnen nicht. Die vorherige Dauerschleife
|
||||
konnte insbesondere mit dem WARP-Softwarerenderer unter Remote Desktop einen
|
||||
erheblichen Teil der CPU belegen. Import, Bildverarbeitung und andere tatsächliche
|
||||
Datenarbeit benötigen weiterhin Rechenzeit.
|
||||
|
||||
## Stärken und Gehälter vergleichen
|
||||
|
||||
**Wertevergleich** in der Seitenleiste (oder die gleichnamige Schaltfläche bei Spielern, Vereinen und Wettbewerben) öffnet eine Übersicht mit drei Ansichten: **Spieler**, **Mannschaften**, **Ligen**. Spieler zeigen ihre einzelnen Spielwerte und das Gehalt je Saison; Mannschaften und Ligen zeigen Durchschnittswerte, Spielergehaltssummen, das Durchschnittsgehalt und die Anzahl bekannter Gehälter. Ein Klick auf eine Zeile öffnet ihren Datensatz zur Bearbeitung.
|
||||
@@ -76,7 +109,7 @@ Unter **Darstellung** stehen die drei Farbwelten der modernen Untermenüs zur Au
|
||||
|
||||
Der MCP-Server ist standardmäßig aktiviert und bindet ausschließlich `127.0.0.1`, standardmäßig Port `8765`. Port `0` wählt einen freien Port. Status und tatsächlicher Port sind in Optionen sichtbar. **Verbindung kopieren** kopiert eine JSON-Konfiguration einschließlich Bearer-Token für HTTP-fähige MCP-Clients. Das Token bleibt lokal im Benutzerprofil und wird nur auf ausdrückliches Kopieren/CLI-Anfordern ausgegeben. Ein anderer bereits laufender Editor kann den Standardport belegen; dann einen anderen Port wählen.
|
||||
|
||||
Implementiert ist [MCP Streamable HTTP 2025-11-25](https://modelcontextprotocol.io/specification/2025-11-25/basic/transports), mit Aushandlung von 2025-06-18; JSON-Antworten, ohne optionale SSE-Sitzungen. Neuere MCP-Versionen werden nicht als unterstützt beworben. Der Server prüft Token, Host und gegebenenfalls Origin. Oberfläche und Agent bearbeiten dieselbe Welt, verwenden dieselbe Validierung und dieselbe Undo-Historie. Für konkurrierende Änderungen `expected_revision` aus `editor_info`/`editor_get` mitsenden.
|
||||
Implementiert ist [MCP Streamable HTTP 2025-11-25](https://modelcontextprotocol.io/specification/2025-11-25/basic/transports), mit Aushandlung von 2025-06-18; JSON-Antworten, ohne optionale SSE-Sitzungen. Neuere MCP-Versionen werden nicht als unterstützt beworben. Der Server prüft Token, Host und gegebenenfalls Origin. Oberfläche und Agent bearbeiten dieselbe Welt, verwenden dieselbe Validierung und dieselbe Undo-Historie. Für konkurrierende Änderungen `expected_revision` aus `editor_info`/`editor_get` mitsenden. `editor_info.world_generation` kennzeichnet die aktuell geladene Welt innerhalb der Sitzung: Öffnen/Neu erhöht den Wert, Bearbeiten, Speichern und Rückgängig behalten ihn bei. Er wird nicht im OBW gespeichert.
|
||||
|
||||
Werkzeuge: `editor_info`, `editor_open`, `editor_new`, `editor_list`, `editor_compare`, `editor_regulations`, `editor_get`, `editor_apply`, `editor_rules`, `editor_validate`, `editor_history`, `editor_save`, `editor_undo`, `editor_redo`, `editor_roster_move`, `editor_roster_swap`, `editor_roster_order`, `editor_review_resolve`, `editor_image_import`, `editor_image_edit`, `editor_image_preview`, `editor_image_export`. Die eingeblendeten Tools enthalten Parameterschemata und Beschreibungen. Öffnen einer anderen Welt verwirft ungespeicherte Änderungen nur mit `discard: true`.
|
||||
|
||||
@@ -135,4 +168,4 @@ Click a crest, portrait, trophy or list thumbnail to open a large read-only imag
|
||||
|
||||
In **Options**, switch the interface to **English**, choose one of the three themes, and enable/disable the integrated local MCP server. **Copy connection** provides the authenticated configuration. The server defaults to loopback port 8765; use port 0 for a free port. GUI and MCP share the same world, validation and undo history. It supports MCP Streamable HTTP 2025-11-25/2025-06-18 and optional stdio mode. Use `expected_revision` for concurrent edits.
|
||||
|
||||
Build with the three commands above, including `-DOPENBMH_BUILD_EDITOR=ON`. Windows uses Direct3D 11 with automatic WARP software fallback. Linux requires OpenGL 3.3; macOS requires OpenGL 4.1, plus the documented platform development dependencies. Editor 0.5.3 is unsigned and does not bundle any real-world dataset or proprietary game assets.
|
||||
Build with the three commands above, including `-DOPENBMH_BUILD_EDITOR=ON`. Windows uses Direct3D 11 with automatic WARP software fallback. Linux requires OpenGL 3.3; macOS requires OpenGL 4.1, plus the documented platform development dependencies. Editor 0.5.4 is unsigned and does not bundle any real-world dataset or proprietary game assets.
|
||||
@@ -0,0 +1,64 @@
|
||||
# Native navigation, pickers and idle rendering
|
||||
|
||||
Editor 0.5.4, native SDL2/RmlUI at 1440×900. The captures contain only generated
|
||||
demo records and project-authored geometric crests. No installation, real photo,
|
||||
savegame, personal profile or MCP token is included. Reproduce the initial
|
||||
database with `OpenBMHEditor --demo --page clubs`.
|
||||
|
||||
| View | Screenshot |
|
||||
|---|---|
|
||||
| Before: 0.5.3 controls and MCP button spacing | [Options before](before-options-0.5.3.png) |
|
||||
| After: Modern Desktop controls and separated Copy connection | [Options](options-midnight-de.png) |
|
||||
| Native dropdown, Midnight / German | [Midnight](dropdown-midnight-de.png) |
|
||||
| Native dropdown, Silver / English | [Silver](dropdown-silver-en.png) |
|
||||
| Native dropdown, Matchday / German | [Matchday](dropdown-matchday-de.png) |
|
||||
| Browser context menu, both directions available | [Back / Forward](history-midnight-de.png) |
|
||||
|
||||
The controls port the Modern Desktop submenu palettes, gradient buttons, rounded
|
||||
popup, selection checkmark, matching text size and hover treatment to RCSS. They
|
||||
retain RmlUI's native select values/events and scale with the editor. Escape
|
||||
cancels the open list before closing its dialog. The connection action now has
|
||||
20dp of space above it. Correct frame initialization preserves transparent
|
||||
offscreen layers for the popup shadows.
|
||||
|
||||
`tests/editor_gui_smoke.py` uses actual mouse/keyboard input and an MCP observer:
|
||||
|
||||
- Drill from the second of two leagues to its club and players. Back twice,
|
||||
then Forward twice; edit/undo the selected destinations to verify their IDs.
|
||||
- Cancel a draft when going Back, then apply it to the original player. The
|
||||
subsequent Back still visits the club, proving the cursor did not advance.
|
||||
- Navigate elsewhere after Back, verify that Forward stays unavailable, and
|
||||
exercise both mouse side buttons.
|
||||
- Follow a preview's exact image-asset link and return in both directions.
|
||||
- Reopen the same OBW through MCP. Its unchanged filename/IDs must not preserve
|
||||
history or unapplied fields from the previous world.
|
||||
- Change native dropdowns by keyboard, cancel one with Escape, apply both
|
||||
languages and all three themes. Options alone leaves the world untouched.
|
||||
- Leave the window idle for three seconds. Its CPU budget is 20% of one logical
|
||||
core, intentionally generous for software-rendered CI. Continuous repainting
|
||||
fails this check. The observed local idle use was below 1% of one core.
|
||||
|
||||
The core tests also verify that edits, undo and save retain `world_generation`,
|
||||
while opening another world increments it. Navigation does not alter data or
|
||||
the editing undo cursor. Scroll positions are restored after rebuilding a view;
|
||||
history is limited to the last 200 visited views in the current world.
|
||||
|
||||
## Idle measurement
|
||||
|
||||
The former loop updated/rendered/presented continuously, with only a 10ms delay
|
||||
after each frame. The new loop waits for input or the next requested RmlUI timer.
|
||||
MCP state is checked every 400ms without repainting an unchanged screen. Async
|
||||
work completion, resize/expose, screenshot and automated-exit deadlines still
|
||||
wake the loop. Minimized windows do not render.
|
||||
|
||||
[Measured CPU time](idle-cpu-linux.json) uses six-second idle samples after the
|
||||
window settles, software OpenGL and two renderer threads. The synthetic demo
|
||||
changed from 95.3% to below the 0.01s sampling resolution; a private supplied world
|
||||
changed from 136.0% to 0.17% of **one logical core**. Multithreaded rendering can
|
||||
exceed 100% on this scale; these figures are not Task Manager's whole-machine
|
||||
percentage. This measurement is separate from import or image-processing work.
|
||||
|
||||
Native startup, screenshot deadlines, Unicode paths and failure reporting are
|
||||
covered by `tests/editor_startup_smoke.py`. Windows/WARP runtime measurements
|
||||
with private data are kept in the private repository. Build success on macOS
|
||||
does not establish native human acceptance there.
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 112 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 109 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 117 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 122 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 145 KiB |
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"environment": {
|
||||
"os": "Debian 13 x64",
|
||||
"renderer": "Mesa software OpenGL",
|
||||
"display": "Xvfb 1600x1000",
|
||||
"window": "1440x900",
|
||||
"software_renderer_threads": 2,
|
||||
"cpu_unit": "percent of one logical core; sums all editor threads"
|
||||
},
|
||||
"before_version": "0.5.3",
|
||||
"after_version": "0.5.4",
|
||||
"before": [
|
||||
{
|
||||
"case": "demo",
|
||||
"duration_s": 6.000090104993433,
|
||||
"cpu_s": 5.720000000000001,
|
||||
"one_core_percent": 95.33190168660411
|
||||
},
|
||||
{
|
||||
"case": "diamond",
|
||||
"duration_s": 6.000068283872679,
|
||||
"cpu_s": 8.16,
|
||||
"one_core_percent": 135.99845224983366
|
||||
}
|
||||
],
|
||||
"after": [
|
||||
{
|
||||
"case": "demo",
|
||||
"duration_s": 6.000068521825597,
|
||||
"cpu_s": 0.0,
|
||||
"one_core_percent": 0.0
|
||||
},
|
||||
{
|
||||
"case": "diamond",
|
||||
"duration_s": 6.000067526940256,
|
||||
"cpu_s": 0.010000000000000009,
|
||||
"one_core_percent": 0.1666647909394367
|
||||
}
|
||||
]
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 114 KiB |
@@ -1,5 +1,27 @@
|
||||
<!-- SPDX-License-Identifier: GPL-3.0-only -->
|
||||
# OpenBMH Editor 0.5.3
|
||||
# OpenBMH Editor 0.5.4
|
||||
|
||||
Adds browser-style **Back / Forward** navigation. Right-click anywhere in the
|
||||
editor to open the context menu; Alt+Left/Right and mouse side buttons use the
|
||||
same history. Returning to a view restores its filters, selected record, sorting,
|
||||
page and scroll positions. Unapplied inspector entries retain their confirmation
|
||||
dialog. Opening another world clears navigation; it does not undo data edits.
|
||||
|
||||
The editor now updates and renders on demand, instead of redrawing the entire
|
||||
window continuously while idle. Input, timed caret/animation updates and external
|
||||
MCP changes remain active. Minimized windows do not render. This is especially
|
||||
useful with Windows software rendering over Remote Desktop.
|
||||
|
||||
Dropdowns follow the Modern Desktop pickers: rounded themed buttons and popup
|
||||
lists, equal label/option font sizes, a checkmark for the current selection and
|
||||
subtle hover surfaces. Escape closes the open list before its dialog. Options
|
||||
also gives **Copy connection** more space below the MCP URL. All three themes
|
||||
and both interface languages are supported.
|
||||
|
||||
[Native screenshots and verification](../../qa/editor-navigation/README.md)
|
||||
include the controls and navigation.
|
||||
|
||||
## Editor 0.5.3
|
||||
|
||||
Fixes the Windows graphical startup on machines without an OpenGL 3.3 driver,
|
||||
including Windows Server / Remote Desktop. The editor and game launcher use the
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
include(FetchContent)
|
||||
set(OPENBMH_EDITOR_VERSION "0.5.3")
|
||||
set(OPENBMH_EDITOR_VERSION "0.5.4")
|
||||
file(WRITE "${CMAKE_BINARY_DIR}/editor-version.json" "{\"version\": \"${OPENBMH_EDITOR_VERSION}\"}\n")
|
||||
set(JSON_BuildTests OFF CACHE BOOL "" FORCE)
|
||||
FetchContent_Declare(editor_json GIT_REPOSITORY https://github.com/nlohmann/json.git
|
||||
|
||||
@@ -91,6 +91,10 @@ std::string tr(const std::string &language, const std::string &key) {
|
||||
using Pair = std::pair<std::string, std::string>;
|
||||
static const std::map<std::string, Pair> words{
|
||||
{"data_areas", {"Datenbereiche", "World data"}},
|
||||
{"navigation_back", {"Zurück", "Back"}},
|
||||
{"navigation_forward", {"Vorwärts", "Forward"}},
|
||||
{"navigation_left", {"Links", "Left"}},
|
||||
{"navigation_right", {"Rechts", "Right"}},
|
||||
{"drill_nations", {"Doppelklick: Ligen anzeigen", "Double-click to view leagues"}},
|
||||
{"drill_competitions",
|
||||
{"Doppelklick auf eine Liga: Vereine anzeigen", "Double-click a league to view clubs"}},
|
||||
|
||||
@@ -59,6 +59,7 @@ Json Session::info() const {
|
||||
Json result = world_ ? world_->statistics() : Json{{"title", ""}, {"counts", Json::object()}};
|
||||
result["loaded"] = bool(world_);
|
||||
result["revision"] = revision_;
|
||||
result["world_generation"] = world_generation_;
|
||||
result["dirty"] = dirty();
|
||||
result["can_undo"] = cursor_ > 0;
|
||||
result["can_redo"] = cursor_ < history_.size();
|
||||
@@ -67,6 +68,7 @@ Json Session::info() const {
|
||||
}
|
||||
void Session::replace(World value) {
|
||||
world_ = std::make_unique<World>(std::move(value));
|
||||
++world_generation_;
|
||||
history_.clear();
|
||||
cursor_ = 0;
|
||||
++revision_;
|
||||
|
||||
@@ -30,7 +30,7 @@ class Session {
|
||||
std::unique_ptr<World> world_;
|
||||
std::vector<Frame> history_;
|
||||
size_t cursor_ = 0;
|
||||
uint64_t revision_ = 0, state_ = 0, next_state_ = 1, saved_state_ = 0;
|
||||
uint64_t revision_ = 0, world_generation_ = 0, state_ = 0, next_state_ = 1, saved_state_ = 0;
|
||||
fs::path saved_path_;
|
||||
fs::file_time_type saved_time_{};
|
||||
uint64_t saved_size_ = 0;
|
||||
|
||||
+325
-31
@@ -7,6 +7,7 @@
|
||||
#include <RmlUi/Core.h>
|
||||
#include <RmlUi/Core/Elements/ElementFormControl.h>
|
||||
#include <RmlUi/Core/Elements/ElementFormControlInput.h>
|
||||
#include <RmlUi/Core/Elements/ElementFormControlSelect.h>
|
||||
#include <RmlUi_Platform_SDL.h>
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
@@ -109,8 +110,9 @@ class EditorUi final : public Rml::EventListener {
|
||||
Rml::Context *context_ = nullptr;
|
||||
Rml::ElementDocument *doc_ = nullptr;
|
||||
bool initialized_ = false, closed_ = false, busy_ = false, modal_ = false;
|
||||
bool roster24_ = false, show_source_ = false, needs_refresh_ = true;
|
||||
bool roster24_ = false, show_source_ = false, needs_refresh_ = true, redraw_ = true;
|
||||
uint64_t revision_ = uint64_t(-1);
|
||||
uint64_t world_generation_ = uint64_t(-1);
|
||||
Json info_, selected_ = Json::object(), listed_ = Json::array();
|
||||
std::map<std::string, Json> lookup_;
|
||||
std::string page_ = "overview", selected_id_, search_, nation_, league_, team_, sort_ = "name", remembered_;
|
||||
@@ -123,6 +125,27 @@ class EditorUi final : public Rml::EventListener {
|
||||
std::string regulation_id_, game_rule_id_;
|
||||
int offset_ = 0;
|
||||
size_t total_ = 0;
|
||||
struct Location {
|
||||
std::string page, selected, search, nation, league, team, sort;
|
||||
bool descending, roster24, show_source;
|
||||
int offset;
|
||||
std::string comparison_table, comparison_set, comparison_sort;
|
||||
bool comparison_descending, regulations_game, regulations_source;
|
||||
std::string regulation_id, game_rule_id;
|
||||
bool operator==(const Location &) const = default;
|
||||
};
|
||||
struct ScrollPosition {
|
||||
std::string selector;
|
||||
float left, top;
|
||||
};
|
||||
struct Visit {
|
||||
Location location;
|
||||
std::vector<ScrollPosition> scroll;
|
||||
};
|
||||
std::vector<Visit> navigation_;
|
||||
size_t navigation_index_ = 0;
|
||||
std::optional<std::vector<ScrollPosition>> restore_scroll_;
|
||||
bool history_menu_open_ = false;
|
||||
struct Field {
|
||||
std::string id, pointer, kind, initial;
|
||||
Json original;
|
||||
@@ -144,7 +167,20 @@ class EditorUi final : public Rml::EventListener {
|
||||
throw std::runtime_error("Missing editor element: " + id);
|
||||
return value;
|
||||
}
|
||||
void html(const std::string &id, const std::string &value) { el(id)->SetInnerRML(value); }
|
||||
void html(const std::string &id, const std::string &value) {
|
||||
auto *container = el(id);
|
||||
container->SetInnerRML(value);
|
||||
Rml::ElementList controls;
|
||||
container->QuerySelectorAll(controls, "select");
|
||||
for (auto *element : controls)
|
||||
if (auto *select = dynamic_cast<Rml::ElementFormControlSelect *>(element))
|
||||
for (int i = 0; i < select->GetNumOptions(); ++i) {
|
||||
auto *option = select->GetOption(i);
|
||||
option->SetInnerRML("<span class=\"option-check\"></span><span class=\"option-label\">" +
|
||||
option->GetInnerRML() + "</span>");
|
||||
}
|
||||
redraw_ = true;
|
||||
}
|
||||
void label(const std::string &id, const std::string &value) { html(id, escaped(value)); }
|
||||
std::string value(const std::string &id) const {
|
||||
auto *field = dynamic_cast<Rml::ElementFormControl *>(el(id));
|
||||
@@ -155,6 +191,136 @@ class EditorUi final : public Rml::EventListener {
|
||||
field->SetValue(value);
|
||||
}
|
||||
std::string table() const { return page_ == "roster" ? "players" : page_; }
|
||||
Location location() const {
|
||||
return {page_,
|
||||
selected_id_,
|
||||
search_,
|
||||
nation_,
|
||||
league_,
|
||||
team_,
|
||||
sort_,
|
||||
descending_,
|
||||
roster24_,
|
||||
show_source_,
|
||||
offset_,
|
||||
comparison_table_,
|
||||
comparison_set_,
|
||||
comparison_sort_,
|
||||
comparison_descending_,
|
||||
regulations_game_,
|
||||
regulations_source_,
|
||||
regulation_id_,
|
||||
game_rule_id_};
|
||||
}
|
||||
std::vector<ScrollPosition> scroll_positions() const {
|
||||
std::vector<ScrollPosition> result;
|
||||
for (const auto *selector :
|
||||
{"#table-scroll", ".inspector-scroll", "#comparison-x", ".regulation-list .table-scroll",
|
||||
".regulation-scroll", ".dashboard", "#navigation"})
|
||||
if (auto *element = doc_->QuerySelector(selector))
|
||||
result.push_back({selector, element->GetScrollLeft(), element->GetScrollTop()});
|
||||
return result;
|
||||
}
|
||||
void remember_location() {
|
||||
if (!navigation_.empty())
|
||||
navigation_[navigation_index_] = {location(), scroll_positions()};
|
||||
}
|
||||
void visit(std::function<void()> next) {
|
||||
leave_fields([this, next] {
|
||||
remember_location();
|
||||
const auto previous = location();
|
||||
next();
|
||||
if (location() == previous)
|
||||
return;
|
||||
navigation_.resize(navigation_index_ + 1);
|
||||
navigation_.push_back({location(), {}});
|
||||
navigation_index_ = navigation_.size() - 1;
|
||||
// Bound memory use during long editing sessions.
|
||||
if (navigation_.size() > 200) {
|
||||
navigation_.erase(navigation_.begin());
|
||||
--navigation_index_;
|
||||
}
|
||||
});
|
||||
}
|
||||
bool can_navigate(int direction) const {
|
||||
return !busy_ && !modal_ && !navigation_.empty() &&
|
||||
(direction < 0 ? navigation_index_ > 0 : navigation_index_ + 1 < navigation_.size());
|
||||
}
|
||||
void navigate_history(int direction) {
|
||||
if (!can_navigate(direction))
|
||||
return;
|
||||
leave_fields([this, direction] {
|
||||
remember_location();
|
||||
navigation_index_ = direction < 0 ? navigation_index_ - 1 : navigation_index_ + 1;
|
||||
const auto &destination = navigation_[navigation_index_];
|
||||
const auto &l = destination.location;
|
||||
page_ = l.page;
|
||||
selected_id_ = l.selected;
|
||||
search_ = l.search;
|
||||
nation_ = l.nation;
|
||||
league_ = l.league;
|
||||
team_ = l.team;
|
||||
sort_ = l.sort;
|
||||
descending_ = l.descending;
|
||||
roster24_ = l.roster24;
|
||||
show_source_ = l.show_source;
|
||||
offset_ = l.offset;
|
||||
comparison_table_ = l.comparison_table;
|
||||
comparison_set_ = l.comparison_set;
|
||||
comparison_sort_ = l.comparison_sort;
|
||||
comparison_descending_ = l.comparison_descending;
|
||||
regulations_game_ = l.regulations_game;
|
||||
regulations_source_ = l.regulations_source;
|
||||
regulation_id_ = l.regulation_id;
|
||||
game_rule_id_ = l.game_rule_id;
|
||||
restore_scroll_ = destination.scroll;
|
||||
fields_.clear();
|
||||
needs_refresh_ = true;
|
||||
});
|
||||
}
|
||||
void close_history_menu() {
|
||||
if (!history_menu_open_)
|
||||
return;
|
||||
el("history-overlay")->SetProperty("display", "none");
|
||||
history_menu_open_ = false;
|
||||
redraw_ = true;
|
||||
}
|
||||
void history_menu(int x, int y) {
|
||||
Rml::ElementList controls;
|
||||
doc_->QuerySelectorAll(controls, "select");
|
||||
for (auto *element : controls)
|
||||
if (auto *select = dynamic_cast<Rml::ElementFormControlSelect *>(element))
|
||||
select->HideSelectBox();
|
||||
std::string items;
|
||||
for (const int direction : {-1, 1}) {
|
||||
const auto action = direction < 0 ? "history-back" : "history-forward";
|
||||
items += "<button id=\"" + std::string(action) + "\" data-action=\"" + action + "\" " +
|
||||
(can_navigate(direction) ? "" : "disabled") + "><span class=\"history-arrow\">" +
|
||||
icon(direction < 0 ? "back" : "forward") + "</span><span>" +
|
||||
escaped(t(direction < 0 ? "navigation_back" : "navigation_forward")) +
|
||||
"</span><small>Alt + " + t(direction < 0 ? "navigation_left" : "navigation_right") +
|
||||
"</small></button>";
|
||||
}
|
||||
html("history-menu", items);
|
||||
el("history-overlay")->SetProperty("display", "block");
|
||||
history_menu_open_ = true;
|
||||
context_->Update();
|
||||
const auto dimensions = context_->GetDimensions();
|
||||
auto *menu = el("history-menu");
|
||||
const float margin = 6 * context_->GetDensityIndependentPixelRatio();
|
||||
menu->SetProperty(
|
||||
"left", number(std::clamp(float(x), margin,
|
||||
std::max(margin, dimensions.x - menu->GetOffsetWidth() - margin))) +
|
||||
"px");
|
||||
menu->SetProperty(
|
||||
"top", number(std::clamp(float(y), margin,
|
||||
std::max(margin, dimensions.y - menu->GetOffsetHeight() - margin))) +
|
||||
"px");
|
||||
if (can_navigate(-1))
|
||||
el("history-back")->Focus();
|
||||
else if (can_navigate(1))
|
||||
el("history-forward")->Focus();
|
||||
}
|
||||
static std::string identity(const Json &row, const std::string &table) {
|
||||
return str(row, table == "assets" ? "key" : "id");
|
||||
}
|
||||
@@ -178,6 +344,8 @@ class EditorUi final : public Rml::EventListener {
|
||||
}
|
||||
std::string icon(const std::string &name) {
|
||||
static const std::map<std::string, std::string> paths{
|
||||
{"back", "M19 12H5M12 5l-7 7 7 7"},
|
||||
{"forward", "M5 12h14M12 5l7 7-7 7"},
|
||||
{"overview", "M3 3h7v7H3zM14 3h7v7h-7zM3 14h7v7H3zM14 14h7v7h-7z"},
|
||||
{"nations", "M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0M3 12h18M12 3c-5 5-5 "
|
||||
"13 0 18M12 3c5 5 5 13 0 18"},
|
||||
@@ -270,6 +438,8 @@ class EditorUi final : public Rml::EventListener {
|
||||
return result;
|
||||
}
|
||||
void resize() {
|
||||
close_history_menu();
|
||||
redraw_ = true;
|
||||
int w, h, pw, ph;
|
||||
SDL_GetWindowSize(video_.window, &w, &h);
|
||||
video_.drawable_size(pw, ph);
|
||||
@@ -281,6 +451,7 @@ class EditorUi final : public Rml::EventListener {
|
||||
std::clamp(std::min(w / 1440.f, h / 900.f), .78f, 1.8f));
|
||||
}
|
||||
void close_modal() {
|
||||
redraw_ = true;
|
||||
el("overlay")->SetProperty("display", "none");
|
||||
if (image_view_open_) {
|
||||
html("modal-content", "");
|
||||
@@ -292,6 +463,7 @@ class EditorUi final : public Rml::EventListener {
|
||||
}
|
||||
void modal(const std::string &title, const std::string &body, const std::string &accept,
|
||||
std::function<void()> callback, bool cancel = true, bool wide = false) {
|
||||
close_history_menu();
|
||||
if (image_view_open_)
|
||||
close_modal();
|
||||
label("modal-title", title);
|
||||
@@ -609,7 +781,7 @@ class EditorUi final : public Rml::EventListener {
|
||||
const auto record = session_.execute("get", {{"table", source}, {"id", id}})["record"];
|
||||
if (source == "competitions" && str(record, "type") != "league")
|
||||
return;
|
||||
leave_fields([this, source, id] {
|
||||
visit([this, source, id] {
|
||||
// Apply/discard decisions may have updated the source record.
|
||||
const auto row = session_.execute("get", {{"table", source}, {"id", id}})["record"];
|
||||
if (source == "competitions" && str(row, "type") != "league")
|
||||
@@ -1233,6 +1405,31 @@ class EditorUi final : public Rml::EventListener {
|
||||
if (auto *input = dynamic_cast<Rml::ElementFormControlInput *>(context_->GetFocusElement()))
|
||||
input->GetSelection(&selection_start, &selection_end, nullptr);
|
||||
info_ = session_.execute("info");
|
||||
const auto generation = info_.value("world_generation", uint64_t(0));
|
||||
if (generation != world_generation_) {
|
||||
// An MCP client can also open a different world, even with the
|
||||
// same filename and identifiers. Never replay an old view/draft.
|
||||
world_generation_ = generation;
|
||||
navigation_.clear();
|
||||
navigation_index_ = 0;
|
||||
restore_scroll_.reset();
|
||||
selected_id_.clear();
|
||||
fields_.clear();
|
||||
search_.clear();
|
||||
nation_.clear();
|
||||
league_.clear();
|
||||
team_.clear();
|
||||
remembered_.clear();
|
||||
comparison_set_.clear();
|
||||
comparison_columns_.clear();
|
||||
regulation_id_.clear();
|
||||
game_rule_id_.clear();
|
||||
offset_ = 0;
|
||||
close_history_menu();
|
||||
if (modal_)
|
||||
close_modal();
|
||||
discard_continuation_ = {};
|
||||
}
|
||||
auto rev = info_.value("revision", uint64_t(0));
|
||||
renderer_.clear();
|
||||
if (revision_ != rev) {
|
||||
@@ -1259,6 +1456,17 @@ class EditorUi final : public Rml::EventListener {
|
||||
input->Focus();
|
||||
input->SetSelectionRange(selection_start, selection_end);
|
||||
}
|
||||
if (restore_scroll_) {
|
||||
context_->Update();
|
||||
for (const auto &position : *restore_scroll_)
|
||||
if (auto *element = doc_->QuerySelector(position.selector)) {
|
||||
element->SetScrollLeft(position.left);
|
||||
element->SetScrollTop(position.top);
|
||||
}
|
||||
restore_scroll_.reset();
|
||||
}
|
||||
if (navigation_.empty())
|
||||
navigation_.push_back({location(), {}});
|
||||
needs_refresh_ = false;
|
||||
}
|
||||
bool has_draft() const {
|
||||
@@ -1333,7 +1541,8 @@ class EditorUi final : public Rml::EventListener {
|
||||
body += "<p class=\"form-help\">" + t("mcp_local") + " · " + t(server_.running() ? "online" : "offline") +
|
||||
(server_.running() ? "<br/>http://127.0.0.1:" + std::to_string(server_.port()) + "/mcp" : "") + "</p>";
|
||||
if (server_.running())
|
||||
body += button("copy-connection", t("copy_connection"));
|
||||
body += "<div class=\"connection-actions\">" + button("copy-connection", t("copy_connection")) +
|
||||
"</div>";
|
||||
modal(t("options"), body, t("apply"), [this] {
|
||||
auto next = options_;
|
||||
next.apply({{"language", value("option-language")},
|
||||
@@ -1546,10 +1755,16 @@ class EditorUi final : public Rml::EventListener {
|
||||
});
|
||||
}
|
||||
void dispatch(const std::string &action, const std::string &arg) {
|
||||
if (action == "history-close" || action == "history-back" || action == "history-forward") {
|
||||
close_history_menu();
|
||||
if (action != "history-close")
|
||||
navigate_history(action == "history-back" ? -1 : 1);
|
||||
return;
|
||||
}
|
||||
if (busy_)
|
||||
return;
|
||||
if (action == "navigate")
|
||||
leave_fields([this, arg] {
|
||||
visit([this, arg] {
|
||||
page_ = arg;
|
||||
fields_.clear();
|
||||
selected_id_.clear();
|
||||
@@ -1572,7 +1787,7 @@ class EditorUi final : public Rml::EventListener {
|
||||
regulations_source_ = !regulations_source_;
|
||||
needs_refresh_ = true;
|
||||
} else if (action == "compare-open" || action == "compare-scope")
|
||||
leave_fields([this, action, arg] {
|
||||
visit([this, action, arg] {
|
||||
comparison_table_ =
|
||||
action == "compare-open" ? (table() == "competitions" ? "leagues" : table()) : arg;
|
||||
page_ = "comparison";
|
||||
@@ -1609,14 +1824,16 @@ class EditorUi final : public Rml::EventListener {
|
||||
offset_ = 0;
|
||||
needs_refresh_ = true;
|
||||
}
|
||||
} else if (action == "compare-edit") {
|
||||
page_ = comparison_table_ == "leagues" ? "competitions" : comparison_table_;
|
||||
selected_id_ = arg;
|
||||
sort_ = "name";
|
||||
offset_ = 0;
|
||||
search_.clear();
|
||||
needs_refresh_ = true;
|
||||
} else if (action.starts_with("browse:"))
|
||||
} else if (action == "compare-edit")
|
||||
visit([this, arg] {
|
||||
page_ = comparison_table_ == "leagues" ? "competitions" : comparison_table_;
|
||||
selected_id_ = arg;
|
||||
sort_ = "name";
|
||||
offset_ = 0;
|
||||
search_.clear();
|
||||
needs_refresh_ = true;
|
||||
});
|
||||
else if (action.starts_with("browse:"))
|
||||
browse_related(action.substr(7), arg);
|
||||
else if (action.starts_with("select:")) {
|
||||
// The click following a double click still belongs to its old list.
|
||||
@@ -1772,7 +1989,7 @@ class EditorUi final : public Rml::EventListener {
|
||||
view_image(arg);
|
||||
else if (action == "image-view-asset") {
|
||||
close_modal();
|
||||
leave_fields([this, arg] {
|
||||
visit([this, arg] {
|
||||
page_ = "assets";
|
||||
selected_id_ = search_ = arg;
|
||||
offset_ = 0;
|
||||
@@ -1897,7 +2114,8 @@ class EditorUi final : public Rml::EventListener {
|
||||
void ProcessEvent(Rml::Event &event) override {
|
||||
auto *target = event.GetTargetElement();
|
||||
const auto type = event.GetType();
|
||||
if (type == "mousedown" && modal_ && doc_->GetElementById("crop-canvas")) {
|
||||
if (type == "mousedown" && event.GetParameter<int>("button", 0) == 0 && modal_ &&
|
||||
doc_->GetElementById("crop-canvas")) {
|
||||
for (auto *node = target; node; node = node->GetParentNode())
|
||||
if (node->GetId() == "crop-canvas") {
|
||||
crop_drag(event.GetParameter<float>("mouse_x", 0), event.GetParameter<float>("mouse_y", 0), true);
|
||||
@@ -1941,10 +2159,32 @@ class EditorUi final : public Rml::EventListener {
|
||||
}
|
||||
}
|
||||
int run() {
|
||||
using Clock = std::chrono::steady_clock;
|
||||
using namespace std::chrono_literals;
|
||||
auto last_poll = start_;
|
||||
auto next_update = start_;
|
||||
auto observed_revision = revision_;
|
||||
while (!closed_) {
|
||||
const auto before_wait = Clock::now();
|
||||
const bool drawable =
|
||||
!(SDL_GetWindowFlags(video_.window) & (SDL_WINDOW_MINIMIZED | SDL_WINDOW_HIDDEN));
|
||||
auto wake = busy_ ? before_wait + 50ms : last_poll + 400ms;
|
||||
if (drawable) {
|
||||
wake = std::min(wake, next_update);
|
||||
if (!busy_ && !config_.screenshot.empty())
|
||||
wake = std::min(wake, start_ + 1200ms);
|
||||
}
|
||||
if (config_.quit_after_ms > 0)
|
||||
wake = std::min(wake, start_ + std::chrono::milliseconds(config_.quit_after_ms));
|
||||
const auto timeout =
|
||||
!pending_.empty() || (drawable && (redraw_ || (needs_refresh_ && !busy_)))
|
||||
? 0
|
||||
: int(std::clamp(std::chrono::ceil<std::chrono::milliseconds>(wake - before_wait).count(),
|
||||
int64_t(0), int64_t(400)));
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event)) {
|
||||
int have_event = timeout > 0 ? SDL_WaitEventTimeout(&event, timeout) : SDL_PollEvent(&event);
|
||||
for (; have_event; have_event = SDL_PollEvent(&event)) {
|
||||
redraw_ = true;
|
||||
if (event.type == SDL_QUIT) {
|
||||
try {
|
||||
leaving([this] { closed_ = true; });
|
||||
@@ -1973,6 +2213,27 @@ class EditorUi final : public Rml::EventListener {
|
||||
pending_.emplace_back("open", "");
|
||||
continue;
|
||||
}
|
||||
if ((event.key.keysym.mod & KMOD_ALT) &&
|
||||
(event.key.keysym.sym == SDLK_LEFT || event.key.keysym.sym == SDLK_RIGHT)) {
|
||||
pending_.emplace_back(
|
||||
event.key.keysym.sym == SDLK_LEFT ? "history-back" : "history-forward", "");
|
||||
continue;
|
||||
}
|
||||
if (event.key.keysym.sym == SDLK_ESCAPE && history_menu_open_) {
|
||||
close_history_menu();
|
||||
continue;
|
||||
}
|
||||
if (event.key.keysym.sym == SDLK_ESCAPE) {
|
||||
auto *owner = focused;
|
||||
while (owner && owner->GetTagName() != "select")
|
||||
owner = owner->GetParentNode();
|
||||
if (auto *select = dynamic_cast<Rml::ElementFormControlSelect *>(owner);
|
||||
select && select->IsSelectBoxVisible()) {
|
||||
select->CancelSelectBox();
|
||||
select->Focus();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (event.key.keysym.sym == SDLK_ESCAPE && modal_) {
|
||||
close_modal();
|
||||
continue;
|
||||
@@ -2008,12 +2269,27 @@ class EditorUi final : public Rml::EventListener {
|
||||
context_->ProcessMouseMove(event.button.x, event.button.y, RmlSDL::GetKeyModifierState());
|
||||
}
|
||||
}
|
||||
if (event.type == SDL_MOUSEBUTTONDOWN || event.type == SDL_MOUSEBUTTONUP) {
|
||||
if (event.button.button == SDL_BUTTON_RIGHT) {
|
||||
if (event.type == SDL_MOUSEBUTTONUP)
|
||||
history_menu(event.button.x, event.button.y);
|
||||
continue;
|
||||
}
|
||||
if (event.button.button == SDL_BUTTON_X1 || event.button.button == SDL_BUTTON_X2) {
|
||||
if (event.type == SDL_MOUSEBUTTONUP)
|
||||
pending_.emplace_back(
|
||||
event.button.button == SDL_BUTTON_X1 ? "history-back" : "history-forward",
|
||||
"");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
RmlSDL::InputEventHandler(context_, video_.window, event);
|
||||
}
|
||||
}
|
||||
while (!pending_.empty()) {
|
||||
auto [action, arg] = pending_.front();
|
||||
pending_.pop_front();
|
||||
redraw_ = true;
|
||||
try {
|
||||
dispatch(action, arg);
|
||||
} catch (const std::exception &e) {
|
||||
@@ -2032,15 +2308,19 @@ class EditorUi final : public Rml::EventListener {
|
||||
}
|
||||
completed_ = {};
|
||||
}
|
||||
const auto now = std::chrono::steady_clock::now();
|
||||
if (!busy_ && now - last_poll > std::chrono::milliseconds(400)) {
|
||||
const auto now = Clock::now();
|
||||
if (!busy_ && now - last_poll >= 400ms) {
|
||||
auto info = session_.execute("info");
|
||||
if (info.value("revision", uint64_t(0)) != revision_) {
|
||||
if (!has_draft() && !modal_)
|
||||
const auto revision = info.value("revision", uint64_t(0));
|
||||
if (info.value("world_generation", uint64_t(0)) != world_generation_)
|
||||
needs_refresh_ = true;
|
||||
else if (info != info_) {
|
||||
if (!has_draft() && !modal_ && !history_menu_open_)
|
||||
needs_refresh_ = true;
|
||||
else
|
||||
else if (revision != revision_ && revision != observed_revision)
|
||||
label("status-message", t("stale_revision"));
|
||||
}
|
||||
observed_revision = revision;
|
||||
last_poll = now;
|
||||
}
|
||||
if (needs_refresh_ && !busy_) {
|
||||
@@ -2051,16 +2331,30 @@ class EditorUi final : public Rml::EventListener {
|
||||
error(e);
|
||||
}
|
||||
}
|
||||
context_->Update();
|
||||
renderer_.BeginFrame();
|
||||
renderer_.Clear();
|
||||
context_->Render();
|
||||
renderer_.EndFrame();
|
||||
auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(now - start_).count();
|
||||
if (!busy_ && elapsed > 1200 && !config_.screenshot.empty())
|
||||
screenshot();
|
||||
video_.present();
|
||||
SDL_Delay(10);
|
||||
const bool capture = !busy_ && elapsed >= 1200 && !config_.screenshot.empty();
|
||||
if (drawable && (redraw_ || now >= next_update || capture)) {
|
||||
const auto updated = Clock::now();
|
||||
context_->Update();
|
||||
// BeginFrame configures transparent clears for offscreen
|
||||
// layers (popup shadows). Clear the output before that setup.
|
||||
renderer_.Clear();
|
||||
renderer_.BeginFrame();
|
||||
context_->Render();
|
||||
renderer_.EndFrame();
|
||||
if (capture)
|
||||
screenshot();
|
||||
video_.present();
|
||||
redraw_ = false;
|
||||
const double delay = context_->GetNextUpdateDelay();
|
||||
// RmlUI requests timed updates for caret blink, animations and
|
||||
// smooth scrolling. A static view needs no frames at all.
|
||||
next_update =
|
||||
std::isfinite(delay)
|
||||
? updated + std::chrono::duration_cast<Clock::duration>(
|
||||
std::chrono::duration<double>(std::clamp(delay, .016, 3600.0)))
|
||||
: Clock::time_point::max();
|
||||
}
|
||||
if (config_.quit_after_ms > 0 && elapsed >= config_.quit_after_ms)
|
||||
closed_ = true;
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ int main() {
|
||||
try {
|
||||
Session s;
|
||||
s.execute("demo");
|
||||
const auto generation = s.execute("info")["world_generation"];
|
||||
check(s.execute("list", {{"table", "players"}})["total"] == 52, "all squads retained");
|
||||
check(s.execute("list", {{"table", "players"}, {"team", "club:north"}, {"limit", 24}})["items"].size() == 24,
|
||||
"24 view");
|
||||
@@ -63,6 +64,8 @@ int main() {
|
||||
s.execute("undo");
|
||||
check(row(s, "players", "player:demo-0") == initial, "undo complete row");
|
||||
check(s.execute("info")["revision"] > revision, "revision monotonic across undo");
|
||||
check(s.execute("info")["world_generation"] == generation,
|
||||
"edits and undo keep navigation world identity");
|
||||
s.execute("redo");
|
||||
check(row(s, "players", "player:demo-0")["attributes"]["strength"] == 99, "redo");
|
||||
rejects("validation_failed",
|
||||
@@ -233,6 +236,17 @@ int main() {
|
||||
}
|
||||
#endif
|
||||
check(tr("de", "clubs") != tr("en", "clubs"), "bilingual labels");
|
||||
{
|
||||
Session reopened;
|
||||
reopened.execute("demo");
|
||||
const auto identity = reopened.execute("info")["world_generation"];
|
||||
reopened.execute("save", {{"path", utf8(root / "navigation-world.obw")}});
|
||||
check(reopened.execute("info")["world_generation"] == identity,
|
||||
"saving keeps navigation world identity");
|
||||
reopened.execute("open", {{"path", utf8(root / "navigation-world.obw")}});
|
||||
check(reopened.execute("info")["world_generation"] > identity,
|
||||
"reopening identical IDs resets navigation identity");
|
||||
}
|
||||
McpServer mcp(s);
|
||||
mcp.start(options);
|
||||
httplib::Client client("127.0.0.1", mcp.port());
|
||||
|
||||
@@ -209,7 +209,100 @@ def main():
|
||||
before_view = tool('editor_info')
|
||||
click(1100, 326); x('key', 'Escape'); time.sleep(.2)
|
||||
assert tool('editor_info') == before_view
|
||||
print('Native edit, comparisons, rules, drill-down, read-only image preview and asset links passed.')
|
||||
# Browser navigation restores the selected league and its
|
||||
# filters without editing data or advancing the undo cursor.
|
||||
def history(direction):
|
||||
before = tool('editor_info')
|
||||
x('mousemove', '--window', window, 760, 300, 'click', 3)
|
||||
time.sleep(.15)
|
||||
click(850, 330 if direction == 'back' else 375)
|
||||
time.sleep(.2)
|
||||
assert tool('editor_info') == before, 'History must be read only'
|
||||
click(100, 264); double_click(350, 385)
|
||||
double_click(350, 335)
|
||||
history('back')
|
||||
edit_selected('clubs', 'club:south', 'History Team')
|
||||
history('back')
|
||||
edit_selected('competitions', 'comp:second', 'History League')
|
||||
history('forward')
|
||||
edit_selected('clubs', 'club:south', 'History Forward Team')
|
||||
history('forward')
|
||||
edit_selected('players', south_player, 'History Forward Player', True)
|
||||
# Cancelling a pending property edit must keep the history
|
||||
# cursor in place, so the next Back still visits the team.
|
||||
click(1150, 443); x('key', 'ctrl+a'); x('type', '--clearmodifiers', 'History Draft')
|
||||
history('back'); x('key', 'Escape'); time.sleep(.2)
|
||||
click(1300, 741)
|
||||
assert tool('editor_get', {'table': 'players', 'id': south_player})['record']['name']['first'] == 'History Draft'
|
||||
tool('editor_undo'); time.sleep(.5)
|
||||
history('back')
|
||||
edit_selected('clubs', 'club:south', 'History After Cancel')
|
||||
# A different destination after Back removes the forward
|
||||
# branch. Alt+arrows and mouse side buttons share this history.
|
||||
click(100, 313)
|
||||
x('key', 'alt+Right'); time.sleep(.2)
|
||||
edit_selected('clubs', 'club:north', 'History New Branch')
|
||||
x('click', 8); time.sleep(.3)
|
||||
edit_selected('clubs', 'club:south', 'History Side Back')
|
||||
x('click', 9); time.sleep(.3)
|
||||
edit_selected('clubs', 'club:north', 'History Side Forward')
|
||||
# Preview -> exact asset is also a visit, not a data undo.
|
||||
click(280, 385); click(985, 757)
|
||||
history('back')
|
||||
edit_selected('clubs', 'club:north', 'History Preview Back')
|
||||
history('forward')
|
||||
edit_selected('assets', 'asset:demo/south', 'History Preview Forward')
|
||||
# External MCP opens invalidate navigation, including when the
|
||||
# filename and all record IDs are unchanged.
|
||||
click(100, 361); click(100, 313)
|
||||
generation = tool('editor_info')['world_generation']
|
||||
tool('editor_open', {'path': str(root / 'world.obw'), 'discard': True})
|
||||
time.sleep(.6)
|
||||
assert tool('editor_info')['world_generation'] > generation
|
||||
x('key', 'alt+Left'); time.sleep(.2)
|
||||
edit_selected('clubs', 'club:north', 'History New World')
|
||||
# Modern dropdowns retain native values and keyboard input.
|
||||
# Escape cancels just the open list, keeping Options open and
|
||||
# restoring its prior value. Nothing applies before Apply.
|
||||
before_options = tool('editor_info')
|
||||
click(1370, 44)
|
||||
click(690, 258); x('key', 'Down'); x('key', 'Escape')
|
||||
time.sleep(.15)
|
||||
assert json.loads(settings.read_text())['language'] == 'de'
|
||||
click(690, 343); x('key', 'Down'); x('key', 'Return')
|
||||
assert json.loads(settings.read_text())['theme'] == 'midnight'
|
||||
click(950, 725)
|
||||
assert json.loads(settings.read_text())['theme'] == 'silver'
|
||||
assert json.loads(settings.read_text())['language'] == 'de'
|
||||
click(1370, 44)
|
||||
click(690, 258); x('key', 'Down'); x('key', 'Return')
|
||||
click(690, 343); x('key', 'Down'); x('key', 'Return')
|
||||
click(950, 725)
|
||||
assert json.loads(settings.read_text())['theme'] == 'matchday'
|
||||
assert json.loads(settings.read_text())['language'] == 'en'
|
||||
click(1370, 44)
|
||||
click(690, 258); x('key', 'Up'); x('key', 'Return')
|
||||
click(690, 343); x('key', 'Up'); x('key', 'Up'); x('key', 'Return')
|
||||
click(950, 725)
|
||||
assert json.loads(settings.read_text())['theme'] == 'midnight'
|
||||
assert json.loads(settings.read_text())['language'] == 'de'
|
||||
assert tool('editor_info') == before_options
|
||||
# An idle, unfocused form must not continuously render. The
|
||||
# generous one-core CPU budget catches a software-render loop
|
||||
# while allowing timer/MCP polling and slow CI machines.
|
||||
click(700, 153); time.sleep(.5)
|
||||
def cpu_seconds():
|
||||
fields = Path(f'/proc/{app.pid}/stat').read_text().rsplit(')', 1)[1].split()
|
||||
return (int(fields[11]) + int(fields[12])) / os.sysconf('SC_CLK_TCK')
|
||||
before_idle = tool('editor_info')
|
||||
cpu_start, wall_start = cpu_seconds(), time.monotonic()
|
||||
time.sleep(3)
|
||||
cpu_used, wall_used = cpu_seconds() - cpu_start, time.monotonic() - wall_start
|
||||
assert cpu_used < .20 * wall_used, f'Idle CPU exceeded 20% of one core: {cpu_used / wall_used:.1%}'
|
||||
assert tool('editor_info') == before_idle
|
||||
assert 'Syntax error parsing property' not in (root / 'app.log').read_text()
|
||||
print(f'Idle CPU: {cpu_used / wall_used:.1%} of one core.')
|
||||
print('Native edits, comparisons, rules, drill-down, image previews, browser history and idle CPU passed.')
|
||||
except Exception:
|
||||
log.flush()
|
||||
print((root / 'app.log').read_text())
|
||||
|
||||
@@ -45,6 +45,24 @@ SKIP_DIRECTORIES = {".git", "__pycache__", ".cache", "_deps", "node_modules"}
|
||||
# The latter are reviewed against docs/qa/editor-poc/README.md; no game material.
|
||||
# Keep prior reviewed hashes if an asset is intentionally revised in history.
|
||||
PROJECT_ARTWORK = {
|
||||
"docs/qa/editor-navigation/before-options-0.5.3.png": {
|
||||
"493984e53b85c516a3a541ae879fdd18fdc7ec54a4d6478c571865bee15a9b44",
|
||||
},
|
||||
"docs/qa/editor-navigation/dropdown-matchday-de.png": {
|
||||
"594bdce386a91e2ef24fbab72d4910eed0899d8c108087b1cf00f9750e949b58",
|
||||
},
|
||||
"docs/qa/editor-navigation/dropdown-midnight-de.png": {
|
||||
"42cc11138163ce0a030c85fc5cb5c1204dbb7c05cfd7f8ef16cff8f6f6eeb422",
|
||||
},
|
||||
"docs/qa/editor-navigation/dropdown-silver-en.png": {
|
||||
"4ec9bf9a7af979c1c72f5cc6cd1b8a969f579a9680d8afc00837fff71da87a22",
|
||||
},
|
||||
"docs/qa/editor-navigation/history-midnight-de.png": {
|
||||
"7f141a6283ee946e17caa5d82a37503776133090fe86f82f0f9b2180b6444706",
|
||||
},
|
||||
"docs/qa/editor-navigation/options-midnight-de.png": {
|
||||
"3facf3da00290e5d39f0eeb210f657ae1040fce54f3e48e81529875e5d6f3fc9",
|
||||
},
|
||||
'docs/qa/editor-images/before-club-image.png': {
|
||||
'ac57bbbce2b8b7f71dad1d9e94d7b7baf182cb337d3800b5aac7a7f65db456bc',
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user