RPS UI panel API reference
Header: RPS_UI_Framework/Framework.h. Namespace: rpsui::api::framework.
Version 2.0, found through RPSUI_QueryInterfaceV1. The header is normative for
signatures, sized fields, enum values, and defaults. It registers consumers and
world panels, submits panel poses and reads panel state; every other interface
takes the owner token issued here.
| Function | Contract |
|---|---|
isFrameworkReady | The host can serve panels. Calls made before it returns true may return FrameworkNotReady. |
registerConsumer | Takes a ConsumerRegistration (stable consumerId, displayName) and returns a ConsumerHandle holding ownerToken. A duplicate consumer ID is invalid. |
unregisterConsumer | Removes the consumer and all its panels. If its callbacks may still be running, use Cooperation's safe unregister instead. |
registerPanel | Takes a PanelRegistration and returns a closed panel handle. Refuses another Dear ImGui build with ImGuiBuildMismatch. |
unregisterPanel | Removes one panel of this owner and its active interaction. |
submitPanelPresentation | Opens, moves or closes the panel with a rising sequence and a PanelPose. |
resetPanelLayout | Returns the panel to the pose it was last presented with, at its default width. |
getPanelState | The current pose (including the player's resizing and carrying), pointer hand and resize state. |
pulseHaptic | Sends your own pulse to a controller, strength 0 to 1 scaled by the player's HapticStrength, from any thread. |
Panels
PanelRegistration field | Meaning |
|---|---|
panelId, displayName | Stable identity and label. Panel IDs are global, not owner-local. |
layoutWidth, layoutHeight | Your drawing size in ImGui units (DisplaySize) and the panel's default shape. Any positive size. |
defaultPhysicalWidth, minimumPhysicalWidth, maximumPhysicalWidth | World size in game units. |
sortOrder | Composition order. |
flags | PanelFlag bits; zero is a rectangular opaque resizable panel. Unknown bits are rejected. |
imgui | Your Dear ImGui build, RPSUI_IMGUI_BUILD(). |
setupCallback | Optional. Called once per ImGui context before its first frame. |
drawCallback, userData | Called every frame the panel is open; keep both alive until the panel is unregistered. |
PanelFlag | Effect |
|---|---|
Transparent | The panel has no opaque background. |
FixedSize | The player cannot resize the panel. |
CircularInput | Hit testing uses the inscribed circle (panelContains). |
ConfigNavigation | Opts in to raw stick handoff and grip-back; hold-based wheels leave it unset. |
Movable | The player can carry the panel: grip held on it moves it with the hand, the stick pushes and pulls it, and releasing the grip places it. |
The host's budgets are 256 consumer registrations and 1024 panels, shared across
all mods; a Registry page reports them. Use
default-initialized structures so size and version are correct.
Presenting
The pose's width must be within the registered limits; its height may be any
positive value. The layout is scaled onto the panel on each axis, so a height off
the layout's shape stretches the drawing. Open poses require finite components
and an approximately orthonormal right-handed basis; closing does not require a
valid pose. PanelPresentation::sequence is a submission-order guard; the
sequence in PanelState also rises when the player resizes or carries the panel.
On a ConfigNavigation or Movable panel the grip belongs to the UI while the
pointer is on the panel. A grip press released before the player's hold time
(GripMoveSeconds in RPS_UI.toml) is Back, delivered on the release; on a
Movable panel a longer hold carries the panel instead. The host pulses the
pointing controller when a press makes an ImGui control active and when a carry
starts; pulseHaptic covers presses ImGui does not see.
Resolution
You never choose a texture size. The host gives each panel Sharpness texture
pixels per layout unit at its default width (RPS_UI.toml, 1.5 by default) and
scales that with the panel's size in the world, so text stays equally sharp when
a player enlarges a panel. PanelDrawFrame::pixelWidth and pixelHeight report
the texture's size this frame.
Drawing
The host owns each panel's Dear ImGui context: the DX11 renderer, the font atlas,
the input it feeds and the frame. Your mod only issues ImGui calls from its
drawCallback, in layout units. See Dear ImGui integration
for the build, the callbacks and themes.
Results
rpsui::api::Result in Abi.h declares Ok, InvalidArgument, VersionMismatch,
FrameworkNotReady, CapacityReached, OwnerNotRegistered,
PanelNotRegistered, OwnershipMismatch, InvalidPose, CallbackFailed,
InternalError, ResourceConflict, UnsupportedStage, CallbackBusy,
PanelClosing and ImGuiBuildMismatch, plus the discovery refusals
UnknownInterface, UnsupportedMajor, UnsupportedMinor, and TableTooSmall.
Registration and presentation size or version failures on this interface return
InvalidArgument; requesting an unsupported API version returns a discovery
refusal and no table. An ImGuiBuildMismatch refusal is logged with your DLL,
like an outdated consumer. A mod built against
1.1 is updated with migrating from RPS UI Framework 1.1.
Separate services
Independent input, cooperation/safe teardown and the other interfaces are separate tables, each acquired on its own. This table does not define their availability.
Complete public declarations: RPS_UI_Framework/Abi.h
#pragma once
#include <cstddef>
#include <cstdint>
#include <type_traits>
#define RPSUI_CALL __cdecl
// RPS UI Framework's shared ABI vocabulary. Each interface header carries its
// own kMajor and kMinor; records and tables belong to their interface headers.
#pragma pack(push, 8)
namespace rpsui::api
{
// Layout version of every size/version-tagged record. Interface versions
// are separate and negotiated through discovery.
inline constexpr std::uint32_t kRecordVersion = 1;
enum class Result : std::uint32_t
{
Ok = 0,
InvalidArgument = 1,
VersionMismatch = 2,
FrameworkNotReady = 3,
CapacityReached = 4,
OwnerNotRegistered = 5,
PanelNotRegistered = 6,
OwnershipMismatch = 7,
InvalidPose = 8,
CallbackFailed = 9,
InternalError = 10,
ResourceConflict = 11,
UnsupportedStage = 12,
CallbackBusy = 13,
PanelClosing = 14,
// The consumer's Dear ImGui build differs from the host's (framework::ImGuiBuild).
ImGuiBuildMismatch = 15,
// Discovery.
UnknownInterface = 100,
UnsupportedMajor = 101,
UnsupportedMinor = 102,
TableTooSmall = 103,
};
// Interface IDs are permanent and never reused.
enum class InterfaceId : std::uint32_t
{
Framework = 1,
Cooperation = 2,
FocusedPanel = 3,
Input = 4,
NumberOverlay = 5,
PassivePanel = 6,
Registry = 7,
WorldDraw = 8,
SettingsMenu = 9,
};
static_assert(sizeof(void*) == 8, "RPS UI Framework requires a 64-bit consumer");
static_assert(sizeof(Result) == 4 && sizeof(InterfaceId) == 4);
}
#pragma pack(pop)
Complete public declarations: RPS_UI_Framework/Discovery.h
#pragma once
#include "Abi.h"
// Resolve kQueryExportName from the loaded kModuleName and ask for an interface
// by ID, exact major, minimum minor and minimum table size. A major this RPS UI
// does not serve returns UnsupportedMajor and no table; RPS UI logs the refusal
// with the calling DLL.
// The pre-2.0 exports (RPSUI_RequestApi, RPSUI_RequestCooperationApi,
// RPSUI_RequestFocusedPanelApi, RPSUI_RequestInputApi,
// RPSUI_RequestNumberOverlayApi, RPSUI_RequestPassivePanelApi,
// RPSUI_RequestRegistryApi and RPSUI_RequestWorldDrawApi) only refuse outdated
// consumers; their names are never reused.
#pragma pack(push, 8)
namespace rpsui::api
{
struct InterfaceDescriptorV1
{
std::uint32_t size{ sizeof(InterfaceDescriptorV1) };
InterfaceId interfaceId{};
std::uint32_t major{};
std::uint32_t minor{};
std::uint32_t tableByteSize{};
// Owner tokens come from the Framework interface; a consumer checks it
// negotiated at least this Framework version.
std::uint32_t requiredFrameworkMajor{};
std::uint32_t requiredFrameworkMinor{};
std::uint32_t reserved{};
const void* table{};
};
// Any thread, including before the framework is ready. The descriptor and
// table stay valid for the process lifetime.
using QueryInterfaceV1 = Result(RPSUI_CALL*)(InterfaceId interfaceId,
std::uint32_t exactMajor, std::uint32_t minimumMinor,
std::uint32_t minimumTableBytes,
const InterfaceDescriptorV1** outDescriptor) noexcept;
inline constexpr char kQueryExportName[] = "RPSUI_QueryInterfaceV1";
inline constexpr wchar_t kModuleName[] = L"RPS_UI_Framework.dll";
static_assert(sizeof(InterfaceDescriptorV1) == 40);
}
#pragma pack(pop)
Complete public declarations: RPS_UI_Framework/Client.h
#pragma once
#include "Discovery.h"
#include "Framework.h"
namespace rpsui::api
{
// Consumer-side helper only; it is not part of the DLL ABI. Pass the
// kQueryExportName export resolved from the loaded kModuleName, for example
// reinterpret_cast<QueryInterfaceV1>(GetProcAddress(module, kQueryExportName)).
// Requests exactly the versions and table size this header set declares, so
// every refusal is a real version mismatch. Any thread.
template <class Table>
[[nodiscard]] Result acquire(QueryInterfaceV1 query, const Table*& output) noexcept
{
output = nullptr;
if (!query) return Result::InvalidArgument;
const InterfaceDescriptorV1* descriptor{};
const auto result = query(Table::interfaceId, Table::majorVersion, Table::minorVersion, sizeof(Table), &descriptor);
if (result != Result::Ok) return result;
if (!descriptor || descriptor->size != sizeof(InterfaceDescriptorV1) ||
descriptor->interfaceId != Table::interfaceId || descriptor->major != Table::majorVersion ||
descriptor->minor < Table::minorVersion || descriptor->tableByteSize < sizeof(Table) ||
descriptor->requiredFrameworkMajor != framework::kMajor ||
descriptor->requiredFrameworkMinor > framework::kMinor || !descriptor->table) return Result::VersionMismatch;
output = static_cast<const Table*>(descriptor->table);
return Result::Ok;
}
}
Complete public declarations: RPS_UI_Framework/Framework.h
#pragma once
#include "Abi.h"
// World panels: consumer registration, panel registration and presentation,
// and panel state. Other interfaces take the owner token issued here.
#pragma pack(push, 8)
namespace rpsui::api::framework
{
inline constexpr InterfaceId kInterfaceId = InterfaceId::Framework;
inline constexpr std::uint32_t kMajor = 2;
inline constexpr std::uint32_t kMinor = 0;
enum class PanelFlag : std::uint32_t
{
Transparent = 1u << 0,
FixedSize = 1u << 1,
CircularInput = 1u << 2,
// Opt in to raw stick handoff and grip-back. Hold-based wheels leave this unset.
ConfigNavigation = 1u << 3,
// The player may carry the panel: grip held on it past the player's hold
// time moves it with the hand until released; the stick pushes and pulls it.
Movable = 1u << 4,
};
[[nodiscard]] constexpr bool hasPanelFlag(std::uint32_t flags, PanelFlag flag) noexcept
{
return (flags & static_cast<std::uint32_t>(flag)) != 0;
}
[[nodiscard]] constexpr bool panelContains(std::uint32_t flags, float u, float v) noexcept
{
if (!(u >= 0 && u <= 1 && v >= 0 && v <= 1)) return false;
if (!hasPanelFlag(flags, PanelFlag::CircularInput)) return true;
const float x = u * 2 - 1, y = v * 2 - 1;
return x * x + y * y <= 1;
}
enum class PhysicalHand : std::uint32_t
{
None = 0,
Left = 1,
Right = 2,
};
enum class ResizeHandle : std::uint32_t
{
None = 0,
Left = 1,
Right = 2,
Top = 3,
Bottom = 4,
TopLeft = 5,
TopRight = 6,
BottomLeft = 7,
BottomRight = 8,
};
struct ConsumerRegistration
{
std::uint32_t size{ sizeof(ConsumerRegistration) };
std::uint32_t version{ kRecordVersion };
char consumerId[64]{};
char displayName[96]{};
};
struct ConsumerHandle
{
std::uint32_t size{ sizeof(ConsumerHandle) };
std::uint32_t version{ kRecordVersion };
std::uint64_t ownerToken{ 0 };
};
struct PanelPose
{
float center[3]{};
float right[3]{ 1.0f, 0.0f, 0.0f };
float up[3]{ 0.0f, 0.0f, 1.0f };
float front[3]{ 0.0f, -1.0f, 0.0f };
// Game units. Any positive height: the layout is scaled onto the
// panel on each axis, so a height off the layout's shape stretches it.
float physicalWidth{ 112.5f };
float physicalHeight{ 70.3125f };
};
/*
* RPS UI draws every panel with Dear ImGui. The host owns the panel's
* context, its DX11 renderer, font atlas, input and frame: it feeds the
* pointer, begins the frame, calls the consumer's draw callback and renders
* the result. The consumer only issues ImGui calls, from its own copy of
* Dear ImGui built as RPS_UI_Framework/ImGuiBuild.h describes.
*/
// The consumer's Dear ImGui build (RPSUI_IMGUI_BUILD()). registerPanel
// refuses a panel whose build differs from the host's.
struct ImGuiBuild
{
std::uint32_t size{ sizeof(ImGuiBuild) };
std::uint32_t version{ kRecordVersion };
std::uint32_t versionNum{ 0 };
std::uint32_t wcharSize{ 0 };
std::uint32_t ioSize{ 0 };
std::uint32_t styleSize{ 0 };
std::uint32_t contextSize{ 0 };
std::uint32_t drawListSize{ 0 };
std::uint32_t fontAtlasSize{ 0 };
std::uint32_t fontSize{ 0 };
std::uint32_t textureDataSize{ 0 };
std::uint32_t drawVertSize{ 0 };
std::uint32_t drawIdxSize{ 0 };
std::uint32_t reserved{ 0 };
};
// Dear ImGui's allocator signatures (ImGuiMemAllocFunc, ImGuiMemFreeFunc).
using ImGuiAllocFunction = void* (*)(std::size_t size, void* userData);
using ImGuiFreeFunction = void (*)(void* pointer, void* userData);
// The host's context and allocator. Bind both with RPSUI_IMGUI_BIND before
// any ImGui call; they are valid only for the callback that received them.
struct ImGuiBinding
{
void* context{ nullptr }; // ImGuiContext*
ImGuiAllocFunction alloc{ nullptr };
ImGuiFreeFunction free{ nullptr };
void* allocUserData{ nullptr };
};
// A colour: straight alpha, each channel 0 to 1, as ImGui's ImVec4.
struct ThemeColor
{
float r{ 0.0f };
float g{ 0.0f };
float b{ 0.0f };
float a{ 1.0f };
};
/*
* The player's theme: RPS_UI.toml names it and Themes\<name>.toml holds
* it. Before a panel's setup callback the host sets the context's ImGui
* style from it and adds its four faces, so plain ImGui widgets follow it.
* A consumer draws its own shapes with these roles rather than fixed
* colours. Sizes are in layout units.
*/
struct Theme
{
std::uint32_t size{ sizeof(Theme) };
std::uint32_t version{ kRecordVersion };
// Changes with every theme change. The host then rebuilds every
// panel's context, so setup callbacks run again with the new theme.
std::uint64_t revision{ 0 };
char name[64]{};
ThemeColor background{}; // A panel's body
ThemeColor surface{}; // Idle controls, headers and rails
ThemeColor hover{}; // Under the pointer
ThemeColor pressed{}; // While pressed or dragged
ThemeColor selected{}; // The open page, the current choice
ThemeColor border{}; // Control outlines
ThemeColor divider{}; // Rules and separators
ThemeColor text{};
ThemeColor textMuted{}; // Help, units and secondary text
ThemeColor textDisabled{};
ThemeColor accent{}; // Solid fills of chosen things, links, the cursor
ThemeColor onAccent{}; // Text and marks on an accent fill
ThemeColor focus{}; // The control the stick adjusts
ThemeColor pending{}; // Changed and not yet saved
ThemeColor invalid{}; // Refused values and errors
ThemeColor success{};
ThemeColor scrim{}; // Behind a modal
float fontSize{ 20.0f }; // Body text
float titleFontSize{ 27.0f };
float smallFontSize{ 17.0f }; // Nothing smaller is drawn
float targetHeight{ 40.0f }; // Anything pressable is at least this tall
float padding{ 10.0f };
float spacing{ 8.0f };
float rounding{ 0.0f };
float borderWidth{ 1.0f };
};
// The theme's faces, indexes into PanelSetup::fonts and PanelDrawFrame::fonts.
enum class FontRole : std::uint32_t
{
Interface = 0, // Labels and controls; io.FontDefault
Strong = 1, // Headings and emphasis
Mono = 2, // Numbers, code and console text
Prose = 3, // Long reading text: dialogue, descriptions
};
inline constexpr std::uint32_t kFontRoleCount = 4;
// Once per context, before its first frame: on registration, after a device
// change, after a theme change and after the host rebuilt the context. The
// theme's style and faces are already in place; add your own fonts, adjust
// the style and create textures here. Everything made in the context
// belongs to it and ends with it; contextGeneration tells the consumer when
// that happened.
struct PanelSetup
{
std::uint32_t size{ sizeof(PanelSetup) };
std::uint32_t version{ kRecordVersion };
std::uint64_t panelHandle{ 0 };
std::uint64_t deviceGeneration{ 0 };
std::uint64_t contextGeneration{ 0 };
void* d3dDevice{ nullptr }; // ID3D11Device*, for the consumer's own textures
ImGuiBinding imgui{};
const Theme* theme{ nullptr }; // Valid for the callback
void* fonts[kFontRoleCount]{}; // ImFont* by FontRole, valid for the context
};
/*
* One frame, between the host's NewFrame and Render. Coordinates are in
* layout units (the registration's layout size), the same units as
* ImGui's DisplaySize and MousePos. pixelWidth and pixelHeight are the
* texture's size this frame, which follows the panel's size in the world. The host has
* already fed the pointer position, the primary button and the scroll axes
* to ImGui and turned the software cursor on while the pointer is valid; a
* consumer may change io.MouseDrawCursor during the frame.
*/
struct PanelDrawFrame
{
std::uint32_t size{ sizeof(PanelDrawFrame) };
std::uint32_t version{ kRecordVersion };
std::uint64_t panelHandle{ 0 };
std::uint64_t frameSequence{ 0 };
std::uint64_t deviceGeneration{ 0 };
std::uint64_t contextGeneration{ 0 };
void* d3dDevice{ nullptr }; // ID3D11Device*, for the consumer's own textures
ImGuiBinding imgui{};
const Theme* theme{ nullptr }; // Valid for the callback
void* fonts[kFontRoleCount]{}; // ImFont* by FontRole
std::uint32_t pixelWidth{ 0 };
std::uint32_t pixelHeight{ 0 };
float layoutWidth{ 0.0f };
float layoutHeight{ 0.0f };
float deltaSeconds{ 0.0f };
float pointerX{ 0.0f };
float pointerY{ 0.0f };
float scrollAxisX{ 0.0f };
float scrollAxisY{ 0.0f };
float physicalWidth{ 0.0f };
float physicalHeight{ 0.0f };
PhysicalHand pointerHand{ PhysicalHand::None };
ResizeHandle hoveredResizeHandle{ ResizeHandle::None };
ResizeHandle activeResizeHandle{ ResizeHandle::None };
std::uint8_t pointerValid{ 0 };
std::uint8_t primaryDown{ 0 };
// 1 on the one frame after a Back press: a grip tap released on this panel.
std::uint8_t backPressed{ 0 };
std::uint8_t reservedBytes[1]{};
};
using PanelSetupCallback = void(RPSUI_CALL*)(const PanelSetup* setup, void* userData) noexcept;
using PanelDrawCallback = void(RPSUI_CALL*)(const PanelDrawFrame* frame, void* userData) noexcept;
struct PanelRegistration
{
std::uint32_t size{ sizeof(PanelRegistration) };
std::uint32_t version{ kRecordVersion };
char panelId[64]{};
char displayName[96]{};
// The panel's drawing size in ImGui units (DisplaySize), and its
// default shape. The host picks the texture's resolution from the
// panel's size in the world and the player's sharpness setting, so
// the layout stays the same however large the panel is shown.
float layoutWidth{ 1440.0f };
float layoutHeight{ 900.0f };
float defaultPhysicalWidth{ 112.5f };
float minimumPhysicalWidth{ 72.0f };
float maximumPhysicalWidth{ 180.0f };
std::int32_t sortOrder{ 0 };
std::uint32_t flags{ 0 }; // PanelFlag bits. Zero is a rectangular opaque panel.
std::uint32_t reserved{ 0 };
ImGuiBuild imgui{};
PanelSetupCallback setupCallback{ nullptr }; // Optional.
PanelDrawCallback drawCallback{ nullptr };
void* userData{ nullptr };
};
struct PanelPresentation
{
std::uint32_t size{ sizeof(PanelPresentation) };
std::uint32_t version{ kRecordVersion };
std::uint64_t sequence{ 0 };
PanelPose pose{};
std::uint8_t open{ 0 };
std::uint8_t reservedBytes[7]{};
};
struct PanelState
{
std::uint32_t size{ sizeof(PanelState) };
std::uint32_t version{ kRecordVersion };
std::uint64_t sequence{ 0 };
PanelPose pose{};
PhysicalHand pointerHand{ PhysicalHand::None };
ResizeHandle hoveredResizeHandle{ ResizeHandle::None };
ResizeHandle activeResizeHandle{ ResizeHandle::None };
std::uint8_t open{ 0 };
std::uint8_t pointerValid{ 0 };
std::uint8_t primaryDown{ 0 };
std::uint8_t reservedBytes[1]{};
};
struct Api
{
static constexpr InterfaceId interfaceId = kInterfaceId;
static constexpr std::uint32_t majorVersion = kMajor;
static constexpr std::uint32_t minorVersion = kMinor;
bool(RPSUI_CALL* isFrameworkReady)() noexcept {};
Result(RPSUI_CALL* registerConsumer)(const ConsumerRegistration* registration, ConsumerHandle* outHandle) noexcept {};
Result(RPSUI_CALL* unregisterConsumer)(std::uint64_t ownerToken) noexcept {};
Result(RPSUI_CALL* registerPanel)(std::uint64_t ownerToken, const PanelRegistration* registration,
std::uint64_t* outPanelHandle) noexcept {};
Result(RPSUI_CALL* unregisterPanel)(std::uint64_t ownerToken, std::uint64_t panelHandle) noexcept {};
Result(RPSUI_CALL* submitPanelPresentation)(std::uint64_t ownerToken, std::uint64_t panelHandle,
const PanelPresentation* presentation) noexcept {};
// Puts the panel back at the pose it was last presented with, at its default size.
Result(RPSUI_CALL* resetPanelLayout)(std::uint64_t ownerToken, std::uint64_t panelHandle) noexcept {};
Result(RPSUI_CALL* getPanelState)(std::uint64_t ownerToken, std::uint64_t panelHandle, PanelState* outState) noexcept {};
// A controller pulse, strength 0 to 1, scaled by the player's haptic
// strength. Any thread; sent on the next input tick while the UI has the
// controllers, dropped otherwise.
Result(RPSUI_CALL* pulseHaptic)(std::uint64_t ownerToken, PhysicalHand hand, float strength) noexcept {};
};
static_assert(std::is_standard_layout_v<ConsumerRegistration> && sizeof(ConsumerRegistration) == 168);
static_assert(std::is_standard_layout_v<ConsumerHandle> && sizeof(ConsumerHandle) == 16);
static_assert(std::is_standard_layout_v<PanelPose> && sizeof(PanelPose) == 56);
static_assert(std::is_standard_layout_v<ImGuiBuild> && sizeof(ImGuiBuild) == 56);
static_assert(std::is_standard_layout_v<ImGuiBinding> && sizeof(ImGuiBinding) == 32);
static_assert(std::is_standard_layout_v<ThemeColor> && sizeof(ThemeColor) == 16);
static_assert(std::is_standard_layout_v<Theme> && sizeof(Theme) == 384);
static_assert(std::is_standard_layout_v<PanelSetup> && sizeof(PanelSetup) == 112);
static_assert(std::is_standard_layout_v<PanelDrawFrame> && sizeof(PanelDrawFrame) == 184);
static_assert(std::is_standard_layout_v<PanelRegistration> && sizeof(PanelRegistration) == 280);
static_assert(std::is_standard_layout_v<PanelPresentation> && sizeof(PanelPresentation) == 80);
static_assert(std::is_standard_layout_v<PanelState> && sizeof(PanelState) == 88);
static_assert(std::is_standard_layout_v<Api> && sizeof(Api) == 72);
}
#pragma pack(pop)