Mercurial > wow > worldplan
comparison QuestPOI.lua @ 64:876c3f0bfd0e
- script upvalues cleanup
- add quest active status to pin metadata
| author | Nick@Zahhak |
|---|---|
| date | Thu, 23 Mar 2017 05:26:51 -0400 |
| parents | 8e130c92698f |
| children | 02f1d3bce558 |
comparison
equal
deleted
inserted
replaced
| 63:8e130c92698f | 64:876c3f0bfd0e |
|---|---|
| 2 -- QuestPOI.lua | 2 -- QuestPOI.lua |
| 3 -- Created: 10/1/2016 7:21 PM | 3 -- Created: 10/1/2016 7:21 PM |
| 4 -- %file-revision% | 4 -- %file-revision% |
| 5 -- | 5 -- |
| 6 local _, db = ... | 6 local _, db = ... |
| 7 | 7 local TQ_GetQuestInfoByQuestID = C_TaskQuest.GetQuestInfoByQuestID |
| 8 local TQ_GetQuestInfoByQuestID = C_TaskQuest.GetQuestInfoByQuestID -- Return the name of a quest with a given ID | |
| 9 local TQ_GetQuestLocation = C_TaskQuest.GetQuestLocation | 8 local TQ_GetQuestLocation = C_TaskQuest.GetQuestLocation |
| 10 local TQ_GetQuestTimeLeftMinutes = C_TaskQuest.GetQuestTimeLeftMinutes | 9 local TQ_GetQuestTimeLeftMinutes = C_TaskQuest.GetQuestTimeLeftMinutes |
| 11 local TQ_IsActive = C_TaskQuest.IsActive | 10 local TQ_IsActive = C_TaskQuest.IsActive |
| 12 local TQ_RequestPreloadRewardData = C_TaskQuest.RequestPreloadRewardData | 11 local TQ_RequestPreloadRewardData = C_TaskQuest.RequestPreloadRewardData |
| 13 local QuestPOIGetIconInfo, WorldMapPOIFrame = QuestPOIGetIconInfo, WorldMapPOIFrame | 12 local QuestPOIGetIconInfo, WorldMapPOIFrame = QuestPOIGetIconInfo, WorldMapPOIFrame |
| 14 local WorldMap_DoesWorldQuestInfoPassFilters = WorldMap_DoesWorldQuestInfoPassFilters | 13 local WorldMap_DoesWorldQuestInfoPassFilters = WorldMap_DoesWorldQuestInfoPassFilters |
| 15 local QuestMapFrame_IsQuestWorldQuest = QuestMapFrame_IsQuestWorldQuest | 14 local QuestMapFrame_IsQuestWorldQuest = QuestMapFrame_IsQuestWorldQuest |
| 16 local GetAchievementNumCriteria, GetAchievementCriteriaInfo, GetAchievementInfo = GetAchievementNumCriteria, GetAchievementCriteriaInfo, GetAchievementInfo | 15 local GetAchievementNumCriteria, GetAchievementCriteriaInfo, GetAchievementInfo = GetAchievementNumCriteria, GetAchievementCriteriaInfo, GetAchievementInfo |
| 16 | |
| 17 local IsQuestFlaggedCompleted = IsQuestFlaggedCompleted | |
| 18 local GetFactionInfoByID, GetQuestObjectiveInfo = GetFactionInfoByID, GetQuestObjectiveInfo | |
| 19 local GetQuestTagInfo, GetProfessionInfo = GetQuestTagInfo, GetProfessionInfo | |
| 20 local GetNumQuestLogRewards, GetNumQuestLogRewardCurrencies, HaveQuestData = GetNumQuestLogRewards, GetNumQuestLogRewardCurrencies, HaveQuestData | |
| 21 local GetQuestLogRewardMoney, GetQuestLogRewardCurrencyInfo, GetMoneyString = GetQuestLogRewardMoney, GetQuestLogRewardCurrencyInfo, GetMoneyString | |
| 22 local SpellCanTargetQuest, GetCVarBool = SpellCanTargetQuest, GetCVarBool | |
| 23 local SetSuperTrackedQuestID = SetSuperTrackedQuestID | |
| 24 | |
| 17 local pairs, ipairs, tinsert, unpack, select = pairs, ipairs, tinsert, unpack, select | 25 local pairs, ipairs, tinsert, unpack, select = pairs, ipairs, tinsert, unpack, select |
| 18 local floor, mod, tostring, tonumber, GetSuperTrackedQuestID = floor, mod, tostring, tonumber, GetSuperTrackedQuestID | 26 local floor, mod, tostring, tonumber, GetSuperTrackedQuestID = floor, mod, tostring, tonumber, GetSuperTrackedQuestID |
| 19 local GameTooltip = GameTooltip | 27 local GameTooltip = GameTooltip |
| 20 local GetItemIcon = GetItemIcon | 28 local GetItemIcon = GetItemIcon |
| 21 | 29 |
| 186 end | 194 end |
| 187 end | 195 end |
| 188 | 196 |
| 189 end | 197 end |
| 190 | 198 |
| 191 local GetFactionInfoByID, GetQuestObjectiveInfo = GetFactionInfoByID, GetQuestObjectiveInfo | |
| 192 | 199 |
| 193 function QuestPOI:OnEnter() | 200 function QuestPOI:OnEnter() |
| 194 if self.filtered and (self.questID ~= GetSuperTrackedQuestID()) then | 201 if self.filtered and (self.questID ~= GetSuperTrackedQuestID()) then |
| 195 return | 202 return |
| 196 end | 203 end |
| 272 WorldMap_RestoreTooltip() | 279 WorldMap_RestoreTooltip() |
| 273 WorldMapTooltip:Hide(); | 280 WorldMapTooltip:Hide(); |
| 274 end | 281 end |
| 275 | 282 |
| 276 -- attempt to pull pin data | 283 -- attempt to pull pin data |
| 277 local GetQuestTagInfo, GetProfessionInfo = GetQuestTagInfo, GetProfessionInfo | |
| 278 function QuestPOI:GetData () | 284 function QuestPOI:GetData () |
| 279 dprint('|cFF00FF88'..self:GetID()..':GetData()|r') | 285 dprint('|cFF00FF88'..self:GetID()..':GetData()|r') |
| 280 local questID = self.questID | 286 local questID = self.questID |
| 281 if not questID then | 287 if not questID then |
| 282 dprint('|cFFFF4400bad pin|r', self:GetName()) | 288 dprint('|cFFFF4400bad pin|r', self:GetName()) |
| 339 self.isCriteria = WorldMapFrame.UIElementsFrame.BountyBoard:IsWorldQuestCriteriaForSelectedBounty(questID) | 345 self.isCriteria = WorldMapFrame.UIElementsFrame.BountyBoard:IsWorldQuestCriteriaForSelectedBounty(questID) |
| 340 | 346 |
| 341 return self.isStale, self.isPending | 347 return self.isStale, self.isPending |
| 342 end | 348 end |
| 343 | 349 |
| 344 local GetNumQuestLogRewards, GetNumQuestLogRewardCurrencies, HaveQuestData = GetNumQuestLogRewards, GetNumQuestLogRewardCurrencies, HaveQuestData | |
| 345 local GetQuestLogRewardMoney, GetQuestLogRewardCurrencyInfo, GetMoneyString = GetQuestLogRewardMoney, GetQuestLogRewardCurrencyInfo, GetMoneyString | |
| 346 function QuestPOI:SetRewardInfo() | 350 function QuestPOI:SetRewardInfo() |
| 347 local questID = self.questID | 351 local questID = self.questID |
| 348 if not HaveQuestData(questID) then | 352 if not HaveQuestData(questID) then |
| 349 self.isPending = true | 353 self.isPending = true |
| 350 else | 354 else |
| 466 end | 470 end |
| 467 | 471 |
| 468 self:ShowFrames() | 472 self:ShowFrames() |
| 469 end | 473 end |
| 470 | 474 |
| 471 | 475 -- Show/Hide the text overlays associated with the quest pin; they aren't hierarchically linked |
| 472 function QuestPOI:ShowFrames() | 476 function QuestPOI:ShowFrames() |
| 473 if not self:IsShown() then | 477 if not self:IsShown() then |
| 474 --self:SetShown(true) | |
| 475 print('|cFFFFFF00' ..self:GetName()..':ShowFrames()') | 478 print('|cFFFFFF00' ..self:GetName()..':ShowFrames()') |
| 476 qprint('|cFFFFFF00'..tostring(self:GetName())..':OnShow()|r update:', self.isStale, 'new:', self.isNew, 'animation:', self.isAnimating) | 479 -- do not SetShown() here |
| 477 else | 480 end |
| 478 | 481 |
| 479 --print(self:GetName()..':ShowFrames()') | |
| 480 end | |
| 481 self.count:SetShown(true) | 482 self.count:SetShown(true) |
| 482 self.Overlay:SetShown(true) | 483 self.Overlay:SetShown(true) |
| 483 self.count:SetShown(true) | 484 self.count:SetShown(true) |
| 484 self.timeLabel:SetShown(true) | 485 self.timeLabel:SetShown(true) |
| 485 end | 486 end |
| 509 self.itemName = '|cFF0088FF' .. RETRIEVING_DATA..'|r' | 510 self.itemName = '|cFF0088FF' .. RETRIEVING_DATA..'|r' |
| 510 | 511 |
| 511 self.Overlay:SetPoint('TOPLEFT', self, 'TOPLEFT', 0, 4) | 512 self.Overlay:SetPoint('TOPLEFT', self, 'TOPLEFT', 0, 4) |
| 512 self.Overlay:SetPoint('BOTTOMRIGHT', self, 'BOTTOMRIGHT', 0, -4) | 513 self.Overlay:SetPoint('BOTTOMRIGHT', self, 'BOTTOMRIGHT', 0, -4) |
| 513 end | 514 end |
| 515 | |
| 514 function QuestPOI:OnMouseDown(button) | 516 function QuestPOI:OnMouseDown(button) |
| 515 if button == 'RightButton' then | 517 if button == 'RightButton' then |
| 516 SetSuperTrackedQuestID(nil) | 518 SetSuperTrackedQuestID(nil) |
| 517 else | 519 else |
| 518 TaskPOI_OnClick(self, button) | 520 TaskPOI_OnClick(self, button) |
| 563 end | 565 end |
| 564 | 566 |
| 565 -- Called at static intervals and with Refresh | 567 -- Called at static intervals and with Refresh |
| 566 function QuestPOI:UpdateStatus() | 568 function QuestPOI:UpdateStatus() |
| 567 -- update time elements | 569 -- update time elements |
| 568 if TQ_IsActive(self.questID) then | 570 self.isActive = TQ_IsActive(self.questID) |
| 571 | |
| 572 if self.isActive then | |
| 569 local tl = self.alertLevel | 573 local tl = self.alertLevel |
| 570 local timeLeft = TQ_GetQuestTimeLeftMinutes(self.questID) | 574 local timeLeft = TQ_GetQuestTimeLeftMinutes(self.questID) |
| 571 if timeLeft > 0 then | 575 if timeLeft > 0 then |
| 572 | 576 |
| 573 local text, timeState = WorldPlan:GetTimeInfo(timeLeft, self.maxAlertLevel) | 577 local text, timeState = WorldPlan:GetTimeInfo(timeLeft, self.maxAlertLevel) |
| 591 self.alertLevel = tl | 595 self.alertLevel = tl |
| 592 self.timeLabel:SetShown(self.worldQuest and (self.maxAlertLevel >= 1)) | 596 self.timeLabel:SetShown(self.worldQuest and (self.maxAlertLevel >= 1)) |
| 593 else | 597 else |
| 594 if not self.completed then | 598 if not self.completed then |
| 595 self.completed = true | 599 self.completed = true |
| 596 WorldPlan:print('|cFFFFFF00'..tostring(self.title).. '|r is no longer active.') | |
| 597 self:HideFrames() | 600 self:HideFrames() |
| 598 end | 601 end |
| 599 end | 602 end |
| 600 end | 603 end |
| 601 | 604 |
| 700 [REWARD_ARTIFACT_POWER] = 'worldQuestFilterArtifactPower', | 703 [REWARD_ARTIFACT_POWER] = 'worldQuestFilterArtifactPower', |
| 701 [REWARD_CURRENCY] = 'worldQuestFilterOrderResources', | 704 [REWARD_CURRENCY] = 'worldQuestFilterOrderResources', |
| 702 [REWARD_REAGENT]= 'worldQuestFilterProfessionMaterials', | 705 [REWARD_REAGENT]= 'worldQuestFilterProfessionMaterials', |
| 703 [REWARD_GEAR] = 'worldQuestFilterEquipment', | 706 [REWARD_GEAR] = 'worldQuestFilterEquipment', |
| 704 } | 707 } |
| 708 | |
| 709 | |
| 705 | 710 |
| 706 function QuestPOI:CheckFilterRules () | 711 function QuestPOI:CheckFilterRules () |
| 707 local print = qprint | 712 local print = qprint |
| 708 local qType = self.worldQuestType | 713 local qType = self.worldQuestType |
| 709 local filtered | 714 local filtered |
