View Single Post
11-06-20, 09:49 AM   #3
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
There is nothing wrong with using XML. If someone else has already created a template you want to use then it's a waste of effort duplicating it in any fashion. Once the widget has been created, it all ends up being the same in-game no matter the method used "read its parts and glue it together".

That said, you can use lua functions to build up widgets just as you would in XML. The "virtual" attribute means "Don't create unless specifically used" just like a function does nothing unless called.

Lua Code:
  1. local function DPBAuraTemplate(base, parent, name)
  2.     local f = CreateFrame(base, "$parent"..name, parent)
  3.     f.Icon = f:CreateTexture("parentIcon", "ARTWORK")
  4.     f.Duration = f:CreateFontstring("$parentDuration")
  5.     --- add the rest of the elements, position, size etc.
  6.    
  7.     return f -- return the frame
  8. end
  9.  
  10. local HelpAura1 = DPBAuraTemplate("Button", MyUnitFrame, "Aura1")
  11.  
  12. local HarmAura1 = DPBAuraTemplate("Frame", MyUnitFrame, "Aura21")
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 11-06-20 at 10:03 AM.
  Reply With Quote