annotate Modules/BuffFrame.lua @ 94:df10cd0ae949

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