annotate QuestPOI.lua @ 35:26dfa661daa7

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