annotate QuestPOI.lua @ 73:25f7dbc20a72

fix WorldMapTooltip getting stranded when flightmap is closed - quests that are not valid spell targets will have their icon go red - auto-complete scrolls will no longer hide pin frames; instead they become click through and blizzard POIs are activated beneath for taint-free interaction
author Nenue
date Fri, 07 Apr 2017 07:20:28 -0400
parents 6db0b9696936
children 2ba11b25aa7f
rev   line source
Nenue@7 1 -- WorldPlan
Nenue@7 2 -- QuestPOI.lua
Nenue@7 3 -- Created: 10/1/2016 7:21 PM
Nenue@7 4 -- %file-revision%
Nenue@65 5 -- Big TODOs:
Nenue@65 6 -- -- generate frames using `WorldMap_GetOrCreateTaskPOI' to remove tainting issues
Nenue@7 7 --
Nenue@40 8 local _, db = ...
Nick@64 9 local TQ_GetQuestInfoByQuestID = C_TaskQuest.GetQuestInfoByQuestID
Nenue@7 10 local TQ_GetQuestLocation = C_TaskQuest.GetQuestLocation
Nenue@7 11 local TQ_GetQuestTimeLeftMinutes = C_TaskQuest.GetQuestTimeLeftMinutes
Nenue@9 12 local TQ_IsActive = C_TaskQuest.IsActive
Nenue@29 13 local TQ_RequestPreloadRewardData = C_TaskQuest.RequestPreloadRewardData
Nenue@7 14 local QuestPOIGetIconInfo, WorldMapPOIFrame = QuestPOIGetIconInfo, WorldMapPOIFrame
Nenue@33 15 local WorldMap_DoesWorldQuestInfoPassFilters = WorldMap_DoesWorldQuestInfoPassFilters
Nenue@33 16 local QuestMapFrame_IsQuestWorldQuest = QuestMapFrame_IsQuestWorldQuest
Nenue@40 17 local GetAchievementNumCriteria, GetAchievementCriteriaInfo, GetAchievementInfo = GetAchievementNumCriteria, GetAchievementCriteriaInfo, GetAchievementInfo
Nick@64 18
Nick@64 19 local IsQuestFlaggedCompleted = IsQuestFlaggedCompleted
Nick@64 20 local GetFactionInfoByID, GetQuestObjectiveInfo = GetFactionInfoByID, GetQuestObjectiveInfo
Nick@64 21 local GetQuestTagInfo, GetProfessionInfo = GetQuestTagInfo, GetProfessionInfo
Nick@64 22 local GetNumQuestLogRewards, GetNumQuestLogRewardCurrencies, HaveQuestData = GetNumQuestLogRewards, GetNumQuestLogRewardCurrencies, HaveQuestData
Nick@64 23 local GetQuestLogRewardMoney, GetQuestLogRewardCurrencyInfo, GetMoneyString = GetQuestLogRewardMoney, GetQuestLogRewardCurrencyInfo, GetMoneyString
Nick@64 24 local SpellCanTargetQuest, GetCVarBool = SpellCanTargetQuest, GetCVarBool
Nick@64 25 local SetSuperTrackedQuestID = SetSuperTrackedQuestID
Nenue@65 26 local HaveQuestRewardData = HaveQuestRewardData
Nenue@65 27
Nick@64 28
Nenue@40 29 local pairs, ipairs, tinsert, unpack, select = pairs, ipairs, tinsert, unpack, select
Nenue@40 30 local floor, mod, tostring, tonumber, GetSuperTrackedQuestID = floor, mod, tostring, tonumber, GetSuperTrackedQuestID
Nenue@33 31 local GameTooltip = GameTooltip
Nenue@33 32 local GetItemIcon = GetItemIcon
Nenue@7 33
Nenue@67 34 local print = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or nop
Nenue@67 35 local qprint = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or nop
Nenue@67 36 local wprint = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or nop
Nenue@67 37 local wqprint = DEVIAN_WORKSPACE and function(...) _G.print('WorldQuests', ...) end or nop
Nenue@67 38 local iprint = DEVIAN_WORKSPACE and function(...) _G.print('ItemScan', ...) end or nop
Nenue@67 39 local rprint = DEVIAN_WORKSPACE and function(...) _G.print('WQRefresh', ...) end or nop
Nenue@67 40 local dprint = DEVIAN_WORKSPACE and function(...) _G.print('WQData', ...) end or nop
Nenue@7 41 local QuestPOI = WorldPlanPOIMixin
Nenue@7 42
Nenue@73 43 local pinBaseIndex = 1500
Nenue@73 44 local overlayBaseIndex = 1580
Nenue@56 45 local previousHighlight
Nenue@40 46
Nenue@67 47 local DATA_DEBUG = false
Nenue@40 48 local PIN_REFRESH_DELAY = .5
Nenue@54 49 local PIN_REQUEST_DELAY = .1
Nenue@9 50 local ICON_UNKNOWN = "Interface\\ICONS\\inv_misc_questionmark"
Nenue@9 51 local ICON_MONEY = "Interface\\Buttons\\UI-GroupLoot-Coin-Up"
Nenue@9 52
Nenue@40 53 local WORLD_QUEST_BORDER = "Interface\\UNITPOWERBARALT\\Generic1Target_Circular_Frame"
Nenue@47 54 local PENDING_BORDER = "Interface\\BUTTONS\\YELLOWORANGE64"
Nenue@40 55 local PENDING_ICON = "Interface\\BUTTONS\\YELLOWORANGE64"
Nenue@9 56
Nenue@29 57 local REWARD_CASH = WORLD_QUEST_REWARD_TYPE_FLAG_GOLD
Nenue@29 58 local REWARD_ARTIFACT_POWER = WORLD_QUEST_REWARD_TYPE_FLAG_ARTIFACT_POWER
Nenue@29 59 local REWARD_GEAR = WORLD_QUEST_REWARD_TYPE_FLAG_EQUIPMENT
Nenue@29 60 local REWARD_CURRENCY = WORLD_QUEST_REWARD_TYPE_FLAG_ORDER_RESOURCES
Nenue@29 61 local REWARD_REAGENT = WORLD_QUEST_REWARD_TYPE_FLAG_MATERIALS
Nenue@69 62
Nenue@69 63 local REWARD_TYPE_NAMES = {
Nenue@69 64 [REWARD_CASH] = 'Money',
Nenue@69 65 [REWARD_ARTIFACT_POWER] = 'AP',
Nenue@69 66 [REWARD_GEAR] = 'Equipment',
Nenue@69 67 [REWARD_CURRENCY] = 'Currency',
Nenue@69 68 [REWARD_REAGENT] = 'Trade Goods'
Nenue@69 69 }
Nenue@29 70
Nenue@29 71 local LE_QUEST_TAG_TYPE_PVP = LE_QUEST_TAG_TYPE_PVP
Nenue@29 72 local LE_QUEST_TAG_TYPE_PET_BATTLE = LE_QUEST_TAG_TYPE_PET_BATTLE
Nenue@29 73 local LE_QUEST_TAG_TYPE_DUNGEON = LE_QUEST_TAG_TYPE_DUNGEON
Nenue@29 74 local LE_QUEST_TAG_TYPE_PROFESSION = LE_QUEST_TAG_TYPE_PROFESSION
Nenue@29 75 local LE_QUEST_TAG_TYPE_NORMAL = LE_QUEST_TAG_TYPE_NORMAL
Nenue@29 76
Nenue@29 77 local LE_QUEST_TAG_TYPE_PVP = LE_QUEST_TAG_TYPE_PVP
Nenue@29 78 local LE_QUEST_TAG_TYPE_PET_BATTLE = LE_QUEST_TAG_TYPE_PET_BATTLE
Nenue@29 79 local LE_QUEST_TAG_TYPE_DUNGEON = LE_QUEST_TAG_TYPE_DUNGEON
Nenue@29 80 local LE_QUEST_TAG_TYPE_PROFESSION = LE_QUEST_TAG_TYPE_PROFESSION
Nenue@29 81 local LE_QUEST_TAG_TYPE_NORMAL = LE_QUEST_TAG_TYPE_NORMAL
Nenue@29 82
Nenue@66 83 local DEFAULT_STYLE = {
Nenue@66 84 border = {1,1,1},
Nenue@69 85 textColor = {1,1,1,1},
Nenue@66 86 x = 0, y = 0,
Nenue@66 87 desaturated = true,
Nenue@66 88 iconMask = "Interface\\Minimap\\UI-Minimap-Background",
Nenue@66 89 borderMask = "Interface\\Minimap\\UI-Minimap-Background",
Nenue@66 90 rewardMark = "Interface\\Minimap\\UI-Minimap-Background",
Nenue@66 91 scaleFactors = {0.25, 0.7, 1},
Nenue@66 92 iconWidth = 18,
Nenue@66 93 borderWidth = 2,
Nenue@66 94 highlightWidth = 2,
Nenue@66 95 TagSize = 8,
Nenue@66 96 maxAlertLevel = 0,
Nenue@66 97 numberFontObject = 'WorldPlanFont'
Nenue@66 98 }
Nenue@66 99 local MINIMIZED_STYLE = {
Nenue@66 100 hideNumber = true,
Nenue@66 101 hideIcon = true,
Nenue@67 102 iconWidth = 3,
Nenue@66 103 }
Nenue@66 104 local REWARD_TYPE_STYLES = {
Nenue@66 105 [REWARD_CASH] = {
Nenue@66 106 border = {1,1,0},
Nenue@66 107 hideNumber = true,
Nenue@66 108 },
Nenue@66 109 [REWARD_ARTIFACT_POWER] = {},
Nenue@66 110 [REWARD_GEAR] = {
Nenue@66 111
Nenue@66 112 hideNumber = true,
Nenue@66 113 },
Nenue@69 114 [REWARD_CURRENCY] = {
Nenue@69 115 textColor = {1,1,0,.5}
Nenue@69 116 },
Nenue@66 117 [REWARD_REAGENT] = {
Nenue@66 118
Nenue@66 119 hideNumber = true,
Nenue@66 120 },
Nenue@66 121 }
Nenue@66 122
Nenue@65 123 local LE_ITEM_CLASS_WEAPON, LE_ITEM_CLASS_ARMOR, LE_ITEM_CLASS_GEM, LE_ITEM_GEM_ARTIFACTRELIC, LE_ITEM_CLASS_TRADEGOODS = LE_ITEM_CLASS_WEAPON, LE_ITEM_CLASS_ARMOR, LE_ITEM_CLASS_GEM, LE_ITEM_GEM_ARTIFACTRELIC, LE_ITEM_CLASS_TRADEGOODS
Nenue@65 124
Nenue@65 125
Nenue@40 126 local STYLE_TYPE_PENDING = 768
Nenue@40 127
Nenue@31 128
Nenue@29 129 -- Pin color/display variables
Nenue@40 130 db.TooltipExtras = db.TooltipExtras or {} -- idiot-proofing
Nenue@49 131 db.PinAlpha = 1
Nenue@29 132
Nenue@33 133 local familiars = {
Nenue@40 134 [42159] = 'Nightwatcher Merayl',
Nenue@40 135 [40277] = 'Tiffany Nelson',
Nenue@40 136 [40298] = 'Sir Galveston',
Nenue@40 137 [40282] = 'Grixis Tinypop',
Nenue@40 138 [40278] = 'Robert Craig',
Nenue@40 139 [48195] = 'Aulier',
Nenue@40 140 [41990] = 'Varenne',
Nenue@40 141 [41860] = 'Xorvasc',
Nenue@40 142 [40299] = 'Bodhi Sunwayver',
Nenue@40 143 [42442] = 'Amalia',
Nenue@40 144 [40280] = 'Bredda Tenderhide',
Nenue@40 145 [41687] = 'Odrogg',
Nenue@40 146 [41944] = 'Trapper Jarrun',
Nenue@40 147 [40337] = 'Master Tamer Flummox',
Nenue@40 148 [40279] = 'Durian Strongfruit'
Nenue@40 149 }
Nenue@40 150 local falcosaurs = {
Nenue@40 151 [44895] = {44881, 'Sharptalon Hatchling', 115786},
Nenue@40 152 [44894] = {44882, 'Bloodgazer Hatchling', 115787},
Nenue@40 153 [44893] = {44880, 'Direbeak Hatchling', 115785},
Nenue@40 154 [44892] = {44879, 'Snowfeather Hatchling', 115784},
Nenue@33 155 }
Nenue@33 156 local familiars_id = 9696
Nenue@40 157 for questID, name in pairs(familiars) do
Nenue@40 158 db.TooltipExtras[questID] = {{
Nenue@40 159 achievementID = familiars_id,
Nenue@40 160 name = name
Nenue@40 161 }}
Nenue@40 162 end
Nenue@40 163 for questID, info in pairs(falcosaurs) do
Nenue@40 164 local trackingQuestID, petName, petID = unpack(info)
Nenue@33 165
Nenue@40 166 db.TooltipExtras[questID] = {{
Nenue@40 167 questID = trackingQuestID,
Nenue@40 168 pet = petName,
Nenue@40 169 petID = petID
Nenue@40 170 }}
Nenue@9 171 end
Nenue@7 172
Nenue@40 173 local GetAchievementTooltipExtras = function(info)
Nenue@29 174
Nenue@40 175 local hasInfo
Nenue@40 176 local achievementID = info.achievementID
Nenue@40 177 local _, name, _, completed, _, _, _, _, _, icon = GetAchievementInfo(achievementID)
Nenue@40 178 if not completed then
Nenue@40 179
Nenue@40 180 local numItems = GetAchievementNumCriteria(achievementID)
Nenue@40 181 local numNeeded = 0
Nenue@40 182 local tooltipLines = {}
Nenue@40 183 for i =1, numItems do
Nenue@40 184 local criteriaName, criteriaType, completed, _, _, _, _, subAchievementID = GetAchievementCriteriaInfo(achievementID, i)
Nenue@49 185 --print(GetAchievementCriteriaInfo(achievementID, i))
Nenue@40 186
Nenue@40 187 if not completed then
Nenue@49 188 --print('::', criteriaName, completed, subAchievementID)
Nenue@40 189 if criteriaType == 8 then
Nenue@40 190 local _, _, _, completed, _, _, _, _, _, subIcon = GetAchievementInfo(subAchievementID)
Nenue@49 191 --print(' -', criteriaName, completed, subIcon)
Nenue@40 192 if not completed then
Nenue@40 193 local numCompleted = 0
Nenue@40 194 local numSubItems = GetAchievementNumCriteria(subAchievementID)
Nenue@40 195 local subCriteriaLine
Nenue@40 196 for j = 1, numSubItems do
Nenue@40 197 local subName, _, completed = GetAchievementCriteriaInfo(subAchievementID, j)
Nenue@40 198
Nenue@49 199 --print(' -',subName, completed)
Nenue@40 200 if completed then
Nenue@40 201 numCompleted = numCompleted + 1
Nenue@40 202 else
Nenue@40 203 numNeeded = numNeeded + 1
Nenue@40 204 if subName:match(info.name) then
Nenue@40 205 hasInfo = true
Nenue@40 206 subCriteriaLine = ' |T'..subIcon..':16:16|t ' .. criteriaName
Nenue@40 207 end
Nenue@40 208 end
Nenue@40 209
Nenue@40 210 end
Nenue@40 211 if subCriteriaLine then
Nenue@40 212 tinsert(tooltipLines, subCriteriaLine .. ' ('..numCompleted..'/'..numSubItems..')')
Nenue@40 213 end
Nenue@40 214 end
Nenue@40 215 elseif criteriaName:match(info.name) and (not completed) then
Nenue@40 216 numNeeded = numNeeded + 1
Nenue@40 217 tinsert(tooltipLines, criteriaName)
Nenue@40 218 end
Nenue@40 219 end
Nenue@40 220 end
Nenue@49 221 if hasInfo then
Nenue@49 222 WorldMapTooltip:AddLine(" ")
Nenue@49 223 WorldMapTooltip:AddLine("Achievements:")
Nenue@49 224 WorldMapTooltip:AddLine(' |T'..icon..':20:20|t '..name)
Nenue@40 225 for i, line in ipairs(tooltipLines) do
Nenue@40 226 WorldMapTooltip:AddLine(line)
Nenue@40 227 end
Nenue@40 228 end
Nenue@40 229 end
Nenue@40 230 return hasInfo
Nenue@40 231 end
Nenue@40 232
Nenue@40 233 local GetQuestTooltipExtras = function(info)
Nenue@40 234 local questID = info.questID
Nenue@40 235 local hasInfo
Nenue@40 236
Nenue@40 237 if info.pet then
Nenue@40 238 local index, guid = C_PetJournal.FindPetIDByName(info.pet)
Nenue@40 239 if not index then
Nenue@40 240 hasInfo = true
Nenue@40 241 WorldMapTooltip:AddLine('Pets:')
Nenue@40 242 WorldMapTooltip:AddLine(' - ' .. info.petName)
Nenue@40 243
Nenue@40 244 if not IsQuestFlaggedCompleted(questID) then
Nenue@40 245 WorldMapTooltip:AddLine(' Required Quest Flags', 1, 1, 0)
Nenue@40 246 else
Nenue@40 247 WorldMapTooltip:AddLine(' Quest Flags Complete!', 0, 1, 0)
Nenue@40 248 end
Nenue@40 249
Nenue@40 250 end
Nenue@29 251 end
Nenue@29 252
Nenue@29 253 end
Nenue@29 254
Nenue@40 255
Nenue@40 256 function QuestPOI:OnEnter()
Nenue@57 257 if self.filtered and (self.questID ~= GetSuperTrackedQuestID()) then
Nenue@49 258 return
Nenue@7 259 end
Nenue@57 260 WorldMap_HijackTooltip(self.owningFrame);
Nenue@56 261 self:SetFrameLevel(pinBaseIndex+100)
Nenue@56 262 self.Overlay:SetFrameLevel(pinBaseIndex+101)
Nenue@56 263
Nenue@56 264 if previousHighlight then
Nenue@56 265 previousHighlight:SetFrameLevel(pinBaseIndex+previousHighlight:GetID())
Nenue@56 266 previousHighlight.Overlay:SetFrameLevel(overlayBaseIndex+previousHighlight:GetID())
Nenue@56 267 end
Nenue@56 268
Nenue@56 269 previousHighlight = self
Nenue@56 270
Nenue@56 271
Nenue@40 272 WorldMapTooltip:SetOwner(self, "ANCHOR_RIGHT");
Nenue@49 273 --print('doing tooltip stuff')
Nenue@40 274
Nenue@40 275 -- Can't add stuff after, so most of the blizzard tooltip hook is simply copied over
Nenue@40 276 local questID = self.questID
Nenue@40 277 local color = WORLD_QUEST_QUALITY_COLORS[self.rarity] or NORMAL_FONT_COLOR;
Nenue@40 278
Nenue@40 279
Nenue@40 280 WorldMapTooltip:SetText(self.title, color.r, color.g, color.b);
Nenue@40 281 QuestUtils_AddQuestTypeToTooltip(WorldMapTooltip, questID, NORMAL_FONT_COLOR);
Nenue@40 282
Nenue@40 283 if ( self.factionID ) then
Nenue@40 284 local factionName = GetFactionInfoByID(self.factionID);
Nenue@40 285 if ( factionName ) then
Nenue@40 286 if (self.capped) then
Nenue@40 287 WorldMapTooltip:AddLine(factionName, GRAY_FONT_COLOR:GetRGB());
Nenue@40 288 else
Nenue@40 289 WorldMapTooltip:AddLine(factionName);
Nenue@40 290 end
Nenue@40 291 end
Nenue@40 292 end
Nenue@40 293
Nenue@40 294 if self.worldQuest then
Nenue@40 295 WorldMap_AddQuestTimeToTooltip(questID);
Nenue@40 296 end
Nenue@40 297
Nenue@40 298
Nenue@40 299 for objectiveIndex = 1, self.numObjectives do
Nenue@40 300 local objectiveText, objectiveType, finished = GetQuestObjectiveInfo(questID, objectiveIndex, false);
Nenue@40 301 if ( objectiveText and #objectiveText > 0 ) then
Nenue@40 302 local color = finished and GRAY_FONT_COLOR or HIGHLIGHT_FONT_COLOR;
Nenue@40 303 WorldMapTooltip:AddLine(QUEST_DASH .. objectiveText, color.r, color.g, color.b, true);
Nenue@40 304 end
Nenue@40 305 end
Nenue@40 306
Nenue@40 307 local percent = C_TaskQuest.GetQuestProgressBarInfo(self.questID);
Nenue@40 308 if ( percent ) then
Nenue@40 309 GameTooltip_InsertFrame(WorldMapTooltip, WorldMapTaskTooltipStatusBar);
Nenue@40 310 WorldMapTaskTooltipStatusBar.Bar:SetValue(percent);
Nenue@40 311 WorldMapTaskTooltipStatusBar.Bar.Label:SetFormattedText(PERCENTAGE_STRING, percent);
Nenue@40 312 end
Nenue@40 313
Nenue@40 314 if db.TooltipExtras[self.questID] then
Nenue@40 315 for index, info in pairs(db.TooltipExtras[questID]) do
Nenue@40 316 if info.achievementID then
Nenue@40 317 GetAchievementTooltipExtras(info)
Nenue@40 318 end
Nenue@40 319 if info.questID then
Nenue@40 320 GetQuestTooltipExtras(info)
Nenue@40 321 end
Nenue@40 322 end
Nenue@40 323 end
Nenue@65 324 GameTooltip_AddQuestRewardsToTooltip(WorldMapTooltip, questID)
Nenue@40 325
Nenue@40 326 WorldMapTooltip:Show()
Nenue@40 327 --WorldMapTooltip.recalculatePadding = true;
Nenue@40 328 --print(WorldMapTooltip:GetParent())
Nenue@40 329 --print(WorldMapTooltip:IsVisible())
Nenue@7 330 end
Nenue@40 331 function QuestPOI:OnLeave()
Nenue@57 332 if self.filtered and (self.questID ~= GetSuperTrackedQuestID()) then
Nenue@57 333 return
Nenue@57 334 end
Nenue@35 335 WorldMap_RestoreTooltip()
Nenue@40 336 WorldMapTooltip:Hide();
Nenue@7 337 end
Nenue@7 338
Nenue@40 339 -- attempt to pull pin data
Nenue@40 340 function QuestPOI:GetData ()
Nenue@49 341 dprint('|cFF00FF88'..self:GetID()..':GetData()|r')
Nenue@40 342 local questID = self.questID
Nenue@40 343 if not questID then
Nenue@49 344 dprint('|cFFFF4400bad pin|r', self:GetName())
Nenue@40 345 return nil
Nenue@29 346 end
Nenue@29 347
Nenue@40 348 local questTitle, factionID, capped = TQ_GetQuestInfoByQuestID(questID)
Nenue@40 349 -- if the title is nil, then wait and try later
Nenue@40 350 if not questTitle then
Nenue@65 351 dprint('|cFFBB8844dataLoaded|r = false|cFF00FFFF', self.questId)
Nenue@65 352 return false
Nenue@40 353 else
Nenue@40 354 self.title, self.factionID, self.capped = questTitle, factionID, capped
Nenue@65 355 dprint(questTitle, factionID, capped)
Nenue@40 356 -- set tag details
Nenue@40 357 local worldQuestType
Nenue@40 358 self.tagID, self.tagName, worldQuestType, self.rarity, self.isElite, self.tradeskillLineIndex = GetQuestTagInfo(questID);
Nenue@40 359 local tagAtlas
Nenue@40 360 if worldQuestType == LE_QUEST_TAG_TYPE_PET_BATTLE then
Nenue@40 361 tagAtlas = "worldquest-icon-petbattle"
Nenue@40 362 elseif worldQuestType == LE_QUEST_TAG_TYPE_PVP then
Nenue@40 363 tagAtlas = "worldquest-icon-pvp-ffa"
Nenue@40 364 elseif worldQuestType == LE_QUEST_TAG_TYPE_PROFESSION then
Nenue@40 365 self.isKnownProfession = nil
Nenue@40 366 local id = self.tradeskillLineIndex and select(7, GetProfessionInfo(self.tradeskillLineIndex))
Nenue@40 367 if id then
Nenue@40 368 self.isKnownProfession = true
Nenue@40 369 qprint('profession' , self.title, id)
Nenue@40 370 tagAtlas = WORLD_QUEST_ICONS_BY_PROFESSION[id]
Nenue@40 371 end
Nenue@40 372 elseif worldQuestType == LE_QUEST_TAG_TYPE_DUNGEON then
Nenue@40 373 tagAtlas = "worldquest-icon-dungeon"
Nenue@40 374 end
Nenue@40 375 self.worldQuestType = worldQuestType
Nenue@40 376 self.tagAtlas = tagAtlas
Nenue@29 377
Nenue@69 378 local dataLoaded, rewardType, itemName, itemTexture, itemNumber, quality, xpType, xpName, xpIcon, xpCount = self:UpdateRewards()
Nenue@65 379 dprint('|cFFBB8844 dataLoaded|r =', dataLoaded, rewardType, itemName, itemTexture, itemNumber, quality)
Nenue@65 380 if dataLoaded then
Nenue@65 381 self.rewardType = rewardType
Nenue@65 382 self.itemName = itemName
Nenue@65 383 self.itemTexture = itemTexture
Nenue@65 384 self.itemNumber = itemNumber
Nenue@65 385 self.itemQuality = quality
Nenue@49 386 self.dataLoaded = true
Nenue@48 387 self.isStale = true
Nenue@69 388 self.xpType, self.xpName, self.xpIcon, self.xpCount = xpType, xpName, xpIcon, xpCount
Nenue@69 389
Nenue@40 390 end
Nenue@40 391 end
Nenue@40 392
Nenue@40 393
Nenue@65 394 return self.dataLoaded
Nenue@40 395 end
Nenue@40 396
Nenue@69 397 local ID_RESOURCES = 1220
Nenue@69 398 local ID_LEGIONFALL = 1342
Nenue@69 399
Nenue@65 400 --- Returns true if data has changed (either from loading in or qualifications changed)
Nenue@65 401 function QuestPOI:UpdateRewards()
Nenue@40 402 local questID = self.questID
Nenue@65 403 if not HaveQuestRewardData(questID) then
Nenue@65 404 C_TaskQuest.RequestPreloadRewardData(questID);
Nenue@65 405 return false;
Nenue@29 406 else
Nenue@65 407 local rewardMoney, rewardAP, rewardHonor
Nenue@65 408 local rewardItems, rewardCurrency = {}, {}
Nenue@65 409 local rewardIcon, rewardName, rewardCount, rewardStyle, rewardType, itemID, quantity, quality
Nenue@65 410 local xpIcon, xpName, xpCount, xpType
Nenue@69 411 local foundPrimary
Nenue@29 412
Nenue@65 413 if (GetNumQuestLogRewardCurrencies(questID) > 0 or GetNumQuestLogRewards(questID) > 0 or GetQuestLogRewardMoney(questID) > 0 or GetQuestLogRewardArtifactXP(questID) > 0 or GetQuestLogRewardHonor(questID)) then
Nenue@65 414 local money = GetQuestLogRewardMoney(questID)
Nenue@65 415 if money > 0 then
Nenue@65 416 rewardMoney = money
Nenue@65 417 rewardIcon = ICON_MONEY
Nenue@65 418 rewardName = GetMoneyString(money)
Nenue@65 419 rewardCount = floor(money/10000)
Nenue@65 420 rewardType = REWARD_CASH
Nenue@65 421 end
Nenue@65 422
Nenue@65 423 local artifactXP = GetQuestLogRewardArtifactXP(questID);
Nenue@65 424 if artifactXP > 0 then
Nenue@65 425 rewardAP = artifactXP
Nenue@65 426 rewardIcon = "Interface\\ICONS\\inv_7xp_inscription_talenttome01"
Nenue@65 427 rewardCount = artifactXP
Nenue@65 428 rewardType = REWARD_ARTIFACT_POWER
Nenue@65 429 qprint(' artifactXP', artifactXP)
Nenue@69 430 foundPrimary = true
Nenue@65 431 end
Nenue@65 432
Nenue@65 433 local numQuestCurrencies = GetNumQuestLogRewardCurrencies(questID);
Nenue@65 434 for i = 1, numQuestCurrencies do
Nenue@69 435 local name, texture, numItems, currencyID = GetQuestLogRewardCurrencyInfo(i, questID);
Nenue@65 436 local text = BONUS_OBJECTIVE_REWARD_WITH_COUNT_FORMAT:format(texture, numItems, name);
Nenue@65 437 tinsert(rewardCurrency, {
Nenue@65 438 name = name,
Nenue@65 439 texture = texture,
Nenue@65 440 numItems = numItems,
Nenue@65 441 text = text
Nenue@65 442 })
Nenue@69 443
Nenue@69 444 qprint(' currency', i, currencyID, name, " |T"..tostring(texture)..":12:12|t")
Nenue@69 445 if currencyID == ID_RESOURCES then
Nenue@69 446 rewardIcon = texture
Nenue@69 447 rewardCount = numItems
Nenue@69 448 rewardName = name
Nenue@69 449 rewardType = REWARD_CURRENCY
Nenue@69 450 foundPrimary = true
Nenue@69 451 elseif currencyID == ID_LEGIONFALL then
Nenue@69 452 xpIcon = texture
Nenue@69 453 xpCount = numItems
Nenue@69 454 xpName = name
Nenue@69 455 xpType = REWARD_CURRENCY
Nenue@69 456 end
Nenue@69 457
Nenue@65 458 end
Nenue@65 459 local honorAmount = GetQuestLogRewardHonor(questID);
Nenue@65 460 if honorAmount > 0 then
Nenue@65 461 xpIcon = "Interface\\ICONS\\Achievement_LegionPVPTier4"
Nenue@65 462 xpCount = honorAmount
Nenue@65 463 xpName = HONOR
Nenue@65 464 xpType = HONOR_CURRENCY
Nenue@65 465 end
Nenue@65 466
Nenue@65 467 local numQuestRewards = GetNumQuestLogRewards(questID);
Nenue@65 468 if numQuestRewards > 0 then
Nenue@65 469 for i = 1, numQuestRewards do
Nenue@65 470 local name, texture, numItems, quality, isUsable, itemID = GetQuestLogRewardInfo(i, questID)
Nenue@65 471
Nenue@65 472 if itemID then
Nenue@65 473 local itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture, sellPrice, classID, subclassID = GetItemInfo(itemID);
Nenue@65 474
Nenue@65 475
Nenue@65 476 if ( classID == LE_ITEM_CLASS_WEAPON or classID == LE_ITEM_CLASS_ARMOR or (classID == LE_ITEM_CLASS_GEM and subclassID == LE_ITEM_GEM_ARTIFACTRELIC) ) then
Nenue@65 477 rewardType = REWARD_GEAR
Nenue@65 478 rewardIcon = texture
Nenue@65 479 rewardName = name
Nenue@65 480 rewardCount = numItems
Nenue@65 481 foundPrimary = true
Nenue@65 482 elseif IsArtifactPowerItem(itemID) then
Nenue@65 483 rewardType = REWARD_ARTIFACT_POWER
Nenue@65 484 rewardIcon = texture
Nenue@65 485 rewardName = name
Nenue@65 486 rewardCount = 1
Nenue@65 487 foundPrimary = true
Nenue@65 488
Nenue@65 489 WorldPlanTooltip:SetOwner(self, 'ANCHOR_NONE')
Nenue@65 490 WorldPlanTooltip:SetHyperlink(itemLink)
Nenue@65 491 for i = 1, WorldPlanTooltip:NumLines() do
Nenue@65 492 local line = _G['WorldPlanTooltipTextLeft' .. i]
Nenue@65 493 local text = line and line:GetText()
Nenue@65 494 local ap = text and text:gsub(',', ''):match('(%d+) '..ARTIFACT_POWER)
Nenue@65 495 if ap then
Nenue@65 496 rewardCount = tonumber(ap)
Nenue@65 497 print(ap)
Nenue@65 498 end
Nenue@65 499
Nenue@65 500 end
Nenue@65 501
Nenue@65 502 if WorldPlanTooltipTextLeft2 then
Nenue@65 503 local text = WorldPlanTooltipTextLeft2:GetText()
Nenue@65 504 end
Nenue@65 505
Nenue@65 506 print('is an AP token')
Nenue@65 507 elseif classID == LE_ITEM_CLASS_TRADEGOODS then
Nenue@65 508 rewardType = REWARD_REAGENT
Nenue@65 509 rewardIcon = texture
Nenue@65 510 rewardName = name
Nenue@65 511 rewardCount = numItems
Nenue@65 512 foundPrimary = true
Nenue@65 513 end
Nenue@65 514
Nenue@65 515
Nenue@65 516 qprint(' reward', i, name, " |T"..tostring(texture)..":12:12|t", quality, isUsable, itemID)
Nenue@65 517 tinsert(rewardItems, {
Nenue@65 518 name = name,
Nenue@65 519 texture = texture,
Nenue@65 520 numItems = numItems,
Nenue@65 521 quality = quality,
Nenue@65 522 isUsable = isUsable
Nenue@65 523 })
Nenue@65 524 if not foundPrimary then
Nenue@69 525 print(' -updating primary')
Nenue@65 526 rewardType = REWARD_GEAR
Nenue@65 527
Nenue@65 528 rewardIcon = texture
Nenue@65 529 rewardName = name
Nenue@65 530 rewardCount = numItems
Nenue@65 531 end
Nenue@65 532
Nenue@65 533 end
Nenue@65 534
Nenue@65 535 end
Nenue@65 536 end
Nenue@65 537
Nenue@65 538 qprint(' '..self.questID..':|cFFFFFF00SetRewardInfo():', numQuestRewards, rewardType)
Nenue@65 539 qprint(' ', tostring(self.title), " |T"..tostring(self.itemTexture)..":12:12|t", tostring(self.itemName))
Nenue@65 540
Nenue@65 541 if (self.itemNumber ~= rewardCount) or (self.rewardType ~= rewardType) or (self.itemName ~= rewardName) or (self.itemTexture ~= rewardIcon) then
Nenue@67 542 if DATA_DEBUG and (self.debugTimer <= 0) then
Nenue@67 543 return false
Nenue@67 544 end
Nenue@67 545
Nenue@69 546 return true, rewardType, rewardName, rewardIcon, rewardCount, quality, xpType, xpName, xpIcon, xpCount
Nenue@67 547
Nenue@65 548 else
Nenue@65 549 return false
Nenue@65 550 end
Nenue@65 551 end
Nenue@65 552
Nenue@65 553
Nenue@65 554
Nenue@65 555 --[[ set reward category
Nenue@29 556 local numRewards = GetNumQuestLogRewards(questID)
Nenue@29 557 local numCurrency = GetNumQuestLogRewardCurrencies(questID)
Nenue@29 558 local money = GetQuestLogRewardMoney(questID)
Nenue@29 559 if numRewards >= 1 then
Nenue@40 560 rewardType, rewardIcon, rewardCount, rewardName, itemID, quality = WorldPlanQuests:GetRewardHeader(questID)
Nenue@29 561 elseif numCurrency >= 1 then
Nenue@29 562 rewardName, rewardIcon, rewardCount = GetQuestLogRewardCurrencyInfo(1, questID)
Nenue@29 563 rewardType = REWARD_CURRENCY
Nenue@29 564 elseif money >= 1 then
Nenue@29 565 rewardName = GetMoneyString(money)
Nenue@29 566 end
Nenue@65 567 --]]
Nenue@29 568
Nenue@40 569 end
Nenue@7 570 end
Nenue@7 571
Nenue@34 572 -- run from OnShow if .isNew is set
Nenue@34 573
Nenue@49 574 function QuestPOI:StartFade()
Nenue@34 575 if not self.isAnimating then
Nenue@69 576 qprint('|cFFFFFF00clearing new status')
Nenue@35 577 self:SetAlpha(0)
Nenue@69 578 if self.dataLoaded then
Nenue@69 579 self:Refresh()
Nenue@49 580 self.FadeIn.FadeIn:SetToAlpha(db.PinAlpha)
Nenue@49 581 self.PendingFade.FadeIn:SetToAlpha(db.PinAlpha)
Nenue@49 582 self.PendingFade.FadeOut:SetFromAlpha(db.PinAlpha)
Nenue@49 583
Nenue@69 584 self.isAnimating = true
Nenue@69 585 self.isNew = nil
Nenue@69 586 self.isStale = true
Nenue@69 587 self.FadeIn:Play()
Nenue@69 588 end
Nenue@34 589 end
Nenue@7 590 end
Nenue@7 591
Nenue@49 592 function QuestPOI:EndFade()
Nenue@49 593 self.isAnimating = nil
Nenue@49 594 self:SetAlpha(db.PinAlpha)
Nenue@49 595 end
Nenue@49 596
Nenue@40 597 function QuestPOI:OnShow ()
Nenue@27 598
Nenue@69 599 if self.isNew then
Nenue@69 600 self:StartFade()
Nenue@69 601 else
Nenue@69 602 if not self.isAnimating then
Nenue@69 603 print('|cFF00FF00Alpha correction')
Nenue@69 604 self:SetAlpha(db.PinAlpha) -- fix stuck alpha
Nenue@69 605 end
Nenue@69 606 if self.isStale then
Nenue@69 607 print('|cFF00FF00refresh on show')
Nenue@69 608 self:Refresh()
Nenue@69 609 end
Nenue@48 610 end
Nick@62 611 self:ShowFrames()
Nenue@27 612 end
Nick@62 613
Nenue@40 614 function QuestPOI:OnHide()
Nick@60 615 --DEFAULT_CHAT_FRAME:AddMessage('|cFFFFFF00'..self:GetName()..'|r:OnHide()')
Nick@62 616 self:HideFrames()
Nenue@59 617 -- reset flags
Nenue@59 618 self:SetAlpha(db.PinAlpha)
Nenue@49 619 self.isAnimating = nil
Nenue@69 620 if db.Config.DebugEnabled then
Nenue@69 621 db.log(tostring(self.questID) .. ' ' .. tostring(self.title) .. "\n" .. tostring(REWARD_TYPE_NAMES[self.rewardType]) .. ' ' .. tostring(self.itemName) .. ' ' .. tostring(self.itemNumber) .. "\n|cFFFF4400" .. (self.hideReason or 'NO_MESSAGE') .. "|r\n|cFF00FFFF" .. debugstack(2,3,0) .. '|r')
Nenue@69 622 end
Nenue@69 623 self.hideReason = nil
Nenue@27 624 end
Nenue@27 625
Nenue@67 626 -- Applies position and sizing parameters to the pin data
Nenue@66 627 function QuestPOI:SetAnchor(owner, dX, dY, mapWidth, mapHeight, scaleFactor)
Nenue@67 628 dprint(self:GetName()..':SetAnchor()', owner, dX, dY, scaleFactor, self.filtered, self.used)
Nick@62 629 if not self.used then
Nenue@69 630 self.hideReason = 'SetAnchor() on an unused frame.'
Nick@62 631 self:HideFrames()
Nick@62 632 return
Nick@62 633 end
Nick@62 634
Nenue@67 635 if owner then
Nenue@67 636 local prevOwner = self:GetParent()
Nenue@67 637 if prevOwner ~= owner then
Nenue@67 638 self.isStale = true
Nenue@67 639 end
Nenue@67 640 self:SetParent(owner)
Nenue@67 641 self.Overlay:SetParent(owner)
Nenue@67 642 else
Nenue@67 643 owner = self:GetParent()
Nenue@67 644 end
Nenue@67 645
Nenue@49 646 self:ClearAllPoints()
Nenue@56 647 self:SetFrameLevel(pinBaseIndex + self:GetID())
Nenue@53 648 self.Overlay:SetFrameLevel(overlayBaseIndex + self:GetID())
Nenue@67 649
Nenue@67 650 local scaleChanged
Nenue@67 651 if scaleFactor and (self.scaleFactor ~= scaleFactor) then
Nenue@69 652 --print('scaleFactor')
Nenue@67 653 self:SetScale(scaleFactor)
Nenue@67 654 self.Overlay:SetScale(scaleFactor)
Nenue@67 655 self.scaleFactor = scaleFactor
Nenue@67 656 scaleChanged = true
Nenue@67 657 end
Nenue@67 658
Nenue@53 659 if (dX and dY) then
Nenue@53 660 if not (mapHeight and mapWidth) then
Nenue@53 661 mapWidth, mapHeight = owner:GetSize()
Nenue@67 662 end
Nenue@67 663
Nenue@67 664 if (self.x ~= dY) or (self.y ~= dY) or scaleChanged then
Nenue@65 665 self.x = dX
Nenue@65 666 self.y = dY
Nenue@66 667 local pX = (dX * mapWidth) * (1 / scaleFactor)
Nenue@66 668 local pY = (-dY * mapHeight) * (1 / scaleFactor)
Nenue@65 669 self:SetPoint('CENTER', owner, 'TOPLEFT', pX, pY)
Nenue@65 670 end
Nenue@53 671 end
Nick@62 672
Nick@62 673 end
Nick@62 674
Nick@64 675 -- Show/Hide the text overlays associated with the quest pin; they aren't hierarchically linked
Nick@62 676 function QuestPOI:ShowFrames()
Nick@62 677 if not self:IsShown() then
Nick@62 678 print('|cFFFFFF00' ..self:GetName()..':ShowFrames()')
Nick@64 679 -- do not SetShown() here
Nick@64 680 end
Nick@62 681 self.Overlay:SetShown(true)
Nick@62 682 self.count:SetShown(true)
Nick@62 683 self.timeLabel:SetShown(true)
Nick@62 684 end
Nick@62 685
Nick@62 686 function QuestPOI:HideFrames()
Nick@62 687 if self:IsShown() then
Nenue@69 688 if not self.hideReason then
Nenue@69 689 self.hideReason = "HideFrames() called"
Nenue@69 690 end
Nenue@69 691 --print(self:GetName()..':HideFrames()')
Nick@62 692 self:SetShown(false)
Nick@62 693 end
Nick@62 694 self.Overlay:SetShown(false)
Nick@62 695 self.count:SetShown(false)
Nick@62 696 self.timeLabel:SetShown(false)
Nick@62 697 self.used = nil
Nenue@7 698 end
Nenue@7 699
Nenue@40 700 function QuestPOI:OnLoad()
Nenue@40 701 qprint('|cFF00FF88'..self:GetName()..':OnLoad()|r',db.Config)
Nenue@67 702 self.debugTimer = 4
Nenue@40 703 self.title = '|cFF0088FF' .. RETRIEVING_DATA..'|r'
Nenue@40 704 self.isPending = true
Nenue@36 705 self.count = self.Overlay.count
Nick@62 706 self.timeLabel = self.Overlay.timeLabel
Nenue@54 707 self.Description = self.Overlay.Description
Nenue@40 708 self.updateRate = PIN_REQUEST_DELAY
Nenue@40 709 self.itemName = '|cFF0088FF' .. RETRIEVING_DATA..'|r'
Nenue@41 710
Nenue@53 711 self.Overlay:SetPoint('TOPLEFT', self, 'TOPLEFT', 0, 4)
Nenue@53 712 self.Overlay:SetPoint('BOTTOMRIGHT', self, 'BOTTOMRIGHT', 0, -4)
Nenue@7 713 end
Nick@64 714
Nenue@57 715 function QuestPOI:OnMouseDown(button)
Nenue@57 716 if button == 'RightButton' then
Nenue@57 717 SetSuperTrackedQuestID(nil)
Nenue@57 718 else
Nenue@57 719 TaskPOI_OnClick(self, button)
Nenue@57 720 end
Nenue@57 721 end
Nenue@57 722
Nenue@7 723
Nenue@40 724 function QuestPOI:OnUpdate (sinceLast)
Nenue@40 725 -- control update check intervals
Nenue@67 726
Nenue@67 727
Nenue@40 728 self.throttle = (self.throttle or self.updateRate) + sinceLast
Nenue@40 729 if self.throttle >= self.updateRate then
Nenue@40 730 -- factor overtime into the throttle timer
Nenue@40 731 self.throttle = self.throttle - self.updateRate
Nenue@40 732 else
Nenue@40 733 return
Nenue@40 734 end
Nenue@67 735 --@debug@
Nenue@67 736 if DATA_DEBUG then
Nenue@67 737 self.debugTimer = self.debugTimer - sinceLast
Nenue@67 738 if self.debugTimer >= 0 then
Nenue@67 739 print(self.debugTimer)
Nenue@67 740 end
Nenue@35 741 end
Nenue@67 742 --@end-debug@
Nenue@7 743
Nenue@7 744 -- query for reward data if it wasn't found in the original scan
Nenue@69 745
Nenue@65 746 if not self.dataLoaded then
Nenue@67 747 print('|cFFFF4400'..self:GetID()..':|r polling reward info')
Nenue@69 748
Nenue@66 749 local dataLoaded = self:GetData()
Nenue@67 750 if dataLoaded and not tContains(db.UpdatedPins, self) then
Nenue@67 751
Nenue@69 752 print('|cFF00FF88'..self:GetID()..':|r delayed reward info, queueing for update')
Nenue@69 753 self.PendingFade:Stop()
Nenue@67 754 tinsert(db.UpdatedPins, self)
Nenue@66 755 end
Nenue@7 756 return
Nenue@7 757 end
Nenue@7 758
Nenue@69 759 if self.maxAlertLevel then
Nenue@69 760 self:UpdateStatus()
Nenue@69 761 end
Nenue@69 762
Nenue@55 763 end
Nenue@7 764
Nenue@55 765 -- Called at static intervals and with Refresh
Nenue@55 766 function QuestPOI:UpdateStatus()
Nenue@7 767 -- update time elements
Nick@64 768 self.isActive = TQ_IsActive(self.questID)
Nick@64 769
Nick@64 770 if self.isActive then
Nenue@40 771 local tl = self.alertLevel
Nenue@55 772 local timeLeft = TQ_GetQuestTimeLeftMinutes(self.questID)
Nenue@40 773 if timeLeft > 0 then
Nenue@40 774
Nenue@40 775 local text, timeState = WorldPlan:GetTimeInfo(timeLeft, self.maxAlertLevel)
Nenue@40 776 if tl ~= timeState then
Nenue@40 777 tl = timeState
Nenue@40 778 self.timeLabel:SetText(text)
Nenue@40 779 end
Nenue@7 780 end
Nenue@55 781
Nenue@57 782 if tl and (timeLeft < 120) then
Nenue@55 783 self.HighlightBorder:SetVertexColor(1,0,0,0.7)
Nenue@55 784 elseif self.isBounty then
Nenue@71 785 self.HighlightBorder:SetVertexColor(1,1,0,1)
Nenue@71 786 elseif self.isCriteria then
Nenue@55 787 self.HighlightBorder:SetVertexColor(.25,.5,1,1)
Nenue@55 788 else
Nenue@55 789 self.HighlightBorder:SetVertexColor(0,0,0,0.7)
Nenue@55 790 end
Nenue@40 791 self.alertLevel = tl
Nick@60 792 self.timeLabel:SetShown(self.worldQuest and (self.maxAlertLevel >= 1))
Nenue@59 793 else
Nenue@69 794 self.hideReason = "No longer active."
Nenue@69 795 self:HideFrames()
Nenue@69 796
Nenue@7 797 end
Nenue@8 798 end
Nenue@8 799
Nenue@66 800
Nick@60 801 function QuestPOI:Refresh ()
Nenue@49 802
Nick@60 803 rprint('|cFF00FF88'..self:GetID()..'|r:Refresh() type =', self.rewardType, 'title =', self.title)
Nenue@49 804
Nenue@66 805 local style = DEFAULT_STYLE
Nenue@66 806 if self.dataLoaded and not self.filtered then
Nenue@66 807 style = REWARD_TYPE_STYLES[self.rewardType]
Nenue@66 808 else
Nenue@66 809 style = MINIMIZED_STYLE
Nenue@66 810 end
Nenue@49 811
Nenue@66 812 local currentWidth = style.iconWidth or DEFAULT_STYLE.iconWidth
Nenue@9 813
Nenue@9 814
Nenue@66 815
Nenue@66 816 local borderWidth = style.borderWidth or DEFAULT_STYLE.borderWidth
Nenue@66 817 local highlightWidth = style.highlightWidth or DEFAULT_STYLE.highlightWidth
Nenue@66 818 local tagSize = style.TagSize or DEFAULT_STYLE.TagSize
Nenue@66 819 local hideIcon = style.hideIcon or DEFAULT_STYLE.hideIcon
Nenue@66 820 local borderColor = style.border or DEFAULT_STYLE.border
Nenue@69 821 local textColor = style.textColor or DEFAULT_STYLE.textColor
Nenue@57 822 local questID = self.questID
Nenue@36 823 local iconBorder = self.RewardBorder
Nenue@36 824 local trackingBorder = self.HighlightBorder
Nenue@9 825 local icon = self.icon
Nenue@9 826 local count = self.count
Nenue@66 827 local hideNumbers = style.hideNumber or DEFAULT_STYLE.hideNumber
Nenue@66 828
Nenue@66 829 local tagIcon = self.tagIcon
Nenue@66 830 self.maxAlertLevel = style.maxAlertLevel or DEFAULT_STYLE.maxAlertLevel
Nenue@66 831
Nenue@9 832 if self.itemName then
Nenue@66 833 if self.itemNumber and (self.itemNumber > 1) and (not hideNumbers) then
Nenue@54 834 local numberString = self.itemNumber
Nenue@65 835 if self.itemNumber >= 1000000 then
Nenue@65 836 numberString = (floor(self.itemNumber/100000)/10) .. 'M'
Nenue@65 837 elseif self.itemNumber >= 10000 then
Nenue@65 838 numberString = floor(self.itemNumber/1000) .. 'k'
Nenue@65 839 elseif self.itemNumber >= 1000 then
Nenue@54 840 local numeral = floor(self.itemNumber/1000)
Nenue@54 841 local decimal = mod(self.itemNumber, 1000)
Nenue@54 842 numberString = numeral
Nenue@54 843 if decimal > 100 then
Nenue@54 844 numberString = numberString .. '.' .. tostring(floor(decimal/100))
Nenue@54 845 end
Nenue@54 846 numberString = numberString .. 'k'
Nenue@40 847 end
Nenue@69 848
Nenue@45 849 self.count:SetText(numberString)
Nenue@69 850 self.count:SetTextColor(unpack(textColor))
Nenue@66 851 self.count:Show()
Nenue@45 852 else
Nenue@54 853 self.count:SetText(nil)
Nenue@66 854 self.count:Hide()
Nenue@45 855 end
Nenue@66 856 else
Nenue@66 857 self.count:Hide()
Nenue@54 858 end
Nenue@30 859
Nenue@55 860 if db.Config.ShowVerboseInfo then
Nenue@55 861 self.Description:SetText(self.title .. "\n" .. floor(self.x*100+.5) .. "," .. floor(self.y*100+.5))
Nenue@55 862 end
Nenue@55 863
Nenue@40 864
Nenue@66 865 icon:SetSize(currentWidth, currentWidth)
Nenue@66 866 icon:SetMask(style.iconMask or DEFAULT_STYLE.iconMask)
Nenue@36 867 if self.itemTexture then
Nenue@47 868 --iconBorder:SetTexture(WORLD_QUEST_BORDER)
Nenue@40 869
Nenue@66 870 if hideIcon then
Nenue@40 871 icon:SetTexture(PENDING_ICON)
Nenue@40 872 icon:SetDesaturated(true)
Nenue@66 873 icon:SetVertexColor(unpack(borderColor))
Nenue@40 874 else
Nenue@40 875 icon:SetTexture(self.itemTexture)
Nenue@40 876 icon:SetDesaturated(false)
Nenue@40 877 icon:SetVertexColor(1, 1, 1)
Nenue@40 878 end
Nenue@40 879 else
Nenue@47 880 --
Nenue@40 881 icon:SetTexture(PENDING_ICON)
Nenue@40 882 icon:SetDesaturated(true)
Nenue@66 883 icon:SetVertexColor(unpack(borderColor))
Nenue@9 884 end
Nenue@66 885 local borderMask = style.borderMask or DEFAULT_STYLE.borderMask
Nenue@66 886 local borderSize = currentWidth + (borderWidth * 2)
Nenue@9 887
Nenue@66 888
Nenue@66 889 iconBorder:SetSize(borderSize, borderSize)
Nenue@66 890 iconBorder:SetMask(borderMask)
Nenue@47 891 iconBorder:SetTexture(PENDING_BORDER)
Nenue@66 892 iconBorder:SetVertexColor(unpack(borderColor))
Nenue@66 893 iconBorder:SetDesaturated(true)
Nenue@52 894
Nenue@66 895 local highlightSize = borderSize + (highlightWidth * 2)
Nenue@66 896 trackingBorder:SetSize(highlightSize, highlightSize)
Nenue@66 897 trackingBorder:SetMask(borderMask)
Nenue@66 898 trackingBorder:SetTexture(PENDING_BORDER)
Nenue@9 899
Nenue@66 900 self:SetSize(borderSize, borderSize)
Nenue@66 901
Nenue@66 902
Nenue@66 903
Nenue@66 904 iconBorder:SetPoint('CENTER', (style.x or 0), (style.y or 0))
Nenue@66 905 trackingBorder:SetPoint('CENTER', (style.x or 0), (style.y or 0))
Nenue@9 906
Nenue@49 907 self.tagIcon:SetShown((not self.filtered) and true or false)
Nenue@9 908 self.tagIcon:SetAtlas(self.tagAtlas)
Nenue@47 909 self.EliteBorder:SetShown(self.isElite and not self.filtered)
Nenue@36 910
Nenue@9 911 self:UpdateSize()
Nenue@55 912 self:UpdateStatus()
Nenue@33 913 self.isStale = nil
Nenue@57 914
Nenue@73 915
Nenue@73 916 if SpellCanTargetQuest() then
Nenue@73 917 if IsQuestIDValidSpellTarget(self.questID) then
Nenue@73 918 icon:SetVertexColor(1,1,1)
Nenue@73 919 else
Nenue@73 920 icon:SetVertexColor(1,0,0,1)
Nenue@73 921 end
Nenue@73 922 self:EnableMouse(false)
Nenue@73 923 else
Nenue@73 924 self:EnableMouse(true)
Nenue@73 925 end
Nenue@73 926
Nenue@57 927 -- signal filter info update
Nenue@57 928 WorldPlanSummary.isStale = true
Nenue@9 929 end
Nenue@9 930
Nenue@35 931 local cvar_check = {
Nenue@35 932 [REWARD_CASH] = 'worldQuestFilterGold',
Nenue@35 933 [REWARD_ARTIFACT_POWER] = 'worldQuestFilterArtifactPower',
Nenue@35 934 [REWARD_CURRENCY] = 'worldQuestFilterOrderResources',
Nenue@35 935 [REWARD_REAGENT]= 'worldQuestFilterProfessionMaterials',
Nenue@35 936 [REWARD_GEAR] = 'worldQuestFilterEquipment',
Nenue@35 937 }
Nenue@8 938
Nick@64 939
Nenue@57 940 function QuestPOI:CheckFilterRules ()
Nenue@36 941 local print = qprint
Nenue@33 942 local qType = self.worldQuestType
Nenue@57 943 local filtered
Nenue@57 944 local canShow = TQ_IsActive(self.questID)
Nenue@69 945
Nenue@69 946
Nenue@69 947 if qType == LE_QUEST_TAG_TYPE_PROFESSION then
Nenue@57 948 if not(self.isKnownProfession or db.Config.ShowAllProfessionQuests) then
Nenue@57 949 canShow = nil
Nenue@36 950 end
Nenue@36 951 end
Nenue@57 952 if canShow then
Nenue@57 953 for filterKey, value in pairs(db.UsedFilters) do
Nenue@57 954 if self[filterKey] ~= value then
Nenue@57 955 if not self.filtered then
Nenue@57 956 print('|cFFFF4400filtering', filterKey, value, '~=', self[filterKey], self.title)
Nenue@57 957 end
Nenue@57 958
Nenue@57 959 filtered = true
Nenue@57 960 end
Nenue@57 961 end
Nenue@57 962 if self.rewardType and cvar_check[self.rewardType] then
Nenue@57 963 if not GetCVarBool(cvar_check[self.rewardType]) then
Nenue@57 964 filtered = true
Nenue@57 965 end
Nenue@57 966 end
Nenue@57 967 if canShow and self.filtered ~= filtered then
Nenue@57 968 self.isStale = true
Nenue@57 969 print(' '..self.questID..':|cFFFFFF00CheckFilterRules()|r ', canShow, filtered, self.title)
Nenue@57 970 end
Nenue@57 971 self.filtered = filtered
Nenue@57 972 end
Nenue@57 973 self.used = canShow
Nenue@69 974 if not canShow then
Nenue@69 975 self.hideReason = "Failed filter check."
Nenue@69 976 end
Nenue@69 977 self:SetShown(canShow)
Nenue@33 978 end
Nenue@33 979
Nenue@33 980 --- Fixes icons upon size update
Nenue@36 981 function QuestPOI:UpdateSize ()
Nenue@33 982
Nenue@49 983 --qprint('|cFF00BB88'..self:GetID()..'|r:UpdateSize()', self.style, self.subStyle)
Nenue@66 984 return
Nenue@66 985 --[[
Nenue@40 986 local style = self.style
Nenue@40 987 local subStyle = self.subStyle
Nenue@36 988 local icon = self.icon
Nenue@36 989 local iconBorder = self.RewardBorder
Nenue@36 990 local trackingBorder = self.HighlightBorder
Nenue@36 991 local tag = self.tagIcon
Nenue@33 992
Nenue@36 993 local iconWidth = subStyle.iconWidth
Nenue@36 994 local borderWidth = iconWidth + (subStyle.borderWidth * 2)
Nenue@36 995 local highlightWidth = borderWidth + (subStyle.highlightWidth * 2)
Nenue@36 996 local iconTexture = self.itemTexture
Nenue@33 997
Nenue@47 998
Nenue@56 999 self:SetSize(highlightWidth, highlightWidth)
Nenue@47 1000 if self.questID == GetSuperTrackedQuestID() then
Nenue@47 1001 highlightWidth = highlightWidth + 2
Nenue@57 1002 if self.filtered then
Nenue@57 1003 self:SetAlpha(db.PinAlpha * 0.5)
Nenue@57 1004 else
Nenue@57 1005 self:SetAlpha(db.PinAlpha)
Nenue@57 1006 end
Nenue@57 1007
Nenue@47 1008 end
Nenue@47 1009
Nenue@47 1010 if self.rarity and WORLD_QUEST_QUALITY_COLORS[self.rarity] then
Nenue@47 1011 highlightWidth = highlightWidth + self.rarity
Nenue@47 1012 end
Nenue@40 1013 self.tagIcon:SetSize(self.tagSize, self.tagSize)
Nenue@36 1014 icon:SetSize(iconWidth, iconWidth)
Nenue@36 1015 iconBorder:SetSize(borderWidth, borderWidth)
Nenue@36 1016 trackingBorder:SetSize(highlightWidth, highlightWidth)
Nenue@33 1017
Nenue@36 1018
Nenue@36 1019 iconBorder:SetPoint('CENTER', (style.x or 0), (style.y or 0))
Nenue@36 1020 trackingBorder:SetPoint('CENTER', (style.x or 0), (style.y or 0))
Nenue@36 1021
Nenue@36 1022
Nick@62 1023 if (subStyle.showNumber and self.itemNumber) and style.hasNumeric then
Nenue@36 1024 self.count:SetTextColor(unpack(style.numberRGB))
Nenue@36 1025 if subStyle.numberFontObject then
Nenue@36 1026 --wqprint('change font', _G[subStyle.numberFontObject]:GetName())
Nenue@36 1027 self.count:SetFontObject(_G[subStyle.numberFontObject])
Nenue@36 1028 end
Nick@62 1029 else
Nick@62 1030 self.count:SetText(nil)
Nenue@33 1031 end
Nenue@66 1032 --]]
Nenue@7 1033 end