File src/ChorusAuraButtonTemplate.lua changed (mode: 100644) (index 10e7c58..01a6f6f) |
1 |
1 |
local DebuffTypeColor = DebuffTypeColor |
local DebuffTypeColor = DebuffTypeColor |
|
2 |
|
local GameTooltip = GameTooltip |
2 |
3 |
local GetTime = GetTime |
local GetTime = GetTime |
3 |
4 |
local UnitAura = UnitAura |
local UnitAura = UnitAura |
4 |
5 |
local UnitExists = UnitExists |
local UnitExists = UnitExists |
|
... |
... |
local UnitIsConnected = UnitIsConnected |
6 |
7 |
|
|
7 |
8 |
local Chorus = Chorus |
local Chorus = Chorus |
8 |
9 |
|
|
9 |
|
local function getUnit(f) |
|
10 |
|
local p = f:GetParent() |
|
11 |
|
local u = f.unit or f:GetAttribute('unit') |
|
12 |
|
if not u and p then |
|
13 |
|
u = p.unit or p:GetAttribute('unit') |
|
14 |
|
end |
|
15 |
|
return u |
|
16 |
|
end |
|
17 |
|
|
|
18 |
10 |
local function auraButtonValidate(auraButton) |
local function auraButtonValidate(auraButton) |
19 |
11 |
assert(auraButton ~= nil) |
assert(auraButton ~= nil) |
20 |
12 |
|
|
|
... |
... |
local function applyDuration(auraButton, now, totalDurationSec, expirationInstan |
142 |
134 |
end |
end |
143 |
135 |
|
|
144 |
136 |
local function auraButtonUpdateProcessor(self) |
local function auraButtonUpdateProcessor(self) |
145 |
|
local unitDesignation = getUnit(self) |
|
146 |
|
if not unitDesignation or not self.index then |
|
|
137 |
|
local unitDesignation = SecureButton_GetUnit(self) |
|
138 |
|
local index = self.index |
|
139 |
|
local filter = SecureButton_GetAttribute(self, 'filter') |
|
140 |
|
if not unitDesignation or not index then |
147 |
141 |
return |
return |
148 |
142 |
end |
end |
149 |
|
local name, _, _, _, _, durationSec, expirationInstance = UnitAura(unitDesignation, self.index, self.filter) |
|
|
143 |
|
local name, _, _, _, _, durationSec, expirationInstance = UnitAura(unitDesignation, index, filter) |
150 |
144 |
if not name then |
if not name then |
151 |
145 |
return |
return |
152 |
146 |
end |
end |
|
... |
... |
local function auraButtonEventProcessor(self, eventCategory) |
204 |
198 |
assert(string.len(eventCategory) >= 1) |
assert(string.len(eventCategory) >= 1) |
205 |
199 |
assert(string.len(eventCategory) <= 256) |
assert(string.len(eventCategory) <= 256) |
206 |
200 |
|
|
207 |
|
local p = self:GetParent() |
|
208 |
|
|
|
209 |
|
local u = getUnit(self) or 'none' |
|
|
201 |
|
local u = SecureButton_GetUnit(self) or 'none' |
210 |
202 |
assert(u ~= nil) |
assert(u ~= nil) |
211 |
203 |
assert('string' == type(u)) |
assert('string' == type(u)) |
212 |
204 |
u = string.lower(strtrim(u)) |
u = string.lower(strtrim(u)) |
|
... |
... |
local function auraButtonEventProcessor(self, eventCategory) |
225 |
217 |
assert('number' == type(i)) |
assert('number' == type(i)) |
226 |
218 |
i = math.min(math.max(0, math.abs(math.floor(i))), 8192) |
i = math.min(math.max(0, math.abs(math.floor(i))), 8192) |
227 |
219 |
|
|
228 |
|
local filter = self.filter |
|
229 |
|
if not filter and p then |
|
230 |
|
filter = p.filter |
|
231 |
|
end |
|
232 |
|
filter = filter or 'HELPFUL' |
|
|
220 |
|
local filter = SecureButton_GetAttribute(self, 'filter') |
233 |
221 |
assert(filter ~= nil) |
assert(filter ~= nil) |
234 |
222 |
assert('string' == type(filter)) |
assert('string' == type(filter)) |
235 |
223 |
filter = string.upper(strtrim(filter)) |
filter = string.upper(strtrim(filter)) |
|
... |
... |
local function auraButtonEventProcessor(self, eventCategory) |
239 |
227 |
apply(self, u, i, filter) |
apply(self, u, i, filter) |
240 |
228 |
end |
end |
241 |
229 |
|
|
|
230 |
|
function Chorus.auraButtonGameTooltipShow(self) |
|
231 |
|
GameTooltip:SetOwner(self, "ANCHOR_BOTTOMLEFT"); |
|
232 |
|
GameTooltip:SetFrameLevel(self:GetFrameLevel() + 2); |
|
233 |
|
local unitDesignation = SecureButton_GetUnit(self) or 'none' |
|
234 |
|
local filter = SecureButton_GetAttribute(self, 'filter') |
|
235 |
|
GameTooltip:SetUnitAura(unitDesignation, self.index, filter) |
|
236 |
|
end |
|
237 |
|
|
|
238 |
|
function Chorus.auraButtonGameTooltipHide() |
|
239 |
|
GameTooltip:Hide(); |
|
240 |
|
end |
|
241 |
|
|
242 |
242 |
function Chorus.auraButtonMain(self) |
function Chorus.auraButtonMain(self) |
243 |
243 |
local n = self:GetName() |
local n = self:GetName() |
244 |
244 |
if n then |
if n then |
File src/ChorusAuraFrameTemplate.lua changed (mode: 100644) (index 69dc29f..859d2b0) |
... |
... |
local auraWeightMap = { |
59 |
59 |
|
|
60 |
60 |
Chorus.auraWeightMap = auraWeightMap |
Chorus.auraWeightMap = auraWeightMap |
61 |
61 |
|
|
62 |
|
local function getUnit(f) |
|
63 |
|
local p = f:GetParent() |
|
64 |
|
local u = f.unit or f:GetAttribute('unit') |
|
65 |
|
if not u and p then |
|
66 |
|
u = p.unit or p:GetAttribute('unit') |
|
67 |
|
end |
|
68 |
|
return u |
|
69 |
|
end |
|
70 |
|
|
|
71 |
62 |
local function getAuraWeight(unitDesignation, auraIndex, filter) |
local function getAuraWeight(unitDesignation, auraIndex, filter) |
72 |
63 |
local name, _, _, _, category, durationSec, owner = UnitAura(unitDesignation, auraIndex, filter) |
local name, _, _, _, category, durationSec, owner = UnitAura(unitDesignation, auraIndex, filter) |
73 |
64 |
if not name then |
if not name then |
|
... |
... |
end |
131 |
122 |
local function auraFrameEventProcessor(self, eventCategory, ...) |
local function auraFrameEventProcessor(self, eventCategory, ...) |
132 |
123 |
assert(self ~= nil) |
assert(self ~= nil) |
133 |
124 |
|
|
134 |
|
local unitDesignation = getUnit(self) or 'none' |
|
|
125 |
|
local unitDesignation = SecureButton_GetUnit(self) or 'none' |
135 |
126 |
assert(unitDesignation ~= nil) |
assert(unitDesignation ~= nil) |
136 |
127 |
assert('string' == type(unitDesignation)) |
assert('string' == type(unitDesignation)) |
137 |
128 |
unitDesignation = string.lower(strtrim(unitDesignation)) |
unitDesignation = string.lower(strtrim(unitDesignation)) |
|
... |
... |
local function auraFrameEventProcessor(self, eventCategory, ...) |
152 |
143 |
end |
end |
153 |
144 |
end |
end |
154 |
145 |
|
|
155 |
|
local filter = self.filter or self:GetAttribute('filter') |
|
|
146 |
|
local filter = SecureButton_GetAttribute(self, 'filter') |
156 |
147 |
assert(filter ~= nil) |
assert(filter ~= nil) |
157 |
148 |
assert('string' == type(filter)) |
assert('string' == type(filter)) |
158 |
149 |
filter = string.upper(strtrim(filter)) |
filter = string.upper(strtrim(filter)) |
|
... |
... |
local function auraFrameEventProcessor(self, eventCategory, ...) |
178 |
169 |
break |
break |
179 |
170 |
end |
end |
180 |
171 |
|
|
181 |
|
b.unit = unitDesignation |
|
182 |
|
b.filter = filter |
|
183 |
|
|
|
184 |
172 |
local k = q[i] |
local k = q[i] |
185 |
173 |
assert(k ~= nil) |
assert(k ~= nil) |
186 |
174 |
assert('number' == type(k)) |
assert('number' == type(k)) |
|
... |
... |
local function auraFrameEventProcessor(self, eventCategory, ...) |
198 |
186 |
i = i + 1 |
i = i + 1 |
199 |
187 |
local b = t[i] |
local b = t[i] |
200 |
188 |
assert(b ~= nil) |
assert(b ~= nil) |
201 |
|
b.unit = unitDesignation |
|
202 |
|
b.filter = filter |
|
203 |
189 |
b.index = 0 |
b.index = 0 |
204 |
190 |
|
|
205 |
191 |
local func = b:GetScript('OnEvent') |
local func = b:GetScript('OnEvent') |
File src/ChorusProgressFrameTemplate.lua changed (mode: 100644) (index 0cda9d2..e69a0c1) |
... |
... |
local UnitPowerType = UnitPowerType |
14 |
14 |
|
|
15 |
15 |
local Chorus = Chorus |
local Chorus = Chorus |
16 |
16 |
|
|
17 |
|
local function getUnit(f) |
|
18 |
|
local p = f:GetParent() |
|
19 |
|
local u = f.unit or f:GetAttribute('unit') |
|
20 |
|
if not u and p then |
|
21 |
|
u = p.unit or p:GetAttribute('unit') |
|
22 |
|
end |
|
23 |
|
return u |
|
24 |
|
end |
|
25 |
|
|
|
26 |
17 |
local function validateProgressFrame(self) |
local function validateProgressFrame(self) |
27 |
18 |
assert(self ~= nil) |
assert(self ~= nil) |
28 |
19 |
|
|
|
... |
... |
local function validateProgressFrame(self) |
50 |
41 |
strategy = strtrim(strategy) |
strategy = strtrim(strategy) |
51 |
42 |
assert(string.len(strategy) >= 1) |
assert(string.len(strategy) >= 1) |
52 |
43 |
assert(string.len(strategy) <= 8192) |
assert(string.len(strategy) <= 8192) |
53 |
|
|
|
54 |
|
local unitDesignation = getUnit(self) or 'none' |
|
55 |
|
assert('string' == type(unitDesignation)) |
|
56 |
|
unitDesignation = string.lower(strtrim(unitDesignation)) |
|
57 |
|
assert(string.len(unitDesignation) >= 1) |
|
58 |
|
assert(string.len(unitDesignation) <= 256) |
|
59 |
44 |
end |
end |
60 |
45 |
end |
end |
61 |
46 |
|
|
|
... |
... |
end |
345 |
330 |
local function healthFrameEventProcessor(self) |
local function healthFrameEventProcessor(self) |
346 |
331 |
validateProgressFrame(self) |
validateProgressFrame(self) |
347 |
332 |
|
|
348 |
|
local unitDesignation = getUnit(self) or 'none' |
|
|
333 |
|
local unitDesignation = SecureButton_GetUnit(self) or 'none' |
349 |
334 |
|
|
350 |
335 |
assert(unitDesignation ~= nil) |
assert(unitDesignation ~= nil) |
351 |
336 |
assert('string' == type(unitDesignation)) |
assert('string' == type(unitDesignation)) |
|
... |
... |
end |
418 |
403 |
local function powerFrameEventProcessor(self) |
local function powerFrameEventProcessor(self) |
419 |
404 |
validateProgressFrame(self) |
validateProgressFrame(self) |
420 |
405 |
|
|
421 |
|
local unitDesignation = getUnit(self) or 'none' |
|
|
406 |
|
local unitDesignation = SecureButton_GetUnit(self) or 'none' |
422 |
407 |
|
|
423 |
408 |
assert(unitDesignation ~= nil) |
assert(unitDesignation ~= nil) |
424 |
409 |
assert('string' == type(unitDesignation)) |
assert('string' == type(unitDesignation)) |
File src/ChorusUnitButtonTemplate.lua changed (mode: 100644) (index 2e9065f..68bac1e) |
1 |
|
local tContains = tContains |
|
2 |
|
|
|
3 |
1 |
local Chorus = Chorus |
local Chorus = Chorus |
4 |
2 |
|
|
5 |
|
local function applySecureHandlerAttributeProcessor(secureHandlerFrame, unitButton) |
|
6 |
|
assert(secureHandlerFrame ~= nil) |
|
7 |
|
assert(unitButton ~= nil) |
|
8 |
|
|
|
9 |
|
--[[ All frames that are children to the unit button inherit the |
|
10 |
|
property of the 'unit' attribute of their parent. ]]-- |
|
11 |
|
|
|
12 |
|
secureHandlerFrame:WrapScript(unitButton, 'OnAttributeChanged', [=[ |
|
13 |
|
if not ('unit' == name) then |
|
14 |
|
return |
|
15 |
|
end |
|
16 |
|
|
|
17 |
|
local unitButton = self |
|
18 |
|
|
|
19 |
|
local t = unitButton:GetChildList(newtable()) |
|
20 |
|
local i = 0 |
|
21 |
|
while (i < #t) do |
|
22 |
|
i = i + 1 |
|
23 |
|
local e = t[i] |
|
24 |
|
if e then |
|
25 |
|
e:SetAttribute(name, value) |
|
26 |
|
end |
|
27 |
|
end |
|
28 |
|
]=]) |
|
29 |
|
end |
|
30 |
|
|
|
31 |
|
local function applyAttributeCascade(self, name, value) |
|
32 |
|
assert(self ~= nil) |
|
33 |
|
|
|
34 |
|
assert(name ~= nil) |
|
35 |
|
assert('string' == type(name)) |
|
36 |
|
name = strtrim(name) |
|
37 |
|
assert(string.len(name) >= 1) |
|
38 |
|
assert(string.len(name) <= 256) |
|
39 |
|
|
|
40 |
|
self[name] = value |
|
41 |
|
|
|
42 |
|
local t = {self:GetChildren()} |
|
43 |
|
local i = 0 |
|
44 |
|
while (i < #t) do |
|
45 |
|
i = i + 1 |
|
46 |
|
local e = t[i] |
|
47 |
|
if nil == e then |
|
48 |
|
break |
|
49 |
|
end |
|
50 |
|
e[name] = value |
|
|
3 |
|
function Chorus.unitButtonAttributeProcessor(self, name, value) |
|
4 |
|
--[[ This is required for UnitFrame_OnEnter to work, which is in turn |
|
5 |
|
used for unit game tooltips. The alternative is to wrap |
|
6 |
|
GameTooltip:SetUnit ourselves.]]-- |
|
7 |
|
if 'unit' == name then |
|
8 |
|
self[name] = value |
51 |
9 |
end |
end |
52 |
10 |
end |
end |
53 |
11 |
|
|
54 |
|
function Chorus.unitButtonAttributeChangedProcessor(self, name, value) |
|
55 |
|
assert(self ~= nil) |
|
56 |
|
|
|
57 |
|
assert(name ~= nil) |
|
58 |
|
assert('string' == type(name)) |
|
59 |
|
name = strtrim(name) |
|
60 |
|
assert(string.len(name) >= 1) |
|
61 |
|
assert(string.len(name) <= 256) |
|
62 |
|
|
|
63 |
|
if not tContains({'unit'}, name) then |
|
64 |
|
return |
|
65 |
|
end |
|
66 |
|
|
|
67 |
|
--[[ FIXME SecureGroupHandlerTemplate empties unit property for all children ]]-- |
|
68 |
|
if not value then |
|
69 |
|
return |
|
70 |
|
end |
|
71 |
|
|
|
72 |
|
applyAttributeCascade(self, name, value) |
|
73 |
|
end |
|
74 |
|
|
|
75 |
12 |
function Chorus.unitButtonMain(self) |
function Chorus.unitButtonMain(self) |
76 |
13 |
self:RegisterForClicks('AnyUp') |
self:RegisterForClicks('AnyUp') |
77 |
|
|
|
78 |
|
self:SetAttribute('type1', 'target') |
|
79 |
|
|
|
80 |
|
local secureHandlerFrame = _G[self:GetName() .. 'SecureHandlerAttributeFrame'] |
|
81 |
|
assert(secureHandlerFrame ~= nil) |
|
82 |
|
applySecureHandlerAttributeProcessor(secureHandlerFrame, self) |
|
83 |
|
|
|
84 |
|
applyAttributeCascade(self, 'unit', self:GetAttribute('unit')) |
|
|
14 |
|
self.unit = self:GetAttribute('unit') |
85 |
15 |
|
|
86 |
16 |
--[[ TODO Add menu popup for unit frames ]]-- |
--[[ TODO Add menu popup for unit frames ]]-- |
87 |
17 |
--[[ TODO Add role indicator ]]-- |
--[[ TODO Add role indicator ]]-- |
88 |
|
--[[ TODO Add raid mark indicator ]]-- |
|
89 |
18 |
end |
end |
File src/ChorusUnitButtonTemplate.xml changed (mode: 100644) (index cd95b0f..7b81d4a) |
6 |
6 |
<Frame name="$parentSecureHandlerAttributeFrame" inherits="SecureHandlerAttributeTemplate"/> |
<Frame name="$parentSecureHandlerAttributeFrame" inherits="SecureHandlerAttributeTemplate"/> |
7 |
7 |
</Frames> |
</Frames> |
8 |
8 |
<Scripts> |
<Scripts> |
9 |
|
<OnAttributeChanged> |
|
10 |
|
Chorus.unitButtonAttributeChangedProcessor(self, name, value); |
|
11 |
|
</OnAttributeChanged> |
|
12 |
|
<OnLoad> |
|
13 |
|
Chorus.unitButtonMain(self); |
|
14 |
|
</OnLoad> |
|
|
9 |
|
<OnAttributeChanged>Chorus.unitButtonAttributeProcessor(self);</OnAttributeChanged> |
15 |
10 |
<OnEnter function="UnitFrame_OnEnter"/> |
<OnEnter function="UnitFrame_OnEnter"/> |
16 |
11 |
<OnLeave function="UnitFrame_OnLeave"/> |
<OnLeave function="UnitFrame_OnLeave"/> |
|
12 |
|
<OnLoad>Chorus.unitButtonMain(self);</OnLoad> |
17 |
13 |
</Scripts> |
</Scripts> |
|
14 |
|
<Attributes> |
|
15 |
|
<!-- When the button is clicked with left mouse button, |
|
16 |
|
given no modifier keys are held, |
|
17 |
|
target game unit that corresponds to the button. --> |
|
18 |
|
<Attribute name="type1" type="string" value="target"/> |
|
19 |
|
</Attributes> |
18 |
20 |
</Button> |
</Button> |
19 |
21 |
<Button name="ChorusTinyUnitButtonTemplate" inherits="ChorusUnitButtonTemplate" virtual="true"> |
<Button name="ChorusTinyUnitButtonTemplate" inherits="ChorusUnitButtonTemplate" virtual="true"> |
20 |
22 |
<Size> |
<Size> |
File src/ChorusUnitNameFrameTemplate.lua changed (mode: 100644) (index a27b822..ff0d56d) |
... |
... |
local function unitNameEventProcessor(self) |
11 |
11 |
local label = self.label |
local label = self.label |
12 |
12 |
assert(label ~= nil) |
assert(label ~= nil) |
13 |
13 |
|
|
14 |
|
local unitDesignation = self.unit or 'none' |
|
|
14 |
|
local unitDesignation = SecureButton_GetUnit(self) or 'none' |
15 |
15 |
assert(unitDesignation ~= nil) |
assert(unitDesignation ~= nil) |
16 |
16 |
assert('string' == type(unitDesignation)) |
assert('string' == type(unitDesignation)) |
17 |
17 |
unitDesignation = string.lower(strtrim(unitDesignation)) |
unitDesignation = string.lower(strtrim(unitDesignation)) |
|
... |
... |
function Chorus.unitNameFrameMain(self) |
65 |
65 |
assert(label ~= nil) |
assert(label ~= nil) |
66 |
66 |
self.label = label |
self.label = label |
67 |
67 |
|
|
68 |
|
self.unit = 'none' |
|
69 |
|
|
|
70 |
68 |
--[[ FIXME Sometimes some unit buttons in raid frames cannot be clicked. ]]-- |
--[[ FIXME Sometimes some unit buttons in raid frames cannot be clicked. ]]-- |
71 |
69 |
self:SetScript('OnEvent', unitNameEventProcessor) |
self:SetScript('OnEvent', unitNameEventProcessor) |
72 |
70 |
|
|