Add read-only image previews and linked asset navigation (by Codex)

This commit is contained in:
Codex committed 2026-10-23 11:03:32 +02:00
1 parent e306c2c4a2
commit f21247a244
12 files changed
+152 -5

No files matched your search

+3
View File
@@ -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; }
+3
View File
@@ -34,6 +34,7 @@ Das vollständige Paket `OpenBMHEditor-0.5.3-<plattform>.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.
+27
View File
@@ -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.
Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

+2
View File
@@ -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"}},
+78 -4
View File
@@ -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 "<img class=\"" + css + "\" src=\"" + renderer_.asset(key) + "\"/>";
return "<img class=\"" + css + "\" src=\"" + renderer_.asset(key) +
"\" data-action=\"image-view\" data-value=\"" + escaped(key) + "\"/>";
}
std::string icon(const std::string &name) {
static const std::map<std::string, std::string> 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<void()> 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 "<div class=\"empty\">" + escaped(t("select_record")) + "</div>";
std::string body = "<div class=\"inspector-head\">";
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 = "<div class=\"image-stage readonly-stage\"><img src=\"" + token +
"\" style=\"width:" + number(raster.width * scale) +
"dp;height:" + number(raster.height * scale) +
"dp;\"/></div><p class=\"form-help image-caption\">" + escaped(caption) +
"</p>";
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();
+24 -1
View File
@@ -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())
+15
View File
@@ -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",
},