OAP Lizzard A game interface engine
Game interfaces, outside the game Settings

Documentation / XML guide

The XML guide

What UI XML is, how Lizzard reads it, and a first window.

World of Warcraft builds its interface from XML files and Lua. The XML says what exists and where: frames, the textures and text inside them, how they are anchored to each other, and which Lua runs when something happens. Addons use the same XML. Lizzard reads it too, so it can run an addon's windows outside the game.

This guide explains that XML the way Lizzard understands it, with examples you can copy and diagrams of what the less obvious rules do. It is written for addon makers and for anyone curious about how the game's windows fit together.

The game is the authority. Lizzard is a work in progress. Where it has measured the game, the guide says so; where it has had to guess, it says that too. If the game and this guide disagree, the game is right, and we would like to hear about it.

The pages of this guide

Files and loading

The .toc, the elements a file may hold at the top, and how other files are found.

Templates

virtual templates, inherits, mixins, and the order a frame is built in.

Names and keys

$parent in names, parentKey and parentArray, and finding a region by its key.

Anchors

The nine points, what one anchor does, offsets, and anchoring to another region.

Sizes and stretching

When the size counts, when anchors stretch a region, and when it has no place at all.

Layering

Strata, frame levels, draw layers and sublevels: what draws on top of what.

Scripts and load order

Script handlers, append and prepend, and when OnLoad and OnShow run.

Values and text

KeyValues, Attributes and text taken from the game's strings.

Buttons and new types

A button's state textures, label and fonts, and intrinsic frame types.

When something is missing

What Lizzard says about XML it can't build, and what it ignores without a word.

Element reference

Every element in UI.xsd, and which of its attributes and children Lizzard reads.

Extending the loader

For Lizzard's own code: adding an element or attribute, with its evidence and test.

A first window

A frame 300 by 200, in the middle of the screen, with a see-through black background and a title near the top:

MyWindow.xml

<Ui xmlns="http://www.blizzard.com/wow/ui/">
  <Frame name="MyWindow" parent="UIParent">
    <Size x="300" y="200"/>
    <Anchors>
      <Anchor point="CENTER"/>
    </Anchors>
    <Layers>
      <Layer level="BACKGROUND">
        <Texture parentKey="Background" setAllPoints="true">
          <Color r="0" g="0" b="0" a="0.6"/>
        </Texture>
      </Layer>
      <Layer level="OVERLAY">
        <FontString parentKey="Title" inherits="GameFontNormal" text="My window">
          <Anchors>
            <Anchor point="TOP" y="-10"/>
          </Anchors>
        </FontString>
      </Layer>
    </Layers>
    <Scripts>
      <OnLoad>
        self.Title:SetText("Hello")
      </OnLoad>
    </Scripts>
  </Frame>
</Ui>
What the first window's XML makes The screen, with MyWindow in its middle. The window's centre point sits on the screen's centre point. Its background fills it, and its title sits 10 units below its top edge. UIParent (the screen) Hello Title: TOP, y -10 CENTER on the screen's CENTER Size 300 × 200: one anchor needs a size Background: setAllPoints
The window's one anchor puts its centre on the screen's centre; its size does the rest. The background fills it, and the title sits 10 units below its top edge (a negative y moves down).

What each part does, and where the guide covers it:

  • parent="UIParent" puts the window inside UIParent, the frame that covers the screen, so it takes UIParent's scale. Templates explains where a parent can also come from.
  • <Size> and one <Anchor> place it. Anchors and Sizes and stretching explain why one anchor needs a size and two do not.
  • <Layers> hold its texture and text, drawn in layer order: the title is OVERLAY, above the BACKGROUND. Layering has the whole order.
  • parentKey="Title" lets the Lua find the font string as self.Title. Names and keys.
  • <OnLoad> runs once the window is built. Scripts and load order says exactly when.
  • text="My window" is replaced by the OnLoad's "Hello". A text that names one of the game's strings shows that string: Values and text.

Where each rule comes from

Each rule in this guide carries a label saying how Lizzard knows it. A rule measured on Retail says nothing about Forever until it is measured there too, so the label names the game.

LabelMeaning
Measured (Retail) A test addon, Lizzard's probe, ran the case in the game and recorded what the game did.
Blizzard's code Blizzard's own interface code relies on it, so it has to work this way.
Screenshot Seen in a picture of the game.
Guessed Not checked yet. Lizzard keeps every guess on a list, so each can be measured later.

The schema, UI.xsd

The game ships a schema file, UI.xsd, that lists every element and attribute its XML may use. Lizzard doesn't read every one of them yet. Rather than say from memory which ones it does, it measured them: while the game's interface loads, Lizzard notes every attribute and element its loader asks about. The element reference comes from that measurement. On Forever, Lizzard read about 91% of the attribute uses in the game's own interface XML.