annotate QuestPOI.lua @ 47:733785e306a3

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