Thread Tools Display Modes
09/17/24, 07:29 PM   #1
nilo
Join Date: Feb 2022
Posts: 17
Question How to append textures to unitframes?

Helloo
I'm a begginer at addon dev and have a question
I have this code that displays on screen an icon representing the role of each member in the group, now I'm trying to figure out how to append the icons to the default group frames.

Code:
function Test()
    for i = 1, GetGroupSize() do
        local unitTag = GetGroupUnitTagByIndex(i)
        local unitFrame = UNIT_FRAMES:GetFrame(unitTag)
        d(unitFrame)

        local frameName = "TestFrame" .. i

        local GroupMemberFrame = WM:CreateTopLevelWindow(frameName)
        GroupMemberFrame:SetDimensions(25, 25)
        GroupMemberFrame:ClearAnchors()
        GroupMemberFrame:SetMouseEnabled(true)
        GroupMemberFrame:SetMovable(true)
        GroupMemberFrame:SetHidden(not LGRI.savedVars.visible)
        GroupMemberFrame:SetClampedToScreen(true)
        GroupMemberFrame:SetHandler("OnMoveStop", function() getPos() end)

        GroupMemberRoleIcon = WM:CreateControl(frameName .. "Teste" .. i, GroupMemberFrame, CT_TEXTURE)
        GroupMemberRoleIcon:SetDimensions(25, 25)
        GroupMemberRoleIcon:SetAnchor(CENTER, GroupMemberFrame, CENTER, 0, 0)
        GroupMemberRoleIcon:SetTexture(Group[i].RoleIcon)
        
        GroupMemberFrame:SetAnchor(TOPLEFT, GuiRoot, TOPLEFT, 250, 100 + (i * 40))
        
    end
end
I've tried this but it crashes the game for some reason
Code:
GroupMemberFrame:SetAnchor(TOPLEFT, unitFrame, TOPLEFT, 0, 0)
  Reply With Quote
09/19/24, 02:46 AM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 5,187
Your frame TLC should be created only once.
Then add each role icon to it in your loop.
change the size of the TLC on x axis to 25xgroup size, or use SetResizeToFitDescendants to auto change the size on x axis.
Anchor first role icon left to tlc left and each next role icon left to the previous role icon right.
This will give you 1 tlc with e. G. 4 role icons from left to right.

If you create 1 tlc for each icon you'd have many movable non connected controls in the end.

Check the WIKI for SetAnchor to see how it works.
  Reply With Quote
09/19/24, 10:26 AM   #3
nilo
Join Date: Feb 2022
Posts: 17
Okay, if I understand correctly what you're suggesting that will give me a single TLC with my icons anchored to it, but is there a way to anchor this TLC or the icons themselves into base game UI components such as the raid unit frames and small group unit frames?

Example: for each group member game creates a unit frame, how to anchor an icon directly to each group member frame
  Reply With Quote
09/19/24, 04:37 PM   #4
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 5,187
Use addons like merTorchbug improved or zgoo to inspect the controls below the mouse cursor to find their names.

/tbm or /tbug mouse or /zgoo mouse

Then anchor your control to that vanilla control, after it has been created. If you set the parent of your custom control the same as the vanilla controls you do not even need to create your own TLC. Just reuse the existing game vanilla TLC so it hides and shows with it automatically.

You can also check vanilla lua and xml code on github/download it from esoui and search it locally in your IDE.
Should be in esoui/ingame/group or similar.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » How to append textures to unitframes?


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