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.
This commit is contained in:
Codex committed 2026-10-17 22:36:58 +02:00
1 parent 9bff07828a
commit 8326a23274
10 files changed
+172 -4

No files matched your search

+38
View File
@@ -10,6 +10,7 @@
#include <SDL.h>
#include <algorithm>
#include <array>
#include <chrono>
#include <cstdio>
#include <cstdlib>
@@ -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<bool, 2> 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;
}
+5 -2
View File
@@ -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
+3
View File
@@ -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, {}},
+1 -1
View File
@@ -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);
+13
View File
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include <filesystem>
#include <string>
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
+5 -1
View File
@@ -8,6 +8,7 @@
#include <system_error>
#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 &&