Persist ImGui panel layout to disk; quiet audio set_audio_ring log spam
Layout persistence: re-enable io.IniFilename (was nullptr "for the spike"), anchored to a coop_layout.ini next to the exe so window positions/sizes survive restarts even when Steam launches us under the donor appid (CWD is unreliable). Path is UTF-8 for ImGui's file IO. When a saved layout is restored at startup, suppress the computed-default force so it does not clobber the user's positions; Reset layout (and a fresh install with no .ini) still applies the default. Log spam: the worker thread re-attaches every audio ring every tick (idempotent), and set_audio_ring logged unconditionally, flooding the log. Only log when the ring pointer actually changes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1,12 +1,34 @@
|
||||
#include "imgui_layer.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <imgui.h>
|
||||
#include <imgui_impl_dx11.h>
|
||||
#include <imgui_impl_win32.h>
|
||||
|
||||
#include "coop/tool_paths.hpp"
|
||||
#include "ui/app_chrome.hpp"
|
||||
|
||||
namespace coop
|
||||
{
|
||||
|
||||
namespace
|
||||
{
|
||||
// ImGui's file IO treats IniFilename as UTF-8 (it converts to wide for _wfopen), so
|
||||
// the path must be UTF-8 rather than the system ANSI code page.
|
||||
std::string to_utf8(const std::wstring& w)
|
||||
{
|
||||
if (w.empty())
|
||||
{
|
||||
return {};
|
||||
}
|
||||
const int n = WideCharToMultiByte(CP_UTF8, 0, w.c_str(), static_cast<int>(w.size()), nullptr, 0, nullptr, nullptr);
|
||||
std::string s(static_cast<std::size_t>(n), '\0');
|
||||
WideCharToMultiByte(CP_UTF8, 0, w.c_str(), static_cast<int>(w.size()), s.data(), n, nullptr, nullptr);
|
||||
return s;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
ImGuiLayer::~ImGuiLayer()
|
||||
{
|
||||
if (initialized_)
|
||||
@@ -23,7 +45,15 @@ bool ImGuiLayer::init(HWND hwnd, ID3D11Device* device, ID3D11DeviceContext* cont
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.IniFilename = nullptr; // don't litter the cwd with imgui.ini during the spike
|
||||
// Persist the panel layout next to the executable so window positions/sizes survive
|
||||
// restarts. CWD is unreliable when Steam launches us under the donor appid, so anchor
|
||||
// to the exe directory. If a layout already exists, tell the chrome not to force the
|
||||
// computed default on startup (which would clobber the restored positions).
|
||||
const std::wstring ini_w = exe_directory() + L"coop_layout.ini";
|
||||
const bool had_layout = GetFileAttributesW(ini_w.c_str()) != INVALID_FILE_ATTRIBUTES;
|
||||
ini_path_ = to_utf8(ini_w);
|
||||
io.IniFilename = ini_path_.c_str();
|
||||
set_layout_persisted(had_layout);
|
||||
ImGui::StyleColorsDark();
|
||||
|
||||
if (!ImGui_ImplWin32_Init(hwnd))
|
||||
|
||||
Reference in New Issue
Block a user