# HG changeset patch # User Nenue # Date 1471789689 14400 # Node ID ebc18a7412a183052c9f79848d6f20c2ac049c7e # Parent be5cea6e1e8ff4a09860076e1574103f27205aa6 - use secure hook functions to manage duration and count text diff -r be5cea6e1e8f -r ebc18a7412a1 Modules/BuffFrame.lua --- a/Modules/BuffFrame.lua Sun Aug 21 07:09:10 2016 -0400 +++ b/Modules/BuffFrame.lua Sun Aug 21 10:28:09 2016 -0400 @@ -82,7 +82,7 @@ local GetVeneer = function(frame) local name = frame:GetName() - if not (_G[name..'Veneer'] and _G[name..'Underlay']) then + if not (_G[name..'Veneer']) then print('|cFF88FF00Creating', name,'Veneer') local veneer = CreateFrame('Frame', name..'Veneer', UIParent) local id = frame:GetID() @@ -127,10 +127,17 @@ veneer.cooldown:SetAllPoints(frame) veneer.cooldown:SetReverse(true) + local overlay = CreateFrame('Frame', name .. 'VeneerOverlay', UIParent) + overlay:Show() + overlay:SetFrameStrata('MEDIUM') + local n = frame:GetNumPoints() + for i = 1, n do + overlay:SetPoint(frame:GetPoint(n)) + end - local underlay = CreateFrame('Frame', name..'Underlay', UIParent) + local underlay = CreateFrame('Frame', name..'VeneerUnderlay', UIParent) underlay:Show() underlay:SetFrameStrata('BACKGROUND') local n = frame:GetNumPoints() @@ -138,19 +145,28 @@ underlay:SetPoint(frame:GetPoint(n)) end + veneer.duration = overlay:CreateFontString(name..'VeneerDuration', 'OVERLAY') + veneer.duration:SetFontObject(VeneerNumberFont) + veneer.duration:SetPoint('TOP', frame, 'BOTTOM', 0, -8) + + veneer.count = overlay:CreateFontString(name..'VeneerCount', 'OVERLAY') + veneer.count:SetFontObject(VeneerNumberFont) + veneer.count:SetPoint('BOTTOMRIGHT', frame, 'BOTTOMRIGHT', -3, 3) veneer.border = underlay:CreateTexture(name..'VeneerBorder', 'BACKGROUND') veneer.border:SetPoint('TOPLEFT', veneer, 'TOPLEFT', -BORDER_SIZE_L, BORDER_SIZE_U) veneer.border:SetPoint('BOTTOMRIGHT', veneer, 'BOTTOMRIGHT', BORDER_SIZE_R, -BORDER_SIZE_D) - --veneer.border:SetColorTexture(0,1,0,1) veneer.border:Show() + + veneer.overlay = overlay + veneer.underlay = underlay end - return _G[name..'Veneer'], _G[name..'Underlay'] + return _G[name..'Veneer'] end @@ -168,7 +184,9 @@ local count = _G[name .. 'Count'] local duration = _G[name .. 'Duration'] local slot = frame:GetID() or 0 - local veneer, underlay = GetVeneer(frame) + local veneer = GetVeneer(frame) + local underlay = veneer.underlay + local overlay = veneer.overlay skinnedFrames[frame] = frame frame:SetSize(BUFF_BUTTON_SIZE,BUFF_BUTTON_SIZE) @@ -192,10 +210,29 @@ end if duration then duration:ClearAllPoints() - duration:SetPoint('TOP', frame, 'BOTTOM', 0, -8) - duration:SetFontObject(VeneerNumberFont) - duration:SetDrawLayer('OVERLAY') + --duration:SetPoint('TOP', frame, 'BOTTOM', 0, -8) + --duration:SetFontObject(VeneerNumberFont) + --duration:SetDrawLayer('OVERLAY') + hooksecurefunc(duration, 'Hide', function(self, text) + veneer.duration:Hide() + end) + hooksecurefunc(duration, 'Show', function(self, text) + veneer.duration:Show() + end) + end + if count then + count:ClearAllPoints() + hooksecurefunc(count, 'SetText', function(self, text) + self:Hide() + veneer.count:SetText(text) + end) + hooksecurefunc(count, 'Hide', function(self, text) + veneer.count:Hide() + end) + hooksecurefunc(count, 'Show', function(self, text) + veneer.count:Show() + end) end @@ -352,6 +389,7 @@ end local AuraButton_UpdateDuration = function(frame, timeLeft) + local veneer = GetVeneer(frame) local hours = floor(timeLeft/3600) local minutes = floor(mod(timeLeft, 3600)/60) local seconds = floor(mod(timeLeft, 60)) @@ -365,8 +403,8 @@ end - frame.duration:SetText(timeString) - frame.duration:SetVertexColor(1,1,1) + veneer.duration:SetText(timeString) + veneer.duration:SetVertexColor(1,1,1) end