railroader-setons-special-s.../native/src/d3d11_renderer.h
seton dd1af2ec30 v0.2.3 - MapEnhancer settings panel, opacity controls, right-click recenter
Extends the existing MapEnhancer gear menu integration with a full settings
panel covering the options added by the community fork: marker visibility
toggles, scale sliders for flares, junctions, track lines, and crossings,
and bulk switch reset buttons.

Also adds pan-cancels-follow and right-click to recenter on player toggles,
three independent opacity controls (Window, Map Elements, Map Background),
a per-element hover minimum of 50% for the window chrome so controls stay
reachable at low opacity, and fixes to make the compass and toolbar correctly
respond to their respective sliders. Both surfaces (in-game overlay and OS
popout) maintain parity on all new settings.
2026-06-19 08:32:05 -04:00

67 lines
3.1 KiB
C

#pragma once
#include "popout_window.h"
// Called from exports.cpp (render thread only)
void Renderer_OnDeviceInit(ID3D11Device* device);
void Renderer_OnDeviceShutdown();
// Creates/recreates the swapchain for a window. Safe to call from render thread.
bool Renderer_EnsureSwapchain(PopoutWindow* win);
// Releases swapchain resources. Called from WM_DESTROY on the pump thread.
void Renderer_ReleaseSwapchain(PopoutWindow* win);
// Blits pendingTexture into the swapchain and calls Present. Render thread only.
void Renderer_Present(PopoutWindow* win);
// ---------------------------------------------------------------------------
// In-game overlay (spike): draw a Dear ImGui frame directly into whatever
// render target Unity has bound (the final backbuffer when issued after
// WaitForEndOfFrame). No swapchain, no Present — composites on top of the game.
// All functions below run on Unity's render thread except the *Set* setters,
// which are called from the C# main thread and only touch atomics.
// ---------------------------------------------------------------------------
// Stash a texture whose owning device we lazily init from (mirrors the popout's
// tex->GetDevice() path) when UnityPluginLoad never fired. Call once from C#.
void Overlay_SetDeviceTexture(void* texturePtr);
// Per-frame input snapshot from C# (top-left origin, pixels). wheel in WHEEL_DELTA units.
void Overlay_SetInput(float displayW, float displayH,
float mouseX, float mouseY,
bool lButton, bool rButton, int wheel);
// The Unity map render texture to display inside the in-game ImGui window, plus
// the UV sub-rect (V flipped: v0=1,v1=0 for a Unity RT). Pass nullptr to clear.
void Overlay_SetMapTexture(void* texturePtr, float u0, float v0, float u1, float v1);
// Drains queued in-game map input (image drag/zoom) for C# to forward to the map
// camera. Returns the number of events written (<= maxEvents).
int Overlay_PollInput(InputEvent* out, int maxEvents);
// Size (px) of the map image region last frame, so C# can set the map camera's
// aspect to the window shape (map fills the window, no letterbox bars).
void Overlay_GetMapView(float* outW, float* outH);
// Show/hide the overlay UI.
void Overlay_SetVisible(bool visible);
// True when ImGui wants the mouse (hovering a widget) — C# uses this to swallow input.
bool Overlay_WantsMouse();
// Apply a new theme. Thread-safe: stores data then applies on the render thread at
// next frame start (before NewFrame), so ImGui style is never written from main thread.
// presetIndex is echoed back into the gear menu checkmarks.
void Renderer_SetTheme(const MapThemeData* t, int presetIndex);
// Set the in-game overlay's chrome (window + toolbar + compass) alpha [0.1, 1.0].
void Overlay_SetAlpha(float alpha);
// Set the map image alpha [0.0, 1.0]. Independent of chrome alpha. Thread-safe via atomic.
void Overlay_SetMapAlpha(float alpha);
// Set the map camera clear-colour opacity [0.0, 1.0]. Thread-safe via atomic.
void Overlay_SetMapBgAlpha(float alpha);
// Render the overlay into the currently bound RTV. Render thread only.
void Renderer_PresentOverlay();