Mercurial > wow > buffalo2
changeset 128:799ec6dce9c3
- use BagBrother for inventory items, fixes bank stuff not being counted
author | Nenue |
---|---|
date | Thu, 19 Oct 2017 10:39:04 -0400 |
parents | 8a915f85b96c |
children | 9f2cf5609420 |
files | Modules/Bank.lua Modules/Currency.lua Veneer.toc |
diffstat | 3 files changed, 92 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/Modules/Bank.lua Tue Oct 17 17:24:27 2017 -0400 +++ b/Modules/Bank.lua Thu Oct 19 10:39:04 2017 -0400 @@ -8,6 +8,8 @@ local m = VeneerBankDBMixin function m:Setup() + + self:RegisterEvent('BANKFRAME_OPENED') self:RegisterEvent('BANKFRAME_CLOSED') @@ -26,9 +28,44 @@ end end +local itemsByID = {} +local itemsBySlot = {} +local bankslots = {-1} function m:OnEvent(event) print('OnEvent', event) - self.Info:SetText(event) + + for i = 1, NUM_BANKBAGSLOTS do + if not tContains(bankslots, i) then + tinsert(bankslots, i) + end + end + + for _, container in pairs(bankslots) do + for slot = 1, GetContainerNumSlots(container) do + local item = GetContainerItemID() + + local itemID = GetContainerItemID(container, slot) + local texture, count, locked, quality, lootable, link = GetContainerItemInfo(container, slot) + if itemsByID[itemID] then + itemsByID[itemID].count = itemsByID[itemID].count + (count or 1) + if not itemsByID[itemID].texture then + itemsByID[itemID].texture = texture + print('tracked currency tally', itemsByID[itemID].count, '|T'..texture..':16:16|t') + itemsByID[itemID].frame.Icon:SetTexture(texture) + end + end + + itemsBySlot[container] = itemsBySlot[container] or {} + itemsBySlot[container][slot] = itemsBySlot[container][slot] or {} + itemsBySlot[container][slot].texture = texture + itemsBySlot[container][slot].count = count + itemsBySlot[container][slot].quality = quality + itemsBySlot[container][slot].lootable = lootable + itemsBySlot[container][slot].link = link + + end + + end end
--- a/Modules/Currency.lua Tue Oct 17 17:24:27 2017 -0400 +++ b/Modules/Currency.lua Thu Oct 19 10:39:04 2017 -0400 @@ -38,13 +38,13 @@ ["Legionfall War Supplies"] = { currencyID = 1342, zones = { - ["The Broken Shore"] = true + ["Broken Shore"] = true } }, ["Nethershard"] = { currencyID = 1226, zones = { - ["The Broken Shore"] = true + ["Broken Shore"] = true } }, ["Veiled Argunite"] = { @@ -81,7 +81,7 @@ end function module:Setup() - self:Update() + self:Reanchor() end function module:OnLoad () @@ -108,25 +108,25 @@ frame = block } block.Update = itemBlock.Update - RegisterEvents(self, itemEvents) + RegisterEvents(block, itemEvents) elseif info.currencyID then local currencyID = info.currencyID block.Update = currencyBlock.Update - RegisterEvents(block, currencyEvents) + RegisterEvents(self, currencyEvents) end if info.zones then - RegisterEvents(block, zoneEvents) + RegisterEvents(self, zoneEvents) local zones = info.zones local of = block.Update - function block:Update(zone, subZone) + function block:Update() local zone = GetRealZoneText() local subZone = GetSubZoneText() - block.debug('Zone Check', zone, subZone) local canShow = ((zone and self.zones[zone]) or (subZone and self.zones[subZone])) and true or false + block.debug('Zone Check', zone, subZone, canShow) if of then canShow = canShow and of(self) end @@ -138,10 +138,11 @@ function module:OnEvent (event, arg) print(self:GetName(), 'OnEvent', event, arg) + self:Update() end -function module:Update(isBatchUpdate) - print(self:GetName(), 'Update()') +function module:Update() + print(self:GetName(), 'Reanchor()') if InCombatLockdown() then self:SetShown(false) return @@ -154,17 +155,47 @@ local canShow = false - for i = 0, NUM_BAG_SLOTS do - local numSlots = GetContainerNumSlots(i) - for j = 1, numSlots do - local itemID = GetContainerItemID(i, j) - local texture, count = GetContainerItemInfo(i,j) - if items[itemID] then - items[itemID].count = items[itemID].count + (count or 1) - if not items[itemID].texture then - items[itemID].texture = texture - print('tracked currency tally', items[itemID].count, '|T'..texture..':16:16|t') - items[itemID].frame.Icon:SetTexture(texture) + if BagBrother then + for i, bag in pairs(BagBrother.Player) do + if type(bag) == 'table' then + --print(i) + for j, item in pairs(bag) do + local itemID, count = string.match(item ,"^(%d+):.+;(%d*)") + itemID = tonumber(itemID) + if itemID then + --print(j, itemID) + count = tonumber(count) + if count and count >= 1 then + local texture = GetItemIcon(itemID) + --print(itemID) + + if items[itemID] then + items[itemID].count = items[itemID].count + (count or 1) + if not items[itemID].texture then + items[itemID].texture = texture + --print('tracked currency tally', items[itemID].count, '|T'..texture..':16:16|t') + items[itemID].frame.Icon:SetTexture(texture) + end + end + end + end + end + end + + end + else + for i = 0, NUM_BAG_SLOTS do + local numSlots = GetContainerNumSlots(i) + for j = 1, numSlots do + local itemID = GetContainerItemID(i, j) + local texture, count = GetContainerItemInfo(i,j) + if items[itemID] then + items[itemID].count = items[itemID].count + (count or 1) + if not items[itemID].texture then + items[itemID].texture = texture + print('tracked currency tally', items[itemID].count, '|T'..texture..':16:16|t') + items[itemID].frame.Icon:SetTexture(texture) + end end end end @@ -175,7 +206,8 @@ local lastBlock local totalWidth = 0 for _, block in ipairs(self.Blocks) do - local blockIsShown = block:Update(self.realZoneText, self.subZoneText) or false + local blockIsShown = block:Update() + print(block.name, blockIsShown) block:SetShown(blockIsShown) canShow = canShow or blockIsShown