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: