annotate QuestPOI.lua @ 88:81e0afddb04a

- Fixed pins not returning to WorldMapFrame after the FlightMap is opened
author Nenue
date Tue, 11 Apr 2017 00:20:51 -0400
parents a12f782571c5
children df733f2174b7
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@75 48 local PIN_REFRESH_DELAY = 1
Nenue@75 49 local PIN_REQUEST_DELAY = .2
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 hideNumber = true,
Nenue@66 107 },
Nenue@66 108 [REWARD_ARTIFACT_POWER] = {},
Nenue@66 109 [REWARD_GEAR] = {
Nenue@66 110 hideNumber = true,
Nenue@66 111 },
Nenue@69 112 [REWARD_CURRENCY] = {
Nenue@69 113 textColor = {1,1,0,.5}
Nenue@69 114 },
Nenue@66 115 [REWARD_REAGENT] = {
Nenue@66 116
Nenue@66 117 hideNumber = true,
Nenue@66 118 },
Nenue@66 119 }
Nenue@74 120 local BORDER_SELECTED_BOUNTY = {1, 1, 0, 1 }
Nenue@74 121 local BORDER_CRITERIA = {.25, .5, 1, 1}
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@78 262 self.Overlay:SetFrameLevel(overlayBaseIndex+100)
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@75 341 --dprint('|cFF00FF88'..self:GetID()..':GetData()|r')
Nenue@40 342 local questID = self.questID
Nenue@40 343 if not questID then
Nenue@75 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@75 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@75 355 print(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@75 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@75 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@75 429 --dprint(' 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@75 444 --dprint(' 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@88 461 rewardIcon = "Interface\\ICONS\\Achievement_LegionPVPTier4"
Nenue@88 462 rewardCount = honorAmount
Nenue@88 463 rewardName = HONOR
Nenue@88 464 rewardType = REWARD_CURRENCY
Nenue@88 465 -- let items override
Nenue@65 466 end
Nenue@65 467
Nenue@65 468 local numQuestRewards = GetNumQuestLogRewards(questID);
Nenue@65 469 if numQuestRewards > 0 then
Nenue@65 470 for i = 1, numQuestRewards do
Nenue@65 471 local name, texture, numItems, quality, isUsable, itemID = GetQuestLogRewardInfo(i, questID)
Nenue@65 472
Nenue@65 473 if itemID then
Nenue@65 474 local itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture, sellPrice, classID, subclassID = GetItemInfo(itemID);
Nenue@65 475
Nenue@65 476
Nenue@65 477 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 478 rewardType = REWARD_GEAR
Nenue@65 479 rewardIcon = texture
Nenue@65 480 rewardName = name
Nenue@65 481 rewardCount = numItems
Nenue@65 482 foundPrimary = true
Nenue@65 483 elseif IsArtifactPowerItem(itemID) then
Nenue@65 484 rewardType = REWARD_ARTIFACT_POWER
Nenue@65 485 rewardIcon = texture
Nenue@65 486 rewardName = name
Nenue@65 487 rewardCount = 1
Nenue@65 488 foundPrimary = true
Nenue@65 489
Nenue@65 490 WorldPlanTooltip:SetOwner(self, 'ANCHOR_NONE')
Nenue@65 491 WorldPlanTooltip:SetHyperlink(itemLink)
Nenue@65 492 for i = 1, WorldPlanTooltip:NumLines() do
Nenue@65 493 local line = _G['WorldPlanTooltipTextLeft' .. i]
Nenue@65 494 local text = line and line:GetText()
Nenue@74 495 local ap = text and text:gsub(',', ''):gsub(' million', '000000'):match('(%d+) '..ARTIFACT_POWER)
Nenue@65 496 if ap then
Nenue@65 497 rewardCount = tonumber(ap)
Nenue@75 498 --dprint(ap)
Nenue@65 499 end
Nenue@65 500
Nenue@65 501 end
Nenue@65 502
Nenue@65 503 if WorldPlanTooltipTextLeft2 then
Nenue@65 504 local text = WorldPlanTooltipTextLeft2:GetText()
Nenue@65 505 end
Nenue@65 506
Nenue@75 507 --dprint('is an AP token')
Nenue@65 508 elseif classID == LE_ITEM_CLASS_TRADEGOODS then
Nenue@65 509 rewardType = REWARD_REAGENT
Nenue@65 510 rewardIcon = texture
Nenue@65 511 rewardName = name
Nenue@65 512 rewardCount = numItems
Nenue@65 513 foundPrimary = true
Nenue@65 514 end
Nenue@65 515
Nenue@65 516
Nenue@75 517 --dprint(' reward', i, name, " |T"..tostring(texture)..":12:12|t", quality, isUsable, itemID)
Nenue@65 518 tinsert(rewardItems, {
Nenue@65 519 name = name,
Nenue@65 520 texture = texture,
Nenue@65 521 numItems = numItems,
Nenue@65 522 quality = quality,
Nenue@65 523 isUsable = isUsable
Nenue@65 524 })
Nenue@65 525 if not foundPrimary then
Nenue@75 526 --print(' -updating primary')
Nenue@82 527 rewardType = REWARD_REAGENT
Nenue@65 528
Nenue@65 529 rewardIcon = texture
Nenue@65 530 rewardName = name
Nenue@65 531 rewardCount = numItems
Nenue@65 532 end
Nenue@65 533
Nenue@65 534 end
Nenue@65 535
Nenue@65 536 end
Nenue@65 537 end
Nenue@65 538
Nenue@75 539 --dprint(' '..self.questID..':|cFFFFFF00UpdateRewards():', numQuestRewards, rewardType)
Nenue@75 540 --dprint(' ', tostring(self.title), " |T"..tostring(self.itemTexture)..":12:12|t", tostring(self.itemName))
Nenue@65 541
Nenue@65 542 if (self.itemNumber ~= rewardCount) or (self.rewardType ~= rewardType) or (self.itemName ~= rewardName) or (self.itemTexture ~= rewardIcon) then
Nenue@67 543 if DATA_DEBUG and (self.debugTimer <= 0) then
Nenue@67 544 return false
Nenue@67 545 end
Nenue@67 546
Nenue@88 547 return (rewardType and true), rewardType, rewardName, rewardIcon, rewardCount, quality, xpType, xpName, xpIcon, xpCount
Nenue@67 548
Nenue@65 549 else
Nenue@65 550 return false
Nenue@65 551 end
Nenue@65 552 end
Nenue@65 553
Nenue@65 554
Nenue@65 555
Nenue@65 556 --[[ set reward category
Nenue@29 557 local numRewards = GetNumQuestLogRewards(questID)
Nenue@29 558 local numCurrency = GetNumQuestLogRewardCurrencies(questID)
Nenue@29 559 local money = GetQuestLogRewardMoney(questID)
Nenue@29 560 if numRewards >= 1 then
Nenue@40 561 rewardType, rewardIcon, rewardCount, rewardName, itemID, quality = WorldPlanQuests:GetRewardHeader(questID)
Nenue@29 562 elseif numCurrency >= 1 then
Nenue@29 563 rewardName, rewardIcon, rewardCount = GetQuestLogRewardCurrencyInfo(1, questID)
Nenue@29 564 rewardType = REWARD_CURRENCY
Nenue@29 565 elseif money >= 1 then
Nenue@29 566 rewardName = GetMoneyString(money)
Nenue@29 567 end
Nenue@65 568 --]]
Nenue@29 569
Nenue@40 570 end
Nenue@7 571 end
Nenue@7 572
Nenue@34 573 -- run from OnShow if .isNew is set
Nenue@34 574
Nenue@75 575 function QuestPOI:OnAnimStart()
Nenue@75 576 --qprint('|cFFFFFF00OnAnimStart(|r'..self:GetID()..'|cFFFFFF00)|r', self.fadeEvent)
Nenue@78 577 self:Refresh('FADE_IN_START')
Nenue@75 578 self.isNew = nil
Nenue@75 579 end
Nenue@75 580
Nenue@75 581 function QuestPOI:TryToFade(event)
Nenue@75 582 if self.FadeIn:IsPlaying() then
Nenue@75 583 --qprint('|cFFFF4400TryToFade('..self:GetID()..'|cFFFF4400)|r stopping because already in progress')
Nenue@75 584 return
Nenue@75 585 end
Nenue@75 586
Nenue@75 587 self.fadeEvent = event
Nenue@75 588 if self.dataLoaded then
Nenue@75 589 --qprint('|cFFFFFF00TryToFade('..self:GetID()..'|cFFFFFF00)|r', event)
Nenue@35 590 self:SetAlpha(0)
Nenue@75 591 self.FadeIn.FadeIn:SetToAlpha(db.PinAlpha)
Nenue@75 592 self.FadeIn:Play()
Nenue@75 593 else
Nenue@49 594
Nenue@75 595 --qprint('|cFFFF4400TryToFade('..self:GetID()..'|cFFFF4400)|r stopping because not loaded')
Nenue@34 596 end
Nenue@7 597 end
Nenue@7 598
Nenue@75 599 function QuestPOI:OnAnimStop()
Nenue@49 600 self:SetAlpha(db.PinAlpha)
Nenue@49 601 end
Nenue@49 602
Nenue@40 603 function QuestPOI:OnShow ()
Nenue@27 604
Nenue@69 605 if self.isNew then
Nenue@75 606 self:TryToFade('POI_ONSHOW_NEW')
Nenue@78 607 elseif not self.FadeIn:IsPlaying() then
Nenue@78 608 print('|cFF00FF00Alpha correction')
Nenue@78 609 self:SetAlpha(db.PinAlpha) -- fix stuck alpha
Nenue@69 610 if self.isStale then
Nenue@75 611 --print('|cFF00FF00refresh on show')
Nenue@75 612 self:Refresh('POI_ONSHOW_STALE')
Nenue@69 613 end
Nenue@48 614 end
Nenue@78 615 self:RegisterEvent('QUEST_LOG_UPDATE')
Nick@62 616 self:ShowFrames()
Nenue@27 617 end
Nick@62 618
Nenue@78 619 function QuestPOI:OnEvent(event)
Nenue@78 620 if not TQ_IsActive(self.questID) then
Nenue@78 621
Nenue@78 622 self:UnregisterEvent('QUEST_LOG_UPDATE')
Nenue@78 623
Nenue@78 624 self.hideReason = 'Hiding self because quest is inactive.'
Nenue@78 625 self:SetShown(false)
Nenue@78 626 end
Nenue@78 627 end
Nenue@78 628
Nenue@40 629 function QuestPOI:OnHide()
Nick@60 630 --DEFAULT_CHAT_FRAME:AddMessage('|cFFFFFF00'..self:GetName()..'|r:OnHide()')
Nick@62 631 self:HideFrames()
Nenue@59 632 -- reset flags
Nenue@59 633 self:SetAlpha(db.PinAlpha)
Nenue@49 634 self.isAnimating = nil
Nenue@69 635 if db.Config.DebugEnabled then
Nenue@69 636 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 637 end
Nenue@69 638 self.hideReason = nil
Nenue@27 639 end
Nenue@27 640
Nenue@67 641 -- Applies position and sizing parameters to the pin data
Nenue@66 642 function QuestPOI:SetAnchor(owner, dX, dY, mapWidth, mapHeight, scaleFactor)
Nenue@75 643 --dprint(self:GetName()..':SetAnchor()', owner, dX, dY, scaleFactor, self.filtered, self.used)
Nick@62 644 if not self.used then
Nenue@69 645 self.hideReason = 'SetAnchor() on an unused frame.'
Nick@62 646 self:HideFrames()
Nick@62 647 return
Nick@62 648 end
Nick@62 649
Nenue@75 650
Nenue@67 651 if owner then
Nenue@67 652 self:SetParent(owner)
Nenue@67 653 self.Overlay:SetParent(owner)
Nenue@78 654 self:SetFrameStrata('HIGH')
Nenue@78 655 self:SetFrameLevel(pinBaseIndex + self:GetID())
Nenue@78 656 self.Overlay:SetFrameStrata('HIGH')
Nenue@78 657 self.Overlay:SetFrameLevel(overlayBaseIndex + self:GetID())
Nenue@74 658 self.isStale = true
Nenue@67 659 else
Nenue@67 660 owner = self:GetParent()
Nenue@67 661 end
Nenue@67 662
Nenue@74 663
Nenue@74 664 if scaleFactor then
Nenue@82 665 print('scaleFactor')
Nenue@67 666 self:SetScale(scaleFactor)
Nenue@67 667 self.Overlay:SetScale(scaleFactor)
Nenue@67 668 self.scaleFactor = scaleFactor
Nenue@67 669 end
Nenue@67 670
Nenue@74 671 mapWidth = mapWidth or owner:GetWidth()
Nenue@74 672 mapHeight = mapHeight or owner:GetHeight()
Nenue@74 673 dX = dX or self.x
Nenue@74 674 dY = dY or self.y
Nenue@74 675 --print(owner:GetName() or tostring(owner), self:GetName(), owner:GetScale(), scaleFactor)
Nenue@74 676 if (self.x ~= dX) or (self.y ~= dY) or scaleFactor then
Nenue@67 677
Nenue@74 678 self.x = dX
Nenue@74 679 self.y = dY
Nenue@74 680 local pX = (dX * mapWidth) * (1 / scaleFactor)
Nenue@74 681 local pY = (-dY * mapHeight) * (1 / scaleFactor)
Nenue@74 682 --print('to', pX, pY, self:GetScale())
Nenue@74 683 self:ClearAllPoints()
Nenue@74 684 self:SetPoint('CENTER', owner, 'TOPLEFT', pX, pY)
Nenue@53 685 end
Nick@62 686
Nick@62 687 end
Nick@62 688
Nick@64 689 -- Show/Hide the text overlays associated with the quest pin; they aren't hierarchically linked
Nick@62 690 function QuestPOI:ShowFrames()
Nick@62 691 if not self:IsShown() then
Nenue@75 692 -- print('|cFFFFFF00' ..self:GetName()..':ShowFrames()')
Nick@64 693 -- do not SetShown() here
Nick@64 694 end
Nick@62 695 self.Overlay:SetShown(true)
Nick@62 696 self.count:SetShown(true)
Nick@62 697 self.timeLabel:SetShown(true)
Nick@62 698 end
Nick@62 699
Nick@62 700 function QuestPOI:HideFrames()
Nick@62 701 if self:IsShown() then
Nenue@69 702 if not self.hideReason then
Nenue@69 703 self.hideReason = "HideFrames() called"
Nenue@69 704 end
Nick@62 705 end
Nick@62 706 self.Overlay:SetShown(false)
Nick@62 707 self.count:SetShown(false)
Nick@62 708 self.timeLabel:SetShown(false)
Nenue@7 709 end
Nenue@7 710
Nenue@40 711 function QuestPOI:OnLoad()
Nenue@75 712 --qprint('|cFF00FF88'..self:GetName()..':OnLoad()|r',db.Config)
Nenue@67 713 self.debugTimer = 4
Nenue@40 714 self.title = '|cFF0088FF' .. RETRIEVING_DATA..'|r'
Nenue@40 715 self.isPending = true
Nenue@36 716 self.count = self.Overlay.count
Nick@62 717 self.timeLabel = self.Overlay.timeLabel
Nenue@54 718 self.Description = self.Overlay.Description
Nenue@40 719 self.updateRate = PIN_REQUEST_DELAY
Nenue@40 720 self.itemName = '|cFF0088FF' .. RETRIEVING_DATA..'|r'
Nenue@41 721
Nenue@53 722 self.Overlay:SetPoint('TOPLEFT', self, 'TOPLEFT', 0, 4)
Nenue@53 723 self.Overlay:SetPoint('BOTTOMRIGHT', self, 'BOTTOMRIGHT', 0, -4)
Nenue@7 724 end
Nick@64 725
Nenue@57 726 function QuestPOI:OnMouseDown(button)
Nenue@57 727 if button == 'RightButton' then
Nenue@57 728 SetSuperTrackedQuestID(nil)
Nenue@57 729 else
Nenue@57 730 TaskPOI_OnClick(self, button)
Nenue@57 731 end
Nenue@57 732 end
Nenue@57 733
Nenue@75 734 local updateTime, markTime
Nenue@40 735 function QuestPOI:OnUpdate (sinceLast)
Nenue@40 736 -- control update check intervals
Nenue@67 737
Nenue@67 738
Nenue@40 739 self.throttle = (self.throttle or self.updateRate) + sinceLast
Nenue@40 740 if self.throttle >= self.updateRate then
Nenue@40 741 -- factor overtime into the throttle timer
Nenue@40 742 self.throttle = self.throttle - self.updateRate
Nenue@40 743 else
Nenue@40 744 return
Nenue@40 745 end
Nenue@67 746 --@debug@
Nenue@67 747 if DATA_DEBUG then
Nenue@67 748 self.debugTimer = self.debugTimer - sinceLast
Nenue@67 749 if self.debugTimer >= 0 then
Nenue@67 750 print(self.debugTimer)
Nenue@75 751 return
Nenue@67 752 end
Nenue@35 753 end
Nenue@67 754 --@end-debug@
Nenue@7 755
Nenue@7 756 -- query for reward data if it wasn't found in the original scan
Nenue@69 757
Nenue@65 758 if not self.dataLoaded then
Nenue@69 759
Nenue@66 760 local dataLoaded = self:GetData()
Nenue@67 761 if dataLoaded and not tContains(db.UpdatedPins, self) then
Nenue@75 762 -- self.PendingFade:Stop()
Nenue@74 763 -- scale info from the parent module is needed, so deal with it there
Nenue@75 764 --print('|cFF00FF88 queueing for update')
Nenue@67 765 tinsert(db.UpdatedPins, self)
Nenue@75 766 else
Nenue@75 767
Nenue@75 768 --print('|cFFFF4400OnUpdate(|r'..self:GetID()..'|cFFFF4400)|r poll failed')
Nenue@66 769 end
Nenue@7 770 return
Nenue@7 771 end
Nenue@7 772
Nenue@69 773 if self.maxAlertLevel then
Nenue@69 774 self:UpdateStatus()
Nenue@69 775 end
Nenue@69 776
Nenue@55 777 end
Nenue@7 778
Nenue@78 779 -- Non-hieriarchical display states, checked separately from used/filtered states
Nenue@74 780 function QuestPOI:GetCriteriaState()
Nenue@74 781 local isCriteria, isBounty, isSpellTarget
Nenue@74 782 if self.factionID then
Nenue@75 783 for index, bounty in pairs(db.Bounties) do
Nenue@75 784 if IsQuestCriteriaForBounty(self.questID, bounty.questID) then
Nenue@75 785 isCriteria = true
Nenue@75 786 if db.selectedBounty == bounty then
Nenue@75 787 isBounty = true
Nenue@74 788 end
Nenue@75 789 --dprint('|cFF00FF88Criteria:|r', self.questID, bounty.questID, isCriteria, isBounty)
Nenue@74 790 end
Nenue@74 791 end
Nenue@74 792 end
Nenue@74 793 isSpellTarget = IsQuestIDValidSpellTarget(self.questID)
Nenue@74 794
Nenue@74 795 if (self.isBounty ~= isBounty) or (self.isCriteria ~= isCriteria) or (self.isSpellTarget ~= isSpellTarget) then
Nenue@75 796 --wqprint('|cFF00FF00criteria state changed')
Nenue@74 797 self.isBounty = isBounty
Nenue@74 798 self.isCriteria = isCriteria
Nenue@74 799 self.isSpellTarget = isSpellTarget
Nenue@75 800 self.isStale = true
Nenue@74 801 return true
Nenue@74 802 end
Nenue@74 803 end
Nenue@74 804
Nenue@55 805 -- Called at static intervals and with Refresh
Nenue@55 806 function QuestPOI:UpdateStatus()
Nenue@7 807 -- update time elements
Nick@64 808 self.isActive = TQ_IsActive(self.questID)
Nick@64 809
Nick@64 810 if self.isActive then
Nenue@40 811 local tl = self.alertLevel
Nenue@55 812 local timeLeft = TQ_GetQuestTimeLeftMinutes(self.questID)
Nenue@40 813 if timeLeft > 0 then
Nenue@40 814
Nenue@40 815 local text, timeState = WorldPlan:GetTimeInfo(timeLeft, self.maxAlertLevel)
Nenue@40 816 if tl ~= timeState then
Nenue@40 817 tl = timeState
Nenue@40 818 self.timeLabel:SetText(text)
Nenue@40 819 end
Nenue@7 820 end
Nenue@55 821
Nenue@74 822 local border = (self.isBounty or self.isCriteria) and self.RewardBorder or self.HighlightBorder
Nenue@74 823
Nenue@57 824 if tl and (timeLeft < 120) then
Nenue@74 825 border:SetVertexColor(1,0,0,0.7)
Nenue@55 826 else
Nenue@74 827 border:SetVertexColor(0,0,0,0.7)
Nenue@55 828 end
Nenue@40 829 self.alertLevel = tl
Nick@60 830 self.timeLabel:SetShown(self.worldQuest and (self.maxAlertLevel >= 1))
Nenue@59 831 else
Nenue@69 832 self.hideReason = "No longer active."
Nenue@69 833 self:HideFrames()
Nenue@69 834
Nenue@7 835 end
Nenue@8 836 end
Nenue@8 837
Nenue@66 838
Nenue@74 839 function QuestPOI:Refresh (event)
Nenue@49 840
Nenue@75 841 print('|cFF00FF88Refresh(|r'..self:GetID()..'|cFF00FF88)|r', event, self.title)
Nenue@49 842
Nenue@66 843 local style = DEFAULT_STYLE
Nenue@66 844 if self.dataLoaded and not self.filtered then
Nenue@66 845 style = REWARD_TYPE_STYLES[self.rewardType]
Nenue@66 846 else
Nenue@66 847 style = MINIMIZED_STYLE
Nenue@66 848 end
Nenue@49 849
Nenue@66 850 local currentWidth = style.iconWidth or DEFAULT_STYLE.iconWidth
Nenue@9 851
Nenue@9 852
Nenue@66 853
Nenue@66 854 local borderWidth = style.borderWidth or DEFAULT_STYLE.borderWidth
Nenue@66 855 local highlightWidth = style.highlightWidth or DEFAULT_STYLE.highlightWidth
Nenue@66 856 local tagSize = style.TagSize or DEFAULT_STYLE.TagSize
Nenue@66 857 local hideIcon = style.hideIcon or DEFAULT_STYLE.hideIcon
Nenue@66 858 local borderColor = style.border or DEFAULT_STYLE.border
Nenue@69 859 local textColor = style.textColor or DEFAULT_STYLE.textColor
Nenue@57 860 local questID = self.questID
Nenue@36 861 local iconBorder = self.RewardBorder
Nenue@36 862 local trackingBorder = self.HighlightBorder
Nenue@9 863 local icon = self.icon
Nenue@9 864 local count = self.count
Nenue@66 865 local hideNumbers = style.hideNumber or DEFAULT_STYLE.hideNumber
Nenue@66 866
Nenue@66 867 local tagIcon = self.tagIcon
Nenue@66 868 self.maxAlertLevel = style.maxAlertLevel or DEFAULT_STYLE.maxAlertLevel
Nenue@66 869
Nenue@74 870
Nenue@9 871 if self.itemName then
Nenue@66 872 if self.itemNumber and (self.itemNumber > 1) and (not hideNumbers) then
Nenue@54 873 local numberString = self.itemNumber
Nenue@65 874 if self.itemNumber >= 1000000 then
Nenue@65 875 numberString = (floor(self.itemNumber/100000)/10) .. 'M'
Nenue@65 876 elseif self.itemNumber >= 10000 then
Nenue@65 877 numberString = floor(self.itemNumber/1000) .. 'k'
Nenue@65 878 elseif self.itemNumber >= 1000 then
Nenue@54 879 local numeral = floor(self.itemNumber/1000)
Nenue@54 880 local decimal = mod(self.itemNumber, 1000)
Nenue@54 881 numberString = numeral
Nenue@54 882 if decimal > 100 then
Nenue@54 883 numberString = numberString .. '.' .. tostring(floor(decimal/100))
Nenue@54 884 end
Nenue@54 885 numberString = numberString .. 'k'
Nenue@40 886 end
Nenue@69 887
Nenue@45 888 self.count:SetText(numberString)
Nenue@69 889 self.count:SetTextColor(unpack(textColor))
Nenue@66 890 self.count:Show()
Nenue@45 891 else
Nenue@54 892 self.count:SetText(nil)
Nenue@66 893 self.count:Hide()
Nenue@45 894 end
Nenue@66 895 else
Nenue@66 896 self.count:Hide()
Nenue@54 897 end
Nenue@30 898
Nenue@55 899 if db.Config.ShowVerboseInfo then
Nenue@55 900 self.Description:SetText(self.title .. "\n" .. floor(self.x*100+.5) .. "," .. floor(self.y*100+.5))
Nenue@55 901 end
Nenue@55 902
Nenue@40 903
Nenue@66 904 icon:SetSize(currentWidth, currentWidth)
Nenue@66 905 icon:SetMask(style.iconMask or DEFAULT_STYLE.iconMask)
Nenue@36 906 if self.itemTexture then
Nenue@47 907 --iconBorder:SetTexture(WORLD_QUEST_BORDER)
Nenue@40 908
Nenue@66 909 if hideIcon then
Nenue@40 910 icon:SetTexture(PENDING_ICON)
Nenue@40 911 icon:SetDesaturated(true)
Nenue@66 912 icon:SetVertexColor(unpack(borderColor))
Nenue@40 913 else
Nenue@40 914 icon:SetTexture(self.itemTexture)
Nenue@40 915 icon:SetDesaturated(false)
Nenue@40 916 icon:SetVertexColor(1, 1, 1)
Nenue@40 917 end
Nenue@40 918 else
Nenue@47 919 --
Nenue@40 920 icon:SetTexture(PENDING_ICON)
Nenue@40 921 icon:SetDesaturated(true)
Nenue@66 922 icon:SetVertexColor(unpack(borderColor))
Nenue@9 923 end
Nenue@66 924 local borderMask = style.borderMask or DEFAULT_STYLE.borderMask
Nenue@74 925 local borderSize = currentWidth + (borderWidth * 2) + (self.isCriteria and 2 or 0)
Nenue@9 926
Nenue@66 927
Nenue@66 928 iconBorder:SetSize(borderSize, borderSize)
Nenue@66 929 iconBorder:SetMask(borderMask)
Nenue@47 930 iconBorder:SetTexture(PENDING_BORDER)
Nenue@74 931
Nenue@66 932 iconBorder:SetDesaturated(true)
Nenue@52 933
Nenue@66 934 local highlightSize = borderSize + (highlightWidth * 2)
Nenue@66 935 trackingBorder:SetSize(highlightSize, highlightSize)
Nenue@66 936 trackingBorder:SetMask(borderMask)
Nenue@66 937 trackingBorder:SetTexture(PENDING_BORDER)
Nenue@9 938
Nenue@66 939 self:SetSize(borderSize, borderSize)
Nenue@66 940
Nenue@66 941
Nenue@66 942
Nenue@66 943 iconBorder:SetPoint('CENTER', (style.x or 0), (style.y or 0))
Nenue@66 944 trackingBorder:SetPoint('CENTER', (style.x or 0), (style.y or 0))
Nenue@9 945
Nenue@49 946 self.tagIcon:SetShown((not self.filtered) and true or false)
Nenue@9 947 self.tagIcon:SetAtlas(self.tagAtlas)
Nenue@47 948 self.EliteBorder:SetShown(self.isElite and not self.filtered)
Nenue@36 949
Nenue@9 950 self:UpdateSize()
Nenue@55 951 self:UpdateStatus()
Nenue@33 952 self.isStale = nil
Nenue@57 953
Nenue@74 954 if self.isBounty then
Nenue@75 955 --print('is bounty')
Nenue@74 956 iconBorder:SetVertexColor(trackingBorder:GetVertexColor())
Nenue@74 957 trackingBorder:SetVertexColor(unpack(BORDER_SELECTED_BOUNTY))
Nenue@74 958 elseif self.isCriteria then
Nenue@75 959 --print('is criteria of a bounty')
Nenue@74 960 iconBorder:SetVertexColor(trackingBorder:GetVertexColor())
Nenue@74 961 trackingBorder:SetVertexColor(unpack(BORDER_CRITERIA))
Nenue@74 962 else
Nenue@74 963
Nenue@74 964 iconBorder:SetVertexColor(unpack(borderColor))
Nenue@74 965 trackingBorder:SetVertexColor(1,1,1,1)
Nenue@74 966 end
Nenue@73 967
Nenue@73 968 if SpellCanTargetQuest() then
Nenue@73 969 if IsQuestIDValidSpellTarget(self.questID) then
Nenue@73 970 icon:SetVertexColor(1,1,1)
Nenue@73 971 else
Nenue@73 972 icon:SetVertexColor(1,0,0,1)
Nenue@73 973 end
Nenue@73 974 self:EnableMouse(false)
Nenue@73 975 else
Nenue@73 976 self:EnableMouse(true)
Nenue@73 977 end
Nenue@73 978
Nenue@57 979 -- signal filter info update
Nenue@57 980 WorldPlanSummary.isStale = true
Nenue@9 981 end
Nenue@9 982
Nenue@35 983 local cvar_check = {
Nenue@35 984 [REWARD_CASH] = 'worldQuestFilterGold',
Nenue@35 985 [REWARD_ARTIFACT_POWER] = 'worldQuestFilterArtifactPower',
Nenue@35 986 [REWARD_CURRENCY] = 'worldQuestFilterOrderResources',
Nenue@35 987 [REWARD_REAGENT]= 'worldQuestFilterProfessionMaterials',
Nenue@35 988 [REWARD_GEAR] = 'worldQuestFilterEquipment',
Nenue@35 989 }
Nenue@8 990
Nick@64 991
Nenue@57 992 function QuestPOI:CheckFilterRules ()
Nenue@36 993 local print = qprint
Nenue@33 994 local qType = self.worldQuestType
Nenue@78 995 if not TQ_IsActive(self.questID) then
Nenue@78 996 self.hideReason = 'Filter check ended because quest is inactive.'
Nenue@78 997 self.used = nil
Nenue@78 998 self:SetShown(false)
Nenue@78 999 return
Nenue@78 1000 end
Nenue@69 1001
Nenue@69 1002 if qType == LE_QUEST_TAG_TYPE_PROFESSION then
Nenue@57 1003 if not(self.isKnownProfession or db.Config.ShowAllProfessionQuests) then
Nenue@78 1004 self.hideReason = 'Failed profession check.'
Nenue@78 1005 self.used = nil
Nenue@78 1006 self:SetShown(false)
Nenue@78 1007 return
Nenue@36 1008 end
Nenue@36 1009 end
Nenue@57 1010
Nenue@78 1011 local filtered
Nenue@78 1012 for filterKey, value in pairs(db.UsedFilters) do
Nenue@78 1013 if self[filterKey] ~= value then
Nenue@78 1014 if not self.filtered then
Nenue@78 1015 print('|cFFFF4400filtering', filterKey, value, '~=', self[filterKey], self.title)
Nenue@57 1016 end
Nenue@78 1017 filtered = true
Nenue@57 1018 end
Nenue@78 1019 end
Nenue@78 1020 if self.rewardType and cvar_check[self.rewardType] then
Nenue@78 1021 if not GetCVarBool(cvar_check[self.rewardType]) then
Nenue@78 1022 filtered = true
Nenue@57 1023 end
Nenue@57 1024 end
Nenue@78 1025
Nenue@78 1026 print(' '..self.questID..':|cFFFFFF00CheckFilterRules()|r', filtered, self.title)
Nenue@78 1027 if self.filtered ~= filtered then
Nenue@82 1028 wqprint('|cFF00FF00filter changed')
Nenue@78 1029 self.isStale = true
Nenue@69 1030 end
Nenue@78 1031
Nenue@82 1032 self.filtered = filtered
Nenue@78 1033 self.used = true
Nenue@78 1034 self:SetShown(true)
Nenue@33 1035 end
Nenue@33 1036
Nenue@33 1037 --- Fixes icons upon size update
Nenue@36 1038 function QuestPOI:UpdateSize ()
Nenue@33 1039
Nenue@49 1040 --qprint('|cFF00BB88'..self:GetID()..'|r:UpdateSize()', self.style, self.subStyle)
Nenue@66 1041 return
Nenue@66 1042 --[[
Nenue@40 1043 local style = self.style
Nenue@40 1044 local subStyle = self.subStyle
Nenue@36 1045 local icon = self.icon
Nenue@36 1046 local iconBorder = self.RewardBorder
Nenue@36 1047 local trackingBorder = self.HighlightBorder
Nenue@36 1048 local tag = self.tagIcon
Nenue@33 1049
Nenue@36 1050 local iconWidth = subStyle.iconWidth
Nenue@36 1051 local borderWidth = iconWidth + (subStyle.borderWidth * 2)
Nenue@36 1052 local highlightWidth = borderWidth + (subStyle.highlightWidth * 2)
Nenue@36 1053 local iconTexture = self.itemTexture
Nenue@33 1054
Nenue@47 1055
Nenue@56 1056 self:SetSize(highlightWidth, highlightWidth)
Nenue@47 1057 if self.questID == GetSuperTrackedQuestID() then
Nenue@47 1058 highlightWidth = highlightWidth + 2
Nenue@57 1059 if self.filtered then
Nenue@57 1060 self:SetAlpha(db.PinAlpha * 0.5)
Nenue@57 1061 else
Nenue@57 1062 self:SetAlpha(db.PinAlpha)
Nenue@57 1063 end
Nenue@57 1064
Nenue@47 1065 end
Nenue@47 1066
Nenue@47 1067 if self.rarity and WORLD_QUEST_QUALITY_COLORS[self.rarity] then
Nenue@47 1068 highlightWidth = highlightWidth + self.rarity
Nenue@47 1069 end
Nenue@40 1070 self.tagIcon:SetSize(self.tagSize, self.tagSize)
Nenue@36 1071 icon:SetSize(iconWidth, iconWidth)
Nenue@36 1072 iconBorder:SetSize(borderWidth, borderWidth)
Nenue@36 1073 trackingBorder:SetSize(highlightWidth, highlightWidth)
Nenue@33 1074
Nenue@36 1075
Nenue@36 1076 iconBorder:SetPoint('CENTER', (style.x or 0), (style.y or 0))
Nenue@36 1077 trackingBorder:SetPoint('CENTER', (style.x or 0), (style.y or 0))
Nenue@36 1078
Nenue@36 1079
Nick@62 1080 if (subStyle.showNumber and self.itemNumber) and style.hasNumeric then
Nenue@36 1081 self.count:SetTextColor(unpack(style.numberRGB))
Nenue@36 1082 if subStyle.numberFontObject then
Nenue@36 1083 --wqprint('change font', _G[subStyle.numberFontObject]:GetName())
Nenue@36 1084 self.count:SetFontObject(_G[subStyle.numberFontObject])
Nenue@36 1085 end
Nick@62 1086 else
Nick@62 1087 self.count:SetText(nil)
Nenue@33 1088 end
Nenue@66 1089 --]]
Nenue@7 1090 end