Hello. I'm trying to implement simple raid frames. Here's what I've come up with so far:
XML:
XML Code:
<Ui xmlns="http://www.blizzard.com/wow/ui/">
<Frame name="MyFrames_UnitTemplate" inherits="SecureUnitButtonTemplate" virtual="true">
<Size x="36" y="36"/>
<Layers>
<Layer level="OVERLAY">
<Texture>
<Color r="0" g="0" b="0"/>
</Texture>
<FontString parentKey="name" inherits="GameFontHighlight" text="Name"/>
</Layer>
</Layers>
<Attributes>
<Attribute name="type1" type="string" value="target"/>
</Attributes>
</Frame>
<Frame name="MyFrames_SecureGroupTemplateHeader" parent="UIParent" inherits="SecureGroupHeaderTemplate">
<Anchors>
<Anchor point="TOP"/>
</Anchors>
<Attributes>
<Attribute name="showParty" type="boolean" value="true"/>
<Attribute name="showRaid" type="boolean" value="true"/>
<Attribute name="showPlayer" type="boolean" value="true"/>
<Attribute name="showSolo" type="boolean" value="true"/>
<Attribute name="maxColumns" type="number" value="8"/>
<Attribute name="unitsPerColumn" type="number" value="5"/>
<Attribute name="columnAnchorPoint" type="string" value="TOP"/>
<Attribute name="point" type="string" value="LEFT"/>
<Attribute name="template" type="string" value="MyFrames_UnitTemplate"/>
<Attribute name="templateType" type="string" value="Button"/>
<Attribute name="columnSpacing" type="number" value="1"/>
</Attributes>
</Frame>
</Ui>
LUA:
Lua Code:
MyFrames_SecureGroupTemplateHeader:SetAttribute("initialConfigFunction", [=[
print("icf", self:GetName())
self:SetAttribute("refreshUnitChange", [[
print("ruc", self:GetName(), self:GetAttribute("unit"))
--self.name:SetText(UnitName(self:GetAttribute("unit")))
]])
]=])
MyFrames_SecureGroupTemplateHeader:Show()
It works with static label, but I'm struggling to set name dynamically. I've commented line that does not work. As far as I understood, self refers to frame handle and this frame handle does not have "name" key (which I expected to be set from XML parentKey attribute). I tried to use self:GetFrameRef("name"), but it returns null. I guess I have to register it earlier, but I can't figure out how do I do that. UnitName is not available either, so I'm further confused atm. I guess, I'm doing something seriously wrong. If possible, I prefer to keep XML for UI layouts instead of coding it all with Lua. Also, if possible, it should work in combat (so people entering/leaving raid won't brake frames, that's why I'm using SecureGroupHeaderTemplate).