Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 93 lines (71 sloc) 2.3 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
--[[ Element: LFD Role Icon

Toggles visibility of the LFD role icon based upon the units current dungeon
role.

Widget

LFDRole - A Texture containing the LFD role icons at specific locations. Look
at the default LFD role icon texture for an example of this.
Alternatively you can look at the return values of
GetTexCoordsForRoleSmallCircle(role).

Notes

The default LFD role texture will be applied if the UI widget is a texture and
doesn't have a texture or color defined.

Examples

-- Position and size
local LFDRole = self:CreateTexture(nil, "OVERLAY")
LFDRole:SetSize(16, 16)
LFDRole:SetPoint("LEFT", self)
-- Register it with oUF
self.LFDRole = LFDRole

Hooks

Override(self) - Used to completely override the internal update function.
Removing the table key entry will make the element fall-back
to its internal function again.
]]

local parent, ns = ...
local oUF = ns.oUF

local Update = function(self, event)
local lfdrole = self.LFDRole
if(lfdrole.PreUpdate) then
lfdrole:PreUpdate()
end

local role = UnitGroupRolesAssigned(self.unit)
if(role == 'TANK' or role == 'HEALER' or role == 'DAMAGER') then
lfdrole:SetTexCoord(GetTexCoordsForRoleSmallCircle(role))
lfdrole:Show()
else
lfdrole:Hide()
end

if(lfdrole.PostUpdate) then
return lfdrole:PostUpdate(role)
end
end

local Path = function(self, ...)
return (self.LFDRole.Override or Update) (self, ...)
end

local ForceUpdate = function(element)
return Path(element.__owner, 'ForceUpdate')
end

local Enable = function(self)
local lfdrole = self.LFDRole
if(lfdrole) then
lfdrole.__owner = self
lfdrole.ForceUpdate = ForceUpdate

if(self.unit == "player") then
self:RegisterEvent("PLAYER_ROLES_ASSIGNED", Path, true)
else
self:RegisterEvent("GROUP_ROSTER_UPDATE", Path, true)
end

if(lfdrole:IsObjectType"Texture" and not lfdrole:GetTexture()) then
lfdrole:SetTexture[[Interface\LFGFrame\UI-LFG-ICON-PORTRAITROLES]]
end

return true
end
end

local Disable = function(self)
local lfdrole = self.LFDRole
if(lfdrole) then
self:UnregisterEvent("PLAYER_ROLES_ASSIGNED", Path)
self:UnregisterEvent("GROUP_ROSTER_UPDATE", Path)
end
end

oUF:AddElement('LFDRole', Path, Enable, Disable)
Something went wrong with that request. Please try again.