Mercurial > wow > buffalo2
comparison Modules/Currency.lua @ 126:3de635cda288 v7.3.17102017
- zone checking fix; moveed code into the zone-context pre-hook
| author | Nenue |
|---|---|
| date | Tue, 17 Oct 2017 17:00:10 -0400 |
| parents | 3f4794dca91b |
| children | 799ec6dce9c3 |
comparison
equal
deleted
inserted
replaced
| 125:3f4794dca91b | 126:3de635cda288 |
|---|---|
| 120 if info.zones then | 120 if info.zones then |
| 121 RegisterEvents(block, zoneEvents) | 121 RegisterEvents(block, 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(zone, subZone) |
| 125 block.debug('Update [Zone]', zone, subZone) | 125 |
| 126 local zone = GetRealZoneText() | |
| 127 local subZone = GetSubZoneText() | |
| 128 block.debug('Zone Check', zone, subZone) | |
| 126 local canShow = ((zone and self.zones[zone]) or (subZone and self.zones[subZone])) and true or false | 129 local canShow = ((zone and self.zones[zone]) or (subZone and self.zones[subZone])) and true or false |
| 127 if of then | 130 if of then |
| 128 canShow = canShow and of(self) | 131 canShow = canShow and of(self) |
| 129 end | 132 end |
| 130 return canShow | 133 return canShow |
| 133 end | 136 end |
| 134 end | 137 end |
| 135 | 138 |
| 136 function module:OnEvent (event, arg) | 139 function module:OnEvent (event, arg) |
| 137 print(self:GetName(), 'OnEvent', event, arg) | 140 print(self:GetName(), 'OnEvent', event, arg) |
| 138 self:Update() | 141 end |
| 139 end | 142 |
| 140 local toUpdate = {} | |
| 141 local wipe = table.wipe | |
| 142 function module:Update(isBatchUpdate) | 143 function module:Update(isBatchUpdate) |
| 143 print(self:GetName(), 'Update()') | 144 print(self:GetName(), 'Update()') |
| 144 if InCombatLockdown() then | 145 if InCombatLockdown() then |
| 145 self:SetShown(false) | 146 self:SetShown(false) |
| 146 return | 147 return |
| 148 | 149 |
| 149 | 150 |
| 150 for itemID in pairs(items) do | 151 for itemID in pairs(items) do |
| 151 items[itemID].count = 0 | 152 items[itemID].count = 0 |
| 152 end | 153 end |
| 153 self.realZoneText = GetRealZoneText() | 154 |
| 154 self.subZoneText = GetSubZoneText() | |
| 155 local canShow = false | 155 local canShow = false |
| 156 | 156 |
| 157 for i = 0, NUM_BAG_SLOTS do | 157 for i = 0, NUM_BAG_SLOTS do |
| 158 local numSlots = GetContainerNumSlots(i) | 158 local numSlots = GetContainerNumSlots(i) |
| 159 for j = 1, numSlots do | 159 for j = 1, numSlots do |
| 191 | 191 |
| 192 block:SetHeight(24) | 192 block:SetHeight(24) |
| 193 block:SetWidth(block.Icon:GetWidth() + block.Label:GetStringWidth()+4) | 193 block:SetWidth(block.Icon:GetWidth() + block.Label:GetStringWidth()+4) |
| 194 totalWidth = totalWidth + block:GetWidth() | 194 totalWidth = totalWidth + block:GetWidth() |
| 195 end | 195 end |
| 196 print(block:IsShown(), '|cFF0088FF'..block.name..'|r', block:GetSize()) | 196 print('|cFF0088FF'..block.name..'|r', block:IsShown(), block:GetSize()) |
| 197 end | 197 end |
| 198 | 198 |
| 199 self:UpdateProfile() | 199 self:UpdateProfile() |
| 200 self:SetWidth(totalWidth) | 200 self:SetWidth(totalWidth) |
| 201 | 201 |
| 242 GameTooltip_Hide() | 242 GameTooltip_Hide() |
| 243 end | 243 end |
| 244 end | 244 end |
| 245 | 245 |
| 246 function block:OnEvent(event, ...) | 246 function block:OnEvent(event, ...) |
| 247 print('|cFF0088FF<'..self.name..'>|r', 'OnEvent', event, ...) | 247 self.debug('OnEvent', event, ...) |
| 248 | 248 self:Update() |
| 249 self:Update(GetRealZoneText(), GetSubZoneText()) | |
| 250 end | 249 end |
| 251 | 250 |
| 252 function block:Setup() | 251 function block:Setup() |
| 253 | 252 end |
| 254 end | 253 |
| 255 function itemBlock:Update(zone, subZone) | 254 function itemBlock:Update() |
| 256 self.debug('Update [Item]', zone, subZone) | |
| 257 if items[self.itemID].count >= 1 then | 255 if items[self.itemID].count >= 1 then |
| 258 self.Icon:SetTexture(GetItemIcon(self.id)) | 256 self.Icon:SetTexture(GetItemIcon(self.id)) |
| 259 self.Label:SetFormattedText("%d", items[self.id].count) | 257 self.Label:SetFormattedText("%d", items[self.id].count) |
| 260 return true | 258 return true |
| 261 end | 259 end |
| 262 return false | 260 return false |
| 263 end | 261 end |
| 264 | 262 |
| 265 function currencyBlock:Update(zone, subZone) | 263 function currencyBlock:Update() |
| 266 self.debug('Update [Currency]', zone, subZone) | |
| 267 local name, earned, texture, earnedThisWeek, weeklyMax, totalMax = GetCurrencyInfo(self.id) | 264 local name, earned, texture, earnedThisWeek, weeklyMax, totalMax = GetCurrencyInfo(self.id) |
| 268 | 265 |
| 269 self.Icon:SetTexture(texture) | 266 self.Icon:SetTexture(texture) |
| 270 if self.showMax then | 267 if self.showMax then |
| 271 self.Label:SetFormattedText("%d / %d", earned, totalMax) | 268 self.Label:SetFormattedText("%d / %d", earned, totalMax) |
| 272 else | 269 else |
| 273 self.Label:SetFormattedText("%d", earned) | 270 self.Label:SetFormattedText("%d", earned) |
| 274 end | 271 end |
| 275 | |
| 276 --self:SetWidth(self.Icon:GetWidth() + self.Label:GetStringWidth() + 6) | |
| 277 return true | 272 return true |
| 278 end | 273 end |
