Mercurial > wow > buffalo2
comparison Modules/Currency.lua @ 133:86621c60512b v7.3.2-20171222
- Fixed AP calc tooltip appearing while hidden
- Fixed PaperDoll relic tooltips missing nether crucible info
| author | Nenue |
|---|---|
| date | Fri, 22 Dec 2017 20:36:40 -0500 |
| parents | 15a7f27b11e6 |
| children | 414e37af1b1b |
comparison
equal
deleted
inserted
replaced
| 132:4cb1d2a0c110 | 133:86621c60512b |
|---|---|
| 12 | 12 |
| 13 local itemBlock = {} | 13 local itemBlock = {} |
| 14 local currencyBlock = {} | 14 local currencyBlock = {} |
| 15 | 15 |
| 16 | 16 |
| 17 local zoneEvents = { | 17 local events = { |
| 18 "ZONE_CHANGED_NEW_AREA", "ZONE_CHANGED_INDOORS", "ZONE_CHANGED" | 18 'CHAT_MSG_LOOT', |
| 19 } | 19 "ZONE_CHANGED_NEW_AREA", "ZONE_CHANGED_INDOORS", "ZONE_CHANGED", |
| 20 local currencyEvents = { | 20 'BAG_UPDATE', 'CURRENCY_DISPLAY_UPDATE', 'CHAT_MSG_CURRENCY', |
| 21 'CURRENCY_DISPLAY_UPDATE', 'CHAT_MSG_CURRENCY' | |
| 22 } | |
| 23 local itemEvents = { | |
| 24 'CHAT_MSG_LOOT', 'BAG_UPDATE' | |
| 25 } | 21 } |
| 26 | 22 |
| 27 local blocks = { | 23 local blocks = { |
| 28 ["Ancient Mana"] = { | 24 ["Ancient Mana"] = { |
| 29 currencyID = 1155, | 25 currencyID = 1155, |
| 85 end | 81 end |
| 86 | 82 |
| 87 function module:OnLoad () | 83 function module:OnLoad () |
| 88 Veneer:AddHandler(self) | 84 Veneer:AddHandler(self) |
| 89 | 85 |
| 86 for _, event in ipairs(events) do | |
| 87 self:RegisterEvent(event) | |
| 88 end | |
| 89 | |
| 90 | |
| 90 for name, info in pairs(blocks) do | 91 for name, info in pairs(blocks) do |
| 91 local block = CreateFrame('Frame', nil, self, 'VeneerCurrencyTemplate') | 92 local block = CreateFrame('Frame', nil, self, 'VeneerCurrencyTemplate') |
| 92 block.name = name | 93 block.name = name |
| 93 for k,v in pairs(info) do | 94 for k,v in pairs(info) do |
| 94 print(name, k, '=', v) | 95 print(name, k, '=', v) |
| 98 block.debug = function(...) | 99 block.debug = function(...) |
| 99 print('|cFF0088FF<'..block.name..'>|r', ...) | 100 print('|cFF0088FF<'..block.name..'>|r', ...) |
| 100 end | 101 end |
| 101 block.id = info.itemID or info.currencyID | 102 block.id = info.itemID or info.currencyID |
| 102 | 103 |
| 104 block:SetScript('OnEnter', itemBlock.OnEnter or block.OnEnter) | |
| 105 block:SetScript('OnLeave', itemBlock.OnLeave or block.OnLeave) | |
| 103 | 106 |
| 104 if info.itemID then | 107 if info.itemID then |
| 105 local itemID = info.itemID | 108 local itemID = info.itemID |
| 106 items[itemID] = { | 109 items[itemID] = { |
| 107 count = 0, | 110 count = 0, |
| 108 frame = block | 111 frame = block |
| 109 } | 112 } |
| 110 block.Update = itemBlock.Update | 113 block.Update = itemBlock.Update |
| 111 RegisterEvents(block, itemEvents) | |
| 112 elseif info.currencyID then | 114 elseif info.currencyID then |
| 113 local currencyID = info.currencyID | 115 local currencyID = info.currencyID |
| 114 block.Update = currencyBlock.Update | 116 block.Update = currencyBlock.Update |
| 115 RegisterEvents(self, currencyEvents) | |
| 116 end | 117 end |
| 117 | 118 |
| 118 | 119 |
| 119 | 120 |
| 120 if info.zones then | 121 if info.zones then |
| 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() | 124 function block:Update() |
| 125 | 125 |
| 126 local zone = GetRealZoneText() | 126 local zone = GetRealZoneText() |
| 155 for itemID in pairs(items) do | 155 for itemID in pairs(items) do |
| 156 items[itemID].count = 0 | 156 items[itemID].count = 0 |
| 157 end | 157 end |
| 158 | 158 |
| 159 local canShow = false | 159 local canShow = false |
| 160 | |
| 161 if BagBrother then | 160 if BagBrother then |
| 162 for i, bag in pairs(BagBrother.Player) do | 161 for i, bag in pairs(BagBrother.Player) do |
| 163 if type(bag) == 'table' then | 162 if type(bag) == 'table' then |
| 164 --print(i) | 163 --print(i) |
| 165 for j, item in pairs(bag) do | 164 for j, item in pairs(bag) do |
| 191 local numSlots = GetContainerNumSlots(i) | 190 local numSlots = GetContainerNumSlots(i) |
| 192 for j = 1, numSlots do | 191 for j = 1, numSlots do |
| 193 local itemID = GetContainerItemID(i, j) | 192 local itemID = GetContainerItemID(i, j) |
| 194 local texture, count = GetContainerItemInfo(i,j) | 193 local texture, count = GetContainerItemInfo(i,j) |
| 195 if items[itemID] then | 194 if items[itemID] then |
| 195 | |
| 196 items[itemID].count = items[itemID].count + (count or 1) | 196 items[itemID].count = items[itemID].count + (count or 1) |
| 197 if not items[itemID].texture then | 197 if not items[itemID].texture then |
| 198 items[itemID].texture = texture | 198 items[itemID].texture = texture |
| 199 print('tracked currency tally', items[itemID].count, '|T'..texture..':16:16|t') | 199 print('tracked currency tally', items[itemID].count, '|T'..texture..':16:16|t') |
| 200 items[itemID].frame.Icon:SetTexture(texture) | 200 items[itemID].frame.Icon:SetTexture(texture) |
| 276 if GameTooltip:IsOwned(self) then | 276 if GameTooltip:IsOwned(self) then |
| 277 GameTooltip_Hide() | 277 GameTooltip_Hide() |
| 278 end | 278 end |
| 279 end | 279 end |
| 280 | 280 |
| 281 function block:OnEvent(event, ...) | |
| 282 self.debug('OnEvent', event, ...) | |
| 283 self:Update() | |
| 284 end | |
| 285 | |
| 286 function block:Setup() | |
| 287 end | |
| 288 | 281 |
| 289 function itemBlock:Update() | 282 function itemBlock:Update() |
| 290 if items[self.itemID].count >= 1 then | 283 if items[self.itemID].count >= 1 then |
| 291 self.Icon:SetTexture(GetItemIcon(self.id)) | 284 self.Icon:SetTexture(GetItemIcon(self.id)) |
| 292 self.Label:SetFormattedText("%d", items[self.id].count) | 285 self.Label:SetFormattedText("%d", items[self.id].count) |
