CMiriGraphicsScreenStack
Runtime owner of the live game-UI overlays. Scans a World for MiriGraphicsComponents, hosts code-driven Push/Pop screens next to them, instantiates each visible one from its .ui asset, composites them (ZOrder-sorted) into a single overlay the host mounts into its Miri root, re-resolves data bindings every Tick, routes widget events to the host's event sink and drives directional (gamepad/keyboard) focus navigation.
- Module
- MiriGraphics
- Header
#include "MiriGraphics/CMiriGraphicsScreenStack.h"- Namespace
Mowo
Type aliases
| Alias | Description |
|---|---|
using FWorldQuadSink = std::function<void(const FMiriGraphicsWorldQuad&)> | The true-3D path: for every visible worldSpace UIWorldWidgetComponent, (re-)renders its tree into an offscreen texture at a distance-driven LOD resolution — only when the widget is dirty or its LOD bucket moved, so an idle nameplate never re-renders — computes its billboard/oriented world quad, and hands each quad to sink for the host to submit to the scene renderer. Widgets with worldSpace = false are skipped here (drive them through SyncWorldWidgets instead). No-ops without a world-widget renderer. |
using FPointerSink = std::function<void(EMiriGraphicsPointerOp op, const Miri::MiriVec2& position)> | |
using FBackHandler = std::function<bool()> |
Constructors
| Signature | Name | Description |
|---|---|---|
CMiriGraphicsScreenStack() | CMiriGraphicsScreenStack | |
~CMiriGraphicsScreenStack() | ~CMiriGraphicsScreenStack | |
CMiriGraphicsScreenStack(const CMiriGraphicsScreenStack&) = delete | CMiriGraphicsScreenStack |
Public functions
| Returns | Name | Description |
|---|---|---|
CMiriGraphicsScreenStack& | operator= | |
void | SetPathResolver | Resolves a serialized asset path ("Assets/UI/x.ui") to something LoadFromFile can open. |
void | SetFocusSink | Where directional nav sends the newly focused widget (host wires this to its Miri input processor's SetFocus). |
void | SetBindingResolver | Supplies the current value for a widget data-binding source. |
void | SetEventSink | Receives (widgetName, eventName, action) for every authored widget event that fires. |
void | InstallVfsPathResolver | Convenience installers so every host mounts identically. |
void | InstallBridgeFocusSink | |
void | InstallWorldBindingResolver | |
void | EnableHotReload | Watches every loaded .ui file and rebuilds its screens on save. |
uint32_t | LoadLocalization | Loads <rootDir>/<locale>/*.txt string tables (key=value lines, file stem = namespace) into Miri's CTextLocalizationManager and makes the locale current, so authored text_key props resolve through CText::FromKey. |
bool | SetProjectTheme | Theme every screen without its own theme: resolves colour tokens against. |
const FMiriGraphicsTheme& | GetActiveTheme | |
void | SetSafeZoneInsets | Title-safe insets as a fraction of each axis, applied by every screen's root canvas (the designer's Safe Area overlay draws the same box). |
void | SetSafeInsets | Per-side insets for THIS stack only (one split-screen viewport, one PIE window). |
void | ClearSafeInsets | |
void | SyncFromWorld | |
void | SyncWorldWidgets | Places every visible UIWorldWidgetComponent's tree at its entity's projected screen position. |
void | SyncWorldWidgets3D | |
void | MarkWorldWidgetDirty | Marks a world widget's offscreen texture stale so the next SyncWorldWidgets3D re-renders it. |
void | RecordPendingWorldWidgets | |
FMiriGraphicsWorldHit | HitTestWorldWidgets | Ray-vs-quad hit test against the interactive world-widget quads resolved by the last SyncWorldWidgets3D, nearest hit first. |
bool | RouteWorldWidgetClick | Ray-picks the nearest interactive world widget and dispatches a synthetic left click (button down + up) to the widget under the mapped local point, exactly as if the user had clicked that pixel of the offscreen tree. |
void | Clear | |
int32_t | PushScreen | Code-driven screens (pause menu, main menu, loading). |
bool | PopScreen | |
bool | PopTopScreen | |
int32_t | PushScreenOnLayer | Layer-addressed push: the layer picks the z band and whether the screen is modal ("game", "menu", "modal", "toast" — see FMiriGraphicsScreenLayers). |
int32_t | PopLayer | |
int32_t | CountOnLayer | |
bool | IsScreenMounted | |
std::string | GetScreenPath | |
void | SetScreenBackHandler | Back for one screen instance; runs before the global handler when that screen is the top code-driven one. |
bool | AttachViewModel | The per-instance state of a pushed screen: "self.<field>" bindings read it, so two copies of one asset hold separate values. |
std::shared_ptr<FMiriGraphicsViewModel> | GetViewModel | |
int32_t | PushScreenWithViewModel | |
bool | SetWidgetTextOnScreen | Handle-addressed twins of the path-addressed setters above: they reach the instance, not the first screen that happens to share the asset. |
Miri::TSharedPtr<Miri::MWidget> | FindNamedOnScreen | |
bool | SetWidgetVisibleOnScreen | |
bool | SetWidgetProgressOnScreen | |
bool | HasModalScreen | |
int32_t | PushedCount | |
bool | PlayAnimation | Timeline playback on a mounted screen (world-scanned or pushed), addressed by its asset path. |
bool | PlayAnimation | |
bool | StopAnimation | |
void | StopAllAnimations | |
bool | IsAnimationPlaying | |
bool | DispatchAction | The built-in event-action vocabulary: "PlayAnim:Name", "PlayAnimReverse:Name", "StopAnim:Name". |
bool | DispatchVisualScriptAction | |
bool | SetWidgetText | |
bool | SetWidgetVisible | |
bool | SetWidgetProgress | |
Miri::MVideoPlayer* | FindVideoPlayer | The VideoPlayer node under a name (empty screen path searches every screen), or null when the name is not a video — MUIStatics' seam. |
void | SetVisualScriptBindingText | |
void | SetVisualScriptBindingNumber | |
FBindingStats | GetBindingStats | |
bool | InVisualScriptBindingEval | |
uint32_t | VisualScriptEvalsLastTick | |
void | NotifyAssetChanged | Marks a loaded asset stale so the next Tick evicts and rebuilds every screen using it — the entry point the file watcher drives, public so hosts without a watcher (and tests) can force the same reload. |
Miri::TSharedPtr<Miri::MWidget> | GetOverlayWidget | |
void | Tick | |
bool | HandleDirectional | Directional navigation: spatial pick of the nearest focusable widget in the pressed direction (center-line projection with axis bias, the UE approach). |
void | SetRightToLeft | The reading order screens build with when a node says "inherit" — set from the active culture. |
bool | IsRightToLeft | |
bool | HandleAccept | Accept delivered as a real activate on the focused widget (the widget translates it internally — click delegate, toggle, open); no synthesized mouse events. |
bool | HandleBack | Back/cancel: a host- or screen-defined handler first, then pop of the top code-driven screen. |
FMiriGraphicsInputRouter& | GetInputRouter | The one router every host feeds. |
const FMiriGraphicsInputRouter& | GetInputRouter | |
void | FeedGamepadButton | |
void | FeedGamepadAxis | |
void | FeedKey | Host keyboard events (the host's own key code). |
void | SetInputActionSystem | The input action system whose UI.* actions drive the router each tick; null (default) uses the global one, a split-screen player passes its own. |
FMiriGraphicsInputConfig | GetDesiredInputConfig | |
int32_t | GetInputOwnerHandle | |
bool | HasInputOwner | |
void | SetPointerSink | |
void | InstallBridgePointerSink | |
void | SetAnalogCursorBounds | |
bool | IsAnalogCursorActive | |
Miri::MiriVec2 | GetAnalogCursorPosition | |
InputActionSystem& | GetActionSystem | |
bool | ProjectFileExists | |
bool | ActivateActionButton | |
uint32_t | GetScreenBuildCount | |
size_t | GetPooledScreenCount | |
uint32_t | GetGlyphResolveCount | |
void | SetBackHandler | |
void | NotifyInputDevice | Hosts report the device each input event came from; switching to the gamepad re-applies the focus visual, switching to the mouse clears it. |
EMiriGraphicsInputDevice | GetActiveInputDevice | |
Miri::TSharedPtr<Miri::MWidget> | FindNamed | |
size_t | GetLeavingScreenCount | |
std::vector<FMiriGraphicsScreenInfo> | DescribeScreens | Read-only views for the editor's UI inspector and tests. |
std::vector<FMiriGraphicsFocusableInfo> | PreviewNavigation | |
int32_t | GetFocusIndex | |
int32_t | MountedCount |
Function details
CMiriGraphicsScreenStack
CMiriGraphicsScreenStack()~CMiriGraphicsScreenStack
~CMiriGraphicsScreenStack()CMiriGraphicsScreenStack
CMiriGraphicsScreenStack(const CMiriGraphicsScreenStack&) = deleteoperator=
CMiriGraphicsScreenStack& operator=(const CMiriGraphicsScreenStack&) = deleteSetPathResolver
void SetPathResolver(std::function<std::string(const std::string&)> resolver)Resolves a serialized asset path ("Assets/UI/x.ui") to something LoadFromFile can open. Identity when unset.
SetFocusSink
void SetFocusSink(std::function<void(Miri::TSharedPtr<Miri::MWidget>)> sink)Where directional nav sends the newly focused widget (host wires this to its Miri input processor's SetFocus). Optional.
SetBindingResolver
void SetBindingResolver(FMiriGraphicsBindingResolver resolver)Supplies the current value for a widget data-binding source. Applied to bound widgets at instantiation, then re-resolved every Tick with a dirty-check so bound widgets track live gameplay state. Optional — without it authored defaults stand. Set it before the first SyncFromWorld.
SetEventSink
void SetEventSink(FMiriGraphicsEventSink sink)Receives (widgetName, eventName, action) for every authored widget event that fires. Optional; without it events are dropped.
InstallVfsPathResolver
void InstallVfsPathResolver()Convenience installers so every host mounts identically. The VFS path resolver maps "Assets/UI/x.ui" to a native path; the bridge focus sink drives CMiriMowoBridge's input processor; the world binding resolver wires FMiriGraphicsBindingLibrary reflection paths against the host's live World + entity-name lookup (customHook is the Visual Script seam).
InstallBridgeFocusSink
void InstallBridgeFocusSink()InstallWorldBindingResolver
void InstallWorldBindingResolver(FMiriGraphicsBindingLibrary::FWorldProvider world, FMiriGraphicsBindingLibrary::FEntityLookup lookup, FMiriGraphicsBindingLibrary::FCustomSourceHook customHook = FMiriGraphicsBindingLibrary::FCustomSourceHook())EnableHotReload
void EnableHotReload(bool enable)Watches every loaded .ui file and rebuilds its screens on save. Watch callbacks only record intent; the rebuild happens in Tick.
LoadLocalization
static uint32_t LoadLocalization(const std::string& rootDir, const std::string& locale)Loads <rootDir>/<locale>/*.txt string tables (key=value lines, file stem = namespace) into Miri's CTextLocalizationManager and makes the locale current, so authored text_key props resolve through CText::FromKey. Returns the number of entries registered.
SetProjectTheme
bool SetProjectTheme(const std::string& themePath)Theme every screen without its own theme: resolves colour tokens against. Loaded through the path resolver and cached; empty clears back to the built-in default theme.
GetActiveTheme
const FMiriGraphicsTheme& GetActiveTheme() constSetSafeZoneInsets
void SetSafeZoneInsets(float fractionX, float fractionY)Title-safe insets as a fraction of each axis, applied by every screen's root canvas (the designer's Safe Area overlay draws the same box).
SetSafeInsets
void SetSafeInsets(const FMiriGraphicsSafeInsets& insets)Per-side insets for THIS stack only (one split-screen viewport, one PIE window). Without it screens use the process default the symmetric call sets.
ClearSafeInsets
void ClearSafeInsets()SyncFromWorld
void SyncFromWorld(World& world)SyncWorldWidgets
void SyncWorldWidgets(World& world, const FMiriGraphicsViewInfo& view)Places every visible UIWorldWidgetComponent's tree at its entity's projected screen position. Call once per frame after the camera is resolved; an invalid view hides the layer instead of dropping the trees. This is the screen-space fallback — components with worldSpace = false use it exclusively, and everything falls back to it when the offscreen renderer is unavailable.
SyncWorldWidgets3D
void SyncWorldWidgets3D(World& world, const FMiriGraphicsViewInfo& view, const FWorldQuadSink& sink)MarkWorldWidgetDirty
void MarkWorldWidgetDirty(uint64_t owner)Marks a world widget's offscreen texture stale so the next SyncWorldWidgets3D re-renders it. Bound widgets whose data changed call this automatically; hosts can force a refresh (e.g. a health bar tick).
RecordPendingWorldWidgets
void RecordPendingWorldWidgets()HitTestWorldWidgets
FMiriGraphicsWorldHit HitTestWorldWidgets(const Vec3& rayOrigin, const Vec3& rayDir) constRay-vs-quad hit test against the interactive world-widget quads resolved by the last SyncWorldWidgets3D, nearest hit first. On a hit, the local UV is filled in (top-left origin, matching the widget's own coordinates).
RouteWorldWidgetClick
bool RouteWorldWidgetClick(const Vec3& rayOrigin, const Vec3& rayDir)Ray-picks the nearest interactive world widget and dispatches a synthetic left click (button down + up) to the widget under the mapped local point, exactly as if the user had clicked that pixel of the offscreen tree. Returns true when a widget consumed it.
Clear
void Clear()PushScreen
int32_t PushScreen(const std::string& assetPath, int32_t zOrder = 1000, bool modal = false)Code-driven screens (pause menu, main menu, loading). Returns a handle for PopScreen; 0 on load failure. Modal screens contain gamepad focus and report through HasModalScreen so the host can gate game input.
PopScreen
bool PopScreen(int32_t handle)PopTopScreen
bool PopTopScreen()PushScreenOnLayer
int32_t PushScreenOnLayer(const std::string& assetPath, const std::string& layer)Layer-addressed push: the layer picks the z band and whether the screen is modal ("game", "menu", "modal", "toast" — see FMiriGraphicsScreenLayers). Opening a screen remembers the focused widget and popping it gives focus back.
PopLayer
int32_t PopLayer(const std::string& layer)CountOnLayer
int32_t CountOnLayer(const std::string& layer) constIsScreenMounted
bool IsScreenMounted(int32_t handle) constGetScreenPath
std::string GetScreenPath(int32_t handle) constSetScreenBackHandler
void SetScreenBackHandler(int32_t handle, std::function<bool()> handler)Back for one screen instance; runs before the global handler when that screen is the top code-driven one.
AttachViewModel
bool AttachViewModel(int32_t handle, std::shared_ptr<FMiriGraphicsViewModel> model)The per-instance state of a pushed screen: "self.<field>" bindings read it, so two copies of one asset hold separate values. Returns false for a dead handle.
GetViewModel
std::shared_ptr<FMiriGraphicsViewModel> GetViewModel(int32_t handle) constPushScreenWithViewModel
int32_t PushScreenWithViewModel(const std::string& assetPath, const std::string& layer, std::shared_ptr<FMiriGraphicsViewModel> model)SetWidgetTextOnScreen
bool SetWidgetTextOnScreen(int32_t handle, const std::string& widgetName, const std::string& text)Handle-addressed twins of the path-addressed setters above: they reach the instance, not the first screen that happens to share the asset.
FindNamedOnScreen
Miri::TSharedPtr<Miri::MWidget> FindNamedOnScreen(int32_t handle, const std::string& widgetName) constSetWidgetVisibleOnScreen
bool SetWidgetVisibleOnScreen(int32_t handle, const std::string& widgetName, bool visible)SetWidgetProgressOnScreen
bool SetWidgetProgressOnScreen(int32_t handle, const std::string& widgetName, float percent)HasModalScreen
bool HasModalScreen() constPushedCount
int32_t PushedCount() constPlayAnimation
bool PlayAnimation(const std::string& assetPath, const std::string& name)Timeline playback on a mounted screen (world-scanned or pushed), addressed by its asset path. The two-argument form starts with the authored loop flag; the params form overrides loop/reverse and takes a completion callback (fired once, after the end pose is applied; looping runs never finish). Playing an already-running animation restarts it. Every finished run also reports through the event sink as (assetPath, "anim_finished", animationName).
PlayAnimation
bool PlayAnimation(const std::string& assetPath, const std::string& name, const FMiriGraphicsAnimPlayParams& params)StopAnimation
bool StopAnimation(const std::string& assetPath, const std::string& name)StopAllAnimations
void StopAllAnimations(const std::string& assetPath)IsAnimationPlaying
bool IsAnimationPlaying(const std::string& assetPath, const std::string& name) constDispatchAction
bool DispatchAction(const std::string& assetPath, const std::string& action)The built-in event-action vocabulary: "PlayAnim:Name", "PlayAnimReverse:Name", "StopAnim:Name". Authored widget events run through this before reaching the host's event sink; hosts and tests can dispatch the same verbs directly. Returns true when the action was one of the built-ins (whether or not the animation existed).
DispatchVisualScriptAction
bool DispatchVisualScriptAction(const std::string& assetPath, const std::string& widgetName, const std::string& action)SetWidgetText
bool SetWidgetText(const std::string& assetPath, const std::string& widgetName, const std::string& text)SetWidgetVisible
bool SetWidgetVisible(const std::string& assetPath, const std::string& widgetName, bool visible)SetWidgetProgress
bool SetWidgetProgress(const std::string& assetPath, const std::string& widgetName, float percent)FindVideoPlayer
Miri::MVideoPlayer* FindVideoPlayer(const std::string& assetPath, const std::string& widgetName) constThe VideoPlayer node under a name (empty screen path searches every screen), or null when the name is not a video — MUIStatics' seam.
SetVisualScriptBindingText
void SetVisualScriptBindingText(const std::string& name, const std::string& text)SetVisualScriptBindingNumber
void SetVisualScriptBindingNumber(const std::string& name, double number)GetBindingStats
FBindingStats GetBindingStats() constInVisualScriptBindingEval
bool InVisualScriptBindingEval() constVisualScriptEvalsLastTick
uint32_t VisualScriptEvalsLastTick() constNotifyAssetChanged
void NotifyAssetChanged(const std::string& assetPath)Marks a loaded asset stale so the next Tick evicts and rebuilds every screen using it — the entry point the file watcher drives, public so hosts without a watcher (and tests) can force the same reload.
GetOverlayWidget
Miri::TSharedPtr<Miri::MWidget> GetOverlayWidget() constTick
void Tick(float deltaSeconds)HandleDirectional
bool HandleDirectional(int32_t dx, int32_t dy)Directional navigation: spatial pick of the nearest focusable widget in the pressed direction (center-line projection with axis bias, the UE approach). Falls back to the linear cycle only when the tree has no usable geometry (headless). Focusability comes from the MWidget IsFocusable predicate, not a type whitelist. The focused widget's navigation rules (nav_up / nav_down / nav_left / nav_right on its node or an ancestor) can stop the move, wrap it at the edge, or send it to a named widget instead.
SetRightToLeft
void SetRightToLeft(bool rightToLeft)The reading order screens build with when a node says "inherit" — set from the active culture. Takes effect on the next (re)build; call before pushing, or push again after switching.
IsRightToLeft
bool IsRightToLeft() constHandleAccept
bool HandleAccept()Accept delivered as a real activate on the focused widget (the widget translates it internally — click delegate, toggle, open); no synthesized mouse events.
HandleBack
bool HandleBack()Back/cancel: a host- or screen-defined handler first, then pop of the top code-driven screen.
GetInputRouter
FMiriGraphicsInputRouter& GetInputRouter()The one router every host feeds. SDL numbers are translated inside; the stick is normalised here so hosts pass the raw axis value.
GetInputRouter
const FMiriGraphicsInputRouter& GetInputRouter() constFeedGamepadButton
void FeedGamepadButton(uint8_t sdlButton, bool down)FeedGamepadAxis
void FeedGamepadAxis(uint8_t sdlAxis, int16_t value)FeedKey
void FeedKey(int32_t keyCode, bool down)Host keyboard events (the host's own key code). Keys are only acted on when bound with GetInputRouter().BindKey, so Miri's own keyboard handling is not doubled.
SetInputActionSystem
void SetInputActionSystem(InputActionSystem* actions, bool enabled = true)The input action system whose UI.* actions drive the router each tick; null (default) uses the global one, a split-screen player passes its own.
GetDesiredInputConfig
FMiriGraphicsInputConfig GetDesiredInputConfig() constGetInputOwnerHandle
int32_t GetInputOwnerHandle() constHasInputOwner
bool HasInputOwner() constSetPointerSink
void SetPointerSink(FPointerSink sink)InstallBridgePointerSink
void InstallBridgePointerSink()SetAnalogCursorBounds
void SetAnalogCursorBounds(float width, float height)IsAnalogCursorActive
bool IsAnalogCursorActive() constGetAnalogCursorPosition
Miri::MiriVec2 GetAnalogCursorPosition() constGetActionSystem
InputActionSystem& GetActionSystem() constProjectFileExists
bool ProjectFileExists(const std::string& path) constActivateActionButton
bool ActivateActionButton(EMiriGraphicsAction action)GetScreenBuildCount
uint32_t GetScreenBuildCount() constGetPooledScreenCount
size_t GetPooledScreenCount() constGetGlyphResolveCount
uint32_t GetGlyphResolveCount() constSetBackHandler
void SetBackHandler(FBackHandler handler)NotifyInputDevice
void NotifyInputDevice(EMiriGraphicsInputDevice device)Hosts report the device each input event came from; switching to the gamepad re-applies the focus visual, switching to the mouse clears it.
GetActiveInputDevice
EMiriGraphicsInputDevice GetActiveInputDevice() constFindNamed
Miri::TSharedPtr<Miri::MWidget> FindNamed(const std::string& name) constGetLeavingScreenCount
size_t GetLeavingScreenCount() constDescribeScreens
std::vector<FMiriGraphicsScreenInfo> DescribeScreens() constRead-only views for the editor's UI inspector and tests.
PreviewNavigation
std::vector<FMiriGraphicsFocusableInfo> PreviewNavigation() constGetFocusIndex
int32_t GetFocusIndex() constMountedCount
int32_t MountedCount() const