Nenue@59
|
1 -- Veneer
|
Nenue@59
|
2 -- BuffFrame.lua
|
Nenue@59
|
3 -- Created: 7/27/2016 8:08 PM
|
Nenue@59
|
4 -- %file-revision%
|
Nenue@62
|
5 --[[
|
Nenue@62
|
6 Adds progress bars and cooldown swirls to buffbutton frames
|
Nenue@60
|
7
|
Nenue@62
|
8 Known Limitations:
|
Nenue@62
|
9 - Individual BuffButton frames are created upon use, making it difficult to do any sort of securestate priming
|
Nenue@62
|
10 - TempEnchant info returns relative values only, and they don't synchronize with aura events
|
Nenue@62
|
11 - BuffButtons can only be hidden/shown by blizzcode, so functions doing that have to be accounted for
|
Nenue@62
|
12 --]]
|
Nenue@62
|
13
|
Nenue@75
|
14 local BUFFS_PER_ROW = 12
|
Nenue@64
|
15 local BUFF_BUTTON_SIZE = 48
|
Nenue@86
|
16 local BUFF_BUTTON_SPACING_H = 5
|
Nenue@71
|
17 local BUFF_BUTTON_SPACING_V = 14
|
Nenue@64
|
18 local BUFF_PROGRESS_SIZE = 4
|
Nenue@86
|
19 local BUFF_PROGRESS_INSET = 2
|
Nenue@86
|
20 local PROGRESS_ANCHOR = 'BOTTOM'
|
Nenue@86
|
21 local PROGRESS_PARENT
|
Nenue@86
|
22 local PROGRESS_OFFSET = 1
|
Nenue@106
|
23 local BUFF_MAX_DISPLAY = 24
|
Nenue@106
|
24 local DEBUFF_MAX_DISPLAY = 12
|
Nenue@86
|
25
|
Nenue@68
|
26 local BUFF_BUTTON_ZOOM = .15
|
Nenue@86
|
27 local BORDER_SIZE_L = 2
|
Nenue@86
|
28 local BORDER_SIZE_R = 2
|
Nenue@86
|
29 local BORDER_SIZE_U = 2
|
Nenue@86
|
30 local BORDER_SIZE_D = 2
|
Nenue@75
|
31 local BUFF_FRAMES_X = -230
|
Nenue@75
|
32 local BUFF_FRAMES_Y = -4
|
Nenue@64
|
33
|
Nenue@86
|
34 local COUNT_ANCHOR = 'TOPRIGHT'
|
Nenue@86
|
35 local COUNT_INSET = 4
|
Nenue@86
|
36 local COUNT_PARENT
|
Nenue@86
|
37
|
Nenue@86
|
38 local DURATION_ANCHOR = 'BOTTOMLEFT'
|
Nenue@97
|
39 local DURATION_INSET = 1
|
Nenue@86
|
40 local DURATION_PARENT
|
Nenue@86
|
41
|
Nenue@84
|
42 VeneerBuffFrameMixin = {
|
Nenue@84
|
43 moduleName = 'Buff Frames',
|
Nenue@84
|
44 defaultCluster = 'TOPRIGHT',
|
Nenue@90
|
45 anchorX = BUFF_FRAMES_X,
|
Nenue@90
|
46 anchorY = BUFF_FRAMES_Y,
|
Nenue@90
|
47 anchorPoint = 'TOPRIGHT',
|
Nenue@84
|
48 Buttons = {},
|
Nenue@84
|
49 DetectedFrames = {},
|
Nenue@84
|
50 AuraCache = {}
|
Nenue@84
|
51 }
|
Nenue@94
|
52 VeneerBuffFrameButtonMixin = {}
|
Nenue@94
|
53 local Facade = VeneerBuffFrameButtonMixin
|
Nenue@84
|
54 local plugin = VeneerBuffFrameMixin
|
Nenue@62
|
55
|
Nenue@84
|
56 local vn = Veneer
|
Nenue@84
|
57 local print = DEVIAN_WORKSPACE and function(...) _G.print('BuffFrame', ...) end or function() end
|
Nenue@68
|
58 local tprint = DEVIAN_WORKSPACE and function(...) _G.print('Timer', ...) end or function() end
|
Nenue@59
|
59
|
Nenue@68
|
60 local _G, UIParent = _G, UIParent
|
Nenue@68
|
61 local tinsert, tremove, unpack, select, tconcat = table.insert, table.remove, unpack, select, table.concat
|
Nenue@68
|
62 local floor, tonumber, format = math.floor, tonumber, string.format
|
Nenue@68
|
63 local UnitAura, GetTime, CreateFrame = UnitAura, GetTime, CreateFrame
|
Nenue@68
|
64 local hooksecurefunc = hooksecurefunc
|
Nenue@59
|
65
|
Nenue@75
|
66 local aurasCache = {}
|
Nenue@75
|
67 local skinnedFrames = {}
|
Nenue@75
|
68 local pendingFrames = {}
|
Nenue@75
|
69 local veneers = {}
|
Nenue@75
|
70 local expirationCache = {}
|
Nenue@75
|
71 local visibility = {}
|
Nenue@75
|
72 local isHooked = {}
|
Nenue@75
|
73
|
Nenue@75
|
74 plugin.options = {
|
Nenue@75
|
75 nameString = 'Buff Frames',
|
Nenue@59
|
76 {
|
Nenue@75
|
77 name = 'BuffButtonZoom',
|
Nenue@75
|
78 type = 'slider',
|
Nenue@75
|
79 min = 0,
|
Nenue@75
|
80 max = 100,
|
Nenue@75
|
81 fullwidth = true,
|
Nenue@59
|
82 },
|
Nenue@59
|
83 {
|
Nenue@75
|
84 name = 'BuffBorderLeft',
|
Nenue@75
|
85 type = 'slider',
|
Nenue@75
|
86 min = 0,
|
Nenue@75
|
87 max = 16,
|
Nenue@59
|
88 },
|
Nenue@59
|
89 {
|
Nenue@75
|
90 name = 'BuffBorderLeft',
|
Nenue@75
|
91 type = 'slider',
|
Nenue@75
|
92 min = 0,
|
Nenue@75
|
93 max = 16,
|
Nenue@59
|
94 }
|
Nenue@59
|
95 }
|
Nenue@59
|
96
|
Nenue@86
|
97 local OFFSET_PARALLELS = {
|
Nenue@86
|
98 TOP = {'LEFT', 'RIGHT', 'SetHeight'},
|
Nenue@86
|
99 BOTTOM = {'LEFT', 'RIGHT', 'SetHeight'},
|
Nenue@86
|
100 LEFT = {'TOP', 'BOTTOM', 'SetWidth'},
|
Nenue@86
|
101 RIGHT = {'TOP', 'BOTTOM', 'SetWidth'},
|
Nenue@86
|
102 }
|
Nenue@86
|
103 local ANCHOR_OFFSET_POINT = {
|
Nenue@86
|
104 TOP = 'BOTTOM',
|
Nenue@86
|
105 TOPLEFT = 'BOTTOMRIGHT',
|
Nenue@86
|
106 TOPRIGHT = 'BOTTOMLEFT',
|
Nenue@86
|
107 LEFT = 'RIGHT',
|
Nenue@86
|
108 RIGHT = 'LEFT',
|
Nenue@86
|
109 CENTER = 'CENTER',
|
Nenue@86
|
110 BOTTOM = 'TOP',
|
Nenue@86
|
111 BOTTOMRIGHT = 'TOPLEFT',
|
Nenue@86
|
112 BOTTOMLEFT = 'TOPRIGHT',
|
Nenue@86
|
113 }
|
Nenue@86
|
114 local ANCHOR_INSET_DELTA = {
|
Nenue@86
|
115 TOP = {0, -1},
|
Nenue@86
|
116 TOPLEFT = {1, -1},
|
Nenue@86
|
117 TOPRIGHT = {-1,-1},
|
Nenue@86
|
118 LEFT = {1, 0},
|
Nenue@86
|
119 BOTTOMLEFT = {1, 1},
|
Nenue@86
|
120 BOTTOM = {0, 1},
|
Nenue@86
|
121 BOTTOMRIGHT = {-1, 1},
|
Nenue@86
|
122 RIGHT = {-1, 0},
|
Nenue@86
|
123 CENTER = {0, 0},
|
Nenue@86
|
124 }
|
Nenue@59
|
125
|
Nenue@90
|
126 -- Associates skinning elements with said button
|
Nenue@90
|
127 local surrogates = {
|
Nenue@90
|
128 ['Show'] = false,
|
Nenue@90
|
129 ['Hide'] = false,
|
Nenue@90
|
130 ['SetText'] = false,
|
Nenue@90
|
131 ['SetVertexColor'] = function(self, region, r, g, b, a)
|
Nenue@90
|
132 if not self.progress then
|
Nenue@90
|
133 return
|
Nenue@90
|
134 end
|
Nenue@90
|
135
|
Nenue@90
|
136 region:Hide()
|
Nenue@93
|
137 --tprint('|cFF0088FFborder:SetVertexColor|r', r,g,b,a)
|
Nenue@90
|
138 self.progress.fg:SetColorTexture(r,g,b,a)
|
Nenue@90
|
139 self.border:SetColorTexture(r,g,b,a)
|
Nenue@90
|
140 self.border:Show()
|
Nenue@90
|
141 end,
|
Nenue@90
|
142 }
|
Nenue@90
|
143 local DoRegionHooks = function (veneer, region)
|
Nenue@90
|
144
|
Nenue@90
|
145 if region then
|
Nenue@90
|
146 --print('hooking', region:GetName())
|
Nenue@90
|
147 region:ClearAllPoints()
|
Nenue@90
|
148 for method, callback in pairs(surrogates) do
|
Nenue@90
|
149 if type(region[method]) == 'function' then
|
Nenue@90
|
150
|
Nenue@90
|
151 --print(method, type(callback))
|
Nenue@90
|
152 local func
|
Nenue@90
|
153 if callback then
|
Nenue@90
|
154 hooksecurefunc(region, method, function(self, ...)
|
Nenue@90
|
155 --tprint('|cFF00FFFF'.. region:GetName().. ':', method)
|
Nenue@90
|
156 region:ClearAllPoints()
|
Nenue@90
|
157 callback(veneer, region, ...)
|
Nenue@90
|
158 end)
|
Nenue@90
|
159 else
|
Nenue@90
|
160 hooksecurefunc(region, method, function(self,...)
|
Nenue@93
|
161 --tprint('|cFF0088FF'.. self:GetName().. ':', method)
|
Nenue@90
|
162 self:ClearAllPoints()
|
Nenue@90
|
163 veneer:Show()
|
Nenue@90
|
164 veneer[method](veneer, ...)
|
Nenue@90
|
165
|
Nenue@90
|
166 if self:GetName():match('Debuff.+Count') then
|
Nenue@90
|
167
|
Nenue@93
|
168 --print('|cFF00FFFF'.. self:GetName().. ':'.. method, '->', veneer:GetName()..':'..method..'(', ...,')')
|
Nenue@93
|
169 --print(veneer:IsVisible(),veneer:GetStringWidth(),veneer:GetText())
|
Nenue@93
|
170 --print(veneer:GetTop(), veneer:GetLeft())
|
Nenue@93
|
171 --print(veneer:GetPoint(1))
|
Nenue@90
|
172 end
|
Nenue@90
|
173
|
Nenue@90
|
174 end)
|
Nenue@90
|
175 end
|
Nenue@90
|
176 end
|
Nenue@90
|
177 end
|
Nenue@90
|
178 end
|
Nenue@90
|
179 end
|
Nenue@75
|
180
|
Nenue@93
|
181
|
Nenue@94
|
182
|
Nenue@94
|
183 function Facade:OnShow()
|
Nenue@95
|
184 print(self:GetName(), 'OnShow')
|
Nenue@94
|
185 self.underlay:Show()
|
Nenue@94
|
186 end
|
Nenue@94
|
187 function Facade:OnHide()
|
Nenue@95
|
188
|
Nenue@95
|
189 print(self:GetName(), 'OnHide')
|
Nenue@94
|
190 self.underlay:Hide()
|
Nenue@95
|
191
|
Nenue@94
|
192 end
|
Nenue@94
|
193
|
Nenue@94
|
194 function Facade:OnLoad()
|
Nenue@94
|
195
|
Nenue@94
|
196 self.duration = self.progress.duration
|
Nenue@94
|
197 self.count = self.overlay.count
|
Nenue@94
|
198 self.border = self.underlay.bg
|
Nenue@94
|
199
|
Nenue@94
|
200 VeneerBuffFrame.ConfigLayers = VeneerBuffFrame.ConfigLayers or {}
|
Nenue@94
|
201 self.configIndex = #VeneerBuffFrame.ConfigLayers
|
Nenue@94
|
202 for i, region in ipairs(self.ConfigLayers) do
|
Nenue@94
|
203 tinsert(VeneerBuffFrame.ConfigLayers, region)
|
Nenue@94
|
204 end
|
Nenue@94
|
205
|
Nenue@94
|
206 self.configIndexEnd = #VeneerBuffFrame.ConfigLayers
|
Nenue@94
|
207 end
|
Nenue@94
|
208
|
Nenue@94
|
209 function Facade:Setup()
|
Nenue@94
|
210 self:SetSize(BUFF_BUTTON_SIZE,BUFF_BUTTON_SIZE)
|
Nenue@94
|
211
|
Nenue@94
|
212 self.progress[OFFSET_PARALLELS[PROGRESS_ANCHOR][3]](self.progress, BUFF_PROGRESS_SIZE + (BUFF_PROGRESS_INSET * 2))
|
Nenue@94
|
213 --print(BUFF_PROGRESS_SIZE + (BUFF_PROGRESS_INSET * 2))
|
Nenue@94
|
214
|
Nenue@94
|
215 self.progress:ClearAllPoints()
|
Nenue@94
|
216 self.progress:SetPoint(ANCHOR_OFFSET_POINT[PROGRESS_ANCHOR], PROGRESS_PARENT or self.border, PROGRESS_ANCHOR,
|
Nenue@94
|
217 (ANCHOR_INSET_DELTA[PROGRESS_ANCHOR][1] * PROGRESS_OFFSET * -1),
|
Nenue@94
|
218 (ANCHOR_INSET_DELTA[PROGRESS_ANCHOR][2] * PROGRESS_OFFSET * -1))
|
Nenue@94
|
219 self.progress:SetPoint(OFFSET_PARALLELS[PROGRESS_ANCHOR][1], self.border, OFFSET_PARALLELS[PROGRESS_ANCHOR][1], 0, 0)
|
Nenue@94
|
220 self.progress:SetPoint(OFFSET_PARALLELS[PROGRESS_ANCHOR][2], self.border, OFFSET_PARALLELS[PROGRESS_ANCHOR][2], 0, 0)
|
Nenue@94
|
221
|
Nenue@94
|
222 --print(self.progress:GetPoint(1))
|
Nenue@94
|
223 --print(self.progress:GetPoint(2))
|
Nenue@94
|
224 --print(self.progress:GetPoint(3))
|
Nenue@94
|
225 self.progress:Show()
|
Nenue@94
|
226
|
Nenue@94
|
227 self.progress.bg:ClearAllPoints()
|
Nenue@94
|
228 self.progress.bg:SetAllPoints(self.progress)
|
Nenue@94
|
229
|
Nenue@94
|
230 self.progress.fg:ClearAllPoints()
|
Nenue@94
|
231 self.progress.fg:SetPoint('BOTTOMLEFT', BUFF_PROGRESS_INSET,BUFF_PROGRESS_INSET)
|
Nenue@94
|
232 self.progress.fg:SetPoint('TOP', 0, -BUFF_PROGRESS_INSET)
|
Nenue@94
|
233 --self.count:ClearAllPoints()
|
Nenue@94
|
234 --self.count:SetPoint('TOPRIGHT', self,'TOPRIGHT', -3, -3)
|
Nenue@94
|
235
|
Nenue@94
|
236
|
Nenue@94
|
237 self.duration:ClearAllPoints()
|
Nenue@94
|
238 self.duration:SetPoint(DURATION_ANCHOR, DURATION_PARENT or self, DURATION_ANCHOR,
|
Nenue@94
|
239 (ANCHOR_INSET_DELTA[DURATION_ANCHOR][1] * DURATION_INSET),
|
Nenue@94
|
240 (ANCHOR_INSET_DELTA[DURATION_ANCHOR][2] * DURATION_INSET))
|
Nenue@94
|
241
|
Nenue@94
|
242 self.count:ClearAllPoints()
|
Nenue@94
|
243 self.count:SetPoint(COUNT_ANCHOR, COUNT_PARENT or self, COUNT_ANCHOR,
|
Nenue@94
|
244 (ANCHOR_INSET_DELTA[COUNT_ANCHOR][1] * COUNT_INSET),
|
Nenue@94
|
245 (ANCHOR_INSET_DELTA[COUNT_ANCHOR][2] * COUNT_INSET))
|
Nenue@94
|
246
|
Nenue@95
|
247 self.underlay:SetParent(UIParent)
|
Nenue@95
|
248
|
Nenue@94
|
249 self.underlay:SetFrameStrata('BACKGROUND')
|
Nenue@94
|
250 self.border:SetColorTexture(0,0,0,1)
|
Nenue@94
|
251 self.border:SetPoint('TOPLEFT', self, 'TOPLEFT', -BORDER_SIZE_L, BORDER_SIZE_U)
|
Nenue@94
|
252 self.border:SetPoint('BOTTOMRIGHT', self, 'BOTTOMRIGHT', BORDER_SIZE_R, -BORDER_SIZE_D)
|
Nenue@94
|
253 self.border:Show()
|
Nenue@95
|
254
|
Nenue@96
|
255 -- play nice with Blizzard's frame locking structure
|
Nenue@96
|
256 FRAMELOCK_STATES.PETBATTLES[self:GetName()] = "hidden"
|
Nenue@95
|
257 FRAMELOCK_STATES.PETBATTLES[self.underlay:GetName()] = "hidden"
|
Nenue@94
|
258 end
|
Nenue@94
|
259
|
Nenue@106
|
260 plugin.defaultSettings = {
|
Nenue@106
|
261 width = 48,
|
Nenue@106
|
262 height = 48,
|
Nenue@106
|
263 }
|
Nenue@106
|
264
|
Nenue@94
|
265 function plugin:AcquireConfigButton(name)
|
Nenue@94
|
266 print('|cFF88FF00Creating config dummy', name,'Veneer')
|
Nenue@94
|
267 local button = self.Buttons[name]
|
Nenue@94
|
268 if not button then
|
Nenue@94
|
269 button = CreateFrame('Frame', name .. 'Veneer', self, 'VeneerBuffTemplate')
|
Nenue@94
|
270 button:Setup()
|
Nenue@94
|
271 button:SetShown(true)
|
Nenue@94
|
272 self.Buttons[name] = button
|
Nenue@94
|
273 end
|
Nenue@94
|
274 return button
|
Nenue@94
|
275 end
|
Nenue@94
|
276
|
Nenue@94
|
277 function plugin:Acquire(name)
|
Nenue@94
|
278 local frame = self.Buttons[name]
|
Nenue@94
|
279 if not frame then
|
Nenue@94
|
280 local target = _G[name]
|
Nenue@84
|
281 local id = target:GetID()
|
Nenue@94
|
282 print('|cFF88FF00Creating', name .. 'Veneer')
|
Nenue@93
|
283 frame = vn:Acquire(target, 'VeneerBuffTemplate')
|
Nenue@94
|
284 frame:Setup()
|
Nenue@94
|
285 self.Buttons[name] = frame
|
Nenue@59
|
286 end
|
Nenue@84
|
287 return frame
|
Nenue@59
|
288 end
|
Nenue@59
|
289
|
Nenue@94
|
290 function plugin:OnLoad()
|
Nenue@84
|
291 Veneer:AddHandler(self, self.defaultCluster)
|
Nenue@84
|
292 end
|
Nenue@68
|
293
|
Nenue@94
|
294 function plugin:Setup()
|
Nenue@84
|
295
|
Nenue@84
|
296
|
Nenue@84
|
297 hooksecurefunc("BuffFrame_Update", function(...) self:OnBuffFrameUpdate(...) end)
|
Nenue@97
|
298 hooksecurefunc("AuraButton_UpdateDuration", function(...) self:OnUpdateDuration(...) end)
|
Nenue@84
|
299 hooksecurefunc("AuraButton_Update", function(...) self:OnAuraButton_Update(...) end)
|
Nenue@84
|
300 hooksecurefunc("BuffFrame_UpdateAllBuffAnchors", function(...) self:OnUpdateAllBuffAnchors(...) end)
|
Nenue@84
|
301 hooksecurefunc("TemporaryEnchantFrame_Update", function(...) self:OnTemporaryEnchantFrameUpdate(...) end)
|
Nenue@84
|
302 for i = 1, 3 do
|
Nenue@84
|
303 self:SetupButton('TempEnchant'..i)
|
Nenue@84
|
304 _G['TempEnchant'..i..'Border']:SetVertexColor(0.5,0,1,1)
|
Nenue@84
|
305 end
|
Nenue@84
|
306 end
|
Nenue@86
|
307
|
Nenue@94
|
308 function plugin:SetHidden(region)
|
Nenue@93
|
309 if not self.hiddenRegions[region] then
|
Nenue@93
|
310 self.hiddenRegions[region] = true
|
Nenue@93
|
311 region:SetShown(false)
|
Nenue@93
|
312 hooksecurefunc(region)
|
Nenue@93
|
313 end
|
Nenue@93
|
314 end
|
Nenue@84
|
315
|
Nenue@94
|
316 function plugin:SetupButton (name)
|
Nenue@94
|
317 local frame = _G[name]
|
Nenue@95
|
318 print('|cFFFFFF00Adopting', name)
|
Nenue@68
|
319
|
Nenue@68
|
320 local icon = _G[name .. 'Icon']
|
Nenue@68
|
321 local border = _G[name .. 'Border']
|
Nenue@68
|
322 local count = _G[name .. 'Count']
|
Nenue@68
|
323 local duration = _G[name .. 'Duration']
|
Nenue@106
|
324 local facade = self:Acquire(name)
|
Nenue@84
|
325 local offset = BUFF_BUTTON_ZOOM/2
|
Nenue@68
|
326
|
Nenue@84
|
327 self.DetectedFrames[frame] = frame
|
Nenue@68
|
328 frame:SetSize(BUFF_BUTTON_SIZE,BUFF_BUTTON_SIZE)
|
Nenue@84
|
329 icon:SetTexCoord(offset, 1 - offset, offset, 1 - offset)
|
Nenue@68
|
330
|
Nenue@78
|
331
|
Nenue@106
|
332 DoRegionHooks(facade, border)
|
Nenue@68
|
333 if border then
|
Nenue@68
|
334 local color = DebuffTypeColor["none"]
|
Nenue@68
|
335 if aurasCache[frame] and aurasCache[frame][5] then
|
Nenue@68
|
336 color = DebuffTypeColor[aurasCache[frame][5]]
|
Nenue@68
|
337 end
|
Nenue@106
|
338 facade.progress.fg:SetColorTexture(color.r,color.g,color.b)
|
Nenue@106
|
339 facade.border:SetColorTexture(0,0,0,1)
|
Nenue@106
|
340 facade.border:Show()
|
Nenue@79
|
341 else
|
Nenue@106
|
342 facade.border:SetColorTexture(0,0,0,1)
|
Nenue@106
|
343 facade.border:Show()
|
Nenue@68
|
344 end
|
Nenue@68
|
345
|
Nenue@93
|
346 if count then
|
Nenue@86
|
347 count:ClearAllPoints()
|
Nenue@93
|
348 hooksecurefunc(count, 'Show', function(self) self:Hide() end)
|
Nenue@93
|
349 if count:GetText() then
|
Nenue@106
|
350 facade.count:SetText(count:GetText())
|
Nenue@93
|
351 end
|
Nenue@86
|
352 end
|
Nenue@86
|
353 if duration then
|
Nenue@86
|
354 duration:ClearAllPoints()
|
Nenue@86
|
355 end
|
Nenue@86
|
356
|
Nenue@95
|
357 hooksecurefunc(frame, "Hide", function(frame)
|
Nenue@106
|
358 facade:Hide()
|
Nenue@68
|
359 end)
|
Nenue@68
|
360
|
Nenue@95
|
361 hooksecurefunc(frame, 'Show', function(frame)
|
Nenue@106
|
362 facade:Show()
|
Nenue@68
|
363 end)
|
Nenue@68
|
364
|
Nenue@95
|
365 hooksecurefunc(frame, 'SetShown', function(frame, isShown)
|
Nenue@106
|
366 facade:SetShown(isShown)
|
Nenue@95
|
367 end)
|
Nenue@95
|
368
|
Nenue@106
|
369 facade.IsAcquired = true
|
Nenue@106
|
370 facade:SetParent(UIParent)
|
Nenue@106
|
371 facade:SetAllPoints(frame)
|
Nenue@106
|
372 facade:SetFrameStrata('MEDIUM')
|
Nenue@68
|
373 end
|
Nenue@68
|
374
|
Nenue@68
|
375
|
Nenue@61
|
376 --- Set widgets to reflect the passed parameters
|
Nenue@94
|
377 function plugin:UpdateButton (name, duration, expires)
|
Nenue@94
|
378 local frame = _G[name]
|
Nenue@106
|
379 local facade = self:Acquire(name)
|
Nenue@68
|
380 -- is it a new button?
|
Nenue@84
|
381 if not self.DetectedFrames[frame] then
|
Nenue@94
|
382 print('|cFFFF4400detected', name)
|
Nenue@94
|
383 self:SetupButton(name)
|
Nenue@68
|
384 end
|
Nenue@106
|
385 print(facade:GetParent():GetName(), facade:GetPoint(1))
|
Nenue@86
|
386 --[[
|
Nenue@86
|
387 if frame.count then
|
Nenue@86
|
388 frame.count:SetText('test')
|
Nenue@86
|
389 frame.count:Show()
|
Nenue@86
|
390 end
|
Nick@108
|
391 --]]
|
Nick@108
|
392
|
Nick@108
|
393 local name, rank, icon, count, dispelType, duration, expires, caster, isStealable, nameplateShowPersonal, spellID, canApplyAura, isBossDebuff, _, nameplateShowAll, timeMod, value1, value2, value3 = UnitAura(frame.unit, frame:GetID(), frame.filter)
|
Nick@108
|
394
|
Nenue@86
|
395
|
Nenue@59
|
396
|
Nenue@61
|
397 if expires and duration then
|
Nenue@61
|
398 if duration ~= 0 then
|
Nenue@61
|
399 local startTime = (expires - duration)
|
Nenue@61
|
400 local endTime = expires or 0
|
Nenue@61
|
401 print('|cFF0088FF'..frame:GetName()..'|r', duration, expires)
|
Nenue@106
|
402 facade.progress:Show()
|
Nenue@106
|
403 facade.elapsed = 0
|
Nenue@106
|
404 facade.progress:SetScript('OnUpdate', function(self, elapsed)
|
Nenue@106
|
405 facade.elapsed = facade.elapsed + elapsed
|
Nenue@60
|
406
|
Nenue@106
|
407 local w = floor(facade.progress:GetWidth()+.5) - (BUFF_PROGRESS_INSET*2)
|
Nenue@61
|
408 local t = GetTime()
|
Nenue@61
|
409 local progress = (t - startTime) / duration
|
Nenue@61
|
410
|
Nenue@67
|
411 local nw = (w - (w * progress))
|
Nenue@106
|
412 if facade.elapsed >= 0.25 then
|
Nenue@61
|
413
|
Nenue@93
|
414 --tprint(t, startTime, floor(progress*100), w * progress, nw, w)
|
Nenue@106
|
415 facade.elapsed = 0.25 - facade.elapsed
|
Nenue@61
|
416 end
|
Nenue@61
|
417 if (progress >= 1) or not frame:IsVisible() then
|
Nenue@106
|
418 facade.startTime = nil
|
Nenue@61
|
419 self:Hide()
|
Nenue@61
|
420 self:SetScript('OnUpdate', nil)
|
Nenue@61
|
421 else
|
Nenue@61
|
422 self.fg:SetWidth(nw)
|
Nenue@61
|
423 end
|
Nick@108
|
424
|
Nick@108
|
425
|
Nenue@61
|
426 end)
|
Nenue@61
|
427
|
Nenue@106
|
428 facade.cooldown:Show()
|
Nenue@106
|
429 facade.cooldown:SetCooldown(startTime, duration)
|
Nenue@61
|
430 else
|
Nenue@61
|
431 print('|cFF00FF88'..frame:GetName()..'|r', 'duration zero')
|
Nenue@106
|
432 facade.progress:SetScript('OnUpdate', nil)
|
Nenue@106
|
433 facade.progress:Hide()
|
Nenue@106
|
434 facade.cooldown:Hide()
|
Nenue@61
|
435 end
|
Nenue@86
|
436
|
Nenue@90
|
437 if count and count > 1 then
|
Nenue@106
|
438 facade.count:SetText(count)
|
Nenue@106
|
439 facade.count:Show()
|
Nenue@90
|
440 frame.count:ClearAllPoints()
|
Nenue@86
|
441 else
|
Nenue@106
|
442 facade.count:Hide()
|
Nenue@86
|
443 end
|
Nenue@86
|
444
|
Nenue@86
|
445
|
Nick@110
|
446 facade.overlay.Value1:SetText(value1)
|
Nick@110
|
447 facade.overlay.Value2:SetText(value2)
|
Nick@110
|
448 facade.overlay.Value3:SetText(value3)
|
Nick@110
|
449
|
Nenue@61
|
450 else
|
Nenue@106
|
451 facade.progress:Hide()
|
Nenue@106
|
452 facade.cooldown:SetCooldown(0,0)
|
Nenue@106
|
453 facade.cooldown:Hide()
|
Nenue@61
|
454 print('|cFF88FF00'..frame:GetName()..'|r', 'nil duration')
|
Nenue@59
|
455 end
|
Nenue@106
|
456 facade:Show()
|
Nenue@59
|
457 end
|
Nenue@59
|
458
|
Nenue@59
|
459
|
Nenue@59
|
460 --- Provides the number of changed indices for use in deciding between partial and full veneer updates
|
Nenue@94
|
461 function plugin:ButtonHasChanged (frame, ...)
|
Nenue@59
|
462 aurasCache[frame] = aurasCache[frame] or {}
|
Nenue@59
|
463 local hasChange = 0
|
Nenue@59
|
464 local numVals = select('#',...)
|
Nenue@59
|
465 for i = 1, numVals do
|
Nenue@59
|
466 local arg = select(i, ...)
|
Nenue@59
|
467 if aurasCache[frame][i] ~= arg then
|
Nenue@59
|
468 hasChange = hasChange + 1
|
Nenue@59
|
469 end
|
Nenue@59
|
470 aurasCache[frame][i] = arg
|
Nenue@59
|
471 end
|
Nenue@59
|
472 return hasChange
|
Nenue@59
|
473 end
|
Nenue@59
|
474
|
Nenue@94
|
475 function plugin:OnAuraButton_Update (name, index, filter)
|
Nenue@59
|
476 local bName = name..index
|
Nenue@59
|
477 local frame = _G[bName]
|
Nick@110
|
478 if frame and frame:IsShown() then
|
Nenue@61
|
479 -- if the name or expirationTime changed
|
Nenue@86
|
480
|
Nenue@94
|
481 if not skinnedFrames[bName] then
|
Nenue@94
|
482 tinsert(pendingFrames, bName)
|
Nenue@61
|
483 end
|
Nenue@59
|
484 expirationCache[name] = frame.expirationTime
|
Nenue@94
|
485 self:UpdateButton(bName)
|
Nenue@68
|
486
|
Nenue@59
|
487
|
Nenue@59
|
488 end
|
Nenue@59
|
489 end
|
Nenue@59
|
490
|
Nenue@94
|
491 function plugin:OnUpdateAllBuffAnchors ()
|
Nenue@59
|
492
|
Nenue@59
|
493 --BuffButton1
|
Nenue@59
|
494 --DebuffButton1
|
Nenue@61
|
495 --todo: separate frame groups and iterate over them at appropriate times
|
Nenue@60
|
496 if BuffButton1 then
|
Nenue@78
|
497
|
Nenue@68
|
498 TempEnchant1:SetPoint('TOPRIGHT', BuffButton1, 'TOPRIGHT', BuffButton1:GetWidth()+4, 0)
|
Nenue@60
|
499 end
|
Nenue@60
|
500
|
Nenue@70
|
501 local lastBuff, topBuff
|
Nenue@74
|
502 local numBuffs = 0
|
Nenue@90
|
503 local numColumns = 1
|
Nenue@90
|
504 local maxColumn = 1
|
Nenue@94
|
505 local limit = self.configMode and BUFF_MAX_DISPLAY or BUFF_ACTUAL_DISPLAY
|
Nenue@94
|
506 for i = 1, limit do
|
Nenue@94
|
507 local name = 'BuffButton'..i
|
Nenue@94
|
508 local buff = _G[name] or self.Buttons[name]
|
Nenue@106
|
509 print(i, name, buff)
|
Nenue@70
|
510 if buff then
|
Nenue@74
|
511 numBuffs = numBuffs + 1
|
Nenue@74
|
512 buff:ClearAllPoints()
|
Nenue@75
|
513 if mod(numBuffs,BUFFS_PER_ROW) == 1 then
|
Nenue@74
|
514 if numBuffs == 1 then
|
Nenue@80
|
515 buff:SetPoint('TOPRIGHT', UIParent, 'TOPRIGHT', BUFF_FRAMES_X, BUFF_FRAMES_Y)
|
Nenue@90
|
516 plugin.currentTop = buff
|
Nenue@71
|
517 else
|
Nenue@71
|
518 buff:SetPoint('TOPRIGHT', topBuff, 'BOTTOMRIGHT', 0, -BUFF_BUTTON_SPACING_V)
|
Nenue@71
|
519 end
|
Nenue@90
|
520 numColumns = 1
|
Nenue@70
|
521 topBuff = buff
|
Nenue@70
|
522 else
|
Nenue@71
|
523 buff:SetPoint('TOPRIGHT', lastBuff, 'TOPLEFT', -BUFF_BUTTON_SPACING_H, 0)
|
Nenue@90
|
524 numColumns = numColumns + 1
|
Nenue@90
|
525 end
|
Nenue@90
|
526 if numColumns > maxColumn then
|
Nenue@90
|
527 maxColumn = numColumns
|
Nenue@90
|
528 plugin.currentLeft = buff
|
Nenue@70
|
529 end
|
Nenue@70
|
530 lastBuff = buff
|
Nenue@70
|
531 end
|
Nenue@70
|
532 end
|
Nenue@70
|
533
|
Nenue@74
|
534 numBuffs = 0
|
Nenue@94
|
535 limit = self.configMode and DEBUFF_MAX_DISPLAY or DEBUFF_ACTUAL_DISPLAY
|
Nenue@106
|
536 local lastDebuff
|
Nenue@106
|
537 local topDebuff = topBuff
|
Nenue@106
|
538 for i = 1, limit do
|
Nenue@94
|
539 local name = 'DebuffButton'..i
|
Nenue@94
|
540 local debuff = _G[name] or self.Buttons[name]
|
Nenue@106
|
541 print(i, name, debuff)
|
Nenue@70
|
542 if debuff then
|
Nenue@74
|
543 numBuffs = numBuffs + 1
|
Nenue@93
|
544 if mod(numBuffs, BUFFS_PER_ROW) == 1 then
|
Nenue@93
|
545
|
Nenue@106
|
546 if topDebuff then
|
Nenue@106
|
547 debuff:SetPoint('TOPRIGHT', topDebuff, 'BOTTOMRIGHT', 0, -BUFF_BUTTON_SPACING_V)
|
Nenue@93
|
548 else
|
Nenue@93
|
549 debuff:SetPoint('TOPRIGHT', UIParent, 'TOPRIGHT', BUFF_FRAMES_X, BUFF_FRAMES_Y)
|
Nenue@93
|
550 end
|
Nenue@106
|
551 topDebuff = debuff
|
Nenue@93
|
552
|
Nenue@70
|
553 else
|
Nenue@106
|
554 debuff:SetPoint('TOPRIGHT', lastDebuff, 'TOPLEFT', -BUFF_BUTTON_SPACING_H, 0)
|
Nenue@70
|
555 end
|
Nenue@106
|
556 lastDebuff = debuff
|
Nenue@94
|
557
|
Nenue@70
|
558 end
|
Nenue@70
|
559 end
|
Nenue@70
|
560
|
Nenue@74
|
561 if lastBuff then
|
Nenue@90
|
562 plugin.currentBottom = lastBuff
|
Nenue@74
|
563 end
|
Nenue@90
|
564
|
Nenue@90
|
565 self.Background:ClearAllPoints()
|
Nenue@90
|
566 self.Background:SetPoint('TOPRIGHT', plugin.currentTop, 'TOPRIGHT', 4, 4)
|
Nenue@90
|
567 self.Background:SetPoint('BOTTOM', plugin.currentBottom, 'BOTTOM', 0, -4)
|
Nenue@90
|
568 self.Background:SetPoint('LEFT', plugin.currentLeft, 'LEFT', -4, 0)
|
Nenue@59
|
569 end
|
Nenue@94
|
570 function plugin:UpdateConfigLayers (configMode)
|
Nenue@90
|
571 self:SetShown(configMode)
|
Nenue@94
|
572 self.configMode = configMode
|
Nenue@94
|
573 for i = 1, BUFF_MAX_DISPLAY do
|
Nenue@94
|
574 local name = 'BuffButton' .. i
|
Nenue@94
|
575 local button = self:AcquireConfigButton(name)
|
Nenue@106
|
576 if not button.IsAcquired then
|
Nenue@106
|
577 button.underlay.bg:SetColorTexture(0,1,0,0.5)
|
Nenue@106
|
578 end
|
Nenue@94
|
579 end
|
Nenue@94
|
580 for i = 1, DEBUFF_MAX_DISPLAY do
|
Nenue@94
|
581 local name = 'DebuffButton' .. i
|
Nenue@94
|
582 local button = self:AcquireConfigButton(name)
|
Nenue@106
|
583 if not button.IsAcquired then
|
Nenue@106
|
584 button.underlay.bg:SetColorTexture(1,0,0,0.5)
|
Nenue@106
|
585 end
|
Nenue@93
|
586 end
|
Nenue@106
|
587 self:OnUpdateAllBuffAnchors()
|
Nenue@90
|
588 end
|
Nenue@94
|
589 function plugin:OnUpdateDuration (frame, timeLeft)
|
Nenue@97
|
590 local veneer = self:Acquire(frame:GetName())
|
Nenue@60
|
591 local hours = floor(timeLeft/3600)
|
Nenue@60
|
592 local minutes = floor(mod(timeLeft, 3600)/60)
|
Nenue@60
|
593 local seconds = floor(mod(timeLeft, 60))
|
Nenue@60
|
594 local timeString = '%ds'
|
Nenue@59
|
595 if timeLeft > 3600 then
|
Nenue@60
|
596 timeString = format('%d:%02d', hours, minutes)
|
Nenue@60
|
597 elseif timeLeft > 60 then
|
Nenue@60
|
598 timeString = format('%d:%02d', minutes, seconds)
|
Nenue@61
|
599 else
|
Nenue@60
|
600 timeString = format('%d', seconds)
|
Nenue@59
|
601 end
|
Nenue@59
|
602
|
Nenue@74
|
603 if timeLeft < 10 then
|
Nenue@74
|
604 if not veneer.duration.getHuge then
|
Nenue@74
|
605 veneer.duration.getHuge = true
|
Nenue@97
|
606 veneer.duration:SetTextColor(1,.5,0,1)
|
Nenue@74
|
607 end
|
Nenue@74
|
608 else
|
Nenue@74
|
609 if veneer.duration.getHuge then
|
Nenue@74
|
610 veneer.duration.getHuge = nil
|
Nenue@74
|
611 veneer.duration:SetTextColor(1,1,1,1)
|
Nenue@74
|
612 end
|
Nenue@74
|
613 end
|
Nenue@74
|
614
|
Nenue@69
|
615 veneer.duration:SetText(timeString)
|
Nenue@59
|
616 end
|
Nenue@59
|
617
|
Nenue@59
|
618
|
Nenue@59
|
619 -- Obtains the first instance of Tenchant use
|
Nenue@59
|
620
|
Nenue@94
|
621 function plugin:OnTemporaryEnchantFrameUpdate (...)
|
Nenue@59
|
622 local numVals = select('#', ...)
|
Nenue@59
|
623 local numItems = numVals / 4
|
Nenue@59
|
624 if numItems >= 1 then
|
Nenue@59
|
625 for itemIndex = numItems, 1, -1 do
|
Nenue@94
|
626 local name = 'TempEnchant'..itemIndex
|
Nenue@94
|
627 local frame = _G[name]
|
Nenue@59
|
628 local hasEnchant, timeRemaining, enchantCharges = select((4 * (itemIndex -1)) + 1, ...)
|
Nenue@59
|
629
|
Nenue@59
|
630
|
Nenue@59
|
631 if hasEnchant then
|
Nenue@59
|
632 local endTime = floor(GetTime()*1000) + timeRemaining
|
Nenue@59
|
633
|
Nenue@59
|
634
|
Nenue@59
|
635 --print(endTime)
|
Nenue@59
|
636 if endTime ~= expirationCache[frame] then
|
Nenue@59
|
637 if expirationCache[frame] then
|
Nenue@59
|
638 print(endTime, expirationCache[frame], endTime - expirationCache[frame])
|
Nenue@59
|
639 end
|
Nenue@59
|
640 expirationCache[frame] = endTime
|
Nenue@59
|
641 print('push tempenchant timer update', timeRemaining / 1000, GetTime()+(timeRemaining/1000))
|
Nenue@94
|
642 self:UpdateButton(frame, timeRemaining/1000, GetTime()+(timeRemaining/1000))
|
Nenue@59
|
643 end
|
Nenue@59
|
644 else
|
Nenue@94
|
645 self:Acquire(name):Hide()
|
Nenue@59
|
646 end
|
Nenue@59
|
647 end
|
Nenue@59
|
648 end
|
Nenue@59
|
649 end
|
Nenue@59
|
650
|
Nenue@94
|
651 function plugin:OnBuffFrameUpdate () end
|
Nenue@59
|
652
|
Nenue@90
|
653
|
Nenue@84
|
654 -- The TempEnchant frames are hardcoded in the base FrameXML, so get them now
|
Nenue@59
|
655
|