annotate QuestPOI.lua @ 64:876c3f0bfd0e

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