Skip to main content

First RPS UI consumer

Build and discovery​

set(RPSUI_INCLUDE_DIR "" CACHE PATH "RPS UI Framework include directory (the folder that contains RPS_UI_Framework/)")
if(NOT EXISTS "${RPSUI_INCLUDE_DIR}/RPS_UI_Framework/Framework.h")
message(FATAL_ERROR "Set RPSUI_INCLUDE_DIR to the RPS UI Framework repository's include directory")
endif()
target_include_directories(MyPanelPlugin PRIVATE "${RPSUI_INCLUDE_DIR}")

Point RPSUI_INCLUDE_DIR at the RPS UI Framework repository's include/ folder in your own, uncommitted CMakeUserPresets.json, and do not copy the headers into your project. Use Windows x64. Our own consumers build the headers as C++23. The headers neither link a host DLL import library nor install the UI runtime or Dear ImGui. ROCK is not a requirement for the UI host.

#include <RPS_UI_Framework/Client.h>
#include <RPS_UI_Framework/Framework.h>

const auto module = GetModuleHandleW(rpsui::api::kModuleName);
const auto query = module ? reinterpret_cast<rpsui::api::QueryInterfaceV1>(
GetProcAddress(module, rpsui::api::kQueryExportName)) : nullptr;

const rpsui::api::framework::Api* ui{};
if (rpsui::api::acquire(query, ui) == rpsui::api::Result::Ok && ui->isFrameworkReady()) {
// Register your consumer here.
}

GetModuleHandleW finds an already loaded RPS_UI_Framework.dll; nothing here loads it. acquire resolves through RPSUI_QueryInterfaceV1, requesting exactly the version and table size your headers declare, and sets a table only on Ok. Every function in an acquired table is set. A missing DLL should leave your feature inactive: retry from an appropriate consumer lifecycle point.

Discovery serves an interface when the major matches exactly, the minor is at least the requested one and the table is at least the requested size. A refusal returns UnknownInterface, UnsupportedMajor, UnsupportedMinor or TableTooSmall and no table. RPS UI logs every version refusal once with the calling DLL; the game keeps running. Major 1 is refused, and the pre-2.0 RPSUI_Request* exports return no table and are logged the same way.

Register once with a stable, globally unique consumerId and a display name. Both strings must be nonempty and NUL-terminated within their fixed buffers. Save ownerToken. Registration itself can succeed before rendering is ready.

Register and present a panel​

Register a framework::PanelRegistration with a globally unique panelId, display name, layoutWidth and layoutHeight (your drawing size in ImGui units), physical width limits, imgui = RPSUI_IMGUI_BUILD() and a non-null noexcept drawCallback. The host copies registration metadata but borrows callback code and userData. A registered panel starts closed.

A cooperative panel consumer acquires both the Framework and Cooperation tables, registers, and then presents, reads state, queries neighbours and stops. Supply stable callback code/data, serialize control calls, and explicitly open after your own gesture. Keep the data alive until safe unregistration returns Ok; retry CallbackBusy on a later control tick.

framework::PanelPose describes a world-space panel in game units: center, unit right/up/front basis, and physical width/height. The defaults describe a valid basis, not a useful player-relative location. Derive placement from current provider data and retain no engine pointers. A height off the layout's shape stretches the drawing.

Submit a framework::PanelPresentation on open, deliberate reposition, or close. Zero sequence asks the host to advance its sequence; explicit nonzero sequences must strictly increase. An open submission replaces the host pose and can cancel an active resize. Repeatedly resubmitting your default pose would undo user resizing. Read getPanelState for the host's resolved size and position; the host may separate overlapping panels. resetPanelLayout returns the panel to the pose it was last presented with, at its default width.

Rendering and closing​

The host owns the panel's Dear ImGui context, renders it into the panel's texture and projects it into the two eyes. Your drawCallback starts with RPSUI_IMGUI_BIND(frame->imgui) and issues ImGui calls in layout units. See ImGui integration.

Close by submitting open = 0; keep registration if you will reopen. Close and cleanup must run independently of render delivery: depth or projection failure can prevent callbacks entirely. Clear your own input edges and pending actions when your gameplay lifecycle becomes unavailable.

For permanent logical teardown, unregister the panel or unregister the consumer to remove all its panels. Framework unregistration is not a wait for in-flight callbacks. Keep callback code and userData alive until rendering is externally quiescent. For a nonblocking callback-drain handshake, use the Cooperation interface's safe unregister and retain context while it returns CallbackBusy. This retires UI callback state, not every plugin subsystem. See the lifetime contract.