annotate QuestPOI.lua @ 59:bc09961d5a98

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