annotate QuestPOI.lua @ 98:d594c5c4a4a3 v1.4.10

- Fixed quest markers for other maps becoming visible due to ambiguous interpretations of pin.used. - Removed some redundant filter checking calls on pins obtained through Acquire() - Attempted fix to a source of combat taint. - Attempt to fix quest markers not disappearing immediately after a completion spell is used.
author Nenue
date Mon, 15 May 2017 00:15:13 -0400
parents 8591401ec278
children fbd4ead2a19f
rev   line source
Nenue@7 1 -- WorldPlan
Nenue@7 2 -- QuestPOI.lua
Nenue@7 3 -- Created: 10/1/2016 7:21 PM
Nenue@7 4 -- %file-revision%
Nenue@65 5 -- Big TODOs:
Nenue@65 6 -- -- generate frames using `WorldMap_GetOrCreateTaskPOI' to remove tainting issues
Nenue@7 7 --
Nenue@40 8 local _, db = ...
Nick@64 9 local TQ_GetQuestInfoByQuestID = C_TaskQuest.GetQuestInfoByQuestID
Nenue@7 10 local TQ_GetQuestLocation = C_TaskQuest.GetQuestLocation
Nenue@7 11 local TQ_GetQuestTimeLeftMinutes = C_TaskQuest.GetQuestTimeLeftMinutes
Nenue@9 12 local TQ_IsActive = C_TaskQuest.IsActive
Nenue@29 13 local TQ_RequestPreloadRewardData = C_TaskQuest.RequestPreloadRewardData
Nenue@7 14 local QuestPOIGetIconInfo, WorldMapPOIFrame = QuestPOIGetIconInfo, WorldMapPOIFrame
Nenue@33 15 local WorldMap_DoesWorldQuestInfoPassFilters = WorldMap_DoesWorldQuestInfoPassFilters
Nenue@33 16 local QuestMapFrame_IsQuestWorldQuest = QuestMapFrame_IsQuestWorldQuest
Nenue@40 17 local GetAchievementNumCriteria, GetAchievementCriteriaInfo, GetAchievementInfo = GetAchievementNumCriteria, GetAchievementCriteriaInfo, GetAchievementInfo
Nick@64 18
Nick@64 19 local IsQuestFlaggedCompleted = IsQuestFlaggedCompleted
Nick@64 20 local GetFactionInfoByID, GetQuestObjectiveInfo = GetFactionInfoByID, GetQuestObjectiveInfo
Nick@64 21 local GetQuestTagInfo, GetProfessionInfo = GetQuestTagInfo, GetProfessionInfo
Nick@64 22 local GetNumQuestLogRewards, GetNumQuestLogRewardCurrencies, HaveQuestData = GetNumQuestLogRewards, GetNumQuestLogRewardCurrencies, HaveQuestData
Nick@64 23 local GetQuestLogRewardMoney, GetQuestLogRewardCurrencyInfo, GetMoneyString = GetQuestLogRewardMoney, GetQuestLogRewardCurrencyInfo, GetMoneyString
Nick@64 24 local SpellCanTargetQuest, GetCVarBool = SpellCanTargetQuest, GetCVarBool
Nick@64 25 local SetSuperTrackedQuestID = SetSuperTrackedQuestID
Nenue@65 26 local HaveQuestRewardData = HaveQuestRewardData
Nenue@96 27 local GetTime = GetTime
Nenue@65 28
Nick@64 29
Nenue@93 30 local pairs, ipairs, tinsert, tremove, unpack, select = pairs, ipairs, tinsert, tremove, unpack, select
Nenue@40 31 local floor, mod, tostring, tonumber, GetSuperTrackedQuestID = floor, mod, tostring, tonumber, GetSuperTrackedQuestID
Nenue@33 32 local GameTooltip = GameTooltip
Nenue@33 33 local GetItemIcon = GetItemIcon
Nenue@7 34
Nenue@67 35 local print = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or nop
Nenue@67 36 local qprint = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or nop
Nenue@67 37 local wprint = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or nop
Nenue@67 38 local wqprint = DEVIAN_WORKSPACE and function(...) _G.print('WorldQuests', ...) end or nop
Nenue@67 39 local iprint = DEVIAN_WORKSPACE and function(...) _G.print('ItemScan', ...) end or nop
Nenue@67 40 local rprint = DEVIAN_WORKSPACE and function(...) _G.print('WQRefresh', ...) end or nop
Nenue@67 41 local dprint = DEVIAN_WORKSPACE and function(...) _G.print('WQData', ...) end or nop
Nenue@7 42 local QuestPOI = WorldPlanPOIMixin
Nenue@7 43
Nenue@93 44 local pinBaseIndex = 1320
Nenue@93 45 local overlayBaseIndex = 1380
Nenue@56 46 local previousHighlight
Nenue@40 47
Nenue@95 48 local FADE_TIMING_MULTIPLIER = 3
Nenue@67 49 local DATA_DEBUG = false
Nenue@75 50 local PIN_REFRESH_DELAY = 1
Nenue@75 51 local PIN_REQUEST_DELAY = .2
Nenue@9 52 local ICON_UNKNOWN = "Interface\\ICONS\\inv_misc_questionmark"
Nenue@9 53 local ICON_MONEY = "Interface\\Buttons\\UI-GroupLoot-Coin-Up"
Nenue@9 54
Nenue@40 55 local WORLD_QUEST_BORDER = "Interface\\UNITPOWERBARALT\\Generic1Target_Circular_Frame"
Nenue@47 56 local PENDING_BORDER = "Interface\\BUTTONS\\YELLOWORANGE64"
Nenue@40 57 local PENDING_ICON = "Interface\\BUTTONS\\YELLOWORANGE64"
Nenue@9 58
Nenue@29 59 local REWARD_CASH = WORLD_QUEST_REWARD_TYPE_FLAG_GOLD
Nenue@29 60 local REWARD_ARTIFACT_POWER = WORLD_QUEST_REWARD_TYPE_FLAG_ARTIFACT_POWER
Nenue@29 61 local REWARD_GEAR = WORLD_QUEST_REWARD_TYPE_FLAG_EQUIPMENT
Nenue@29 62 local REWARD_CURRENCY = WORLD_QUEST_REWARD_TYPE_FLAG_ORDER_RESOURCES
Nenue@29 63 local REWARD_REAGENT = WORLD_QUEST_REWARD_TYPE_FLAG_MATERIALS
Nenue@69 64
Nenue@69 65 local REWARD_TYPE_NAMES = {
Nenue@69 66 [REWARD_CASH] = 'Money',
Nenue@69 67 [REWARD_ARTIFACT_POWER] = 'AP',
Nenue@69 68 [REWARD_GEAR] = 'Equipment',
Nenue@69 69 [REWARD_CURRENCY] = 'Currency',
Nenue@69 70 [REWARD_REAGENT] = 'Trade Goods'
Nenue@69 71 }
Nenue@29 72
Nenue@29 73 local LE_QUEST_TAG_TYPE_PVP = LE_QUEST_TAG_TYPE_PVP
Nenue@29 74 local LE_QUEST_TAG_TYPE_PET_BATTLE = LE_QUEST_TAG_TYPE_PET_BATTLE
Nenue@29 75 local LE_QUEST_TAG_TYPE_DUNGEON = LE_QUEST_TAG_TYPE_DUNGEON
Nenue@29 76 local LE_QUEST_TAG_TYPE_PROFESSION = LE_QUEST_TAG_TYPE_PROFESSION
Nenue@29 77 local LE_QUEST_TAG_TYPE_NORMAL = LE_QUEST_TAG_TYPE_NORMAL
Nenue@29 78
Nenue@29 79 local LE_QUEST_TAG_TYPE_PVP = LE_QUEST_TAG_TYPE_PVP
Nenue@29 80 local LE_QUEST_TAG_TYPE_PET_BATTLE = LE_QUEST_TAG_TYPE_PET_BATTLE
Nenue@29 81 local LE_QUEST_TAG_TYPE_DUNGEON = LE_QUEST_TAG_TYPE_DUNGEON
Nenue@29 82 local LE_QUEST_TAG_TYPE_PROFESSION = LE_QUEST_TAG_TYPE_PROFESSION
Nenue@29 83 local LE_QUEST_TAG_TYPE_NORMAL = LE_QUEST_TAG_TYPE_NORMAL
Nenue@29 84
Nenue@66 85 local DEFAULT_STYLE = {
Nenue@66 86 border = {1,1,1},
Nenue@69 87 textColor = {1,1,1,1},
Nenue@66 88 x = 0, y = 0,
Nenue@66 89 desaturated = true,
Nenue@66 90 iconMask = "Interface\\Minimap\\UI-Minimap-Background",
Nenue@66 91 borderMask = "Interface\\Minimap\\UI-Minimap-Background",
Nenue@66 92 rewardMark = "Interface\\Minimap\\UI-Minimap-Background",
Nenue@66 93 scaleFactors = {0.25, 0.7, 1},
Nenue@66 94 iconWidth = 18,
Nenue@66 95 borderWidth = 2,
Nenue@66 96 highlightWidth = 2,
Nenue@66 97 TagSize = 8,
Nenue@95 98 maxAlertLevel = 3,
Nenue@66 99 numberFontObject = 'WorldPlanFont'
Nenue@66 100 }
Nenue@66 101 local MINIMIZED_STYLE = {
Nenue@66 102 hideNumber = true,
Nenue@66 103 hideIcon = true,
Nenue@67 104 iconWidth = 3,
Nenue@66 105 }
Nenue@66 106 local REWARD_TYPE_STYLES = {
Nenue@66 107 [REWARD_CASH] = {
Nenue@66 108 hideNumber = true,
Nenue@66 109 },
Nenue@66 110 [REWARD_ARTIFACT_POWER] = {},
Nenue@66 111 [REWARD_GEAR] = {
Nenue@66 112 hideNumber = true,
Nenue@66 113 },
Nenue@69 114 [REWARD_CURRENCY] = {
Nenue@69 115 textColor = {1,1,0,.5}
Nenue@69 116 },
Nenue@66 117 [REWARD_REAGENT] = {
Nenue@66 118
Nenue@66 119 hideNumber = true,
Nenue@66 120 },
Nenue@66 121 }
Nenue@74 122 local BORDER_SELECTED_BOUNTY = {1, 1, 0, 1 }
Nenue@74 123 local BORDER_CRITERIA = {.25, .5, 1, 1}
Nenue@66 124
Nenue@65 125 local LE_ITEM_CLASS_WEAPON, LE_ITEM_CLASS_ARMOR, LE_ITEM_CLASS_GEM, LE_ITEM_GEM_ARTIFACTRELIC, LE_ITEM_CLASS_TRADEGOODS = LE_ITEM_CLASS_WEAPON, LE_ITEM_CLASS_ARMOR, LE_ITEM_CLASS_GEM, LE_ITEM_GEM_ARTIFACTRELIC, LE_ITEM_CLASS_TRADEGOODS
Nenue@65 126
Nenue@65 127
Nenue@40 128 local STYLE_TYPE_PENDING = 768
Nenue@40 129
Nenue@31 130
Nenue@29 131 -- Pin color/display variables
Nenue@40 132 db.TooltipExtras = db.TooltipExtras or {} -- idiot-proofing
Nenue@49 133 db.PinAlpha = 1
Nenue@29 134
Nenue@33 135 local familiars = {
Nenue@40 136 [42159] = 'Nightwatcher Merayl',
Nenue@40 137 [40277] = 'Tiffany Nelson',
Nenue@40 138 [40298] = 'Sir Galveston',
Nenue@40 139 [40282] = 'Grixis Tinypop',
Nenue@40 140 [40278] = 'Robert Craig',
Nenue@40 141 [48195] = 'Aulier',
Nenue@40 142 [41990] = 'Varenne',
Nenue@40 143 [41860] = 'Xorvasc',
Nenue@40 144 [40299] = 'Bodhi Sunwayver',
Nenue@40 145 [42442] = 'Amalia',
Nenue@40 146 [40280] = 'Bredda Tenderhide',
Nenue@40 147 [41687] = 'Odrogg',
Nenue@40 148 [41944] = 'Trapper Jarrun',
Nenue@40 149 [40337] = 'Master Tamer Flummox',
Nenue@40 150 [40279] = 'Durian Strongfruit'
Nenue@40 151 }
Nenue@40 152 local falcosaurs = {
Nenue@40 153 [44895] = {44881, 'Sharptalon Hatchling', 115786},
Nenue@40 154 [44894] = {44882, 'Bloodgazer Hatchling', 115787},
Nenue@40 155 [44893] = {44880, 'Direbeak Hatchling', 115785},
Nenue@40 156 [44892] = {44879, 'Snowfeather Hatchling', 115784},
Nenue@33 157 }
Nenue@33 158 local familiars_id = 9696
Nenue@40 159 for questID, name in pairs(familiars) do
Nenue@40 160 db.TooltipExtras[questID] = {{
Nenue@40 161 achievementID = familiars_id,
Nenue@40 162 name = name
Nenue@40 163 }}
Nenue@40 164 end
Nenue@40 165 for questID, info in pairs(falcosaurs) do
Nenue@40 166 local trackingQuestID, petName, petID = unpack(info)
Nenue@33 167
Nenue@40 168 db.TooltipExtras[questID] = {{
Nenue@40 169 questID = trackingQuestID,
Nenue@40 170 pet = petName,
Nenue@40 171 petID = petID
Nenue@40 172 }}
Nenue@9 173 end
Nenue@7 174
Nenue@95 175
Nenue@95 176 do
Nenue@95 177 local timeStates = {
Nenue@95 178 {maxSeconds = 60,
Nenue@95 179 r=1, g=0.25, b =0, format = function (minutes) return '|cFFFF4400'.. minutes .. 'm' end,
Nenue@95 180 },
Nenue@95 181 {maxSeconds = 240,
Nenue@95 182 r=1, g=.5, b=0, format = function(minutes) return '|cFFFF4400'.. floor(minutes/60) .. 'h' end,
Nenue@95 183 },
Nenue@95 184 {maxSeconds = 1440,
Nenue@95 185 r=1, g=1, b=0, format = function(minutes) return '|cFFFFFF00'.. floor(minutes/60) .. 'h' end,
Nenue@95 186 },
Nenue@95 187 {maxSeconds = 10081,
Nenue@95 188 r=0, g=1, b=0,
Nenue@95 189 }, -- 7 days + 1 minute
Nenue@95 190 }
Nenue@95 191 -- Generates a timeleft string
Nenue@95 192 function QuestPOI:GetTimeInfo(timeLeft, limit)
Nenue@95 193 for index = 1, limit do
Nenue@95 194 local state = timeStates[index]
Nenue@95 195 if timeLeft <= state.maxSeconds then
Nenue@95 196 local text
Nenue@95 197 if state.format then
Nenue@95 198 text = state.format(timeLeft)
Nenue@95 199 end
Nenue@95 200 return text, index, state
Nenue@95 201 end
Nenue@95 202 end
Nenue@95 203 return
Nenue@95 204 end
Nenue@95 205 end
Nenue@95 206
Nenue@95 207
Nenue@40 208 local GetAchievementTooltipExtras = function(info)
Nenue@29 209
Nenue@40 210 local hasInfo
Nenue@40 211 local achievementID = info.achievementID
Nenue@40 212 local _, name, _, completed, _, _, _, _, _, icon = GetAchievementInfo(achievementID)
Nenue@40 213 if not completed then
Nenue@40 214
Nenue@40 215 local numItems = GetAchievementNumCriteria(achievementID)
Nenue@40 216 local numNeeded = 0
Nenue@40 217 local tooltipLines = {}
Nenue@40 218 for i =1, numItems do
Nenue@40 219 local criteriaName, criteriaType, completed, _, _, _, _, subAchievementID = GetAchievementCriteriaInfo(achievementID, i)
Nenue@49 220 --print(GetAchievementCriteriaInfo(achievementID, i))
Nenue@40 221
Nenue@40 222 if not completed then
Nenue@49 223 --print('::', criteriaName, completed, subAchievementID)
Nenue@40 224 if criteriaType == 8 then
Nenue@40 225 local _, _, _, completed, _, _, _, _, _, subIcon = GetAchievementInfo(subAchievementID)
Nenue@49 226 --print(' -', criteriaName, completed, subIcon)
Nenue@40 227 if not completed then
Nenue@40 228 local numCompleted = 0
Nenue@40 229 local numSubItems = GetAchievementNumCriteria(subAchievementID)
Nenue@40 230 local subCriteriaLine
Nenue@40 231 for j = 1, numSubItems do
Nenue@40 232 local subName, _, completed = GetAchievementCriteriaInfo(subAchievementID, j)
Nenue@40 233
Nenue@49 234 --print(' -',subName, completed)
Nenue@40 235 if completed then
Nenue@40 236 numCompleted = numCompleted + 1
Nenue@40 237 else
Nenue@40 238 numNeeded = numNeeded + 1
Nenue@40 239 if subName:match(info.name) then
Nenue@40 240 hasInfo = true
Nenue@40 241 subCriteriaLine = ' |T'..subIcon..':16:16|t ' .. criteriaName
Nenue@40 242 end
Nenue@40 243 end
Nenue@40 244
Nenue@40 245 end
Nenue@40 246 if subCriteriaLine then
Nenue@40 247 tinsert(tooltipLines, subCriteriaLine .. ' ('..numCompleted..'/'..numSubItems..')')
Nenue@40 248 end
Nenue@40 249 end
Nenue@40 250 elseif criteriaName:match(info.name) and (not completed) then
Nenue@40 251 numNeeded = numNeeded + 1
Nenue@40 252 tinsert(tooltipLines, criteriaName)
Nenue@40 253 end
Nenue@40 254 end
Nenue@40 255 end
Nenue@49 256 if hasInfo then
Nenue@49 257 WorldMapTooltip:AddLine(" ")
Nenue@49 258 WorldMapTooltip:AddLine("Achievements:")
Nenue@49 259 WorldMapTooltip:AddLine(' |T'..icon..':20:20|t '..name)
Nenue@40 260 for i, line in ipairs(tooltipLines) do
Nenue@40 261 WorldMapTooltip:AddLine(line)
Nenue@40 262 end
Nenue@40 263 end
Nenue@40 264 end
Nenue@40 265 return hasInfo
Nenue@40 266 end
Nenue@40 267
Nenue@40 268 local GetQuestTooltipExtras = function(info)
Nenue@40 269 local questID = info.questID
Nenue@40 270 local hasInfo
Nenue@40 271
Nenue@40 272 if info.pet then
Nenue@40 273 local index, guid = C_PetJournal.FindPetIDByName(info.pet)
Nenue@40 274 if not index then
Nenue@40 275 hasInfo = true
Nenue@40 276 WorldMapTooltip:AddLine('Pets:')
Nenue@40 277 WorldMapTooltip:AddLine(' - ' .. info.petName)
Nenue@40 278
Nenue@40 279 if not IsQuestFlaggedCompleted(questID) then
Nenue@40 280 WorldMapTooltip:AddLine(' Required Quest Flags', 1, 1, 0)
Nenue@40 281 else
Nenue@40 282 WorldMapTooltip:AddLine(' Quest Flags Complete!', 0, 1, 0)
Nenue@40 283 end
Nenue@40 284
Nenue@40 285 end
Nenue@29 286 end
Nenue@29 287
Nenue@29 288 end
Nenue@29 289
Nenue@93 290 function QuestPOI:OnLoad()
Nenue@93 291 --qprint('|cFF00FF88'..self:GetName()..':OnLoad()|r',db.Config)
Nenue@93 292 self.debugTimer = 4
Nenue@93 293 self.title = '|cFF0088FF' .. RETRIEVING_DATA..'|r'
Nenue@93 294 self.count = self.Overlay.count
Nenue@93 295 self.timeLabel = self.Overlay.timeLabel
Nenue@93 296 self.Description = self.Overlay.Description
Nenue@93 297 self.updateRate = PIN_REQUEST_DELAY
Nenue@93 298 self.itemName = '|cFF0088FF' .. RETRIEVING_DATA..'|r'
Nenue@93 299
Nenue@93 300
Nenue@93 301 self.IconBackdrop:SetVertexColor(0,0,0,1)
Nenue@93 302 self.Overlay:SetPoint('TOPLEFT', self, 'TOPLEFT', 0, 4)
Nenue@93 303 self.Overlay:SetPoint('BOTTOMRIGHT', self, 'BOTTOMRIGHT', 0, -4)
Nenue@93 304 end
Nenue@93 305
Nenue@93 306 function QuestPOI:OnShow ()
Nenue@93 307 if self.isStale then
Nenue@93 308 --print('|cFF00FF00refresh on show')
Nenue@93 309 self:Refresh('POI_ONSHOW_STALE')
Nenue@93 310 end
Nenue@95 311
Nenue@95 312 if self.questID and IsQuestComplete(self.questID) then
Nenue@95 313 self:Release()
Nenue@95 314 return
Nenue@95 315 end
Nenue@95 316
Nenue@93 317 self:RegisterEvent('QUEST_TURNED_IN')
Nenue@93 318 self:RegisterEvent('QUEST_LOG_UPDATE')
Nenue@93 319 self:HideOrShowFrames(true)
Nenue@93 320 end
Nenue@93 321
Nenue@93 322 function QuestPOI:OnEvent(event, questID)
Nenue@93 323 if (self.questID == questID) and IsQuestComplete(self.questID) then
Nenue@93 324 db.log(self.questID .. " Marked completed.")
Nenue@93 325 self:Release()
Nenue@93 326 end
Nenue@93 327 end
Nenue@93 328
Nenue@93 329 function QuestPOI:OnHide()
Nenue@93 330 --DEFAULT_CHAT_FRAME:AddMessage('|cFFFFFF00'..self:GetName()..'|r:OnHide()')
Nenue@93 331 self:HideOrShowFrames(false)
Nenue@93 332 -- reset flags
Nenue@93 333 self:SetAlpha(db.PinAlpha)
Nenue@93 334 self.isAnimating = nil
Nenue@93 335 if db.Config.DebugEnabled then
Nenue@93 336 db.log(tostring(self.questID) .. ' ' .. tostring(self.title) .. "\n" .. tostring(REWARD_TYPE_NAMES[self.rewardType]) .. ' ' .. tostring(self.itemName) .. ' ' .. tostring(self.itemNumber) .. "\n|cFFFF4400" .. (self.hideReason or 'NO_MESSAGE') .. "|r\n|cFF00FFFF" .. debugstack(2,3,0) .. '|r')
Nenue@93 337 end
Nenue@93 338 self.hideReason = nil
Nenue@93 339 end
Nenue@40 340
Nenue@40 341 function QuestPOI:OnEnter()
Nenue@57 342 if self.filtered and (self.questID ~= GetSuperTrackedQuestID()) then
Nenue@49 343 return
Nenue@7 344 end
Nenue@57 345 WorldMap_HijackTooltip(self.owningFrame);
Nenue@56 346 self:SetFrameLevel(pinBaseIndex+100)
Nenue@78 347 self.Overlay:SetFrameLevel(overlayBaseIndex+100)
Nenue@56 348
Nenue@56 349 if previousHighlight then
Nenue@56 350 previousHighlight:SetFrameLevel(pinBaseIndex+previousHighlight:GetID())
Nenue@56 351 previousHighlight.Overlay:SetFrameLevel(overlayBaseIndex+previousHighlight:GetID())
Nenue@56 352 end
Nenue@56 353
Nenue@56 354 previousHighlight = self
Nenue@56 355
Nenue@56 356
Nenue@40 357 WorldMapTooltip:SetOwner(self, "ANCHOR_RIGHT");
Nenue@49 358 --print('doing tooltip stuff')
Nenue@40 359
Nenue@40 360 -- Can't add stuff after, so most of the blizzard tooltip hook is simply copied over
Nenue@40 361 local questID = self.questID
Nenue@40 362 local color = WORLD_QUEST_QUALITY_COLORS[self.rarity] or NORMAL_FONT_COLOR;
Nenue@40 363
Nenue@40 364
Nenue@40 365 WorldMapTooltip:SetText(self.title, color.r, color.g, color.b);
Nenue@40 366 QuestUtils_AddQuestTypeToTooltip(WorldMapTooltip, questID, NORMAL_FONT_COLOR);
Nenue@40 367
Nenue@40 368 if ( self.factionID ) then
Nenue@40 369 local factionName = GetFactionInfoByID(self.factionID);
Nenue@40 370 if ( factionName ) then
Nenue@40 371 if (self.capped) then
Nenue@40 372 WorldMapTooltip:AddLine(factionName, GRAY_FONT_COLOR:GetRGB());
Nenue@40 373 else
Nenue@40 374 WorldMapTooltip:AddLine(factionName);
Nenue@40 375 end
Nenue@40 376 end
Nenue@40 377 end
Nenue@40 378
Nenue@40 379 if self.worldQuest then
Nenue@40 380 WorldMap_AddQuestTimeToTooltip(questID);
Nenue@40 381 end
Nenue@40 382
Nenue@40 383
Nenue@40 384 for objectiveIndex = 1, self.numObjectives do
Nenue@40 385 local objectiveText, objectiveType, finished = GetQuestObjectiveInfo(questID, objectiveIndex, false);
Nenue@40 386 if ( objectiveText and #objectiveText > 0 ) then
Nenue@40 387 local color = finished and GRAY_FONT_COLOR or HIGHLIGHT_FONT_COLOR;
Nenue@40 388 WorldMapTooltip:AddLine(QUEST_DASH .. objectiveText, color.r, color.g, color.b, true);
Nenue@40 389 end
Nenue@40 390 end
Nenue@40 391
Nenue@40 392 local percent = C_TaskQuest.GetQuestProgressBarInfo(self.questID);
Nenue@40 393 if ( percent ) then
Nenue@40 394 GameTooltip_InsertFrame(WorldMapTooltip, WorldMapTaskTooltipStatusBar);
Nenue@40 395 WorldMapTaskTooltipStatusBar.Bar:SetValue(percent);
Nenue@40 396 WorldMapTaskTooltipStatusBar.Bar.Label:SetFormattedText(PERCENTAGE_STRING, percent);
Nenue@40 397 end
Nenue@40 398
Nenue@40 399 if db.TooltipExtras[self.questID] then
Nenue@40 400 for index, info in pairs(db.TooltipExtras[questID]) do
Nenue@40 401 if info.achievementID then
Nenue@40 402 GetAchievementTooltipExtras(info)
Nenue@40 403 end
Nenue@40 404 if info.questID then
Nenue@40 405 GetQuestTooltipExtras(info)
Nenue@40 406 end
Nenue@40 407 end
Nenue@40 408 end
Nenue@65 409 GameTooltip_AddQuestRewardsToTooltip(WorldMapTooltip, questID)
Nenue@40 410
Nenue@40 411 WorldMapTooltip:Show()
Nenue@40 412 --WorldMapTooltip.recalculatePadding = true;
Nenue@40 413 --print(WorldMapTooltip:GetParent())
Nenue@40 414 --print(WorldMapTooltip:IsVisible())
Nenue@7 415 end
Nenue@93 416
Nenue@93 417 function QuestPOI:OnMouseDown(button)
Nenue@93 418 if button == 'RightButton' then
Nenue@93 419 SetSuperTrackedQuestID(nil)
Nenue@93 420 else
Nenue@93 421 TaskPOI_OnClick(self, button)
Nenue@93 422 end
Nenue@93 423 end
Nenue@93 424
Nenue@40 425 function QuestPOI:OnLeave()
Nenue@57 426 if self.filtered and (self.questID ~= GetSuperTrackedQuestID()) then
Nenue@57 427 return
Nenue@57 428 end
Nenue@35 429 WorldMap_RestoreTooltip()
Nenue@40 430 WorldMapTooltip:Hide();
Nenue@7 431 end
Nenue@7 432
Nenue@96 433
Nenue@96 434
Nenue@93 435 local updateTime, markTime
Nenue@93 436 function QuestPOI:OnUpdate (sinceLast)
Nenue@93 437 -- control update check intervals
Nenue@93 438
Nenue@95 439 if self.toAlpha then
Nenue@95 440 if not self.alphaStart then
Nenue@95 441 self.alphaStart = GetTime()
Nenue@95 442 end
Nenue@93 443
Nenue@93 444
Nenue@95 445 local alpha = self.icon:GetAlpha()
Nenue@95 446 local alphaMod = ((GetTime()-self.alphaStart) *FADE_TIMING_MULTIPLIER)
Nenue@96 447
Nenue@95 448 if alpha > self.toAlpha then
Nenue@95 449 alpha = alpha - (sinceLast*FADE_TIMING_MULTIPLIER)
Nenue@95 450
Nenue@95 451 if (alpha <= self.toAlpha) then
Nenue@95 452 alpha = self.toAlpha
Nenue@95 453 self.toAlpha = nil
Nenue@95 454 elseif (alpha <= 0) then
Nenue@95 455 alpha = 0
Nenue@95 456 self.toAlpha = nil
Nenue@95 457 end
Nenue@95 458 elseif alpha < self.toAlpha then
Nenue@95 459 alpha = alpha + alphaMod
Nenue@95 460
Nenue@95 461 if (alpha >= self.toAlpha) then
Nenue@95 462 alpha = self.toAlpha
Nenue@95 463 self.toAlpha = nil
Nenue@95 464 elseif (alpha >= 1) then
Nenue@95 465 alpha = 1
Nenue@95 466 self.toAlpha = nil
Nenue@95 467 end
Nenue@95 468
Nenue@95 469 else
Nenue@95 470 self.toAlpha = nil
Nenue@95 471 end
Nenue@95 472
Nenue@95 473 if not self.toAlpha then
Nenue@95 474 self.alphaStart = nil
Nenue@95 475 else
Nenue@95 476 self.alphaStart = GetTime()
Nenue@93 477 end
Nenue@93 478
Nenue@93 479 self.icon:SetAlpha(alpha)
Nenue@93 480 self.RewardBorder:SetAlpha(alpha)
Nenue@93 481 end
Nenue@93 482
Nenue@93 483 self.throttle = (self.throttle or self.updateRate) + sinceLast
Nenue@93 484 if self.throttle >= self.updateRate then
Nenue@93 485 -- factor overtime into the throttle timer
Nenue@93 486 self.throttle = self.throttle - self.updateRate
Nenue@93 487 else
Nenue@93 488 return
Nenue@93 489 end
Nenue@93 490 --@debug@
Nenue@93 491 if DATA_DEBUG then
Nenue@93 492 self.debugTimer = self.debugTimer - sinceLast
Nenue@93 493 if self.debugTimer >= 0 then
Nenue@93 494 print(self.debugTimer)
Nenue@93 495 return
Nenue@93 496 end
Nenue@93 497 end
Nenue@93 498 --@end-debug@
Nenue@93 499
Nenue@93 500 -- query for reward data if it wasn't found in the original scan
Nenue@93 501
Nenue@93 502 if not self.dataLoaded then
Nenue@93 503 local dataLoaded = self:GetData()
Nenue@93 504 if dataLoaded and not tContains(db.UpdatedPins, self) then
Nenue@93 505 -- self.PendingFade:Stop()
Nenue@93 506 -- scale info from the parent module is needed, so deal with it there
Nenue@93 507 print('|cFF00FF88 queueing for update')
Nenue@93 508 self.isNew = true
Nenue@93 509 tinsert(db.UpdatedPins, self)
Nenue@93 510 else
Nenue@93 511
Nenue@93 512 --print('|cFFFF4400OnUpdate(|r'..self:GetID()..'|cFFFF4400)|r poll failed')
Nenue@93 513 end
Nenue@93 514 return
Nenue@93 515 end
Nenue@93 516
Nenue@93 517 if self.maxAlertLevel then
Nenue@93 518 self:UpdateStatus()
Nenue@93 519 end
Nenue@96 520
Nenue@96 521
Nenue@96 522 if self.isStale then
Nenue@96 523 self:Refresh()
Nenue@96 524 end
Nenue@96 525
Nenue@93 526 end
Nenue@93 527
Nenue@93 528
Nenue@93 529 function QuestPOI:StartFading()
Nenue@95 530 if not self.toAlpha then
Nenue@95 531 print('setting toAlpha')
Nenue@95 532 self.toAlpha = 1
Nenue@93 533 self.icon:SetAlpha(0)
Nenue@93 534 self.RewardBorder:SetAlpha(0)
Nenue@93 535 end
Nenue@93 536 end
Nenue@93 537
Nenue@40 538 -- attempt to pull pin data
Nenue@40 539 function QuestPOI:GetData ()
Nenue@75 540 --dprint('|cFF00FF88'..self:GetID()..':GetData()|r')
Nenue@40 541 local questID = self.questID
Nenue@40 542 if not questID then
Nenue@75 543 --dprint('|cFFFF4400bad pin|r', self:GetName())
Nenue@40 544 return nil
Nenue@29 545 end
Nenue@29 546
Nenue@40 547 local questTitle, factionID, capped = TQ_GetQuestInfoByQuestID(questID)
Nenue@40 548 -- if the title is nil, then wait and try later
Nenue@40 549 if not questTitle then
Nenue@75 550 --dprint('|cFFBB8844dataLoaded|r = false|cFF00FFFF', self.questId)
Nenue@65 551 return false
Nenue@40 552 else
Nenue@40 553 self.title, self.factionID, self.capped = questTitle, factionID, capped
Nenue@93 554 --print(questTitle, factionID, capped)
Nenue@40 555 -- set tag details
Nenue@40 556 local worldQuestType
Nenue@40 557 self.tagID, self.tagName, worldQuestType, self.rarity, self.isElite, self.tradeskillLineIndex = GetQuestTagInfo(questID);
Nenue@40 558 local tagAtlas
Nenue@40 559 if worldQuestType == LE_QUEST_TAG_TYPE_PET_BATTLE then
Nenue@40 560 tagAtlas = "worldquest-icon-petbattle"
Nenue@40 561 elseif worldQuestType == LE_QUEST_TAG_TYPE_PVP then
Nenue@40 562 tagAtlas = "worldquest-icon-pvp-ffa"
Nenue@40 563 elseif worldQuestType == LE_QUEST_TAG_TYPE_PROFESSION then
Nenue@40 564 self.isKnownProfession = nil
Nenue@40 565 local id = self.tradeskillLineIndex and select(7, GetProfessionInfo(self.tradeskillLineIndex))
Nenue@40 566 if id then
Nenue@40 567 self.isKnownProfession = true
Nenue@75 568 --qprint('profession' , self.title, id)
Nenue@40 569 tagAtlas = WORLD_QUEST_ICONS_BY_PROFESSION[id]
Nenue@40 570 end
Nenue@40 571 elseif worldQuestType == LE_QUEST_TAG_TYPE_DUNGEON then
Nenue@40 572 tagAtlas = "worldquest-icon-dungeon"
Nenue@40 573 end
Nenue@40 574 self.worldQuestType = worldQuestType
Nenue@40 575 self.tagAtlas = tagAtlas
Nenue@29 576
Nenue@69 577 local dataLoaded, rewardType, itemName, itemTexture, itemNumber, quality, xpType, xpName, xpIcon, xpCount = self:UpdateRewards()
Nenue@75 578 --dprint('|cFFBB8844 dataLoaded|r =', dataLoaded, rewardType, itemName, itemTexture, itemNumber, quality)
Nenue@65 579 if dataLoaded then
Nenue@65 580 self.rewardType = rewardType
Nenue@65 581 self.itemName = itemName
Nenue@65 582 self.itemTexture = itemTexture
Nenue@65 583 self.itemNumber = itemNumber
Nenue@65 584 self.itemQuality = quality
Nenue@49 585 self.dataLoaded = true
Nenue@48 586 self.isStale = true
Nenue@69 587 self.xpType, self.xpName, self.xpIcon, self.xpCount = xpType, xpName, xpIcon, xpCount
Nenue@95 588 WorldPlan.dataFlush = true
Nenue@40 589 end
Nenue@40 590 end
Nenue@40 591
Nenue@40 592
Nenue@65 593 return self.dataLoaded
Nenue@40 594 end
Nenue@40 595
Nenue@69 596 local ID_RESOURCES = 1220
Nenue@69 597 local ID_LEGIONFALL = 1342
Nenue@69 598
Nenue@65 599 --- Returns true if data has changed (either from loading in or qualifications changed)
Nenue@65 600 function QuestPOI:UpdateRewards()
Nenue@40 601 local questID = self.questID
Nenue@65 602 if not HaveQuestRewardData(questID) then
Nenue@65 603 C_TaskQuest.RequestPreloadRewardData(questID);
Nenue@65 604 return false;
Nenue@29 605 else
Nenue@65 606 local rewardMoney, rewardAP, rewardHonor
Nenue@65 607 local rewardItems, rewardCurrency = {}, {}
Nenue@65 608 local rewardIcon, rewardName, rewardCount, rewardStyle, rewardType, itemID, quantity, quality
Nenue@65 609 local xpIcon, xpName, xpCount, xpType
Nenue@69 610 local foundPrimary
Nenue@29 611
Nenue@65 612 if (GetNumQuestLogRewardCurrencies(questID) > 0 or GetNumQuestLogRewards(questID) > 0 or GetQuestLogRewardMoney(questID) > 0 or GetQuestLogRewardArtifactXP(questID) > 0 or GetQuestLogRewardHonor(questID)) then
Nenue@65 613 local money = GetQuestLogRewardMoney(questID)
Nenue@65 614 if money > 0 then
Nenue@65 615 rewardMoney = money
Nenue@65 616 rewardIcon = ICON_MONEY
Nenue@65 617 rewardName = GetMoneyString(money)
Nenue@65 618 rewardCount = floor(money/10000)
Nenue@65 619 rewardType = REWARD_CASH
Nenue@65 620 end
Nenue@65 621
Nenue@65 622 local artifactXP = GetQuestLogRewardArtifactXP(questID);
Nenue@65 623 if artifactXP > 0 then
Nenue@65 624 rewardAP = artifactXP
Nenue@65 625 rewardIcon = "Interface\\ICONS\\inv_7xp_inscription_talenttome01"
Nenue@65 626 rewardCount = artifactXP
Nenue@65 627 rewardType = REWARD_ARTIFACT_POWER
Nenue@75 628 --dprint(' artifactXP', artifactXP)
Nenue@69 629 foundPrimary = true
Nenue@65 630 end
Nenue@65 631
Nenue@65 632 local numQuestCurrencies = GetNumQuestLogRewardCurrencies(questID);
Nenue@65 633 for i = 1, numQuestCurrencies do
Nenue@69 634 local name, texture, numItems, currencyID = GetQuestLogRewardCurrencyInfo(i, questID);
Nenue@65 635 local text = BONUS_OBJECTIVE_REWARD_WITH_COUNT_FORMAT:format(texture, numItems, name);
Nenue@65 636 tinsert(rewardCurrency, {
Nenue@65 637 name = name,
Nenue@65 638 texture = texture,
Nenue@65 639 numItems = numItems,
Nenue@65 640 text = text
Nenue@65 641 })
Nenue@69 642
Nenue@75 643 --dprint(' currency', i, currencyID, name, " |T"..tostring(texture)..":12:12|t")
Nenue@69 644 if currencyID == ID_RESOURCES then
Nenue@69 645 rewardIcon = texture
Nenue@69 646 rewardCount = numItems
Nenue@69 647 rewardName = name
Nenue@69 648 rewardType = REWARD_CURRENCY
Nenue@69 649 foundPrimary = true
Nenue@69 650 elseif currencyID == ID_LEGIONFALL then
Nenue@69 651 xpIcon = texture
Nenue@69 652 xpCount = numItems
Nenue@69 653 xpName = name
Nenue@69 654 xpType = REWARD_CURRENCY
Nenue@69 655 end
Nenue@89 656 end
Nenue@69 657
Nenue@65 658 local honorAmount = GetQuestLogRewardHonor(questID);
Nenue@65 659 if honorAmount > 0 then
Nenue@89 660 xpIcon = "Interface\\ICONS\\Achievement_LegionPVPTier4"
Nenue@89 661 xpCount = honorAmount
Nenue@89 662 xpName = HONOR
Nenue@89 663 xpType = HONOR_CURRENCY
Nenue@88 664 -- let items override
Nenue@65 665 end
Nenue@65 666
Nenue@65 667 local numQuestRewards = GetNumQuestLogRewards(questID);
Nenue@65 668 if numQuestRewards > 0 then
Nenue@65 669 for i = 1, numQuestRewards do
Nenue@65 670 local name, texture, numItems, quality, isUsable, itemID = GetQuestLogRewardInfo(i, questID)
Nenue@65 671
Nenue@65 672 if itemID then
Nenue@65 673 local itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture, sellPrice, classID, subclassID = GetItemInfo(itemID);
Nenue@65 674 if ( classID == LE_ITEM_CLASS_WEAPON or classID == LE_ITEM_CLASS_ARMOR or (classID == LE_ITEM_CLASS_GEM and subclassID == LE_ITEM_GEM_ARTIFACTRELIC) ) then
Nenue@65 675 rewardType = REWARD_GEAR
Nenue@65 676 rewardIcon = texture
Nenue@65 677 rewardName = name
Nenue@65 678 rewardCount = numItems
Nenue@65 679 foundPrimary = true
Nenue@65 680 elseif IsArtifactPowerItem(itemID) then
Nenue@65 681 rewardType = REWARD_ARTIFACT_POWER
Nenue@65 682 rewardIcon = texture
Nenue@65 683 rewardName = name
Nenue@93 684 rewardCount = self:UpdateArtifactPower(itemLink)
Nenue@65 685 foundPrimary = true
Nenue@75 686 --dprint('is an AP token')
Nenue@65 687 elseif classID == LE_ITEM_CLASS_TRADEGOODS then
Nenue@65 688 rewardType = REWARD_REAGENT
Nenue@65 689 rewardIcon = texture
Nenue@65 690 rewardName = name
Nenue@65 691 rewardCount = numItems
Nenue@65 692 foundPrimary = true
Nenue@65 693 end
Nenue@75 694 --dprint(' reward', i, name, " |T"..tostring(texture)..":12:12|t", quality, isUsable, itemID)
Nenue@65 695 tinsert(rewardItems, {
Nenue@65 696 name = name,
Nenue@65 697 texture = texture,
Nenue@65 698 numItems = numItems,
Nenue@65 699 quality = quality,
Nenue@65 700 isUsable = isUsable
Nenue@65 701 })
Nenue@65 702 if not foundPrimary then
Nenue@75 703 --print(' -updating primary')
Nenue@82 704 rewardType = REWARD_REAGENT
Nenue@65 705
Nenue@65 706 rewardIcon = texture
Nenue@65 707 rewardName = name
Nenue@65 708 rewardCount = numItems
Nenue@65 709 end
Nenue@65 710
Nenue@65 711 end
Nenue@65 712
Nenue@65 713 end
Nenue@65 714 end
Nenue@65 715
Nenue@75 716 --dprint(' '..self.questID..':|cFFFFFF00UpdateRewards():', numQuestRewards, rewardType)
Nenue@75 717 --dprint(' ', tostring(self.title), " |T"..tostring(self.itemTexture)..":12:12|t", tostring(self.itemName))
Nenue@65 718
Nenue@89 719 if rewardType and ((self.itemNumber ~= rewardCount) or (self.rewardType ~= rewardType) or (self.itemName ~= rewardName) or (self.itemTexture ~= rewardIcon)) then
Nenue@67 720 if DATA_DEBUG and (self.debugTimer <= 0) then
Nenue@67 721 return false
Nenue@67 722 end
Nenue@67 723
Nenue@89 724 return true, rewardType, rewardName, rewardIcon, rewardCount, quality, xpType, xpName, xpIcon, xpCount
Nenue@67 725
Nenue@65 726 else
Nenue@65 727 return false
Nenue@65 728 end
Nenue@65 729 end
Nenue@65 730
Nenue@65 731
Nenue@65 732
Nenue@65 733 --[[ set reward category
Nenue@29 734 local numRewards = GetNumQuestLogRewards(questID)
Nenue@29 735 local numCurrency = GetNumQuestLogRewardCurrencies(questID)
Nenue@29 736 local money = GetQuestLogRewardMoney(questID)
Nenue@29 737 if numRewards >= 1 then
Nenue@40 738 rewardType, rewardIcon, rewardCount, rewardName, itemID, quality = WorldPlanQuests:GetRewardHeader(questID)
Nenue@29 739 elseif numCurrency >= 1 then
Nenue@29 740 rewardName, rewardIcon, rewardCount = GetQuestLogRewardCurrencyInfo(1, questID)
Nenue@29 741 rewardType = REWARD_CURRENCY
Nenue@29 742 elseif money >= 1 then
Nenue@29 743 rewardName = GetMoneyString(money)
Nenue@29 744 end
Nenue@65 745 --]]
Nenue@29 746
Nenue@40 747 end
Nenue@7 748 end
Nenue@7 749
Nenue@34 750
Nenue@93 751 function QuestPOI:UpdateArtifactPower(rewardLink)
Nenue@93 752 if not (rewardLink or self.rewardLink) then
Nenue@75 753 return
Nenue@75 754 end
Nenue@75 755
Nenue@93 756 self.rewardLink = rewardLink or self.rewardLink
Nenue@49 757
Nenue@93 758 local rewardCount
Nenue@93 759 WorldPlanTooltip:SetOwner(self, 'ANCHOR_NONE')
Nenue@93 760 WorldPlanTooltip:SetHyperlink(rewardLink or self.rewardLink)
Nenue@93 761 for i = 1, WorldPlanTooltip:NumLines() do
Nenue@93 762 local line = _G['WorldPlanTooltipTextLeft' .. i]
Nenue@93 763 local text = line and line:GetText()
Nenue@95 764 local multiplier = (text:match('million') and 1000000) or 1
Nenue@95 765 if text then
Nenue@95 766 text = text:gsub(',', '')
Nenue@95 767 local ap = text:match('([%d]+) '..ARTIFACT_POWER)
Nenue@95 768 if not ap then
Nenue@95 769 ap = text:match('([%d%.]+) million '..ARTIFACT_POWER)
Nenue@95 770 if ap then
Nenue@95 771 ap = tonumber(ap) * 1000000
Nenue@95 772 end
Nenue@95 773 end
Nenue@95 774 if ap then
Nenue@95 775 rewardCount = tonumber(ap)
Nenue@95 776 end
Nenue@69 777 end
Nenue@48 778 end
Nenue@93 779 return rewardCount
Nenue@27 780 end
Nenue@27 781
Nenue@67 782 -- Applies position and sizing parameters to the pin data
Nenue@66 783 function QuestPOI:SetAnchor(owner, dX, dY, mapWidth, mapHeight, scaleFactor)
Nenue@75 784 --dprint(self:GetName()..':SetAnchor()', owner, dX, dY, scaleFactor, self.filtered, self.used)
Nick@62 785 if not self.used then
Nenue@69 786 self.hideReason = 'SetAnchor() on an unused frame.'
Nenue@93 787 self:HideOrShowFrames(false)
Nick@62 788 return
Nick@62 789 end
Nick@62 790
Nenue@75 791
Nenue@67 792 if owner then
Nenue@67 793 self:SetParent(owner)
Nenue@67 794 self.Overlay:SetParent(owner)
Nenue@78 795 self:SetFrameStrata('HIGH')
Nenue@78 796 self:SetFrameLevel(pinBaseIndex + self:GetID())
Nenue@78 797 self.Overlay:SetFrameStrata('HIGH')
Nenue@78 798 self.Overlay:SetFrameLevel(overlayBaseIndex + self:GetID())
Nenue@74 799 self.isStale = true
Nenue@67 800 else
Nenue@67 801 owner = self:GetParent()
Nenue@67 802 end
Nenue@67 803
Nenue@74 804
Nenue@74 805 if scaleFactor then
Nenue@82 806 print('scaleFactor')
Nenue@67 807 self:SetScale(scaleFactor)
Nenue@67 808 self.Overlay:SetScale(scaleFactor)
Nenue@67 809 self.scaleFactor = scaleFactor
Nenue@67 810 end
Nenue@67 811
Nenue@74 812 mapWidth = mapWidth or owner:GetWidth()
Nenue@74 813 mapHeight = mapHeight or owner:GetHeight()
Nenue@74 814 dX = dX or self.x
Nenue@74 815 dY = dY or self.y
Nenue@74 816 --print(owner:GetName() or tostring(owner), self:GetName(), owner:GetScale(), scaleFactor)
Nenue@74 817 if (self.x ~= dX) or (self.y ~= dY) or scaleFactor then
Nenue@67 818
Nenue@74 819 self.x = dX
Nenue@74 820 self.y = dY
Nenue@74 821 local pX = (dX * mapWidth) * (1 / scaleFactor)
Nenue@74 822 local pY = (-dY * mapHeight) * (1 / scaleFactor)
Nenue@74 823 --print('to', pX, pY, self:GetScale())
Nenue@74 824 self:ClearAllPoints()
Nenue@74 825 self:SetPoint('CENTER', owner, 'TOPLEFT', pX, pY)
Nenue@53 826 end
Nick@62 827
Nick@62 828 end
Nick@62 829
Nenue@78 830 -- Non-hieriarchical display states, checked separately from used/filtered states
Nenue@74 831 function QuestPOI:GetCriteriaState()
Nenue@74 832 local isCriteria, isBounty, isSpellTarget
Nenue@93 833
Nenue@93 834
Nenue@93 835
Nenue@93 836 for index, bounty in pairs(db.Bounties) do
Nenue@93 837 if (not IsQuestComplete(bounty.questID)) and IsQuestCriteriaForBounty(self.questID, bounty.questID) then
Nenue@93 838 isCriteria = true
Nenue@93 839 if db.selectedBounty == bounty then
Nenue@93 840 isBounty = true
Nenue@74 841 end
Nenue@93 842 --dprint('|cFF00FF88Criteria:|r', self.questID, bounty.questID, isCriteria, isBounty)
Nenue@74 843 end
Nenue@74 844 end
Nenue@74 845 isSpellTarget = IsQuestIDValidSpellTarget(self.questID)
Nenue@74 846
Nenue@74 847 if (self.isBounty ~= isBounty) or (self.isCriteria ~= isCriteria) or (self.isSpellTarget ~= isSpellTarget) then
Nenue@75 848 --wqprint('|cFF00FF00criteria state changed')
Nenue@74 849 self.isBounty = isBounty
Nenue@74 850 self.isCriteria = isCriteria
Nenue@74 851 self.isSpellTarget = isSpellTarget
Nenue@75 852 self.isStale = true
Nenue@74 853 return true
Nenue@74 854 end
Nenue@74 855 end
Nenue@74 856
Nenue@35 857 local cvar_check = {
Nenue@35 858 [REWARD_CASH] = 'worldQuestFilterGold',
Nenue@35 859 [REWARD_ARTIFACT_POWER] = 'worldQuestFilterArtifactPower',
Nenue@35 860 [REWARD_CURRENCY] = 'worldQuestFilterOrderResources',
Nenue@35 861 [REWARD_REAGENT]= 'worldQuestFilterProfessionMaterials',
Nenue@35 862 [REWARD_GEAR] = 'worldQuestFilterEquipment',
Nenue@35 863 }
Nenue@8 864
Nick@64 865
Nenue@57 866 function QuestPOI:CheckFilterRules ()
Nenue@36 867 local print = qprint
Nenue@33 868 local qType = self.worldQuestType
Nenue@96 869
Nenue@96 870 self.canShow = false
Nenue@96 871
Nenue@78 872 if not TQ_IsActive(self.questID) then
Nenue@78 873 self.hideReason = 'Filter check ended because quest is inactive.'
Nenue@78 874 self.used = nil
Nenue@78 875 self:SetShown(false)
Nenue@78 876 return
Nenue@78 877 end
Nenue@69 878
Nenue@69 879 if qType == LE_QUEST_TAG_TYPE_PROFESSION then
Nenue@57 880 if not(self.isKnownProfession or db.Config.ShowAllProfessionQuests) then
Nenue@78 881 self.hideReason = 'Failed profession check.'
Nenue@78 882 self.used = nil
Nenue@78 883 self:SetShown(false)
Nenue@78 884 return
Nenue@36 885 end
Nenue@36 886 end
Nenue@57 887
Nenue@78 888 local filtered
Nenue@78 889 for filterKey, value in pairs(db.UsedFilters) do
Nenue@78 890 if self[filterKey] ~= value then
Nenue@78 891 if not self.filtered then
Nenue@78 892 print('|cFFFF4400filtering', filterKey, value, '~=', self[filterKey], self.title)
Nenue@57 893 end
Nenue@78 894 filtered = true
Nenue@57 895 end
Nenue@78 896 end
Nenue@78 897 if self.rewardType and cvar_check[self.rewardType] then
Nenue@78 898 if not GetCVarBool(cvar_check[self.rewardType]) then
Nenue@78 899 filtered = true
Nenue@57 900 end
Nenue@57 901 end
Nenue@78 902
Nenue@78 903 print(' '..self.questID..':|cFFFFFF00CheckFilterRules()|r', filtered, self.title)
Nenue@78 904 if self.filtered ~= filtered then
Nenue@82 905 wqprint('|cFF00FF00filter changed')
Nenue@78 906 self.isStale = true
Nenue@69 907 end
Nenue@78 908
Nenue@96 909 self.canShow = true
Nenue@82 910 self.filtered = filtered
Nenue@33 911 end
Nenue@33 912
Nenue@93 913 function QuestPOI:Refresh (event)
Nenue@93 914 print('|cFF00FF88Refresh(|r'..self:GetID()..'|cFF00FF88)|r', event, self.title)
Nenue@33 915
Nenue@93 916
Nenue@93 917 local style = DEFAULT_STYLE
Nenue@93 918 if self.filtered then
Nenue@93 919 print('choose minimized')
Nenue@93 920 style = MINIMIZED_STYLE
Nenue@93 921 elseif self.dataLoaded then
Nenue@93 922 print('choose reward type')
Nenue@93 923 style = REWARD_TYPE_STYLES[self.rewardType]
Nenue@93 924 else
Nenue@93 925 print('choose default')
Nenue@93 926 end
Nenue@93 927
Nenue@93 928 local currentWidth = style.iconWidth or DEFAULT_STYLE.iconWidth
Nenue@93 929
Nenue@93 930
Nenue@93 931
Nenue@93 932 local borderWidth = style.borderWidth or DEFAULT_STYLE.borderWidth
Nenue@93 933 local highlightWidth = style.highlightWidth or DEFAULT_STYLE.highlightWidth
Nenue@93 934 local tagSize = style.TagSize or DEFAULT_STYLE.TagSize
Nenue@93 935 local hideIcon = style.hideIcon or DEFAULT_STYLE.hideIcon
Nenue@93 936 local borderColor = style.border or DEFAULT_STYLE.border
Nenue@93 937 local textColor = style.textColor or DEFAULT_STYLE.textColor
Nenue@93 938 local questID = self.questID
Nenue@36 939 local iconBorder = self.RewardBorder
Nenue@36 940 local trackingBorder = self.HighlightBorder
Nenue@93 941 local icon = self.icon
Nenue@93 942 local count = self.count
Nenue@93 943 local hideNumbers = style.hideNumber or DEFAULT_STYLE.hideNumber
Nenue@33 944
Nenue@33 945
Nenue@93 946 local tagIcon = self.tagIcon
Nenue@93 947 self.maxAlertLevel = style.maxAlertLevel or DEFAULT_STYLE.maxAlertLevel
Nenue@47 948
Nenue@93 949 if self.dataLoaded then
Nenue@93 950 if self.isNew then
Nenue@95 951 print('new pin, has data, cue fade')
Nenue@93 952 self:StartFading()
Nenue@93 953 self.isNew = nil
Nenue@93 954 end
Nenue@93 955 else
Nenue@95 956 if not self.toAlpha then
Nenue@95 957 icon:SetAlpha(0)
Nenue@95 958 iconBorder:SetAlpha(0)
Nenue@93 959 end
Nenue@93 960 end
Nenue@93 961
Nenue@93 962 if self.itemName then
Nenue@93 963 if self.itemNumber and (self.itemNumber > 1) and (not hideNumbers) then
Nenue@93 964 local numberString = self.itemNumber
Nenue@93 965 if self.itemNumber >= 1000000 then
Nenue@93 966 numberString = (floor(self.itemNumber/100000)/10) .. 'M'
Nenue@93 967 elseif self.itemNumber >= 10000 then
Nenue@93 968 numberString = floor(self.itemNumber/1000) .. 'k'
Nenue@93 969 elseif self.itemNumber >= 1000 then
Nenue@93 970 local numeral = floor(self.itemNumber/1000)
Nenue@93 971 local decimal = mod(self.itemNumber, 1000)
Nenue@93 972 numberString = numeral
Nenue@93 973 if decimal > 100 then
Nenue@93 974 numberString = numberString .. '.' .. tostring(floor(decimal/100))
Nenue@93 975 end
Nenue@93 976 numberString = numberString .. 'k'
Nenue@93 977 end
Nenue@93 978
Nenue@93 979 self.count:SetText(numberString)
Nenue@93 980 self.count:SetTextColor(unpack(textColor))
Nenue@93 981 self.count:Show()
Nenue@57 982 else
Nenue@93 983 self.count:SetText(nil)
Nenue@93 984 self.count:Hide()
Nenue@93 985 end
Nenue@93 986 else
Nenue@93 987 self.count:Hide()
Nenue@93 988 end
Nenue@93 989
Nenue@93 990 if db.Config.ShowVerboseInfo then
Nenue@93 991 self.Description:SetText(self.title .. "\n" .. floor(self.x*100+.5) .. "," .. floor(self.y*100+.5))
Nenue@93 992 end
Nenue@93 993
Nenue@93 994
Nenue@93 995 icon:SetSize(currentWidth, currentWidth)
Nenue@93 996 icon:SetMask(style.iconMask or DEFAULT_STYLE.iconMask)
Nenue@93 997 if self.itemTexture then
Nenue@93 998 --iconBorder:SetTexture(WORLD_QUEST_BORDER)
Nenue@93 999
Nenue@93 1000 if hideIcon then
Nenue@93 1001 icon:SetTexture(PENDING_ICON)
Nenue@93 1002 icon:SetDesaturated(true)
Nenue@93 1003 icon:SetVertexColor(unpack(borderColor))
Nenue@93 1004 else
Nenue@93 1005 icon:SetTexture(self.itemTexture)
Nenue@93 1006 icon:SetDesaturated(false)
Nenue@93 1007 icon:SetVertexColor(1, 1, 1)
Nenue@93 1008 end
Nenue@93 1009 else
Nenue@93 1010 --
Nenue@93 1011 --icon:SetTexture(PENDING_ICON)
Nenue@93 1012 --icon:SetDesaturated(true)
Nenue@93 1013 --icon:SetVertexColor(unpack(borderColor))
Nenue@93 1014 end
Nenue@93 1015 local borderMask = style.borderMask or DEFAULT_STYLE.borderMask
Nenue@93 1016 local borderSize = currentWidth + (borderWidth * 2) + (self.isCriteria and 2 or 0)
Nenue@93 1017
Nenue@93 1018
Nenue@93 1019 iconBorder:SetSize(borderSize, borderSize)
Nenue@93 1020
Nenue@93 1021 iconBorder:SetMask(borderMask)
Nenue@93 1022 iconBorder:SetTexture(PENDING_BORDER)
Nenue@93 1023
Nenue@93 1024 iconBorder:SetDesaturated(true)
Nenue@93 1025
Nenue@93 1026 local highlightSize = borderSize + (highlightWidth * 2)
Nenue@93 1027 trackingBorder:SetSize(highlightSize, highlightSize)
Nenue@93 1028 trackingBorder:SetMask(borderMask)
Nenue@93 1029 trackingBorder:SetTexture(PENDING_BORDER)
Nenue@93 1030
Nenue@93 1031 self:SetSize(borderSize, borderSize)
Nenue@93 1032 self.IconBackdrop:SetSize(currentWidth, currentWidth)
Nenue@93 1033
Nenue@93 1034
Nenue@93 1035
Nenue@93 1036 iconBorder:SetPoint('CENTER', (style.x or 0), (style.y or 0))
Nenue@93 1037 trackingBorder:SetPoint('CENTER', (style.x or 0), (style.y or 0))
Nenue@93 1038
Nenue@93 1039 self.tagIcon:SetShown((not self.filtered) and true or false)
Nenue@93 1040 self.tagIcon:SetAtlas(self.tagAtlas)
Nenue@93 1041 self.EliteBorder:SetShown(self.isElite and not self.filtered)
Nenue@93 1042
Nenue@93 1043 self:UpdateStatus()
Nenue@93 1044
Nenue@93 1045 if self.isBounty then
Nenue@93 1046 --print('is bounty')
Nenue@93 1047 iconBorder:SetVertexColor(trackingBorder:GetVertexColor())
Nenue@93 1048 trackingBorder:SetVertexColor(unpack(BORDER_SELECTED_BOUNTY))
Nenue@93 1049 elseif self.isCriteria then
Nenue@93 1050 --print('is criteria of a bounty')
Nenue@93 1051 iconBorder:SetVertexColor(trackingBorder:GetVertexColor())
Nenue@93 1052 trackingBorder:SetVertexColor(unpack(BORDER_CRITERIA))
Nenue@93 1053 else
Nenue@93 1054
Nenue@93 1055 iconBorder:SetVertexColor(unpack(borderColor))
Nenue@93 1056 trackingBorder:SetVertexColor(0,0,0,.5)
Nenue@93 1057 end
Nenue@93 1058
Nenue@93 1059 if SpellCanTargetQuest() then
Nenue@93 1060 if IsQuestIDValidSpellTarget(self.questID) then
Nenue@93 1061 icon:SetVertexColor(1,1,1)
Nenue@93 1062 else
Nenue@93 1063 icon:SetVertexColor(1,0,0,1)
Nenue@93 1064 end
Nenue@93 1065 self:EnableMouse(false)
Nenue@93 1066 else
Nenue@93 1067 self:EnableMouse(true)
Nenue@93 1068 end
Nenue@93 1069 self.isStale = nil
Nenue@93 1070
Nenue@93 1071 -- signal filter info update
Nenue@93 1072 WorldPlanSummary.isStale = true
Nenue@93 1073 end
Nenue@93 1074
Nenue@93 1075 -- Called at static intervals and with Refresh
Nenue@93 1076 function QuestPOI:UpdateStatus()
Nenue@93 1077 -- update time elements
Nenue@93 1078 self.isActive = TQ_IsActive(self.questID)
Nenue@95 1079 --print(self.maxAlertLevel)
Nenue@95 1080 local border = (self.isBounty or self.isCriteria) and self.RewardBorder or self.HighlightBorder
Nenue@93 1081
Nenue@93 1082 if self.isActive then
Nenue@93 1083 local tl = self.alertLevel
Nenue@93 1084 local timeLeft = TQ_GetQuestTimeLeftMinutes(self.questID)
Nenue@93 1085 if timeLeft > 0 then
Nenue@93 1086
Nenue@95 1087 local text, timeState, style = self:GetTimeInfo(timeLeft, self.maxAlertLevel)
Nenue@93 1088 if tl ~= timeState then
Nenue@93 1089 tl = timeState
Nenue@93 1090 self.timeLabel:SetText(text)
Nenue@93 1091 end
Nenue@95 1092 if style then
Nenue@95 1093 self.RewardBorder:SetVertexColor(style.r, style.g, style.b, style.a)
Nenue@95 1094 end
Nenue@93 1095 end
Nenue@93 1096
Nenue@93 1097 self.alertLevel = tl
Nenue@93 1098 self.timeLabel:SetShown(self.worldQuest and (self.maxAlertLevel >= 1))
Nenue@93 1099 else
Nenue@93 1100 self.hideReason = "No longer active."
Nenue@93 1101 self:HideOrShowFrames(false)
Nenue@93 1102
Nenue@93 1103 end
Nenue@93 1104 end
Nenue@93 1105
Nenue@93 1106 -- Show/Hide the text overlays associated with the quest pin; they aren't hierarchically linked
Nenue@93 1107 function QuestPOI:HideOrShowFrames(isShown)
Nenue@93 1108 if not isShown then
Nenue@93 1109 -- print('|cFFFFFF00' ..self:GetName()..':HideOrShowFrames()')
Nenue@93 1110 -- do not SetShown() here
Nenue@93 1111 if not self.hideReason then
Nenue@95 1112 self.hideReason = "HideOrShowFrames() called without a reason."
Nenue@93 1113 end
Nenue@93 1114 end
Nenue@93 1115 self.Overlay:SetShown(isShown)
Nenue@93 1116 self.count:SetShown(isShown)
Nenue@93 1117 self.timeLabel:SetShown(isShown)
Nenue@93 1118 end
Nenue@93 1119
Nenue@98 1120 function QuestPOI:Release(msg)
Nenue@95 1121 print('|cFFFF4400'..self:GetID()..':Release()', self.hideReason)
Nenue@98 1122 self.hideReason = msg or 'Released by script.'
Nenue@98 1123 self:SetShown(false)
Nenue@95 1124 self:HideOrShowFrames(false)
Nenue@98 1125
Nenue@93 1126 if self.questID then
Nenue@93 1127 db.QuestsByID[self.questID] = nil
Nenue@93 1128 for _, map in pairs(db.QuestsByZone) do
Nenue@93 1129 map[self.questID] = nil
Nenue@93 1130 end
Nenue@93 1131 self.questID = nil
Nenue@93 1132 end
Nenue@93 1133 self.isActive = nil
Nenue@93 1134 self.complete = nil
Nenue@93 1135 self.used = nil
Nenue@93 1136 self.dataLoaded = nil
Nenue@93 1137 self.rewardType = nil
Nenue@93 1138 self.itemTexture = nil
Nenue@93 1139 self.itemName = nil
Nenue@93 1140 self.itemNumber = nil
Nenue@93 1141 self.animating = nil
Nenue@93 1142 self.icon:SetAlpha(0)
Nenue@93 1143 self.RewardBorder:SetAlpha(0)
Nenue@93 1144 self:UnregisterEvent('QUEST_TURNED_IN')
Nenue@93 1145 self:UnregisterEvent('QUEST_LOG_UPDATE')
Nenue@93 1146
Nenue@93 1147 for i, pin in ipairs(db.UsedPins) do
Nenue@93 1148 if pin == self then
Nenue@95 1149 print('|cFFFF4400cleared from UsedPins|r')
Nenue@93 1150 tremove(db.UsedPins, i)
Nenue@93 1151 break
Nenue@57 1152 end
Nenue@47 1153 end
Nenue@47 1154
Nenue@93 1155 tinsert(db.FreePins, self)
Nenue@93 1156 WorldPlan.dataFlush = true
Nenue@95 1157 WorldPlanSummary.isStale = true
Nenue@95 1158
Nenue@95 1159 return true
Nenue@7 1160 end