annotate Modules/BuffFrame.lua @ 96:bb38bc0e787f

- fix weapon slot anchors for paperdoll
author Nenue
date Tue, 03 Jan 2017 14:06:41 -0500
parents 43303398d1b9
children 5476337198ec
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@95 183 print(self:GetName(), 'OnShow')
Nenue@94 184 self.underlay:Show()
Nenue@94 185 end
Nenue@94 186 function Facade:OnHide()
Nenue@95 187
Nenue@95 188 print(self:GetName(), 'OnHide')
Nenue@94 189 self.underlay:Hide()
Nenue@95 190
Nenue@94 191 end
Nenue@94 192
Nenue@94 193 function Facade:OnLoad()
Nenue@94 194
Nenue@94 195 self.duration = self.progress.duration
Nenue@94 196 self.count = self.overlay.count
Nenue@94 197 self.border = self.underlay.bg
Nenue@94 198
Nenue@94 199 VeneerBuffFrame.ConfigLayers = VeneerBuffFrame.ConfigLayers or {}
Nenue@94 200 self.configIndex = #VeneerBuffFrame.ConfigLayers
Nenue@94 201 for i, region in ipairs(self.ConfigLayers) do
Nenue@94 202 tinsert(VeneerBuffFrame.ConfigLayers, region)
Nenue@94 203 end
Nenue@94 204
Nenue@94 205 self.configIndexEnd = #VeneerBuffFrame.ConfigLayers
Nenue@94 206 end
Nenue@94 207
Nenue@94 208 function Facade:Setup()
Nenue@94 209 self:SetSize(BUFF_BUTTON_SIZE,BUFF_BUTTON_SIZE)
Nenue@94 210
Nenue@94 211 self.progress[OFFSET_PARALLELS[PROGRESS_ANCHOR][3]](self.progress, BUFF_PROGRESS_SIZE + (BUFF_PROGRESS_INSET * 2))
Nenue@94 212 --print(BUFF_PROGRESS_SIZE + (BUFF_PROGRESS_INSET * 2))
Nenue@94 213
Nenue@94 214 self.progress:ClearAllPoints()
Nenue@94 215 self.progress:SetPoint(ANCHOR_OFFSET_POINT[PROGRESS_ANCHOR], PROGRESS_PARENT or self.border, PROGRESS_ANCHOR,
Nenue@94 216 (ANCHOR_INSET_DELTA[PROGRESS_ANCHOR][1] * PROGRESS_OFFSET * -1),
Nenue@94 217 (ANCHOR_INSET_DELTA[PROGRESS_ANCHOR][2] * PROGRESS_OFFSET * -1))
Nenue@94 218 self.progress:SetPoint(OFFSET_PARALLELS[PROGRESS_ANCHOR][1], self.border, OFFSET_PARALLELS[PROGRESS_ANCHOR][1], 0, 0)
Nenue@94 219 self.progress:SetPoint(OFFSET_PARALLELS[PROGRESS_ANCHOR][2], self.border, OFFSET_PARALLELS[PROGRESS_ANCHOR][2], 0, 0)
Nenue@94 220
Nenue@94 221 --print(self.progress:GetPoint(1))
Nenue@94 222 --print(self.progress:GetPoint(2))
Nenue@94 223 --print(self.progress:GetPoint(3))
Nenue@94 224 self.progress:Show()
Nenue@94 225
Nenue@94 226 self.progress.bg:ClearAllPoints()
Nenue@94 227 self.progress.bg:SetAllPoints(self.progress)
Nenue@94 228
Nenue@94 229 self.progress.fg:ClearAllPoints()
Nenue@94 230 self.progress.fg:SetPoint('BOTTOMLEFT', BUFF_PROGRESS_INSET,BUFF_PROGRESS_INSET)
Nenue@94 231 self.progress.fg:SetPoint('TOP', 0, -BUFF_PROGRESS_INSET)
Nenue@94 232 --self.count:ClearAllPoints()
Nenue@94 233 --self.count:SetPoint('TOPRIGHT', self,'TOPRIGHT', -3, -3)
Nenue@94 234
Nenue@94 235
Nenue@94 236 self.duration:ClearAllPoints()
Nenue@94 237 self.duration:SetPoint(DURATION_ANCHOR, DURATION_PARENT or self, DURATION_ANCHOR,
Nenue@94 238 (ANCHOR_INSET_DELTA[DURATION_ANCHOR][1] * DURATION_INSET),
Nenue@94 239 (ANCHOR_INSET_DELTA[DURATION_ANCHOR][2] * DURATION_INSET))
Nenue@94 240
Nenue@94 241 self.count:ClearAllPoints()
Nenue@94 242 self.count:SetPoint(COUNT_ANCHOR, COUNT_PARENT or self, COUNT_ANCHOR,
Nenue@94 243 (ANCHOR_INSET_DELTA[COUNT_ANCHOR][1] * COUNT_INSET),
Nenue@94 244 (ANCHOR_INSET_DELTA[COUNT_ANCHOR][2] * COUNT_INSET))
Nenue@94 245
Nenue@96 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@94 260 function plugin:AcquireConfigButton(name)
Nenue@94 261 print('|cFF88FF00Creating config dummy', name,'Veneer')
Nenue@94 262 local button = self.Buttons[name]
Nenue@94 263 if not button then
Nenue@94 264 button = CreateFrame('Frame', name .. 'Veneer', self, 'VeneerBuffTemplate')
Nenue@94 265 button:Setup()
Nenue@94 266 button:SetShown(true)
Nenue@94 267 self.Buttons[name] = button
Nenue@94 268 end
Nenue@94 269 return button
Nenue@94 270 end
Nenue@94 271
Nenue@94 272 function plugin:Acquire(name)
Nenue@94 273 local frame = self.Buttons[name]
Nenue@94 274 if not frame then
Nenue@94 275 local target = _G[name]
Nenue@84 276 local id = target:GetID()
Nenue@94 277 print('|cFF88FF00Creating', name .. 'Veneer')
Nenue@93 278 frame = vn:Acquire(target, 'VeneerBuffTemplate')
Nenue@94 279 frame:Setup()
Nenue@94 280 self.Buttons[name] = frame
Nenue@59 281 end
Nenue@84 282 return frame
Nenue@59 283 end
Nenue@59 284
Nenue@94 285 function plugin:OnLoad()
Nenue@84 286 Veneer:AddHandler(self, self.defaultCluster)
Nenue@84 287 end
Nenue@68 288
Nenue@94 289 function plugin:Setup()
Nenue@84 290
Nenue@84 291
Nenue@84 292 hooksecurefunc("BuffFrame_Update", function(...) self:OnBuffFrameUpdate(...) end)
Nenue@93 293 --hooksecurefunc("AuraButton_UpdateDuration", function(...) self:OnUpdateDuration(...) end)
Nenue@84 294 hooksecurefunc("AuraButton_Update", function(...) self:OnAuraButton_Update(...) end)
Nenue@84 295 hooksecurefunc("BuffFrame_UpdateAllBuffAnchors", function(...) self:OnUpdateAllBuffAnchors(...) end)
Nenue@84 296 hooksecurefunc("TemporaryEnchantFrame_Update", function(...) self:OnTemporaryEnchantFrameUpdate(...) end)
Nenue@84 297 for i = 1, 3 do
Nenue@84 298 self:SetupButton('TempEnchant'..i)
Nenue@84 299 _G['TempEnchant'..i..'Border']:SetVertexColor(0.5,0,1,1)
Nenue@84 300 end
Nenue@84 301 end
Nenue@86 302
Nenue@94 303 function plugin:SetHidden(region)
Nenue@93 304 if not self.hiddenRegions[region] then
Nenue@93 305 self.hiddenRegions[region] = true
Nenue@93 306 region:SetShown(false)
Nenue@93 307 hooksecurefunc(region)
Nenue@93 308 end
Nenue@93 309 end
Nenue@84 310
Nenue@94 311 function plugin:SetupButton (name)
Nenue@94 312 local frame = _G[name]
Nenue@95 313 print('|cFFFFFF00Adopting', name)
Nenue@68 314
Nenue@68 315 local icon = _G[name .. 'Icon']
Nenue@68 316 local border = _G[name .. 'Border']
Nenue@68 317 local count = _G[name .. 'Count']
Nenue@68 318 local duration = _G[name .. 'Duration']
Nenue@94 319 local veneer = self:Acquire(name)
Nenue@84 320 local offset = BUFF_BUTTON_ZOOM/2
Nenue@68 321
Nenue@84 322 self.DetectedFrames[frame] = frame
Nenue@68 323 frame:SetSize(BUFF_BUTTON_SIZE,BUFF_BUTTON_SIZE)
Nenue@84 324 icon:SetTexCoord(offset, 1 - offset, offset, 1 - offset)
Nenue@68 325
Nenue@78 326
Nenue@84 327 DoRegionHooks(veneer, border)
Nenue@68 328 if border then
Nenue@68 329 local color = DebuffTypeColor["none"]
Nenue@68 330 if aurasCache[frame] and aurasCache[frame][5] then
Nenue@68 331 color = DebuffTypeColor[aurasCache[frame][5]]
Nenue@68 332 end
Nenue@71 333 veneer.progress.fg:SetColorTexture(color.r,color.g,color.b)
Nenue@75 334 veneer.border:SetColorTexture(0,0,0,1)
Nenue@79 335 veneer.border:Show()
Nenue@79 336 else
Nenue@79 337 veneer.border:SetColorTexture(0,0,0,1)
Nenue@79 338 veneer.border:Show()
Nenue@68 339 end
Nenue@68 340
Nenue@93 341 if count then
Nenue@86 342 count:ClearAllPoints()
Nenue@93 343 hooksecurefunc(count, 'Show', function(self) self:Hide() end)
Nenue@93 344 if count:GetText() then
Nenue@93 345 veneer.count:SetText(count:GetText())
Nenue@93 346 end
Nenue@86 347 end
Nenue@86 348 if duration then
Nenue@86 349 duration:ClearAllPoints()
Nenue@86 350 end
Nenue@86 351
Nenue@95 352 hooksecurefunc(frame, "Hide", function(frame)
Nenue@68 353 veneer:Hide()
Nenue@68 354 end)
Nenue@68 355
Nenue@95 356 hooksecurefunc(frame, 'Show', function(frame)
Nenue@68 357 veneer:Show()
Nenue@68 358 end)
Nenue@68 359
Nenue@95 360 hooksecurefunc(frame, 'SetShown', function(frame, isShown)
Nenue@95 361 veneer:SetShown(isShown)
Nenue@95 362 end)
Nenue@95 363
Nenue@95 364
Nenue@94 365 veneer:SetParent(UIParent)
Nenue@94 366 veneer:SetAllPoints(frame)
Nenue@95 367 veneer:SetFrameStrata('MEDIUM')
Nenue@68 368 end
Nenue@68 369
Nenue@68 370
Nenue@61 371 --- Set widgets to reflect the passed parameters
Nenue@94 372 function plugin:UpdateButton (name, duration, expires)
Nenue@94 373 local frame = _G[name]
Nenue@94 374 local veneer = self:Acquire(name)
Nenue@68 375 -- is it a new button?
Nenue@84 376 if not self.DetectedFrames[frame] then
Nenue@94 377 print('|cFFFF4400detected', name)
Nenue@94 378 self:SetupButton(name)
Nenue@68 379 end
Nenue@94 380 print(veneer:GetParent():GetName(), veneer:GetPoint(1))
Nenue@86 381 --[[
Nenue@86 382 if frame.count then
Nenue@86 383 frame.count:SetText('test')
Nenue@86 384 frame.count:Show()
Nenue@86 385 end
Nenue@86 386 --]]
Nenue@86 387 local name, rank, icon, count, _, duration, expires = UnitAura(frame.unit, frame:GetID(), frame.filter)
Nenue@86 388
Nenue@59 389
Nenue@61 390 if expires and duration then
Nenue@61 391 if duration ~= 0 then
Nenue@61 392 local startTime = (expires - duration)
Nenue@61 393 local endTime = expires or 0
Nenue@61 394 print('|cFF0088FF'..frame:GetName()..'|r', duration, expires)
Nenue@61 395 veneer.progress:Show()
Nenue@61 396 veneer.elapsed = 0
Nenue@61 397 veneer.progress:SetScript('OnUpdate', function(self, elapsed)
Nenue@61 398 veneer.elapsed = veneer.elapsed + elapsed
Nenue@60 399
Nenue@67 400 local w = floor(veneer.progress:GetWidth()+.5) - (BUFF_PROGRESS_INSET*2)
Nenue@61 401 local t = GetTime()
Nenue@61 402 local progress = (t - startTime) / duration
Nenue@61 403
Nenue@67 404 local nw = (w - (w * progress))
Nenue@61 405 if veneer.elapsed >= 0.25 then
Nenue@61 406
Nenue@93 407 --tprint(t, startTime, floor(progress*100), w * progress, nw, w)
Nenue@61 408 veneer.elapsed = 0.25 - veneer.elapsed
Nenue@61 409 end
Nenue@61 410 if (progress >= 1) or not frame:IsVisible() then
Nenue@61 411 veneer.startTime = nil
Nenue@61 412 self:Hide()
Nenue@61 413 self:SetScript('OnUpdate', nil)
Nenue@61 414 else
Nenue@61 415 self.fg:SetWidth(nw)
Nenue@61 416 end
Nenue@61 417 end)
Nenue@61 418
Nenue@61 419 veneer.cooldown:Show()
Nenue@61 420 veneer.cooldown:SetCooldown(startTime, duration)
Nenue@61 421 else
Nenue@61 422 print('|cFF00FF88'..frame:GetName()..'|r', 'duration zero')
Nenue@61 423 veneer.progress:SetScript('OnUpdate', nil)
Nenue@61 424 veneer.progress:Hide()
Nenue@61 425 veneer.cooldown:Hide()
Nenue@61 426 end
Nenue@86 427
Nenue@90 428 if count and count > 1 then
Nenue@86 429 veneer.count:SetText(count)
Nenue@86 430 veneer.count:Show()
Nenue@90 431 frame.count:ClearAllPoints()
Nenue@86 432 else
Nenue@86 433 veneer.count:Hide()
Nenue@86 434 end
Nenue@86 435
Nenue@86 436
Nenue@61 437 else
Nenue@61 438 veneer.progress:Hide()
Nenue@61 439 veneer.cooldown:SetCooldown(0,0)
Nenue@61 440 veneer.cooldown:Hide()
Nenue@61 441 print('|cFF88FF00'..frame:GetName()..'|r', 'nil duration')
Nenue@59 442 end
Nenue@59 443 veneer:Show()
Nenue@59 444 end
Nenue@59 445
Nenue@59 446
Nenue@59 447 --- Provides the number of changed indices for use in deciding between partial and full veneer updates
Nenue@94 448 function plugin:ButtonHasChanged (frame, ...)
Nenue@59 449 aurasCache[frame] = aurasCache[frame] or {}
Nenue@59 450 local hasChange = 0
Nenue@59 451 local numVals = select('#',...)
Nenue@59 452 for i = 1, numVals do
Nenue@59 453 local arg = select(i, ...)
Nenue@59 454 if aurasCache[frame][i] ~= arg then
Nenue@59 455 hasChange = hasChange + 1
Nenue@59 456 end
Nenue@59 457 aurasCache[frame][i] = arg
Nenue@59 458 end
Nenue@59 459 return hasChange
Nenue@59 460 end
Nenue@59 461
Nenue@94 462 function plugin:OnAuraButton_Update (name, index, filter)
Nenue@59 463 local bName = name..index
Nenue@59 464 local frame = _G[bName]
Nenue@59 465 if frame and frame:IsVisible() then
Nenue@61 466 -- if the name or expirationTime changed
Nenue@86 467
Nenue@94 468 if not skinnedFrames[bName] then
Nenue@94 469 tinsert(pendingFrames, bName)
Nenue@61 470 end
Nenue@59 471 expirationCache[name] = frame.expirationTime
Nenue@94 472 self:UpdateButton(bName)
Nenue@68 473
Nenue@59 474
Nenue@59 475 end
Nenue@59 476 end
Nenue@59 477
Nenue@94 478 function plugin:OnUpdateAllBuffAnchors ()
Nenue@59 479
Nenue@59 480 --BuffButton1
Nenue@59 481 --DebuffButton1
Nenue@61 482 --todo: separate frame groups and iterate over them at appropriate times
Nenue@60 483 if BuffButton1 then
Nenue@78 484
Nenue@68 485 TempEnchant1:SetPoint('TOPRIGHT', BuffButton1, 'TOPRIGHT', BuffButton1:GetWidth()+4, 0)
Nenue@60 486 end
Nenue@60 487
Nenue@70 488 local lastBuff, topBuff
Nenue@74 489 local numBuffs = 0
Nenue@90 490 local numColumns = 1
Nenue@90 491 local maxColumn = 1
Nenue@94 492 local limit = self.configMode and BUFF_MAX_DISPLAY or BUFF_ACTUAL_DISPLAY
Nenue@94 493 for i = 1, limit do
Nenue@94 494 local name = 'BuffButton'..i
Nenue@94 495 local buff = _G[name] or self.Buttons[name]
Nenue@94 496 print(buff:GetName(), self.configMode)
Nenue@70 497 if buff then
Nenue@74 498 numBuffs = numBuffs + 1
Nenue@74 499 buff:ClearAllPoints()
Nenue@75 500 if mod(numBuffs,BUFFS_PER_ROW) == 1 then
Nenue@74 501 if numBuffs == 1 then
Nenue@80 502 buff:SetPoint('TOPRIGHT', UIParent, 'TOPRIGHT', BUFF_FRAMES_X, BUFF_FRAMES_Y)
Nenue@90 503 plugin.currentTop = buff
Nenue@71 504 else
Nenue@71 505 buff:SetPoint('TOPRIGHT', topBuff, 'BOTTOMRIGHT', 0, -BUFF_BUTTON_SPACING_V)
Nenue@71 506 end
Nenue@90 507 numColumns = 1
Nenue@70 508 topBuff = buff
Nenue@70 509 else
Nenue@71 510 buff:SetPoint('TOPRIGHT', lastBuff, 'TOPLEFT', -BUFF_BUTTON_SPACING_H, 0)
Nenue@90 511 numColumns = numColumns + 1
Nenue@90 512 end
Nenue@90 513 if numColumns > maxColumn then
Nenue@90 514 maxColumn = numColumns
Nenue@90 515 plugin.currentLeft = buff
Nenue@70 516 end
Nenue@70 517 lastBuff = buff
Nenue@70 518 end
Nenue@70 519 end
Nenue@70 520
Nenue@74 521 numBuffs = 0
Nenue@94 522 limit = self.configMode and DEBUFF_MAX_DISPLAY or DEBUFF_ACTUAL_DISPLAY
Nenue@70 523 for i = 1, DEBUFF_ACTUAL_DISPLAY do
Nenue@94 524 local name = 'DebuffButton'..i
Nenue@94 525 local debuff = _G[name] or self.Buttons[name]
Nenue@70 526 if debuff then
Nenue@74 527 numBuffs = numBuffs + 1
Nenue@93 528 if mod(numBuffs, BUFFS_PER_ROW) == 1 then
Nenue@93 529
Nenue@93 530 if topBuff then
Nenue@93 531 debuff:SetPoint('TOPRIGHT', topBuff, 'BOTTOMRIGHT', 0, -BUFF_BUTTON_SPACING_V)
Nenue@93 532 else
Nenue@93 533 debuff:SetPoint('TOPRIGHT', UIParent, 'TOPRIGHT', BUFF_FRAMES_X, BUFF_FRAMES_Y)
Nenue@93 534 end
Nenue@93 535 topBuff = debuff
Nenue@93 536
Nenue@70 537 else
Nenue@71 538 debuff:SetPoint('TOPRIGHT', lastBuff, 'TOPLEFT', -BUFF_BUTTON_SPACING_H, 0)
Nenue@70 539 end
Nenue@70 540 lastBuff = debuff
Nenue@94 541
Nenue@70 542 end
Nenue@70 543 end
Nenue@70 544
Nenue@74 545 if lastBuff then
Nenue@90 546 plugin.currentBottom = lastBuff
Nenue@74 547 end
Nenue@90 548
Nenue@90 549 self.Background:ClearAllPoints()
Nenue@90 550 self.Background:SetPoint('TOPRIGHT', plugin.currentTop, 'TOPRIGHT', 4, 4)
Nenue@90 551 self.Background:SetPoint('BOTTOM', plugin.currentBottom, 'BOTTOM', 0, -4)
Nenue@90 552 self.Background:SetPoint('LEFT', plugin.currentLeft, 'LEFT', -4, 0)
Nenue@59 553 end
Nenue@94 554 function plugin:UpdateConfigLayers (configMode)
Nenue@90 555 self:SetShown(configMode)
Nenue@94 556 self.configMode = configMode
Nenue@94 557 for i = 1, BUFF_MAX_DISPLAY do
Nenue@94 558 local name = 'BuffButton' .. i
Nenue@94 559 local button = self:AcquireConfigButton(name)
Nenue@94 560 end
Nenue@94 561 for i = 1, DEBUFF_MAX_DISPLAY do
Nenue@94 562 local name = 'DebuffButton' .. i
Nenue@94 563 local button = self:AcquireConfigButton(name)
Nenue@93 564 end
Nenue@90 565 end
Nenue@94 566 function plugin:OnUpdateDuration (frame, timeLeft)
Nenue@84 567 local veneer = self:Acquire(frame)
Nenue@60 568 local hours = floor(timeLeft/3600)
Nenue@60 569 local minutes = floor(mod(timeLeft, 3600)/60)
Nenue@60 570 local seconds = floor(mod(timeLeft, 60))
Nenue@60 571 local timeString = '%ds'
Nenue@59 572 if timeLeft > 3600 then
Nenue@60 573 timeString = format('%d:%02d', hours, minutes)
Nenue@60 574 elseif timeLeft > 60 then
Nenue@60 575 timeString = format('%d:%02d', minutes, seconds)
Nenue@61 576 else
Nenue@60 577 timeString = format('%d', seconds)
Nenue@59 578 end
Nenue@59 579
Nenue@74 580 if timeLeft < 10 then
Nenue@74 581 if not veneer.duration.getHuge then
Nenue@74 582 veneer.duration.getHuge = true
Nenue@74 583 veneer.duration:SetFontObject(VeneerNumberFontLarge)
Nenue@75 584 veneer.duration:SetTextColor(1,1,0,1)
Nenue@74 585 end
Nenue@74 586 else
Nenue@74 587 if veneer.duration.getHuge then
Nenue@74 588 veneer.duration.getHuge = nil
Nenue@74 589 veneer.duration:SetFontObject(VeneerNumberFont)
Nenue@74 590 veneer.duration:SetTextColor(1,1,1,1)
Nenue@74 591 end
Nenue@74 592 end
Nenue@74 593
Nenue@69 594 veneer.duration:SetText(timeString)
Nenue@59 595 end
Nenue@59 596
Nenue@59 597
Nenue@59 598 -- Obtains the first instance of Tenchant use
Nenue@59 599
Nenue@94 600 function plugin:OnTemporaryEnchantFrameUpdate (...)
Nenue@59 601 local numVals = select('#', ...)
Nenue@59 602 local numItems = numVals / 4
Nenue@59 603 if numItems >= 1 then
Nenue@59 604 for itemIndex = numItems, 1, -1 do
Nenue@94 605 local name = 'TempEnchant'..itemIndex
Nenue@94 606 local frame = _G[name]
Nenue@59 607 local hasEnchant, timeRemaining, enchantCharges = select((4 * (itemIndex -1)) + 1, ...)
Nenue@59 608
Nenue@59 609
Nenue@59 610 if hasEnchant then
Nenue@59 611 local endTime = floor(GetTime()*1000) + timeRemaining
Nenue@59 612
Nenue@59 613
Nenue@59 614 --print(endTime)
Nenue@59 615 if endTime ~= expirationCache[frame] then
Nenue@59 616 if expirationCache[frame] then
Nenue@59 617 print(endTime, expirationCache[frame], endTime - expirationCache[frame])
Nenue@59 618 end
Nenue@59 619 expirationCache[frame] = endTime
Nenue@59 620 print('push tempenchant timer update', timeRemaining / 1000, GetTime()+(timeRemaining/1000))
Nenue@94 621 self:UpdateButton(frame, timeRemaining/1000, GetTime()+(timeRemaining/1000))
Nenue@59 622 end
Nenue@59 623 else
Nenue@94 624 self:Acquire(name):Hide()
Nenue@59 625 end
Nenue@59 626 end
Nenue@59 627 end
Nenue@59 628 end
Nenue@59 629
Nenue@94 630 function plugin:OnBuffFrameUpdate () end
Nenue@59 631
Nenue@90 632
Nenue@84 633 -- The TempEnchant frames are hardcoded in the base FrameXML, so get them now
Nenue@59 634