Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 89 lines (65 sloc) 2.036 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
--[[ Element: Raid Role Icon

Handles visibility and updating of `self.RaidRole` based upon the units
party assignment.

Widget

RaidRole - A Texture representing the units party assignment. This is can be
main tank, main assist or blank.

Notes

This element updates by changing the texture.

Examples

-- Position and size
local RaidRole = self:CreateTexture(nil, 'OVERLAY')
RaidRole:SetSize(16, 16)
RaidRole:SetPoint('TOPLEFT')
-- Register it with oUF
self.RaidRole = RaidRole

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 unit = self.unit
if(not UnitInRaid(unit)) then return end

local raidrole = self.RaidRole
if(raidrole.PreUpdate) then
raidrole:PreUpdate()
end

local inVehicle = UnitHasVehicleUI(unit)
if(GetPartyAssignment('MAINTANK', unit) and not inVehicle) then
raidrole:Show()
raidrole:SetTexture[[Interface\GROUPFRAME\UI-GROUP-MAINTANKICON]]
elseif(GetPartyAssignment('MAINASSIST', unit) and not inVehicle) then
raidrole:Show()
raidrole:SetTexture[[Interface\GROUPFRAME\UI-GROUP-MAINASSISTICON]]
else
raidrole:Hide()
end

if(raidrole.PostUpdate) then
return raidrole:PostUpdate(rinfo)
end
end

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

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

local Enable = function(self)
local raidrole = self.RaidRole

if(raidrole) then
raidrole.__owner = self
raidrole.ForceUpdate = ForceUpdate

self:RegisterEvent('GROUP_ROSTER_UPDATE', Path, true)

return true
end
end

local Disable = function(self)
local raidrole = self.RaidRole

if(raidrole) then
self:UnregisterEvent('GROUP_ROSTER_UPDATE', Path)
end
end

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