Add league-to-squad navigation and preserve Windows CPU dispatch (by Codex)

This commit is contained in:
Codex committed 2026-10-23 10:10:23 +02:00
1 parent 06e846416a
commit e306c2c4a2
7 files changed
+168 -31

No files matched your search

+11 -1
View File
@@ -47,7 +47,17 @@ jobs:
run: |
args=()
if [[ "$RUNNER_OS" == "macOS" ]]; then args+=(-DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0); fi
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DOPENBMH_BUILD_EDITOR=ON -DBMH_DATA= "${args[@]}"
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DOPENBMH_BUILD_EDITOR=ON -DBMH_DATA= "${args[@]}"
- name: Check portable Windows WebP instructions
if: runner.os == 'Windows'
shell: python
run: |
import json, pathlib, re
commands = json.loads(pathlib.Path('build/compile_commands.json').read_text())
simd = [c for c in commands if 'libwebp' in c['file'] and re.search(r'_sse(?:2|41)\.c$', c['file'])]
assert simd, 'No WebP runtime-dispatched SIMD sources found'
assert all(not re.search(r'/arch:AVX', c['command'], re.I) for c in simd), 'WebP SSE paths must run without AVX'
print('WebP SSE paths retain the Windows x64 baseline and runtime CPU detection')
- name: Build editor and synthetic tests
run: cmake --build build --target openbmh_editor launcher_gui_smoke editor_core_tests editor_comparison_tests editor_regulations_tests --parallel 2
- name: Native editor core and MCP tests
+1
View File
@@ -26,6 +26,7 @@ Das vollständige Paket `OpenBMHEditor-0.5.3-<plattform>.zip` entpacken und `Ope
## Bearbeiten
- Links einen Datenbereich auswählen; die Liste lässt sich durchsuchen, filtern, sortieren und seitenweise durchgehen. Rechts Änderungen mit **Anwenden** übernehmen. **Speichern** übernimmt auch die aktuellen Eingaben.
- **Doppelklick** auf ein Land zeigt seine Ligen, auf eine Liga ihre Vereine und auf einen Verein dessen Spieler. Land, Liga und Verein werden als Filter übernommen. Ein einfacher Klick wählt weiterhin den Datensatz zum Bearbeiten aus. Nicht übernommene Eingaben werden vor dem Wechsel abgefragt.
- Länder, Wettbewerbe, Vereine, Spieler, Kader, Stadien und Schiedsrichter lassen sich anlegen und bearbeiten. Referenzierte Datensätze werden erst nach Änderung ihrer Verknüpfungen gelöscht. Vereinswechsel zwischen Ligen aktualisieren auch deren Mitgliederlisten.
- Spielwerte behalten ihre **quellenspezifischen Wertebereiche**. Ein Classic-Wert wird nicht auf eine erfundene 1–10-Skala umgerechnet. Neue Spieler ohne belegte Werte bleiben zunächst unbewertet.
- Kader bleiben vollständig erhalten. Die Schaltfläche **24** schaltet lediglich die Seitengröße um. Spieler lassen sich über das Vereinsfeld verschieben, zum Tausch merken und mit einem anderen Spieler tauschen; die Pfeile ändern ihre Reihenfolge.
+5 -1
View File
@@ -7,9 +7,13 @@ pinned RmlUI Direct3D 11 renderer with automatic WARP software fallback. No
additional graphics runtime download is needed on the supported Windows systems.
Linux/macOS retain their existing OpenGL rendering.
Windows also uses the portable WebP decoder, avoiding illegal AVX instructions
Windows also builds WebP without an AVX requirement, avoiding illegal instructions
when displaying imported club images on older CPUs or virtual machines.
Double-click a country to see its competitions, a league to see its clubs, and
a club to see its players. Destination lists inherit the corresponding filters;
unapplied inspector entries are protected by the existing confirmation dialog.
Windows startup failures now produce a native dialog and a log in
`%LOCALAPPDATA%/OpenBMH/OpenBMHEditor-startup.log`. Console redirection is
retained and headless/MCP errors remain nonmodal. Native GUI startup, screenshots,
+15 -4
View File
@@ -22,10 +22,7 @@ set(SDL2IMAGE_PNG ON CACHE BOOL "" FORCE)
set(SDL2IMAGE_JPG ON CACHE BOOL "" FORCE)
set(SDL2IMAGE_WEBP ON CACHE BOOL "" FORCE)
if(MSVC)
# The pinned WebP build applies /arch:AVX to its SSE2 sources as well.
# Runtime SSE2 detection cannot make those AVX instructions safe on older
# CPUs or virtual machines. Small editor images use the portable decoder.
set(WEBP_ENABLE_SIMD OFF CACHE BOOL "Portable Windows WebP decoding" FORCE)
set(WEBP_ENABLE_SIMD ON CACHE BOOL "Use WebP's runtime CPU selection" FORCE)
endif()
set(SDL2IMAGE_PNG_SAVE OFF CACHE BOOL "" FORCE)
set(SDL2IMAGE_JPG_SAVE OFF CACHE BOOL "" FORCE)
@@ -39,6 +36,20 @@ set(PUGIXML_BUILD_SHARED_AND_STATIC_LIBS OFF CACHE BOOL "" FORCE)
FetchContent_Declare(editor_xml GIT_REPOSITORY https://github.com/zeux/pugixml.git
GIT_TAG v1.15 GIT_SHALLOW TRUE)
FetchContent_MakeAvailable(editor_json editor_http editor_images editor_svg editor_xml)
if(MSVC)
# The pinned WebP CMake propagates /arch:AVX into SSE2 source files, even
# though their runtime gate only checks SSE2. Compile its explicit SSE
# intrinsics at the default x64 baseline, preserving CPU dispatch and all
# upstream sources. Disabling SIMD is broken in this pinned MSVC build.
get_target_property(webp_source_directory webpdsp SOURCE_DIR)
get_target_property(webp_dsp_sources webpdsp SOURCES)
foreach(source IN LISTS webp_dsp_sources)
if(source MATCHES "_sse(2|41)\\.c$")
set_source_files_properties("${source}" DIRECTORY "${webp_source_directory}"
PROPERTIES COMPILE_FLAGS "")
endif()
endforeach()
endif()
file(WRITE "${CMAKE_BINARY_DIR}/editor-dependencies.json" "{\n")
foreach(component editor_json editor_http editor_images editor_svg editor_xml)
file(TO_CMAKE_PATH "${${component}_SOURCE_DIR}" component_path)
+4
View File
@@ -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"}},
{"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"}},
{"drill_clubs", {"Doppelklick: Spieler anzeigen", "Double-click to view players"}},
{"regulations", {"Regelwerk", "Regulations"}},
{"regulations_title", {"Spiel- & Ligaregeln", "Game & league rules"}},
{"subtitle_regulations",
+82 -24
View File
@@ -36,11 +36,15 @@ class Renderer final : public bmh::rml::Renderer {
Session &session;
std::map<std::string, std::pair<std::string, std::string>> memory;
std::map<std::string, std::string> logical;
std::map<std::string, std::string> asset_tokens;
uint64_t serial = 0;
Renderer(Session &s, bmh::rml::Video &video) : bmh::rml::Renderer(video), session(s) {}
std::string asset(const std::string &key) {
if (auto found = asset_tokens.find(key); found != asset_tokens.end())
return found->second;
auto token = "world-image-" + std::to_string(serial++) + ".png";
logical[token] = key;
asset_tokens[key] = token;
return token;
}
std::string bytes(std::string data, const std::string &extension) {
@@ -51,6 +55,7 @@ class Renderer final : public bmh::rml::Renderer {
void clear() {
Rml::ReleaseTextures(this);
logical.clear();
asset_tokens.clear();
memory.clear();
}
Rml::TextureHandle LoadTexture(Rml::Vector2i &dimensions, const Rml::String &source) override {
@@ -375,6 +380,8 @@ class EditorUi final : public Rml::EventListener {
label("page-subtitle", page_ == "roster" ? t("roster_hint")
: page_ == "review" ? t("review_hint")
: t("subtitle_" + page_));
if (page_ == "nations" || page_ == "competitions" || page_ == "clubs")
label("page-subtitle", t("subtitle_" + page_) + " · " + t("drill_" + page_));
label("state", info_.value("dirty", false) ? "* " + t("unsaved") : t("saved"));
html("bottom-actions",
button("undo", t("undo"), "quiet", info_.value("can_undo", false) ? "" : "disabled") +
@@ -441,8 +448,8 @@ class EditorUi final : public Rml::EventListener {
std::string inspector() {
fields_.clear();
if (selected_.empty())
return "<div class=\"inspector\"><div class=\"empty\">" + escaped(t("select_record")) + "</div></div>";
std::string body = "<div class=\"inspector\"><div class=\"inspector-head\">";
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")
body += img(table() == "players" && selected_.contains("appearance") ? "portrait:" + selected_id_
: image_key(selected_),
@@ -550,7 +557,53 @@ class EditorUi final : public Rml::EventListener {
if (page_ != "review")
body += "<div class=\"inspector-actions\">" + button("delete", t("delete"), "danger") +
button("apply", t("apply"), "primary") + "</div>";
return body + "</div>";
return body;
}
void initialize_fields() {
// Native values also preserve JSON textarea contents without escaping.
for (auto &f : fields_) {
set_value(f.id, f.kind == "bool" && f.initial.empty() ? "false" : f.initial);
f.initial = value(f.id);
}
}
void select_record(const std::string &id) {
if (id == selected_id_)
return;
auto record = session_.execute("get", {{"table", table()}, {"id", id}})["record"];
selected_id_ = id;
selected_ = std::move(record);
Rml::ElementList rows;
el("table-scroll")->QuerySelectorAll(rows, ".record");
for (auto *row : rows)
row->SetClass("selected", row->GetAttribute<Rml::String>("data-value", "") == id);
// Keep list elements alive between clicks. Replacing them here would
// cancel RmlUI's native double-click detection on a different row.
html("record-inspector", inspector());
initialize_fields();
}
void browse_related(const std::string &source, const std::string &id) {
if (source != table())
return;
const auto record = session_.execute("get", {{"table", source}, {"id", id}})["record"];
if (source == "competitions" && str(record, "type") != "league")
return;
leave_fields([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")
return;
page_ = source == "nations" ? "competitions" : source == "competitions" ? "clubs" : "players";
nation_ = source == "nations" ? id : str(row, "nation");
league_ = source == "competitions" ? id : source == "clubs" ? str(row, "competition") : "";
team_ = source == "clubs" ? id : "";
fields_.clear();
selected_id_.clear();
search_.clear();
offset_ = 0;
sort_ = "name";
descending_ = false;
needs_refresh_ = true;
});
}
void records() {
if (!info_.value("loaded", false)) {
@@ -572,7 +625,8 @@ class EditorUi final : public Rml::EventListener {
toolbar += "<select id=\"filter-league\">" + choices("competitions", league_, t("all_leagues"), nation_) +
"</select>";
if (table() == "players")
toolbar += "<select id=\"filter-team\">" + choices("clubs", team_, t("all_clubs"), nation_) + "</select>";
toolbar += "<select id=\"filter-team\">" +
choices("clubs", team_, t("all_clubs"), nation_, league_) + "</select>";
if (page_ == "roster")
toolbar += button("view24", "24", roster24_ ? "primary" : "");
html("toolbar", toolbar);
@@ -637,13 +691,11 @@ class EditorUi final : public Rml::EventListener {
html("page-content", "<div class=\"split\"><div class=\"list-panel\"><div "
"class=\"table-header\">" +
columns + "</div><div class=\"table-scroll\" id=\"table-scroll\">" + rows +
"</div></div>" + inspector() + "</div>");
"</div></div><div class=\"inspector\" id=\"record-inspector\">" +
inspector() + "</div></div>");
// RmlUI's textarea parser retains its raw body rather than decoding
// HTML entities. Assign native values after constructing the controls.
for (auto &f : fields_) {
set_value(f.id, f.kind == "bool" && f.initial.empty() ? "false" : f.initial);
f.initial = value(f.id);
}
initialize_fields();
html("pagination",
"<span>" + std::to_string(total_) + " " + escaped(t("records")) +
(roster24_ ? " · " + escaped(t("compatibility24")) : "") + "</span><div class=\"button-row\">" +
@@ -1445,11 +1497,9 @@ class EditorUi final : public Rml::EventListener {
selected_id_.clear();
offset_ = 0;
search_.clear();
if (arg == "comparison" || arg == "regulations") {
nation_.clear();
league_.clear();
team_.clear();
}
nation_.clear();
league_.clear();
team_.clear();
needs_refresh_ = true;
});
else if (action == "regulations-tab") {
@@ -1508,12 +1558,13 @@ class EditorUi final : public Rml::EventListener {
offset_ = 0;
search_.clear();
needs_refresh_ = true;
} else if (action == "select")
leave_fields([this, arg] {
selected_id_ = arg;
needs_refresh_ = true;
});
else if (action == "cancel-modal")
} 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.
if (action.substr(7) == table() && arg != selected_id_)
leave_fields([this, arg] { select_record(arg); });
} else if (action == "cancel-modal")
close_modal();
else if (action == "accept-modal") {
if (modal_accept_) {
@@ -1756,7 +1807,7 @@ class EditorUi final : public Rml::EventListener {
doc_ = context_->LoadDocument(bmh::rml::asset_path(config_.assets / "editor.rml"));
if (!doc_)
throw Error("ui_assets_missing");
for (auto event : {"click", "change", "mousedown", "mouseup", "mousemove"})
for (auto event : {"click", "dblclick", "change", "mousedown", "mouseup", "mousemove"})
doc_->AddEventListener(event, this);
resize();
refresh();
@@ -1799,12 +1850,19 @@ class EditorUi final : public Rml::EventListener {
pending_.emplace_back("image-preview", "");
return;
}
if (type != "click")
if (type != "click" && type != "dblclick")
return;
for (auto *node = target; node; node = node->GetParentNode())
if (node->HasAttribute("data-action") && !node->HasAttribute("disabled")) {
pending_.emplace_back(node->GetAttribute<Rml::String>("data-action", ""),
node->GetAttribute<Rml::String>("data-value", ""));
auto action = node->GetAttribute<Rml::String>("data-action", "");
if (type == "dblclick") {
if (action != "select" ||
(table() != "nations" && table() != "competitions" && table() != "clubs"))
return;
action = "browse:" + table();
} else if (action == "select")
action = "select:" + table();
pending_.emplace_back(action, node->GetAttribute<Rml::String>("data-value", ""));
return;
}
}
+50 -1
View File
@@ -137,7 +137,56 @@ def main():
assert rules['read_only'] is True and len(rules['items']) == 1
assert rules['items'][0]['movement_defined'] is False
assert tool('editor_info') == before_rules
print('Native edit, search, undo/save, sorted comparisons and read-only regulations passed.')
# Two distinct leagues ensure drilling filters rows rather than
# merely opening the first club/player from the whole world.
tool('editor_apply', {'changes': [
{'op': 'create', 'table': 'competitions', 'id': 'comp:second',
'name': 'Zweite Demo-Liga', 'data': {'nation': 'nation:de', 'tier': 2}},
{'op': 'create', 'table': 'competitions', 'id': 'comp:cup',
'name': 'Zzz-Testpokal', 'data': {'nation': 'nation:de', 'type': 'cup'}},
{'op': 'update', 'table': 'clubs', 'id': 'club:south',
'set': {'/competition': 'comp:second'}}]})
tool('editor_save', {'path': str(root / 'world.obw')})
time.sleep(.6)
def double_click(a, b):
before = tool('editor_info')
x('mousemove', '--window', window, a, b, 'click', '--repeat', 2, '--delay', 120, 1)
time.sleep(.4)
assert tool('editor_info') == before, 'Navigation must not mutate the world'
def edit_selected(table, identifier, expected, first=False):
click(1150, 443); x('key', 'ctrl+a'); x('type', '--clearmodifiers', expected)
click(1300, 741)
for _ in range(40):
name = tool('editor_get', {'table': table, 'id': identifier})['record']['name']
if name['first' if first else 'default'] == expected:
break
time.sleep(.05)
else:
raise AssertionError('Double click did not filter the expected destination: ' + identifier)
tool('editor_undo'); time.sleep(.5)
south_player = tool('editor_list', {'table': 'players', 'team': 'club:south',
'sort': 'name', 'limit': 1})['items'][0]['id']
click(100, 264) # Leagues, then the unselected second row.
double_click(350, 385)
edit_selected('clubs', 'club:south', 'Filtered South')
double_click(350, 335) # That club's players, all nationalities.
edit_selected('players', south_player, 'Filtered Player', True)
click(100, 264) # Root navigation clears hidden team filters.
double_click(350, 335)
edit_selected('clubs', 'club:north', 'Filtered North')
click(100, 313) # Double click a club that was not already selected.
double_click(350, 385)
edit_selected('players', south_player, 'Second Club', True)
click(100, 313)
click(1150, 443); x('key', 'ctrl+a'); x('type', '--clearmodifiers', 'Keep Draft')
double_click(350, 385)
x('key', 'Escape'); time.sleep(.2)
click(1300, 741); wait_name('Keep Draft')
tool('editor_undo'); time.sleep(.5)
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.')
except Exception:
log.flush()
print((root / 'app.log').read_text())