Mercurial > wow > buffalo2
comparison ObjectiveTracker/Widgets.lua @ 34:9856ebc63fa4
- half solution to Update being fired multiple times during load
- change securefunc handlers to dispense a reason code; catch that reason code in the enclosure passed to hooksecurefunc, and decide whether to update or not from there.
author | Nenue |
---|---|
date | Sun, 17 Apr 2016 00:21:45 -0400 |
parents | 64f2a9bbea79 |
children | 69d03f8e293e |
comparison
equal
deleted
inserted
replaced
33:64f2a9bbea79 | 34:9856ebc63fa4 |
---|---|
100 end | 100 end |
101 | 101 |
102 local OnClick = {} | 102 local OnClick = {} |
103 OnClick.CloseButton = function(self) | 103 OnClick.CloseButton = function(self) |
104 T:SetEnabled() | 104 T:SetEnabled() |
105 if T.Conf.enabled then | |
106 T:Update() | |
107 end | |
108 | |
105 UpdatePanelButton(self, T.Conf.enabled) | 109 UpdatePanelButton(self, T.Conf.enabled) |
106 end | 110 end |
107 | 111 |
108 OnClick.QuestMapButton = function() | 112 OnClick.QuestMapButton = function() |
109 ToggleWorldMap() | 113 ToggleWorldMap() |
175 | 179 |
176 itemButton:SetAttribute("type", "item") | 180 itemButton:SetAttribute("type", "item") |
177 itemButton:SetAttribute("item", itemInfo.link) | 181 itemButton:SetAttribute("item", itemInfo.link) |
178 | 182 |
179 itemButton.questID = info.questID | 183 itemButton.questID = info.questID |
180 itemButton.questLogIndex = info.questLogIndex | 184 itemButton.logIndex = info.logIndex |
181 itemButton.charges = itemInfo.charges | 185 itemButton.charges = itemInfo.charges |
182 itemButton.rangeTimer = -1 | 186 itemButton.rangeTimer = -1 |
183 itemButton.block = block | 187 itemButton.block = block |
184 | 188 |
185 SetItemButtonTexture(itemButton, itemInfo.icon) | 189 SetItemButtonTexture(itemButton, itemInfo.icon) |
212 -- Handle range indicator | 216 -- Handle range indicator |
213 local rangeTimer = self.rangeTimer | 217 local rangeTimer = self.rangeTimer |
214 if (rangeTimer) then | 218 if (rangeTimer) then |
215 rangeTimer = rangeTimer - elapsed | 219 rangeTimer = rangeTimer - elapsed |
216 if (rangeTimer <= 0) then | 220 if (rangeTimer <= 0) then |
217 local link, item, charges, showItemWhenComplete = GetQuestLogSpecialItemInfo(self.questLogIndex) | 221 local link, item, charges, showItemWhenComplete = GetQuestLogSpecialItemInfo(self.logIndex) |
218 if ((not charges) or (charges ~= self.charges)) then | 222 if ((not charges) or (charges ~= self.charges)) then |
219 T:Update() | 223 T:Update() |
220 return | 224 return |
221 end | 225 end |
222 | 226 |
223 local count = self.HotKey | 227 local count = self.HotKey |
224 local valid = IsQuestLogSpecialItemInRange(self.questLogIndex) | 228 local valid = IsQuestLogSpecialItemInRange(self.logIndex) |
225 if (valid == 0) then | 229 if (valid == 0) then |
226 count:Show() | 230 count:Show() |
227 count:SetVertexColor(1.0, 0.1, 0.1) | 231 count:SetVertexColor(1.0, 0.1, 0.1) |
228 elseif (valid == 1) then | 232 elseif (valid == 1) then |
229 count:Show() | 233 count:Show() |
237 self.rangeTimer = rangeTimer | 241 self.rangeTimer = rangeTimer |
238 end | 242 end |
239 end | 243 end |
240 | 244 |
241 function Veneer_QuestObjectiveItem_UpdateCooldown (itemButton) | 245 function Veneer_QuestObjectiveItem_UpdateCooldown (itemButton) |
242 local start, duration, enable = GetQuestLogSpecialItemCooldown(itemButton.questLogIndex) | 246 local start, duration, enable = GetQuestLogSpecialItemCooldown(itemButton.logIndex) |
243 if (start) then | 247 if (start) then |
244 CooldownFrame_SetTimer(itemButton.Cooldown, start, duration, enable) | 248 CooldownFrame_SetTimer(itemButton.Cooldown, start, duration, enable) |
245 if (duration > 0 and enable == 0) then | 249 if (duration > 0 and enable == 0) then |
246 SetItemButtonTextureVertexColor(itemButton, 0.4, 0.4, 0.4) | 250 SetItemButtonTextureVertexColor(itemButton, 0.4, 0.4, 0.4) |
247 else | 251 else |
318 textIndent = T.Conf.Wrapper.TextIndent | 322 textIndent = T.Conf.Wrapper.TextIndent |
319 end | 323 end |
320 | 324 |
321 frame:SetWidth(wrapperWidth - textIndent * 2) | 325 frame:SetWidth(wrapperWidth - textIndent * 2) |
322 frame:SetScript('OnEvent', T.UpdateWidget[frame.widgetType]) | 326 frame:SetScript('OnEvent', T.UpdateWidget[frame.widgetType]) |
327 frame:RegisterEvent('QUEST_LOG_UPDATE') | |
323 frame:RegisterEvent('TRACKED_ACHIEVEMENT_UPDATE') | 328 frame:RegisterEvent('TRACKED_ACHIEVEMENT_UPDATE') |
324 frame:RegisterEvent('TRACKED_ACHIEVEMENT_LIST_CHANGED') | 329 frame:RegisterEvent('TRACKED_ACHIEVEMENT_LIST_CHANGED') |
325 frame:RegisterEvent('CRITERIA_UPDATE') | 330 frame:RegisterEvent('CRITERIA_UPDATE') |
326 frame:RegisterEvent('CRITERIA_COMPLETE') | 331 frame:RegisterEvent('CRITERIA_COMPLETE') |
327 frame:RegisterEvent('CRITERIA_EARNED') | 332 frame:RegisterEvent('CRITERIA_EARNED') |
385 | 390 |
386 T.defaults.WidgetStyle = { | 391 T.defaults.WidgetStyle = { |
387 | 392 |
388 } | 393 } |
389 | 394 |
390 local progressHeight = 16 | 395 local progressHeight = 8 |
391 local progressBorder = 1 | 396 local progressBorder = 1 |
392 local progressIndent = 3 | |
393 local progressFont = _G.VeneerCriteriaFontNormal | 397 local progressFont = _G.VeneerCriteriaFontNormal |
394 | 398 |
395 | 399 local lprint = B.print('Line') |
396 T.InitializeWidget.ProgressBar = function(self) | 400 T.InitializeWidget.ProgressBar = function(self) |
401 local print = lprint | |
397 local c = T.Conf.Wrapper | 402 local c = T.Conf.Wrapper |
398 self.height = progressHeight + c.TextSpacing | 403 self.height = progressHeight + c.TextSpacing |
399 self.width = c.Width - c.TextSpacing | 404 self.width = c.Width - c.TextSpacing |
400 self.indent = progressIndent | 405 self.value = self.value or 1 |
401 self.value = 1 | 406 self.maxValue = self.maxValue or 1 |
402 self.maxValue = 1 | |
403 | 407 |
404 self:SetHeight(progressHeight) | 408 self:SetHeight(progressHeight) |
405 self.bg:SetHeight(progressHeight) | 409 self.bg:SetHeight(progressHeight) |
406 self.bg:SetWidth(self.width) | 410 self.bg:SetWidth(self.width) |
407 self.fg:ClearAllPoints() | 411 self.fg:ClearAllPoints() |
408 self.fg:SetPoint('BOTTOMLEFT', self, 'BOTTOMLEFT', progressBorder, progressBorder) | 412 self.fg:SetPoint('BOTTOMLEFT', self, 'BOTTOMLEFT', progressBorder, progressBorder) |
409 self.fg:SetHeight(progressHeight - progressBorder * 2) | 413 self.fg:SetHeight(progressHeight - progressBorder * 2) |
414 | |
410 self.status:SetFontObject(progressFont) | 415 self.status:SetFontObject(progressFont) |
411 self.status:SetText(self.objective.quantityString) | 416 self.status:SetText(self.objective.quantityString) |
412 end | 417 end |
413 | 418 |
414 T.UpdateWidget.ProgressBar = function (self) | 419 T.UpdateWidget.ProgressBar = function (self) |
415 local quantity, requiredQuantity = self.value, self.maxValue | 420 local quantity, requiredQuantity = self.value, self.maxValue |
416 print('update vals:') | 421 print('update vals:') |
417 for k,v in pairs(self.line) do | 422 for k,v in pairs(self.line) do |
418 print(k, v) | 423 print(k, v) |
419 end | |
420 | |
421 if self.line.format then | |
422 self.status:SetFormattedText(self.line.format, quantity, requiredQuantity) | |
423 end | 424 end |
424 | 425 |
425 local progress = (quantity / requiredQuantity) | 426 local progress = (quantity / requiredQuantity) |
426 if progress >= 1 then | 427 if progress >= 1 then |
427 self.fg:Show() | 428 self.fg:Show() |