Mercurial > wow > buffalo2
diff Modules/Currency.lua @ 115:8c94bee4fdfc
- AddHandler simplified
- Centralized combat start/stop hooks
- WorldState removed
author | Nenue |
---|---|
date | Tue, 28 Mar 2017 07:02:26 -0400 |
parents | 6748c98a6c6c |
children | ddfe19d70a34 |
line wrap: on
line diff
--- a/Modules/Currency.lua Mon Mar 27 00:39:29 2017 -0400 +++ b/Modules/Currency.lua Tue Mar 28 07:02:26 2017 -0400 @@ -7,6 +7,7 @@ -- local print = DEVIAN_WORKSPACE and function(...) print('VnWorldState', ...) end or nop +local profileUpdate, needsUpdate local zoneEvents = { "ZONE_CHANGED_NEW_AREA", "ZONE_CHANGED_INDOORS", "ZONE_CHANGED" @@ -31,13 +32,19 @@ itemID = 124124, } } -local items = {} +local items, currencies = {}, {} -VeneerWorldStateCurrencyMixin = { Blocks = {} } -VeneerWorldStateCurrencyBlockMixin = {} -local module = VeneerWorldStateCurrencyMixin -local block = VeneerWorldStateCurrencyBlockMixin +VeneerCurrencyMixin = { + Blocks = {}, + HideCombat = true, + EventList = {'PLAYER_ENTERING_WORLD'}, + moduleName = 'Currency Watch', + anchorPoint = 'TOP', +} +VeneerCurrencyBlockMixin = {} +local module = VeneerCurrencyMixin +local block = VeneerCurrencyBlockMixin @@ -49,9 +56,7 @@ end function module:OnLoad () - self:RegisterEvent("PLAYER_ENTERING_WORLD"); - self:RegisterEvent('PLAYER_REGEN_ENABLED') - self:RegisterEvent('PLAYER_REGEN_DISABLED') + Veneer:AddHandler(self) for name, info in pairs(blocks) do local frame = CreateFrame('Frame', nil, self, 'VeneerCurrencyTemplate') @@ -138,15 +143,16 @@ local texture, count = GetContainerItemInfo(i,j) if items[itemID] then items[itemID].count = items[itemID].count + (count or 1) - items[itemID].texture = texture - print('tracked currency tally', items[itemID].count, '|T'..texture..':16:16|t') - items[itemID].frame.Icon:SetTexture(texture) + if not items[itemID].texture then + items[itemID].texture = texture + print('tracked currency tally', items[itemID].count, '|T'..texture..':16:16|t') + items[itemID].frame.Icon:SetTexture(texture) + end end end end - for itemID, info in pairs(items) do - end + local lastBlock local totalWidth = 0 @@ -170,21 +176,36 @@ totalWidth = totalWidth + block:GetWidth() end print(block:IsShown(), '|cFF0088FF'..block.name..'|r', block:GetSize()) - end + self:UpdateProfile() self:SetWidth(totalWidth) - self.needsUpdate = nil + needsUpdate = nil print(self:IsShown(), '|cFF00FF88'..self:GetName()..'|r', self:GetSize()) self:SetShown(canShow) - VeneerWorldState:Reanchor(true) + Veneer:DynamicReanchor() +end + +function module:UpdateProfile() + if not self.profile then + profileUpdate = true + return + end + + for itemID, info in pairs(items) do + self.profile.Items = self.profile.Items or {} + self.profile.Items[itemID] = info + end end function module:OnUpdate() - if self.needsUpdate then + if needsUpdate then self:Update() + elseif profileUpdate then + self:UpdateProfile() end + end function block:OnEnter()