comparison Modules/Bank.lua @ 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 3de635cda288
children
comparison
equal deleted inserted replaced
127:8a915f85b96c 128:799ec6dce9c3
6 local profileUpdate, needsUpdate 6 local profileUpdate, needsUpdate
7 VeneerBankDBMixin = {} 7 VeneerBankDBMixin = {}
8 local m = VeneerBankDBMixin 8 local m = VeneerBankDBMixin
9 9
10 function m:Setup() 10 function m:Setup()
11
12
11 self:RegisterEvent('BANKFRAME_OPENED') 13 self:RegisterEvent('BANKFRAME_OPENED')
12 self:RegisterEvent('BANKFRAME_CLOSED') 14 self:RegisterEvent('BANKFRAME_CLOSED')
13 15
14 self:SetPoint('CENTER', UIParent, 'CENTER') 16 self:SetPoint('CENTER', UIParent, 'CENTER')
15 self:SetSize(100,100) 17 self:SetSize(100,100)
24 for k,v in pairs(self) do 26 for k,v in pairs(self) do
25 print(k,v) 27 print(k,v)
26 end 28 end
27 end 29 end
28 30
31 local itemsByID = {}
32 local itemsBySlot = {}
33 local bankslots = {-1}
29 function m:OnEvent(event) 34 function m:OnEvent(event)
30 print('OnEvent', event) 35 print('OnEvent', event)
31 self.Info:SetText(event) 36
37 for i = 1, NUM_BANKBAGSLOTS do
38 if not tContains(bankslots, i) then
39 tinsert(bankslots, i)
40 end
41 end
42
43 for _, container in pairs(bankslots) do
44 for slot = 1, GetContainerNumSlots(container) do
45 local item = GetContainerItemID()
46
47 local itemID = GetContainerItemID(container, slot)
48 local texture, count, locked, quality, lootable, link = GetContainerItemInfo(container, slot)
49 if itemsByID[itemID] then
50 itemsByID[itemID].count = itemsByID[itemID].count + (count or 1)
51 if not itemsByID[itemID].texture then
52 itemsByID[itemID].texture = texture
53 print('tracked currency tally', itemsByID[itemID].count, '|T'..texture..':16:16|t')
54 itemsByID[itemID].frame.Icon:SetTexture(texture)
55 end
56 end
57
58 itemsBySlot[container] = itemsBySlot[container] or {}
59 itemsBySlot[container][slot] = itemsBySlot[container][slot] or {}
60 itemsBySlot[container][slot].texture = texture
61 itemsBySlot[container][slot].count = count
62 itemsBySlot[container][slot].quality = quality
63 itemsBySlot[container][slot].lootable = lootable
64 itemsBySlot[container][slot].link = link
65
66 end
67
68 end
32 end 69 end
33 70
34 71
35 72
36 73