Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions runtime/app/panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::mutex> lock(g_requestMutex);
g_requested = true;
g_requestedTab = tab;
}

void Panel::draw()
{
Impl &m = *impl_;
if (!m.ready)
return;
{
std::lock_guard<std::mutex> 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();
Expand Down
5 changes: 5 additions & 0 deletions runtime/include/bozo/app/panel.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#pragma once

#include <functional>
#include <string>

#include <cstdint>

Expand All @@ -28,6 +29,10 @@ namespace bozo::app
void setStateSlot(int slot);
void registerStateTab(std::function<void(int)> save, std::function<void(int)> 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:
Expand Down
Loading