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

Documentation / XML guide

Templates

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

A template is an element marked virtual="true". Nothing is built from it when it loads: it waits until a frame names it in inherits, or Lua's CreateFrame is given its name. Templates can inherit templates, so a window can be built up in layers of shared parts.

A panel, a titled panel made from it, and a window made from both (MyMovableTemplate and MyOptionsMixin stand for your own)

<Frame name="MyPanelTemplate" virtual="true">
  <Size x="200" y="100"/>
  <Layers>
    <Layer level="BACKGROUND">
      <Texture parentKey="Bg" setAllPoints="true">
        <Color r="0" g="0" b="0" a="0.45"/>
      </Texture>
    </Layer>
  </Layers>
</Frame>

<Frame name="MyTitledPanelTemplate" inherits="MyPanelTemplate" virtual="true">
  <Layers>
    <Layer level="OVERLAY">
      <FontString parentKey="Title" inherits="GameFontNormal">
        <Anchors><Anchor point="TOP" y="-6"/></Anchors>
      </FontString>
    </Layer>
  </Layers>
</Frame>

<Frame name="MyOptions" parent="UIParent" inherits="MyTitledPanelTemplate, MyMovableTemplate"
       mixin="MyOptionsMixin">
  <Size x="320"/>
  <Anchors><Anchor point="CENTER"/></Anchors>
</Frame>

The order a frame is built in

When Lizzard builds MyOptions, it works through four steps. Each step can change what an earlier one set, so the element's own values, which come last, win.

The order MyOptions is built in First its templates, in the order inherits names them, each with its own templates first: MyPanelTemplate, MyTitledPanelTemplate, then MyMovableTemplate. Then its mixins. Then its own attributes. Then its own child elements, in the order written. Later steps win. 1. Templates, in the order inherits names them MyPanelTemplate MyTitledPanelTemplate's own template comes first: Size, Bg MyTitledPanelTemplate then the template itself: Title MyMovableTemplate then the next name in inherits 2. Mixins mixin="MyOptionsMixin" 3. Its own attributes parent, name, ... 4. Its own children, as written <Size x="320"/>, <Anchors> later steps win Result: 320 wide (its own) by 100 high (the template's)
The window's own <Size x="320"/> comes last and changes only the width; the height it leaves out keeps the 100 its template set.

Blizzard's code This is the order Blizzard's interface relies on, and Lizzard's probe compares whole templates built this way with the game's.

A template's frames, textures and font strings are made when it is applied, so MyOptions gets its own Bg and Title. Anchors from templates and the element's own add up rather than replace each other, unless they are for the same point: see Anchors.

Values a template gives when the element has none

  • parentKey and parentArray: a template can name the frame in its parent. Blizzard's Edit Mode reads self.Selection on frames whose template says parentKey="Selection". Blizzard's code
  • parent="UIParent": a frame with no parent of its own takes its template's. One of Blizzard's chat windows depends on it; without it, it drew about one and a half times too big. Screenshot

Mixins

mixin="A, B" copies the functions and values of the global tables A and B into the frame, so self:Method() works. secureMixin does the same. A table that doesn't exist yet is reported: "mixin 'A' not found". The <Mixins><Mixin key="A"/></Mixins> form works too, applied where it stands among the frame's children. Guessed whether the game applies that form before the frame's KeyValues.

Lua's CreateFrame("Frame", "Name", parent, "TemplateA, TemplateB") applies the templates the same way, then runs the frame's OnLoad.