View Single Post
06/12/20, 08:35 PM   #2
Dolgubon
 
Dolgubon's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2016
Posts: 409
So, there's two ways to use a template:
1. You can use it in the xml file2. You can use it in Lua code.


Note that stuff like loops is only possible in Lua code.


XML file:

With XML files, you'll need to add inherits="BarTracker_Slot". With this option, it's pretty straightforward for how the names work: exactly as the names normally work within xml. Like, whatever the control is, imagine the template info is just 'slotted' where the control is. So imagining the Front gets the BarTracker_Slot template. Then you have that control's name is the same as the name you give it (BarTrackerWindowFront) and there will be a texture under it created with name="$(parent)Tex" which will evaluate to BarTrackerWindowFrontTex.


Lua file

Within the Lua file you can use WINDOW_MANAGER:CreateControlFromVirtual(controlName, parentControl, templateToUse). So say you wanted to create a control under the BarTracker_Slot which has the template. You'd do WINDOW_MANAGER:CreateControlFromVirtual("BarTrackerWindowFrontChildNameWhateverYouWant", BarTrackerWindowFront, "BarTracker_Slot").
Then the control name is BarTrackerWindowFrontChildNameWhateverYouWant, and there's a control created under (following xml name rules) it with the name BarTrackerWindowFrontChildNameWhateverYouWantTex. Since this is in Lua code, you can use loops, ifs, etc.
  Reply With Quote