From 8326a23274ab173b7577f98d7571526f64720163 Mon Sep 17 00:00:00 2001 From: Codex Date: Sat, 17 Oct 2026 22:36:58 +0200 Subject: [PATCH] Fix English desktop mapping and host file input issues (by Codex) Correct setup sprites, balance colour and shortcut controls; restore native filename focus, normalize displayed directory separators and guard setup mouse releases. Refs #7, #8, #9, #10. --- CMakeLists.txt | 11 ++++++ docs/release/0.1/RELEASE_NOTES.md | 20 ++++++++++ src/app/main.cpp | 38 +++++++++++++++++++ src/formats/executable_layout.hpp | 7 +++- src/launch/fltd_map.inc | 3 ++ src/launch/game_data.cpp | 2 +- src/ui/host_path.hpp | 13 +++++++ src/ui/save_load.cpp | 6 ++- tests/fltd_translation_unit_tests.cpp | 51 ++++++++++++++++++++++++++ tests/host_path_display_unit_tests.cpp | 25 +++++++++++++ 10 files changed, 172 insertions(+), 4 deletions(-) create mode 100644 src/ui/host_path.hpp create mode 100644 tests/fltd_translation_unit_tests.cpp create mode 100644 tests/host_path_display_unit_tests.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 88ffb94..a3caed7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1070,6 +1070,17 @@ if(MSVC) endif() add_test(NAME launch_unit_tests COMMAND launch_unit_tests) +add_executable(fltd_translation_unit_tests tests/fltd_translation_unit_tests.cpp) +target_link_libraries(fltd_translation_unit_tests PRIVATE bmhlaunch) +add_test(NAME fltd_translation_unit_tests COMMAND fltd_translation_unit_tests) + +add_executable(host_path_display_unit_tests tests/host_path_display_unit_tests.cpp) +target_include_directories(host_path_display_unit_tests PRIVATE src) +if(MSVC) + target_compile_options(host_path_display_unit_tests PRIVATE /utf-8) +endif() +add_test(NAME host_path_display_unit_tests COMMAND host_path_display_unit_tests) + add_executable(fixture_table_tests tests/fixture_table_tests.cpp) target_link_libraries(fixture_table_tests PRIVATE bmhcore) add_test(NAME fixture_table_unit_tests COMMAND fixture_table_tests) diff --git a/docs/release/0.1/RELEASE_NOTES.md b/docs/release/0.1/RELEASE_NOTES.md index 0f236f5..883e926 100644 --- a/docs/release/0.1/RELEASE_NOTES.md +++ b/docs/release/0.1/RELEASE_NOTES.md @@ -2,6 +2,26 @@ OpenBMH reconstructs the Bundesliga Manager Hattrick engine in C++20. The graphical client uses SDL2; the console provides command batches and local manager-client transports over the same career session. This release needs a supported game installation supplied by the player. No original executable, artwork, music, text database, manual or saved game is included. +## Unreleased corrections + +- Football Limited uses the correct enabled/disabled setup sprites, positive + balance colour and outside controls of the desktop shortcut bar ([#7](https://github.com/Weyoune/openbmh/issues/7)). + Its cached data is regenerated automatically for the corrected mapping. +- Filename dialogs reacquire the native SDL text editor on entry and window + focus, including the live settings dialog. macOS acceptance remains human QA + ([#8](https://github.com/Weyoune/openbmh/issues/8)). +- Save-directory labels use portable `/` separators, avoiding the German bitmap + font's `Ö` glyph at the backslash position on Windows ([#9](https://github.com/Weyoune/openbmh/issues/9)). +- Setup ignores mouse releases without a matching press on that screen, so + window activation cannot toggle the initial league/national-team selection + through that input path ([#10](https://github.com/Weyoune/openbmh/issues/10)). +- Source builds include the standalone [OBW installation converter](../../formats/obw/import.md). + It produces intermediate database conversions; game integration remains + planned for 0.2. + +These changes require a build from the updated source. The tagged 0.1.2 package +does not contain these subsequent corrections. + ## Changes in 0.1.2 - The environment menu shows all six original artwork panels: three youth teams, diff --git a/src/app/main.cpp b/src/app/main.cpp index ae6a067..9c2ff29 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -74,6 +75,18 @@ static void show_start_error(const std::string& text) { SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "OpenBMH", text.c_str(), nullptr); } +// Reattach the native editor when an in-game filename field takes focus. Cocoa +// owns a field-editor responder in addition to SDL's TEXTINPUT enable flag. +static void focus_filename_input(SDL_Renderer* renderer) { + int left, top, right, bottom; + SDL_RenderLogicalToWindow(renderer, 106, 209, &left, &top); + SDL_RenderLogicalToWindow(renderer, 262, 219, &right, &bottom); + const SDL_Rect field{left, top, std::max(1, right - left), std::max(1, bottom - top)}; + SDL_StopTextInput(); + SDL_SetTextInputRect(&field); + SDL_StartTextInput(); +} + #ifdef _WIN32 // The game is a Windows GUI program (no console window on double-click). Started from a // console, it writes --version, --help and start errors there (kernel32 AttachConsole). @@ -2614,6 +2627,7 @@ int main(int argc, char** argv) { SDL_RenderPresent(renderer); }; render_file(); + focus_filename_input(renderer); bool finished = false; while (running && !finished) { SDL_Event file_input; @@ -3575,7 +3589,12 @@ int main(int argc, char** argv) { } }; SDL_StartTextInput(); + bool filename_input_active = false; + std::array setup_button_down{}; while (running) { + const bool filename_open = flow.screen_name() == "save_load"; + if (filename_open && !filename_input_active) focus_filename_input(renderer); + filename_input_active = filename_open; if(timed_notice_presented_at && flow.timed_notice_open() && SDL_GetTicks64()-*timed_notice_presented_at>=70*3*20) handle(flow.expire_timed_notice()); @@ -3587,6 +3606,25 @@ int main(int argc, char** argv) { running = false; break; } + if (e.type == SDL_WINDOWEVENT) { + if (e.window.event == SDL_WINDOWEVENT_FOCUS_LOST) setup_button_down.fill(false); + if (e.window.event == SDL_WINDOWEVENT_FOCUS_GAINED) { + if (flow.screen_name() == "save_load") focus_filename_input(renderer); + else SDL_StartTextInput(); + } + } + // A native picker/window activation can leave an unmatched UP. + // Only a press which began on setup may toggle its options. + if ((e.type == SDL_MOUSEBUTTONDOWN || e.type == SDL_MOUSEBUTTONUP) && + (e.button.button == SDL_BUTTON_LEFT || e.button.button == SDL_BUTTON_RIGHT)) { + const size_t button = e.button.button == SDL_BUTTON_LEFT ? 0 : 1; + if (e.type == SDL_MOUSEBUTTONDOWN) setup_button_down[button] = flow.screen_name() == "setup"; + else { + const bool owned = setup_button_down[button]; + setup_button_down[button] = false; + if (flow.screen_name() == "setup" && !owned) continue; + } + } if(e.type==SDL_MOUSEBUTTONUP&&timed_notice_release&&e.button.button==*timed_notice_release) { timed_notice_release.reset();continue; } diff --git a/src/formats/executable_layout.hpp b/src/formats/executable_layout.hpp index 7d6b398..9e53beb 100644 --- a/src/formats/executable_layout.hpp +++ b/src/formats/executable_layout.hpp @@ -764,7 +764,7 @@ inline constexpr auto EnglishLayoutTranslation156 = 0x6e08c; inline constexpr auto EnglishLayoutTranslation157 = 0x6e094; inline constexpr auto EnglishLayoutTranslation158 = 0x6e0b8; inline constexpr auto EnglishLayoutTranslation159 = 0x6e0bb; -inline constexpr auto EnglishLayoutTranslation16 = 0x6be4f; +inline constexpr auto EnglishLayoutTranslation16 = 0x6be50; inline constexpr auto EnglishLayoutTranslation160 = 0x6e0d8; inline constexpr auto EnglishLayoutTranslation161 = 0x6e110; inline constexpr auto EnglishLayoutTranslation162 = 0x6e11c; @@ -986,7 +986,7 @@ inline constexpr auto EnglishLayoutTranslation7 = 0x6be0c; inline constexpr auto EnglishLayoutTranslation70 = 0x6d270; inline constexpr auto EnglishLayoutTranslation71 = 0x6d272; inline constexpr auto EnglishLayoutTranslation72 = 0x6d274; -inline constexpr auto EnglishLayoutTranslation73 = 0x6d29c; +inline constexpr auto EnglishLayoutTranslation73 = 0x6d29d; inline constexpr auto EnglishLayoutTranslation74 = 0x6d3b4; inline constexpr auto EnglishLayoutTranslation75 = 0x6d404; inline constexpr auto EnglishLayoutTranslation76 = 0x6d408; @@ -1972,4 +1972,7 @@ inline constexpr auto EnglishFourTeamFixtureTable = 0x6eea0; inline constexpr auto EnglishSixTeamFixtureTable = 0x6eed4; inline constexpr auto EnglishTwelveTeamFixtureTable = 0x6f0bc; inline constexpr auto EnglishTwentyTeamFixtureTable = 0x6ee40; +inline constexpr auto EnglishDesktopBinSourceX = 0x6e180; +inline constexpr auto EnglishDesktopBinSourceY = 0x6e182; +inline constexpr auto EnglishDesktopSocketSourceX = 0x6e184; } // namespace bmh::layout diff --git a/src/launch/fltd_map.inc b/src/launch/fltd_map.inc index 572856f..74ed650 100644 --- a/src/launch/fltd_map.inc +++ b/src/launch/fltd_map.inc @@ -96,6 +96,9 @@ {::bmh::layout::TeamStatistics_Render_ExecutableField, 2, Kind::copy, ::bmh::layout::EnglishLayoutTranslation72, {}}, {::bmh::layout::DeskDrawers_Curve_ExecutableField, 24, Kind::copy, ::bmh::layout::EnglishLayoutTranslation160, {}}, {::bmh::layout::DeskState_FormatError_RuntimeField, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation161, {}}, + {::bmh::layout::Desktop_Render_RuntimeField, 2, Kind::copy, ::bmh::layout::EnglishDesktopBinSourceX, {}}, + {::bmh::layout::Desktop_Render_RuntimeField2, 2, Kind::copy, ::bmh::layout::EnglishDesktopBinSourceY, {}}, + {::bmh::layout::Desktop_Render_RuntimeField3, 2, Kind::copy, ::bmh::layout::EnglishDesktopSocketSourceX, {}}, {::bmh::layout::Tactics_DrawSetting_RuntimeField, 4, Kind::copy, ::bmh::layout::EnglishLayoutTranslation224, {}}, {::bmh::layout::Tactics_DrawSetting_RuntimeField2, 1, Kind::copy, ::bmh::layout::EnglishLayoutTranslation225, {}}, {::bmh::layout::Tactics_DrawSetting_RuntimeField3, 7, Kind::copy, ::bmh::layout::EnglishLayoutTranslation226, {}}, diff --git a/src/launch/game_data.cpp b/src/launch/game_data.cpp index 199b631..df203b7 100644 --- a/src/launch/game_data.cpp +++ b/src/launch/game_data.cpp @@ -379,7 +379,7 @@ ResolvedGame resolve_game(const fs::path& input, const fs::path& cache) { const fs::path marker = prepared / ".openbmh-english"; // the version of the translation (launch/fltd.cpp, fltd_map.inc): a cache built // by another version is built again - constexpr const char* kTranslation = "english translation 12"; // 12: contract warning ContractExpiryWarningText; 11: statistics windows, graph labels/count classes, streaks and national-badge banks + constexpr const char* kTranslation = "english translation 13"; // 13: setup toggle rows, positive balance colour and desktop bar controls std::string built; { std::ifstream in(marker); diff --git a/src/ui/host_path.hpp b/src/ui/host_path.hpp new file mode 100644 index 0000000..05f4dee --- /dev/null +++ b/src/ui/host_path.hpp @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: GPL-3.0-only +#pragma once + +#include +#include + +namespace bmh::ui { +// Host paths use portable separators: the legacy font's backslash glyph is Ö. +inline std::string save_directory_label(const std::filesystem::path& directory) { + const auto value = directory.generic_u8string(); + return std::string(value.begin(), value.end()); +} +} // namespace bmh::ui diff --git a/src/ui/save_load.cpp b/src/ui/save_load.cpp index 96b6e08..e11a1c6 100644 --- a/src/ui/save_load.cpp +++ b/src/ui/save_load.cpp @@ -8,6 +8,7 @@ #include #include "ui/manager.hpp" +#include "ui/host_path.hpp" #include "ui/setup.hpp" #include "formats/fbm.hpp" @@ -124,7 +125,10 @@ Image SaveLoadScreen::render() const { button(out, field_x, directory_y, field_width); button(out, field_x, filename_y, field_width); - const auto directory_label = original_to_utf8(text_at(texts_, ::bmh::layout::SaveLoad_Render_TextPointer3)) + path_to_utf8(directory_); + // ISO 646-DE uses the backslash code point for Ö. Generic separators retain + // a valid host path on Windows without displaying that unrelated glyph. + const auto directory_label = original_to_utf8(text_at(texts_, ::bmh::layout::SaveLoad_Render_TextPointer3)) + + save_directory_label(directory_); text(out, 55, 203, directory_label, 0x6c, 140, footer_font_, true); text(out, 55, 216, original_to_utf8(text_at(texts_, ::bmh::layout::SaveLoad_Render_TextPointer4)), 0x6c, 50, footer_font_, true); const std::string displayed_filename = mode_ == SaveLoadMode::load && selected_ >= 0 && diff --git a/tests/fltd_translation_unit_tests.cpp b/tests/fltd_translation_unit_tests.cpp new file mode 100644 index 0000000..e8db50d --- /dev/null +++ b/tests/fltd_translation_unit_tests.cpp @@ -0,0 +1,51 @@ +// SPDX-License-Identifier: GPL-3.0-only +#include "formats/executable_layout.hpp" +#include "launch/fltd.hpp" + +#include +#include +#include +#include + +int main() { + using namespace bmh; + std::filesystem::path root; + try { + root = std::filesystem::temp_directory_path() / ("openbmh-fltd-map-" + + std::to_string(std::chrono::steady_clock::now().time_since_epoch().count())); + std::filesystem::create_directory(root); + // Authored X-32-shaped data: only tested source slots have nonzero bytes. + Bytes source(507925); + source[0] = 'M'; source[1] = 'Z'; + const auto put = [&](uint32_t address, uint8_t value) { source.at(address + 0x496d) = value; }; + const auto check = [](bool value, const char* message) { if (!value) throw std::runtime_error(message); }; + const uint8_t toggle_rows[] = {3, 7, 11, 13, 17, 19}; + put(layout::EnglishLayoutTranslation16 - 1, 99); // alignment padding is not a toggle row + for (uint32_t i = 0; i < 6; ++i) put(layout::EnglishLayoutTranslation16 + i, toggle_rows[i]); + put(layout::EnglishLayoutTranslation73 - 1, 0xfb); // negative colour precedes positive colour + put(layout::EnglishLayoutTranslation73, 0x47); + for (uint32_t i = 0; i < 2; ++i) { + put(layout::EnglishDesktopBinSourceX + i, uint8_t(10 + i)); + put(layout::EnglishDesktopBinSourceY + i, uint8_t(20 + i)); + put(layout::EnglishDesktopSocketSourceX + i, uint8_t(30 + i)); + } + const auto path = root / "FLTD.EXE"; + { std::ofstream out(path, std::ios::binary); out.write(reinterpret_cast(source.data()), std::streamsize(source.size())); } + const auto image = launch::translate_fltd(path); + for (uint32_t i = 0; i < 6; ++i) + check(image.u8(layout::Setup_FormatError_RuntimeField8 + i) == toggle_rows[i], "toggle mapping includes alignment padding"); + check(image.u8(layout::Desktop_Copy_TextPointer) == 0xfb, "negative balance colour"); + check(image.u8(layout::Desktop_Copy_TextPointer + 1) == 0x47, "positive balance must use the next source byte"); + for (uint32_t i = 0; i < 2; ++i) { + check(image.u8(layout::Desktop_Render_RuntimeField + i) == 10 + i, "bin source x"); + check(image.u8(layout::Desktop_Render_RuntimeField2 + i) == 20 + i, "bin source y"); + check(image.u8(layout::Desktop_Render_RuntimeField3 + i) == 30 + i, "socket source x"); + } + std::filesystem::remove_all(root); + std::cout << "FLTD setup, colour and desktop-control mappings passed\n"; + return 0; + } catch (const std::exception& error) { + if (!root.empty()) { std::error_code ec; std::filesystem::remove_all(root, ec); } + std::cerr << error.what() << '\n'; return 1; + } +} diff --git a/tests/host_path_display_unit_tests.cpp b/tests/host_path_display_unit_tests.cpp new file mode 100644 index 0000000..7a78c5f --- /dev/null +++ b/tests/host_path_display_unit_tests.cpp @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: GPL-3.0-only +#include "ui/host_path.hpp" + +#include +#include + +int main() { + try { + // make_preferred produces actual backslashes on Windows. No installed + // game assets or existing directory are needed for this native test. + auto native = std::filesystem::path(u8"C:/Example/Profile/Save Games").make_preferred(); + const auto label = bmh::ui::save_directory_label(native); + if (label != "C:/Example/Profile/Save Games" || label.find('\\') != std::string::npos) + throw std::runtime_error("native path separators leak into the ISO 646-DE label"); + if (std::filesystem::path(std::u8string(label.begin(), label.end())) != native) + throw std::runtime_error("displayed path does not identify the original host path"); + native = std::filesystem::path(u8"C:/Example/Büro/Spielstände").make_preferred(); + if (bmh::ui::save_directory_label(native) != "C:/Example/Büro/Spielstände") + throw std::runtime_error("Unicode host path changed during separator normalization"); + std::cout << "Host path labels preserve Unicode and portable separators\n"; + return 0; + } catch (const std::exception& error) { + std::cerr << error.what() << '\n'; return 1; + } +}