annotate QuestPOI.lua @ 34:0100d923d8c3

WorldPlan: - Reward filter toggle changed to clear out other reward filters. The assumption being that one is most often looking only for that particular type of quest when they go to use it. - Fixed filter bar info falling out of sync after player-triggered world map updates. - Code stuff: -- Quest pin shown-state management makes better use of OnShow OnHide handlers, SetShown is toggled and it all goes from there -- WorldQuests module re-factored outside of the top level frame script. ClassPlan: - Available missions are now recorded; the mission list can be toggled between in-progress and available by clicking the heading.
author Nenue
date Wed, 02 Nov 2016 19:04:47 -0400
parents be4db60219ca
children 26dfa661daa7
rev   line source
Nenue@7 1 -- WorldPlan
Nenue@7 2 -- QuestPOI.lua
Nenue@7 3 -- Created: 10/1/2016 7:21 PM
Nenue@7 4 -- %file-revision%
Nenue@7 5 --
Nenue@29 6
Nenue@33 7 WorldPlanPOIMixin = {}
Nenue@29 8 local TQ_GetQuestInfoByQuestID = C_TaskQuest.GetQuestInfoByQuestID -- Return the name of a quest with a given ID
Nenue@7 9 local TQ_GetQuestLocation = C_TaskQuest.GetQuestLocation
Nenue@7 10 local TQ_GetQuestTimeLeftMinutes = C_TaskQuest.GetQuestTimeLeftMinutes
Nenue@9 11 local TQ_IsActive = C_TaskQuest.IsActive
Nenue@29 12 local TQ_RequestPreloadRewardData = C_TaskQuest.RequestPreloadRewardData
Nenue@7 13 local QuestPOIGetIconInfo, WorldMapPOIFrame = QuestPOIGetIconInfo, WorldMapPOIFrame
Nenue@33 14 local WorldMap_DoesWorldQuestInfoPassFilters = WorldMap_DoesWorldQuestInfoPassFilters
Nenue@33 15 local QuestMapFrame_IsQuestWorldQuest = QuestMapFrame_IsQuestWorldQuest
Nenue@33 16 local GameTooltip = GameTooltip
Nenue@33 17 local GetItemIcon = GetItemIcon
Nenue@7 18
Nenue@33 19 local print = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or function() end
Nenue@7 20 local qprint = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or function() end
Nenue@33 21 local wprint = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or function() end
Nenue@30 22 local wqprint = DEVIAN_WORKSPACE and function(...) _G.print('WorldQuests', ...) end or function() end
Nenue@7 23 local iprint = DEVIAN_WORKSPACE and function(...) _G.print('ItemScan', ...) end or function() end
Nenue@7 24 local QuestPOI = WorldPlanPOIMixin
Nenue@7 25
Nenue@9 26 local ICON_UNKNOWN = "Interface\\ICONS\\inv_misc_questionmark"
Nenue@9 27 local ICON_MONEY = "Interface\\Buttons\\UI-GroupLoot-Coin-Up"
Nenue@9 28
Nenue@9 29 local POI_BORDER_MASK = "Interface\\Minimap\\UI-Minimap-Background"
Nenue@9 30 local POI_BORDER_FILL = "Interface\\BUTTONS\\YELLOWORANGE64"
Nenue@9 31 local POI_BORDER_BLUE = "Interface\\BUTTONS\\GRADBLUE"
Nenue@9 32 local POI_BORDER_RED = "Interface\\BUTTONS\\RedGrad64"
Nenue@9 33 local POI_BORDER_YELLOW = "Interface\\BUTTONS\\YELLOWORANGE64"
Nenue@9 34 local POI_BORDER_GREEN = "Interface\\BUTTONS\\GREENGRAD64"
Nenue@9 35
Nenue@29 36 local REWARD_CASH = WORLD_QUEST_REWARD_TYPE_FLAG_GOLD
Nenue@29 37 local REWARD_ARTIFACT_POWER = WORLD_QUEST_REWARD_TYPE_FLAG_ARTIFACT_POWER
Nenue@29 38 local REWARD_GEAR = WORLD_QUEST_REWARD_TYPE_FLAG_EQUIPMENT
Nenue@29 39 local REWARD_CURRENCY = WORLD_QUEST_REWARD_TYPE_FLAG_ORDER_RESOURCES
Nenue@29 40 local REWARD_REAGENT = WORLD_QUEST_REWARD_TYPE_FLAG_MATERIALS
Nenue@29 41
Nenue@29 42
Nenue@29 43 local LE_QUEST_TAG_TYPE_PVP = LE_QUEST_TAG_TYPE_PVP
Nenue@29 44 local LE_QUEST_TAG_TYPE_PET_BATTLE = LE_QUEST_TAG_TYPE_PET_BATTLE
Nenue@29 45 local LE_QUEST_TAG_TYPE_DUNGEON = LE_QUEST_TAG_TYPE_DUNGEON
Nenue@29 46 local LE_QUEST_TAG_TYPE_PROFESSION = LE_QUEST_TAG_TYPE_PROFESSION
Nenue@29 47 local LE_QUEST_TAG_TYPE_NORMAL = LE_QUEST_TAG_TYPE_NORMAL
Nenue@29 48
Nenue@29 49 local LE_QUEST_TAG_TYPE_PVP = LE_QUEST_TAG_TYPE_PVP
Nenue@29 50 local LE_QUEST_TAG_TYPE_PET_BATTLE = LE_QUEST_TAG_TYPE_PET_BATTLE
Nenue@29 51 local LE_QUEST_TAG_TYPE_DUNGEON = LE_QUEST_TAG_TYPE_DUNGEON
Nenue@29 52 local LE_QUEST_TAG_TYPE_PROFESSION = LE_QUEST_TAG_TYPE_PROFESSION
Nenue@29 53 local LE_QUEST_TAG_TYPE_NORMAL = LE_QUEST_TAG_TYPE_NORMAL
Nenue@29 54
Nenue@31 55 local subStyles = {
Nenue@31 56 continent = {
Nenue@31 57 PinSize = 14,
Nenue@31 58 Border = 2,
Nenue@31 59 TrackingBorder = 1,
Nenue@31 60 TagSize = 6,
Nenue@31 61 TimeleftStage = 0,
Nenue@31 62 showNumber = false,
Nenue@31 63 numberFontObject = 'WorldPlanFont'
Nenue@31 64 },
Nenue@31 65 zone = {
Nenue@31 66 PinSize = 22,
Nenue@31 67 Border = 3,
Nenue@31 68 TrackingBorder = 2,
Nenue@31 69 TagSize = 12,
Nenue@31 70 TimeleftStage = 3,
Nenue@31 71 showNumber = true,
Nenue@31 72 numberFontObject = 'WorldPlanNumberFontThin'
Nenue@31 73 },
Nenue@31 74 minimized = {
Nenue@31 75 PinSize = 4,
Nenue@31 76 Border = 0,
Nenue@31 77 TrackingBorder = 1,
Nenue@31 78 NoIcon = true,
Nenue@31 79 TimeleftStage = 1,
Nenue@31 80 showNumber = false,
Nenue@31 81 }
Nenue@31 82 }
Nenue@31 83
Nenue@29 84 -- Pin color/display variables
Nenue@29 85
Nenue@33 86 local familiars = {
Nenue@33 87 [42159] = {npc = 106552, name = 'Nightwatcher Merayl'},
Nenue@33 88 [40277] = {npc = 97804, name = 'Tiffany Nelson'},
Nenue@33 89 [40298] = {npc = 99182, name = 'Sir Galveston'},
Nenue@33 90 [40282] = {npc= 99150, name = 'Grixis Tinypop'},
Nenue@33 91 [40278] = {npc = 98270, name = 'Robert Craig'},
Nenue@33 92 [48195] = {npc = 105250, name = 'Aulier'},
Nenue@33 93 [41990] = {npc = 105674, name = 'Varenne'},
Nenue@33 94 [41860] = {npc = 104970, name = 'Xorvasc'},
Nenue@33 95 [40299] = {npc = 99210, name = 'Bodhi Sunwayver'},
Nenue@33 96 [42442] = {npc = 107489, name = 'Amalia'},
Nenue@33 97 [40280] = {npc = 99077, name = 'Bredda Tenderhide'},
Nenue@33 98 [41687] = {npc = 104553, name = 'Odrogg'},
Nenue@33 99 [41944] = {npc = 105455, name = 'Trapper Jarrun'},
Nenue@33 100 [40337] = {npc = 97709, name = 'Master Tamer Flummox'},
Nenue@33 101 [40279] = {npc = 99035, name = 'Durian Strongfruit'}
Nenue@33 102 }
Nenue@33 103 local familiars_id = 9696
Nenue@33 104
Nenue@33 105
Nenue@33 106 -- update a masked texture without messing up its blending mask
Nenue@7 107
Nenue@7 108
Nenue@9 109 -- update a masked texture without messing up its blending mask
Nenue@9 110 local SetMaskedTexture = function(region, file, mask)
Nenue@33 111 mask = mask or "Interface\\Minimap\\UI-Minimap-Background"
Nenue@9 112 region:SetMask(nil)
Nenue@9 113 region:SetTexture(file)
Nenue@9 114 region:SetMask(mask)
Nenue@9 115 end
Nenue@7 116
Nenue@29 117
Nenue@29 118 -- use tooltip object to extract item details
Nenue@29 119 local ParseItemReward = function(questID)
Nenue@29 120 local name, icon, quantity, quality, _, itemID = GetQuestLogRewardInfo(1, questID)
Nenue@29 121 local scanner = _G.WorldPlanTooltip
Nenue@29 122 if not itemID then
Nenue@29 123 return
Nenue@29 124 end
Nenue@29 125
Nenue@29 126 scanner:SetOwner(WorldPlan, "ANCHOR_NONE")
Nenue@29 127 scanner:SetItemByID(itemID)
Nenue@29 128 scanner:Show()
Nenue@29 129 local ttl1 = _G['WorldPlanTooltipTextLeft1']
Nenue@29 130 local ttl2 = _G['WorldPlanTooltipTextLeft2']
Nenue@29 131 local ttl3 = _G['WorldPlanTooltipTextLeft3']
Nenue@29 132 local ttl4 = _G['WorldPlanTooltipTextLeft4']
Nenue@29 133 if ttl2 then
Nenue@29 134 local text = ttl2:GetText()
Nenue@29 135 -- Artifact Power
Nenue@29 136 if text then
Nenue@29 137 if text:match("|cFFE6CC80") then
Nenue@29 138 --print('AP token!', text)
Nenue@29 139 local power
Nenue@29 140 if ttl4 then
Nenue@29 141 local text = ttl4:GetText()
Nenue@29 142 --print('tip line 4', text)
Nenue@29 143 if text then
Nenue@29 144 power = text:gsub("%p", ""):match("%d+")
Nenue@29 145 power = tonumber(power)
Nenue@29 146 end
Nenue@29 147
Nenue@29 148 end
Nenue@31 149 return REWARD_ARTIFACT_POWER, "Interface\\ICONS\\inv_7xp_inscription_talenttome01", power, name, itemID, quality
Nenue@29 150 elseif text:match("Item Level") then
Nenue@29 151 --print('equipment!', text)
Nenue@29 152 quantity = text:match("Item Level ([%d\+]+)")
Nenue@31 153 return REWARD_GEAR, icon, quantity, name, itemID, quality
Nenue@29 154 elseif text:match("Crafting Reagent") then
Nenue@29 155 --print('|cFFFF4400it is a reagent', text)
Nenue@31 156 return REWARD_REAGENT, icon, quantity, name, itemID, quality
Nenue@29 157 end
Nenue@29 158 end
Nenue@29 159
Nenue@29 160 elseif ttl3 then
Nenue@29 161 local text = ttl3:GetText()
Nenue@29 162 if text:match("Crafting Reagent") then
Nenue@29 163 --print('|cFFFF4400it is a reagent', text)
Nenue@31 164 return REWARD_REAGENT, icon, quantity, name, itemID, quality
Nenue@29 165 end
Nenue@29 166 end
Nenue@31 167 return 128, icon, quantity, name, itemID, quality
Nenue@29 168 end
Nenue@29 169
Nenue@27 170 function WorldPlanPOIMixin:OnEnter()
Nenue@7 171 local completed = select(4,GetAchievementInfo(familiars_id))
Nenue@7 172 if not completed then
Nenue@7 173 if self.worldQuestType == LE_QUEST_TAG_TYPE_PET_BATTLE and familiars[self.questID] then
Nenue@7 174 WorldMapTooltip:SetOwner(self, 'ANCHOR_RIGHT')
Nenue@31 175 WorldMapTooltip:AddLine(self.title, 1, 1, 1)
Nenue@31 176 if self.quality then
Nenue@31 177 local c = ITEM_QUALITY_COLORS[self.quality]
Nenue@31 178 WorldMapTooltip:AddLine(" ")
Nenue@31 179 WorldMapTooltip:AddLine('Rewards')
Nenue@31 180 WorldMapTooltip:AddLine(self.itemName .. (self.quantity and (' x'..self.quantity) or ''), c.r, c.g, c.b)
Nenue@31 181 WorldMapTooltip:AddTexture(self.itemTexture)
Nenue@31 182
Nenue@31 183 local cLine = WorldMapTooltip:NumLines()
Nenue@31 184 local line = _G['WorldMapTooltipTextLeft'..cLine]
Nenue@31 185 local pline = _G['WorldMapTooltipTextLeft'..(cLine-1)]
Nenue@31 186 local icon = _G['WorldMapTooltipTexture'..(cLine-3)]
Nenue@31 187 icon:SetSize(24,24)
Nenue@31 188 icon:ClearAllPoints()
Nenue@31 189 icon:SetPoint('TOPLEFT', pline, 'BOTTOMLEFT', 0, -2)
Nenue@31 190 line:ClearAllPoints()
Nenue@31 191 line:SetPoint('TOPLEFT', icon, 'TOPRIGHT', 7, 0)
Nenue@31 192
Nenue@31 193 --- voodoo workaround for IDs getting coerced to string
Nenue@31 194 if type(self.itemTexture) == 'number' then
Nenue@31 195 icon:Show()
Nenue@31 196 icon:SetTexture(self.itemTexture)
Nenue@31 197 end
Nenue@31 198 end
Nenue@31 199
Nenue@31 200
Nenue@31 201 WorldMapTooltip:AddLine(" ") -- causes crash for some reason
Nenue@7 202 WorldMapTooltip:AddLine('Family Familiars')
Nenue@7 203 local trainer = familiars[self.questID].name
Nenue@7 204 local numCheevs = GetAchievementNumCriteria(familiars_id)
Nenue@7 205 for index = 1, numCheevs do
Nenue@7 206 local cheevName, cType, cCompleted, quantity, requiredQuantity, charName, flags, cheevID, quantityString, criteriaID = GetAchievementCriteriaInfo(familiars_id, index)
Nenue@7 207 local numTrainers = GetAchievementNumCriteria(cheevID)
Nenue@7 208 for subIndex = 1, numTrainers do
Nenue@7 209 local desc, cType, partCompleted = GetAchievementCriteriaInfo(cheevID, subIndex)
Nenue@7 210 if desc == trainer then
Nenue@7 211 if not partCompleted then
Nenue@7 212 local iconPath = select(10, GetAchievementInfo(cheevID))
Nenue@7 213 WorldMapTooltip:AddLine(cheevName)
Nenue@7 214 WorldMapTooltip:AddTexture(iconPath)
Nenue@7 215 end
Nenue@7 216 end
Nenue@7 217 end
Nenue@7 218 end
Nenue@7 219 WorldMapTooltip:Show()
Nenue@7 220 return
Nenue@7 221 end
Nenue@7 222 end
Nenue@7 223 TaskPOI_OnEnter(self)
Nenue@7 224 end
Nenue@27 225 function WorldPlanPOIMixin:OnLeave()
Nenue@7 226 TaskPOI_OnLeave(self)
Nenue@7 227 end
Nenue@27 228 function WorldPlanPOIMixin:OnMouseDown()
Nenue@7 229 TaskPOI_OnClick(self)
Nenue@7 230 end
Nenue@7 231
Nenue@7 232
Nenue@29 233
Nenue@29 234 -- create or update the pin using the given questID and C_TaskQuest results
Nenue@29 235 function WorldPlanPOIMixin:RefreshData (info)
Nenue@29 236
Nenue@29 237 qprint('|cFF00FF88'..self:GetName()..':RefreshData()|r')
Nenue@29 238
Nenue@29 239 if info then
Nenue@29 240 self.inProgress = info.inProgress
Nenue@29 241 self.floor = info.floor
Nenue@29 242 self.numObjectives = info.numObjectives or 0
Nenue@30 243 if info.x and info.y then
Nenue@30 244 self.x = info.x or self.x
Nenue@30 245 self.y = info.y or self.y
Nenue@30 246 qprint('|cFFFF4400applying taskInfo coords:', info.x, info.y)
Nenue@30 247 end
Nenue@30 248
Nenue@29 249 end
Nenue@29 250
Nenue@29 251
Nenue@29 252 local questID = self:GetID()
Nenue@29 253 local questTitle, rewardIcon, rewardName, rewardCount, rewardStyle, rewardType, itemID, quantity, quality, _
Nenue@33 254 local hasUpdate, isPending = (self.isStale or self.isNew), self.isPending
Nenue@29 255
Nenue@29 256
Nenue@29 257 if not HaveQuestData(questID) then
Nenue@29 258 TQ_RequestPreloadRewardData(questID)
Nenue@29 259 isPending = true
Nenue@29 260 else
Nenue@29 261
Nenue@29 262 -- set reward category
Nenue@29 263 local numRewards = GetNumQuestLogRewards(questID)
Nenue@29 264 local numCurrency = GetNumQuestLogRewardCurrencies(questID)
Nenue@29 265 local money = GetQuestLogRewardMoney(questID)
Nenue@29 266 if numRewards >= 1 then
Nenue@31 267 rewardType, rewardIcon, rewardCount, rewardName, itemID, quality = ParseItemReward(questID)
Nenue@29 268 elseif numCurrency >= 1 then
Nenue@29 269 rewardName, rewardIcon, rewardCount = GetQuestLogRewardCurrencyInfo(1, questID)
Nenue@29 270 rewardType = REWARD_CURRENCY
Nenue@29 271 elseif money >= 1 then
Nenue@29 272 rewardIcon = ICON_MONEY
Nenue@29 273 rewardName = GetMoneyString(money)
Nenue@29 274 rewardType = REWARD_CASH
Nenue@29 275 end
Nenue@30 276 rewardStyle = self:GetTypeInfo(rewardType)
Nenue@29 277
Nenue@29 278 self.itemNumber = rewardCount or self.itemNumber
Nenue@29 279 self.rewardType = rewardType or REWARD_ITEM
Nenue@29 280 self.style = rewardStyle
Nenue@31 281 self.quality = quality
Nenue@29 282
Nenue@29 283 -- title, faction, capped state
Nenue@29 284 local questTitle, factionID, capped = TQ_GetQuestInfoByQuestID(questID)
Nenue@29 285 self.factionID = factionID
Nenue@29 286 self.capped = capped
Nenue@29 287
Nenue@29 288 -- set tag details
Nenue@29 289 local tagID, tagName, worldQuestType, rarity, isElite, tradeskillLineIndex = GetQuestTagInfo(questID);
Nenue@29 290 local tagAtlas
Nenue@29 291 if worldQuestType == LE_QUEST_TAG_TYPE_PET_BATTLE then
Nenue@29 292 tagAtlas = "worldquest-icon-petbattle"
Nenue@29 293 elseif worldQuestType == LE_QUEST_TAG_TYPE_PVP then
Nenue@29 294 tagAtlas = "worldquest-icon-pvp-ffa"
Nenue@29 295 elseif worldQuestType == LE_QUEST_TAG_TYPE_PROFESSION then
Nenue@29 296 local id = tradeskillLineIndex and select(7, GetProfessionInfo(tradeskillLineIndex))
Nenue@29 297 if id then
Nenue@29 298 tagAtlas = WORLD_QUEST_ICONS_BY_PROFESSION[id]
Nenue@29 299 end
Nenue@29 300 elseif worldQuestType == LE_QUEST_TAG_TYPE_DUNGEON then
Nenue@29 301 tagAtlas = "worldquest-icon-dungeon"
Nenue@29 302 end
Nenue@29 303
Nenue@29 304 self.tagID = tagID
Nenue@29 305 self.tagName = tagName
Nenue@29 306 self.worldQuestType = worldQuestType
Nenue@29 307 self.isElite = isElite
Nenue@29 308 self.tradeskillLineIndex = tradeskillLineIndex
Nenue@29 309 self.rarity = rarity
Nenue@29 310 self.tagAtlas = tagAtlas
Nenue@29 311
Nenue@29 312 -- flag unresolved info
Nenue@29 313 if not (rewardIcon and rewardName) then
Nenue@29 314 isPending = true
Nenue@29 315 qprint('because not have icon')
Nenue@29 316 TQ_RequestPreloadRewardData (questID)
Nenue@29 317 --WorldPlan:print('|cFFFFFF00'..tostring(self.title)..'|r waiting on texture info')
Nenue@29 318 else
Nenue@29 319 if (rewardIcon and rewardName) and isPending then
Nenue@29 320 --WorldPlan:print('|cFF00FF00'..tostring(self.title)..'|r has info', rewardIcon, rewardName)
Nenue@29 321 hasUpdate = true
Nenue@29 322 end
Nenue@29 323 isPending = false
Nenue@29 324 end
Nenue@29 325
Nenue@29 326 self.title = questTitle or "|cFFFF0000Retrieving..."
Nenue@29 327 self.itemTexture = rewardIcon or self.itemTexture
Nenue@29 328 self.itemName = rewardName or self.itemName
Nenue@33 329 self.isStale = hasUpdate
Nenue@29 330 self.isPending = isPending
Nenue@29 331
Nenue@29 332
Nenue@29 333 qprint(' |cFF00FFFF'..questID..'|r hasUpdate:', hasUpdate, 'isPending:', isPending)
Nenue@30 334 qprint(' ', 'rewardType:', self.rewardType, 'tag:', self.tagID)
Nenue@30 335 qprint(' ', tostring(self.title), " |T"..tostring(self.itemTexture)..":12:12|t", tostring(self.itemName))
Nenue@29 336 end
Nenue@31 337 self.cheevos = familiars[self.questID]
Nenue@31 338
Nenue@29 339 return hasUpdate, isPending
Nenue@29 340 end
Nenue@29 341
Nenue@29 342
Nenue@7 343 function WorldPlanPOIMixin:SetAchievementProgressTooltip()
Nenue@7 344 print('cheevos')
Nenue@7 345 end
Nenue@7 346
Nenue@34 347 -- run from OnShow if .isNew is set
Nenue@34 348 function WorldPlanPOIMixin:OnNew()
Nenue@34 349 self:SetAlpha(0)
Nenue@34 350
Nenue@34 351 if WorldPlan.db.FadeWhileGrouped then
Nenue@34 352 self.FadeIn.FadeIn:SetToAlpha(0.15)
Nenue@34 353 self.PendingFade.FadeIn:SetToAlpha(0.15)
Nenue@34 354 self.PendingFade.FadeIn:SetFromAlpha(0.15)
Nenue@34 355 else
Nenue@34 356 self.FadeIn.FadeIn:SetToAlpha(1)
Nenue@34 357 self.PendingFade.FadeIn:SetToAlpha(1)
Nenue@34 358 self.PendingFade.FadeIn:SetFromAlpha(1)
Nenue@34 359 end
Nenue@34 360 if not self.isAnimating then
Nenue@34 361 self.isAnimating = true
Nenue@34 362 WorldPlan:OnNext(function()
Nenue@34 363 self.isNew = nil
Nenue@34 364 self.FadeIn:Play()
Nenue@34 365 end)
Nenue@34 366 end
Nenue@7 367 end
Nenue@7 368
Nenue@27 369 function WorldPlanPOIMixin:OnShow ()
Nenue@33 370 qprint('|cFFFFFF00["'..tostring(self.title)..'"]|r:OnShow() update:', self.isStale, 'new:', self.isNew, 'animation:', self.isAnimating)
Nenue@27 371 -- pop this on principle
Nenue@34 372
Nenue@34 373 if self.isNew or self.isStale then
Nenue@27 374 self:Refresh()
Nenue@27 375 end
Nenue@27 376
Nenue@34 377
Nenue@34 378 -- is it a new quest?
Nenue@34 379 if self.isNew then
Nenue@34 380 WorldPlan:print('|cFF0088FF', self.title, '|r', self.isNew and 'new', self.isStale and 'stale', self.isAnimating and 'animating')
Nenue@34 381 self:OnNew()
Nenue@34 382 -- trap new but animating pins here
Nenue@34 383 else
Nenue@34 384 -- hard show existing self
Nenue@34 385 --print('refresh #', questID, 'filtered:', self.filtered, 'hasUpdate', self.hasUpdate)
Nenue@34 386 self:Show()
Nenue@34 387 end
Nenue@34 388
Nenue@34 389
Nenue@27 390 end
Nenue@27 391 function WorldPlanPOIMixin:OnHide()
Nenue@27 392 qprint('|cFFFFFF00["'..tostring(self.title)..'"]|r:OnHide()')
Nenue@34 393 if not self:IsShown() then
Nenue@34 394 self.isAnimating = nil
Nenue@34 395 self:SetAlpha(0)
Nenue@34 396 end
Nenue@34 397
Nenue@27 398 end
Nenue@27 399
Nenue@27 400 function WorldPlanPOIMixin:SetAnchor(frame, mapID, mapWidth, mapHeight)
Nenue@33 401 --qprint(' |cFF00FF00'..self:GetName()..':SetAnchor()|r', self.questID, mapID, mapWidth)
Nenue@7 402 self:ClearAllPoints()
Nenue@29 403 local dX, dY = TQ_GetQuestLocation(self.questID)
Nenue@7 404 if not dX or dX == 0 then
Nenue@7 405 local _, x, y = QuestPOIGetIconInfo(self.questID)
Nenue@7 406 if x and floor(x) ~= 0 then
Nenue@7 407 dX, dY = x, y
Nenue@7 408 else
Nenue@7 409 dX, dY = self.x, self.y
Nenue@7 410 end
Nenue@7 411 end
Nenue@7 412 self.x = dX
Nenue@7 413 self.y = dY
Nenue@7 414
Nenue@29 415 --qprint(' |cFF00FF00'..self.questID..':|r', format("%0.2f %0.2f", dX, dY))
Nenue@7 416
Nenue@7 417 local pX = (dX * mapWidth)
Nenue@7 418 local pY = (-dY * mapHeight)
Nenue@7 419
Nenue@7 420 self:SetParent(WorldMapPOIFrame)
Nenue@7 421 self:SetPoint('CENTER', frame, 'TOPLEFT', pX, pY)
Nenue@7 422 end
Nenue@7 423
Nenue@7 424
Nenue@27 425 function WorldPlanPOIMixin:OnLoad()
Nenue@27 426 qprint('|cFF00FF88'..self:GetName()..':OnLoad()|r',WorldPlan.db)
Nenue@7 427 self:RegisterEvent('SUPER_TRACKED_QUEST_CHANGED')
Nenue@27 428 self.style = WorldPlan.db.defaultPinStyle
Nenue@27 429 self.subStyle = WorldPlan.db.defaultPinStyle.continent
Nenue@7 430 end
Nenue@7 431
Nenue@27 432 function WorldPlanPOIMixin:OnEvent(event, ...)
Nenue@7 433 if event == 'SUPER_TRACKED_QUEST_CHANGED' then
Nenue@33 434 self.isStale = true
Nenue@7 435 end
Nenue@7 436 end
Nenue@7 437
Nenue@7 438
Nenue@7 439 local PIN_UPDATE_DELAY = .016
Nenue@7 440 local TOP_PIN_ID
Nenue@27 441 function WorldPlanPOIMixin:OnUpdate (sinceLast)
Nenue@30 442
Nenue@33 443 if self.isStale then
Nenue@33 444 print('|cFFFFFF00push poi update')
Nenue@30 445 self:Refresh()
Nenue@30 446 return
Nenue@30 447 end
Nenue@7 448 -- control update check intervals
Nenue@7 449 self.throttle = (self.throttle or PIN_UPDATE_DELAY) - sinceLast
Nenue@7 450 if self.throttle <= 0 then
Nenue@7 451 -- factor overtime into the throttle timer
Nenue@7 452 self.throttle = PIN_UPDATE_DELAY - self.throttle
Nenue@7 453 else
Nenue@7 454 return
Nenue@7 455 end
Nenue@7 456
Nenue@7 457 -- query for reward data if it wasn't found in the original scan
Nenue@7 458 local questID = self.questID
Nenue@7 459 if self.isPending then
Nenue@29 460 self:RefreshData()
Nenue@7 461 if not (self.PendingFade:IsPlaying() or self.isAnimating) then
Nenue@7 462 self.PendingFade:Play()
Nenue@7 463 end
Nenue@7 464 return
Nenue@7 465 else
Nenue@7 466 if self.PendingFade:IsPlaying() then
Nenue@7 467 self.PendingFade:Stop()
Nenue@7 468 end
Nenue@7 469 end
Nenue@7 470
Nenue@7 471
Nenue@7 472 -- update time elements
Nenue@7 473 local tl = self.timeThreschold
Nenue@7 474 local timeLeft = TQ_GetQuestTimeLeftMinutes(questID)
Nenue@7 475 if timeLeft > 0 then
Nenue@29 476 local text, timeState = WorldPlan:GetTimeInfo(timeLeft, self.TimeleftStage)
Nenue@29 477 if tl ~= timeState then
Nenue@29 478 tl = timeState
Nenue@29 479 self.timeLabel:SetText(text)
Nenue@7 480 end
Nenue@7 481 else
Nenue@7 482 -- remove self in a timely manner
Nenue@9 483 if not TQ_IsActive(self.questID) then
Nenue@9 484 print('|cFFFF4400'..self:GetName()..' pin hard timeout')
Nenue@9 485 if self.worldQuestType ~= LE_QUEST_TAG_TYPE_PROFESSION then
Nenue@9 486 self:Hide()
Nenue@9 487 end
Nenue@7 488 end
Nenue@7 489 end
Nenue@7 490 self.timeThreschold = tl
Nenue@7 491
Nenue@7 492 if self:IsMouseOver() then
Nenue@7 493 self.MouseGlow:Show()
Nenue@7 494 else
Nenue@7 495 self.MouseGlow:Hide()
Nenue@7 496 end
Nenue@8 497 end
Nenue@8 498
Nenue@8 499
Nenue@9 500
Nenue@27 501 function WorldPlanPOIMixin:Refresh ()
Nenue@9 502 local db = WorldPlan.db
Nenue@30 503 print('|cFF00FF88'..self:GetName()..'|r:Refresh()')
Nenue@9 504
Nenue@9 505
Nenue@9 506
Nenue@29 507 local questID = self:GetID()
Nenue@30 508 local style,subStyle = self:GetTypeInfo(self.rewardType)
Nenue@29 509 if self.filtered then
Nenue@29 510 subStyle = style.minimized
Nenue@29 511 end
Nenue@30 512 self.style = style
Nenue@31 513 self.subStyle = subStyle
Nenue@30 514
Nenue@29 515
Nenue@9 516 local borderMask = style.mask
Nenue@9 517 local borderFill = style.texture
Nenue@9 518 local iconBorder = self.iconBorder
Nenue@9 519 local icon = self.icon
Nenue@9 520 local count = self.count
Nenue@9 521
Nenue@27 522 self.hasNumeric = style.hasNumeric
Nenue@27 523 self.numberRGB = style.numberRGB
Nenue@27 524 self.showNumber = subStyle.showNumber
Nenue@9 525
Nenue@27 526
Nenue@9 527
Nenue@9 528 --WorldPlan:print(tostring(self.title), "|T"..tostring(self.itemTexture)..":16:16|t", tostring(self.itemName))
Nenue@9 529 SetMaskedTexture(icon, self.itemTexture or ICON_UNKNOWN, borderMask)
Nenue@9 530 icon:SetAllPoints(self)
Nenue@9 531
Nenue@9 532 if self.itemName then
Nenue@27 533
Nenue@29 534
Nenue@27 535 if self.hasNumeric then
Nenue@30 536 if subStyle.numberFontObject then
Nenue@33 537 --wqprint('change font', _G[subStyle.numberFontObject]:GetName())
Nenue@30 538 self.count:SetFontObject(_G[subStyle.numberFontObject])
Nenue@30 539 end
Nenue@33 540 --wqprint('filtered:', self.filtered, 'showNumber:', self.showNumber)
Nenue@30 541
Nenue@31 542 self.count:SetShown(self.showNumber)
Nenue@29 543 self.count:SetText(self.itemNumber)
Nenue@29 544 self.count:SetTextColor(unpack(self.numberRGB))
Nenue@9 545 else
Nenue@29 546 self.count:SetShown(false)
Nenue@29 547 self.count:SetText(nil)
Nenue@9 548 end
Nenue@27 549
Nenue@9 550 end
Nenue@9 551
Nenue@9 552 SetMaskedTexture(iconBorder, borderFill, borderMask)
Nenue@30 553 local border = self:GetTypeInfo(self.rewardType)
Nenue@9 554 iconBorder:SetVertexColor(border.r, border.g, border.b, border.a)
Nenue@9 555 iconBorder:SetDesaturated(true)
Nenue@9 556
Nenue@9 557 local trackingBorder = self.supertrackBorder
Nenue@9 558
Nenue@9 559 self.highlight:SetMask(nil)
Nenue@9 560 if questID == GetSuperTrackedQuestID() then
Nenue@9 561 trackingBorder:SetVertexColor(0,0,0,1)
Nenue@9 562 else
Nenue@9 563 trackingBorder:SetVertexColor(0,0,0,0.5)
Nenue@9 564 end
Nenue@9 565 self.highlight:SetAllPoints(trackingBorder)
Nenue@9 566
Nenue@9 567 SetMaskedTexture(trackingBorder, borderFill, borderMask)
Nenue@9 568 self.highlight:SetMask(borderMask)
Nenue@9 569
Nenue@9 570 local qType = self.worldQuestType
Nenue@9 571 self.tagIcon:SetAtlas(self.tagAtlas)
Nenue@9 572 self.tagIcon:SetTexCoord(0,1,0,1)
Nenue@9 573
Nenue@9 574
Nenue@9 575 if self.isElite then
Nenue@29 576 self.EliteBorder:Show()
Nenue@9 577 else
Nenue@29 578 self.EliteBorder:Hide()
Nenue@9 579 end
Nenue@30 580 --qprint('|cFF88FF00updated', questID, self.title, self.rewardType, (style.showNumber and self.itemNumber) or '')
Nenue@30 581 --print(' - subStyle:', (self.filtered == true), self.subStyle)
Nenue@9 582
Nenue@9 583
Nenue@9 584 self:UpdateSize()
Nenue@33 585 self.isStale = nil
Nenue@9 586 end
Nenue@9 587
Nenue@8 588
Nenue@8 589
Nenue@33 590
Nenue@33 591 function QuestPOI:IsShowable ()
Nenue@33 592 local print = wqprint
Nenue@33 593 local db = WorldPlan.db
Nenue@33 594 local qType = self.worldQuestType
Nenue@33 595 local rType = self.rewardType
Nenue@33 596 self.filtered = nil
Nenue@33 597 self.used = true
Nenue@33 598
Nenue@33 599
Nenue@33 600 self.questId = self:GetID()
Nenue@33 601 if not (WorldMap_DoesWorldQuestInfoPassFilters(self, false, true)) then
Nenue@33 602 self.filtered = true
Nenue@33 603 end
Nenue@33 604
Nenue@33 605 for filterKey, value in pairs(WorldPlan.UsedFilters) do
Nenue@33 606 if self[filterKey] ~= value then
Nenue@33 607 self.filtered = true
Nenue@8 608 end
Nenue@8 609 end
Nenue@33 610
Nenue@33 611 if not TQ_IsActive(self.questID) then
Nenue@33 612 self.used = nil
Nenue@33 613 elseif qType == LE_QUEST_TAG_TYPE_PROFESSION then
Nenue@33 614 if not (db.ShowAllProfessionQuests or (self.tradeskillLineIndex and GetProfessionInfo(self.tradeskillLineIndex))) then
Nenue@33 615 self.used = nil
Nenue@33 616 end
Nenue@33 617 end
Nenue@34 618 print(' |cFFFF4400IsShowable()|r', self.isNew, self.isAnimating, self.used, self.filtered, self.title)
Nenue@33 619 return self.used, self.filtered
Nenue@33 620 end
Nenue@33 621
Nenue@33 622 function QuestPOI:UpdateTimer (timeLeft, timeType)
Nenue@33 623 print('|cFF0088FFUpdatePinTimer()|r')
Nenue@33 624 end
Nenue@33 625
Nenue@33 626 --- Fixes icons upon size update
Nenue@33 627 function QuestPOI:UpdateSize (style, subStyle)
Nenue@33 628 style = style or self.style
Nenue@33 629 subStyle = subStyle or self.subStyle
Nenue@33 630
Nenue@33 631 --qprint('|cFF00FF88'..self:GetName()..'|r:UpdateSize()', style, subStyle)
Nenue@33 632
Nenue@33 633 self.currentWidth = subStyle.PinSize
Nenue@33 634 self.borderSize = subStyle.Border
Nenue@33 635 self.trackingBorderSize = subStyle.TrackingBorder
Nenue@33 636 self.tagSize = subStyle.TagSize
Nenue@33 637 self.TimeleftStage = subStyle.TimeleftStage
Nenue@33 638 self.NoIcon = subStyle.NoIcon
Nenue@33 639
Nenue@33 640
Nenue@33 641 self:SetSize(self.currentWidth, self.currentWidth)
Nenue@33 642
Nenue@33 643 local icon = self.icon
Nenue@33 644 local iconBorder = self.iconBorder
Nenue@33 645 local trackingBorder = self.supertrackBorder
Nenue@33 646 local tag = self.tagIcon
Nenue@33 647 local pinMask = style.pinMask
Nenue@33 648 local rewardMask = style.rewardMask
Nenue@33 649
Nenue@33 650 if self.NoIcon then
Nenue@33 651 self.icon:Hide()
Nenue@33 652 else
Nenue@33 653 self.icon:Show()
Nenue@33 654 icon:SetMask(nil)
Nenue@33 655 icon:SetMask(rewardMask)
Nenue@33 656 icon:SetTexture(self.icon:GetTexture())
Nenue@33 657 end
Nenue@33 658 iconBorder:SetMask(nil)
Nenue@33 659 trackingBorder:SetMask(nil)
Nenue@33 660
Nenue@33 661
Nenue@33 662 local borderWidth = self.borderSize
Nenue@33 663 local trackingWidth = self.trackingBorderSize
Nenue@33 664
Nenue@33 665 iconBorder:ClearAllPoints()
Nenue@33 666 iconBorder:SetPoint('BOTTOMLEFT', self, 'BOTTOMLEFT', -borderWidth + (style.x or 0), -borderWidth + (style.y or 0))
Nenue@33 667 iconBorder:SetPoint('TOPRIGHT', self, 'TOPRIGHT', borderWidth + (style.x or 0), borderWidth + (style.y or 0))
Nenue@33 668
Nenue@33 669 trackingBorder:ClearAllPoints()
Nenue@33 670 trackingBorder:SetPoint('BOTTOMLEFT', iconBorder, 'BOTTOMLEFT', -trackingWidth, -trackingWidth)
Nenue@33 671 trackingBorder:SetPoint('TOPRIGHT', iconBorder, 'TOPRIGHT', trackingWidth, trackingWidth)
Nenue@33 672
Nenue@33 673 if self.tagSize then
Nenue@33 674 tag:Show()
Nenue@33 675 tag:ClearAllPoints()
Nenue@33 676 tag:SetPoint('BOTTOMRIGHT', self, 'BOTTOMRIGHT', borderWidth, -borderWidth)
Nenue@33 677 else
Nenue@33 678 tag:Hide()
Nenue@33 679 end
Nenue@33 680
Nenue@33 681 --qprint('using mask:', mask, self.name )
Nenue@33 682 iconBorder:SetMask(pinMask)
Nenue@33 683 trackingBorder:SetMask(pinMask)
Nenue@7 684 end