diff 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
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