Mercurial > wow > buffalo2
comparison Modules/Currency.lua @ 123:b3c0258b419d v7.3.0-1
ArtifactPower:
- XP progress bar fixes
Currency:
- More argus stuff
- Block dimensions are calculated more consistently
TalkingHead
- Aesthetic changes
- Default right-click behaviour restored (hides the text box)
author | Nenue |
---|---|
date | Tue, 05 Sep 2017 02:56:33 -0400 |
parents | ddfe19d70a34 |
children | 3f4794dca91b |
comparison
equal
deleted
inserted
replaced
122:ea2c616a3b4f | 123:b3c0258b419d |
---|---|
6 -- To change this template use File | Settings | File Templates. | 6 -- To change this template use File | Settings | File Templates. |
7 -- | 7 -- |
8 | 8 |
9 local print = DEVIAN_WORKSPACE and function(...) print('VnWorldState', ...) end or nop | 9 local print = DEVIAN_WORKSPACE and function(...) print('VnWorldState', ...) end or nop |
10 local profileUpdate, needsUpdate | 10 local profileUpdate, needsUpdate |
11 | |
12 | |
13 local itemBlock = {} | |
14 local currencyBlock = {} | |
15 | |
11 | 16 |
12 local zoneEvents = { | 17 local zoneEvents = { |
13 "ZONE_CHANGED_NEW_AREA", "ZONE_CHANGED_INDOORS", "ZONE_CHANGED" | 18 "ZONE_CHANGED_NEW_AREA", "ZONE_CHANGED_INDOORS", "ZONE_CHANGED" |
14 } | 19 } |
15 local currencyEvents = { | 20 local currencyEvents = { |
38 ["Legionfall War Supplies"] = { | 43 ["Legionfall War Supplies"] = { |
39 currencyID = 1342, | 44 currencyID = 1342, |
40 }, | 45 }, |
41 ["Nethershard"] = { | 46 ["Nethershard"] = { |
42 currencyID = 1226, | 47 currencyID = 1226, |
48 }, | |
49 ["Veiled Argunite"] = { | |
50 currencyID = 1508, | |
51 }, | |
52 ["Argus Waystone"] = { | |
53 currencyID = 1506, | |
43 } | 54 } |
44 } | 55 } |
45 local items, currencies = {}, {} | 56 local items, currencies = {}, {} |
46 | 57 |
47 | 58 |
75 for k,v in pairs(info) do | 86 for k,v in pairs(info) do |
76 print(name, k, '=', v) | 87 print(name, k, '=', v) |
77 frame[k] = v | 88 frame[k] = v |
78 end | 89 end |
79 | 90 |
80 local debug = function(...) | 91 frame.debug = function(...) |
81 print('|cFF0088FF<'..frame.name..'>|r', ...) | 92 print('|cFF0088FF<'..frame.name..'>|r', ...) |
82 end | 93 end |
94 frame.id = info.itemID or info.currencyID | |
95 | |
83 | 96 |
84 if info.itemID then | 97 if info.itemID then |
85 local itemID = info.itemID | 98 local itemID = info.itemID |
86 items[itemID] = { | 99 items[itemID] = { |
87 count = 0, | 100 count = 0, |
88 frame = frame | 101 frame = frame |
89 } | 102 } |
90 frame.Update = function(block) | 103 frame.Update = itemBlock.Update |
91 debug('Update [Item]') | |
92 if items[itemID].count >= 1 then | |
93 block.Icon:SetTexture(GetItemIcon(itemID)) | |
94 block.Label:SetFormattedText("%d", items[itemID].count) | |
95 return true | |
96 end | |
97 end | |
98 RegisterEvents(self, itemEvents) | 104 RegisterEvents(self, itemEvents) |
99 elseif info.currencyID then | 105 elseif info.currencyID then |
100 local currencyID = info.currencyID | 106 local currencyID = info.currencyID |
101 frame.Update = function (block) | 107 frame.Update = currencyBlock.Update |
102 debug('Update [Currency]') | |
103 local name, earned, texture, earnedThisWeek, weeklyMax, totalMax = GetCurrencyInfo(currencyID) | |
104 | |
105 block.Icon:SetTexture(texture) | |
106 if self.showMax then | |
107 block.Label:SetFormattedText("%d / %d", earned, totalMax) | |
108 else | |
109 block.Label:SetFormattedText("%d", earned) | |
110 end | |
111 | |
112 block:SetWidth(block.Icon:GetWidth() + block.Label:GetStringWidth() + 6) | |
113 return true | |
114 end | |
115 | |
116 RegisterEvents(frame, currencyEvents) | 108 RegisterEvents(frame, currencyEvents) |
117 end | 109 end |
110 | |
111 | |
112 | |
118 if info.zones then | 113 if info.zones then |
119 RegisterEvents(frame, zoneEvents) | 114 RegisterEvents(frame, zoneEvents) |
120 local zones = info.zones | 115 local zones = info.zones |
121 local of = frame.Update | 116 local of = frame.Update |
122 frame.Update = function(block) | 117 frame.Update = function(block) |
123 debug('Update [Zone]') | 118 frame.debug('Update [Zone]') |
124 local zone = self.zoneText | 119 local zone = self.zoneText |
125 local canShow = (zone and block.zones[zone]) and true or false | 120 local canShow = (zone and block.zones[zone]) and true or false |
126 if of then | 121 if of then |
127 canShow = canShow and of(frame) | 122 canShow = canShow and of(frame) |
128 end | 123 end |
186 block:SetPoint('TOPLEFT', self, 'TOPLEFT') | 181 block:SetPoint('TOPLEFT', self, 'TOPLEFT') |
187 end | 182 end |
188 lastBlock = block | 183 lastBlock = block |
189 | 184 |
190 block:SetHeight(24) | 185 block:SetHeight(24) |
191 block:SetWidth(block.Icon:GetWidth() + block.Label:GetWidth()+4) | 186 block:SetWidth(block.Icon:GetWidth() + block.Label:GetStringWidth()+4) |
192 totalWidth = totalWidth + block:GetWidth() | 187 totalWidth = totalWidth + block:GetWidth() |
193 end | 188 end |
194 print(block:IsShown(), '|cFF0088FF'..block.name..'|r', block:GetSize()) | 189 print(block:IsShown(), '|cFF0088FF'..block.name..'|r', block:GetSize()) |
195 end | 190 end |
196 | 191 |
247 end | 242 end |
248 | 243 |
249 function block:Setup() | 244 function block:Setup() |
250 | 245 |
251 end | 246 end |
247 function itemBlock:Update() | |
248 self.debug('Update [Item]') | |
249 if items[self.itemID].count >= 1 then | |
250 self.Icon:SetTexture(GetItemIcon(self.id)) | |
251 self.Label:SetFormattedText("%d", items[self.id].count) | |
252 return true | |
253 end | |
254 end | |
255 | |
256 function currencyBlock:Update() | |
257 self.debug('Update [Currency]') | |
258 local name, earned, texture, earnedThisWeek, weeklyMax, totalMax = GetCurrencyInfo(self.id) | |
259 | |
260 self.Icon:SetTexture(texture) | |
261 if self.showMax then | |
262 self.Label:SetFormattedText("%d / %d", earned, totalMax) | |
263 else | |
264 self.Label:SetFormattedText("%d", earned) | |
265 end | |
266 | |
267 --self:SetWidth(self.Icon:GetWidth() + self.Label:GetStringWidth() + 6) | |
268 return true | |
269 end |