Thread Tools Display Modes
04-06-13, 05:31 AM   #1
fRodzet
A Flamescale Wyrmkin
Join Date: Mar 2013
Posts: 114
Originally Posted by Resike View Post
Also you have to create the inhertited frame/button which points to the template in xml too.
True that is!

Creating Templates in XML is easy anyways, but for longer codes i think XML gets really messy and adding comments (<!-- xxx -->) in XML doesn't seem to make it more readable to me.
  Reply With Quote
04-06-13, 05:38 AM   #2
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by fRodzet View Post
True that is!

Creating Templates in XML is easy anyways, but for longer codes i think XML gets really messy and adding comments (<!-- xxx -->) in XML doesn't seem to make it more readable to me.
True that, i recently formatted a 4000+ line xml file, was fun, but at the end i could do it with closed eyes too. Some addons even use 14000-15000+ line xml codes too.
  Reply With Quote
04-06-13, 05:50 AM   #3
Ailae
A Rage Talon Dragon Guard
 
Ailae's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 318
Couldn't you create a function that creates the frame and then call on that function every time you create such a frame?

Lua Code:
  1. -- Creates an ordinary frame, just more awesome
  2. function CreateAwesomeFrame(name)
  3.     local f = CreateFrame("Frame", name, UIParent)
  4.     f:SetSize(128, 128) -- this is the really awesome bit
  5.     f:SetBackdrop({
  6.         bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
  7.         insets = {top = 0, left = 0, bottom = 0, right = 0},
  8.     })
  9.     f:SetBackdropColor(1, 1, 1, 0)
  10.     f:SetPoint("CENTER")
  11.    
  12.     return f
  13. end
  14.  
  15. local AwesomeFrame = CreateAwesomeFrame()
__________________
Oh, the simulated horror!
  Reply With Quote
04-06-13, 06:03 AM   #4
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by Ailae View Post
Couldn't you create a function that creates the frame and then call on that function every time you create such a frame?

Lua Code:
  1. -- Creates an ordinary frame, just more awesome
  2. function CreateAwesomeFrame(name)
  3.     local f = CreateFrame("Frame", name, UIParent)
  4.     f:SetSize(128, 128) -- this is the really awesome bit
  5.     f:SetBackdrop({
  6.         bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
  7.         insets = {top = 0, left = 0, bottom = 0, right = 0},
  8.     })
  9.     f:SetBackdropColor(1, 1, 1, 0)
  10.     f:SetPoint("CENTER")
  11.    
  12.     return f
  13. end
  14.  
  15. local AwesomeFrame = CreateAwesomeFrame()
Intresting, but i'm not sure it would work with all UI elements.
  Reply With Quote
04-06-13, 06:24 AM   #5
fRodzet
A Flamescale Wyrmkin
Join Date: Mar 2013
Posts: 114
Originally Posted by Ailae View Post
Couldn't you create a function that creates the frame and then call on that function every time you create such a frame?

Lua Code:
  1. -- Creates an ordinary frame, just more awesome
  2. function CreateAwesomeFrame(name)
  3.     local f = CreateFrame("Frame", name, UIParent)
  4.     f:SetSize(128, 128) -- this is the really awesome bit
  5.     f:SetBackdrop({
  6.         bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
  7.         insets = {top = 0, left = 0, bottom = 0, right = 0},
  8.     })
  9.     f:SetBackdropColor(1, 1, 1, 0)
  10.     f:SetPoint("CENTER")
  11.    
  12.     return f
  13. end
  14.  
  15. local AwesomeFrame = CreateAwesomeFrame()
Imma try that when i get home!

Ill tell you if it works
  Reply With Quote
04-06-13, 12:48 PM   #6
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Originally Posted by Ailae View Post
Couldn't you create a function that creates the frame and then call on that function every time you create such a frame?
Yes, we call that a frame factory or a factory function. You can see an example of its usage with my sStats addon. The core sStats addon has the factory function, while the display modules use it to create their frames.

However, iirc, if you want to create secure frames/buttons you need to use XML.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
04-06-13, 01:57 PM   #7
Ailae
A Rage Talon Dragon Guard
 
Ailae's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 318
Originally Posted by Seerah View Post
Yes, we call that a frame factory or a factory function. You can see an example of its usage with my sStats addon. The core sStats addon has the factory function, while the display modules use it to create their frames.

However, iirc, if you want to create secure frames/buttons you need to use XML.
Yeah, I too use them just like that. I find it much easier then mucking about with XML-files.

I'm fairly sure you don't even need to use XML for secure stuff either.
__________________
Oh, the simulated horror!
  Reply With Quote
04-06-13, 02:01 PM   #8
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
XML is not required for secure buttons/frames. You can use templates (which are xml).
http://www.wowpedia.org/SecureActionButtonTemplate
__________________
The cataclysm broke the world ... and the pandas could not fix it!

Last edited by Rilgamon : 04-06-13 at 02:04 PM.
  Reply With Quote
04-06-13, 06:17 PM   #9
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
The only time you need to use XML is if you are creating secure templates (virtual frames), and the only time you need to do that is if you are working with the secure header system -- for example, setting up a secure header for party frames where each unit frame will include an attached child unit frame for the party member's pet. See attached awesome MSPaint drawing for a better explanation.
Attached Thumbnails
Click image for larger version

Name:	childframetemplate.png
Views:	1093
Size:	9.3 KB
ID:	7661  
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
04-07-13, 10:00 AM   #10
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by Phanx View Post
The only time you need to use XML is if you are creating secure templates (virtual frames), and the only time you need to do that is if you are working with the secure header system -- for example, setting up a secure header for party frames where each unit frame will include an attached child unit frame for the party member's pet. See attached awesome MSPaint drawing for a better explanation.
And how can you import blizzard templates by only using lua?
  Reply With Quote
04-06-13, 06:22 AM   #11
fRodzet
A Flamescale Wyrmkin
Join Date: Mar 2013
Posts: 114
Originally Posted by Resike View Post
True that, i recently formatted a 4000+ line xml file, was fun, but at the end i could do it with closed eyes too. Some addons even use 14000-15000+ line xml codes too.
Chill dude! Did your eyes pop out?
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » How to create a Template using lua?


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