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-30 14:20:55 +01:00
1 parent c3704878d6
commit 17ac426039
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;
}