#pragma once #define WIN32_LEAN_AND_MEAN #include #include #include #include #include #include "input_queue.h" struct PopoutWindow { HWND hwnd = nullptr; HWND contentHwnd = nullptr; // D3D11 swapchain target IDXGISwapChain* swapChain = nullptr; ID3D11RenderTargetView* rtv = nullptr; // Message-pump thread that owns hwnd. Kept open for the window's lifetime so // DestroyPopoutWindow can join it before freeing this struct (the pump thread // touches `this` while processing WM_DESTROY). HANDLE pumpThread = nullptr; // Swapchain dimensions — content area only (no status bar gap any more; // the ImGui toolbar is an overlay rendered into the same swapchain). std::atomic width {800}; std::atomic height {600}; // Texture + UV rect written by RRPOPOUT_SetFrameTexture on the main thread, // read by Renderer_Present on the render thread. std::atomic pendingTexture {nullptr}; std::atomic srcU0 {0.f}, srcV0 {0.f}; std::atomic srcU1 {1.f}, srcV1 {1.f}; std::atomic resizing {false}; std::atomic destroyRequested {false}; std::atomic alive {true}; InputQueue inputQueue; // ----------------------------------------------------------------------- // ImGui input state // Written by the Win32 message pump thread; consumed by the render thread. // ----------------------------------------------------------------------- std::atomic imMouseX {-1.f}; std::atomic imMouseY {-1.f}; std::atomic imLButton {false}; std::atomic imRButton {false}; // Wheel accumulator in raw WHEEL_DELTA units (120 per notch). // fetch_add on message pump; exchange(0) on render thread. std::atomic imWheelRaw {0}; // Written by render thread after each ImGui frame. // When true, PollInputEvents suppresses mouse events so they don't reach Unity. std::atomic imWantMouse {false}; // ----------------------------------------------------------------------- // Status bar label (UTF-8), shown in the ImGui toolbar. // Written by RRPOPOUT_SetStatusText (main thread), read by render thread. // ----------------------------------------------------------------------- char imStatusText[256]; std::mutex imStatusMutex; // ----------------------------------------------------------------------- // Dynamic menu lists (UTF-8 labels), set by RRPOPOUT_SetLocoList / // RRPOPOUT_SetLocationList from the C# side every few seconds. // Read by the render thread inside the ImGui settings menu. // ----------------------------------------------------------------------- struct ImMenuItem { char label[128]; }; std::vector imLocoList; std::mutex imLocoMutex; std::vector imLocationList; std::mutex imLocationMutex; // ----------------------------------------------------------------------- // Map rotation + ME flag (C# → render thread via exports) // ----------------------------------------------------------------------- std::atomic imMapRotationDeg {0.f}; std::atomic imMapZoom {500.f}; std::atomic imMapSyncPlayer {false}; std::atomic imMapEnhancerInstalled{false}; std::atomic imFollowPlayer {false}; std::atomic imAlwaysOnTop {false}; // Loaded geometry from the save file — consumed by MessagePumpThread before CreateWindowExW. std::atomic lastWinX {-1}, lastWinY {-1}; std::atomic lastWinW {900}, lastWinH {700}; PopoutWindow() { // Status starts empty (filled live with zoom/coords). Avoids a default label // that would be redundant with the window title bar and would render any // non-ASCII glyph as '?' in ImGui's default font. imStatusText[0] = '\0'; } };