# HG changeset patch # User Nenue # Date 1483317066 18000 # Node ID df10cd0ae949cf5c9b5856661784abf0b607bfa6 # Parent caded26687015b95a545e994a9e84c8a752343d7 - Pre-load veneer frames for buffs, set their triggers when the appropriate frames have spawned. - Fix to background layers remaining on screen during pet battles. diff -r caded2668701 -r df10cd0ae949 Modules/BuffFrame.lua --- a/Modules/BuffFrame.lua Sun Jan 01 18:25:26 2017 -0500 +++ b/Modules/BuffFrame.lua Sun Jan 01 19:31:06 2017 -0500 @@ -48,8 +48,8 @@ DetectedFrames = {}, AuraCache = {} } -VeneerBuffFrameButtonMixin = { -} +VeneerBuffFrameButtonMixin = {} +local Facade = VeneerBuffFrameButtonMixin local plugin = VeneerBuffFrameMixin local vn = Veneer @@ -176,69 +176,107 @@ end end end -function VeneerBuffFrameMixin:Acquire(target) - local frame = self.Buttons[target] - if not (self.Buttons[target]) then - local name = target:GetName() + +function Facade:OnShow() + self.underlay:Show() +end +function Facade:OnHide() + self.underlay:Hide() +end + +function Facade:OnLoad() + + self.duration = self.progress.duration + self.count = self.overlay.count + self.border = self.underlay.bg + + VeneerBuffFrame.ConfigLayers = VeneerBuffFrame.ConfigLayers or {} + self.configIndex = #VeneerBuffFrame.ConfigLayers + for i, region in ipairs(self.ConfigLayers) do + tinsert(VeneerBuffFrame.ConfigLayers, region) + end + + self.configIndexEnd = #VeneerBuffFrame.ConfigLayers +end + +function Facade:Setup() + self:SetSize(BUFF_BUTTON_SIZE,BUFF_BUTTON_SIZE) + + self.progress[OFFSET_PARALLELS[PROGRESS_ANCHOR][3]](self.progress, BUFF_PROGRESS_SIZE + (BUFF_PROGRESS_INSET * 2)) + --print(BUFF_PROGRESS_SIZE + (BUFF_PROGRESS_INSET * 2)) + + self.progress:ClearAllPoints() + self.progress:SetPoint(ANCHOR_OFFSET_POINT[PROGRESS_ANCHOR], PROGRESS_PARENT or self.border, PROGRESS_ANCHOR, + (ANCHOR_INSET_DELTA[PROGRESS_ANCHOR][1] * PROGRESS_OFFSET * -1), + (ANCHOR_INSET_DELTA[PROGRESS_ANCHOR][2] * PROGRESS_OFFSET * -1)) + self.progress:SetPoint(OFFSET_PARALLELS[PROGRESS_ANCHOR][1], self.border, OFFSET_PARALLELS[PROGRESS_ANCHOR][1], 0, 0) + self.progress:SetPoint(OFFSET_PARALLELS[PROGRESS_ANCHOR][2], self.border, OFFSET_PARALLELS[PROGRESS_ANCHOR][2], 0, 0) + + --print(self.progress:GetPoint(1)) + --print(self.progress:GetPoint(2)) + --print(self.progress:GetPoint(3)) + self.progress:Show() + + self.progress.bg:ClearAllPoints() + self.progress.bg:SetAllPoints(self.progress) + + self.progress.fg:ClearAllPoints() + self.progress.fg:SetPoint('BOTTOMLEFT', BUFF_PROGRESS_INSET,BUFF_PROGRESS_INSET) + self.progress.fg:SetPoint('TOP', 0, -BUFF_PROGRESS_INSET) + --self.count:ClearAllPoints() + --self.count:SetPoint('TOPRIGHT', self,'TOPRIGHT', -3, -3) + + + self.duration:ClearAllPoints() + self.duration:SetPoint(DURATION_ANCHOR, DURATION_PARENT or self, DURATION_ANCHOR, + (ANCHOR_INSET_DELTA[DURATION_ANCHOR][1] * DURATION_INSET), + (ANCHOR_INSET_DELTA[DURATION_ANCHOR][2] * DURATION_INSET)) + + self.count:ClearAllPoints() + self.count:SetPoint(COUNT_ANCHOR, COUNT_PARENT or self, COUNT_ANCHOR, + (ANCHOR_INSET_DELTA[COUNT_ANCHOR][1] * COUNT_INSET), + (ANCHOR_INSET_DELTA[COUNT_ANCHOR][2] * COUNT_INSET)) + + self.underlay:SetParent(self) + self.underlay:SetFrameStrata('BACKGROUND') + self.border:SetColorTexture(0,0,0,1) + self.border:SetPoint('TOPLEFT', self, 'TOPLEFT', -BORDER_SIZE_L, BORDER_SIZE_U) + self.border:SetPoint('BOTTOMRIGHT', self, 'BOTTOMRIGHT', BORDER_SIZE_R, -BORDER_SIZE_D) + self.border:Show() +end + +function plugin:AcquireConfigButton(name) + print('|cFF88FF00Creating config dummy', name,'Veneer') + local button = self.Buttons[name] + if not button then + button = CreateFrame('Frame', name .. 'Veneer', self, 'VeneerBuffTemplate') + button:Setup() + button:SetShown(true) + self.Buttons[name] = button + end + return button +end + +function plugin:Acquire(name) + local frame = self.Buttons[name] + if not frame then + local target = _G[name] local id = target:GetID() - print('|cFF88FF00Creating', name,'Veneer') + print('|cFF88FF00Creating', name .. 'Veneer') frame = vn:Acquire(target, 'VeneerBuffTemplate') - - - frame.progress[OFFSET_PARALLELS[PROGRESS_ANCHOR][3]](frame.progress, BUFF_PROGRESS_SIZE + (BUFF_PROGRESS_INSET * 2)) - print(BUFF_PROGRESS_SIZE + (BUFF_PROGRESS_INSET * 2)) - - frame.progress:ClearAllPoints() - frame.progress:SetPoint(ANCHOR_OFFSET_POINT[PROGRESS_ANCHOR], PROGRESS_PARENT or frame.border, PROGRESS_ANCHOR, - (ANCHOR_INSET_DELTA[PROGRESS_ANCHOR][1] * PROGRESS_OFFSET * -1), - (ANCHOR_INSET_DELTA[PROGRESS_ANCHOR][2] * PROGRESS_OFFSET * -1)) - frame.progress:SetPoint(OFFSET_PARALLELS[PROGRESS_ANCHOR][1], frame.border, OFFSET_PARALLELS[PROGRESS_ANCHOR][1], 0, 0) - frame.progress:SetPoint(OFFSET_PARALLELS[PROGRESS_ANCHOR][2], frame.border, OFFSET_PARALLELS[PROGRESS_ANCHOR][2], 0, 0) - - print(frame.progress:GetPoint(1)) - print(frame.progress:GetPoint(2)) - print(frame.progress:GetPoint(3)) - frame.progress:Show() - - frame.progress.bg:ClearAllPoints() - frame.progress.bg:SetAllPoints(frame.progress) - - frame.progress.fg:ClearAllPoints() - frame.progress.fg:SetPoint('BOTTOMLEFT', BUFF_PROGRESS_INSET,BUFF_PROGRESS_INSET) - frame.progress.fg:SetPoint('TOP', 0, -BUFF_PROGRESS_INSET) - --frame.count:ClearAllPoints() - --frame.count:SetPoint('TOPRIGHT', frame,'TOPRIGHT', -3, -3) - - - frame.duration:ClearAllPoints() - frame.duration:SetPoint(DURATION_ANCHOR, DURATION_PARENT or frame, DURATION_ANCHOR, - (ANCHOR_INSET_DELTA[DURATION_ANCHOR][1] * DURATION_INSET), - (ANCHOR_INSET_DELTA[DURATION_ANCHOR][2] * DURATION_INSET)) - - frame.count:ClearAllPoints() - frame.count:SetPoint(COUNT_ANCHOR, COUNT_PARENT or frame, COUNT_ANCHOR, - (ANCHOR_INSET_DELTA[COUNT_ANCHOR][1] * COUNT_INSET), - (ANCHOR_INSET_DELTA[COUNT_ANCHOR][2] * COUNT_INSET)) - - frame.underlay:SetParent(UIParent) - frame.underlay:SetFrameStrata('BACKGROUND') - frame.border:SetColorTexture(0,0,0,1) - frame.border:SetPoint('TOPLEFT', frame, 'TOPLEFT', -BORDER_SIZE_L, BORDER_SIZE_U) - frame.border:SetPoint('BOTTOMRIGHT', frame, 'BOTTOMRIGHT', BORDER_SIZE_R, -BORDER_SIZE_D) - frame.border:Show() - - self.Buttons[target] = frame + frame:Setup() + self.Buttons[name] = frame end return frame end -function VeneerBuffFrameMixin:OnLoad() +function plugin:OnLoad() Veneer:AddHandler(self, self.defaultCluster) end -function VeneerBuffFrameMixin:Setup() +function plugin:Setup() hooksecurefunc("BuffFrame_Update", function(...) self:OnBuffFrameUpdate(...) end) @@ -252,7 +290,7 @@ end end -function VeneerBuffFrameMixin:SetHidden(region) +function plugin:SetHidden(region) if not self.hiddenRegions[region] then self.hiddenRegions[region] = true region:SetShown(false) @@ -260,19 +298,15 @@ end end -function VeneerBuffFrameMixin:SetupButton (name) - local frame = _G[name ] - if self.DetectedFrames[frame] then - --print('|cFFFF4400Attempting to skin a frame that already went through.|r') - return - end +function plugin:SetupButton (name) + local frame = _G[name] --print('|cFFFFFF00Adopting', name) local icon = _G[name .. 'Icon'] local border = _G[name .. 'Border'] local count = _G[name .. 'Count'] local duration = _G[name .. 'Duration'] - local veneer = self:Acquire(frame) + local veneer = self:Acquire(name) local offset = BUFF_BUTTON_ZOOM/2 self.DetectedFrames[frame] = frame @@ -280,7 +314,6 @@ icon:SetTexCoord(offset, 1 - offset, offset, 1 - offset) - DoRegionHooks(veneer, border) if border then local color = DebuffTypeColor["none"] @@ -306,39 +339,30 @@ duration:ClearAllPoints() end - - - hooksecurefunc(frame, "Hide", function(self) - local isVisible = self:IsVisible() - if isVisible ~= visibility[self] then - visibility[self] = isVisible - end veneer:Hide() - veneer.underlay:Hide() end) hooksecurefunc(frame, 'Show', function(self) veneer:Show() - local isVisible = self:IsVisible() - if isVisible ~= visibility[self] then - print('|cFFFFFF00SHOW|r', self:GetName()) - visibility[self] = isVisible - end - veneer.underlay:Show() end) + veneer:SetParent(UIParent) + veneer:SetAllPoints(frame) + veneer:SetFrameStrata('BACKGROUND') end --- Set widgets to reflect the passed parameters -function VeneerBuffFrameMixin:UpdateButton (frame, duration, expires) - local veneer = self:Acquire(frame) +function plugin:UpdateButton (name, duration, expires) + local frame = _G[name] + local veneer = self:Acquire(name) -- is it a new button? if not self.DetectedFrames[frame] then - self:SetupButton(frame:GetName()) + print('|cFFFF4400detected', name) + self:SetupButton(name) end - + print(veneer:GetParent():GetName(), veneer:GetPoint(1)) --[[ if frame.count then frame.count:SetText('test') @@ -406,7 +430,7 @@ --- Provides the number of changed indices for use in deciding between partial and full veneer updates -function VeneerBuffFrameMixin:ButtonHasChanged (frame, ...) +function plugin:ButtonHasChanged (frame, ...) aurasCache[frame] = aurasCache[frame] or {} local hasChange = 0 local numVals = select('#',...) @@ -420,35 +444,24 @@ return hasChange end -function VeneerBuffFrameMixin:OnAuraButton_Update (name, index, filter) +function plugin:OnAuraButton_Update (name, index, filter) local bName = name..index local frame = _G[bName] if frame and frame:IsVisible() then -- if the name or expirationTime changed - if not skinnedFrames[frame] then - tinsert(pendingFrames, frame) + if not skinnedFrames[bName] then + tinsert(pendingFrames, bName) end expirationCache[name] = frame.expirationTime - self:UpdateButton(frame) + self:UpdateButton(bName) end end -function VeneerBuffFrameMixin:OnUpdateAllBuffAnchors () - local todo = {} - if #pendingFrames >= 1 then +function plugin:OnUpdateAllBuffAnchors () - print('|cFFBBFF00AllBuffAnchors|r', #pendingFrames) - while pendingFrames[1] do - local frame = tremove(pendingFrames) - tinsert(todo, frame:GetName()) - - -- re-apply custom anchors - end - print(tconcat(todo, ', ')) - end --BuffButton1 --DebuffButton1 --todo: separate frame groups and iterate over them at appropriate times @@ -461,8 +474,11 @@ local numBuffs = 0 local numColumns = 1 local maxColumn = 1 - for i = 1, BUFF_ACTUAL_DISPLAY do - local buff = _G['BuffButton'..i] + local limit = self.configMode and BUFF_MAX_DISPLAY or BUFF_ACTUAL_DISPLAY + for i = 1, limit do + local name = 'BuffButton'..i + local buff = _G[name] or self.Buttons[name] + print(buff:GetName(), self.configMode) if buff then numBuffs = numBuffs + 1 buff:ClearAllPoints() @@ -488,8 +504,10 @@ end numBuffs = 0 + limit = self.configMode and DEBUFF_MAX_DISPLAY or DEBUFF_ACTUAL_DISPLAY for i = 1, DEBUFF_ACTUAL_DISPLAY do - local debuff = _G['DebuffButton'..i] + local name = 'DebuffButton'..i + local debuff = _G[name] or self.Buttons[name] if debuff then numBuffs = numBuffs + 1 if mod(numBuffs, BUFFS_PER_ROW) == 1 then @@ -505,6 +523,7 @@ debuff:SetPoint('TOPRIGHT', lastBuff, 'TOPLEFT', -BUFF_BUTTON_SPACING_H, 0) end lastBuff = debuff + end end @@ -517,13 +536,19 @@ self.Background:SetPoint('BOTTOM', plugin.currentBottom, 'BOTTOM', 0, -4) self.Background:SetPoint('LEFT', plugin.currentLeft, 'LEFT', -4, 0) end -function VeneerBuffFrameMixin:UpdateConfigLayers (configMode) +function plugin:UpdateConfigLayers (configMode) self:SetShown(configMode) - for _, button in pairs(self.Buttons) do - button:SetShown(configMode) + self.configMode = configMode + for i = 1, BUFF_MAX_DISPLAY do + local name = 'BuffButton' .. i + local button = self:AcquireConfigButton(name) + end + for i = 1, DEBUFF_MAX_DISPLAY do + local name = 'DebuffButton' .. i + local button = self:AcquireConfigButton(name) end end -function VeneerBuffFrameMixin:OnUpdateDuration (frame, timeLeft) +function plugin:OnUpdateDuration (frame, timeLeft) local veneer = self:Acquire(frame) local hours = floor(timeLeft/3600) local minutes = floor(mod(timeLeft, 3600)/60) @@ -557,12 +582,13 @@ -- Obtains the first instance of Tenchant use -function VeneerBuffFrameMixin:OnTemporaryEnchantFrameUpdate (...) +function plugin:OnTemporaryEnchantFrameUpdate (...) local numVals = select('#', ...) local numItems = numVals / 4 if numItems >= 1 then for itemIndex = numItems, 1, -1 do - local frame = _G['TempEnchant'..itemIndex] + local name = 'TempEnchant'..itemIndex + local frame = _G[name] local hasEnchant, timeRemaining, enchantCharges = select((4 * (itemIndex -1)) + 1, ...) @@ -577,35 +603,17 @@ end expirationCache[frame] = endTime print('push tempenchant timer update', timeRemaining / 1000, GetTime()+(timeRemaining/1000)) - UpdateVeneer(frame, timeRemaining/1000, GetTime()+(timeRemaining/1000)) + self:UpdateButton(frame, timeRemaining/1000, GetTime()+(timeRemaining/1000)) end else - self:Acquire(frame):Hide() + self:Acquire(name):Hide() end - end - end - -end -function VeneerBuffFrameMixin:OnBuffFrameUpdate () end +function plugin:OnBuffFrameUpdate () end -function VeneerBuffFrameButtonMixin:OnLoad() - - self.duration = self.progress.duration - self.count = self.overlay.count - self.border = self.underlay.bg - - VeneerBuffFrame.ConfigLayers = VeneerBuffFrame.ConfigLayers or {} - self.configIndex = #VeneerBuffFrame.ConfigLayers - for i, region in ipairs(self.ConfigLayers) do - tinsert(VeneerBuffFrame.ConfigLayers, region) - end - - self.configIndexEnd = #VeneerBuffFrame.ConfigLayers -end -- The TempEnchant frames are hardcoded in the base FrameXML, so get them now diff -r caded2668701 -r df10cd0ae949 Modules/BuffFrame.xml --- a/Modules/BuffFrame.xml Sun Jan 01 18:25:26 2017 -0500 +++ b/Modules/BuffFrame.xml Sun Jan 01 19:31:06 2017 -0500 @@ -9,6 +9,8 @@ + +