From 1a826e5587c0e9b32f6e057a1c387bb7bc9ffa7b Mon Sep 17 00:00:00 2001 From: Thomas Martin <304581853+boubou666@users.noreply.github.com> Date: Fri, 27 Nov 2026 11:48:34 +0100 Subject: [PATCH] app: requestSettings, the settings window opened on a tab from any thread A port whose game's own menus lead to the settings (Amplitude's PC SETTINGS entry in its Options and pause menus) asks from the game's thread; the panel takes the request at its next draw, as F2 opens it, on the tab named (PS2X_SETTINGS_OPEN's selection). Co-Authored-By: Claude Opus 5.5 --- runtime/app/panel.cpp | 25 +++++++++++++++++++++++++ runtime/include/bozo/app/panel.h | 5 +++++ 2 files changed, 30 insertions(+) diff --git a/runtime/app/panel.cpp b/runtime/app/panel.cpp index 37c3e9c..183b883 100644 --- a/runtime/app/panel.cpp +++ b/runtime/app/panel.cpp @@ -211,11 +211,36 @@ namespace bozo::app } bool Panel::holdsMouse() const { return impl_->ready && impl_->settings; } + namespace + { + // requestSettings: the tab asked for, taken at the panel's next draw. + std::mutex g_requestMutex; + bool g_requested = false; + std::string g_requestedTab; + } + + void requestSettings(const std::string &tab) + { + std::lock_guard lock(g_requestMutex); + g_requested = true; + g_requestedTab = tab; + } + void Panel::draw() { Impl &m = *impl_; if (!m.ready) return; + { + std::lock_guard lock(g_requestMutex); + if (g_requested) + { + g_requested = false; + m.settings = true; + m.focusSettings = true; + m.openTab = g_requestedTab; + } + } ImGui_ImplOpenGL3_NewFrame(); ImGui_ImplSDL3_NewFrame(); ImGui::NewFrame(); diff --git a/runtime/include/bozo/app/panel.h b/runtime/include/bozo/app/panel.h index 5033ef3..b391cd3 100644 --- a/runtime/include/bozo/app/panel.h +++ b/runtime/include/bozo/app/panel.h @@ -13,6 +13,7 @@ #pragma once #include +#include #include @@ -28,6 +29,10 @@ namespace bozo::app void setStateSlot(int slot); void registerStateTab(std::function save, std::function load); + // The settings window opened on `tab` (empty: the tab it was on), from any thread: taken at the panel's next draw. + // For a port whose game's own menus lead to it (Amplitude's PC SETTINGS entry in its Options and pause menus). + void requestSettings(const std::string &tab); + class Panel { public: