Mercurial > wow > buffalo2
changeset 102:1e511e9aaca5
- clean up handler loading inconsistencies; exclude free frames from anchor cluster iterations, and remove extraneous PLAYER_LOGIN handling
- added a Setup method to the handler template that creates and reconciles a SavedVariables table for that module
author | Nenue |
---|---|
date | Wed, 25 Jan 2017 23:11:27 -0500 |
parents | f32b63c93275 |
children | 8df154a2bfd6 |
files | Modules/ArtifactPower.lua Modules/GuildInfo.lua Modules/GuildInfo.xml Modules/PaperDoll.lua Modules/TalkingHead.lua Templates.lua Veneer.lua |
diffstat | 7 files changed, 114 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/Modules/ArtifactPower.lua Sat Jan 21 20:12:17 2017 -0500 +++ b/Modules/ArtifactPower.lua Wed Jan 25 23:11:27 2017 -0500 @@ -74,16 +74,44 @@ end + +local IsBagnonOpen = function() + return ((BagnonFramebank and BagnonFramebank:IsShown()) or (BagnonFrameinventory and BagnonFrameinventory:IsShown())) +end local addonCompatibility = { ['Bagnon'] = { BagFrames = {'BagnonFrameinventory'}, BankFrames = {'BagnonFramebank'}, + FrameMethods = { + ['HideFrame'] = IsBagnonOpen, + ['ShowFrame'] = IsBagnonOpen + }, PostHooks = {'ToggleAllBags', 'ToggleBackpack' }, MethodClass = 'Bagnon', - MethodHooks = {'BANK_OPENED', 'BANKFRAME_CLOSED'} + MethodHooks = {'BANK_OPENED', 'BANKFRAME_CLOSED'}, + } } +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) + end +end +local PENDING_HOOKS = {} + +local function RegisterInventoryFrame(name, listType, args) + print('register', name, 'as inventory frame type =', (listType == BAG_FRAMES) and 'bags' or 'bank') + tinsert(FRAME_LIST, name) + tinsert(listType, name) + if _G[name] then + AddFrameHooks(_G[name], args) + else + PENDING_HOOKS[name] = args + end +end + function ap:Setup() print(self:GetName()..':Setup()') @@ -123,14 +151,15 @@ -- todo: ArkInventory, Elv, etc for addon, args in pairs(addonCompatibility) do if IsAddOnLoaded(addon) then + for _, name in ipairs(args.BagFrames) do - tinsert(FRAME_LIST, name) - tinsert(BAG_FRAMES, name) + RegisterInventoryFrame(name, BAG_FRAMES, args) end for _, name in ipairs(args.BankFrames) do - tinsert(FRAME_LIST, name) - tinsert(BAG_FRAMES, name) + RegisterInventoryFrame(name, BANK_FRAMES, args) end + + -- should only specify non-secure functions in this table for _, name in ipairs(args.PostHooks) do local oFunc = _G[name] _G[name] = function(...) @@ -217,13 +246,18 @@ function ap:OnShow() print('|cFFFFFF00OnShow()|r') + + for name, args in pairs(PENDING_HOOKS) do + if _G[name] then + AddFrameHooks(_G[name], args) + PENDING_HOOKS[name] = nil + end + end + + self.enabled = true self:ScanAllBags() self:Reanchor() - if not self.postShowSetup then - self.postShowSetup = true - hooksecurefunc("HideUIPanel", function() self:TryToShow() end) - end end function ap:OnHide() print('|cFF88FF00OnHide()|r') @@ -506,7 +540,6 @@ if itemAP then itemAP = itemAP / self.profile.knowledgeMultiplier self.cache[itemID] = itemAP - return itemAP end end end @@ -518,7 +551,6 @@ if fishingAP then self.cache[itemID] = fishingAP self.fishingCache[itemID] = true - return fishingAP, true end end else @@ -553,20 +585,21 @@ local name, _, quality, iLevel, reqLevel, class, subclass = GetItemInfo(link) if class == 'Consumable' and subclass == 'Other' then - print(GetItemInfo(link)) + --print(GetItemInfo(link)) local itemAP, isFishingAP = self:GetItemAP(itemID, link) - print(itemAP, isFishingAP) - if itemAP > 0 then + --print(itemAP, isFishingAP) + if itemAP and (itemAP > 0) then + local itemButton = self:GetItemButton(itemID, texture, itemAP) + if isFishingAP then bagData.fishingItems = (bagData.fishingItems or 0) + 1 bagData.fishingAP = (bagData.fishingAP or 0) + itemAP else - + itemAP = itemAP * self.profile.knowledgeMultiplier bagData.numItems = (bagData.numItems or 0) + 1 bagData.totalAP = (bagData.totalAP or 0) + itemAP end bagData.items[itemID] = (bagData.items[itemID] or 0) + 1 - local itemButton = self:GetItemButton(itemID, texture, itemAP) end elseif self.profile.artifacts[itemID] then print('artfiact weapon', itemID, link, id, slotID) @@ -665,6 +698,7 @@ self.potentialLevel = potentialPoints self.potentialAdjustedXP = potentialXP + if index ~= 1 then self:ClearAllPoints()
--- a/Modules/GuildInfo.lua Sat Jan 21 20:12:17 2017 -0500 +++ b/Modules/GuildInfo.lua Wed Jan 25 23:11:27 2017 -0500 @@ -0,0 +1,22 @@ +VeneerRosterKunMixin = { + addonTrigger = 'Blizzard_GuildUI', + + anchorFrame = 'GuildFrame', + anchorPoint = 'TOPLEFT', +} + + +local module = VeneerRosterKunMixin + +function module:OnLoad() + + Veneer:AddHandler(self, self.anchorPoint) + + self:RegisterEvent('GUILD_ROSTER_UPDATE') + self:RegisterEvent('GUILD_TRADESKILL_UPDATE') +end + +function module:OnEvent() + + +end \ No newline at end of file
--- a/Modules/GuildInfo.xml Sat Jan 21 20:12:17 2017 -0500 +++ b/Modules/GuildInfo.xml Wed Jan 25 23:11:27 2017 -0500 @@ -0,0 +1,10 @@ +<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ +..\FrameXML\UI.xsd"> + <Script file="GuildInfo.lua" /> + + <Frame name="$parentRosterKun" mixin="VeneerRosterKunMixin" parent="Veneer" inherits="VeneerHandlerTemplate"> + + + </Frame> + + </Ui> \ No newline at end of file
--- a/Modules/PaperDoll.lua Sat Jan 21 20:12:17 2017 -0500 +++ b/Modules/PaperDoll.lua Wed Jan 25 23:11:27 2017 -0500 @@ -62,10 +62,8 @@ self:GetStats(PaperDollItemsFrame, ...) end) - self:RegisterEvent('ADDON_LOADED') self:RegisterEvent('INSPECT_READY') - - self.SocketType = {} + Veneer:AddHandler(self) end function VeneerPaperDollMixin:SetupInspectFrame()
--- a/Modules/TalkingHead.lua Sat Jan 21 20:12:17 2017 -0500 +++ b/Modules/TalkingHead.lua Wed Jan 25 23:11:27 2017 -0500 @@ -12,7 +12,7 @@ anchorPoint = 'BOTTOMLEFT', anchorFrom = 'TOPLEFT', anchorX = -4, - anchorY = 24, + anchorY = 96, anchorFrame = 'ChatFrame1', addonTrigger = 'Blizzard_TalkingHeadUI'
--- a/Templates.lua Sat Jan 21 20:12:17 2017 -0500 +++ b/Templates.lua Wed Jan 25 23:11:27 2017 -0500 @@ -5,10 +5,14 @@ -- -- Mover Widget base local print = DEVIAN_WORKSPACE and function(...) _G.print('VnTemplate', ...) end or nop +local debugTemplates = {} VeneerConfigLayerMixin = {} VeneerAnimationMixin = {} -VeneerHandlerMixin = { anchorPoint = 'CENTER' } +VeneerHandlerMixin = { + anchorPoint = 'CENTER', + data = {}, +} function VeneerConfigLayerMixin:OnLoad() local handler = self:GetParent() @@ -53,6 +57,22 @@ function VeneerHandlerMixin:Reanchor (anchorAll) Veneer:DynamicReanchor() end +function VeneerHandlerMixin:Setup() + local configName = self:GetName():gsub('^Veneer', '') + VeneerData[configName] = VeneerData[configName] or {} + + -- reconcile any data accumulated before login trigger + for k,v in pairs(self.data) do + if not VeneerData[configName][k] then + print('reconciling pre-data:', k, v) + VeneerData[configName][k] = v + end + end + + self.data = VeneerData[configName] + print('data table loaded:', configName) + self.initialized = true +end function VeneerHandlerMixin:Print(...) local txt = '|cFFFFFF00'..self:GetName()..'|r:' @@ -60,5 +80,7 @@ txt = txt .. ' '.. tostring(select(i, ...)) end + + DEFAULT_CHAT_FRAME:AddMessage(txt) end \ No newline at end of file
--- a/Veneer.lua Sat Jan 21 20:12:17 2017 -0500 +++ b/Veneer.lua Wed Jan 25 23:11:27 2017 -0500 @@ -247,7 +247,7 @@ function VeneerCore:AddHandler(handler, ...) print('|cFFFFFF00*** Adding handler:', handler.moduleName or handler:GetName()) - + if not handler.anchorFrame then local anchorGroup, clusterTable, clusterIndex = self:GetClusterFromArgs(...) if clusterIndex == 1 then for i, frame in ipairs(clusterTable) do @@ -255,11 +255,14 @@ end end tinsert(clusterTable, clusterIndex, handler) + print(' cluster', anchorGroup, 'table', clusterTable, 'position', clusterIndex) - print(' cluster', anchorGroup, 'table', clusterTable, 'position', clusterIndex) + handler.anchorCluster = clusterTable + handler.anchorIndex = clusterIndex + else + print(' free frame') + end - handler.anchorCluster = clusterTable - handler.anchorIndex = clusterIndex for k,v in pairs(VeneerHandlerMixin) do if not handler[k] then print(' * from mixin:', k)