diff --git a/assets/editor/theme.rcss b/assets/editor/theme.rcss index 6e9ff17..78f10f6 100644 --- a/assets/editor/theme.rcss +++ b/assets/editor/theme.rcss @@ -264,6 +264,9 @@ footer { height: 57dp; padding: 0 28dp; display: flex; align-items: center; gap: #modal-error { color: var(--danger); font-size: 13dp; margin-top: 10dp; } .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; } +.readonly-stage { height: 500dp; } +.image-caption { margin-top: 12dp; word-break: break-all; } #crop-canvas { position: relative; } #edit-preview { display: block; } #crop-box { position: absolute; border: 2dp var(--crop); background-color: var(--crop-wash); pointer-events: none; } diff --git a/docs/EDITOR.md b/docs/EDITOR.md index 79c0706..fd506a7 100644 --- a/docs/EDITOR.md +++ b/docs/EDITOR.md @@ -34,6 +34,7 @@ Das vollständige Paket `OpenBMHEditor-0.5.3-.zip` entpacken und `Ope - Rückgängig/Wiederholen gilt gemeinsam für native Oberfläche und MCP. Noch nicht angewendete Eingaben werden bei externen Änderungen nicht automatisch ersetzt; eine veraltete Änderung muss nach Aktualisierung erneut geprüft werden. - **Bilder** und die Bildaktionen am Datensatz unterstützen PNG, JPEG, WebP und eigenständige SVG. Vor dem Import: Ausschnitt ziehen oder Werte eingeben, frei drehen, spiegeln. Ein unveränderter Import behält seine Originalbytes. Bearbeitete Rasterbilder werden PNG, SVG bleibt Vektor. Das Original und die Transformationswerte bleiben für erneutes Bearbeiten im Paket. Classic-Porträts werden aus ihren eingefrorenen Rezepten angezeigt; eine Umbenennung ändert das Gesicht nicht. - Bildänderungen am Spieler, Verein oder Wettbewerb erhalten eine eigene Zuordnung. Gemeinsame Platzhalter und Bilder anderer Datensätze bleiben dabei erhalten. Im Bereich **Bilder** kann ein gemeinsam verwendetes Bild bewusst zentral bearbeitet werden. +- Ein Klick auf ein Wappen, Porträt, einen Pokal oder ein Bild in der Liste öffnet eine große, schreibgeschützte **Bildvorschau**. **Zum Asset** öffnet den zugehörigen Eintrag im Bereich **Bilder**. Bei zusammengesetzten Classic-Porträts ohne einzelne Bilddatei führt die Schaltfläche zur allgemeinen Bildübersicht. Das Anschauen verändert keine Daten; beim Wechsel bleiben offene Eingaben durch die Übernehmen-/Verwerfen-Abfrage geschützt. **Speichern** erzeugt ausschließlich `.obw` im Profil **`editor-world-v1`, Format 1.1**. Editorwelten sind **noch nicht im Classic-Spiel startbar**. Die Bezeichnung ist im Editor sichtbar. Unbekannte Erweiterungen, nicht bearbeitete Dokumente, Quellnachweise und Bilder bleiben erhalten. Noch nicht im Formular angebotene Regeln, Kalender- und Finanzdaten werden erhalten, aber nicht als vollständig editierbare Bereiche ausgegeben. @@ -130,6 +131,8 @@ Use **Regulations** to inspect promotion, relegation, playoffs, international qu The editor retains full squads, original image data, source claims and unknown extensions. Its 24-player view does not remove players. Image import offers normalized crop, arbitrary rotation and mirroring; re-editing uses the preserved source. Classic portraits keep their frozen appearance recipe. Unsupported editing areas are preserved rather than replaced. +Click a crest, portrait, trophy or list thumbnail to open a large read-only image preview. **View asset** opens its linked asset record; composed Classic portraits without a single image file lead to the image library. Viewing preserves the world and pending property edits. + 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. diff --git a/docs/qa/editor-images/README.md b/docs/qa/editor-images/README.md new file mode 100644 index 0000000..7ad5364 --- /dev/null +++ b/docs/qa/editor-images/README.md @@ -0,0 +1,27 @@ +# Native read-only image preview + +Editor 0.5.3, captured from the native RmlUI application at 1440×900. +All pictures and records are authored synthetic demo data. No game installation, +real crest, portrait, savegame or personal profile is included. + +| View | Native screenshot | +|---|---| +| Before: small image in the club inspector | [Club inspector](before-club-image.png) | +| After: large read-only preview, Midnight / German | [Midnight](preview-midnight-de.png) | +| Silver / English | [Silver](preview-silver-en.png) | +| Matchday / German | [Matchday](preview-matchday-de.png) | +| Jump to the exact linked image record | [Linked asset](linked-asset.png) | + +Clicking the inspector image or a list thumbnail opens the same viewer. Images +retain their aspect ratio; there are no editing controls. Close, the window's +close button and Escape return to the current form. **View asset** opens the +linked asset, clearing unrelated country/league/team filters. Composed Classic +portraits without a single backing asset offer the general image library. + +`tests/editor_gui_smoke.py` exercises the actual mouse and keyboard path. MCP +observes that opening/closing the preview leaves the world and history unchanged. +The test also preserves a pending property draft, cancels a guarded asset jump, +checks the selected club's exact asset, and opens the different asset from an +unselected row. These checks complement the core, comparison and regulations +tests. The synthetic demo starts unsaved; the asterisk in these captures reflects +that initial state rather than a modification caused by the preview. diff --git a/docs/qa/editor-images/before-club-image.png b/docs/qa/editor-images/before-club-image.png new file mode 100644 index 0000000..7222dba Binary files /dev/null and b/docs/qa/editor-images/before-club-image.png differ diff --git a/docs/qa/editor-images/linked-asset.png b/docs/qa/editor-images/linked-asset.png new file mode 100644 index 0000000..c6631c2 Binary files /dev/null and b/docs/qa/editor-images/linked-asset.png differ diff --git a/docs/qa/editor-images/preview-matchday-de.png b/docs/qa/editor-images/preview-matchday-de.png new file mode 100644 index 0000000..cf84867 Binary files /dev/null and b/docs/qa/editor-images/preview-matchday-de.png differ diff --git a/docs/qa/editor-images/preview-midnight-de.png b/docs/qa/editor-images/preview-midnight-de.png new file mode 100644 index 0000000..4e2e954 Binary files /dev/null and b/docs/qa/editor-images/preview-midnight-de.png differ diff --git a/docs/qa/editor-images/preview-silver-en.png b/docs/qa/editor-images/preview-silver-en.png new file mode 100644 index 0000000..1023ec2 Binary files /dev/null and b/docs/qa/editor-images/preview-silver-en.png differ diff --git a/src/editor/options.cpp b/src/editor/options.cpp index 1323198..c0e817b 100644 --- a/src/editor/options.cpp +++ b/src/editor/options.cpp @@ -415,6 +415,8 @@ std::string tr(const std::string &language, const std::string &key) { {"amateur", {"Amateur", "Amateur"}}, {"image_import", {"Bild importieren", "Import image"}}, {"image_edit", {"Bild bearbeiten", "Edit image"}}, + {"image_view", {"Bildvorschau", "Image preview"}}, + {"view_asset", {"Zum Asset", "View asset"}}, {"image_export", {"PNG exportieren", "Export PNG"}}, {"angle", {"Drehwinkel", "Rotation"}}, {"flip_x", {"Horizontal spiegeln", "Flip horizontally"}}, diff --git a/src/editor/ui.cpp b/src/editor/ui.cpp index e351441..c4b0a49 100644 --- a/src/editor/ui.cpp +++ b/src/editor/ui.cpp @@ -52,6 +52,18 @@ class Renderer final : public bmh::rml::Renderer { memory[token] = {std::move(data), extension}; return token; } + static constexpr const char *view_source = "readonly-image-preview.png"; + void release_view() { + for (const auto &source : Rml::GetTextureSourceList()) + if (utf8(path(source).filename()) == view_source) + Rml::ReleaseTexture(source, this); + memory.erase(view_source); + } + std::string view(std::string data) { + release_view(); + memory[view_source] = {std::move(data), ".png"}; + return view_source; + } void clear() { Rml::ReleaseTextures(this); logical.clear(); @@ -123,7 +135,7 @@ class EditorUi final : public Rml::EventListener { std::string image_bytes_, image_extension_, image_file_, image_key_, image_source_key_; Json image_target_, image_recipe_; double drag_x_ = 0, drag_y_ = 0; - bool dragging_ = false; + bool dragging_ = false, image_view_open_ = false; std::chrono::steady_clock::time_point start_ = std::chrono::steady_clock::now(); std::string t(const std::string &key) const { return tr(options_.language, key); } Rml::Element *el(const std::string &id) const { @@ -161,7 +173,8 @@ class EditorUi final : public Rml::EventListener { return found == lookup_.end() ? id : title(found->second); } std::string img(const std::string &key, const std::string &css) { - return ""; + return ""; } std::string icon(const std::string &name) { static const std::map paths{ @@ -269,11 +282,18 @@ class EditorUi final : public Rml::EventListener { } void close_modal() { el("overlay")->SetProperty("display", "none"); + if (image_view_open_) { + html("modal-content", ""); + renderer_.release_view(); + image_view_open_ = false; + } modal_ = dragging_ = false; modal_accept_ = {}; } void modal(const std::string &title, const std::string &body, const std::string &accept, std::function callback, bool cancel = true, bool wide = false) { + if (image_view_open_) + close_modal(); label("modal-title", title); html("modal-content", body); label("modal-error", ""); @@ -439,7 +459,8 @@ class EditorUi final : public Rml::EventListener { if (selected_["name"].contains("first") || selected_["name"].contains("last")) { field(body, "/name/first", t("first")); field(body, "/name/last", t("last")); - field(body, "/name/known_as", t("known_as")); + if (selected_["name"].contains("known_as")) + field(body, "/name/known_as", t("known_as")); } else field(body, "/name/default", t("name")); } else @@ -450,7 +471,8 @@ class EditorUi final : public Rml::EventListener { if (selected_.empty()) return "
" + escaped(t("select_record")) + "
"; std::string body = "
"; - if (table() == "players" || table() == "clubs" || table() == "competitions" || table() == "assets") + if (table() == "players" || table() == "clubs" || table() == "competitions" || table() == "assets" || + table() == "staff") body += img(table() == "players" && selected_.contains("appearance") ? "portrait:" + selected_id_ : image_key(selected_), "hero-image"); @@ -1360,6 +1382,42 @@ class EditorUi final : public Rml::EventListener { el("crop-canvas")->SetProperty("height", std::to_string(h) + "dp"); crop_box(); } + void view_image(const std::string &key) { + if (image_view_open_) + close_modal(); + std::string asset_key = key; + if (key.starts_with("portrait:")) { + const auto player = + session_.execute("get", {{"table", "players"}, {"id", key.substr(9)}})["record"]; + asset_key = str(player, "photo"); + } + std::string caption; + if (!asset_key.empty()) { + try { + const auto asset = + session_.execute("get", {{"table", "assets"}, {"id", asset_key}})["record"]; + caption = title(asset); + } catch (const Error &error) { + if (error.code != "record_missing") + throw; + asset_key.clear(); + } + } + const auto source = session_.asset_bytes(key); + const auto raster = images::preview(source.first, source.second, Json::object(), 1536); + const double scale = std::min(810.0 / raster.width, 500.0 / raster.height); + const auto token = renderer_.view(images::encode_png(raster)); + const std::string body = "

" + escaped(caption) + + "

"; + modal(t("image_view"), body, t("close"), [this] { close_modal(); }, false, true); + image_view_open_ = true; + html("modal-buttons", button("image-view-asset", t(asset_key.empty() ? "assets" : "view_asset"), "", + "data-value=\"" + escaped(asset_key) + "\"") + + button("accept-modal", t("close"), "primary")); + } void edit_image(bool existing, bool fresh = false) { image_file_.clear(); image_key_ = fresh ? "" : image_key(selected_); @@ -1710,6 +1768,22 @@ class EditorUi final : public Rml::EventListener { {"choice", std::stoi(value("review-choice"))}, {"expected_revision", revision_}}); needs_refresh_ = true; + } else if (action == "image-view") + view_image(arg); + else if (action == "image-view-asset") { + close_modal(); + leave_fields([this, arg] { + page_ = "assets"; + selected_id_ = search_ = arg; + offset_ = 0; + sort_ = "name"; + descending_ = false; + nation_.clear(); + league_.clear(); + team_.clear(); + fields_.clear(); + needs_refresh_ = true; + }); } else if (action == "image-import" || action == "image-edit") { if (has_draft()) { apply_fields(); diff --git a/tests/editor_gui_smoke.py b/tests/editor_gui_smoke.py index 0a10a7a..fb59eec 100644 --- a/tests/editor_gui_smoke.py +++ b/tests/editor_gui_smoke.py @@ -186,7 +186,30 @@ def main(): click(100, 215); double_click(350, 335) # Country -> its competitions. double_click(350, 434) # A cup keeps its own inspector. edit_selected('competitions', 'comp:cup', 'Cup Inspector') - print('Native edit, comparisons, rules, league/club drill-down and draft protection passed.') + # Viewing a linked image is read only and must preserve a + # pending property draft until the user chooses to apply it. + click(100, 313) + before_view = tool('editor_info') + click(1150, 443); x('key', 'ctrl+a'); x('type', '--clearmodifiers', 'Preview Draft') + click(1100, 326) + assert tool('editor_info') == before_view + click(985, 757) # A jump with a pending draft asks before leaving. + assert tool('editor_info') == before_view + x('key', 'Escape'); time.sleep(.2) + click(1300, 741); wait_name('Preview Draft') + tool('editor_undo'); time.sleep(.5) + click(1100, 326); click(985, 757) # Exact linked asset, not the first world row. + edit_selected('assets', 'asset:demo/north', 'Preview Asset') + # A thumbnail on an unselected row previews that row's image. + click(100, 313); click(280, 385); click(985, 757) + edit_selected('assets', 'asset:demo/south', 'Second Preview Asset') + # Missing/composed portraits still open, with a library link + # instead of inventing a single backing asset. + click(100, 361) + 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.') except Exception: log.flush() print((root / 'app.log').read_text()) diff --git a/tools/public_release/check_public_tree.py b/tools/public_release/check_public_tree.py index 811aefe..052e319 100644 --- a/tools/public_release/check_public_tree.py +++ b/tools/public_release/check_public_tree.py @@ -45,6 +45,21 @@ 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-images/before-club-image.png': { + 'ac57bbbce2b8b7f71dad1d9e94d7b7baf182cb337d3800b5aac7a7f65db456bc', + }, + 'docs/qa/editor-images/linked-asset.png': { + '76717df021e0c6db9a4afcab283923a20c2bf47d43f7e111303dca66041d3bf8', + }, + 'docs/qa/editor-images/preview-matchday-de.png': { + 'b7c0fad929fb28d25ef9e104e4ee90e62ab1d6e5ff8746bd0e8805bc2204d410', + }, + 'docs/qa/editor-images/preview-midnight-de.png': { + 'cc0ba1b7a1e4ea21f06fa9eb254a8b523da79bfa495a5068e345651619ab0407', + }, + 'docs/qa/editor-images/preview-silver-en.png': { + '8704055293f58796b92057bc8a0c111b4db8bcaca297e45b7cb8d4bcacdd9a92', + }, "docs/qa/editor-regulations/before-competitions-0.5.1.png": { "cffa594e4d5ee942e086ab24fe7744a53dab4d5083dc1659f5e4b3ebdaee1f0b", },