annotate QuestPOI.lua @ 33:be4db60219ca

WorldPlan: - Toggling a reward filter cancels out other types by default. Use right mouse to clear. - Fixed filter bar info falling out of sync after player-triggered world map updates. 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 17:25:07 -0400
parents d0114b51cdea
children 0100d923d8c3
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@27 347 function WorldPlanPOIMixin:ShowNew()
Nenue@27 348 self:SetShown(true)
Nenue@27 349 self.isNew = nil
Nenue@33 350 self.isStale = true
Nenue@27 351 self.FadeIn:Play()
Nenue@7 352 end
Nenue@7 353
Nenue@27 354 function WorldPlanPOIMixin:OnShow ()
Nenue@33 355 qprint('|cFFFFFF00["'..tostring(self.title)..'"]|r:OnShow() update:', self.isStale, 'new:', self.isNew, 'animation:', self.isAnimating)
Nenue@27 356 -- pop this on principle
Nenue@33 357 if self.isStale then
Nenue@27 358 self:Refresh()
Nenue@27 359 end
Nenue@27 360
Nenue@27 361 end
Nenue@27 362 function WorldPlanPOIMixin:OnHide()
Nenue@27 363 qprint('|cFFFFFF00["'..tostring(self.title)..'"]|r:OnHide()')
Nenue@27 364 end
Nenue@27 365
Nenue@27 366 function WorldPlanPOIMixin:SetAnchor(frame, mapID, mapWidth, mapHeight)
Nenue@33 367 --qprint(' |cFF00FF00'..self:GetName()..':SetAnchor()|r', self.questID, mapID, mapWidth)
Nenue@7 368 self:ClearAllPoints()
Nenue@29 369 local dX, dY = TQ_GetQuestLocation(self.questID)
Nenue@7 370 if not dX or dX == 0 then
Nenue@7 371 local _, x, y = QuestPOIGetIconInfo(self.questID)
Nenue@7 372 if x and floor(x) ~= 0 then
Nenue@7 373 dX, dY = x, y
Nenue@7 374 else
Nenue@7 375 dX, dY = self.x, self.y
Nenue@7 376 end
Nenue@7 377 end
Nenue@7 378 self.x = dX
Nenue@7 379 self.y = dY
Nenue@7 380
Nenue@29 381 --qprint(' |cFF00FF00'..self.questID..':|r', format("%0.2f %0.2f", dX, dY))
Nenue@7 382
Nenue@7 383 local pX = (dX * mapWidth)
Nenue@7 384 local pY = (-dY * mapHeight)
Nenue@7 385
Nenue@7 386 self:SetParent(WorldMapPOIFrame)
Nenue@7 387 self:SetPoint('CENTER', frame, 'TOPLEFT', pX, pY)
Nenue@7 388 end
Nenue@7 389
Nenue@7 390
Nenue@27 391 function WorldPlanPOIMixin:OnLoad()
Nenue@27 392 qprint('|cFF00FF88'..self:GetName()..':OnLoad()|r',WorldPlan.db)
Nenue@7 393 self:RegisterEvent('SUPER_TRACKED_QUEST_CHANGED')
Nenue@27 394 self.style = WorldPlan.db.defaultPinStyle
Nenue@27 395 self.subStyle = WorldPlan.db.defaultPinStyle.continent
Nenue@7 396 end
Nenue@7 397
Nenue@27 398 function WorldPlanPOIMixin:OnEvent(event, ...)
Nenue@7 399 if event == 'SUPER_TRACKED_QUEST_CHANGED' then
Nenue@33 400 self.isStale = true
Nenue@7 401 end
Nenue@7 402 end
Nenue@7 403
Nenue@7 404
Nenue@7 405 local PIN_UPDATE_DELAY = .016
Nenue@7 406 local TOP_PIN_ID
Nenue@27 407 function WorldPlanPOIMixin:OnUpdate (sinceLast)
Nenue@30 408
Nenue@33 409 if self.isStale then
Nenue@33 410 print('|cFFFFFF00push poi update')
Nenue@30 411 self:Refresh()
Nenue@30 412 return
Nenue@30 413 end
Nenue@7 414 -- control update check intervals
Nenue@7 415 self.throttle = (self.throttle or PIN_UPDATE_DELAY) - sinceLast
Nenue@7 416 if self.throttle <= 0 then
Nenue@7 417 -- factor overtime into the throttle timer
Nenue@7 418 self.throttle = PIN_UPDATE_DELAY - self.throttle
Nenue@7 419 else
Nenue@7 420 return
Nenue@7 421 end
Nenue@7 422
Nenue@7 423 -- query for reward data if it wasn't found in the original scan
Nenue@7 424 local questID = self.questID
Nenue@7 425 if self.isPending then
Nenue@29 426 self:RefreshData()
Nenue@7 427 if not (self.PendingFade:IsPlaying() or self.isAnimating) then
Nenue@7 428 self.PendingFade:Play()
Nenue@7 429 end
Nenue@7 430 return
Nenue@7 431 else
Nenue@7 432 if self.PendingFade:IsPlaying() then
Nenue@7 433 self.PendingFade:Stop()
Nenue@7 434 end
Nenue@7 435 end
Nenue@7 436
Nenue@7 437
Nenue@7 438 -- update time elements
Nenue@7 439 local tl = self.timeThreschold
Nenue@7 440 local timeLeft = TQ_GetQuestTimeLeftMinutes(questID)
Nenue@7 441 if timeLeft > 0 then
Nenue@29 442 local text, timeState = WorldPlan:GetTimeInfo(timeLeft, self.TimeleftStage)
Nenue@29 443 if tl ~= timeState then
Nenue@29 444 tl = timeState
Nenue@29 445 self.timeLabel:SetText(text)
Nenue@7 446 end
Nenue@7 447 else
Nenue@7 448 -- remove self in a timely manner
Nenue@9 449 if not TQ_IsActive(self.questID) then
Nenue@9 450 print('|cFFFF4400'..self:GetName()..' pin hard timeout')
Nenue@9 451 if self.worldQuestType ~= LE_QUEST_TAG_TYPE_PROFESSION then
Nenue@9 452 self:Hide()
Nenue@9 453 end
Nenue@7 454 end
Nenue@7 455 end
Nenue@7 456 self.timeThreschold = tl
Nenue@7 457
Nenue@7 458 if self:IsMouseOver() then
Nenue@7 459 self.MouseGlow:Show()
Nenue@7 460 else
Nenue@7 461 self.MouseGlow:Hide()
Nenue@7 462 end
Nenue@8 463 end
Nenue@8 464
Nenue@8 465
Nenue@9 466
Nenue@27 467 function WorldPlanPOIMixin:Refresh ()
Nenue@9 468 local db = WorldPlan.db
Nenue@30 469 print('|cFF00FF88'..self:GetName()..'|r:Refresh()')
Nenue@9 470
Nenue@9 471
Nenue@9 472
Nenue@29 473 local questID = self:GetID()
Nenue@30 474 local style,subStyle = self:GetTypeInfo(self.rewardType)
Nenue@29 475 if self.filtered then
Nenue@29 476 subStyle = style.minimized
Nenue@29 477 end
Nenue@30 478 self.style = style
Nenue@31 479 self.subStyle = subStyle
Nenue@30 480
Nenue@29 481
Nenue@9 482 local borderMask = style.mask
Nenue@9 483 local borderFill = style.texture
Nenue@9 484 local iconBorder = self.iconBorder
Nenue@9 485 local icon = self.icon
Nenue@9 486 local count = self.count
Nenue@9 487
Nenue@27 488 self.hasNumeric = style.hasNumeric
Nenue@27 489 self.numberRGB = style.numberRGB
Nenue@27 490 self.showNumber = subStyle.showNumber
Nenue@9 491
Nenue@27 492
Nenue@9 493
Nenue@9 494 --WorldPlan:print(tostring(self.title), "|T"..tostring(self.itemTexture)..":16:16|t", tostring(self.itemName))
Nenue@9 495 SetMaskedTexture(icon, self.itemTexture or ICON_UNKNOWN, borderMask)
Nenue@9 496 icon:SetAllPoints(self)
Nenue@9 497
Nenue@9 498 if self.itemName then
Nenue@27 499
Nenue@29 500
Nenue@27 501 if self.hasNumeric then
Nenue@30 502 if subStyle.numberFontObject then
Nenue@33 503 --wqprint('change font', _G[subStyle.numberFontObject]:GetName())
Nenue@30 504 self.count:SetFontObject(_G[subStyle.numberFontObject])
Nenue@30 505 end
Nenue@33 506 --wqprint('filtered:', self.filtered, 'showNumber:', self.showNumber)
Nenue@30 507
Nenue@31 508 self.count:SetShown(self.showNumber)
Nenue@29 509 self.count:SetText(self.itemNumber)
Nenue@29 510 self.count:SetTextColor(unpack(self.numberRGB))
Nenue@9 511 else
Nenue@29 512 self.count:SetShown(false)
Nenue@29 513 self.count:SetText(nil)
Nenue@9 514 end
Nenue@27 515
Nenue@9 516 end
Nenue@9 517
Nenue@9 518 SetMaskedTexture(iconBorder, borderFill, borderMask)
Nenue@30 519 local border = self:GetTypeInfo(self.rewardType)
Nenue@9 520 iconBorder:SetVertexColor(border.r, border.g, border.b, border.a)
Nenue@9 521 iconBorder:SetDesaturated(true)
Nenue@9 522
Nenue@9 523 local trackingBorder = self.supertrackBorder
Nenue@9 524
Nenue@9 525 self.highlight:SetMask(nil)
Nenue@9 526 if questID == GetSuperTrackedQuestID() then
Nenue@9 527 trackingBorder:SetVertexColor(0,0,0,1)
Nenue@9 528 else
Nenue@9 529 trackingBorder:SetVertexColor(0,0,0,0.5)
Nenue@9 530 end
Nenue@9 531 self.highlight:SetAllPoints(trackingBorder)
Nenue@9 532
Nenue@9 533 SetMaskedTexture(trackingBorder, borderFill, borderMask)
Nenue@9 534 self.highlight:SetMask(borderMask)
Nenue@9 535
Nenue@9 536 local qType = self.worldQuestType
Nenue@9 537 self.tagIcon:SetAtlas(self.tagAtlas)
Nenue@9 538 self.tagIcon:SetTexCoord(0,1,0,1)
Nenue@9 539
Nenue@9 540
Nenue@9 541 if self.isElite then
Nenue@29 542 self.EliteBorder:Show()
Nenue@9 543 else
Nenue@29 544 self.EliteBorder:Hide()
Nenue@9 545 end
Nenue@30 546 --qprint('|cFF88FF00updated', questID, self.title, self.rewardType, (style.showNumber and self.itemNumber) or '')
Nenue@30 547 --print(' - subStyle:', (self.filtered == true), self.subStyle)
Nenue@9 548
Nenue@9 549
Nenue@9 550 self:UpdateSize()
Nenue@33 551 self.isStale = nil
Nenue@9 552 end
Nenue@9 553
Nenue@8 554
Nenue@8 555
Nenue@33 556
Nenue@33 557 function QuestPOI:IsShowable ()
Nenue@33 558 local print = wqprint
Nenue@33 559 local db = WorldPlan.db
Nenue@33 560 local qType = self.worldQuestType
Nenue@33 561 local rType = self.rewardType
Nenue@33 562 self.filtered = nil
Nenue@33 563 self.used = true
Nenue@33 564
Nenue@33 565
Nenue@33 566 self.questId = self:GetID()
Nenue@33 567 if not (WorldMap_DoesWorldQuestInfoPassFilters(self, false, true)) then
Nenue@33 568 self.filtered = true
Nenue@33 569 end
Nenue@33 570
Nenue@33 571 for filterKey, value in pairs(WorldPlan.UsedFilters) do
Nenue@33 572 if self[filterKey] ~= value then
Nenue@33 573 self.filtered = true
Nenue@8 574 end
Nenue@8 575 end
Nenue@33 576
Nenue@33 577 if not TQ_IsActive(self.questID) then
Nenue@33 578 self.used = nil
Nenue@33 579 elseif qType == LE_QUEST_TAG_TYPE_PROFESSION then
Nenue@33 580 if not (db.ShowAllProfessionQuests or (self.tradeskillLineIndex and GetProfessionInfo(self.tradeskillLineIndex))) then
Nenue@33 581 self.used = nil
Nenue@33 582 end
Nenue@33 583 end
Nenue@33 584 print(' |cFFFF4400IsShowable()|r', self.used, self.filtered, self.title)
Nenue@33 585 return self.used, self.filtered
Nenue@33 586 end
Nenue@33 587
Nenue@33 588 function QuestPOI:UpdateTimer (timeLeft, timeType)
Nenue@33 589 print('|cFF0088FFUpdatePinTimer()|r')
Nenue@33 590 end
Nenue@33 591
Nenue@33 592 --- Fixes icons upon size update
Nenue@33 593 function QuestPOI:UpdateSize (style, subStyle)
Nenue@33 594 style = style or self.style
Nenue@33 595 subStyle = subStyle or self.subStyle
Nenue@33 596
Nenue@33 597 --qprint('|cFF00FF88'..self:GetName()..'|r:UpdateSize()', style, subStyle)
Nenue@33 598
Nenue@33 599 self.currentWidth = subStyle.PinSize
Nenue@33 600 self.borderSize = subStyle.Border
Nenue@33 601 self.trackingBorderSize = subStyle.TrackingBorder
Nenue@33 602 self.tagSize = subStyle.TagSize
Nenue@33 603 self.TimeleftStage = subStyle.TimeleftStage
Nenue@33 604 self.NoIcon = subStyle.NoIcon
Nenue@33 605
Nenue@33 606
Nenue@33 607 self:SetSize(self.currentWidth, self.currentWidth)
Nenue@33 608
Nenue@33 609 local icon = self.icon
Nenue@33 610 local iconBorder = self.iconBorder
Nenue@33 611 local trackingBorder = self.supertrackBorder
Nenue@33 612 local tag = self.tagIcon
Nenue@33 613 local pinMask = style.pinMask
Nenue@33 614 local rewardMask = style.rewardMask
Nenue@33 615
Nenue@33 616 if self.NoIcon then
Nenue@33 617 self.icon:Hide()
Nenue@33 618 else
Nenue@33 619 self.icon:Show()
Nenue@33 620 icon:SetMask(nil)
Nenue@33 621 icon:SetMask(rewardMask)
Nenue@33 622 icon:SetTexture(self.icon:GetTexture())
Nenue@33 623 end
Nenue@33 624 iconBorder:SetMask(nil)
Nenue@33 625 trackingBorder:SetMask(nil)
Nenue@33 626
Nenue@33 627
Nenue@33 628 local borderWidth = self.borderSize
Nenue@33 629 local trackingWidth = self.trackingBorderSize
Nenue@33 630
Nenue@33 631 iconBorder:ClearAllPoints()
Nenue@33 632 iconBorder:SetPoint('BOTTOMLEFT', self, 'BOTTOMLEFT', -borderWidth + (style.x or 0), -borderWidth + (style.y or 0))
Nenue@33 633 iconBorder:SetPoint('TOPRIGHT', self, 'TOPRIGHT', borderWidth + (style.x or 0), borderWidth + (style.y or 0))
Nenue@33 634
Nenue@33 635 trackingBorder:ClearAllPoints()
Nenue@33 636 trackingBorder:SetPoint('BOTTOMLEFT', iconBorder, 'BOTTOMLEFT', -trackingWidth, -trackingWidth)
Nenue@33 637 trackingBorder:SetPoint('TOPRIGHT', iconBorder, 'TOPRIGHT', trackingWidth, trackingWidth)
Nenue@33 638
Nenue@33 639 if self.tagSize then
Nenue@33 640 tag:Show()
Nenue@33 641 tag:ClearAllPoints()
Nenue@33 642 tag:SetPoint('BOTTOMRIGHT', self, 'BOTTOMRIGHT', borderWidth, -borderWidth)
Nenue@33 643 else
Nenue@33 644 tag:Hide()
Nenue@33 645 end
Nenue@33 646
Nenue@33 647 --qprint('using mask:', mask, self.name )
Nenue@33 648 iconBorder:SetMask(pinMask)
Nenue@33 649 trackingBorder:SetMask(pinMask)
Nenue@7 650 end