annotate QuestPOI.lua @ 32:e8679ecb48d8

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