Mercurial > wow > buffalo2
comparison Modules/ArtifactPower.lua @ 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 |
comparison
equal
deleted
inserted
replaced
| 101:f32b63c93275 | 102:1e511e9aaca5 |
|---|---|
| 72 tinsert(UISpecialFrames, self:GetName()) | 72 tinsert(UISpecialFrames, self:GetName()) |
| 73 | 73 |
| 74 | 74 |
| 75 end | 75 end |
| 76 | 76 |
| 77 | |
| 78 local IsBagnonOpen = function() | |
| 79 return ((BagnonFramebank and BagnonFramebank:IsShown()) or (BagnonFrameinventory and BagnonFrameinventory:IsShown())) | |
| 80 end | |
| 77 local addonCompatibility = { | 81 local addonCompatibility = { |
| 78 ['Bagnon'] = { | 82 ['Bagnon'] = { |
| 79 BagFrames = {'BagnonFrameinventory'}, | 83 BagFrames = {'BagnonFrameinventory'}, |
| 80 BankFrames = {'BagnonFramebank'}, | 84 BankFrames = {'BagnonFramebank'}, |
| 85 FrameMethods = { | |
| 86 ['HideFrame'] = IsBagnonOpen, | |
| 87 ['ShowFrame'] = IsBagnonOpen | |
| 88 }, | |
| 81 PostHooks = {'ToggleAllBags', 'ToggleBackpack' }, | 89 PostHooks = {'ToggleAllBags', 'ToggleBackpack' }, |
| 82 MethodClass = 'Bagnon', | 90 MethodClass = 'Bagnon', |
| 83 MethodHooks = {'BANK_OPENED', 'BANKFRAME_CLOSED'} | 91 MethodHooks = {'BANK_OPENED', 'BANKFRAME_CLOSED'}, |
| 92 | |
| 84 } | 93 } |
| 85 } | 94 } |
| 95 | |
| 96 local function AddFrameHooks(frame, args) | |
| 97 for funcName, func in pairs(args.FrameMethods) do | |
| 98 print('binding', frame:GetName(), funcName, 'to', tostring(func)) | |
| 99 hooksecurefunc(frame, funcName, func) | |
| 100 end | |
| 101 end | |
| 102 local PENDING_HOOKS = {} | |
| 103 | |
| 104 local function RegisterInventoryFrame(name, listType, args) | |
| 105 print('register', name, 'as inventory frame type =', (listType == BAG_FRAMES) and 'bags' or 'bank') | |
| 106 tinsert(FRAME_LIST, name) | |
| 107 tinsert(listType, name) | |
| 108 if _G[name] then | |
| 109 AddFrameHooks(_G[name], args) | |
| 110 else | |
| 111 PENDING_HOOKS[name] = args | |
| 112 end | |
| 113 end | |
| 86 | 114 |
| 87 | 115 |
| 88 function ap:Setup() | 116 function ap:Setup() |
| 89 print(self:GetName()..':Setup()') | 117 print(self:GetName()..':Setup()') |
| 90 local guid = UnitGUID('player') | 118 local guid = UnitGUID('player') |
| 121 | 149 |
| 122 -- Bagnon compatibility | 150 -- Bagnon compatibility |
| 123 -- todo: ArkInventory, Elv, etc | 151 -- todo: ArkInventory, Elv, etc |
| 124 for addon, args in pairs(addonCompatibility) do | 152 for addon, args in pairs(addonCompatibility) do |
| 125 if IsAddOnLoaded(addon) then | 153 if IsAddOnLoaded(addon) then |
| 154 | |
| 126 for _, name in ipairs(args.BagFrames) do | 155 for _, name in ipairs(args.BagFrames) do |
| 127 tinsert(FRAME_LIST, name) | 156 RegisterInventoryFrame(name, BAG_FRAMES, args) |
| 128 tinsert(BAG_FRAMES, name) | |
| 129 end | 157 end |
| 130 for _, name in ipairs(args.BankFrames) do | 158 for _, name in ipairs(args.BankFrames) do |
| 131 tinsert(FRAME_LIST, name) | 159 RegisterInventoryFrame(name, BANK_FRAMES, args) |
| 132 tinsert(BAG_FRAMES, name) | 160 end |
| 133 end | 161 |
| 162 -- should only specify non-secure functions in this table | |
| 134 for _, name in ipairs(args.PostHooks) do | 163 for _, name in ipairs(args.PostHooks) do |
| 135 local oFunc = _G[name] | 164 local oFunc = _G[name] |
| 136 _G[name] = function(...) | 165 _G[name] = function(...) |
| 137 print('|cFFFF0088' .. name .. '|r', ...) | 166 print('|cFFFF0088' .. name .. '|r', ...) |
| 138 oFunc(...) | 167 oFunc(...) |
| 215 end | 244 end |
| 216 end | 245 end |
| 217 | 246 |
| 218 function ap:OnShow() | 247 function ap:OnShow() |
| 219 print('|cFFFFFF00OnShow()|r') | 248 print('|cFFFFFF00OnShow()|r') |
| 249 | |
| 250 for name, args in pairs(PENDING_HOOKS) do | |
| 251 if _G[name] then | |
| 252 AddFrameHooks(_G[name], args) | |
| 253 PENDING_HOOKS[name] = nil | |
| 254 end | |
| 255 end | |
| 256 | |
| 257 | |
| 220 self.enabled = true | 258 self.enabled = true |
| 221 self:ScanAllBags() | 259 self:ScanAllBags() |
| 222 self:Reanchor() | 260 self:Reanchor() |
| 223 if not self.postShowSetup then | |
| 224 self.postShowSetup = true | |
| 225 hooksecurefunc("HideUIPanel", function() self:TryToShow() end) | |
| 226 end | |
| 227 end | 261 end |
| 228 function ap:OnHide() | 262 function ap:OnHide() |
| 229 print('|cFF88FF00OnHide()|r') | 263 print('|cFF88FF00OnHide()|r') |
| 230 self:Reanchor() | 264 self:Reanchor() |
| 231 end | 265 end |
| 504 print(itemLink, '-', tonumber(text)) | 538 print(itemLink, '-', tonumber(text)) |
| 505 local itemAP = tonumber(text) | 539 local itemAP = tonumber(text) |
| 506 if itemAP then | 540 if itemAP then |
| 507 itemAP = itemAP / self.profile.knowledgeMultiplier | 541 itemAP = itemAP / self.profile.knowledgeMultiplier |
| 508 self.cache[itemID] = itemAP | 542 self.cache[itemID] = itemAP |
| 509 return itemAP | |
| 510 end | 543 end |
| 511 end | 544 end |
| 512 end | 545 end |
| 513 end | 546 end |
| 514 local fishingText = _G[TOOLTIP_NAME .. 'TextLeft3']:GetText() | 547 local fishingText = _G[TOOLTIP_NAME .. 'TextLeft3']:GetText() |
| 516 local fishingAP = fishingText:match("%d+") | 549 local fishingAP = fishingText:match("%d+") |
| 517 fishingAP = tonumber(fishingAP) | 550 fishingAP = tonumber(fishingAP) |
| 518 if fishingAP then | 551 if fishingAP then |
| 519 self.cache[itemID] = fishingAP | 552 self.cache[itemID] = fishingAP |
| 520 self.fishingCache[itemID] = true | 553 self.fishingCache[itemID] = true |
| 521 return fishingAP, true | |
| 522 end | 554 end |
| 523 end | 555 end |
| 524 else | 556 else |
| 525 | 557 |
| 526 self.cache[itemID] = 0 | 558 self.cache[itemID] = 0 |
| 551 if link then | 583 if link then |
| 552 local itemID = GetContainerItemID(id, slotID) | 584 local itemID = GetContainerItemID(id, slotID) |
| 553 local name, _, quality, iLevel, reqLevel, class, subclass = GetItemInfo(link) | 585 local name, _, quality, iLevel, reqLevel, class, subclass = GetItemInfo(link) |
| 554 | 586 |
| 555 if class == 'Consumable' and subclass == 'Other' then | 587 if class == 'Consumable' and subclass == 'Other' then |
| 556 print(GetItemInfo(link)) | 588 --print(GetItemInfo(link)) |
| 557 local itemAP, isFishingAP = self:GetItemAP(itemID, link) | 589 local itemAP, isFishingAP = self:GetItemAP(itemID, link) |
| 558 print(itemAP, isFishingAP) | 590 --print(itemAP, isFishingAP) |
| 559 if itemAP > 0 then | 591 if itemAP and (itemAP > 0) then |
| 592 local itemButton = self:GetItemButton(itemID, texture, itemAP) | |
| 593 | |
| 560 if isFishingAP then | 594 if isFishingAP then |
| 561 bagData.fishingItems = (bagData.fishingItems or 0) + 1 | 595 bagData.fishingItems = (bagData.fishingItems or 0) + 1 |
| 562 bagData.fishingAP = (bagData.fishingAP or 0) + itemAP | 596 bagData.fishingAP = (bagData.fishingAP or 0) + itemAP |
| 563 else | 597 else |
| 564 | 598 itemAP = itemAP * self.profile.knowledgeMultiplier |
| 565 bagData.numItems = (bagData.numItems or 0) + 1 | 599 bagData.numItems = (bagData.numItems or 0) + 1 |
| 566 bagData.totalAP = (bagData.totalAP or 0) + itemAP | 600 bagData.totalAP = (bagData.totalAP or 0) + itemAP |
| 567 end | 601 end |
| 568 bagData.items[itemID] = (bagData.items[itemID] or 0) + 1 | 602 bagData.items[itemID] = (bagData.items[itemID] or 0) + 1 |
| 569 local itemButton = self:GetItemButton(itemID, texture, itemAP) | |
| 570 end | 603 end |
| 571 elseif self.profile.artifacts[itemID] then | 604 elseif self.profile.artifacts[itemID] then |
| 572 print('artfiact weapon', itemID, link, id, slotID) | 605 print('artfiact weapon', itemID, link, id, slotID) |
| 573 self.profile.artifacts[itemID].containerID = id | 606 self.profile.artifacts[itemID].containerID = id |
| 574 self.profile.artifacts[itemID].slotID = slotID | 607 self.profile.artifacts[itemID].slotID = slotID |
| 663 end | 696 end |
| 664 self.potentialCost = potentialCost | 697 self.potentialCost = potentialCost |
| 665 self.potentialLevel = potentialPoints | 698 self.potentialLevel = potentialPoints |
| 666 self.potentialAdjustedXP = potentialXP | 699 self.potentialAdjustedXP = potentialXP |
| 667 | 700 |
| 701 | |
| 668 | 702 |
| 669 if index ~= 1 then | 703 if index ~= 1 then |
| 670 self:ClearAllPoints() | 704 self:ClearAllPoints() |
| 671 self:SetPoint('TOPLEFT', self.relativeFrame, 'TOPRIGHT', 4, 0) | 705 self:SetPoint('TOPLEFT', self.relativeFrame, 'TOPRIGHT', 4, 0) |
| 672 else | 706 else |
