Nenue@59: -- Veneer Nenue@59: -- BuffFrame.lua Nenue@59: -- Created: 7/27/2016 8:08 PM Nenue@59: -- %file-revision% Nenue@62: --[[ Nenue@62: Adds progress bars and cooldown swirls to buffbutton frames Nenue@60: Nenue@62: Known Limitations: Nenue@62: - Individual BuffButton frames are created upon use, making it difficult to do any sort of securestate priming Nenue@62: - TempEnchant info returns relative values only, and they don't synchronize with aura events Nenue@62: - BuffButtons can only be hidden/shown by blizzcode, so functions doing that have to be accounted for Nenue@62: --]] Nenue@62: Nenue@90: Nenue@75: local BUFFS_PER_ROW = 12 Nenue@64: local BUFF_BUTTON_SIZE = 48 Nenue@86: local BUFF_BUTTON_SPACING_H = 5 Nenue@71: local BUFF_BUTTON_SPACING_V = 14 Nenue@64: local BUFF_PROGRESS_SIZE = 4 Nenue@86: local BUFF_PROGRESS_INSET = 2 Nenue@86: local PROGRESS_ANCHOR = 'BOTTOM' Nenue@86: local PROGRESS_PARENT Nenue@86: local PROGRESS_OFFSET = 1 Nenue@86: Nenue@68: local BUFF_BUTTON_ZOOM = .15 Nenue@86: local BORDER_SIZE_L = 2 Nenue@86: local BORDER_SIZE_R = 2 Nenue@86: local BORDER_SIZE_U = 2 Nenue@86: local BORDER_SIZE_D = 2 Nenue@75: local BUFF_FRAMES_X = -230 Nenue@75: local BUFF_FRAMES_Y = -4 Nenue@64: Nenue@86: local COUNT_ANCHOR = 'TOPRIGHT' Nenue@86: local COUNT_INSET = 4 Nenue@86: local COUNT_PARENT Nenue@86: Nenue@86: local DURATION_ANCHOR = 'BOTTOMLEFT' Nenue@86: local DURATION_INSET = 4 Nenue@86: local DURATION_PARENT Nenue@86: Nenue@84: VeneerBuffFrameMixin = { Nenue@84: moduleName = 'Buff Frames', Nenue@84: defaultCluster = 'TOPRIGHT', Nenue@90: anchorX = BUFF_FRAMES_X, Nenue@90: anchorY = BUFF_FRAMES_Y, Nenue@90: anchorPoint = 'TOPRIGHT', Nenue@84: Buttons = {}, Nenue@84: DetectedFrames = {}, Nenue@84: AuraCache = {} Nenue@84: } Nenue@94: VeneerBuffFrameButtonMixin = {} Nenue@94: local Facade = VeneerBuffFrameButtonMixin Nenue@84: local plugin = VeneerBuffFrameMixin Nenue@62: Nenue@84: local vn = Veneer Nenue@84: local print = DEVIAN_WORKSPACE and function(...) _G.print('BuffFrame', ...) end or function() end Nenue@68: local tprint = DEVIAN_WORKSPACE and function(...) _G.print('Timer', ...) end or function() end Nenue@59: Nenue@68: local _G, UIParent = _G, UIParent Nenue@68: local tinsert, tremove, unpack, select, tconcat = table.insert, table.remove, unpack, select, table.concat Nenue@68: local floor, tonumber, format = math.floor, tonumber, string.format Nenue@68: local UnitAura, GetTime, CreateFrame = UnitAura, GetTime, CreateFrame Nenue@68: local hooksecurefunc = hooksecurefunc Nenue@59: Nenue@75: local aurasCache = {} Nenue@75: local skinnedFrames = {} Nenue@75: local pendingFrames = {} Nenue@75: local veneers = {} Nenue@75: local expirationCache = {} Nenue@75: local visibility = {} Nenue@75: local isHooked = {} Nenue@75: Nenue@75: plugin.options = { Nenue@75: nameString = 'Buff Frames', Nenue@59: { Nenue@75: name = 'BuffButtonZoom', Nenue@75: type = 'slider', Nenue@75: min = 0, Nenue@75: max = 100, Nenue@75: fullwidth = true, Nenue@59: }, Nenue@59: { Nenue@75: name = 'BuffBorderLeft', Nenue@75: type = 'slider', Nenue@75: min = 0, Nenue@75: max = 16, Nenue@59: }, Nenue@59: { Nenue@75: name = 'BuffBorderLeft', Nenue@75: type = 'slider', Nenue@75: min = 0, Nenue@75: max = 16, Nenue@59: } Nenue@59: } Nenue@59: Nenue@86: local OFFSET_PARALLELS = { Nenue@86: TOP = {'LEFT', 'RIGHT', 'SetHeight'}, Nenue@86: BOTTOM = {'LEFT', 'RIGHT', 'SetHeight'}, Nenue@86: LEFT = {'TOP', 'BOTTOM', 'SetWidth'}, Nenue@86: RIGHT = {'TOP', 'BOTTOM', 'SetWidth'}, Nenue@86: } Nenue@86: local ANCHOR_OFFSET_POINT = { Nenue@86: TOP = 'BOTTOM', Nenue@86: TOPLEFT = 'BOTTOMRIGHT', Nenue@86: TOPRIGHT = 'BOTTOMLEFT', Nenue@86: LEFT = 'RIGHT', Nenue@86: RIGHT = 'LEFT', Nenue@86: CENTER = 'CENTER', Nenue@86: BOTTOM = 'TOP', Nenue@86: BOTTOMRIGHT = 'TOPLEFT', Nenue@86: BOTTOMLEFT = 'TOPRIGHT', Nenue@86: } Nenue@86: local ANCHOR_INSET_DELTA = { Nenue@86: TOP = {0, -1}, Nenue@86: TOPLEFT = {1, -1}, Nenue@86: TOPRIGHT = {-1,-1}, Nenue@86: LEFT = {1, 0}, Nenue@86: BOTTOMLEFT = {1, 1}, Nenue@86: BOTTOM = {0, 1}, Nenue@86: BOTTOMRIGHT = {-1, 1}, Nenue@86: RIGHT = {-1, 0}, Nenue@86: CENTER = {0, 0}, Nenue@86: } Nenue@59: Nenue@90: -- Associates skinning elements with said button Nenue@90: local surrogates = { Nenue@90: ['Show'] = false, Nenue@90: ['Hide'] = false, Nenue@90: ['SetText'] = false, Nenue@90: ['SetVertexColor'] = function(self, region, r, g, b, a) Nenue@90: if not self.progress then Nenue@90: return Nenue@90: end Nenue@90: Nenue@90: region:Hide() Nenue@93: --tprint('|cFF0088FFborder:SetVertexColor|r', r,g,b,a) Nenue@90: self.progress.fg:SetColorTexture(r,g,b,a) Nenue@90: self.border:SetColorTexture(r,g,b,a) Nenue@90: self.border:Show() Nenue@90: end, Nenue@90: } Nenue@90: local DoRegionHooks = function (veneer, region) Nenue@90: Nenue@90: if region then Nenue@90: --print('hooking', region:GetName()) Nenue@90: region:ClearAllPoints() Nenue@90: for method, callback in pairs(surrogates) do Nenue@90: if type(region[method]) == 'function' then Nenue@90: Nenue@90: --print(method, type(callback)) Nenue@90: local func Nenue@90: if callback then Nenue@90: hooksecurefunc(region, method, function(self, ...) Nenue@90: --tprint('|cFF00FFFF'.. region:GetName().. ':', method) Nenue@90: region:ClearAllPoints() Nenue@90: callback(veneer, region, ...) Nenue@90: end) Nenue@90: else Nenue@90: hooksecurefunc(region, method, function(self,...) Nenue@93: --tprint('|cFF0088FF'.. self:GetName().. ':', method) Nenue@90: self:ClearAllPoints() Nenue@90: veneer:Show() Nenue@90: veneer[method](veneer, ...) Nenue@90: Nenue@90: if self:GetName():match('Debuff.+Count') then Nenue@90: Nenue@93: --print('|cFF00FFFF'.. self:GetName().. ':'.. method, '->', veneer:GetName()..':'..method..'(', ...,')') Nenue@93: --print(veneer:IsVisible(),veneer:GetStringWidth(),veneer:GetText()) Nenue@93: --print(veneer:GetTop(), veneer:GetLeft()) Nenue@93: --print(veneer:GetPoint(1)) Nenue@90: end Nenue@90: Nenue@90: end) Nenue@90: end Nenue@90: end Nenue@90: end Nenue@90: end Nenue@90: end Nenue@75: Nenue@93: Nenue@94: Nenue@94: function Facade:OnShow() Nenue@94: self.underlay:Show() Nenue@94: end Nenue@94: function Facade:OnHide() Nenue@94: self.underlay:Hide() Nenue@94: end Nenue@94: Nenue@94: function Facade:OnLoad() Nenue@94: Nenue@94: self.duration = self.progress.duration Nenue@94: self.count = self.overlay.count Nenue@94: self.border = self.underlay.bg Nenue@94: Nenue@94: VeneerBuffFrame.ConfigLayers = VeneerBuffFrame.ConfigLayers or {} Nenue@94: self.configIndex = #VeneerBuffFrame.ConfigLayers Nenue@94: for i, region in ipairs(self.ConfigLayers) do Nenue@94: tinsert(VeneerBuffFrame.ConfigLayers, region) Nenue@94: end Nenue@94: Nenue@94: self.configIndexEnd = #VeneerBuffFrame.ConfigLayers Nenue@94: end Nenue@94: Nenue@94: function Facade:Setup() Nenue@94: self:SetSize(BUFF_BUTTON_SIZE,BUFF_BUTTON_SIZE) Nenue@94: Nenue@94: self.progress[OFFSET_PARALLELS[PROGRESS_ANCHOR][3]](self.progress, BUFF_PROGRESS_SIZE + (BUFF_PROGRESS_INSET * 2)) Nenue@94: --print(BUFF_PROGRESS_SIZE + (BUFF_PROGRESS_INSET * 2)) Nenue@94: Nenue@94: self.progress:ClearAllPoints() Nenue@94: self.progress:SetPoint(ANCHOR_OFFSET_POINT[PROGRESS_ANCHOR], PROGRESS_PARENT or self.border, PROGRESS_ANCHOR, Nenue@94: (ANCHOR_INSET_DELTA[PROGRESS_ANCHOR][1] * PROGRESS_OFFSET * -1), Nenue@94: (ANCHOR_INSET_DELTA[PROGRESS_ANCHOR][2] * PROGRESS_OFFSET * -1)) Nenue@94: self.progress:SetPoint(OFFSET_PARALLELS[PROGRESS_ANCHOR][1], self.border, OFFSET_PARALLELS[PROGRESS_ANCHOR][1], 0, 0) Nenue@94: self.progress:SetPoint(OFFSET_PARALLELS[PROGRESS_ANCHOR][2], self.border, OFFSET_PARALLELS[PROGRESS_ANCHOR][2], 0, 0) Nenue@94: Nenue@94: --print(self.progress:GetPoint(1)) Nenue@94: --print(self.progress:GetPoint(2)) Nenue@94: --print(self.progress:GetPoint(3)) Nenue@94: self.progress:Show() Nenue@94: Nenue@94: self.progress.bg:ClearAllPoints() Nenue@94: self.progress.bg:SetAllPoints(self.progress) Nenue@94: Nenue@94: self.progress.fg:ClearAllPoints() Nenue@94: self.progress.fg:SetPoint('BOTTOMLEFT', BUFF_PROGRESS_INSET,BUFF_PROGRESS_INSET) Nenue@94: self.progress.fg:SetPoint('TOP', 0, -BUFF_PROGRESS_INSET) Nenue@94: --self.count:ClearAllPoints() Nenue@94: --self.count:SetPoint('TOPRIGHT', self,'TOPRIGHT', -3, -3) Nenue@94: Nenue@94: Nenue@94: self.duration:ClearAllPoints() Nenue@94: self.duration:SetPoint(DURATION_ANCHOR, DURATION_PARENT or self, DURATION_ANCHOR, Nenue@94: (ANCHOR_INSET_DELTA[DURATION_ANCHOR][1] * DURATION_INSET), Nenue@94: (ANCHOR_INSET_DELTA[DURATION_ANCHOR][2] * DURATION_INSET)) Nenue@94: Nenue@94: self.count:ClearAllPoints() Nenue@94: self.count:SetPoint(COUNT_ANCHOR, COUNT_PARENT or self, COUNT_ANCHOR, Nenue@94: (ANCHOR_INSET_DELTA[COUNT_ANCHOR][1] * COUNT_INSET), Nenue@94: (ANCHOR_INSET_DELTA[COUNT_ANCHOR][2] * COUNT_INSET)) Nenue@94: Nenue@94: self.underlay:SetParent(self) Nenue@94: self.underlay:SetFrameStrata('BACKGROUND') Nenue@94: self.border:SetColorTexture(0,0,0,1) Nenue@94: self.border:SetPoint('TOPLEFT', self, 'TOPLEFT', -BORDER_SIZE_L, BORDER_SIZE_U) Nenue@94: self.border:SetPoint('BOTTOMRIGHT', self, 'BOTTOMRIGHT', BORDER_SIZE_R, -BORDER_SIZE_D) Nenue@94: self.border:Show() Nenue@94: end Nenue@94: Nenue@94: function plugin:AcquireConfigButton(name) Nenue@94: print('|cFF88FF00Creating config dummy', name,'Veneer') Nenue@94: local button = self.Buttons[name] Nenue@94: if not button then Nenue@94: button = CreateFrame('Frame', name .. 'Veneer', self, 'VeneerBuffTemplate') Nenue@94: button:Setup() Nenue@94: button:SetShown(true) Nenue@94: self.Buttons[name] = button Nenue@94: end Nenue@94: return button Nenue@94: end Nenue@94: Nenue@94: function plugin:Acquire(name) Nenue@94: local frame = self.Buttons[name] Nenue@94: if not frame then Nenue@94: local target = _G[name] Nenue@84: local id = target:GetID() Nenue@94: print('|cFF88FF00Creating', name .. 'Veneer') Nenue@93: frame = vn:Acquire(target, 'VeneerBuffTemplate') Nenue@94: frame:Setup() Nenue@94: self.Buttons[name] = frame Nenue@59: end Nenue@84: return frame Nenue@59: end Nenue@59: Nenue@94: function plugin:OnLoad() Nenue@84: Veneer:AddHandler(self, self.defaultCluster) Nenue@84: end Nenue@68: Nenue@94: function plugin:Setup() Nenue@84: Nenue@84: Nenue@84: hooksecurefunc("BuffFrame_Update", function(...) self:OnBuffFrameUpdate(...) end) Nenue@93: --hooksecurefunc("AuraButton_UpdateDuration", function(...) self:OnUpdateDuration(...) end) Nenue@84: hooksecurefunc("AuraButton_Update", function(...) self:OnAuraButton_Update(...) end) Nenue@84: hooksecurefunc("BuffFrame_UpdateAllBuffAnchors", function(...) self:OnUpdateAllBuffAnchors(...) end) Nenue@84: hooksecurefunc("TemporaryEnchantFrame_Update", function(...) self:OnTemporaryEnchantFrameUpdate(...) end) Nenue@84: for i = 1, 3 do Nenue@84: self:SetupButton('TempEnchant'..i) Nenue@84: _G['TempEnchant'..i..'Border']:SetVertexColor(0.5,0,1,1) Nenue@84: end Nenue@84: end Nenue@86: Nenue@94: function plugin:SetHidden(region) Nenue@93: if not self.hiddenRegions[region] then Nenue@93: self.hiddenRegions[region] = true Nenue@93: region:SetShown(false) Nenue@93: hooksecurefunc(region) Nenue@93: end Nenue@93: end Nenue@84: Nenue@94: function plugin:SetupButton (name) Nenue@94: local frame = _G[name] Nenue@86: --print('|cFFFFFF00Adopting', name) Nenue@68: Nenue@68: local icon = _G[name .. 'Icon'] Nenue@68: local border = _G[name .. 'Border'] Nenue@68: local count = _G[name .. 'Count'] Nenue@68: local duration = _G[name .. 'Duration'] Nenue@94: local veneer = self:Acquire(name) Nenue@84: local offset = BUFF_BUTTON_ZOOM/2 Nenue@68: Nenue@84: self.DetectedFrames[frame] = frame Nenue@68: frame:SetSize(BUFF_BUTTON_SIZE,BUFF_BUTTON_SIZE) Nenue@84: icon:SetTexCoord(offset, 1 - offset, offset, 1 - offset) Nenue@68: Nenue@78: Nenue@84: DoRegionHooks(veneer, border) Nenue@68: if border then Nenue@68: local color = DebuffTypeColor["none"] Nenue@68: if aurasCache[frame] and aurasCache[frame][5] then Nenue@68: color = DebuffTypeColor[aurasCache[frame][5]] Nenue@68: end Nenue@71: veneer.progress.fg:SetColorTexture(color.r,color.g,color.b) Nenue@75: veneer.border:SetColorTexture(0,0,0,1) Nenue@79: veneer.border:Show() Nenue@79: else Nenue@79: veneer.border:SetColorTexture(0,0,0,1) Nenue@79: veneer.border:Show() Nenue@68: end Nenue@68: Nenue@93: if count then Nenue@86: count:ClearAllPoints() Nenue@93: hooksecurefunc(count, 'Show', function(self) self:Hide() end) Nenue@93: if count:GetText() then Nenue@93: veneer.count:SetText(count:GetText()) Nenue@93: end Nenue@86: end Nenue@86: if duration then Nenue@86: duration:ClearAllPoints() Nenue@86: end Nenue@86: Nenue@68: hooksecurefunc(frame, "Hide", function(self) Nenue@68: veneer:Hide() Nenue@68: end) Nenue@68: Nenue@68: hooksecurefunc(frame, 'Show', function(self) Nenue@68: veneer:Show() Nenue@68: end) Nenue@68: Nenue@94: veneer:SetParent(UIParent) Nenue@94: veneer:SetAllPoints(frame) Nenue@94: veneer:SetFrameStrata('BACKGROUND') Nenue@68: end Nenue@68: Nenue@68: Nenue@61: --- Set widgets to reflect the passed parameters Nenue@94: function plugin:UpdateButton (name, duration, expires) Nenue@94: local frame = _G[name] Nenue@94: local veneer = self:Acquire(name) Nenue@68: -- is it a new button? Nenue@84: if not self.DetectedFrames[frame] then Nenue@94: print('|cFFFF4400detected', name) Nenue@94: self:SetupButton(name) Nenue@68: end Nenue@94: print(veneer:GetParent():GetName(), veneer:GetPoint(1)) Nenue@86: --[[ Nenue@86: if frame.count then Nenue@86: frame.count:SetText('test') Nenue@86: frame.count:Show() Nenue@86: end Nenue@86: --]] Nenue@86: local name, rank, icon, count, _, duration, expires = UnitAura(frame.unit, frame:GetID(), frame.filter) Nenue@86: Nenue@59: Nenue@61: if expires and duration then Nenue@61: if duration ~= 0 then Nenue@61: local startTime = (expires - duration) Nenue@61: local endTime = expires or 0 Nenue@61: print('|cFF0088FF'..frame:GetName()..'|r', duration, expires) Nenue@61: veneer.progress:Show() Nenue@61: veneer.elapsed = 0 Nenue@61: veneer.progress:SetScript('OnUpdate', function(self, elapsed) Nenue@61: veneer.elapsed = veneer.elapsed + elapsed Nenue@60: Nenue@67: local w = floor(veneer.progress:GetWidth()+.5) - (BUFF_PROGRESS_INSET*2) Nenue@61: local t = GetTime() Nenue@61: local progress = (t - startTime) / duration Nenue@61: Nenue@67: local nw = (w - (w * progress)) Nenue@61: if veneer.elapsed >= 0.25 then Nenue@61: Nenue@93: --tprint(t, startTime, floor(progress*100), w * progress, nw, w) Nenue@61: veneer.elapsed = 0.25 - veneer.elapsed Nenue@61: end Nenue@61: if (progress >= 1) or not frame:IsVisible() then Nenue@61: veneer.startTime = nil Nenue@61: self:Hide() Nenue@61: self:SetScript('OnUpdate', nil) Nenue@61: else Nenue@61: self.fg:SetWidth(nw) Nenue@61: end Nenue@61: end) Nenue@61: Nenue@61: veneer.cooldown:Show() Nenue@61: veneer.cooldown:SetCooldown(startTime, duration) Nenue@61: else Nenue@61: print('|cFF00FF88'..frame:GetName()..'|r', 'duration zero') Nenue@61: veneer.progress:SetScript('OnUpdate', nil) Nenue@61: veneer.progress:Hide() Nenue@61: veneer.cooldown:Hide() Nenue@61: end Nenue@86: Nenue@90: if count and count > 1 then Nenue@86: veneer.count:SetText(count) Nenue@86: veneer.count:Show() Nenue@90: frame.count:ClearAllPoints() Nenue@86: else Nenue@86: veneer.count:Hide() Nenue@86: end Nenue@86: Nenue@86: Nenue@61: else Nenue@61: veneer.progress:Hide() Nenue@61: veneer.cooldown:SetCooldown(0,0) Nenue@61: veneer.cooldown:Hide() Nenue@61: print('|cFF88FF00'..frame:GetName()..'|r', 'nil duration') Nenue@59: end Nenue@59: veneer:Show() Nenue@59: end Nenue@59: Nenue@59: Nenue@59: --- Provides the number of changed indices for use in deciding between partial and full veneer updates Nenue@94: function plugin:ButtonHasChanged (frame, ...) Nenue@59: aurasCache[frame] = aurasCache[frame] or {} Nenue@59: local hasChange = 0 Nenue@59: local numVals = select('#',...) Nenue@59: for i = 1, numVals do Nenue@59: local arg = select(i, ...) Nenue@59: if aurasCache[frame][i] ~= arg then Nenue@59: hasChange = hasChange + 1 Nenue@59: end Nenue@59: aurasCache[frame][i] = arg Nenue@59: end Nenue@59: return hasChange Nenue@59: end Nenue@59: Nenue@94: function plugin:OnAuraButton_Update (name, index, filter) Nenue@59: local bName = name..index Nenue@59: local frame = _G[bName] Nenue@59: if frame and frame:IsVisible() then Nenue@61: -- if the name or expirationTime changed Nenue@86: Nenue@94: if not skinnedFrames[bName] then Nenue@94: tinsert(pendingFrames, bName) Nenue@61: end Nenue@59: expirationCache[name] = frame.expirationTime Nenue@94: self:UpdateButton(bName) Nenue@68: Nenue@59: Nenue@59: end Nenue@59: end Nenue@59: Nenue@94: function plugin:OnUpdateAllBuffAnchors () Nenue@59: Nenue@59: --BuffButton1 Nenue@59: --DebuffButton1 Nenue@61: --todo: separate frame groups and iterate over them at appropriate times Nenue@60: if BuffButton1 then Nenue@78: Nenue@68: TempEnchant1:SetPoint('TOPRIGHT', BuffButton1, 'TOPRIGHT', BuffButton1:GetWidth()+4, 0) Nenue@60: end Nenue@60: Nenue@70: local lastBuff, topBuff Nenue@74: local numBuffs = 0 Nenue@90: local numColumns = 1 Nenue@90: local maxColumn = 1 Nenue@94: local limit = self.configMode and BUFF_MAX_DISPLAY or BUFF_ACTUAL_DISPLAY Nenue@94: for i = 1, limit do Nenue@94: local name = 'BuffButton'..i Nenue@94: local buff = _G[name] or self.Buttons[name] Nenue@94: print(buff:GetName(), self.configMode) Nenue@70: if buff then Nenue@74: numBuffs = numBuffs + 1 Nenue@74: buff:ClearAllPoints() Nenue@75: if mod(numBuffs,BUFFS_PER_ROW) == 1 then Nenue@74: if numBuffs == 1 then Nenue@80: buff:SetPoint('TOPRIGHT', UIParent, 'TOPRIGHT', BUFF_FRAMES_X, BUFF_FRAMES_Y) Nenue@90: plugin.currentTop = buff Nenue@71: else Nenue@71: buff:SetPoint('TOPRIGHT', topBuff, 'BOTTOMRIGHT', 0, -BUFF_BUTTON_SPACING_V) Nenue@71: end Nenue@90: numColumns = 1 Nenue@70: topBuff = buff Nenue@70: else Nenue@71: buff:SetPoint('TOPRIGHT', lastBuff, 'TOPLEFT', -BUFF_BUTTON_SPACING_H, 0) Nenue@90: numColumns = numColumns + 1 Nenue@90: end Nenue@90: if numColumns > maxColumn then Nenue@90: maxColumn = numColumns Nenue@90: plugin.currentLeft = buff Nenue@70: end Nenue@70: lastBuff = buff Nenue@70: end Nenue@70: end Nenue@70: Nenue@74: numBuffs = 0 Nenue@94: limit = self.configMode and DEBUFF_MAX_DISPLAY or DEBUFF_ACTUAL_DISPLAY Nenue@70: for i = 1, DEBUFF_ACTUAL_DISPLAY do Nenue@94: local name = 'DebuffButton'..i Nenue@94: local debuff = _G[name] or self.Buttons[name] Nenue@70: if debuff then Nenue@74: numBuffs = numBuffs + 1 Nenue@93: if mod(numBuffs, BUFFS_PER_ROW) == 1 then Nenue@93: Nenue@93: if topBuff then Nenue@93: debuff:SetPoint('TOPRIGHT', topBuff, 'BOTTOMRIGHT', 0, -BUFF_BUTTON_SPACING_V) Nenue@93: else Nenue@93: debuff:SetPoint('TOPRIGHT', UIParent, 'TOPRIGHT', BUFF_FRAMES_X, BUFF_FRAMES_Y) Nenue@93: end Nenue@93: topBuff = debuff Nenue@93: Nenue@70: else Nenue@71: debuff:SetPoint('TOPRIGHT', lastBuff, 'TOPLEFT', -BUFF_BUTTON_SPACING_H, 0) Nenue@70: end Nenue@70: lastBuff = debuff Nenue@94: Nenue@70: end Nenue@70: end Nenue@70: Nenue@74: if lastBuff then Nenue@90: plugin.currentBottom = lastBuff Nenue@74: end Nenue@90: Nenue@90: self.Background:ClearAllPoints() Nenue@90: self.Background:SetPoint('TOPRIGHT', plugin.currentTop, 'TOPRIGHT', 4, 4) Nenue@90: self.Background:SetPoint('BOTTOM', plugin.currentBottom, 'BOTTOM', 0, -4) Nenue@90: self.Background:SetPoint('LEFT', plugin.currentLeft, 'LEFT', -4, 0) Nenue@59: end Nenue@94: function plugin:UpdateConfigLayers (configMode) Nenue@90: self:SetShown(configMode) Nenue@94: self.configMode = configMode Nenue@94: for i = 1, BUFF_MAX_DISPLAY do Nenue@94: local name = 'BuffButton' .. i Nenue@94: local button = self:AcquireConfigButton(name) Nenue@94: end Nenue@94: for i = 1, DEBUFF_MAX_DISPLAY do Nenue@94: local name = 'DebuffButton' .. i Nenue@94: local button = self:AcquireConfigButton(name) Nenue@93: end Nenue@90: end Nenue@94: function plugin:OnUpdateDuration (frame, timeLeft) Nenue@84: local veneer = self:Acquire(frame) Nenue@60: local hours = floor(timeLeft/3600) Nenue@60: local minutes = floor(mod(timeLeft, 3600)/60) Nenue@60: local seconds = floor(mod(timeLeft, 60)) Nenue@60: local timeString = '%ds' Nenue@59: if timeLeft > 3600 then Nenue@60: timeString = format('%d:%02d', hours, minutes) Nenue@60: elseif timeLeft > 60 then Nenue@60: timeString = format('%d:%02d', minutes, seconds) Nenue@61: else Nenue@60: timeString = format('%d', seconds) Nenue@59: end Nenue@59: Nenue@74: if timeLeft < 10 then Nenue@74: if not veneer.duration.getHuge then Nenue@74: veneer.duration.getHuge = true Nenue@74: veneer.duration:SetFontObject(VeneerNumberFontLarge) Nenue@75: veneer.duration:SetTextColor(1,1,0,1) Nenue@74: end Nenue@74: else Nenue@74: if veneer.duration.getHuge then Nenue@74: veneer.duration.getHuge = nil Nenue@74: veneer.duration:SetFontObject(VeneerNumberFont) Nenue@74: veneer.duration:SetTextColor(1,1,1,1) Nenue@74: end Nenue@74: end Nenue@74: Nenue@69: veneer.duration:SetText(timeString) Nenue@59: end Nenue@59: Nenue@59: Nenue@59: -- Obtains the first instance of Tenchant use Nenue@59: Nenue@94: function plugin:OnTemporaryEnchantFrameUpdate (...) Nenue@59: local numVals = select('#', ...) Nenue@59: local numItems = numVals / 4 Nenue@59: if numItems >= 1 then Nenue@59: for itemIndex = numItems, 1, -1 do Nenue@94: local name = 'TempEnchant'..itemIndex Nenue@94: local frame = _G[name] Nenue@59: local hasEnchant, timeRemaining, enchantCharges = select((4 * (itemIndex -1)) + 1, ...) Nenue@59: Nenue@59: Nenue@59: if hasEnchant then Nenue@59: local endTime = floor(GetTime()*1000) + timeRemaining Nenue@59: Nenue@59: Nenue@59: --print(endTime) Nenue@59: if endTime ~= expirationCache[frame] then Nenue@59: if expirationCache[frame] then Nenue@59: print(endTime, expirationCache[frame], endTime - expirationCache[frame]) Nenue@59: end Nenue@59: expirationCache[frame] = endTime Nenue@59: print('push tempenchant timer update', timeRemaining / 1000, GetTime()+(timeRemaining/1000)) Nenue@94: self:UpdateButton(frame, timeRemaining/1000, GetTime()+(timeRemaining/1000)) Nenue@59: end Nenue@59: else Nenue@94: self:Acquire(name):Hide() Nenue@59: end Nenue@59: end Nenue@59: end Nenue@59: end Nenue@59: Nenue@94: function plugin:OnBuffFrameUpdate () end Nenue@59: Nenue@90: Nenue@84: -- The TempEnchant frames are hardcoded in the base FrameXML, so get them now Nenue@59: