-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathraidroleindicator.lua
More file actions
119 lines (91 loc) · 3.03 KB
/
raidroleindicator.lua
File metadata and controls
119 lines (91 loc) · 3.03 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
--[[
# Element: Raid Role Indicator
Handles the visibility and updating of an indicator based on the unit's raid assignment (main tank or main assist).
## Widget
RaidRoleIndicator - A `Texture` representing the unit's raid assignment.
## Notes
This element updates by changing the texture.
## Options
.useAtlasSize - Makes the element use preprogrammed atlas' size instead of its set dimensions (boolean)
## Examples
-- Position and size
local RaidRoleIndicator = self:CreateTexture(nil, 'OVERLAY')
RaidRoleIndicator:SetSize(16, 16)
RaidRoleIndicator:SetPoint('TOPLEFT')
-- Register it with oUF
self.RaidRoleIndicator = RaidRoleIndicator
--]]
local _, ns = ...
local oUF = ns.oUF
local function Update(self, event)
local element = self.RaidRoleIndicator
local unit = self.unit
--[[ Callback: RaidRoleIndicator:PreUpdate()
Called before the element has been updated.
* self - the RaidRoleIndicator element
--]]
if(element.PreUpdate) then
element:PreUpdate()
end
local role, isShown
if(UnitInRaid(unit) and not UnitHasVehicleUI(unit)) then
if(GetPartyAssignment('MAINTANK', unit)) then
isShown = true
element:SetAtlas('RaidFrame-Icon-MainTank', element.useAtlasSize)
role = 'MAINTANK'
elseif(GetPartyAssignment('MAINASSIST', unit)) then
isShown = true
element:SetAtlas('RaidFrame-Icon-MainAssist', element.useAtlasSize)
role = 'MAINASSIST'
end
end
element:SetShown(isShown)
-- Apply visual raid role glow effect using ObjectPool
local addon = _G.SimpleUnitFrames
if addon and addon.IndicatorPoolManager then
if role == 'MAINTANK' then
addon.IndicatorPoolManager:ApplyCustomGlow(self, 1, 0.3, 0.3, 0.6) -- Red glow for tank
elseif role == 'MAINASSIST' then
addon.IndicatorPoolManager:ApplyCustomGlow(self, 1, 0.9, 0.3, 0.6) -- Orange glow for assist
else
addon.IndicatorPoolManager:Release(self, "custom_glow")
end
end
--[[ Callback: RaidRoleIndicator:PostUpdate(role)
Called after the element has been updated.
* self - the RaidRoleIndicator element
* role - the unit's raid assignment (string?)['MAINTANK', 'MAINASSIST']
--]]
if(element.PostUpdate) then
return element:PostUpdate(role)
end
end
local function Path(self, ...)
--[[ Override: RaidRoleIndicator.Override(self, event, ...)
Used to completely override the internal update function.
* self - the parent object
* event - the event triggering the update (string)
* ... - the arguments accompanying the event
--]]
return (self.RaidRoleIndicator.Override or Update)(self, ...)
end
local function ForceUpdate(element)
return Path(element.__owner, 'ForceUpdate')
end
local function Enable(self)
local element = self.RaidRoleIndicator
if(element) then
element.__owner = self
element.ForceUpdate = ForceUpdate
self:RegisterEvent('GROUP_ROSTER_UPDATE', Path, true)
return true
end
end
local function Disable(self)
local element = self.RaidRoleIndicator
if(element) then
element:Hide()
self:UnregisterEvent('GROUP_ROSTER_UPDATE', Path)
end
end
oUF:AddElement('RaidRoleIndicator', Path, Enable, Disable)