Hello,
I am developing a unit frame addon, and am having some struggles with lacking documentation. I have a UnitFrame template which I want to dynamically populate with data, and I can spawn these using CreateControl, as in my example.
Code:
<GuiXml>
<TopLevelControl name="UnitFrame" hidden="false" virtual="true">
<Controls>
<Label name="$(parent)Name" text="Hello!" />
</Controls>
</GuiXml>
Lua Code:
Controls[0] = CreateControlFromVirtual("Target", GuiRoot, "UnitFrame")
TargetName:SetText("Bob")
Now, for the party and raid frames I need to do this for group1...group24, and at that point it becomes quite awkward. What I'd like to do is something like
Lua Code:
Controls[unitTag].Name:SetText("Bob")
, but I can't find any way to do this. Surely this must be doable without using massive if-statements?
I have considered creating one list for each element I may need to access, so I could have
Lua Code:
self.ControlsName = {
[group1] = Group1Name,
[group2] = Group2Name,
-- ...
}
self.ControlsHealthBar = {
[group1] = Group1HealthBar,
[group2] = Group2HealthBar,
-- ...
}
But this becomes quite verbose as well. Are there any options I am missing? I know about string evaluation/introspection, but I fear it might hurt performance a lot.