annotate QuestPOI.lua @ 113:03e4a8b93012 v7.3.0-2

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