Skip to content

WoW FrameXML Layout

games/world-of-warcraft/menu/stb_wowxml.h parses FrameXML using DDX-style schema tables and owns the element registry, inheritance, parent/relative-frame links, anchors, and rectangle calculation. ui_xml.c supplies Lua bindings, drawing, and input. Production and UI tests compile the single-header implementation with STB_WOW_XML_IMPLEMENTATION in ui_xml.c.

DDX Schema Tables (stb_wowxml.h)

stb_wowxml.h parses FrameXML grammar through declarative descriptor tables:

  • uiwow_node_types[]: Maps XML element tags (Frame, ScrollFrame, Slider, Model, Texture, FontString, Button, CheckButton, EditBox, ThumbTexture, etc.) to uiWowXmlType_t and intrinsic flags (EF_IS_SCROLLFRAME, EF_CHECKBUTTON, EF_FOCUSABLE).
  • uiwow_shared_attrs[]: Maps XML attributes (file, text, hidden, virtual, setAllPoints, password, id, wordWrap, checked) to element fields or flags through uiWowAttrType_t.
  • uiwow_script_tags[]: Dispatches <Scripts> child elements (OnClick, OnLoad, OnShow, OnEnter, OnLeave, OnEnterPressed, OnEscapePressed, OnTabPressed, OnMouseWheel, OnUpdateModel, OnUpdate) directly to uiWowXmlStr_t fields.
  • uiwow_button_part_tags[]: Table-drives button texture layers (NormalTexture, PushedTexture, HighlightTexture, CheckedTexture) and their associated texcoord flags.
  • uiwow_button_text_tags[]: Table-drives button font strings (NormalText, HighlightText, DisabledText) to uiWowXmlButtonTextState_t.
  • uiwow_point_factors[]: Maps anchor points (TOPLEFT, TOP, CENTER, BOTTOMRIGHT, etc.) to X and Y bounding-box interpolation factors, eliminating branching ladders in anchor math.
  • uiwow_layer_levels[], uiwow_justify_h[], uiwow_justify_v[]: Table-driven string-to-enum lookups.

FrameXML Font definitions are non-drawing templates. Their font, FontHeight, color, and text justification flow through inherits into font strings and button text. An explicit property on the receiving element overrides the inherited value. Lua font strings support GetFont, SetFont, and SetFontObject, and a change invalidates natural text measurements. Fonts are cached by path and size. If an authored font cannot be loaded, the menu reports the failure and tries the default interface font.

Geometry contract

  • <Size><AbsDimension .../></Size> supplies explicit axes after conversion from the native 1024x768 grid.
  • Two authored anchors can derive width and height independently. Anchor order does not affect a stretched axis. An anchor with an omitted target or an exact $parent target uses the structural parent, even when that parent has no name.
  • XML setAllPoints fills the parent rectangle. Lua SetAllPoints can also fill another frame. ClearAllPoints clears both anchors and the fill constraint. A top-level UIParent with no authored size or anchors fills the full interface canvas.
  • A self-anchor falls back to the parent in XML, and a cyclic relative layout falls back to canvas bounds at the recursive edge. Cyclic structural parents are rejected.
  • An unconstrained FontString axis uses the renderer's natural text measurement. Text changes invalidate that measurement.
  • Any other unresolved axis remains zero. Never invent a default rectangle: it hides missing inheritance, relative-frame, or anchor support and makes invalid XML appear usable.
  • Drawing logs UIWow: unresolved FrameXML geometry once per affected element with its frame and source-file names. The zero extent also prevents an unresolved Button/EditBox from receiving a fabricated hit target.

Lua scroll offsets and ranges use the same vertical UI units as frame sizes. The range reflects the content bounds at query time and can be zero. Children declared inside ScrollChild contribute regardless of their name. Shrinking content clamps the current offset to the new range.

Lua GetTime() exposes the menu clock in seconds. The existing ow3.time() binding returns milliseconds.

Focused verification:

make test-wow-hud-xml
make run-wow ARGS='+com_frame_limit 100'

The standalone test covers authored size, zero unresolved size, one-shot diagnostics, and renderer-measured FontString dimensions.

Native-only production UI

Production does not ship project-owned files under share/Interface/FrameXML/. Load Blizzard FrameXML from the client archives when it exists. If classic WoW creates presentation outside FrameXML, reproduce that runtime path in C instead of authoring a parallel XML layout. Test MPQs may carry reduced fixtures under the original Blizzard paths, but production must resolve those paths from WoW data.

Classic interface.MPQ has no loading-screen FrameXML, so menu_loading.c draws the server-selected map texture and title at runtime. The custom message inbox and its combined tutorial/message alert strip also remain runtime presentation because no Blizzard FrameXML owns that project-specific data model. Their tutorial alert art and dimensions follow the native TutorialFrame contract.

Native tutorial layout and height

menu_windows.c loads Fonts.xml, BasicControls.xml, UIPanelTemplates.xml, and TutorialFrame.xml from interface.MPQ. These own the 230px frame, backdrop, zero-height natural FontStrings, UICheckButtonTemplate, button textures, and input rectangles. The parser supports native CheckedTexture state; C only binds localized strings and client state.

TutorialFrame_Update in Blizzard's TutorialFrame.lua runs TutorialFrame:SetHeight(TutorialFrameText:GetHeight() + 62). The C binding applies the same formula before drawing the backdrop: it measures the 210px-wide wrapped body, caches the FontString's natural height, then changes only the native frame's runtime height. Never replace the zero-height fields with guessed fixed XML heights.

The welcome tutorial (id == 42) has another native Lua lifecycle rule: TutorialFrame_CheckIntro moves the frame's BOTTOM anchor to UIParent.CENTER with a -90 Y offset. That position assumes Blizzard's original body height; retaining the bottom anchor after a long localized body expands shifts the popup upward. The runtime therefore uses CENTER/CENTER for tutorial 42 so the resized bounds remain vertically centered. Ordinary help retains the XML-authored BOTTOM/BOTTOM anchor at +100. Both go through FrameXML's runtime SetPoint representation rather than changing or replacing native XML.

Inspect the original client source with:

build/bin/mpqtool -mpq data/world-of-warcraft/interface.MPQ cat 'Interface/FrameXML/TutorialFrame.xml'

The native Lua source can be inspected alongside the XML:

build/bin/mpqtool -mpq data/world-of-warcraft/interface.MPQ cat 'Interface/FrameXML/TutorialFrame.lua'

Glue scripts and text

Focused EditBoxes send OnTextChanged for edits. The classic arg1 flag distinguishes keyboard input from a script calling SetText. Frame callbacks restore the enclosing this and event when they return.

FontStrings inherit normal or thick outlines from their font objects. The outline follows the text alpha and scroll clipping. Lua can read and set the outline through GetFont and SetFont.

Scripts can install a reporter with seterrorhandler and retrieve it with geterrorhandler. Syntax and callback errors reach the reporter. A failure inside the reporter goes directly to the engine console.

Slider and StatusBar nodes retain their authored minValue, maxValue, defaultValue, valueStep, and orientation through template inheritance. Their Lua range/value methods clamp values, and slider steps round to the nearest step from the minimum. A changed value dispatches OnValueChanged with the value in arg1. Slider tracks accept mouse clicks and dragging; ThumbTexture follows the value, while BarTexture is cropped to the filled fraction. ScrollFrame scrollbar parts retain their existing scroll handling.

Frames can register up to 16 named events with RegisterEvent, UnregisterEvent, UnregisterAllEvents, and IsEventRegistered. Dispatch snapshots recipients, honors unregistration during a callback, and preserves nested this, event, and arg1 through arg9 contexts. Recursion is bounded to 16 levels. The local character-list refresh emits CHARACTER_LIST_UPDATE; additional game events require explicit producers.

ScrollFrame supports assigning and retrieving a scroll child and querying or setting horizontal and vertical offsets in UI units. Ranges are recomputed from content bounds and clamp offsets when content changes. Drawn descendants accumulate offsets and intersect nested viewport clips. Scrollbar thumbs use their track orientation for dragging. Input hit testing applies the same nested viewport offsets and clips.

Lua CreateFrame creates supported frame types with optional named parent and inheritance; frames can create texture and font-string regions. Named objects are published as globals, duplicate names and invalid parents are rejected, and stale Lua frame handles cannot address newly reused element slots. Runtime creation remains subject to the shared FrameXML element limit.