Mercurial > wow > buffalo2
changeset 103:8df154a2bfd6 v7.1.5-r104
- Fixed a tainting issue caused by trying to hook ToggleAllBags
author | Nenue |
---|---|
date | Thu, 26 Jan 2017 17:36:12 -0500 |
parents | 1e511e9aaca5 |
children | 8599826a68b7 |
files | Modules/ArtifactPower.lua Modules/TalkingHead.lua Templates.lua Veneer.lua |
diffstat | 4 files changed, 122 insertions(+), 78 deletions(-) [+] |
line wrap: on
line diff
--- a/Modules/ArtifactPower.lua Wed Jan 25 23:11:27 2017 -0500 +++ b/Modules/ArtifactPower.lua Thu Jan 26 17:36:12 2017 -0500 @@ -83,20 +83,40 @@ BagFrames = {'BagnonFrameinventory'}, BankFrames = {'BagnonFramebank'}, FrameMethods = { - ['HideFrame'] = IsBagnonOpen, - ['ShowFrame'] = IsBagnonOpen + ['Hide'] = IsBagnonOpen, + ['Show'] = IsBagnonOpen }, - PostHooks = {'ToggleAllBags', 'ToggleBackpack' }, + PostHooks = {}, MethodClass = 'Bagnon', MethodHooks = {'BANK_OPENED', 'BANKFRAME_CLOSED'}, } } + + +local queued_hooks = {} +local function CreateHook(...) + if select('#', ...) >= 2 then + tinsert(queued_hooks, {...}) + end + if not InCombatLockdown() then + local info = tremove(queued_hooks) + while info do + print('hooking', unpack(info)) + hooksecurefunc(unpack(info)) + info = tremove(queued_hooks) + end + + end +end + local function AddFrameHooks(frame, args) for funcName, func in pairs(args.FrameMethods) do print('binding', frame:GetName(), funcName, 'to', tostring(func)) - hooksecurefunc(frame, funcName, func) + CreateHook(frame, funcName, function() + VeneerArtifactPower:TryToShow() + end) end end local PENDING_HOOKS = {} @@ -112,7 +132,6 @@ end end - function ap:Setup() print(self:GetName()..':Setup()') local guid = UnitGUID('player') @@ -144,8 +163,8 @@ local DoTryToShow = function() self:TryToShow() end - hooksecurefunc("OpenBackpack", DoTryToShow) - hooksecurefunc("CloseBackpack", DoTryToShow) + CreateHook("OpenBackpack", DoTryToShow) + CreateHook("CloseBackpack", DoTryToShow) -- Bagnon compatibility -- todo: ArkInventory, Elv, etc @@ -162,16 +181,18 @@ -- should only specify non-secure functions in this table for _, name in ipairs(args.PostHooks) do local oFunc = _G[name] - _G[name] = function(...) - print('|cFFFF0088' .. name .. '|r', ...) + print('hook entry', name, tostring(oFunc)) + CreateHook(name, function(...) + print('|cFFFF0088' .. name .. '|r', ..., 'original', tostring(oFunc)) oFunc(...) self:TryToShow() - end + end) end local frame = _G[args.MethodClass] if frame then + print() for _, name in ipairs(args.MethodHooks) do - hooksecurefunc(frame, name, DoTryToShow) + CreateHook(frame, name, DoTryToShow) end end end @@ -184,48 +205,7 @@ end local UNDERLIGHT_ANGLER_ID = 133755 -function ap:SetArtifact(itemID, name, texture, currentXP, pointsSpent) - print('|cFF00FF00SetArtifact()|r') - if not self.profile then - return - end - local artifacts = self.profile.artifacts - local multi = C_ArtifactUI.GetArtifactKnowledgeMultiplier() - self.profile.knowledgeMultiplier = multi or self.profile.knowledgeMultiplier - print('multiplier:', multi) - - if itemID then - - self.currentEquipped = itemID - - artifacts[itemID] = artifacts[itemID] or {} - table.wipe(artifacts[itemID]) - local artifact = artifacts[itemID] - - artifact.name = name - artifact.texture = texture - artifact.currentXP = currentXP - artifact.level = pointsSpent - local cost = C_ArtifactUI.GetCostForPointAtRank(pointsSpent) - artifact.cost = cost - - local pointsAvailable = pointsSpent - local actualCost = cost - local actualXP = currentXP - while actualXP >= actualCost do - pointsAvailable = pointsAvailable + 1 - actualXP = actualXP - actualCost - print(pointsAvailable, '-', actualCost, '=', actualXP) - actualCost = C_ArtifactUI.GetCostForPointAtRank(pointsAvailable) - end - print('updating', itemID, name, currentXP, pointsSpent, pointsAvailable, actualXP) - artifact.actualXP = actualXP - artifact.actualLevel = pointsAvailable - artifact.actualCost = actualCost - - end -end function ap:QueueBag(containerID) containerID = tonumber(containerID) if not containerID then @@ -279,7 +259,7 @@ if not InCombatLockdown() then for _, name in ipairs(FRAME_LIST) do - --print(name, (_G[name] and _G[name]:IsShown())) + print('test:', name, (_G[name] and _G[name]:IsShown())) if _G[name] and _G[name]:IsShown() then if self:IsShown() then self:Update() @@ -328,14 +308,16 @@ self:SetArtifact(itemID, name, texture, currentXP, pointsSpent) self:ScanAllBags(self.bankAccess) elseif event == 'PLAYER_REGEN_ENABLED' then - if self.enabled then - if self.queuedScan then - self:ScanAllBags(self.backAccess) - else - self:TryToShow() - end + + if self.queuedScan then + self:ScanAllBags(self.backAccess) + else + self:TryToShow() end + if #queued_hooks >= 1 then + CreateHook() + end elseif event == 'PLAYER_REGEN_DISABLED' then self:Hide() end @@ -561,6 +543,49 @@ return self.cache[itemID], self.fishingCache[itemID] end +function ap:SetArtifact(itemID, name, texture, currentXP, pointsSpent) + print('|cFF00FF00SetArtifact()|r') + if not self.profile then + return + end + local artifacts = self.profile.artifacts + + local multi = C_ArtifactUI.GetArtifactKnowledgeMultiplier() + self.profile.knowledgeMultiplier = multi or self.profile.knowledgeMultiplier + print('multiplier:', multi) + + if itemID then + + self.currentEquipped = itemID + + artifacts[itemID] = artifacts[itemID] or {} + table.wipe(artifacts[itemID]) + local artifact = artifacts[itemID] + + artifact.name = name + artifact.texture = texture + artifact.currentXP = currentXP + artifact.level = pointsSpent + local cost = C_ArtifactUI.GetCostForPointAtRank(pointsSpent) + artifact.cost = cost + + local pointsAvailable = pointsSpent + local actualCost = cost + local actualXP = currentXP + while actualXP >= actualCost do + pointsAvailable = pointsAvailable + 1 + actualXP = actualXP - actualCost + print(pointsAvailable, '-', actualCost, '=', actualXP) + actualCost = C_ArtifactUI.GetCostForPointAtRank(pointsAvailable) + end + print('updating', itemID, name, currentXP, pointsSpent, pointsAvailable, actualXP) + artifact.actualXP = actualXP + artifact.actualLevel = pointsAvailable + artifact.actualCost = actualCost + + end +end + function ap:ScanBag(id) print('|cFF00FFFFScanBag()|r', id, IsBagOpen(id), GetContainerNumSlots(id)) local numSlots = GetContainerNumSlots(id) @@ -666,6 +691,7 @@ end self.lastUpdate = GetTime() + self.queuedScan = nil self:TryToShow() end
--- a/Modules/TalkingHead.lua Wed Jan 25 23:11:27 2017 -0500 +++ b/Modules/TalkingHead.lua Thu Jan 26 17:36:12 2017 -0500 @@ -81,4 +81,3 @@ Veneer:InternalReanchor(self) end -
--- a/Templates.lua Wed Jan 25 23:11:27 2017 -0500 +++ b/Templates.lua Thu Jan 26 17:36:12 2017 -0500 @@ -83,4 +83,13 @@ DEFAULT_CHAT_FRAME:AddMessage(txt) +end + +function VeneerHandlerMixin:UpdateConfigLayers (configMode) + -- Override to manage config visual elements when a config update is fired from /vn or login + if not self:IsShown() then + self:SetShown(configMode) + self:Reanchor() + end + self.configMode = configMode end \ No newline at end of file
--- a/Veneer.lua Wed Jan 25 23:11:27 2017 -0500 +++ b/Veneer.lua Thu Jan 26 17:36:12 2017 -0500 @@ -8,6 +8,7 @@ SLASH_VENEER1 = "/veneer" SLASH_VENEER2 = "/vn" local VENEER_VERSION = 703 +local LE_FREE_FRAMES_GROUP = 1 local type, strrep, ipairs, tinsert, tostring, select = type, string.rep, ipairs, tinsert, tostring, select local pairs, tremove = pairs, tremove @@ -24,7 +25,9 @@ VeneerCore = { Frames = {}, ConfigLayers = {}, - FrameClusters = {}, + FrameClusters = { + [LE_FREE_FRAMES_GROUP] = {}, + }, parserDepth = 0, pendingCalls = {}, AddOnCheck = {} @@ -260,6 +263,10 @@ handler.anchorCluster = clusterTable handler.anchorIndex = clusterIndex else + local clusterTable = self.FrameClusters[LE_FREE_FRAMES_GROUP] + handler.anchorCluster = clusterTable + handler.anchorIndex = #clusterTable+1 + tinsert(clusterTable, handler.anchorIndex, handler) print(' free frame') end @@ -319,30 +326,33 @@ parent = parent or self print('|cFF88FF00DynamicReanchor()') for anchorPoint, cluster in pairs(parent.FrameClusters) do - local lastFrame - for index, frame in ipairs(cluster) do - print(' |cFF00FF00'..index, frame:GetName(), frame:IsVisible(), (lastFrame and ('|cFFFFFF00'..lastFrame:GetName()..'|r') or '|cFF00FFFFUIParent')) - if frame:IsVisible() then + if anchorPoint ~= LE_FREE_FRAMES_GROUP then + local lastFrame + for index, frame in ipairs(cluster) do + print(' |cFF00FF00'..index, frame:GetName(), frame:IsVisible(), (lastFrame and ('|cFFFFFF00'..lastFrame:GetName()..'|r') or '|cFF00FFFFUIParent')) + if frame:IsVisible() then - if frame.anchorFrame then - print(frame.anchorPoint) - frame:SetPoint(frame.anchorPoint, frame.anchorFrame, frame.anchorFrom, frame.anchorX, frame.anchorY) - print(frame:GetTop(), frame:GetRight()) - else - anchorPoint = frame.anchorPoint or anchorPoint - frame:ClearAllPoints() - if lastFrame then - frame:SetPoint(anchorPoint, lastFrame, ANCHOR_OFFSET_POINT[anchorPoint], 0, 0) + if frame.anchorFrame then + print(frame.anchorPoint) + frame:SetPoint(frame.anchorPoint, frame.anchorFrame, frame.anchorFrom, frame.anchorX, frame.anchorY) + print(frame:GetTop(), frame:GetRight()) else - frame:SetPoint(anchorPoint, UIParent, anchorPoint, frame.anchorX, frame.anchorY) + anchorPoint = frame.anchorPoint or anchorPoint + frame:ClearAllPoints() + if lastFrame then + frame:SetPoint(anchorPoint, lastFrame, ANCHOR_OFFSET_POINT[anchorPoint], 0, 0) + else + frame:SetPoint(anchorPoint, UIParent, anchorPoint, frame.anchorX, frame.anchorY) + end + print(frame:GetTop(), frame:GetRight()) + lastFrame = frame end - print(frame:GetTop(), frame:GetRight()) - lastFrame = frame + end end + end - end end end