annotate Modules/BuffFrame.lua @ 70:1b0d7bcd252e

- anchors code
author Nenue
date Mon, 22 Aug 2016 20:38:43 -0400
parents ebc18a7412a1
children 6f8661094643
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@64 14 local BUFF_BUTTON_SIZE = 48
Nenue@64 15 local BUFF_PROGRESS_SIZE = 4
Nenue@64 16 local BUFF_PROGRESS_INSET = 1
Nenue@68 17 local BUFF_BUTTON_ZOOM = .15
Nenue@70 18 local BORDER_SIZE_L = 1
Nenue@70 19 local BORDER_SIZE_R = 1
Nenue@70 20 local BORDER_SIZE_U = 4
Nenue@70 21 local BORDER_SIZE_D = 1
Nenue@64 22
Nenue@62 23
Nenue@62 24 local plugin = CreateFrame('Frame', 'VeneerBuffFrame', UIParent)
Nenue@59 25 local vn, print = LibStub("LibKraken").register(VeneerController, plugin)
Nenue@68 26 local tprint = DEVIAN_WORKSPACE and function(...) _G.print('Timer', ...) end or function() end
Nenue@59 27
Nenue@68 28 local _G, UIParent = _G, UIParent
Nenue@68 29 local tinsert, tremove, unpack, select, tconcat = table.insert, table.remove, unpack, select, table.concat
Nenue@68 30 local floor, tonumber, format = math.floor, tonumber, string.format
Nenue@68 31 local UnitAura, GetTime, CreateFrame = UnitAura, GetTime, CreateFrame
Nenue@68 32 local hooksecurefunc = hooksecurefunc
Nenue@59 33
Nenue@59 34 local buttons = {}
Nenue@59 35 local buffTypes = {
Nenue@59 36 {
Nenue@59 37 name = 'buff',
Nenue@59 38 pattern = 'BuffButton(%d)',
Nenue@59 39 filters = 'HELPFUL',
Nenue@59 40 },
Nenue@59 41 {
Nenue@59 42 name = 'debuff',
Nenue@59 43 pattern = 'DebuffButton(%d)',
Nenue@59 44 filters = 'HARMFUL',
Nenue@59 45 },
Nenue@59 46 {
Nenue@59 47 name = 'tempenchant',
Nenue@59 48 pattern = 'TempEnchant(%d)',
Nenue@59 49 filters = 'TEMPENCHANT'
Nenue@59 50 }
Nenue@59 51 }
Nenue@59 52
Nenue@59 53 local textureMapping = {
Nenue@59 54 [1] = 16, --Main hand
Nenue@59 55 [2] = 17, --Off-hand
Nenue@59 56 [3] = 18, --Ranged
Nenue@59 57 }
Nenue@59 58
Nenue@59 59 local tickCounter = {}
Nenue@59 60 local aurasCache = {}
Nenue@59 61 local skinnedFrames = {}
Nenue@59 62 local pendingFrames = {}
Nenue@59 63 local anchors = {}
Nenue@59 64 local expirationCache = {}
Nenue@68 65 local visibility = {}
Nenue@59 66
Nenue@59 67 local VeneerButton_OnHide = function(self)
Nenue@59 68 self:SetScript('OnDragStart', self.StartMoving)
Nenue@59 69 self:SetScript('OnDragStop', self.StopMovingOrSizing)
Nenue@60 70 self:SetMovable(false)
Nenue@60 71 self:EnableMouse(false)
Nenue@59 72 self:RegisterForDrag('LeftButton')
Nenue@59 73 end
Nenue@59 74 local VeneerButton_OnShow = function(self)
Nenue@59 75 self:SetScript('OnDragStart', self.StartMoving)
Nenue@59 76 self:SetScript('OnDragStop', self.StopMovingOrSizing)
Nenue@60 77 self:SetMovable(false)
Nenue@60 78 self:EnableMouse(false)
Nenue@59 79 self:RegisterForDrag('LeftButton')
Nenue@59 80 end
Nenue@59 81
Nenue@59 82
Nenue@59 83 local GetVeneer = function(frame)
Nenue@59 84 local name = frame:GetName()
Nenue@69 85 if not (_G[name..'Veneer']) then
Nenue@68 86 print('|cFF88FF00Creating', name,'Veneer')
Nenue@59 87 local veneer = CreateFrame('Frame', name..'Veneer', UIParent)
Nenue@60 88 local id = frame:GetID()
Nenue@59 89 veneer:SetAllPoints(frame)
Nenue@60 90 veneer:SetParent(frame)
Nenue@59 91 veneer.bg = veneer:CreateTexture()
Nenue@61 92 veneer.bg:SetColorTexture(1,1,1,0)
Nenue@59 93 veneer.bg:SetAllPoints(veneer)
Nenue@60 94 veneer.bg:Show()
Nenue@59 95 veneer:Hide()
Nenue@60 96 veneer:EnableMouse(false)
Nenue@59 97
Nenue@59 98 veneer:SetScript('OnShow', VeneerButton_OnShow)
Nenue@59 99 veneer:SetScript('OnHide', VeneerButton_OnHide)
Nenue@59 100
Nenue@59 101 local position = tonumber(name:match("%d"))
Nenue@59 102 if position == 1 then
Nenue@59 103 veneer:Show()
Nenue@59 104 end
Nenue@59 105
Nenue@59 106 veneer.progress = CreateFrame('Frame', name .. 'VeneerProgress', veneer)
Nenue@59 107 veneer.progress:Hide()
Nenue@59 108 veneer.progress:SetPoint('BOTTOMLEFT', veneer, 'BOTTOMLEFT', 3, -6)
Nenue@59 109 veneer.progress:SetPoint('TOPRIGHT', veneer, 'BOTTOMRIGHT', -3, -1)
Nenue@68 110 veneer.progress:SetHeight(BUFF_PROGRESS_SIZE + (BUFF_PROGRESS_INSET * 2))
Nenue@59 111
Nenue@59 112 veneer.progress.bg = veneer.progress:CreateTexture(nil, 'BACKGROUND')
Nenue@61 113 veneer.progress.bg:SetColorTexture(0,0,0,1)
Nenue@59 114 veneer.progress.bg:SetAllPoints(veneer.progress)
Nenue@59 115
Nenue@59 116 veneer.progress.fg = veneer.progress:CreateTexture(nil, 'ARTWORK')
Nenue@59 117 veneer.progress.fg:SetColorTexture(0,1,0,1)
Nenue@68 118 veneer.progress.fg:SetPoint('BOTTOMLEFT', BUFF_PROGRESS_INSET,BUFF_PROGRESS_INSET)
Nenue@68 119 veneer.progress.fg:SetPoint('TOP', 0, -BUFF_PROGRESS_INSET)
Nenue@59 120
Nenue@59 121 veneer.progress.status = veneer.progress:CreateFontString()
Nenue@59 122 veneer.progress.status:SetFontObject(VeneerNumberFont)
Nenue@59 123 veneer.progress.status:SetPoint('TOP')
Nenue@59 124
Nenue@61 125
Nenue@61 126 veneer.cooldown = CreateFrame('Cooldown', name ..'VeneerCooldown', veneer, 'CooldownFrameTemplate')
Nenue@61 127 veneer.cooldown:SetAllPoints(frame)
Nenue@61 128 veneer.cooldown:SetReverse(true)
Nenue@61 129
Nenue@69 130 local overlay = CreateFrame('Frame', name .. 'VeneerOverlay', UIParent)
Nenue@68 131
Nenue@69 132 overlay:Show()
Nenue@69 133 overlay:SetFrameStrata('MEDIUM')
Nenue@69 134 local n = frame:GetNumPoints()
Nenue@69 135 for i = 1, n do
Nenue@69 136 overlay:SetPoint(frame:GetPoint(n))
Nenue@69 137 end
Nenue@68 138
Nenue@68 139
Nenue@69 140 local underlay = CreateFrame('Frame', name..'VeneerUnderlay', UIParent)
Nenue@68 141 underlay:Show()
Nenue@68 142 underlay:SetFrameStrata('BACKGROUND')
Nenue@68 143 local n = frame:GetNumPoints()
Nenue@68 144 for i = 1, n do
Nenue@68 145 underlay:SetPoint(frame:GetPoint(n))
Nenue@68 146 end
Nenue@68 147
Nenue@69 148 veneer.duration = overlay:CreateFontString(name..'VeneerDuration', 'OVERLAY')
Nenue@69 149 veneer.duration:SetFontObject(VeneerNumberFont)
Nenue@69 150 veneer.duration:SetPoint('TOP', frame, 'BOTTOM', 0, -8)
Nenue@69 151
Nenue@69 152 veneer.count = overlay:CreateFontString(name..'VeneerCount', 'OVERLAY')
Nenue@69 153 veneer.count:SetFontObject(VeneerNumberFont)
Nenue@69 154 veneer.count:SetPoint('BOTTOMRIGHT', frame, 'BOTTOMRIGHT', -3, 3)
Nenue@68 155
Nenue@68 156
Nenue@68 157
Nenue@68 158 veneer.border = underlay:CreateTexture(name..'VeneerBorder', 'BACKGROUND')
Nenue@68 159 veneer.border:SetPoint('TOPLEFT', veneer, 'TOPLEFT', -BORDER_SIZE_L, BORDER_SIZE_U)
Nenue@68 160 veneer.border:SetPoint('BOTTOMRIGHT', veneer, 'BOTTOMRIGHT', BORDER_SIZE_R, -BORDER_SIZE_D)
Nenue@68 161 veneer.border:Show()
Nenue@68 162
Nenue@69 163
Nenue@69 164 veneer.overlay = overlay
Nenue@69 165 veneer.underlay = underlay
Nenue@59 166 end
Nenue@59 167
Nenue@59 168
Nenue@69 169 return _G[name..'Veneer']
Nenue@59 170 end
Nenue@59 171
Nenue@68 172
Nenue@68 173 -- Associates skinning elements with said button
Nenue@68 174 local SkinFrame = function(name)
Nenue@68 175 local frame = _G[name ]
Nenue@68 176 if skinnedFrames[frame] then
Nenue@68 177 print('|cFFFF4400Attempting to skin a frame that already went through.|r')
Nenue@68 178 return
Nenue@68 179 end
Nenue@68 180 print('|cFFFFFF00Adopting', name)
Nenue@68 181
Nenue@68 182 local icon = _G[name .. 'Icon']
Nenue@68 183 local border = _G[name .. 'Border']
Nenue@68 184 local count = _G[name .. 'Count']
Nenue@68 185 local duration = _G[name .. 'Duration']
Nenue@68 186 local slot = frame:GetID() or 0
Nenue@69 187 local veneer = GetVeneer(frame)
Nenue@69 188 local underlay = veneer.underlay
Nenue@69 189 local overlay = veneer.overlay
Nenue@68 190
Nenue@68 191 skinnedFrames[frame] = frame
Nenue@68 192 frame:SetSize(BUFF_BUTTON_SIZE,BUFF_BUTTON_SIZE)
Nenue@68 193
Nenue@68 194 local offset = BUFF_BUTTON_ZOOM/2
Nenue@68 195 icon:SetTexCoord(offset, 1 - offset, offset, 1 - offset)
Nenue@68 196 if border then
Nenue@68 197 border:Hide()
Nenue@68 198 hooksecurefunc(border, 'SetVertexColor', function(frame, r, g, b, a)
Nenue@68 199 frame:Hide()
Nenue@68 200 print('|cFF0088FFborder:SetVertexColor|r', r,g,b,a)
Nenue@68 201 veneer.border:SetColorTexture(r,g,b,a)
Nenue@68 202 end)
Nenue@68 203
Nenue@68 204 local color = DebuffTypeColor["none"]
Nenue@68 205 if aurasCache[frame] and aurasCache[frame][5] then
Nenue@68 206 color = DebuffTypeColor[aurasCache[frame][5]]
Nenue@68 207 end
Nenue@68 208
Nenue@68 209 veneer.border:SetColorTexture(color.r,color.g,color.b)
Nenue@68 210 end
Nenue@68 211 if duration then
Nenue@68 212 duration:ClearAllPoints()
Nenue@69 213 --duration:SetPoint('TOP', frame, 'BOTTOM', 0, -8)
Nenue@69 214 --duration:SetFontObject(VeneerNumberFont)
Nenue@69 215 --duration:SetDrawLayer('OVERLAY')
Nenue@68 216
Nenue@69 217 hooksecurefunc(duration, 'Hide', function(self, text)
Nenue@69 218 veneer.duration:Hide()
Nenue@69 219 end)
Nenue@69 220 hooksecurefunc(duration, 'Show', function(self, text)
Nenue@69 221 veneer.duration:Show()
Nenue@69 222 end)
Nenue@69 223 end
Nenue@69 224 if count then
Nenue@69 225 count:ClearAllPoints()
Nenue@69 226 hooksecurefunc(count, 'SetText', function(self, text)
Nenue@69 227 self:Hide()
Nenue@69 228 veneer.count:SetText(text)
Nenue@69 229 end)
Nenue@69 230 hooksecurefunc(count, 'Hide', function(self, text)
Nenue@69 231 veneer.count:Hide()
Nenue@69 232 end)
Nenue@69 233 hooksecurefunc(count, 'Show', function(self, text)
Nenue@69 234 veneer.count:Show()
Nenue@69 235 end)
Nenue@68 236 end
Nenue@68 237
Nenue@68 238
Nenue@68 239 hooksecurefunc(frame, "Hide", function(self)
Nenue@68 240 local isVisible = self:IsVisible()
Nenue@68 241 if isVisible ~= visibility[self] then
Nenue@68 242 visibility[self] = isVisible
Nenue@68 243 end
Nenue@68 244 veneer:Hide()
Nenue@70 245 veneer.count:Hide()
Nenue@68 246 underlay:Hide()
Nenue@68 247 end)
Nenue@68 248
Nenue@68 249 hooksecurefunc(frame, 'Show', function(self)
Nenue@68 250 veneer:Show()
Nenue@70 251 veneer.count:Show()
Nenue@68 252 veneer.border:Show()
Nenue@68 253 underlay:Show()
Nenue@68 254 local isVisible = self:IsVisible()
Nenue@68 255 if isVisible ~= visibility[self] then
Nenue@68 256 print('|cFFFFFF00SHOW|r', self:GetName())
Nenue@68 257 visibility[self] = isVisible
Nenue@68 258 end
Nenue@68 259 end)
Nenue@68 260
Nenue@68 261 anchors[frame] = veneer
Nenue@68 262 end
Nenue@68 263
Nenue@68 264 local Aura_SetBorderColor = function(self, r,g,b,a) end
Nenue@68 265 local Aura_OnShow = function(self) end
Nenue@68 266 local Aura_OnHide = function(self) end
Nenue@68 267
Nenue@61 268 --- Set widgets to reflect the passed parameters
Nenue@59 269 local UpdateVeneer = function (frame, duration, expires)
Nenue@59 270 local veneer = GetVeneer(frame)
Nenue@68 271 -- is it a new button?
Nenue@68 272 if not skinnedFrames[frame] then
Nenue@68 273 SkinFrame(frame:GetName())
Nenue@68 274 end
Nenue@68 275
Nenue@68 276 if frame.filter == 'HARMFUL' then
Nenue@68 277
Nenue@68 278 veneer.border:Show()
Nenue@68 279 end
Nenue@68 280
Nenue@59 281
Nenue@61 282 if expires and duration then
Nenue@61 283 if duration ~= 0 then
Nenue@61 284 local startTime = (expires - duration)
Nenue@61 285 local endTime = expires or 0
Nenue@61 286 print('|cFF0088FF'..frame:GetName()..'|r', duration, expires)
Nenue@61 287 veneer.progress:Show()
Nenue@61 288 veneer.elapsed = 0
Nenue@61 289 veneer.progress:SetScript('OnUpdate', function(self, elapsed)
Nenue@61 290 veneer.elapsed = veneer.elapsed + elapsed
Nenue@60 291
Nenue@67 292 local w = floor(veneer.progress:GetWidth()+.5) - (BUFF_PROGRESS_INSET*2)
Nenue@61 293 local t = GetTime()
Nenue@61 294 local progress = (t - startTime) / duration
Nenue@61 295
Nenue@67 296 local nw = (w - (w * progress))
Nenue@61 297 if veneer.elapsed >= 0.25 then
Nenue@61 298
Nenue@68 299 tprint(t, startTime, floor(progress*100), w * progress, nw, w)
Nenue@61 300 veneer.elapsed = 0.25 - veneer.elapsed
Nenue@61 301 end
Nenue@61 302 if (progress >= 1) or not frame:IsVisible() then
Nenue@61 303 veneer.startTime = nil
Nenue@61 304 self:Hide()
Nenue@61 305 self:SetScript('OnUpdate', nil)
Nenue@61 306 else
Nenue@61 307 self.fg:SetWidth(nw)
Nenue@61 308 end
Nenue@61 309 end)
Nenue@61 310
Nenue@61 311 veneer.cooldown:Show()
Nenue@61 312 veneer.cooldown:SetCooldown(startTime, duration)
Nenue@61 313 else
Nenue@61 314 print('|cFF00FF88'..frame:GetName()..'|r', 'duration zero')
Nenue@61 315 veneer.progress:SetScript('OnUpdate', nil)
Nenue@61 316 veneer.progress:Hide()
Nenue@61 317 veneer.cooldown:Hide()
Nenue@61 318 end
Nenue@61 319 else
Nenue@61 320 veneer.progress:Hide()
Nenue@61 321 veneer.cooldown:SetCooldown(0,0)
Nenue@61 322 veneer.cooldown:Hide()
Nenue@61 323 print('|cFF88FF00'..frame:GetName()..'|r', 'nil duration')
Nenue@59 324 end
Nenue@59 325 veneer:Show()
Nenue@59 326 end
Nenue@59 327
Nenue@59 328
Nenue@59 329 --- Provides the number of changed indices for use in deciding between partial and full veneer updates
Nenue@59 330 local CacheCheck = function(frame, ...)
Nenue@59 331 aurasCache[frame] = aurasCache[frame] or {}
Nenue@59 332 local hasChange = 0
Nenue@59 333 local numVals = select('#',...)
Nenue@59 334 for i = 1, numVals do
Nenue@59 335 local arg = select(i, ...)
Nenue@59 336 if aurasCache[frame][i] ~= arg then
Nenue@59 337 hasChange = hasChange + 1
Nenue@59 338 end
Nenue@59 339 aurasCache[frame][i] = arg
Nenue@59 340 end
Nenue@59 341 return hasChange
Nenue@59 342 end
Nenue@59 343
Nenue@59 344 local AuraButton_Update = function(name, index, filter)
Nenue@59 345 local bName = name..index
Nenue@59 346 local frame = _G[bName]
Nenue@59 347 if frame and frame:IsVisible() then
Nenue@59 348 tickCounter[frame] = (tickCounter[frame] or 0) + 1
Nenue@68 349
Nenue@68 350
Nenue@68 351
Nenue@59 352 local cacheDiff = CacheCheck(frame, UnitAura(frame.unit, frame:GetID(), frame.filter))
Nenue@68 353
Nenue@61 354 -- if the name or expirationTime changed
Nenue@61 355 if (cacheDiff >= 1) then
Nenue@68 356 print('|cFFFF4400', frame:GetName(), 'diff:', cacheDiff)
Nenue@61 357 if not skinnedFrames[frame] then
Nenue@61 358 tinsert(pendingFrames, frame)
Nenue@61 359 end
Nenue@59 360 expirationCache[name] = frame.expirationTime
Nenue@59 361 print(unpack(aurasCache[frame]))
Nenue@68 362
Nenue@68 363
Nenue@68 364
Nenue@59 365 UpdateVeneer(frame, aurasCache[frame][6], aurasCache[frame][7])
Nenue@59 366 end
Nenue@59 367
Nenue@59 368 end
Nenue@59 369 end
Nenue@59 370
Nenue@59 371 local BuffFrame_UpdateAllBuffAnchors = function()
Nenue@59 372 local todo = {}
Nenue@59 373 if #pendingFrames >= 1 then
Nenue@59 374
Nenue@59 375 print('|cFFBBFF00AllBuffAnchors|r', #pendingFrames)
Nenue@59 376 while pendingFrames[1] do
Nenue@59 377 local frame = tremove(pendingFrames)
Nenue@59 378 tinsert(todo, frame:GetName())
Nenue@59 379
Nenue@61 380 -- re-apply custom anchors
Nenue@59 381 end
Nenue@68 382 print(tconcat(todo, ', '))
Nenue@59 383 end
Nenue@59 384 --BuffButton1
Nenue@59 385 --DebuffButton1
Nenue@61 386 --todo: separate frame groups and iterate over them at appropriate times
Nenue@60 387 if BuffButton1 then
Nenue@68 388 TempEnchant1:SetPoint('TOPRIGHT', BuffButton1, 'TOPRIGHT', BuffButton1:GetWidth()+4, 0)
Nenue@60 389 end
Nenue@60 390
Nenue@70 391 local lastBuff, topBuff
Nenue@70 392 for i = 1, BUFF_ACTUAL_DISPLAY do
Nenue@70 393 local buff = _G['BuffButton'..i]
Nenue@70 394 if buff then
Nenue@70 395 if i == 1 then
Nenue@70 396 buff:SetPoint('TOPRIGHT', UIParent, 'TOPRIGHT', -120, -6)
Nenue@70 397 topBuff = buff
Nenue@70 398 elseif mod(i,12) == 1 then
Nenue@70 399 buff:SetPoint('TOPRIGHT', topBuff, 'BOTTOMRIGHT', 0, -14)
Nenue@70 400 topBuff = buff
Nenue@70 401 else
Nenue@70 402 buff:SetPoint('TOPRIGHT', lastBuff, 'TOPLEFT')
Nenue@70 403 end
Nenue@70 404 lastBuff = buff
Nenue@70 405 end
Nenue@70 406 end
Nenue@70 407
Nenue@70 408 for i = 1, DEBUFF_ACTUAL_DISPLAY do
Nenue@70 409 local debuff = _G['DebuffButton'..i]
Nenue@70 410 if debuff then
Nenue@70 411 if i == 1 then
Nenue@70 412 if topBuff then
Nenue@70 413 debuff:SetPoint('TOPRIGHT', topBuff, 'BOTTOMRIGHT', 0, -14)
Nenue@70 414 else
Nenue@70 415 debuff:SetPoint('TOPRIGHT', UIParent, 'TOPRIGHT', -120, -6)
Nenue@70 416 end
Nenue@70 417 topBuff = debuff
Nenue@70 418 elseif mod(i, 12) == 1 then
Nenue@70 419 debuff:SetPoint('TOPRIGHT', topBuff, 'BOTTOMRIGHT', 0, -14)
Nenue@70 420 topBuff = debuff
Nenue@70 421 else
Nenue@70 422 debuff:SetPoint('TOPRIGHT', lastBuff, 'TOPLEFT')
Nenue@70 423 end
Nenue@70 424 lastBuff = debuff
Nenue@70 425 end
Nenue@70 426 end
Nenue@70 427
Nenue@59 428 end
Nenue@59 429
Nenue@59 430 local AuraButton_UpdateDuration = function(frame, timeLeft)
Nenue@69 431 local veneer = GetVeneer(frame)
Nenue@60 432 local hours = floor(timeLeft/3600)
Nenue@60 433 local minutes = floor(mod(timeLeft, 3600)/60)
Nenue@60 434 local seconds = floor(mod(timeLeft, 60))
Nenue@60 435 local timeString = '%ds'
Nenue@59 436 if timeLeft > 3600 then
Nenue@60 437 timeString = format('%d:%02d', hours, minutes)
Nenue@60 438 elseif timeLeft > 60 then
Nenue@60 439 timeString = format('%d:%02d', minutes, seconds)
Nenue@61 440 else
Nenue@60 441 timeString = format('%d', seconds)
Nenue@59 442 end
Nenue@59 443
Nenue@60 444
Nenue@69 445 veneer.duration:SetText(timeString)
Nenue@69 446 veneer.duration:SetVertexColor(1,1,1)
Nenue@59 447 end
Nenue@59 448
Nenue@59 449
Nenue@59 450 -- Obtains the first instance of Tenchant use
Nenue@59 451
Nenue@59 452 local TemporaryEnchantFrame_Update = function(...)
Nenue@59 453 local numVals = select('#', ...)
Nenue@59 454 local numItems = numVals / 4
Nenue@59 455 if numItems >= 1 then
Nenue@59 456 for itemIndex = numItems, 1, -1 do
Nenue@59 457 local frame = _G['TempEnchant'..itemIndex]
Nenue@59 458 local hasEnchant, timeRemaining, enchantCharges = select((4 * (itemIndex -1)) + 1, ...)
Nenue@59 459
Nenue@59 460
Nenue@59 461 if hasEnchant then
Nenue@59 462 local endTime = floor(GetTime()*1000) + timeRemaining
Nenue@59 463
Nenue@59 464
Nenue@59 465 --print(endTime)
Nenue@59 466 if endTime ~= expirationCache[frame] then
Nenue@59 467 if expirationCache[frame] then
Nenue@59 468 print(endTime, expirationCache[frame], endTime - expirationCache[frame])
Nenue@59 469 end
Nenue@59 470 expirationCache[frame] = endTime
Nenue@59 471 print('push tempenchant timer update', timeRemaining / 1000, GetTime()+(timeRemaining/1000))
Nenue@59 472 UpdateVeneer(frame, timeRemaining/1000, GetTime()+(timeRemaining/1000))
Nenue@59 473 end
Nenue@59 474 else
Nenue@59 475 GetVeneer(frame):Hide()
Nenue@59 476 end
Nenue@59 477
Nenue@59 478 end
Nenue@59 479
Nenue@59 480 end
Nenue@59 481
Nenue@59 482 end
Nenue@59 483
Nenue@59 484 local BuffFrame_Update = function(...)
Nenue@61 485
Nenue@59 486 end
Nenue@59 487
Nenue@59 488
Nenue@59 489 hooksecurefunc("BuffFrame_Update", BuffFrame_Update)
Nenue@59 490 hooksecurefunc("AuraButton_UpdateDuration", AuraButton_UpdateDuration)
Nenue@59 491 hooksecurefunc("AuraButton_Update", AuraButton_Update)
Nenue@59 492 hooksecurefunc("BuffFrame_UpdateAllBuffAnchors", BuffFrame_UpdateAllBuffAnchors)
Nenue@59 493 hooksecurefunc("TemporaryEnchantFrame_Update", TemporaryEnchantFrame_Update)
Nenue@59 494
Nenue@59 495 -- The TempEnchant frames are hardcoded in the base FrameXML, so get them now
Nenue@59 496 for i = 1, 3 do
Nenue@59 497
Nenue@59 498 SkinFrame('TempEnchant'..i)
Nenue@68 499 _G['TempEnchant'..i..'Border']:SetVertexColor(0.5,0,1,1)
Nenue@59 500
Nenue@59 501 end
Nenue@59 502
Nenue@59 503 plugin.init = function ()
Nenue@61 504
Nenue@61 505
Nenue@61 506
Nenue@59 507 plugin.db = vn.db[PLUGIN_NAME]
Nenue@59 508 end