Game screens
How a .ui asset describes a game screen, how the screen stack mounts it, and how bindings, events, animations and controller classes bring it to life.
A game screen in Mowo is a .ui asset: an MDF document holding a widget tree, data bindings, event wiring and animations. At run time the screen stack (CMiriGraphicsScreenStack) builds the asset into Miri widgets, mounts it over the game view, and keeps it in sync with gameplay every tick.
The lifecycle of a screen
- Load .ui
- Factory builds Miri widgets
- Mount on stack
- Tick: bindings + animations
- Events → actions / graphs
FMiriGraphicsAssetreads the MDF fileFMiriGraphicsAsset.FMiriGraphicsWidgetFactoryturns each node into a live Miri widget and wires its bindings and eventsFMiriGraphicsWidgetFactory.- The stack composites every mounted screen into one overlay widget, sorted by z-order.
- Each
Tickapplies the bindings whose source changed (and re-polls the rest), advances animations, and advances the settings-screen countdown. - Widget events run built-in verbs, controller graphs or the host's handlers.
The .ui format
A screen is a .ui file. A file starts with a Package block that carries the asset id and the assets it imports, then the UI "Widget" document. This is an excerpt of the test project's main menu:
UI "Widget" {
design_width: 1920
design_height: 1080
Animations {
Anim "MenuIn" {
auto_play: true
Track {
target: "MenuPanel"
property: opacity
Key {
t: 0.0
v: 0.0
}
Key {
t: 0.35
v: 1.0
easing: cubic_out
}
}
}
}
Widget "Root" {
class: "CanvasPanel"
anchor: Stretch
Widget "StartButton" {
class: "Button"
variable: true
anchor: Center
position: vec2(0.0, -120.0)
size: vec2(360.0, 52.0)
Props {
label: "Start Match"
text_key: "Menu.start"
}
Events {
On {
event: "clicked"
action: "PlayAnim:StartNudge"
}
On {
event: "clicked"
action: "StartMatch"
}
}
}
}
}Root properties
| Property | Meaning |
|---|---|
schema_version | Written on every save; currently 1 FMiriGraphicsAsset |
design_width, design_height | The resolution the numbers in the tree are authored in. The root canvas scales the screen to the viewport. |
theme | Optional .theme for color, font and metric tokens. See Styling. |
pooled | true keeps a removed instance of this screen and reuses it on the next push instead of building it again. See Pooled screens. |
Input | Optional block: what this screen asks of the player's input. See Input modes. |
visual_script_class | Optional Visual Scripting class (.vscript) that acts as the screen's controller. See Controller classes. |
controller_class | Optional reflected C++ class (an actor or actor component) that acts as the screen's controller, by class name. A screen has one controller: this key is read only when visual_script_class is empty. See C++ controllers. |
Node properties
Every Widget node has a class and a name. The name is what bindings, animation targets and FindNamed use.
| Property | Meaning |
|---|---|
anchor | TopLeft, TopCenter, TopRight, CenterLeft, Center, CenterRight, BottomLeft, BottomCenter, BottomRight or Stretch FMiriGraphicsAsset |
position, size | Offset from the anchor and size, in design units |
anchor_min, anchor_max, alignment | Fractional anchors and pivot, overriding the preset |
offset_high | The far inset on a stretched axis |
size_to_content_x, size_to_content_y | Take the widget's desired size on that axis |
z_order | Paint and hit-test order inside a canvas |
variable | Expose the widget by name to the controller |
slot_margin, slot_fill, slot_h_align, slot_v_align | Slot settings when the parent is a box, overlay or grid |
nav_up, nav_down, nav_left, nav_right and their _targets, clip_to_bounds, flow_direction | Gamepad navigation rules, clipping and reading direction. See Widgets and layout. |
design_hidden, design_locked | Designer-only; ignored unless the factory runs in designer mode |
Text properties
Text nodes take these optional properties; a node that sets no font property keeps the style's font:
| Property | Meaning |
|---|---|
text | The source text, also the fallback for text_key |
text_key | Namespace.key in the string tables. See Localization. |
font, font_size, bold, italic | Font family, size in logical pixels and face |
line_height, letter_spacing | Pixels between baselines (0 means the face's own) and tracking |
font_features | OpenType features, such as tnum for tabular figures |
justify | left, center or right; logical, so a right-to-left paragraph's left is the right edge |
wrap, ellipsis | Wrap at the arranged width; elide at the tail, head or middle |
text_direction | auto, ltr or rtl |
shadow_x, shadow_y, shadow_color | A drop shadow under the text |
Child blocks: Props (class-specific key/value pairs), Bindings, Events, and nested Widget nodes. Props is schema-tolerant: unknown keys are kept through a save.
Fields are written only when they differ from their default, so opening and saving an untouched asset gives a byte-identical file. slot_h_align and slot_v_align default to Default, which means "keep the parent's own alignment".
Widget types
The factory knows these class names:
| Kind | Classes |
|---|---|
| Panels | CanvasPanel, ClipBox, HorizontalBox, VerticalBox, GridPanel, UniformGridPanel, WrapPanel, FlexBox, Overlay, ScrollBox, Border, SizeBox, ScaleBox, RetainerBox, WidgetSwitcher |
| Text | Text, RichText, RichTextBlock, EditableTextBox, MultiLineEditableTextBox, Hyperlink |
| Input | Button, CheckBox, ToggleSwitch, ComboBox, Slider, KeyCap, KeyCapture |
| Data | ListView, TreeView |
| Display | Image, RenderTargetImage, Particles, ProgressBar, Shape, Spinner, Spacer, VideoPlayer, Breadcrumb |
| Composite | UserWidget, SettingsScreen, RebindScreen, LobbyScreen |
A FlexBox lays its children out like CSS flexbox. Its node takes direction (row, row_reverse, column, column_reverse), justify (start, end, center, space_between, space_around, space_evenly), align (start, end, center, stretch), align_content (the same values plus stretch for wrapped lines), wrap, gap and cross_gap. Each child may set flex_grow, flex_shrink, flex_basis, min_width, max_width, min_height, max_height, aspect_ratio and align_self. On a right-to-left screen a row starts at the right edge.
A ListView takes an items array and one child node as its row template. Strings in the template can use $item, $index, or $0, $1… for fields of an array item.
A UserWidget embeds another .ui. ClipBox is a canvas panel that always clips. Nesting deeper than MaxUserWidgetDepth (8), or a reference back to an asset that is already being expanded, becomes a placeholder and a build error instead of a crash FMiriGraphicsWidgetFactory.
The screen stack
There are two ways to mount a screen.
World screens. Add a UIWidget component to an entity. It has asset, z_order, visible and auto_focus UIWidgetComponent. SyncFromWorld mounts every visible one.
Code screens. Call PushScreen(assetPath, zOrder, modal). It returns a handle for PopScreen, or 0 if the asset failed to load. PopTopScreen() pops the most recent one CMiriGraphicsScreenStack. In a game, MGameEngine wraps these as PushUIScreen and PopUIScreen.
#include <MiriGraphics/CMiriGraphicsScreenStack.h>
static int32_t g_mainMenu = 0;
void ShowMainMenu(Mowo::CMiriGraphicsScreenStack& stack)
{
g_mainMenu = stack.PushScreen("Assets/UI/MainMenu.ui", 1000, true);
}
void HideMainMenu(Mowo::CMiriGraphicsScreenStack& stack)
{
if (g_mainMenu != 0) {
stack.PopScreen(g_mainMenu);
g_mainMenu = 0;
}
}Map an action string from a .ui event, such as the sample's StartMatch, to a C++ handler with MGameEngine::RegisterUIAction(action, handler) or, from code with no engine pointer, the action registry. QuitGame is registered by default and stops the engine. Play-in-editor dispatches through the same registry.
Modal screens
A modal screen:
- keeps gamepad focus inside itself;
- is drawn over a full-screen scrim that eats clicks and wheel input, so nothing reaches screens or gameplay below;
- switches the input mode to
UIOnlyand gives back the previous mode when it pops.
The input-mode rule is re-checked every tick against the stack's own HasModalScreen(), so it works however the screen was pushed, including from a graph and in Play-In-Editor FMiriGraphicsModalInputGate.
Safe zone
SetSafeZoneInsets(x, y) insets every screen's root canvas by a fraction of each axis, clamped to 0–0.25. The default is zero.
Bindings
A Bind entry drives one widget property from a source. The widget is written only when the value changes.
Bindings {
Bind {
property: "text"
source: "visualscript.UiDemoController.GetStatus"
}
}Bindable properties:
| Property | Widgets |
|---|---|
text | Text, RichText, EditableTextBox |
percent | ProgressBar |
value | Slider, ProgressBar |
checked | CheckBox, ToggleSwitch |
selected | ComboBox (the item index) |
visible | any widget |
image | Image (an asset path; empty clears it) |
active_index | WidgetSwitcher |
spinning | Spinner |
media, playing, volume | VideoPlayer |
opacity | any widget |
render_translation | any widget (a vec2, or text "x, y") |
render_scale, render_angle | any widget (the angle is in degrees) |
color | Text, RichText, Shape |
progress | Shape |
tint | Image |
background_color | Border |
fill_color | ProgressBar |
A colour property takes a vec4 (three or four lanes), #rrggbb[aa] text, or a theme colour token. A bound value that is none of those leaves the widget as it was. The three render-transform properties write one transform together (translate, then rotate, then scale about the widget's pivot), so setting one keeps the other two.
Sources, in the order the stack tries them:
- Published values
An exact name published with
MUIStatics::SetBindingValueorSetBindingNumber. This is how a controller pushes values to the screen. - Controller functions
visualscript.<Class>.<Function>calls a function on the screen's controller class.controller.<Name>reads a field or a zero-argument getter of a C++ controller class. See below. - The host resolver
A custom hook first, then numeric literals (
"0.75"), then reflection pathsEntity.Component.Property[.x|.y|.z|.w]. The entity is found by scene name and the component by its reflected nameFMiriGraphicsBindingLibrary.
When a binding updates
Sources that announce their own changes are pushed: self.<field> (the view model attached to the screen), vm.<Model>.<field> (a registered view model) and published values. The stack marks such a binding when the source is written and resolves it once on the next Tick, so three writes in one tick apply once and a screen with only pushed bindings does no binding work while nothing changes. Everything else (controller., visualscript., prompt., the host resolver and reflection paths, bindings on world widgets and in list rows) cannot announce a change and is polled every tick. A format binding pushes only when every placeholder does. A binding that carries mode: "tick" is polled even when its source could push.
Bind {
property: "text"
source: "vm.Player.name"
mode: "tick"
}CMiriGraphicsScreenStack::GetBindingStats returns how many bindings are pushed and polled and how many resolves and writes the last tick made; the Game UI Inspector prints the same line.
Formats and converters
format builds one text from several sources: every {source} in it is resolved and its value written in place, so "{self.hp}/{self.max}" shows 30/100 and updates when either field changes. A binding with a format needs no source. Spaces inside the braces are ignored ({ self.hp } is {self.hp}), {{ and }} write a literal brace, and a { without a closing } stays as text. A placeholder that resolves to nothing contributes nothing; the binding has no value only when none of them resolves. converter runs the resolved value through a named function before the widget sees it; a name after a colon passes arguments (ramp:Danger,Warning,Success). An unknown converter name is reported when the screen builds, and again with one warning when a value reaches it later (a converter registered after the screen built starts working from then on); until then the value passes through unchanged.
Bindings {
Bind {
property: "text"
format: "{self.hp}/{self.max}"
}
Bind {
property: "visible"
source: "self.alive"
converter: "bool_to_visibility"
}
Bind {
property: "fill_color"
source: "self.hp_ratio"
converter: "ramp:Danger,Warning,Success"
}
}| Converter | Result |
|---|---|
bool_to_visibility | true for a non-zero number or the text true / 1, otherwise false, so visible shows or collapses the widget. |
invert | The logical opposite of the same test. |
percent | The value times 100 as text with a percent sign (0.756 becomes 76%); percent:1 keeps one decimal. |
ramp:a,b,c | A colour read from the colour stops (hex, or colour tokens of the active theme) at a value of 0 to 1, spaced evenly and blended between neighbours. |
Games add their own with FMiriGraphicsConverterRegistry::Register(name, function) FMiriGraphicsConverterRegistry. Visual Scripting functions are not converters yet; a visualscript. source can already return a computed value.
Two-way bindings
mode: "two_way" on a binding of a Slider (value), CheckBox or ToggleSwitch (checked), EditableTextBox (text, written when the box commits) or ComboBox (selected) also writes the widget's changes back to the source. Only self.<field> (the screen needs an attached view model), vm.<Model>.<field> (the model must be registered) and names that are already published accept a write; the warning names which of these failed. An empty string committed to a published name stays an empty text. Any other source stays read-only: the first change logs one warning and the widget keeps what the player set until the source moves. A two-way binding with a format or a converter is read-only too, and the build reports it. The widget is not rewritten with the value it just sent, so a write costs no extra update.
Events
An On entry wires a widget event to an action string. Several entries for the same event all run, in order.
| Event | Fired by |
|---|---|
clicked | Button, Hyperlink |
changed | CheckBox, ToggleSwitch, ComboBox, Slider |
committed | EditableTextBox, MultiLineEditableTextBox |
link | RichText links; the payload is the link target |
drop, drop_outside | Widgets with drop_target / drag_source props |
closed, rebind | SettingsScreen (closed also on RebindScreen and LobbyScreen) |
Actions are resolved in this order:
- Built-in animation verbs:
PlayAnim:Name,PlayAnimReverse:Name,StopAnim:Name. VisualScript:<Class>.<Event>[:payload], which runs an event graph on the controller class.- A handler registered in the action registry under the action name (or under the part before the first
:, with the rest as the payload). The narrowest scope wins: this screen, then this host, then global. - A zero-argument function of that name on the screen's C++ controller, optionally written
Controller:<Function>. - Anything else reaches the host's event sink, which only logs, and is reported once as an error:
UI action '<name>' has no handler. In play-in-editor the same case also raises a warning toast. A screen with a Visual Scripting controller is exempt: that controller receives every action throughOnUIEvent.
The packaged game, play-in-editor and the editor's test hosts all run this one path, so a button behaves the same in each.
Animations
An Anim is a named timeline. Each Track animates one property of one named node. opacity, translation_x, translation_y, scale and rotation move the node through its render host, and a color track tints Text and RichText widgets. Any other name is looked up in the property table of the node's widget and written through the same setter a binding uses, so a track can drive every property that is marked animatable: tint on an Image, background_color on a Border, fill_color on a ProgressBar, render_translation, render_scale, render_angle, and material.<Parameter> on a Border with a material brush. A track that names no such property logs one warning and does nothing.
Keys have a time t, a number v, and an easing into that key: linear, or quad, cubic, quart, quint, sine, expo, circ, back, bounce, elastic with _in, _out or _in_out, or spring. A key may carry color: vec4(...) or v4: vec4(...) instead of v for a colour or a vector property, and spring: vec2(stiffness, damping) sets the spring of a spring key (the default overshoots a little, a damping above the square root of the stiffness does not).
Playback attributes on the Anim:
| Attribute | Meaning |
|---|---|
rate | Playback speed, 2.0 plays twice as fast. A rate of zero or less logs a warning and plays at 1. |
ping_pong | Plays forward and then back; one cycle is twice the duration, and a run ends on the start pose. |
loops: N | Plays N cycles and stops; loop: true plays until stopped. |
stagger: s | Track number i starts i * s seconds late, and the duration grows to fit. A negative value counts as 0. |
Event { t: 0.5 name: "hit" } | Reports anim_event with the name through the event sink whenever the playhead crosses t, forward, backward and across a loop wrap, in the order it crossed them. |
auto_play starts a timeline when the screen mounts; loop wraps it. From C++, use PlayAnimation(assetPath, name, params) with FMiriGraphicsAnimPlayParams (Loop, Reverse, OnFinished) FMiriGraphicsAnimPlayParams. Every finished run also reports anim_finished through the event sink.
State transitions
A node can play an animation when it enters a state, without a controller or an event action:
Widget "PlayButton" {
class: "Button"
Transitions {
On "hover" {
anim: "Glow"
reverse_on_exit: true
}
On "pressed" {
anim: "Squash"
}
On "focus" {
anim: "FocusRing"
reverse_on_exit: true
}
}
}hover plays when the pointer enters the node or anything inside it, pressed when a Button is pressed, and focus when gamepad or keyboard focus lands on the node or something inside it (a mouse player sees no focus transition, including the one a screen starts with on its first button). Hover and pressed transitions need a named node: an unnamed one reports an error and keeps its own hover feedback. With reverse_on_exit the animation plays backwards from wherever it stands when the state ends, so leaving a half-played hover does not jump; without it the animation stays at its end pose. A hover transition switches off the Button's or CheckBox's own colour fade for that one widget, so the animation is the only thing moving; widgets without a transition, and every editor widget, keep the fade.
Screen transitions
A screen can animate itself in when it is pushed and out when it is popped. Put a Transition block on the .ui root:
UI "Widget" {
Transition {
push: slide_up
pop: fade
duration: 0.25
easing: cubic_out
}
}push and pop name a preset (fade, slide_left, slide_up or scale) or one of the screen's own animations, which can target the whole screen with the name __screen. A slide moves the screen by one design width or height, entering from the right or the bottom and leaving towards the left or the top. duration and easing default to the theme's Motion "screen" entry, then to 0.2 seconds with cubic_out.
PopScreen removes the screen from the stack at once, so focus, bindings and screen hidden events behave as for any pop, and keeps drawing the picture until the animation ends. A screen that is leaving ignores the pointer and gamepad. The leaving picture is dropped at once when the stack is cleared, when a screen is hot-reloaded or rebuilt, when the same asset is pushed again, when PopScreen is called a second time for the same handle, and whenever reduced motion is on; with reduced motion neither push nor pop animates.
Controller classes
A screen can be driven entirely from Visual Scripting. Set visual_script_class at the root to a .vscript class, then:
- Pull values with
visualscript.<Class>.<Function>bindings. The stack keeps one shared instance per class and caches each source's result per tick. Evaluation runs under a 50,000-step budget, so a runaway loop warns and yields nothing. - Push events with
VisualScript:<Class>.<Event>actions. Before the graph runs, the stack sets the variablesWidgetName,EventName,PinPayload,ScreenPathandOwnerEntity. - React to the screen: the controller receives
OnScreenShown,OnScreenHidden, andOnUIEventfor every widget event on the screen. - Reach back with the
MUIStaticsfunctions:SetWidgetText,SetWidgetVisible,SetProgress,PlayWidgetAnim,StopWidgetAnim,PushScreen,PopScreen,SetBindingValue,SetBindingNumberand the video controlsMUIStatics.
UI graphs run with no actor behind them. Calls that need a target actor do nothing and log an error; go through MUIStatics or gameplay events instead. Pushing or popping screens during a binding evaluation is refused, so a binding can never rebuild the screen it is drawing.
The test project pairs Assets/UI/VisualScriptDemo.ui with Assets/UI/UiDemoController.vscript. For graph authoring, see Functions, macros and dispatchers and Calling C++.
The action registry
FMiriGraphicsActionRegistry maps an action name to a handler FMiriGraphicsActionRegistry. It is one process-wide table that every host reads, so game-module code registers without holding an engine pointer:
class AMenuDirector : public AActor {
void BeginPlay() override {
m_quit = FMiriGraphicsActionRegistry::Get().Register("QuitToDesktop", [] { /* ... */ }, FMiriGraphicsActionScope::ForActiveStack());
}
void EndPlay() override {
m_quit.Reset();
}
FMiriGraphicsActionHandle m_quit;
};- Handles own the registration. Dropping or resetting an
FMiriGraphicsActionHandleunregisters the handler, so hold it exactly as long as the object the handler touches.Detach()leaves the entry registered for the life of its scope. - Scopes.
FMiriGraphicsActionScope()is global.ForHost(stack)limits a handler to one screen stack andForScreen(stack, assetPath)to one.uiasset;ForActiveStack()is the stack gameplay UI is on right now (MUIStatics::GetActiveStack). A stack takes its registrations with it when it is destroyed, and play-in-editor drops its stack's registrations on Stop. A global handler is never cleared by a session, so release it from the object that owns it. - Duplicates. Registering the same name in the same scope again replaces the earlier handler (the earlier handle reads invalid); a replacement from another module logs a warning.
- Modules. An entry records the module that registered it and is removed when that module unloads, so a hot reload never leaves a click calling into freed code. Pass the optional
ownerargument only if you register on behalf of another module. - Handler shape. A handler is invocable as
void()orvoid(const FMiriGraphicsActionContext&); the context carries the action, payload, widget, event and screen path. A handler may unregister itself or register another action while it runs. - The game host.
MGameEngine::RegisterUIAction(name, handler)is a thin forwarder that registers in the registry scoped to the engine's stack.
An action nobody took is logged once per name as an error (ReportUnhandled); registering the name re-arms that report.
C++ controllers
A screen's root may name any reflected actor or actor component class as its controller (controller_class, set from the Designer's C++ Controller Class picker). No Visual Scripting is involved:
MCLASS()
class AMainMenuController : public AActor {
public:
MGENERATED_BODY()
MPROPERTY()
int32_t Score = 0;
MFUNCTION()
void OnPlayPressed() { ++Score; }
};With that class as the root's controller, a button whose clicked event has the action OnPlayPressed calls the function, and a text widget bound to controller.Score shows the field. Details:
- Which instance. The first live actor of that class in the active world, or else the first actor component of that class. Place one in the level. The lookup is repeated whenever the instance is destroyed or the world changes (a play session ends, travel, hot reload), and nothing keeps a pointer to a dead object. With no instance the call does nothing and a warning is logged once.
- Functions. Only functions with no parameters are called by an action; one with parameters is refused with a warning.
OnScreenShownandOnScreenHidden, when present, run as the screen mounts and unmounts. - Bindings.
controller.<Name>reads anMPROPERTYthat is a bool, an integer, a float, a double, a string or an enum, or a zero-argument getterMFUNCTIONwith a bool, number or string result. Usecontroller.<Class>.<Name>to read from a controller other than the screen's own. - Visual Scripting classes keep working as before and take precedence for a name that is both.
- Layering. MiriGraphics knows nothing of actors. The Game layer installs the
FMiriGraphicsControllerResolverhooks throughFUIControllerBridge::Install(stack, worldProvider), which the packaged game and play-in-editor each call for their stackFMiriGraphicsControllerResolver.
Input modes
A screen can state how the game should read input while it is up, in an Input block on the root. The block is written only when the screen has one, so a screen without it saves exactly as before.
Input {
mode: menu
cursor: auto
contexts: "UI.Menu,Map"
analog_cursor: false
}| Key | Meaning |
|---|---|
mode | menu is UI-only input, game is game-only, all is both. Default menu. |
cursor | auto shows the cursor unless the gamepad is the active device, visible and hidden force it. A game screen with auto leaves the cursor as the game had it. |
contexts | Comma-separated input contexts the screen pushes while it owns input and pops when it stops. A name the project does not define is reported once and skipped; a context the game already stacked is left alone. |
analog_cursor | true lets the left stick move an on-screen cursor while a gamepad is the active device. See Analog cursor. |
The input owner is the top-most mounted screen (by z-order, then push order) that is not leaving and either has mode: menu or is modal. When ownership moves, the stack pops the old owner's contexts and pushes the new one's, so two stacked menus swap contexts and a screen that is fading out no longer owns input. GetDesiredInputConfig() answers with the top-most screen that has an Input block, or UI-only for a modal screen without one CMiriGraphicsScreenStack.
The packaged game and play-in-editor apply the answer through the same FMiriGraphicsModalInputGate, once per tick, so the result does not depend on how the screen was pushed. The gate remembers the mode and cursor the game had before the first screen asked and gives exactly those back, so a game that set UI-only itself keeps it FMiriGraphicsModalInputGate. A split-screen player's stack pushes contexts into its own input system, and only the primary stack drives the mode and the cursor.
Pooled screens
Building a large screen costs real time, so a menu a player opens often can opt in with pooled: true. When it is removed the stack keeps the built instance, up to two per asset and eight in all, and the next push of the same asset takes one back: no rebuild, with the handle, the animations (autoplay ones start again from zero), the bindings, the view model and the focus all as for a new screen. A pushed view model is attached again after the push as usual.
Whatever lives inside a widget and is not driven by a binding is not reset: scroll positions, typed text, check box and toggle states, slider values, combo box and tab selections, list contents and list selection, and hover or pressed states. Keep a pooled screen free of them, drive them from a binding, or write them back from your own state. Bound values are marked dirty and written again on the first tick after the push. The kept instances are dropped when the asset or anything it embeds is hot reloaded, when the theme, the language or high contrast changes, when a material changes and on Clear, so a reused screen never shows a stale look. GetScreenBuildCount() counts builds, for tests CMiriGraphicsScreenStack.
Analog cursor
A screen whose Input block sets analog_cursor: true gets a software cursor on the gamepad, for menus that were built for a mouse (a map, an inventory grid). It is active only while that screen is the one the stack takes its input config from and the last input came from a gamepad; on keyboard and mouse it is off.
- The left stick moves the cursor and no longer navigates focus; the D-pad still does. The stick has a 0.2 dead zone and a squared response, and the cursor runs at 1400 pixels per second at 1080p, scaled with the screen height, and stops at the screen edges.
- The accept button (South) sends a pointer press and release at the cursor, so widgets see an ordinary click, instead of activating the focused widget.
- The cursor is drawn above every screen with the theme sprite named
cursor, or a ring when the theme has none. The system cursor is reported hidden while it is active. - The packaged game and play-in-editor install a pointer sink on the primary stack only. A split-screen player's stack has none, so a screen asking for the cursor there is reported once and keeps normal navigation
CMiriGraphicsScreenStack.
Menu input
Both hosts feed one FMiriGraphicsInputRouter. D-pad and the left stick navigate with hold-to-repeat, South accepts, East goes back, shoulders switch tabs and the right stick scrolls. BindPadButton rebinds an action, and SerializeBindings / LoadBindings persist it. Enhanced Input actions named UI.Accept, UI.Back and so on drive the router through FeedNamedAction. prompt.<Action> and prompt.bar bind the current button label for the active device and controller family FMiriGraphicsInputRouter.
Safe zone and scale
Safe-area insets are per side. safe_zone on a root canvas picks sides (all, or the letters l, t, r, b). scale_rule is fit (default), shortest_side, longest_side, width, height, fixed or curve, with scale_fixed, scale_min, scale_max and scale_curve ("360:0.75,1080:1.5"). ui.SafeZone.Overscan is the player's TV-overscan margin and ui.DebugSafeZone previews an inset. A stack can carry its own insets (SetSafeInsets), so split-screen viewports and PIE windows do not share one value FMiriGraphicsSafeZone.
Named slots
A NamedSlot node marks a place in a widget asset where whoever embeds it supplies content. In the embedding UserWidget node, give each child a slot prop naming the slot; the child is built inside that slot. A single unnamed slot also takes children with no slot. A child naming a slot the asset does not have is dropped FMiriGraphicsWidgetFactory.
Prompts and the action bar
KeyPrompt shows the button or key bound to an action for the device in use (action: a UI action such as Accept, Back, TabPrev, or the name of a game input action). It shows the glyph image when one resolves and the label otherwise. ActionBar shows a line of prompts such as A Select B Back (actions: a comma-separated list). Both follow rebinding and the controller family (Xbox, PlayStation, Switch, Steam Deck) and are listed under Input in the designer palette FMiriGraphicsGlyphTable.
Glyphs and action buttons
For one action the glyph is chosen in this order: an installed glyph hook (the packaged game and play-in-editor install one that asks the platform input service, so Steam Input shows the art of the control the player bound in Steam), then your project's art, then text. Project art lives at Assets/UI/Glyphs/<family>/<label>.png, where <family> is keyboard, xbox, playstation, switch or steamdeck and <label> is the lower-case text of the control with spaces as underscores (b, circle, right_trigger, esc). The text is the pad or key label for a UI action and the first binding of the input action for a game action. A file that is missing, or a texture that cannot be loaded, falls back to the text.
ActionButton is a button that shows the glyph beside a label and fires when its action does. Its props are action (a UI action or an input action name), label and show_glyph; it raises the clicked event like any button.
- UI actions (
Back,Accept,TabPrev,TabNext,ScrollUp,ScrollDown) are claimed by the button before the default handling: Back presses the button instead of popping the screen, and Accept presses it only when nothing is focused, or, while the analog cursor is active, instead of the cursor click. - Game actions fire once per press, on the frame the input action triggers.
- A button fires only while it is visible and enabled, and only when its screen is at or above the input owner, so a button on the HUD does nothing under an open menu.
Glyphs are resolved again only when something they depend on changes: the controller family, the active input device, the glyph hook, a rebind of an input action, or the platform reporting a different origin. On Steam the origin is the controller, its type and its active action set, so switching pads re-resolves the glyphs; edits made in Steam's own binding panel are picked up the next time one of those changes. A screen with action buttons adds no bindings and nothing is resolved per frame.
A KeyPrompt or ActionButton inside a list row follows the device and rebinding the same way, because the stack collects it when the row is built. An action button that shares its action with the input that opened the screen does not fire on the frame the screen appears; it fires on the next press. A project glyph is found through the virtual file system, so art that ships inside a package resolves too.
Showing a scene capture
RenderTargetImage shows a render target asset (a .mrt file) that a scene capture component writes, so a security monitor, a minimap or a character preview can sit in a screen. Its props are target (the path of the render target asset), stretch (fill or fit, which keeps the target's aspect ratio) and tint.
Until a capture has written the target, the widget paints a flat surface-colour placeholder, so a screen never shows an uninitialised image. The packaged game and play-in-editor wrap the target's image once, the first frame after a capture wrote it, and the widget paints the live image from then on. The widget is only retained while it shows the image, so the placeholder is replaced on the frame the first capture lands. In the designer no captures run, so the widget shows the placeholder FMiriGraphicsWidgetFactory.
Particles
A Particles node is a small 2D emitter for UI effects such as sparks, embers or confetti behind a button or over a reward. It draws up to 512 particles at once in a single batch, and an emitter that has nothing alive paints nothing and costs nothing.
| Prop | Meaning |
|---|---|
sprite | A theme sprite name or an image path; the image goes into the sprite atlas |
rate, burst | Particles per second, and a burst that spawns when the screen starts |
max | The most alive at once, clamped to 512 (a larger value is reported once in the log) |
lifetime, speed, spin | A minimum and a maximum; each particle picks a value between them. spin is degrees per second |
angle, spread | The launch direction in degrees (-90 is up) and how far it may stray |
gravity, drag | An acceleration in pixels per second squared, and a velocity damping per second |
size | Start and end size, in pixels |
color_start, color_end | Colours or tokens; a particle blends from one to the other over its life |
area | point spawns at the middle of the node, rect anywhere inside its rectangle |
seed, autoplay | The random seed, so a screen looks the same every run, and whether it starts emitting by itself |
emitting (0 or 1) and rate can be animated or bound, so a button can start a shower when it is hovered. A pooled screen's emitters start again from nothing, at the rate the screen authored, when it is reused FMiriGraphicsWidgetFactory.
Emitters step in fixed slices of 1/120 s, so what a screen shows depends on the time that passed and not on how the frame rate cut it: a seeded emitter looks the same at 30 and at 60 frames per second. A rect emitter waits for its first layout before it spawns, so a burst always lands inside the node.
Split screen
With more than one local player the game keeps one screen stack per player. Each stack has its own screens, focus and router, is laid out inside that player pane, and receives the gamepad assigned to the player. Per-player menu actions (UI.Accept, UI.Back, UI.NavUp ...) are read from that player input action system FMiriGraphicsPlayerStacks.
Menu actions from input assets
Define actions named UI.Accept, UI.Back, UI.NavUp, UI.NavDown, UI.NavLeft, UI.NavRight, UI.TabPrev, UI.TabNext, UI.ScrollUp and UI.ScrollDown in a mapping context and the menu follows them, with the same hold-to-repeat as the gamepad. Keyboard keys reach the router only when bound with BindKey, so Miri own keyboard handling is never doubled FMiriGraphicsActionBridge.
Game UI Inspector
Developer menu, Game UI Inspector (Ctrl+Shift+U) attaches to the play-in-editor UI. It lists the screens and layers, every focusable widget with the target each direction leads to, the router bindings and, when switched on, a log of routed UI events. Save snapshot writes the same text to the project .Mowo/Saved/UiSnapshots folder FMiriGraphicsInspector.
Pointer options
miri.CoalesceMouseMove 1 routes only the last of consecutive mouse-motion events in one drain. miri.HitTest.Grid 1 prunes the hit test through a grid built once per frame; 2 also runs the plain walk and counts any difference in miri.HitTest.Stats (Mismatches). Both default to off.
Related
- UI Designer to author these assets visually.
- API: MiriGraphics reference, including
CMiriGraphicsScreenStack,FMiriGraphicsAsset,FMiriGraphicsWidgetFactory,FMiriGraphicsBindingLibrary,MUIStatics,UIWidgetComponent.
Engine sources
This page describes behavior implemented in these files of the engine repository, checked against commit 23111c146.
- Engine/Source/Gameplay/MiriGraphics/Api/MiriGraphics/FMiriGraphicsAsset.h
- Engine/Source/Gameplay/MiriGraphics/Api/MiriGraphics/FMiriGraphicsWidgetFactory.h
- Engine/Source/Gameplay/MiriGraphics/Api/MiriGraphics/CMiriGraphicsScreenStack.h
- Engine/Source/Gameplay/MiriGraphics/Api/MiriGraphics/FMiriGraphicsActionRegistry.h
- Engine/Source/Gameplay/MiriGraphics/Api/MiriGraphics/FMiriGraphicsControllerResolver.h
- Engine/Source/Gameplay/MiriGraphics/Api/MiriGraphics/FMiriGraphicsBindingLibrary.h
- Engine/Source/Gameplay/MiriGraphics/Api/MiriGraphics/FMiriGraphicsConverterRegistry.h
- Engine/Source/Gameplay/MiriGraphics/Api/MiriGraphics/FMiriGraphicsAnimPlayer.h
- Engine/Source/Gameplay/MiriGraphics/Api/MiriGraphics/FMiriGraphicsModalInputGate.h
- Engine/Source/Gameplay/MiriGraphics/Api/MiriGraphics/FMiriGraphicsInputConfig.h
- Engine/Source/Gameplay/MiriGraphics/Api/MiriGraphics/FMiriGraphicsGlyphTable.h
- Engine/Source/Gameplay/MiriGraphics/Api/MiriGraphics/Widgets/MGraphicsActionButton.h
- Engine/Source/Gameplay/GameHost/Api/GameHost/FUiActionGlyphs.h
- Engine/Source/Gameplay/GameHost/Api/GameHost/FUiRenderTargetResolver.h
- Engine/Source/Gameplay/MiriGraphics/Api/MiriGraphics/Widgets/MGraphicsRenderTargetImage.h
- Engine/Source/Gameplay/MiriGraphics/Api/MiriGraphics/Widgets/MGraphicsParticleEmitter.h
- Engine/Source/Gameplay/MiriGraphics/Api/MiriGraphics/Statics/MUIStatics.h
- Engine/Source/Gameplay/MiriGraphics/Api/MiriGraphics/ECS/Components/UIWidgetComponent.h
- Engine/Source/Gameplay/GameHost/Api/GameHost/MGameEngine.h