Mercurial > wow > buffalo2
comparison Modules/Currency.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 | 15a7f27b11e6 |
comparison
equal
deleted
inserted
replaced
| 127:8a915f85b96c | 128:799ec6dce9c3 |
|---|---|
| 36 itemID = 124124, | 36 itemID = 124124, |
| 37 }, | 37 }, |
| 38 ["Legionfall War Supplies"] = { | 38 ["Legionfall War Supplies"] = { |
| 39 currencyID = 1342, | 39 currencyID = 1342, |
| 40 zones = { | 40 zones = { |
| 41 ["The Broken Shore"] = true | 41 ["Broken Shore"] = true |
| 42 } | 42 } |
| 43 }, | 43 }, |
| 44 ["Nethershard"] = { | 44 ["Nethershard"] = { |
| 45 currencyID = 1226, | 45 currencyID = 1226, |
| 46 zones = { | 46 zones = { |
| 47 ["The Broken Shore"] = true | 47 ["Broken Shore"] = true |
| 48 } | 48 } |
| 49 }, | 49 }, |
| 50 ["Veiled Argunite"] = { | 50 ["Veiled Argunite"] = { |
| 51 currencyID = 1508, | 51 currencyID = 1508, |
| 52 zones = { | 52 zones = { |
| 79 frame:RegisterEvent(event) | 79 frame:RegisterEvent(event) |
| 80 end | 80 end |
| 81 end | 81 end |
| 82 | 82 |
| 83 function module:Setup() | 83 function module:Setup() |
| 84 self:Update() | 84 self:Reanchor() |
| 85 end | 85 end |
| 86 | 86 |
| 87 function module:OnLoad () | 87 function module:OnLoad () |
| 88 Veneer:AddHandler(self) | 88 Veneer:AddHandler(self) |
| 89 | 89 |
| 106 items[itemID] = { | 106 items[itemID] = { |
| 107 count = 0, | 107 count = 0, |
| 108 frame = block | 108 frame = block |
| 109 } | 109 } |
| 110 block.Update = itemBlock.Update | 110 block.Update = itemBlock.Update |
| 111 RegisterEvents(self, itemEvents) | 111 RegisterEvents(block, itemEvents) |
| 112 elseif info.currencyID then | 112 elseif info.currencyID then |
| 113 local currencyID = info.currencyID | 113 local currencyID = info.currencyID |
| 114 block.Update = currencyBlock.Update | 114 block.Update = currencyBlock.Update |
| 115 RegisterEvents(block, currencyEvents) | 115 RegisterEvents(self, currencyEvents) |
| 116 end | 116 end |
| 117 | 117 |
| 118 | 118 |
| 119 | 119 |
| 120 if info.zones then | 120 if info.zones then |
| 121 RegisterEvents(block, zoneEvents) | 121 RegisterEvents(self, zoneEvents) |
| 122 local zones = info.zones | 122 local zones = info.zones |
| 123 local of = block.Update | 123 local of = block.Update |
| 124 function block:Update(zone, subZone) | 124 function block:Update() |
| 125 | 125 |
| 126 local zone = GetRealZoneText() | 126 local zone = GetRealZoneText() |
| 127 local subZone = GetSubZoneText() | 127 local subZone = GetSubZoneText() |
| 128 block.debug('Zone Check', zone, subZone) | |
| 129 local canShow = ((zone and self.zones[zone]) or (subZone and self.zones[subZone])) and true or false | 128 local canShow = ((zone and self.zones[zone]) or (subZone and self.zones[subZone])) and true or false |
| 129 block.debug('Zone Check', zone, subZone, canShow) | |
| 130 if of then | 130 if of then |
| 131 canShow = canShow and of(self) | 131 canShow = canShow and of(self) |
| 132 end | 132 end |
| 133 return canShow | 133 return canShow |
| 134 end | 134 end |
| 136 end | 136 end |
| 137 end | 137 end |
| 138 | 138 |
| 139 function module:OnEvent (event, arg) | 139 function module:OnEvent (event, arg) |
| 140 print(self:GetName(), 'OnEvent', event, arg) | 140 print(self:GetName(), 'OnEvent', event, arg) |
| 141 end | 141 self:Update() |
| 142 | 142 end |
| 143 function module:Update(isBatchUpdate) | 143 |
| 144 print(self:GetName(), 'Update()') | 144 function module:Update() |
| 145 print(self:GetName(), 'Reanchor()') | |
| 145 if InCombatLockdown() then | 146 if InCombatLockdown() then |
| 146 self:SetShown(false) | 147 self:SetShown(false) |
| 147 return | 148 return |
| 148 end | 149 end |
| 149 | 150 |
| 152 items[itemID].count = 0 | 153 items[itemID].count = 0 |
| 153 end | 154 end |
| 154 | 155 |
| 155 local canShow = false | 156 local canShow = false |
| 156 | 157 |
| 157 for i = 0, NUM_BAG_SLOTS do | 158 if BagBrother then |
| 158 local numSlots = GetContainerNumSlots(i) | 159 for i, bag in pairs(BagBrother.Player) do |
| 159 for j = 1, numSlots do | 160 if type(bag) == 'table' then |
| 160 local itemID = GetContainerItemID(i, j) | 161 --print(i) |
| 161 local texture, count = GetContainerItemInfo(i,j) | 162 for j, item in pairs(bag) do |
| 162 if items[itemID] then | 163 local itemID, count = string.match(item ,"^(%d+):.+;(%d*)") |
| 163 items[itemID].count = items[itemID].count + (count or 1) | 164 itemID = tonumber(itemID) |
| 164 if not items[itemID].texture then | 165 if itemID then |
| 165 items[itemID].texture = texture | 166 --print(j, itemID) |
| 166 print('tracked currency tally', items[itemID].count, '|T'..texture..':16:16|t') | 167 count = tonumber(count) |
| 167 items[itemID].frame.Icon:SetTexture(texture) | 168 if count and count >= 1 then |
| 169 local texture = GetItemIcon(itemID) | |
| 170 --print(itemID) | |
| 171 | |
| 172 if items[itemID] then | |
| 173 items[itemID].count = items[itemID].count + (count or 1) | |
| 174 if not items[itemID].texture then | |
| 175 items[itemID].texture = texture | |
| 176 --print('tracked currency tally', items[itemID].count, '|T'..texture..':16:16|t') | |
| 177 items[itemID].frame.Icon:SetTexture(texture) | |
| 178 end | |
| 179 end | |
| 180 end | |
| 181 end | |
| 182 end | |
| 183 end | |
| 184 | |
| 185 end | |
| 186 else | |
| 187 for i = 0, NUM_BAG_SLOTS do | |
| 188 local numSlots = GetContainerNumSlots(i) | |
| 189 for j = 1, numSlots do | |
| 190 local itemID = GetContainerItemID(i, j) | |
| 191 local texture, count = GetContainerItemInfo(i,j) | |
| 192 if items[itemID] then | |
| 193 items[itemID].count = items[itemID].count + (count or 1) | |
| 194 if not items[itemID].texture then | |
| 195 items[itemID].texture = texture | |
| 196 print('tracked currency tally', items[itemID].count, '|T'..texture..':16:16|t') | |
| 197 items[itemID].frame.Icon:SetTexture(texture) | |
| 198 end | |
| 168 end | 199 end |
| 169 end | 200 end |
| 170 end | 201 end |
| 171 end | 202 end |
| 172 | 203 |
| 173 | 204 |
| 174 | 205 |
| 175 local lastBlock | 206 local lastBlock |
| 176 local totalWidth = 0 | 207 local totalWidth = 0 |
| 177 for _, block in ipairs(self.Blocks) do | 208 for _, block in ipairs(self.Blocks) do |
| 178 local blockIsShown = block:Update(self.realZoneText, self.subZoneText) or false | 209 local blockIsShown = block:Update() |
| 210 print(block.name, blockIsShown) | |
| 179 block:SetShown(blockIsShown) | 211 block:SetShown(blockIsShown) |
| 180 canShow = canShow or blockIsShown | 212 canShow = canShow or blockIsShown |
| 181 | 213 |
| 182 | 214 |
| 183 if blockIsShown then | 215 if blockIsShown then |
