annotate Modules/BuffFrame.lua @ 138:6e2f20230190 tip

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