UIManager
UIManager owns the top-level UI element list and drives UI command submission each frame.
You access it through:
UI().setElements(uiElements);
The element list is a fixed-size UIElementRef[] array.
nullptr entries are not allowed.
static UIElementRef uiElements[] = { scoreLabel, healthLabel };
Setup
Register UI elements after StartEngine() and before StartGame().
#include "WolfEngine/WolfEngine.hpp"
#include "WolfEngine/Graphics/UserInterface/UIElements/WE_UIElements.hpp"
static UILabel scoreLabel(4, 4, 96, 7, "Score: 0", PL_GS_White, PALETTE_GRAYSCALE, 0, UIAnchor::TopLeft);
static UILabel healthLabel(4, 16, 96, 7, "HP: 100", PL_GS_White, PALETTE_GRAYSCALE, 0, UIAnchor::TopLeft);
static UIElementRef uiElements[] = { scoreLabel, healthLabel };
extern "C" void app_main() {
Engine().StartEngine();
UI().setElements(uiElements);
Engine().StartGame();
}
setElements
template <size_t N>
UI().setElements(const UIElementRef (&elements)[N]);
What it does:
- Copies the list into internal fixed storage using the compile-time array size
N - Wires each element to the manager pointer
- Assigns each element draw metadata (
m_drawOrder,m_layer) - Marks UI dirty if renderer/framebuffer has already been initialized
Bound rule:
Nmust be<= Settings.limits.maxUIElements(compile-time checked)- Use
UI().clearElements()to unregister everything
Dirty Behavior
BaseUIElement::markDirty() sets a manager-level dirty flag.
At render time:
- Renderer currently calls
UI().render()every frame. UIManager::render()iterates all registered elements and callsdraw(...)on each.- Elements submit
DrawCommandobjects (FillRect,Line,Circle,TextRun) viaRenderSys().submitDrawCommand(...).
The dirty flag still exists and is useful for future optimization/caching, but it no longer gates whether UI render is invoked.
Layout Notes
Game code sets UI layout through constructor arguments (x, y, w, h, layer, anchor).
Use anchors (TopLeft, BotCenter, Center, etc.) to place elements relative to screen edges or center.
The engine still resolves final screen rectangles with UITransform internally in BaseUIElement::resolveRect().
Note: UILabel, UIShape, and UIPanel are not aggregates (virtual base methods), so use constructors for initialization.