annotate QuestPOI.lua @ 100:fbd4ead2a19f v1.4.11

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