FMiriGraphicsActionRegistry
Action name -> handler, for every .ui button and widget event whose action is not a built-in verb. One registry serves the packaged game, the editor's play-in-editor session and the test hosts, so a handler registered from a game module behaves the same in all of them.
- Module
- MiriGraphics
- Header
#include "MiriGraphics/FMiriGraphicsActionRegistry.h"- Namespace
Mowo
Handlers are stored as plain function pointers plus an opaque state the REGISTRANT allocated and frees (the template Register below instantiates in the caller's image): a std::function built in a game module and relocated or freed inside this library crosses allocators. An entry is swept with the module that registered it (FModuleAnchor::Here via owner), so a handler is never called into unloaded code.
Main thread only, like the screen stack.
Type aliases
| Alias | Description |
|---|---|
using FInvokeFn = void (*)(void* state, const FMiriGraphicsActionContext& context) | |
using FDestroyFn = void (*)(void* state) |
Public functions
| Returns | Name | Description |
|---|---|---|
FMiriGraphicsActionRegistry& | Get | |
FMiriGraphicsActionScope | ForActiveStack | Scope of the stack gameplay UI is on right now (the packaged game's, or play-in-editor's during a session; MUIStatics::GetActiveStack). |
FMiriGraphicsActionHandle | Register | handler is invocable as void() or void(const FMiriGraphicsActionContext&). |
FMiriGraphicsActionHandle | RegisterRaw | Takes ownership of state even when it refuses the registration (empty action), calling destroy on it. |
bool | Unregister | |
bool | IsRegistered | |
size_t | RemoveHost | Drop everything a host (a play session's stack) registered. |
size_t | RemoveScreen | |
size_t | RemoveModule | Drop every entry whose registering code lives in the unloading module; run by the module-unload broadcast. |
bool | Dispatch | Runs the narrowest handler registered for ctx.Action (or its verb before the first ':', with the rest as Payload). |
bool | HasAction | |
size_t | Count | |
bool | ReportUnhandled | Logs "no handler for action" once per action name. |
Function details
Get
static FMiriGraphicsActionRegistry& Get()ForActiveStack
static FMiriGraphicsActionScope ForActiveStack()Scope of the stack gameplay UI is on right now (the packaged game's, or play-in-editor's during a session; MUIStatics::GetActiveStack). Handlers registered against it are dropped when that session's stack goes away. A null Host scope (no stack yet) is global.
Register
template<typename F> FMiriGraphicsActionHandle Register(const std::string& action, F&& handler, const FMiriGraphicsActionScope& scope = FMiriGraphicsActionScope(), const void* owner = FModuleAnchor::Here())handler is invocable as void() or void(const FMiriGraphicsActionContext&). Registering the same (action, scope) again replaces the earlier handler (the earlier handle goes inert); a replacement from another module is logged as a warning.
RegisterRaw
FMiriGraphicsActionHandle RegisterRaw(const std::string& action, const FMiriGraphicsActionScope& scope, const void* owner, FInvokeFn invoke, FDestroyFn destroy, void* state)Takes ownership of state even when it refuses the registration (empty action), calling destroy on it.
Unregister
bool Unregister(uint64_t id)IsRegistered
bool IsRegistered(uint64_t id) constRemoveHost
size_t RemoveHost(const void* host)Drop everything a host (a play session's stack) registered.
RemoveScreen
size_t RemoveScreen(const void* host, const std::string& screen)RemoveModule
size_t RemoveModule(void* moduleHandle)Drop every entry whose registering code lives in the unloading module; run by the module-unload broadcast.
Dispatch
bool Dispatch(const FMiriGraphicsActionContext& context)Runs the narrowest handler registered for ctx.Action (or its verb before the first ':', with the rest as Payload). Returns whether one ran.
HasAction
bool HasAction(const std::string& action, const void* host = nullptr, const std::string& screen = std::string()) constCount
size_t Count() constReportUnhandled
bool ReportUnhandled(const std::string& action)Logs "no handler for action" once per action name. Returns true on the first report. A later registration of the name makes it report again.