Thread Tools Display Modes
Prev Previous Post   Next Post Next
06/12/20, 03:49 PM   #1
QuantumPie
AddOn Author - Click to view addons
Join Date: Sep 2019
Posts: 32
Struggling to understand inherritence

I'm currently trying to develop an addon that tracks cool-downs of abilities on your bar. I have the main window made with two controls representing the front and back bar. Each of the two controls representing a bar will have 5 children containing the ability texture and a label overlapping. Instead of duplicating that layout 5 times I figured I could use inheritance but I don't quite understand how it works.

Currently my virtual control is (missing the label for now):
Lua Code:
  1. <Control name="BarTracker_Slot" virtual="true">
  2.     <Dimensions x="50" y="50"/>
  3.     <Controls>
  4.         <Texture name="$(parent)Tex">
  5.             <Anchor point="CENTER" relativePoint="CENTER"/>
  6.         </Texture>
  7.     </Controls>
  8. </Control>

And my top level is:
Lua Code:
  1. <TopLevelControl name="BarTrackerWindow">
  2.     <Controls>
  3.         <Backdrop name="$(parent)BG" alpha="1" centerColor="40000000" edgeColor="60000000" clampedToScreen="true" movable="true" mouseEnabled="true">
  4.             <Anchor point="TOPLEFT" relativeTo="$(parent)" relativePoint="CENTER" offsetX="0" offsetY="0"/>
  5.             <Dimensions x="250" y="100"/>
  6.             <Edge edgeSize="1"/>
  7.             <OnMouseEnter>WINDOW_MANAGER:SetMouseCursor(12);</OnMouseEnter>
  8.             <OnMouseExit>WINDOW_MANAGER:SetMouseCursor(0);</OnMouseExit>
  9.             <OnMoveStop>BarTracker.savePosition()</OnMoveStop>
  10.         </Backdrop>
  11.         <Control name="$(parent)Front">
  12.             <Anchor point="TOPLEFT" relativePoint="TOPLEFT" relativeTo="$(parent)BG"/>
  13.             <Dimensions x="250" y="50"/>
  14.         </Control>
  15.         <Control name="$(parent)Back">
  16.             <Anchor point="TOPLEFT" relativePoint="TOPLEFT" relativeTo="$(parent)Front"/>
  17.             <Dimensions x="250" y="50"/>
  18.         </Control>
  19. </TopLevelControl>

So how would I use the virtual in a loop to add it to the Front and Back control? I've been looking through CMX's code to try and figure it out but there is a lot and I can't figure out where they actually add the virtuals.

The other thing throwing me off is how would I reference it? The components all have their own name so the texture is "BarTracker_SlotTex". But how would I differentiate it while generating the virtual components since there will be 10 in total?
  Reply With Quote
 

ESOUI » Developer Discussions » Lua/XML Help » Struggling to understand inherritence

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