Thread Tools Display Modes
Prev Previous Post   Next Post Next
03-15-18, 09:01 AM   #1
Ethly
A Fallenroot Satyr
Join Date: Mar 2018
Posts: 23
Accessing fontstring from secure snippet

Hello. I'm trying to implement simple raid frames. Here's what I've come up with so far:

XML:
XML Code:
  1. <Ui xmlns="http://www.blizzard.com/wow/ui/">
  2.   <Frame name="MyFrames_UnitTemplate" inherits="SecureUnitButtonTemplate" virtual="true">
  3.     <Size x="36" y="36"/>
  4.     <Layers>
  5.       <Layer level="OVERLAY">
  6.         <Texture>
  7.           <Color r="0" g="0" b="0"/>
  8.         </Texture>
  9.         <FontString parentKey="name" inherits="GameFontHighlight" text="Name"/>
  10.       </Layer>
  11.     </Layers>
  12.     <Attributes>
  13.       <Attribute name="type1" type="string" value="target"/>
  14.     </Attributes>
  15.   </Frame>
  16.  
  17.   <Frame name="MyFrames_SecureGroupTemplateHeader" parent="UIParent" inherits="SecureGroupHeaderTemplate">
  18.     <Anchors>
  19.       <Anchor point="TOP"/>
  20.     </Anchors>
  21.     <Attributes>
  22.       <Attribute name="showParty" type="boolean" value="true"/>
  23.       <Attribute name="showRaid" type="boolean" value="true"/>
  24.       <Attribute name="showPlayer" type="boolean" value="true"/>
  25.       <Attribute name="showSolo" type="boolean" value="true"/>
  26.       <Attribute name="maxColumns" type="number" value="8"/>
  27.       <Attribute name="unitsPerColumn" type="number" value="5"/>
  28.       <Attribute name="columnAnchorPoint" type="string" value="TOP"/>
  29.       <Attribute name="point" type="string" value="LEFT"/>
  30.       <Attribute name="template" type="string" value="MyFrames_UnitTemplate"/>
  31.       <Attribute name="templateType" type="string" value="Button"/>
  32.       <Attribute name="columnSpacing" type="number" value="1"/>
  33.     </Attributes>
  34.   </Frame>
  35. </Ui>
LUA:
Lua Code:
  1. MyFrames_SecureGroupTemplateHeader:SetAttribute("initialConfigFunction", [=[
  2.   print("icf", self:GetName())
  3.   self:SetAttribute("refreshUnitChange", [[
  4.     print("ruc", self:GetName(), self:GetAttribute("unit"))
  5.     --self.name:SetText(UnitName(self:GetAttribute("unit")))
  6.   ]])
  7. ]=])
  8.  
  9. 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).

Last edited by Ethly : 03-15-18 at 10:12 AM.
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » Accessing fontstring from secure snippet

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off