annotate QuestPOI.lua @ 54:b289eb3e6a32

- Fix stray pin text arising from pins that are never shown.
author Nenue
date Sat, 31 Dec 2016 17:31:39 -0500
parents 44baf4f35c7c
children 6a2e85836219
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@7 5 --
Nenue@40 6 local _, db = ...
Nenue@29 7
Nenue@29 8 local TQ_GetQuestInfoByQuestID = C_TaskQuest.GetQuestInfoByQuestID -- Return the name of a quest with a given ID
Nenue@7 9 local TQ_GetQuestLocation = C_TaskQuest.GetQuestLocation
Nenue@7 10 local TQ_GetQuestTimeLeftMinutes = C_TaskQuest.GetQuestTimeLeftMinutes
Nenue@9 11 local TQ_IsActive = C_TaskQuest.IsActive
Nenue@29 12 local TQ_RequestPreloadRewardData = C_TaskQuest.RequestPreloadRewardData
Nenue@7 13 local QuestPOIGetIconInfo, WorldMapPOIFrame = QuestPOIGetIconInfo, WorldMapPOIFrame
Nenue@33 14 local WorldMap_DoesWorldQuestInfoPassFilters = WorldMap_DoesWorldQuestInfoPassFilters
Nenue@33 15 local QuestMapFrame_IsQuestWorldQuest = QuestMapFrame_IsQuestWorldQuest
Nenue@40 16 local GetAchievementNumCriteria, GetAchievementCriteriaInfo, GetAchievementInfo = GetAchievementNumCriteria, GetAchievementCriteriaInfo, GetAchievementInfo
Nenue@40 17 local pairs, ipairs, tinsert, unpack, select = pairs, ipairs, tinsert, unpack, select
Nenue@40 18 local floor, mod, tostring, tonumber, GetSuperTrackedQuestID = floor, mod, tostring, tonumber, GetSuperTrackedQuestID
Nenue@33 19 local GameTooltip = GameTooltip
Nenue@33 20 local GetItemIcon = GetItemIcon
Nenue@7 21
Nenue@33 22 local print = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or function() end
Nenue@7 23 local qprint = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or function() end
Nenue@33 24 local wprint = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or function() end
Nenue@30 25 local wqprint = DEVIAN_WORKSPACE and function(...) _G.print('WorldQuests', ...) end or function() end
Nenue@7 26 local iprint = DEVIAN_WORKSPACE and function(...) _G.print('ItemScan', ...) end or function() end
Nenue@40 27 local rprint = DEVIAN_WORKSPACE and function(...) _G.print('WQRefresh', ...) end or function() end
Nenue@49 28 local dprint = DEVIAN_WORKSPACE and function(...) _G.print('WQData', ...) end or function() end
Nenue@7 29 local QuestPOI = WorldPlanPOIMixin
Nenue@7 30
Nenue@40 31
Nenue@40 32 local PIN_REFRESH_DELAY = .5
Nenue@54 33 local PIN_REQUEST_DELAY = .1
Nenue@9 34 local ICON_UNKNOWN = "Interface\\ICONS\\inv_misc_questionmark"
Nenue@9 35 local ICON_MONEY = "Interface\\Buttons\\UI-GroupLoot-Coin-Up"
Nenue@9 36
Nenue@40 37 local WORLD_QUEST_BORDER = "Interface\\UNITPOWERBARALT\\Generic1Target_Circular_Frame"
Nenue@47 38 local PENDING_BORDER = "Interface\\BUTTONS\\YELLOWORANGE64"
Nenue@40 39 local PENDING_ICON = "Interface\\BUTTONS\\YELLOWORANGE64"
Nenue@9 40
Nenue@29 41 local REWARD_CASH = WORLD_QUEST_REWARD_TYPE_FLAG_GOLD
Nenue@29 42 local REWARD_ARTIFACT_POWER = WORLD_QUEST_REWARD_TYPE_FLAG_ARTIFACT_POWER
Nenue@29 43 local REWARD_GEAR = WORLD_QUEST_REWARD_TYPE_FLAG_EQUIPMENT
Nenue@29 44 local REWARD_CURRENCY = WORLD_QUEST_REWARD_TYPE_FLAG_ORDER_RESOURCES
Nenue@29 45 local REWARD_REAGENT = WORLD_QUEST_REWARD_TYPE_FLAG_MATERIALS
Nenue@29 46
Nenue@29 47 local LE_QUEST_TAG_TYPE_PVP = LE_QUEST_TAG_TYPE_PVP
Nenue@29 48 local LE_QUEST_TAG_TYPE_PET_BATTLE = LE_QUEST_TAG_TYPE_PET_BATTLE
Nenue@29 49 local LE_QUEST_TAG_TYPE_DUNGEON = LE_QUEST_TAG_TYPE_DUNGEON
Nenue@29 50 local LE_QUEST_TAG_TYPE_PROFESSION = LE_QUEST_TAG_TYPE_PROFESSION
Nenue@29 51 local LE_QUEST_TAG_TYPE_NORMAL = LE_QUEST_TAG_TYPE_NORMAL
Nenue@29 52
Nenue@29 53 local LE_QUEST_TAG_TYPE_PVP = LE_QUEST_TAG_TYPE_PVP
Nenue@29 54 local LE_QUEST_TAG_TYPE_PET_BATTLE = LE_QUEST_TAG_TYPE_PET_BATTLE
Nenue@29 55 local LE_QUEST_TAG_TYPE_DUNGEON = LE_QUEST_TAG_TYPE_DUNGEON
Nenue@29 56 local LE_QUEST_TAG_TYPE_PROFESSION = LE_QUEST_TAG_TYPE_PROFESSION
Nenue@29 57 local LE_QUEST_TAG_TYPE_NORMAL = LE_QUEST_TAG_TYPE_NORMAL
Nenue@29 58
Nenue@40 59 local STYLE_TYPE_PENDING = 768
Nenue@40 60
Nenue@31 61
Nenue@29 62 -- Pin color/display variables
Nenue@40 63 db.TooltipExtras = db.TooltipExtras or {} -- idiot-proofing
Nenue@49 64 db.PinAlpha = 1
Nenue@29 65
Nenue@33 66 local familiars = {
Nenue@40 67 [42159] = 'Nightwatcher Merayl',
Nenue@40 68 [40277] = 'Tiffany Nelson',
Nenue@40 69 [40298] = 'Sir Galveston',
Nenue@40 70 [40282] = 'Grixis Tinypop',
Nenue@40 71 [40278] = 'Robert Craig',
Nenue@40 72 [48195] = 'Aulier',
Nenue@40 73 [41990] = 'Varenne',
Nenue@40 74 [41860] = 'Xorvasc',
Nenue@40 75 [40299] = 'Bodhi Sunwayver',
Nenue@40 76 [42442] = 'Amalia',
Nenue@40 77 [40280] = 'Bredda Tenderhide',
Nenue@40 78 [41687] = 'Odrogg',
Nenue@40 79 [41944] = 'Trapper Jarrun',
Nenue@40 80 [40337] = 'Master Tamer Flummox',
Nenue@40 81 [40279] = 'Durian Strongfruit'
Nenue@40 82 }
Nenue@40 83 local falcosaurs = {
Nenue@40 84 [44895] = {44881, 'Sharptalon Hatchling', 115786},
Nenue@40 85 [44894] = {44882, 'Bloodgazer Hatchling', 115787},
Nenue@40 86 [44893] = {44880, 'Direbeak Hatchling', 115785},
Nenue@40 87 [44892] = {44879, 'Snowfeather Hatchling', 115784},
Nenue@33 88 }
Nenue@33 89 local familiars_id = 9696
Nenue@40 90 for questID, name in pairs(familiars) do
Nenue@40 91 db.TooltipExtras[questID] = {{
Nenue@40 92 achievementID = familiars_id,
Nenue@40 93 name = name
Nenue@40 94 }}
Nenue@40 95 end
Nenue@40 96 for questID, info in pairs(falcosaurs) do
Nenue@40 97 local trackingQuestID, petName, petID = unpack(info)
Nenue@33 98
Nenue@40 99 db.TooltipExtras[questID] = {{
Nenue@40 100 questID = trackingQuestID,
Nenue@40 101 pet = petName,
Nenue@40 102 petID = petID
Nenue@40 103 }}
Nenue@9 104 end
Nenue@7 105
Nenue@40 106 local GetAchievementTooltipExtras = function(info)
Nenue@29 107
Nenue@40 108 local hasInfo
Nenue@40 109 local achievementID = info.achievementID
Nenue@40 110 local _, name, _, completed, _, _, _, _, _, icon = GetAchievementInfo(achievementID)
Nenue@40 111 if not completed then
Nenue@40 112
Nenue@40 113 local numItems = GetAchievementNumCriteria(achievementID)
Nenue@40 114 local numNeeded = 0
Nenue@40 115 local tooltipLines = {}
Nenue@40 116 for i =1, numItems do
Nenue@40 117 local criteriaName, criteriaType, completed, _, _, _, _, subAchievementID = GetAchievementCriteriaInfo(achievementID, i)
Nenue@49 118 --print(GetAchievementCriteriaInfo(achievementID, i))
Nenue@40 119
Nenue@40 120 if not completed then
Nenue@49 121 --print('::', criteriaName, completed, subAchievementID)
Nenue@40 122 if criteriaType == 8 then
Nenue@40 123 local _, _, _, completed, _, _, _, _, _, subIcon = GetAchievementInfo(subAchievementID)
Nenue@49 124 --print(' -', criteriaName, completed, subIcon)
Nenue@40 125 if not completed then
Nenue@40 126 local numCompleted = 0
Nenue@40 127 local numSubItems = GetAchievementNumCriteria(subAchievementID)
Nenue@40 128 local subCriteriaLine
Nenue@40 129 for j = 1, numSubItems do
Nenue@40 130 local subName, _, completed = GetAchievementCriteriaInfo(subAchievementID, j)
Nenue@40 131
Nenue@49 132 --print(' -',subName, completed)
Nenue@40 133 if completed then
Nenue@40 134 numCompleted = numCompleted + 1
Nenue@40 135 else
Nenue@40 136 numNeeded = numNeeded + 1
Nenue@40 137 if subName:match(info.name) then
Nenue@40 138 hasInfo = true
Nenue@40 139 subCriteriaLine = ' |T'..subIcon..':16:16|t ' .. criteriaName
Nenue@40 140 end
Nenue@40 141 end
Nenue@40 142
Nenue@40 143 end
Nenue@40 144 if subCriteriaLine then
Nenue@40 145 tinsert(tooltipLines, subCriteriaLine .. ' ('..numCompleted..'/'..numSubItems..')')
Nenue@40 146 end
Nenue@40 147 end
Nenue@40 148 elseif criteriaName:match(info.name) and (not completed) then
Nenue@40 149 numNeeded = numNeeded + 1
Nenue@40 150 tinsert(tooltipLines, criteriaName)
Nenue@40 151 end
Nenue@40 152 end
Nenue@40 153 end
Nenue@49 154 if hasInfo then
Nenue@49 155 WorldMapTooltip:AddLine(" ")
Nenue@49 156 WorldMapTooltip:AddLine("Achievements:")
Nenue@49 157 WorldMapTooltip:AddLine(' |T'..icon..':20:20|t '..name)
Nenue@40 158 for i, line in ipairs(tooltipLines) do
Nenue@40 159 WorldMapTooltip:AddLine(line)
Nenue@40 160 end
Nenue@40 161 end
Nenue@40 162 end
Nenue@40 163 return hasInfo
Nenue@40 164 end
Nenue@40 165
Nenue@40 166 local GetQuestTooltipExtras = function(info)
Nenue@40 167 local questID = info.questID
Nenue@40 168 local hasInfo
Nenue@40 169
Nenue@40 170 if info.pet then
Nenue@40 171 local index, guid = C_PetJournal.FindPetIDByName(info.pet)
Nenue@40 172 if not index then
Nenue@40 173 hasInfo = true
Nenue@40 174 WorldMapTooltip:AddLine('Pets:')
Nenue@40 175 WorldMapTooltip:AddLine(' - ' .. info.petName)
Nenue@40 176
Nenue@40 177 if not IsQuestFlaggedCompleted(questID) then
Nenue@40 178 WorldMapTooltip:AddLine(' Required Quest Flags', 1, 1, 0)
Nenue@40 179 else
Nenue@40 180 WorldMapTooltip:AddLine(' Quest Flags Complete!', 0, 1, 0)
Nenue@40 181 end
Nenue@40 182
Nenue@40 183 end
Nenue@29 184 end
Nenue@29 185
Nenue@29 186 end
Nenue@29 187
Nenue@40 188 local GetFactionInfoByID, GetQuestObjectiveInfo = GetFactionInfoByID, GetQuestObjectiveInfo
Nenue@40 189
Nenue@40 190 function QuestPOI:OnEnter()
Nenue@40 191 if not WorldMapFrame:IsVisible() then
Nenue@49 192 end
Nenue@49 193 if self.filtered then
Nenue@49 194 return
Nenue@7 195 end
Nenue@40 196 WorldMapTooltip:SetOwner(self, "ANCHOR_RIGHT");
Nenue@49 197 --print('doing tooltip stuff')
Nenue@40 198
Nenue@40 199 -- Can't add stuff after, so most of the blizzard tooltip hook is simply copied over
Nenue@40 200 local questID = self.questID
Nenue@40 201 local color = WORLD_QUEST_QUALITY_COLORS[self.rarity] or NORMAL_FONT_COLOR;
Nenue@40 202
Nenue@40 203
Nenue@40 204 WorldMapTooltip:SetText(self.title, color.r, color.g, color.b);
Nenue@40 205 QuestUtils_AddQuestTypeToTooltip(WorldMapTooltip, questID, NORMAL_FONT_COLOR);
Nenue@40 206
Nenue@40 207 if ( self.factionID ) then
Nenue@40 208 local factionName = GetFactionInfoByID(self.factionID);
Nenue@40 209 if ( factionName ) then
Nenue@40 210 if (self.capped) then
Nenue@40 211 WorldMapTooltip:AddLine(factionName, GRAY_FONT_COLOR:GetRGB());
Nenue@40 212 else
Nenue@40 213 WorldMapTooltip:AddLine(factionName);
Nenue@40 214 end
Nenue@40 215 end
Nenue@40 216 end
Nenue@40 217
Nenue@40 218 if self.worldQuest then
Nenue@40 219 WorldMap_AddQuestTimeToTooltip(questID);
Nenue@40 220 end
Nenue@40 221
Nenue@40 222
Nenue@40 223 for objectiveIndex = 1, self.numObjectives do
Nenue@40 224 local objectiveText, objectiveType, finished = GetQuestObjectiveInfo(questID, objectiveIndex, false);
Nenue@40 225 if ( objectiveText and #objectiveText > 0 ) then
Nenue@40 226 local color = finished and GRAY_FONT_COLOR or HIGHLIGHT_FONT_COLOR;
Nenue@40 227 WorldMapTooltip:AddLine(QUEST_DASH .. objectiveText, color.r, color.g, color.b, true);
Nenue@40 228 end
Nenue@40 229 end
Nenue@40 230
Nenue@40 231 local percent = C_TaskQuest.GetQuestProgressBarInfo(self.questID);
Nenue@40 232 if ( percent ) then
Nenue@40 233 GameTooltip_InsertFrame(WorldMapTooltip, WorldMapTaskTooltipStatusBar);
Nenue@40 234 WorldMapTaskTooltipStatusBar.Bar:SetValue(percent);
Nenue@40 235 WorldMapTaskTooltipStatusBar.Bar.Label:SetFormattedText(PERCENTAGE_STRING, percent);
Nenue@40 236 end
Nenue@40 237
Nenue@40 238 if db.TooltipExtras[self.questID] then
Nenue@40 239 for index, info in pairs(db.TooltipExtras[questID]) do
Nenue@40 240 if info.achievementID then
Nenue@40 241 GetAchievementTooltipExtras(info)
Nenue@40 242 end
Nenue@40 243 if info.questID then
Nenue@40 244 GetQuestTooltipExtras(info)
Nenue@40 245 end
Nenue@40 246 end
Nenue@40 247 end
Nenue@40 248 WorldMap_AddQuestRewardsToTooltip(questID)
Nenue@40 249
Nenue@40 250 self.MouseGlow:Show()
Nenue@40 251 WorldMapTooltip:Show()
Nenue@40 252 --WorldMapTooltip.recalculatePadding = true;
Nenue@40 253 --print(WorldMapTooltip:GetParent())
Nenue@40 254 --print(WorldMapTooltip:IsVisible())
Nenue@7 255 end
Nenue@40 256 function QuestPOI:OnLeave()
Nenue@35 257 WorldMap_RestoreTooltip()
Nenue@40 258 self.MouseGlow:Hide()
Nenue@40 259 WorldMapTooltip:Hide();
Nenue@7 260 end
Nenue@7 261
Nenue@40 262 -- attempt to pull pin data
Nenue@40 263 local GetQuestTagInfo, GetProfessionInfo = GetQuestTagInfo, GetProfessionInfo
Nenue@40 264 function QuestPOI:GetData ()
Nenue@49 265 dprint('|cFF00FF88'..self:GetID()..':GetData()|r')
Nenue@40 266 local questID = self.questID
Nenue@40 267 if not questID then
Nenue@49 268 dprint('|cFFFF4400bad pin|r', self:GetName())
Nenue@40 269 return nil
Nenue@29 270 end
Nenue@29 271
Nenue@40 272 local questTitle, factionID, capped = TQ_GetQuestInfoByQuestID(questID)
Nenue@40 273 -- if the title is nil, then wait and try later
Nenue@40 274 if not questTitle then
Nenue@54 275 if not self.isPending then
Nenue@54 276 C_TaskQuest.RequestPreloadRewardData(questID)
Nenue@54 277 self.isPending = true
Nenue@54 278 end
Nenue@49 279 dprint('|cFFBB8844isPending=true|r|cFF00FFFF', self.questId)
Nenue@40 280 else
Nenue@40 281 self.title, self.factionID, self.capped = questTitle, factionID, capped
Nenue@49 282 dprint('|cFFBB8844 data|r|cFF00FFFF', (self.isPending and '|cFFFF4400delayed|r' or '|cFF00FF00success|r'), self.title, '|r', self.factionID)
Nenue@49 283 if self.dataLoaded then
Nenue@49 284 dprint(' |cFFFF4400overwriting data|r')
Nenue@49 285 end
Nenue@49 286
Nenue@40 287 -- set tag details
Nenue@40 288 local worldQuestType
Nenue@40 289 self.tagID, self.tagName, worldQuestType, self.rarity, self.isElite, self.tradeskillLineIndex = GetQuestTagInfo(questID);
Nenue@40 290 local tagAtlas
Nenue@40 291 if worldQuestType == LE_QUEST_TAG_TYPE_PET_BATTLE then
Nenue@40 292 tagAtlas = "worldquest-icon-petbattle"
Nenue@40 293 elseif worldQuestType == LE_QUEST_TAG_TYPE_PVP then
Nenue@40 294 tagAtlas = "worldquest-icon-pvp-ffa"
Nenue@40 295 elseif worldQuestType == LE_QUEST_TAG_TYPE_PROFESSION then
Nenue@40 296 self.isKnownProfession = nil
Nenue@40 297 local id = self.tradeskillLineIndex and select(7, GetProfessionInfo(self.tradeskillLineIndex))
Nenue@40 298 if id then
Nenue@40 299 self.isKnownProfession = true
Nenue@40 300 qprint('profession' , self.title, id)
Nenue@40 301 tagAtlas = WORLD_QUEST_ICONS_BY_PROFESSION[id]
Nenue@40 302 end
Nenue@40 303 elseif worldQuestType == LE_QUEST_TAG_TYPE_DUNGEON then
Nenue@40 304 tagAtlas = "worldquest-icon-dungeon"
Nenue@40 305 end
Nenue@40 306 self.worldQuestType = worldQuestType
Nenue@40 307 self.tagAtlas = tagAtlas
Nenue@29 308
Nenue@40 309 self:SetRewardInfo()
Nenue@40 310
Nenue@40 311 -- force throttle on success
Nenue@40 312 --qprint(' |cFF00FFFF'..questID..'|r hasUpdate:', hasUpdate, 'isPending:', isPending, 'isShown', self:IsShown())
Nenue@40 313 --qprint(' ', 'rewardType:', self.rewardType, 'tag:', self.tagID)
Nenue@40 314 qprint(' ', tostring(self.title), " |T"..tostring(self.itemTexture)..":12:12|t", tostring(self.itemName))
Nenue@40 315
Nenue@40 316 if self.itemTexture and self.itemName and self.title then
Nenue@49 317 self.dataLoaded = true
Nenue@40 318 self.isPending = nil
Nenue@40 319 self.throttle = 1
Nenue@40 320 self.updateRate = PIN_REFRESH_DELAY
Nenue@48 321 self.isStale = true
Nenue@40 322 end
Nenue@40 323 end
Nenue@40 324
Nenue@40 325 self.isCriteria = WorldMapFrame.UIElementsFrame.BountyBoard:IsWorldQuestCriteriaForSelectedBounty(questID)
Nenue@40 326
Nenue@40 327 return self.isStale, self.isPending
Nenue@40 328 end
Nenue@40 329
Nenue@40 330 local GetNumQuestLogRewards, GetNumQuestLogRewardCurrencies, HaveQuestData = GetNumQuestLogRewards, GetNumQuestLogRewardCurrencies, HaveQuestData
Nenue@40 331 local GetQuestLogRewardMoney, GetQuestLogRewardCurrencyInfo, GetMoneyString = GetQuestLogRewardMoney, GetQuestLogRewardCurrencyInfo, GetMoneyString
Nenue@40 332 function QuestPOI:SetRewardInfo()
Nenue@40 333 local questID = self.questID
Nenue@29 334 if not HaveQuestData(questID) then
Nenue@40 335 self.isPending = true
Nenue@29 336 else
Nenue@29 337
Nenue@40 338 local rewardIcon, rewardName, rewardCount, rewardStyle, rewardType, itemID, quantity, quality
Nenue@29 339 -- set reward category
Nenue@29 340 local numRewards = GetNumQuestLogRewards(questID)
Nenue@29 341 local numCurrency = GetNumQuestLogRewardCurrencies(questID)
Nenue@29 342 local money = GetQuestLogRewardMoney(questID)
Nenue@29 343 if numRewards >= 1 then
Nenue@40 344 rewardType, rewardIcon, rewardCount, rewardName, itemID, quality = WorldPlanQuests:GetRewardHeader(questID)
Nenue@29 345 elseif numCurrency >= 1 then
Nenue@29 346 rewardName, rewardIcon, rewardCount = GetQuestLogRewardCurrencyInfo(1, questID)
Nenue@29 347 rewardType = REWARD_CURRENCY
Nenue@29 348 elseif money >= 1 then
Nenue@29 349 rewardIcon = ICON_MONEY
Nenue@29 350 rewardName = GetMoneyString(money)
Nenue@29 351 rewardType = REWARD_CASH
Nenue@29 352 end
Nenue@29 353
Nenue@49 354 qprint(' '..self.questID..':|cFFFFFF00SetRewardInfo():', numRewards, rewardType)
Nenue@40 355 self.itemNumber = tonumber(rewardCount or self.itemNumber)
Nenue@49 356 self.rewardType = rewardType
Nenue@31 357 self.quality = quality
Nenue@29 358
Nenue@40 359 self.itemTexture = rewardIcon or self.itemTexture
Nenue@40 360 self.itemName = rewardName or self.itemName
Nenue@29 361
Nenue@29 362 -- flag unresolved info
Nenue@29 363 if not (rewardIcon and rewardName) then
Nenue@40 364 self.isPending = true
Nenue@48 365 self.isStale = nil
Nenue@29 366 --WorldPlan:print('|cFFFFFF00'..tostring(self.title)..'|r waiting on texture info')
Nenue@29 367 else
Nenue@40 368 if (rewardIcon and rewardName) and self.isPending then
Nenue@29 369 --WorldPlan:print('|cFF00FF00'..tostring(self.title)..'|r has info', rewardIcon, rewardName)
Nenue@40 370 self.isStale = true
Nenue@29 371 end
Nenue@40 372 self.isPending = nil
Nenue@29 373 end
Nenue@29 374
Nenue@40 375 end
Nenue@7 376 end
Nenue@7 377
Nenue@34 378 -- run from OnShow if .isNew is set
Nenue@34 379
Nenue@49 380 function QuestPOI:StartFade()
Nenue@34 381 if not self.isAnimating then
Nenue@35 382 --qprint('|cFFFFFF00'.. self.title .. ' added to quest log.')
Nenue@35 383 self:SetAlpha(0)
Nenue@49 384 self.FadeIn.FadeIn:SetToAlpha(db.PinAlpha)
Nenue@49 385 self.PendingFade.FadeIn:SetToAlpha(db.PinAlpha)
Nenue@49 386 self.PendingFade.FadeOut:SetFromAlpha(db.PinAlpha)
Nenue@49 387
Nenue@34 388 self.isAnimating = true
Nenue@35 389 self.isNew = nil
Nenue@40 390 self.isStale = true
Nenue@35 391 self.FadeIn:Play()
Nenue@34 392 end
Nenue@7 393 end
Nenue@7 394
Nenue@49 395 function QuestPOI:EndFade()
Nenue@49 396 self.isAnimating = nil
Nenue@49 397 self:SetAlpha(db.PinAlpha)
Nenue@49 398 end
Nenue@49 399
Nenue@40 400 function QuestPOI:OnShow ()
Nenue@27 401
Nenue@49 402 if self.isStale then
Nenue@49 403 qprint('|cFF0088FFflagged for refresh')
Nenue@48 404 self:Refresh()
Nenue@48 405 end
Nenue@34 406
Nenue@54 407 if self.isNew or (not self.Overlay:IsShown()) then
Nenue@54 408 qprint('|cFFFFFF00'..tostring(self:GetName())..':OnShow()|r update:', self.isStale, 'new:', self.isNew, 'animation:', self.isAnimating)
Nenue@54 409 --qprint('|cFFFFFF00popping new pin handler')
Nenue@49 410 self:StartFade()
Nenue@49 411 end
Nenue@49 412
Nenue@54 413 if not self.isAnimating then
Nenue@54 414 self:SetAlpha(1) -- fix stuck alpha
Nenue@54 415 end
Nenue@49 416 self.Overlay:SetShown(true)
Nenue@27 417 end
Nenue@40 418 function QuestPOI:OnHide()
Nenue@49 419 qprint('|cFFFFFF00'..self:GetID()..'r:OnHide()')
Nenue@49 420 self.isAnimating = nil
Nenue@49 421 self:SetAlpha(db.PinAlpha)
Nenue@36 422 self.Overlay:SetShown(false)
Nenue@27 423 end
Nenue@27 424
Nenue@49 425 local overlayBaseIndex = 1300
Nenue@52 426 function QuestPOI:SetAnchor(owner, dX, dY, mapWidth, mapHeight)
Nenue@54 427 wqprint(self:GetName()..':SetAnchor', self.filtered, self.used)
Nenue@52 428 self:SetParent(owner)
Nenue@49 429 self:ClearAllPoints()
Nenue@54 430 self:SetFrameLevel(overlayBaseIndex + self:GetID())
Nenue@53 431 self.Overlay:SetParent(owner)
Nenue@53 432 self.Overlay:SetFrameLevel(overlayBaseIndex + self:GetID())
Nenue@53 433 if (dX and dY) then
Nenue@53 434 if not (mapHeight and mapWidth) then
Nenue@53 435 mapWidth, mapHeight = owner:GetSize()
Nenue@53 436 end
Nenue@53 437 local pX = (dX * mapWidth)
Nenue@53 438 local pY = (-dY * mapHeight)
Nenue@53 439 self.x = dX
Nenue@53 440 self.y = dY
Nenue@53 441 self:SetPoint('CENTER', owner, 'TOPLEFT', pX, pY)
Nenue@53 442 else
Nenue@53 443 self:SetPoint('CENTER')
Nenue@53 444 end
Nenue@49 445 self:SetShown(self.used)
Nenue@7 446 end
Nenue@7 447
Nenue@40 448 function QuestPOI:OnLoad()
Nenue@40 449 qprint('|cFF00FF88'..self:GetName()..':OnLoad()|r',db.Config)
Nenue@7 450 self:RegisterEvent('SUPER_TRACKED_QUEST_CHANGED')
Nenue@36 451
Nenue@40 452 self.title = '|cFF0088FF' .. RETRIEVING_DATA..'|r'
Nenue@40 453 self.isPending = true
Nenue@36 454 self.count = self.Overlay.count
Nenue@54 455 self.Description = self.Overlay.Description
Nenue@36 456 self.timeLabel = self.Overlay.timeLabel
Nenue@40 457 self.updateRate = PIN_REQUEST_DELAY
Nenue@40 458 self.itemName = '|cFF0088FF' .. RETRIEVING_DATA..'|r'
Nenue@41 459
Nenue@41 460 self:SetScript('OnMouseDown', TaskPOI_OnClick)
Nenue@53 461
Nenue@53 462 self.Overlay:SetPoint('TOPLEFT', self, 'TOPLEFT', 0, 4)
Nenue@53 463 self.Overlay:SetPoint('BOTTOMRIGHT', self, 'BOTTOMRIGHT', 0, -4)
Nenue@7 464 end
Nenue@7 465
Nenue@40 466 function QuestPOI:OnEvent(event, ...)
Nenue@7 467 if event == 'SUPER_TRACKED_QUEST_CHANGED' then
Nenue@33 468 self.isStale = true
Nenue@7 469 end
Nenue@7 470 end
Nenue@7 471
Nenue@40 472 function QuestPOI:OnUpdate (sinceLast)
Nenue@40 473 -- control update check intervals
Nenue@40 474 self.throttle = (self.throttle or self.updateRate) + sinceLast
Nenue@40 475 if self.throttle >= self.updateRate then
Nenue@40 476 -- factor overtime into the throttle timer
Nenue@40 477 self.throttle = self.throttle - self.updateRate
Nenue@40 478 else
Nenue@40 479 return
Nenue@40 480 end
Nenue@35 481 if self.isNew then
Nenue@35 482 print('|cFFFFFF00push new poi stuff')
Nenue@35 483 self:OnNew()
Nenue@40 484 elseif (self.isStale or (not self.title)) and not self.isAnimating then
Nenue@36 485 wprint('|cFFFFFF00push poi update')
Nenue@35 486 self:Refresh()
Nenue@35 487 return
Nenue@35 488 end
Nenue@7 489
Nenue@7 490 -- query for reward data if it wasn't found in the original scan
Nenue@7 491 local questID = self.questID
Nenue@7 492 if self.isPending then
Nenue@49 493 print('|cFFFF4400'..self:GetID()..':|r polling reward info')
Nenue@49 494 if not (self.isAnimating) then
Nenue@7 495 self.PendingFade:Play()
Nenue@7 496 end
Nenue@49 497 self:GetData()
Nenue@7 498 return
Nenue@7 499 else
Nenue@7 500 if self.PendingFade:IsPlaying() then
Nenue@7 501 self.PendingFade:Stop()
Nenue@7 502 end
Nenue@7 503 end
Nenue@7 504
Nenue@7 505
Nenue@7 506 -- update time elements
Nenue@40 507 if TQ_IsActive(self.questID) then
Nenue@40 508
Nenue@40 509 local tl = self.alertLevel
Nenue@40 510 local timeLeft = TQ_GetQuestTimeLeftMinutes(questID)
Nenue@40 511 if timeLeft > 0 then
Nenue@40 512
Nenue@40 513 local text, timeState = WorldPlan:GetTimeInfo(timeLeft, self.maxAlertLevel)
Nenue@40 514 if tl ~= timeState then
Nenue@40 515 tl = timeState
Nenue@40 516 self.timeLabel:SetText(text)
Nenue@40 517 end
Nenue@40 518 else
Nenue@9 519 if self.worldQuestType ~= LE_QUEST_TAG_TYPE_PROFESSION then
Nenue@40 520 self:SetShown(false)
Nenue@9 521 end
Nenue@7 522 end
Nenue@40 523 self.alertLevel = tl
Nenue@7 524 end
Nenue@40 525 self.timeLabel:SetShown(self.worldQuest and (self.maxAlertLevel >= 1))
Nenue@8 526 end
Nenue@8 527
Nenue@8 528
Nenue@9 529
Nenue@49 530 function QuestPOI:Refresh (fromUser)
Nenue@49 531
Nenue@49 532 --rprint('|c'..(fromUser and 'FF0088FF' or 'FF00FF88' )..self:GetID()..'|r:Refresh() type =', self.rewardType, 'title =', self.title)
Nenue@49 533
Nenue@49 534
Nenue@9 535
Nenue@40 536 local styleType = (self.isPending and STYLE_TYPE_PENDING) or self.rewardType
Nenue@40 537 local style,subStyle = self:GetTypeInfo(self.rewardType)
Nenue@52 538 if (self.filtered or (not self.dataLoaded)) and (self.questID ~= GetSuperTrackedQuestID()) then
Nenue@40 539 subStyle = style.minimized
Nenue@40 540 end
Nenue@40 541 self.style = style
Nenue@40 542 self.subStyle = subStyle
Nenue@40 543 --print(style, subStyle)
Nenue@40 544 self.currentWidth = subStyle.iconWidth
Nenue@40 545 self.borderWidth = subStyle.borderWidth
Nenue@40 546 self.highlightWidth = subStyle.highlightWidth
Nenue@40 547 self.tagSize = subStyle.TagSize
Nenue@40 548 self.maxAlertLevel = subStyle.maxAlertLevel
Nenue@40 549 self.NoIcon = subStyle.NoIcon
Nenue@9 550
Nenue@29 551 local questID = self:GetID()
Nenue@36 552 local iconBorder = self.RewardBorder
Nenue@36 553 local trackingBorder = self.HighlightBorder
Nenue@9 554 local icon = self.icon
Nenue@9 555 local count = self.count
Nenue@52 556 local isBounty = WorldMapFrame.UIElementsFrame.BountyBoard:IsWorldQuestCriteriaForSelectedBounty(self.questID)
Nenue@36 557
Nenue@9 558 if self.itemName then
Nenue@45 559
Nenue@54 560 if self.itemNumber then
Nenue@54 561 local numberString = self.itemNumber
Nenue@54 562 if self.itemNumber >= 1000 then
Nenue@54 563 local numeral = floor(self.itemNumber/1000)
Nenue@54 564 local decimal = mod(self.itemNumber, 1000)
Nenue@54 565 numberString = numeral
Nenue@54 566 if decimal > 100 then
Nenue@54 567 numberString = numberString .. '.' .. tostring(floor(decimal/100))
Nenue@54 568 end
Nenue@54 569 numberString = numberString .. 'k'
Nenue@40 570 end
Nenue@45 571 self.count:SetText(numberString)
Nenue@45 572 else
Nenue@54 573 self.count:SetText(nil)
Nenue@45 574 end
Nenue@54 575 end
Nenue@30 576
Nenue@54 577 self.Description:SetText(self.title .. "\n" .. floor(self.x*100+.5) .. "," .. floor(self.y*100+.5))
Nenue@40 578
Nenue@40 579 icon:SetMask("Interface\\Minimap\\UI-Minimap-Background")
Nenue@36 580 if self.itemTexture then
Nenue@47 581 --iconBorder:SetTexture(WORLD_QUEST_BORDER)
Nenue@40 582
Nenue@40 583 if self.NoIcon then
Nenue@40 584 icon:SetTexture(PENDING_ICON)
Nenue@40 585 icon:SetDesaturated(true)
Nenue@47 586 icon:SetVertexColor(style.r, style.g, style.b)
Nenue@40 587 else
Nenue@40 588
Nenue@40 589 icon:SetTexture(self.itemTexture)
Nenue@40 590 icon:SetDesaturated(false)
Nenue@40 591 icon:SetVertexColor(1, 1, 1)
Nenue@40 592 end
Nenue@40 593 else
Nenue@47 594 --
Nenue@40 595 icon:SetTexture(PENDING_ICON)
Nenue@40 596 icon:SetDesaturated(true)
Nenue@47 597 icon:SetVertexColor(style.r, style.g, style.b)
Nenue@9 598 end
Nenue@9 599
Nenue@47 600 iconBorder:SetMask("Interface\\Minimap\\UI-Minimap-Background")
Nenue@47 601 iconBorder:SetTexture(PENDING_BORDER)
Nenue@54 602 iconBorder:SetVertexColor(style.r, style.g, style.b, 1)
Nenue@52 603
Nenue@9 604 iconBorder:SetDesaturated(true)
Nenue@40 605 iconBorder:SetAlpha(subStyle.alpha or 1)
Nenue@9 606
Nenue@47 607 trackingBorder:SetMask("Interface\\Minimap\\UI-Minimap-Background")
Nenue@47 608 trackingBorder:SetTexture(PENDING_BORDER)
Nenue@54 609 if isBounty then
Nenue@54 610 trackingBorder:SetVertexColor(.25,.5,1)
Nenue@54 611 else
Nenue@54 612 trackingBorder:SetVertexColor(0,0,0,1)
Nenue@54 613 end
Nenue@9 614
Nenue@49 615 self.tagIcon:SetShown((not self.filtered) and true or false)
Nenue@9 616 self.tagIcon:SetAtlas(self.tagAtlas)
Nenue@49 617
Nenue@47 618 self.EliteBorder:SetShown(self.isElite and not self.filtered)
Nenue@36 619
Nenue@9 620
Nenue@9 621 self:UpdateSize()
Nenue@33 622 self.isStale = nil
Nenue@9 623 end
Nenue@9 624
Nenue@35 625 local cvar_check = {
Nenue@35 626 [REWARD_CASH] = 'worldQuestFilterGold',
Nenue@35 627 [REWARD_ARTIFACT_POWER] = 'worldQuestFilterArtifactPower',
Nenue@35 628 [REWARD_CURRENCY] = 'worldQuestFilterOrderResources',
Nenue@35 629 [REWARD_REAGENT]= 'worldQuestFilterProfessionMaterials',
Nenue@35 630 [REWARD_GEAR] = 'worldQuestFilterEquipment',
Nenue@35 631 }
Nenue@8 632
Nenue@33 633
Nenue@40 634 function QuestPOI:IsFiltered ()
Nenue@41 635 local filtered
Nenue@41 636 local usingFilters
Nenue@40 637 for filterKey, value in pairs(db.UsedFilters) do
Nenue@41 638 usingFilters = true
Nenue@40 639 print('|cFFFF4400', filterKey, self[filterKey])
Nenue@40 640 if self[filterKey] ~= value then
Nenue@41 641 filtered = true
Nenue@40 642 end
Nenue@40 643 end
Nenue@40 644 if self.rewardType and cvar_check[self.rewardType] then
Nenue@41 645 if not GetCVarBool(cvar_check[self.rewardType]) then
Nenue@41 646 filtered = true
Nenue@40 647 end
Nenue@40 648 end
Nenue@49 649 self.filtered = filtered
Nenue@40 650 end
Nenue@40 651
Nenue@33 652 function QuestPOI:IsShowable ()
Nenue@36 653 local print = qprint
Nenue@33 654 local qType = self.worldQuestType
Nenue@33 655
Nenue@40 656 if not self.worldQuest then
Nenue@49 657 --print('ignoring showable check')
Nenue@40 658 return self.used, self.filtered
Nenue@40 659 end
Nenue@40 660 self.used = TQ_IsActive(self.questID)
Nenue@52 661 if SpellCanTargetQuest() then
Nenue@52 662 -- hiding so player can click a valid target
Nenue@52 663 self.used = nil
Nenue@52 664 elseif qType == LE_QUEST_TAG_TYPE_PROFESSION then
Nenue@40 665 if (not self.isKnownProfession) and (db.Config.ShowAllProfessionQuests == false) then
Nenue@40 666 self.used = nil
Nenue@36 667 end
Nenue@36 668 end
Nenue@49 669 rprint(' '..self.questID..':|cFFFFFF00IsShowable()|r ', self.used, self.title)
Nenue@33 670 end
Nenue@33 671
Nenue@33 672 --- Fixes icons upon size update
Nenue@36 673 function QuestPOI:UpdateSize ()
Nenue@33 674
Nenue@49 675 --qprint('|cFF00BB88'..self:GetID()..'|r:UpdateSize()', self.style, self.subStyle)
Nenue@33 676
Nenue@40 677 local style = self.style
Nenue@40 678 local subStyle = self.subStyle
Nenue@36 679 local icon = self.icon
Nenue@36 680 local iconBorder = self.RewardBorder
Nenue@36 681 local trackingBorder = self.HighlightBorder
Nenue@36 682 local tag = self.tagIcon
Nenue@33 683
Nenue@36 684 local iconWidth = subStyle.iconWidth
Nenue@36 685 local borderWidth = iconWidth + (subStyle.borderWidth * 2)
Nenue@36 686 local highlightWidth = borderWidth + (subStyle.highlightWidth * 2)
Nenue@36 687 local iconTexture = self.itemTexture
Nenue@33 688
Nenue@47 689
Nenue@47 690 if self.questID == GetSuperTrackedQuestID() then
Nenue@47 691 highlightWidth = highlightWidth + 2
Nenue@47 692 end
Nenue@47 693
Nenue@47 694 if self.rarity and WORLD_QUEST_QUALITY_COLORS[self.rarity] then
Nenue@47 695 highlightWidth = highlightWidth + self.rarity
Nenue@47 696 end
Nenue@40 697 self.tagIcon:SetSize(self.tagSize, self.tagSize)
Nenue@36 698 self:SetSize(iconWidth, iconWidth)
Nenue@36 699 icon:SetSize(iconWidth, iconWidth)
Nenue@36 700 iconBorder:SetSize(borderWidth, borderWidth)
Nenue@36 701 trackingBorder:SetSize(highlightWidth, highlightWidth)
Nenue@33 702
Nenue@36 703
Nenue@36 704 iconBorder:SetPoint('CENTER', (style.x or 0), (style.y or 0))
Nenue@36 705 trackingBorder:SetPoint('CENTER', (style.x or 0), (style.y or 0))
Nenue@36 706
Nenue@36 707
Nenue@36 708 if style.hasNumeric then
Nenue@36 709 self.count:SetTextColor(unpack(style.numberRGB))
Nenue@36 710 if subStyle.numberFontObject then
Nenue@36 711 --wqprint('change font', _G[subStyle.numberFontObject]:GetName())
Nenue@36 712 self.count:SetFontObject(_G[subStyle.numberFontObject])
Nenue@36 713 end
Nenue@33 714 end
Nenue@33 715
Nenue@36 716 self.count:SetShown((subStyle.showNumber and self.itemNumber) and style.hasNumeric)
Nenue@33 717
Nenue@36 718
Nenue@7 719 end