Mercurial > wow > worldplan
comparison QuestPOI.lua @ 95:b29b35cb8539
- Fixed quest completion checking and handling
- Changed animation method to hopefully stop weird flickering.
- Pins are now visible before full reward data is loaded
- Filter bar redesigned:
- aligned horizontally along the top of the map display
- filter buttons display a '+' when there are matches in both current and other zones, and '*' when there only matches in other zones
- button tooltips separate local and global quests
- button categories are highlighted and labeled when the cursor is over them
- Fixed invalid POI targets appearing when the spell targeting cursor is active
- ClassOrderPlan can be closed with the game menu button
| author | Nenue |
|---|---|
| date | Mon, 08 May 2017 22:38:52 -0400 |
| parents | 98b5e08b75ed |
| children | 8591401ec278 |
comparison
equal
deleted
inserted
replaced
| 94:dfd53f7c0fe5 | 95:b29b35cb8539 |
|---|---|
| 42 | 42 |
| 43 local pinBaseIndex = 1320 | 43 local pinBaseIndex = 1320 |
| 44 local overlayBaseIndex = 1380 | 44 local overlayBaseIndex = 1380 |
| 45 local previousHighlight | 45 local previousHighlight |
| 46 | 46 |
| 47 local FADE_TIMING_MULTIPLIER = 3 | |
| 47 local DATA_DEBUG = false | 48 local DATA_DEBUG = false |
| 48 local PIN_REFRESH_DELAY = 1 | 49 local PIN_REFRESH_DELAY = 1 |
| 49 local PIN_REQUEST_DELAY = .2 | 50 local PIN_REQUEST_DELAY = .2 |
| 50 local ICON_UNKNOWN = "Interface\\ICONS\\inv_misc_questionmark" | 51 local ICON_UNKNOWN = "Interface\\ICONS\\inv_misc_questionmark" |
| 51 local ICON_MONEY = "Interface\\Buttons\\UI-GroupLoot-Coin-Up" | 52 local ICON_MONEY = "Interface\\Buttons\\UI-GroupLoot-Coin-Up" |
| 91 scaleFactors = {0.25, 0.7, 1}, | 92 scaleFactors = {0.25, 0.7, 1}, |
| 92 iconWidth = 18, | 93 iconWidth = 18, |
| 93 borderWidth = 2, | 94 borderWidth = 2, |
| 94 highlightWidth = 2, | 95 highlightWidth = 2, |
| 95 TagSize = 8, | 96 TagSize = 8, |
| 96 maxAlertLevel = 0, | 97 maxAlertLevel = 3, |
| 97 numberFontObject = 'WorldPlanFont' | 98 numberFontObject = 'WorldPlanFont' |
| 98 } | 99 } |
| 99 local MINIMIZED_STYLE = { | 100 local MINIMIZED_STYLE = { |
| 100 hideNumber = true, | 101 hideNumber = true, |
| 101 hideIcon = true, | 102 hideIcon = true, |
| 168 pet = petName, | 169 pet = petName, |
| 169 petID = petID | 170 petID = petID |
| 170 }} | 171 }} |
| 171 end | 172 end |
| 172 | 173 |
| 174 | |
| 175 do | |
| 176 local timeStates = { | |
| 177 {maxSeconds = 60, | |
| 178 r=1, g=0.25, b =0, format = function (minutes) return '|cFFFF4400'.. minutes .. 'm' end, | |
| 179 }, | |
| 180 {maxSeconds = 240, | |
| 181 r=1, g=.5, b=0, format = function(minutes) return '|cFFFF4400'.. floor(minutes/60) .. 'h' end, | |
| 182 }, | |
| 183 {maxSeconds = 1440, | |
| 184 r=1, g=1, b=0, format = function(minutes) return '|cFFFFFF00'.. floor(minutes/60) .. 'h' end, | |
| 185 }, | |
| 186 {maxSeconds = 10081, | |
| 187 r=0, g=1, b=0, | |
| 188 }, -- 7 days + 1 minute | |
| 189 } | |
| 190 -- Generates a timeleft string | |
| 191 function QuestPOI:GetTimeInfo(timeLeft, limit) | |
| 192 for index = 1, limit do | |
| 193 local state = timeStates[index] | |
| 194 if timeLeft <= state.maxSeconds then | |
| 195 local text | |
| 196 if state.format then | |
| 197 text = state.format(timeLeft) | |
| 198 end | |
| 199 return text, index, state | |
| 200 end | |
| 201 end | |
| 202 return | |
| 203 end | |
| 204 end | |
| 205 | |
| 206 | |
| 173 local GetAchievementTooltipExtras = function(info) | 207 local GetAchievementTooltipExtras = function(info) |
| 174 | 208 |
| 175 local hasInfo | 209 local hasInfo |
| 176 local achievementID = info.achievementID | 210 local achievementID = info.achievementID |
| 177 local _, name, _, completed, _, _, _, _, _, icon = GetAchievementInfo(achievementID) | 211 local _, name, _, completed, _, _, _, _, _, icon = GetAchievementInfo(achievementID) |
| 271 function QuestPOI:OnShow () | 305 function QuestPOI:OnShow () |
| 272 if self.isStale then | 306 if self.isStale then |
| 273 --print('|cFF00FF00refresh on show') | 307 --print('|cFF00FF00refresh on show') |
| 274 self:Refresh('POI_ONSHOW_STALE') | 308 self:Refresh('POI_ONSHOW_STALE') |
| 275 end | 309 end |
| 310 | |
| 311 if self.questID and IsQuestComplete(self.questID) then | |
| 312 self:Release() | |
| 313 return | |
| 314 end | |
| 315 | |
| 276 self:RegisterEvent('QUEST_TURNED_IN') | 316 self:RegisterEvent('QUEST_TURNED_IN') |
| 277 self:RegisterEvent('QUEST_LOG_UPDATE') | 317 self:RegisterEvent('QUEST_LOG_UPDATE') |
| 278 self:HideOrShowFrames(true) | 318 self:HideOrShowFrames(true) |
| 279 end | 319 end |
| 280 | 320 |
| 391 | 431 |
| 392 local updateTime, markTime | 432 local updateTime, markTime |
| 393 function QuestPOI:OnUpdate (sinceLast) | 433 function QuestPOI:OnUpdate (sinceLast) |
| 394 -- control update check intervals | 434 -- control update check intervals |
| 395 | 435 |
| 396 if self.animating then | 436 if self.toAlpha then |
| 397 local alpha = self.icon:GetAlpha() + sinceLast*3 | 437 if not self.alphaStart then |
| 398 | 438 self.alphaStart = GetTime() |
| 399 self.animateTime = (self.animateTime or 0) + sinceLast | 439 end |
| 400 if alpha >= 1 then | 440 |
| 401 alpha = 1 | 441 |
| 402 print('fade over', self.animateTime) | 442 local alpha = self.icon:GetAlpha() |
| 403 self.animating = nil | 443 local alphaMod = ((GetTime()-self.alphaStart) *FADE_TIMING_MULTIPLIER) |
| 404 self.animateTime = nil | 444 if self:GetID() == 1 then |
| 405 | 445 print(alpha, self.toAlpha, sinceLast, alphaMod) |
| 446 end | |
| 447 if alpha > self.toAlpha then | |
| 448 alpha = alpha - (sinceLast*FADE_TIMING_MULTIPLIER) | |
| 449 | |
| 450 if (alpha <= self.toAlpha) then | |
| 451 alpha = self.toAlpha | |
| 452 self.toAlpha = nil | |
| 453 elseif (alpha <= 0) then | |
| 454 alpha = 0 | |
| 455 self.toAlpha = nil | |
| 456 end | |
| 457 elseif alpha < self.toAlpha then | |
| 458 alpha = alpha + alphaMod | |
| 459 | |
| 460 if (alpha >= self.toAlpha) then | |
| 461 alpha = self.toAlpha | |
| 462 self.toAlpha = nil | |
| 463 elseif (alpha >= 1) then | |
| 464 alpha = 1 | |
| 465 self.toAlpha = nil | |
| 466 end | |
| 467 | |
| 468 else | |
| 469 self.toAlpha = nil | |
| 470 end | |
| 471 | |
| 472 if not self.toAlpha then | |
| 473 self.alphaStart = nil | |
| 474 else | |
| 475 self.alphaStart = GetTime() | |
| 406 end | 476 end |
| 407 | 477 |
| 408 self.icon:SetAlpha(alpha) | 478 self.icon:SetAlpha(alpha) |
| 409 self.RewardBorder:SetAlpha(alpha) | 479 self.RewardBorder:SetAlpha(alpha) |
| 410 end | 480 end |
| 448 end | 518 end |
| 449 end | 519 end |
| 450 | 520 |
| 451 | 521 |
| 452 function QuestPOI:StartFading() | 522 function QuestPOI:StartFading() |
| 453 if not self.animating then | 523 if not self.toAlpha then |
| 454 self.animating = true | 524 print('setting toAlpha') |
| 525 self.toAlpha = 1 | |
| 455 self.icon:SetAlpha(0) | 526 self.icon:SetAlpha(0) |
| 456 self.RewardBorder:SetAlpha(0) | 527 self.RewardBorder:SetAlpha(0) |
| 457 end | 528 end |
| 458 end | 529 end |
| 459 | 530 |
| 505 self.itemNumber = itemNumber | 576 self.itemNumber = itemNumber |
| 506 self.itemQuality = quality | 577 self.itemQuality = quality |
| 507 self.dataLoaded = true | 578 self.dataLoaded = true |
| 508 self.isStale = true | 579 self.isStale = true |
| 509 self.xpType, self.xpName, self.xpIcon, self.xpCount = xpType, xpName, xpIcon, xpCount | 580 self.xpType, self.xpName, self.xpIcon, self.xpCount = xpType, xpName, xpIcon, xpCount |
| 510 | 581 WorldPlan.dataFlush = true |
| 511 end | 582 end |
| 512 end | 583 end |
| 513 | 584 |
| 514 | 585 |
| 515 return self.dataLoaded | 586 return self.dataLoaded |
| 681 WorldPlanTooltip:SetOwner(self, 'ANCHOR_NONE') | 752 WorldPlanTooltip:SetOwner(self, 'ANCHOR_NONE') |
| 682 WorldPlanTooltip:SetHyperlink(rewardLink or self.rewardLink) | 753 WorldPlanTooltip:SetHyperlink(rewardLink or self.rewardLink) |
| 683 for i = 1, WorldPlanTooltip:NumLines() do | 754 for i = 1, WorldPlanTooltip:NumLines() do |
| 684 local line = _G['WorldPlanTooltipTextLeft' .. i] | 755 local line = _G['WorldPlanTooltipTextLeft' .. i] |
| 685 local text = line and line:GetText() | 756 local text = line and line:GetText() |
| 686 local ap = text and text:gsub(',', ''):gsub(' million', '000000'):match('([%d%.]+) '..ARTIFACT_POWER) | 757 local multiplier = (text:match('million') and 1000000) or 1 |
| 687 if ap then | 758 if text then |
| 688 rewardCount = tonumber(ap) | 759 text = text:gsub(',', '') |
| 760 local ap = text:match('([%d]+) '..ARTIFACT_POWER) | |
| 761 if not ap then | |
| 762 ap = text:match('([%d%.]+) million '..ARTIFACT_POWER) | |
| 763 if ap then | |
| 764 ap = tonumber(ap) * 1000000 | |
| 765 end | |
| 766 end | |
| 767 if ap then | |
| 768 rewardCount = tonumber(ap) | |
| 769 end | |
| 689 end | 770 end |
| 690 end | 771 end |
| 691 return rewardCount | 772 return rewardCount |
| 692 end | 773 end |
| 693 | 774 |
| 855 | 936 |
| 856 local tagIcon = self.tagIcon | 937 local tagIcon = self.tagIcon |
| 857 self.maxAlertLevel = style.maxAlertLevel or DEFAULT_STYLE.maxAlertLevel | 938 self.maxAlertLevel = style.maxAlertLevel or DEFAULT_STYLE.maxAlertLevel |
| 858 | 939 |
| 859 if self.dataLoaded then | 940 if self.dataLoaded then |
| 860 print('new pin, has data, cue fade') | |
| 861 if self.isNew then | 941 if self.isNew then |
| 942 print('new pin, has data, cue fade') | |
| 862 self:StartFading() | 943 self:StartFading() |
| 863 self.isNew = nil | 944 self.isNew = nil |
| 864 end | 945 end |
| 865 else | 946 else |
| 866 if not self.animating then | 947 if not self.toAlpha then |
| 867 print('new pin, but no data, hide icon') | 948 icon:SetAlpha(0) |
| 868 self.icon:SetAlpha(0) | 949 iconBorder:SetAlpha(0) |
| 869 self.RewardBorder:SetAlpha(0) | |
| 870 end | 950 end |
| 871 end | 951 end |
| 872 | 952 |
| 873 if self.itemName then | 953 if self.itemName then |
| 874 if self.itemNumber and (self.itemNumber > 1) and (not hideNumbers) then | 954 if self.itemNumber and (self.itemNumber > 1) and (not hideNumbers) then |
| 985 | 1065 |
| 986 -- Called at static intervals and with Refresh | 1066 -- Called at static intervals and with Refresh |
| 987 function QuestPOI:UpdateStatus() | 1067 function QuestPOI:UpdateStatus() |
| 988 -- update time elements | 1068 -- update time elements |
| 989 self.isActive = TQ_IsActive(self.questID) | 1069 self.isActive = TQ_IsActive(self.questID) |
| 1070 --print(self.maxAlertLevel) | |
| 1071 local border = (self.isBounty or self.isCriteria) and self.RewardBorder or self.HighlightBorder | |
| 990 | 1072 |
| 991 if self.isActive then | 1073 if self.isActive then |
| 992 local tl = self.alertLevel | 1074 local tl = self.alertLevel |
| 993 local timeLeft = TQ_GetQuestTimeLeftMinutes(self.questID) | 1075 local timeLeft = TQ_GetQuestTimeLeftMinutes(self.questID) |
| 994 if timeLeft > 0 then | 1076 if timeLeft > 0 then |
| 995 | 1077 |
| 996 local text, timeState = WorldPlan:GetTimeInfo(timeLeft, self.maxAlertLevel) | 1078 local text, timeState, style = self:GetTimeInfo(timeLeft, self.maxAlertLevel) |
| 997 if tl ~= timeState then | 1079 if tl ~= timeState then |
| 998 tl = timeState | 1080 tl = timeState |
| 999 self.timeLabel:SetText(text) | 1081 self.timeLabel:SetText(text) |
| 1000 end | 1082 end |
| 1001 end | 1083 if style then |
| 1002 | 1084 self.RewardBorder:SetVertexColor(style.r, style.g, style.b, style.a) |
| 1003 local border = (self.isBounty or self.isCriteria) and self.RewardBorder or self.HighlightBorder | 1085 end |
| 1004 | 1086 end |
| 1005 if tl and (timeLeft < 120) then | 1087 |
| 1006 border:SetVertexColor(1,0,0,0.7) | |
| 1007 else | |
| 1008 border:SetVertexColor(0,0,0,0.7) | |
| 1009 end | |
| 1010 self.alertLevel = tl | 1088 self.alertLevel = tl |
| 1011 self.timeLabel:SetShown(self.worldQuest and (self.maxAlertLevel >= 1)) | 1089 self.timeLabel:SetShown(self.worldQuest and (self.maxAlertLevel >= 1)) |
| 1012 else | 1090 else |
| 1013 self.hideReason = "No longer active." | 1091 self.hideReason = "No longer active." |
| 1014 self:HideOrShowFrames(false) | 1092 self:HideOrShowFrames(false) |
| 1020 function QuestPOI:HideOrShowFrames(isShown) | 1098 function QuestPOI:HideOrShowFrames(isShown) |
| 1021 if not isShown then | 1099 if not isShown then |
| 1022 -- print('|cFFFFFF00' ..self:GetName()..':HideOrShowFrames()') | 1100 -- print('|cFFFFFF00' ..self:GetName()..':HideOrShowFrames()') |
| 1023 -- do not SetShown() here | 1101 -- do not SetShown() here |
| 1024 if not self.hideReason then | 1102 if not self.hideReason then |
| 1025 self.hideReason = "HideOrShowFrames() called" | 1103 self.hideReason = "HideOrShowFrames() called without a reason." |
| 1026 end | 1104 end |
| 1027 end | 1105 end |
| 1028 self.Overlay:SetShown(isShown) | 1106 self.Overlay:SetShown(isShown) |
| 1029 self.count:SetShown(isShown) | 1107 self.count:SetShown(isShown) |
| 1030 self.timeLabel:SetShown(isShown) | 1108 self.timeLabel:SetShown(isShown) |
| 1031 end | 1109 end |
| 1032 | 1110 |
| 1033 function QuestPOI:Release() | 1111 function QuestPOI:Release() |
| 1034 | 1112 print('|cFFFF4400'..self:GetID()..':Release()', self.hideReason) |
| 1035 self.hideReason = 'Released by script.' | 1113 self.hideReason = 'Released by script.' |
| 1036 self:SetShown(false) | 1114 self:HideOrShowFrames(false) |
| 1037 if self.questID then | 1115 if self.questID then |
| 1038 db.QuestsByID[self.questID] = nil | 1116 db.QuestsByID[self.questID] = nil |
| 1039 for _, map in pairs(db.QuestsByZone) do | 1117 for _, map in pairs(db.QuestsByZone) do |
| 1040 map[self.questID] = nil | 1118 map[self.questID] = nil |
| 1041 end | 1119 end |
| 1056 self:UnregisterEvent('QUEST_TURNED_IN') | 1134 self:UnregisterEvent('QUEST_TURNED_IN') |
| 1057 self:UnregisterEvent('QUEST_LOG_UPDATE') | 1135 self:UnregisterEvent('QUEST_LOG_UPDATE') |
| 1058 | 1136 |
| 1059 for i, pin in ipairs(db.UsedPins) do | 1137 for i, pin in ipairs(db.UsedPins) do |
| 1060 if pin == self then | 1138 if pin == self then |
| 1139 print('|cFFFF4400cleared from UsedPins|r') | |
| 1061 tremove(db.UsedPins, i) | 1140 tremove(db.UsedPins, i) |
| 1062 break | 1141 break |
| 1063 end | 1142 end |
| 1064 | |
| 1065 end | 1143 end |
| 1066 | 1144 |
| 1067 tinsert(db.FreePins, self) | 1145 tinsert(db.FreePins, self) |
| 1068 WorldPlan.dataFlush = true | 1146 WorldPlan.dataFlush = true |
| 1069 end | 1147 WorldPlanSummary.isStale = true |
| 1148 | |
| 1149 return true | |
| 1150 end |
