annotate QuestPOI.lua @ 93:98b5e08b75ed v1.4.9

- Fixed quest completion checking and handling - Changed animation method to hopefully stop weird flickering. - Pins are now visible before full reward data is loaded - Filter bar redesigned: - aligned horizontally along the top of the map display - filter buttons display a '+' when there are matches in both current and other zones, and '*' when there only matches in other zones - button tooltips separate local and global quests - button categories are highlighted and labeled when the cursor is over them - Fixed invalid POI targets appearing when the spell targeting cursor is active
author Nenue
date Sat, 15 Apr 2017 11:04:54 -0400
parents 77013bd72adb
children b29b35cb8539
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@93 29 local pairs, ipairs, tinsert, tremove, unpack, select = pairs, ipairs, tinsert, tremove, 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@93 43 local pinBaseIndex = 1320
Nenue@93 44 local overlayBaseIndex = 1380
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@93 255 function QuestPOI:OnLoad()
Nenue@93 256 --qprint('|cFF00FF88'..self:GetName()..':OnLoad()|r',db.Config)
Nenue@93 257 self.debugTimer = 4
Nenue@93 258 self.title = '|cFF0088FF' .. RETRIEVING_DATA..'|r'
Nenue@93 259 self.count = self.Overlay.count
Nenue@93 260 self.timeLabel = self.Overlay.timeLabel
Nenue@93 261 self.Description = self.Overlay.Description
Nenue@93 262 self.updateRate = PIN_REQUEST_DELAY
Nenue@93 263 self.itemName = '|cFF0088FF' .. RETRIEVING_DATA..'|r'
Nenue@93 264
Nenue@93 265
Nenue@93 266 self.IconBackdrop:SetVertexColor(0,0,0,1)
Nenue@93 267 self.Overlay:SetPoint('TOPLEFT', self, 'TOPLEFT', 0, 4)
Nenue@93 268 self.Overlay:SetPoint('BOTTOMRIGHT', self, 'BOTTOMRIGHT', 0, -4)
Nenue@93 269 end
Nenue@93 270
Nenue@93 271 function QuestPOI:OnShow ()
Nenue@93 272 if self.isStale then
Nenue@93 273 --print('|cFF00FF00refresh on show')
Nenue@93 274 self:Refresh('POI_ONSHOW_STALE')
Nenue@93 275 end
Nenue@93 276 self:RegisterEvent('QUEST_TURNED_IN')
Nenue@93 277 self:RegisterEvent('QUEST_LOG_UPDATE')
Nenue@93 278 self:HideOrShowFrames(true)
Nenue@93 279 end
Nenue@93 280
Nenue@93 281 function QuestPOI:OnEvent(event, questID)
Nenue@93 282 if (self.questID == questID) and IsQuestComplete(self.questID) then
Nenue@93 283 db.log(self.questID .. " Marked completed.")
Nenue@93 284 self:Release()
Nenue@93 285 end
Nenue@93 286 end
Nenue@93 287
Nenue@93 288 function QuestPOI:OnHide()
Nenue@93 289 --DEFAULT_CHAT_FRAME:AddMessage('|cFFFFFF00'..self:GetName()..'|r:OnHide()')
Nenue@93 290 self:HideOrShowFrames(false)
Nenue@93 291 -- reset flags
Nenue@93 292 self:SetAlpha(db.PinAlpha)
Nenue@93 293 self.isAnimating = nil
Nenue@93 294 if db.Config.DebugEnabled then
Nenue@93 295 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@93 296 end
Nenue@93 297 self.hideReason = nil
Nenue@93 298 end
Nenue@40 299
Nenue@40 300 function QuestPOI:OnEnter()
Nenue@57 301 if self.filtered and (self.questID ~= GetSuperTrackedQuestID()) then
Nenue@49 302 return
Nenue@7 303 end
Nenue@57 304 WorldMap_HijackTooltip(self.owningFrame);
Nenue@56 305 self:SetFrameLevel(pinBaseIndex+100)
Nenue@78 306 self.Overlay:SetFrameLevel(overlayBaseIndex+100)
Nenue@56 307
Nenue@56 308 if previousHighlight then
Nenue@56 309 previousHighlight:SetFrameLevel(pinBaseIndex+previousHighlight:GetID())
Nenue@56 310 previousHighlight.Overlay:SetFrameLevel(overlayBaseIndex+previousHighlight:GetID())
Nenue@56 311 end
Nenue@56 312
Nenue@56 313 previousHighlight = self
Nenue@56 314
Nenue@56 315
Nenue@40 316 WorldMapTooltip:SetOwner(self, "ANCHOR_RIGHT");
Nenue@49 317 --print('doing tooltip stuff')
Nenue@40 318
Nenue@40 319 -- Can't add stuff after, so most of the blizzard tooltip hook is simply copied over
Nenue@40 320 local questID = self.questID
Nenue@40 321 local color = WORLD_QUEST_QUALITY_COLORS[self.rarity] or NORMAL_FONT_COLOR;
Nenue@40 322
Nenue@40 323
Nenue@40 324 WorldMapTooltip:SetText(self.title, color.r, color.g, color.b);
Nenue@40 325 QuestUtils_AddQuestTypeToTooltip(WorldMapTooltip, questID, NORMAL_FONT_COLOR);
Nenue@40 326
Nenue@40 327 if ( self.factionID ) then
Nenue@40 328 local factionName = GetFactionInfoByID(self.factionID);
Nenue@40 329 if ( factionName ) then
Nenue@40 330 if (self.capped) then
Nenue@40 331 WorldMapTooltip:AddLine(factionName, GRAY_FONT_COLOR:GetRGB());
Nenue@40 332 else
Nenue@40 333 WorldMapTooltip:AddLine(factionName);
Nenue@40 334 end
Nenue@40 335 end
Nenue@40 336 end
Nenue@40 337
Nenue@40 338 if self.worldQuest then
Nenue@40 339 WorldMap_AddQuestTimeToTooltip(questID);
Nenue@40 340 end
Nenue@40 341
Nenue@40 342
Nenue@40 343 for objectiveIndex = 1, self.numObjectives do
Nenue@40 344 local objectiveText, objectiveType, finished = GetQuestObjectiveInfo(questID, objectiveIndex, false);
Nenue@40 345 if ( objectiveText and #objectiveText > 0 ) then
Nenue@40 346 local color = finished and GRAY_FONT_COLOR or HIGHLIGHT_FONT_COLOR;
Nenue@40 347 WorldMapTooltip:AddLine(QUEST_DASH .. objectiveText, color.r, color.g, color.b, true);
Nenue@40 348 end
Nenue@40 349 end
Nenue@40 350
Nenue@40 351 local percent = C_TaskQuest.GetQuestProgressBarInfo(self.questID);
Nenue@40 352 if ( percent ) then
Nenue@40 353 GameTooltip_InsertFrame(WorldMapTooltip, WorldMapTaskTooltipStatusBar);
Nenue@40 354 WorldMapTaskTooltipStatusBar.Bar:SetValue(percent);
Nenue@40 355 WorldMapTaskTooltipStatusBar.Bar.Label:SetFormattedText(PERCENTAGE_STRING, percent);
Nenue@40 356 end
Nenue@40 357
Nenue@40 358 if db.TooltipExtras[self.questID] then
Nenue@40 359 for index, info in pairs(db.TooltipExtras[questID]) do
Nenue@40 360 if info.achievementID then
Nenue@40 361 GetAchievementTooltipExtras(info)
Nenue@40 362 end
Nenue@40 363 if info.questID then
Nenue@40 364 GetQuestTooltipExtras(info)
Nenue@40 365 end
Nenue@40 366 end
Nenue@40 367 end
Nenue@65 368 GameTooltip_AddQuestRewardsToTooltip(WorldMapTooltip, questID)
Nenue@40 369
Nenue@40 370 WorldMapTooltip:Show()
Nenue@40 371 --WorldMapTooltip.recalculatePadding = true;
Nenue@40 372 --print(WorldMapTooltip:GetParent())
Nenue@40 373 --print(WorldMapTooltip:IsVisible())
Nenue@7 374 end
Nenue@93 375
Nenue@93 376 function QuestPOI:OnMouseDown(button)
Nenue@93 377 if button == 'RightButton' then
Nenue@93 378 SetSuperTrackedQuestID(nil)
Nenue@93 379 else
Nenue@93 380 TaskPOI_OnClick(self, button)
Nenue@93 381 end
Nenue@93 382 end
Nenue@93 383
Nenue@40 384 function QuestPOI:OnLeave()
Nenue@57 385 if self.filtered and (self.questID ~= GetSuperTrackedQuestID()) then
Nenue@57 386 return
Nenue@57 387 end
Nenue@35 388 WorldMap_RestoreTooltip()
Nenue@40 389 WorldMapTooltip:Hide();
Nenue@7 390 end
Nenue@7 391
Nenue@93 392 local updateTime, markTime
Nenue@93 393 function QuestPOI:OnUpdate (sinceLast)
Nenue@93 394 -- control update check intervals
Nenue@93 395
Nenue@93 396 if self.animating then
Nenue@93 397 local alpha = self.icon:GetAlpha() + sinceLast*3
Nenue@93 398
Nenue@93 399 self.animateTime = (self.animateTime or 0) + sinceLast
Nenue@93 400 if alpha >= 1 then
Nenue@93 401 alpha = 1
Nenue@93 402 print('fade over', self.animateTime)
Nenue@93 403 self.animating = nil
Nenue@93 404 self.animateTime = nil
Nenue@93 405
Nenue@93 406 end
Nenue@93 407
Nenue@93 408 self.icon:SetAlpha(alpha)
Nenue@93 409 self.RewardBorder:SetAlpha(alpha)
Nenue@93 410 end
Nenue@93 411
Nenue@93 412 self.throttle = (self.throttle or self.updateRate) + sinceLast
Nenue@93 413 if self.throttle >= self.updateRate then
Nenue@93 414 -- factor overtime into the throttle timer
Nenue@93 415 self.throttle = self.throttle - self.updateRate
Nenue@93 416 else
Nenue@93 417 return
Nenue@93 418 end
Nenue@93 419 --@debug@
Nenue@93 420 if DATA_DEBUG then
Nenue@93 421 self.debugTimer = self.debugTimer - sinceLast
Nenue@93 422 if self.debugTimer >= 0 then
Nenue@93 423 print(self.debugTimer)
Nenue@93 424 return
Nenue@93 425 end
Nenue@93 426 end
Nenue@93 427 --@end-debug@
Nenue@93 428
Nenue@93 429 -- query for reward data if it wasn't found in the original scan
Nenue@93 430
Nenue@93 431 if not self.dataLoaded then
Nenue@93 432 local dataLoaded = self:GetData()
Nenue@93 433 if dataLoaded and not tContains(db.UpdatedPins, self) then
Nenue@93 434 -- self.PendingFade:Stop()
Nenue@93 435 -- scale info from the parent module is needed, so deal with it there
Nenue@93 436 print('|cFF00FF88 queueing for update')
Nenue@93 437 self.isNew = true
Nenue@93 438 tinsert(db.UpdatedPins, self)
Nenue@93 439 else
Nenue@93 440
Nenue@93 441 --print('|cFFFF4400OnUpdate(|r'..self:GetID()..'|cFFFF4400)|r poll failed')
Nenue@93 442 end
Nenue@93 443 return
Nenue@93 444 end
Nenue@93 445
Nenue@93 446 if self.maxAlertLevel then
Nenue@93 447 self:UpdateStatus()
Nenue@93 448 end
Nenue@93 449 end
Nenue@93 450
Nenue@93 451
Nenue@93 452 function QuestPOI:StartFading()
Nenue@93 453 if not self.animating then
Nenue@93 454 self.animating = true
Nenue@93 455 self.icon:SetAlpha(0)
Nenue@93 456 self.RewardBorder:SetAlpha(0)
Nenue@93 457 end
Nenue@93 458 end
Nenue@93 459
Nenue@40 460 -- attempt to pull pin data
Nenue@40 461 function QuestPOI:GetData ()
Nenue@75 462 --dprint('|cFF00FF88'..self:GetID()..':GetData()|r')
Nenue@40 463 local questID = self.questID
Nenue@40 464 if not questID then
Nenue@75 465 --dprint('|cFFFF4400bad pin|r', self:GetName())
Nenue@40 466 return nil
Nenue@29 467 end
Nenue@29 468
Nenue@40 469 local questTitle, factionID, capped = TQ_GetQuestInfoByQuestID(questID)
Nenue@40 470 -- if the title is nil, then wait and try later
Nenue@40 471 if not questTitle then
Nenue@75 472 --dprint('|cFFBB8844dataLoaded|r = false|cFF00FFFF', self.questId)
Nenue@65 473 return false
Nenue@40 474 else
Nenue@40 475 self.title, self.factionID, self.capped = questTitle, factionID, capped
Nenue@93 476 --print(questTitle, factionID, capped)
Nenue@40 477 -- set tag details
Nenue@40 478 local worldQuestType
Nenue@40 479 self.tagID, self.tagName, worldQuestType, self.rarity, self.isElite, self.tradeskillLineIndex = GetQuestTagInfo(questID);
Nenue@40 480 local tagAtlas
Nenue@40 481 if worldQuestType == LE_QUEST_TAG_TYPE_PET_BATTLE then
Nenue@40 482 tagAtlas = "worldquest-icon-petbattle"
Nenue@40 483 elseif worldQuestType == LE_QUEST_TAG_TYPE_PVP then
Nenue@40 484 tagAtlas = "worldquest-icon-pvp-ffa"
Nenue@40 485 elseif worldQuestType == LE_QUEST_TAG_TYPE_PROFESSION then
Nenue@40 486 self.isKnownProfession = nil
Nenue@40 487 local id = self.tradeskillLineIndex and select(7, GetProfessionInfo(self.tradeskillLineIndex))
Nenue@40 488 if id then
Nenue@40 489 self.isKnownProfession = true
Nenue@75 490 --qprint('profession' , self.title, id)
Nenue@40 491 tagAtlas = WORLD_QUEST_ICONS_BY_PROFESSION[id]
Nenue@40 492 end
Nenue@40 493 elseif worldQuestType == LE_QUEST_TAG_TYPE_DUNGEON then
Nenue@40 494 tagAtlas = "worldquest-icon-dungeon"
Nenue@40 495 end
Nenue@40 496 self.worldQuestType = worldQuestType
Nenue@40 497 self.tagAtlas = tagAtlas
Nenue@29 498
Nenue@69 499 local dataLoaded, rewardType, itemName, itemTexture, itemNumber, quality, xpType, xpName, xpIcon, xpCount = self:UpdateRewards()
Nenue@75 500 --dprint('|cFFBB8844 dataLoaded|r =', dataLoaded, rewardType, itemName, itemTexture, itemNumber, quality)
Nenue@65 501 if dataLoaded then
Nenue@65 502 self.rewardType = rewardType
Nenue@65 503 self.itemName = itemName
Nenue@65 504 self.itemTexture = itemTexture
Nenue@65 505 self.itemNumber = itemNumber
Nenue@65 506 self.itemQuality = quality
Nenue@49 507 self.dataLoaded = true
Nenue@48 508 self.isStale = true
Nenue@69 509 self.xpType, self.xpName, self.xpIcon, self.xpCount = xpType, xpName, xpIcon, xpCount
Nenue@69 510
Nenue@40 511 end
Nenue@40 512 end
Nenue@40 513
Nenue@40 514
Nenue@65 515 return self.dataLoaded
Nenue@40 516 end
Nenue@40 517
Nenue@69 518 local ID_RESOURCES = 1220
Nenue@69 519 local ID_LEGIONFALL = 1342
Nenue@69 520
Nenue@65 521 --- Returns true if data has changed (either from loading in or qualifications changed)
Nenue@65 522 function QuestPOI:UpdateRewards()
Nenue@40 523 local questID = self.questID
Nenue@65 524 if not HaveQuestRewardData(questID) then
Nenue@65 525 C_TaskQuest.RequestPreloadRewardData(questID);
Nenue@65 526 return false;
Nenue@29 527 else
Nenue@65 528 local rewardMoney, rewardAP, rewardHonor
Nenue@65 529 local rewardItems, rewardCurrency = {}, {}
Nenue@65 530 local rewardIcon, rewardName, rewardCount, rewardStyle, rewardType, itemID, quantity, quality
Nenue@65 531 local xpIcon, xpName, xpCount, xpType
Nenue@69 532 local foundPrimary
Nenue@29 533
Nenue@65 534 if (GetNumQuestLogRewardCurrencies(questID) > 0 or GetNumQuestLogRewards(questID) > 0 or GetQuestLogRewardMoney(questID) > 0 or GetQuestLogRewardArtifactXP(questID) > 0 or GetQuestLogRewardHonor(questID)) then
Nenue@65 535 local money = GetQuestLogRewardMoney(questID)
Nenue@65 536 if money > 0 then
Nenue@65 537 rewardMoney = money
Nenue@65 538 rewardIcon = ICON_MONEY
Nenue@65 539 rewardName = GetMoneyString(money)
Nenue@65 540 rewardCount = floor(money/10000)
Nenue@65 541 rewardType = REWARD_CASH
Nenue@65 542 end
Nenue@65 543
Nenue@65 544 local artifactXP = GetQuestLogRewardArtifactXP(questID);
Nenue@65 545 if artifactXP > 0 then
Nenue@65 546 rewardAP = artifactXP
Nenue@65 547 rewardIcon = "Interface\\ICONS\\inv_7xp_inscription_talenttome01"
Nenue@65 548 rewardCount = artifactXP
Nenue@65 549 rewardType = REWARD_ARTIFACT_POWER
Nenue@75 550 --dprint(' artifactXP', artifactXP)
Nenue@69 551 foundPrimary = true
Nenue@65 552 end
Nenue@65 553
Nenue@65 554 local numQuestCurrencies = GetNumQuestLogRewardCurrencies(questID);
Nenue@65 555 for i = 1, numQuestCurrencies do
Nenue@69 556 local name, texture, numItems, currencyID = GetQuestLogRewardCurrencyInfo(i, questID);
Nenue@65 557 local text = BONUS_OBJECTIVE_REWARD_WITH_COUNT_FORMAT:format(texture, numItems, name);
Nenue@65 558 tinsert(rewardCurrency, {
Nenue@65 559 name = name,
Nenue@65 560 texture = texture,
Nenue@65 561 numItems = numItems,
Nenue@65 562 text = text
Nenue@65 563 })
Nenue@69 564
Nenue@75 565 --dprint(' currency', i, currencyID, name, " |T"..tostring(texture)..":12:12|t")
Nenue@69 566 if currencyID == ID_RESOURCES then
Nenue@69 567 rewardIcon = texture
Nenue@69 568 rewardCount = numItems
Nenue@69 569 rewardName = name
Nenue@69 570 rewardType = REWARD_CURRENCY
Nenue@69 571 foundPrimary = true
Nenue@69 572 elseif currencyID == ID_LEGIONFALL then
Nenue@69 573 xpIcon = texture
Nenue@69 574 xpCount = numItems
Nenue@69 575 xpName = name
Nenue@69 576 xpType = REWARD_CURRENCY
Nenue@69 577 end
Nenue@89 578 end
Nenue@69 579
Nenue@65 580 local honorAmount = GetQuestLogRewardHonor(questID);
Nenue@65 581 if honorAmount > 0 then
Nenue@89 582 xpIcon = "Interface\\ICONS\\Achievement_LegionPVPTier4"
Nenue@89 583 xpCount = honorAmount
Nenue@89 584 xpName = HONOR
Nenue@89 585 xpType = HONOR_CURRENCY
Nenue@88 586 -- let items override
Nenue@65 587 end
Nenue@65 588
Nenue@65 589 local numQuestRewards = GetNumQuestLogRewards(questID);
Nenue@65 590 if numQuestRewards > 0 then
Nenue@65 591 for i = 1, numQuestRewards do
Nenue@65 592 local name, texture, numItems, quality, isUsable, itemID = GetQuestLogRewardInfo(i, questID)
Nenue@65 593
Nenue@65 594 if itemID then
Nenue@65 595 local itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture, sellPrice, classID, subclassID = GetItemInfo(itemID);
Nenue@65 596 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 597 rewardType = REWARD_GEAR
Nenue@65 598 rewardIcon = texture
Nenue@65 599 rewardName = name
Nenue@65 600 rewardCount = numItems
Nenue@65 601 foundPrimary = true
Nenue@65 602 elseif IsArtifactPowerItem(itemID) then
Nenue@65 603 rewardType = REWARD_ARTIFACT_POWER
Nenue@65 604 rewardIcon = texture
Nenue@65 605 rewardName = name
Nenue@93 606 rewardCount = self:UpdateArtifactPower(itemLink)
Nenue@65 607 foundPrimary = true
Nenue@75 608 --dprint('is an AP token')
Nenue@65 609 elseif classID == LE_ITEM_CLASS_TRADEGOODS then
Nenue@65 610 rewardType = REWARD_REAGENT
Nenue@65 611 rewardIcon = texture
Nenue@65 612 rewardName = name
Nenue@65 613 rewardCount = numItems
Nenue@65 614 foundPrimary = true
Nenue@65 615 end
Nenue@75 616 --dprint(' reward', i, name, " |T"..tostring(texture)..":12:12|t", quality, isUsable, itemID)
Nenue@65 617 tinsert(rewardItems, {
Nenue@65 618 name = name,
Nenue@65 619 texture = texture,
Nenue@65 620 numItems = numItems,
Nenue@65 621 quality = quality,
Nenue@65 622 isUsable = isUsable
Nenue@65 623 })
Nenue@65 624 if not foundPrimary then
Nenue@75 625 --print(' -updating primary')
Nenue@82 626 rewardType = REWARD_REAGENT
Nenue@65 627
Nenue@65 628 rewardIcon = texture
Nenue@65 629 rewardName = name
Nenue@65 630 rewardCount = numItems
Nenue@65 631 end
Nenue@65 632
Nenue@65 633 end
Nenue@65 634
Nenue@65 635 end
Nenue@65 636 end
Nenue@65 637
Nenue@75 638 --dprint(' '..self.questID..':|cFFFFFF00UpdateRewards():', numQuestRewards, rewardType)
Nenue@75 639 --dprint(' ', tostring(self.title), " |T"..tostring(self.itemTexture)..":12:12|t", tostring(self.itemName))
Nenue@65 640
Nenue@89 641 if rewardType and ((self.itemNumber ~= rewardCount) or (self.rewardType ~= rewardType) or (self.itemName ~= rewardName) or (self.itemTexture ~= rewardIcon)) then
Nenue@67 642 if DATA_DEBUG and (self.debugTimer <= 0) then
Nenue@67 643 return false
Nenue@67 644 end
Nenue@67 645
Nenue@89 646 return true, rewardType, rewardName, rewardIcon, rewardCount, quality, xpType, xpName, xpIcon, xpCount
Nenue@67 647
Nenue@65 648 else
Nenue@65 649 return false
Nenue@65 650 end
Nenue@65 651 end
Nenue@65 652
Nenue@65 653
Nenue@65 654
Nenue@65 655 --[[ set reward category
Nenue@29 656 local numRewards = GetNumQuestLogRewards(questID)
Nenue@29 657 local numCurrency = GetNumQuestLogRewardCurrencies(questID)
Nenue@29 658 local money = GetQuestLogRewardMoney(questID)
Nenue@29 659 if numRewards >= 1 then
Nenue@40 660 rewardType, rewardIcon, rewardCount, rewardName, itemID, quality = WorldPlanQuests:GetRewardHeader(questID)
Nenue@29 661 elseif numCurrency >= 1 then
Nenue@29 662 rewardName, rewardIcon, rewardCount = GetQuestLogRewardCurrencyInfo(1, questID)
Nenue@29 663 rewardType = REWARD_CURRENCY
Nenue@29 664 elseif money >= 1 then
Nenue@29 665 rewardName = GetMoneyString(money)
Nenue@29 666 end
Nenue@65 667 --]]
Nenue@29 668
Nenue@40 669 end
Nenue@7 670 end
Nenue@7 671
Nenue@34 672
Nenue@93 673 function QuestPOI:UpdateArtifactPower(rewardLink)
Nenue@93 674 if not (rewardLink or self.rewardLink) then
Nenue@75 675 return
Nenue@75 676 end
Nenue@75 677
Nenue@93 678 self.rewardLink = rewardLink or self.rewardLink
Nenue@49 679
Nenue@93 680 local rewardCount
Nenue@93 681 WorldPlanTooltip:SetOwner(self, 'ANCHOR_NONE')
Nenue@93 682 WorldPlanTooltip:SetHyperlink(rewardLink or self.rewardLink)
Nenue@93 683 for i = 1, WorldPlanTooltip:NumLines() do
Nenue@93 684 local line = _G['WorldPlanTooltipTextLeft' .. i]
Nenue@93 685 local text = line and line:GetText()
Nenue@93 686 local ap = text and text:gsub(',', ''):gsub(' million', '000000'):match('([%d%.]+) '..ARTIFACT_POWER)
Nenue@93 687 if ap then
Nenue@93 688 rewardCount = tonumber(ap)
Nenue@69 689 end
Nenue@48 690 end
Nenue@93 691 return rewardCount
Nenue@27 692 end
Nenue@27 693
Nenue@67 694 -- Applies position and sizing parameters to the pin data
Nenue@66 695 function QuestPOI:SetAnchor(owner, dX, dY, mapWidth, mapHeight, scaleFactor)
Nenue@75 696 --dprint(self:GetName()..':SetAnchor()', owner, dX, dY, scaleFactor, self.filtered, self.used)
Nick@62 697 if not self.used then
Nenue@69 698 self.hideReason = 'SetAnchor() on an unused frame.'
Nenue@93 699 self:HideOrShowFrames(false)
Nick@62 700 return
Nick@62 701 end
Nick@62 702
Nenue@75 703
Nenue@67 704 if owner then
Nenue@67 705 self:SetParent(owner)
Nenue@67 706 self.Overlay:SetParent(owner)
Nenue@78 707 self:SetFrameStrata('HIGH')
Nenue@78 708 self:SetFrameLevel(pinBaseIndex + self:GetID())
Nenue@78 709 self.Overlay:SetFrameStrata('HIGH')
Nenue@78 710 self.Overlay:SetFrameLevel(overlayBaseIndex + self:GetID())
Nenue@74 711 self.isStale = true
Nenue@67 712 else
Nenue@67 713 owner = self:GetParent()
Nenue@67 714 end
Nenue@67 715
Nenue@74 716
Nenue@74 717 if scaleFactor then
Nenue@82 718 print('scaleFactor')
Nenue@67 719 self:SetScale(scaleFactor)
Nenue@67 720 self.Overlay:SetScale(scaleFactor)
Nenue@67 721 self.scaleFactor = scaleFactor
Nenue@67 722 end
Nenue@67 723
Nenue@74 724 mapWidth = mapWidth or owner:GetWidth()
Nenue@74 725 mapHeight = mapHeight or owner:GetHeight()
Nenue@74 726 dX = dX or self.x
Nenue@74 727 dY = dY or self.y
Nenue@74 728 --print(owner:GetName() or tostring(owner), self:GetName(), owner:GetScale(), scaleFactor)
Nenue@74 729 if (self.x ~= dX) or (self.y ~= dY) or scaleFactor then
Nenue@67 730
Nenue@74 731 self.x = dX
Nenue@74 732 self.y = dY
Nenue@74 733 local pX = (dX * mapWidth) * (1 / scaleFactor)
Nenue@74 734 local pY = (-dY * mapHeight) * (1 / scaleFactor)
Nenue@74 735 --print('to', pX, pY, self:GetScale())
Nenue@74 736 self:ClearAllPoints()
Nenue@74 737 self:SetPoint('CENTER', owner, 'TOPLEFT', pX, pY)
Nenue@53 738 end
Nick@62 739
Nick@62 740 end
Nick@62 741
Nenue@78 742 -- Non-hieriarchical display states, checked separately from used/filtered states
Nenue@74 743 function QuestPOI:GetCriteriaState()
Nenue@74 744 local isCriteria, isBounty, isSpellTarget
Nenue@93 745
Nenue@93 746
Nenue@93 747
Nenue@93 748 for index, bounty in pairs(db.Bounties) do
Nenue@93 749 if (not IsQuestComplete(bounty.questID)) and IsQuestCriteriaForBounty(self.questID, bounty.questID) then
Nenue@93 750 isCriteria = true
Nenue@93 751 if db.selectedBounty == bounty then
Nenue@93 752 isBounty = true
Nenue@74 753 end
Nenue@93 754 --dprint('|cFF00FF88Criteria:|r', self.questID, bounty.questID, isCriteria, isBounty)
Nenue@74 755 end
Nenue@74 756 end
Nenue@74 757 isSpellTarget = IsQuestIDValidSpellTarget(self.questID)
Nenue@74 758
Nenue@74 759 if (self.isBounty ~= isBounty) or (self.isCriteria ~= isCriteria) or (self.isSpellTarget ~= isSpellTarget) then
Nenue@75 760 --wqprint('|cFF00FF00criteria state changed')
Nenue@74 761 self.isBounty = isBounty
Nenue@74 762 self.isCriteria = isCriteria
Nenue@74 763 self.isSpellTarget = isSpellTarget
Nenue@75 764 self.isStale = true
Nenue@74 765 return true
Nenue@74 766 end
Nenue@74 767 end
Nenue@74 768
Nenue@35 769 local cvar_check = {
Nenue@35 770 [REWARD_CASH] = 'worldQuestFilterGold',
Nenue@35 771 [REWARD_ARTIFACT_POWER] = 'worldQuestFilterArtifactPower',
Nenue@35 772 [REWARD_CURRENCY] = 'worldQuestFilterOrderResources',
Nenue@35 773 [REWARD_REAGENT]= 'worldQuestFilterProfessionMaterials',
Nenue@35 774 [REWARD_GEAR] = 'worldQuestFilterEquipment',
Nenue@35 775 }
Nenue@8 776
Nick@64 777
Nenue@57 778 function QuestPOI:CheckFilterRules ()
Nenue@36 779 local print = qprint
Nenue@33 780 local qType = self.worldQuestType
Nenue@78 781 if not TQ_IsActive(self.questID) then
Nenue@78 782 self.hideReason = 'Filter check ended because quest is inactive.'
Nenue@78 783 self.used = nil
Nenue@78 784 self:SetShown(false)
Nenue@78 785 return
Nenue@78 786 end
Nenue@69 787
Nenue@69 788 if qType == LE_QUEST_TAG_TYPE_PROFESSION then
Nenue@57 789 if not(self.isKnownProfession or db.Config.ShowAllProfessionQuests) then
Nenue@78 790 self.hideReason = 'Failed profession check.'
Nenue@78 791 self.used = nil
Nenue@78 792 self:SetShown(false)
Nenue@78 793 return
Nenue@36 794 end
Nenue@36 795 end
Nenue@57 796
Nenue@78 797 local filtered
Nenue@78 798 for filterKey, value in pairs(db.UsedFilters) do
Nenue@78 799 if self[filterKey] ~= value then
Nenue@78 800 if not self.filtered then
Nenue@78 801 print('|cFFFF4400filtering', filterKey, value, '~=', self[filterKey], self.title)
Nenue@57 802 end
Nenue@78 803 filtered = true
Nenue@57 804 end
Nenue@78 805 end
Nenue@78 806 if self.rewardType and cvar_check[self.rewardType] then
Nenue@78 807 if not GetCVarBool(cvar_check[self.rewardType]) then
Nenue@78 808 filtered = true
Nenue@57 809 end
Nenue@57 810 end
Nenue@78 811
Nenue@78 812 print(' '..self.questID..':|cFFFFFF00CheckFilterRules()|r', filtered, self.title)
Nenue@78 813 if self.filtered ~= filtered then
Nenue@82 814 wqprint('|cFF00FF00filter changed')
Nenue@78 815 self.isStale = true
Nenue@69 816 end
Nenue@78 817
Nenue@82 818 self.filtered = filtered
Nenue@78 819 self.used = true
Nenue@78 820 self:SetShown(true)
Nenue@33 821 end
Nenue@33 822
Nenue@93 823 function QuestPOI:Refresh (event)
Nenue@93 824 print('|cFF00FF88Refresh(|r'..self:GetID()..'|cFF00FF88)|r', event, self.title)
Nenue@33 825
Nenue@93 826
Nenue@93 827 local style = DEFAULT_STYLE
Nenue@93 828 if self.filtered then
Nenue@93 829 print('choose minimized')
Nenue@93 830 style = MINIMIZED_STYLE
Nenue@93 831 elseif self.dataLoaded then
Nenue@93 832 print('choose reward type')
Nenue@93 833 style = REWARD_TYPE_STYLES[self.rewardType]
Nenue@93 834 else
Nenue@93 835 print('choose default')
Nenue@93 836 end
Nenue@93 837
Nenue@93 838 local currentWidth = style.iconWidth or DEFAULT_STYLE.iconWidth
Nenue@93 839
Nenue@93 840
Nenue@93 841
Nenue@93 842 local borderWidth = style.borderWidth or DEFAULT_STYLE.borderWidth
Nenue@93 843 local highlightWidth = style.highlightWidth or DEFAULT_STYLE.highlightWidth
Nenue@93 844 local tagSize = style.TagSize or DEFAULT_STYLE.TagSize
Nenue@93 845 local hideIcon = style.hideIcon or DEFAULT_STYLE.hideIcon
Nenue@93 846 local borderColor = style.border or DEFAULT_STYLE.border
Nenue@93 847 local textColor = style.textColor or DEFAULT_STYLE.textColor
Nenue@93 848 local questID = self.questID
Nenue@36 849 local iconBorder = self.RewardBorder
Nenue@36 850 local trackingBorder = self.HighlightBorder
Nenue@93 851 local icon = self.icon
Nenue@93 852 local count = self.count
Nenue@93 853 local hideNumbers = style.hideNumber or DEFAULT_STYLE.hideNumber
Nenue@33 854
Nenue@33 855
Nenue@93 856 local tagIcon = self.tagIcon
Nenue@93 857 self.maxAlertLevel = style.maxAlertLevel or DEFAULT_STYLE.maxAlertLevel
Nenue@47 858
Nenue@93 859 if self.dataLoaded then
Nenue@93 860 print('new pin, has data, cue fade')
Nenue@93 861 if self.isNew then
Nenue@93 862 self:StartFading()
Nenue@93 863 self.isNew = nil
Nenue@93 864 end
Nenue@93 865 else
Nenue@93 866 if not self.animating then
Nenue@93 867 print('new pin, but no data, hide icon')
Nenue@93 868 self.icon:SetAlpha(0)
Nenue@93 869 self.RewardBorder:SetAlpha(0)
Nenue@93 870 end
Nenue@93 871 end
Nenue@93 872
Nenue@93 873 if self.itemName then
Nenue@93 874 if self.itemNumber and (self.itemNumber > 1) and (not hideNumbers) then
Nenue@93 875 local numberString = self.itemNumber
Nenue@93 876 if self.itemNumber >= 1000000 then
Nenue@93 877 numberString = (floor(self.itemNumber/100000)/10) .. 'M'
Nenue@93 878 elseif self.itemNumber >= 10000 then
Nenue@93 879 numberString = floor(self.itemNumber/1000) .. 'k'
Nenue@93 880 elseif self.itemNumber >= 1000 then
Nenue@93 881 local numeral = floor(self.itemNumber/1000)
Nenue@93 882 local decimal = mod(self.itemNumber, 1000)
Nenue@93 883 numberString = numeral
Nenue@93 884 if decimal > 100 then
Nenue@93 885 numberString = numberString .. '.' .. tostring(floor(decimal/100))
Nenue@93 886 end
Nenue@93 887 numberString = numberString .. 'k'
Nenue@93 888 end
Nenue@93 889
Nenue@93 890 self.count:SetText(numberString)
Nenue@93 891 self.count:SetTextColor(unpack(textColor))
Nenue@93 892 self.count:Show()
Nenue@57 893 else
Nenue@93 894 self.count:SetText(nil)
Nenue@93 895 self.count:Hide()
Nenue@93 896 end
Nenue@93 897 else
Nenue@93 898 self.count:Hide()
Nenue@93 899 end
Nenue@93 900
Nenue@93 901 if db.Config.ShowVerboseInfo then
Nenue@93 902 self.Description:SetText(self.title .. "\n" .. floor(self.x*100+.5) .. "," .. floor(self.y*100+.5))
Nenue@93 903 end
Nenue@93 904
Nenue@93 905
Nenue@93 906 icon:SetSize(currentWidth, currentWidth)
Nenue@93 907 icon:SetMask(style.iconMask or DEFAULT_STYLE.iconMask)
Nenue@93 908 if self.itemTexture then
Nenue@93 909 --iconBorder:SetTexture(WORLD_QUEST_BORDER)
Nenue@93 910
Nenue@93 911 if hideIcon then
Nenue@93 912 icon:SetTexture(PENDING_ICON)
Nenue@93 913 icon:SetDesaturated(true)
Nenue@93 914 icon:SetVertexColor(unpack(borderColor))
Nenue@93 915 else
Nenue@93 916 icon:SetTexture(self.itemTexture)
Nenue@93 917 icon:SetDesaturated(false)
Nenue@93 918 icon:SetVertexColor(1, 1, 1)
Nenue@93 919 end
Nenue@93 920 else
Nenue@93 921 --
Nenue@93 922 --icon:SetTexture(PENDING_ICON)
Nenue@93 923 --icon:SetDesaturated(true)
Nenue@93 924 --icon:SetVertexColor(unpack(borderColor))
Nenue@93 925 end
Nenue@93 926 local borderMask = style.borderMask or DEFAULT_STYLE.borderMask
Nenue@93 927 local borderSize = currentWidth + (borderWidth * 2) + (self.isCriteria and 2 or 0)
Nenue@93 928
Nenue@93 929
Nenue@93 930 iconBorder:SetSize(borderSize, borderSize)
Nenue@93 931
Nenue@93 932 iconBorder:SetMask(borderMask)
Nenue@93 933 iconBorder:SetTexture(PENDING_BORDER)
Nenue@93 934
Nenue@93 935 iconBorder:SetDesaturated(true)
Nenue@93 936
Nenue@93 937 local highlightSize = borderSize + (highlightWidth * 2)
Nenue@93 938 trackingBorder:SetSize(highlightSize, highlightSize)
Nenue@93 939 trackingBorder:SetMask(borderMask)
Nenue@93 940 trackingBorder:SetTexture(PENDING_BORDER)
Nenue@93 941
Nenue@93 942 self:SetSize(borderSize, borderSize)
Nenue@93 943 self.IconBackdrop:SetSize(currentWidth, currentWidth)
Nenue@93 944
Nenue@93 945
Nenue@93 946
Nenue@93 947 iconBorder:SetPoint('CENTER', (style.x or 0), (style.y or 0))
Nenue@93 948 trackingBorder:SetPoint('CENTER', (style.x or 0), (style.y or 0))
Nenue@93 949
Nenue@93 950 self.tagIcon:SetShown((not self.filtered) and true or false)
Nenue@93 951 self.tagIcon:SetAtlas(self.tagAtlas)
Nenue@93 952 self.EliteBorder:SetShown(self.isElite and not self.filtered)
Nenue@93 953
Nenue@93 954 self:UpdateStatus()
Nenue@93 955
Nenue@93 956 if self.isBounty then
Nenue@93 957 --print('is bounty')
Nenue@93 958 iconBorder:SetVertexColor(trackingBorder:GetVertexColor())
Nenue@93 959 trackingBorder:SetVertexColor(unpack(BORDER_SELECTED_BOUNTY))
Nenue@93 960 elseif self.isCriteria then
Nenue@93 961 --print('is criteria of a bounty')
Nenue@93 962 iconBorder:SetVertexColor(trackingBorder:GetVertexColor())
Nenue@93 963 trackingBorder:SetVertexColor(unpack(BORDER_CRITERIA))
Nenue@93 964 else
Nenue@93 965
Nenue@93 966 iconBorder:SetVertexColor(unpack(borderColor))
Nenue@93 967 trackingBorder:SetVertexColor(0,0,0,.5)
Nenue@93 968 end
Nenue@93 969
Nenue@93 970 if SpellCanTargetQuest() then
Nenue@93 971 if IsQuestIDValidSpellTarget(self.questID) then
Nenue@93 972 icon:SetVertexColor(1,1,1)
Nenue@93 973 else
Nenue@93 974 icon:SetVertexColor(1,0,0,1)
Nenue@93 975 end
Nenue@93 976 self:EnableMouse(false)
Nenue@93 977 else
Nenue@93 978 self:EnableMouse(true)
Nenue@93 979 end
Nenue@93 980 self.isStale = nil
Nenue@93 981
Nenue@93 982 -- signal filter info update
Nenue@93 983 WorldPlanSummary.isStale = true
Nenue@93 984 end
Nenue@93 985
Nenue@93 986 -- Called at static intervals and with Refresh
Nenue@93 987 function QuestPOI:UpdateStatus()
Nenue@93 988 -- update time elements
Nenue@93 989 self.isActive = TQ_IsActive(self.questID)
Nenue@93 990
Nenue@93 991 if self.isActive then
Nenue@93 992 local tl = self.alertLevel
Nenue@93 993 local timeLeft = TQ_GetQuestTimeLeftMinutes(self.questID)
Nenue@93 994 if timeLeft > 0 then
Nenue@93 995
Nenue@93 996 local text, timeState = WorldPlan:GetTimeInfo(timeLeft, self.maxAlertLevel)
Nenue@93 997 if tl ~= timeState then
Nenue@93 998 tl = timeState
Nenue@93 999 self.timeLabel:SetText(text)
Nenue@93 1000 end
Nenue@93 1001 end
Nenue@93 1002
Nenue@93 1003 local border = (self.isBounty or self.isCriteria) and self.RewardBorder or self.HighlightBorder
Nenue@93 1004
Nenue@93 1005 if tl and (timeLeft < 120) then
Nenue@93 1006 border:SetVertexColor(1,0,0,0.7)
Nenue@93 1007 else
Nenue@93 1008 border:SetVertexColor(0,0,0,0.7)
Nenue@93 1009 end
Nenue@93 1010 self.alertLevel = tl
Nenue@93 1011 self.timeLabel:SetShown(self.worldQuest and (self.maxAlertLevel >= 1))
Nenue@93 1012 else
Nenue@93 1013 self.hideReason = "No longer active."
Nenue@93 1014 self:HideOrShowFrames(false)
Nenue@93 1015
Nenue@93 1016 end
Nenue@93 1017 end
Nenue@93 1018
Nenue@93 1019 -- Show/Hide the text overlays associated with the quest pin; they aren't hierarchically linked
Nenue@93 1020 function QuestPOI:HideOrShowFrames(isShown)
Nenue@93 1021 if not isShown then
Nenue@93 1022 -- print('|cFFFFFF00' ..self:GetName()..':HideOrShowFrames()')
Nenue@93 1023 -- do not SetShown() here
Nenue@93 1024 if not self.hideReason then
Nenue@93 1025 self.hideReason = "HideOrShowFrames() called"
Nenue@93 1026 end
Nenue@93 1027 end
Nenue@93 1028 self.Overlay:SetShown(isShown)
Nenue@93 1029 self.count:SetShown(isShown)
Nenue@93 1030 self.timeLabel:SetShown(isShown)
Nenue@93 1031 end
Nenue@93 1032
Nenue@93 1033 function QuestPOI:Release()
Nenue@93 1034
Nenue@93 1035 self.hideReason = 'Released by script.'
Nenue@93 1036 self:SetShown(false)
Nenue@93 1037 if self.questID then
Nenue@93 1038 db.QuestsByID[self.questID] = nil
Nenue@93 1039 for _, map in pairs(db.QuestsByZone) do
Nenue@93 1040 map[self.questID] = nil
Nenue@93 1041 end
Nenue@93 1042 self.questID = nil
Nenue@93 1043 end
Nenue@93 1044 self.isActive = nil
Nenue@93 1045 self.complete = nil
Nenue@93 1046 self.used = nil
Nenue@93 1047 self.dataLoaded = nil
Nenue@93 1048 self.rewardType = nil
Nenue@93 1049 self.itemTexture = nil
Nenue@93 1050 self.itemName = nil
Nenue@93 1051 self.itemNumber = nil
Nenue@93 1052 self:SetShown(false)
Nenue@93 1053 self.animating = nil
Nenue@93 1054 self.icon:SetAlpha(0)
Nenue@93 1055 self.RewardBorder:SetAlpha(0)
Nenue@93 1056 self:UnregisterEvent('QUEST_TURNED_IN')
Nenue@93 1057 self:UnregisterEvent('QUEST_LOG_UPDATE')
Nenue@93 1058
Nenue@93 1059 for i, pin in ipairs(db.UsedPins) do
Nenue@93 1060 if pin == self then
Nenue@93 1061 tremove(db.UsedPins, i)
Nenue@93 1062 break
Nenue@57 1063 end
Nenue@57 1064
Nenue@47 1065 end
Nenue@47 1066
Nenue@93 1067 tinsert(db.FreePins, self)
Nenue@93 1068 WorldPlan.dataFlush = true
Nenue@7 1069 end