annotate QuestPOI.lua @ 37:78cf1f19856a

WorldPlan: - Quest pins are now placed on the flight map. Their visibility rules will mirror the filter options from the world map. - Filter controls polish: - First click negates other reward type filters. Subsequent clicks will then toggle individual reward types until the filters are reset via Right-click. - Adheres to the Blizzard CVars added in patch 7.1 - Numerous optimizations to how data and visual updates are handled; should see an even better load time, and snappier world map interaction. ClassPlan: - The 'Available Missions' list is now recorded. It can be reviewed by clicking on the mission list heading. - Information filtering by character and realm.
author Nenue
date Fri, 04 Nov 2016 02:47:17 -0400
parents 21bcff08b0f4
children 589c444d4837
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@36 56 iconWidth = 14,
Nenue@36 57 borderWidth = 2,
Nenue@36 58 highlightWidth = 1,
Nenue@31 59 TagSize = 6,
Nenue@36 60 maxAlertLevel = 0,
Nenue@31 61 showNumber = false,
Nenue@31 62 numberFontObject = 'WorldPlanFont'
Nenue@31 63 },
Nenue@31 64 zone = {
Nenue@36 65 iconWidth = 22,
Nenue@36 66 borderWidth = 3,
Nenue@36 67 highlightWidth = 2,
Nenue@31 68 TagSize = 12,
Nenue@36 69 maxAlertLevel = 3,
Nenue@31 70 showNumber = true,
Nenue@31 71 numberFontObject = 'WorldPlanNumberFontThin'
Nenue@31 72 },
Nenue@31 73 minimized = {
Nenue@36 74 iconWidth = 4,
Nenue@36 75 borderWidth = 0,
Nenue@36 76 highlightWidth = 1,
Nenue@31 77 NoIcon = true,
Nenue@36 78 maxAlertLevel = 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@37 170 if WorldMapFrame:IsVisible() then
Nenue@37 171 WorldMapTooltip:SetOwner(self, 'ANCHOR_RIGHT')
Nenue@37 172 else
Nenue@37 173 WorldMap_HijackTooltip(self.owningFrame)
Nenue@36 174 end
Nenue@36 175
Nenue@7 176 local completed = select(4,GetAchievementInfo(familiars_id))
Nenue@7 177 if not completed then
Nenue@7 178 if self.worldQuestType == LE_QUEST_TAG_TYPE_PET_BATTLE and familiars[self.questID] then
Nenue@37 179
Nenue@31 180 WorldMapTooltip:AddLine(self.title, 1, 1, 1)
Nenue@31 181 if self.quality then
Nenue@31 182 local c = ITEM_QUALITY_COLORS[self.quality]
Nenue@31 183 WorldMapTooltip:AddLine(" ")
Nenue@31 184 WorldMapTooltip:AddLine('Rewards')
Nenue@31 185 WorldMapTooltip:AddLine(self.itemName .. (self.quantity and (' x'..self.quantity) or ''), c.r, c.g, c.b)
Nenue@31 186 WorldMapTooltip:AddTexture(self.itemTexture)
Nenue@31 187
Nenue@31 188 local cLine = WorldMapTooltip:NumLines()
Nenue@31 189 local line = _G['WorldMapTooltipTextLeft'..cLine]
Nenue@31 190 local pline = _G['WorldMapTooltipTextLeft'..(cLine-1)]
Nenue@31 191 local icon = _G['WorldMapTooltipTexture'..(cLine-3)]
Nenue@31 192 icon:SetSize(24,24)
Nenue@31 193 icon:ClearAllPoints()
Nenue@31 194 icon:SetPoint('TOPLEFT', pline, 'BOTTOMLEFT', 0, -2)
Nenue@31 195 line:ClearAllPoints()
Nenue@31 196 line:SetPoint('TOPLEFT', icon, 'TOPRIGHT', 7, 0)
Nenue@31 197
Nenue@31 198 --- voodoo workaround for IDs getting coerced to string
Nenue@31 199 if type(self.itemTexture) == 'number' then
Nenue@31 200 icon:Show()
Nenue@31 201 icon:SetTexture(self.itemTexture)
Nenue@31 202 end
Nenue@31 203 end
Nenue@31 204
Nenue@31 205
Nenue@31 206 WorldMapTooltip:AddLine(" ") -- causes crash for some reason
Nenue@7 207 WorldMapTooltip:AddLine('Family Familiars')
Nenue@7 208 local trainer = familiars[self.questID].name
Nenue@7 209 local numCheevs = GetAchievementNumCriteria(familiars_id)
Nenue@7 210 for index = 1, numCheevs do
Nenue@7 211 local cheevName, cType, cCompleted, quantity, requiredQuantity, charName, flags, cheevID, quantityString, criteriaID = GetAchievementCriteriaInfo(familiars_id, index)
Nenue@7 212 local numTrainers = GetAchievementNumCriteria(cheevID)
Nenue@7 213 for subIndex = 1, numTrainers do
Nenue@7 214 local desc, cType, partCompleted = GetAchievementCriteriaInfo(cheevID, subIndex)
Nenue@7 215 if desc == trainer then
Nenue@7 216 if not partCompleted then
Nenue@7 217 local iconPath = select(10, GetAchievementInfo(cheevID))
Nenue@7 218 WorldMapTooltip:AddLine(cheevName)
Nenue@7 219 WorldMapTooltip:AddTexture(iconPath)
Nenue@7 220 end
Nenue@7 221 end
Nenue@7 222 end
Nenue@7 223 end
Nenue@7 224 WorldMapTooltip:Show()
Nenue@7 225 return
Nenue@7 226 end
Nenue@7 227 end
Nenue@7 228 TaskPOI_OnEnter(self)
Nenue@7 229 end
Nenue@27 230 function WorldPlanPOIMixin:OnLeave()
Nenue@35 231 WorldMap_RestoreTooltip()
Nenue@7 232 TaskPOI_OnLeave(self)
Nenue@7 233 end
Nenue@27 234 function WorldPlanPOIMixin:OnMouseDown()
Nenue@7 235 TaskPOI_OnClick(self)
Nenue@7 236 end
Nenue@7 237
Nenue@7 238
Nenue@29 239
Nenue@29 240 -- create or update the pin using the given questID and C_TaskQuest results
Nenue@29 241 function WorldPlanPOIMixin:RefreshData (info)
Nenue@29 242
Nenue@29 243 qprint('|cFF00FF88'..self:GetName()..':RefreshData()|r')
Nenue@29 244
Nenue@29 245 if info then
Nenue@29 246 self.inProgress = info.inProgress
Nenue@29 247 self.floor = info.floor
Nenue@29 248 self.numObjectives = info.numObjectives or 0
Nenue@30 249 if info.x and info.y then
Nenue@30 250 self.x = info.x or self.x
Nenue@30 251 self.y = info.y or self.y
Nenue@35 252 --qprint('|cFFFF4400applying taskInfo coords:', info.x, info.y)
Nenue@30 253 end
Nenue@30 254
Nenue@29 255 end
Nenue@29 256
Nenue@29 257
Nenue@29 258 local questID = self:GetID()
Nenue@29 259 local questTitle, rewardIcon, rewardName, rewardCount, rewardStyle, rewardType, itemID, quantity, quality, _
Nenue@33 260 local hasUpdate, isPending = (self.isStale or self.isNew), self.isPending
Nenue@29 261
Nenue@29 262
Nenue@29 263 if not HaveQuestData(questID) then
Nenue@29 264 TQ_RequestPreloadRewardData(questID)
Nenue@29 265 isPending = true
Nenue@29 266 else
Nenue@29 267
Nenue@29 268 -- set reward category
Nenue@29 269 local numRewards = GetNumQuestLogRewards(questID)
Nenue@29 270 local numCurrency = GetNumQuestLogRewardCurrencies(questID)
Nenue@29 271 local money = GetQuestLogRewardMoney(questID)
Nenue@29 272 if numRewards >= 1 then
Nenue@31 273 rewardType, rewardIcon, rewardCount, rewardName, itemID, quality = ParseItemReward(questID)
Nenue@29 274 elseif numCurrency >= 1 then
Nenue@29 275 rewardName, rewardIcon, rewardCount = GetQuestLogRewardCurrencyInfo(1, questID)
Nenue@29 276 rewardType = REWARD_CURRENCY
Nenue@29 277 elseif money >= 1 then
Nenue@29 278 rewardIcon = ICON_MONEY
Nenue@29 279 rewardName = GetMoneyString(money)
Nenue@29 280 rewardType = REWARD_CASH
Nenue@29 281 end
Nenue@30 282 rewardStyle = self:GetTypeInfo(rewardType)
Nenue@29 283
Nenue@29 284 self.itemNumber = rewardCount or self.itemNumber
Nenue@29 285 self.rewardType = rewardType or REWARD_ITEM
Nenue@29 286 self.style = rewardStyle
Nenue@31 287 self.quality = quality
Nenue@29 288
Nenue@29 289 -- title, faction, capped state
Nenue@29 290 local questTitle, factionID, capped = TQ_GetQuestInfoByQuestID(questID)
Nenue@29 291 self.factionID = factionID
Nenue@29 292 self.capped = capped
Nenue@29 293
Nenue@29 294 -- set tag details
Nenue@29 295 local tagID, tagName, worldQuestType, rarity, isElite, tradeskillLineIndex = GetQuestTagInfo(questID);
Nenue@29 296 local tagAtlas
Nenue@29 297 if worldQuestType == LE_QUEST_TAG_TYPE_PET_BATTLE then
Nenue@29 298 tagAtlas = "worldquest-icon-petbattle"
Nenue@29 299 elseif worldQuestType == LE_QUEST_TAG_TYPE_PVP then
Nenue@29 300 tagAtlas = "worldquest-icon-pvp-ffa"
Nenue@29 301 elseif worldQuestType == LE_QUEST_TAG_TYPE_PROFESSION then
Nenue@29 302 local id = tradeskillLineIndex and select(7, GetProfessionInfo(tradeskillLineIndex))
Nenue@29 303 if id then
Nenue@29 304 tagAtlas = WORLD_QUEST_ICONS_BY_PROFESSION[id]
Nenue@29 305 end
Nenue@29 306 elseif worldQuestType == LE_QUEST_TAG_TYPE_DUNGEON then
Nenue@29 307 tagAtlas = "worldquest-icon-dungeon"
Nenue@29 308 end
Nenue@29 309
Nenue@29 310 self.tagID = tagID
Nenue@29 311 self.tagName = tagName
Nenue@29 312 self.worldQuestType = worldQuestType
Nenue@29 313 self.isElite = isElite
Nenue@29 314 self.tradeskillLineIndex = tradeskillLineIndex
Nenue@29 315 self.rarity = rarity
Nenue@29 316 self.tagAtlas = tagAtlas
Nenue@29 317
Nenue@29 318 -- flag unresolved info
Nenue@29 319 if not (rewardIcon and rewardName) then
Nenue@29 320 isPending = true
Nenue@29 321 qprint('because not have icon')
Nenue@29 322 TQ_RequestPreloadRewardData (questID)
Nenue@29 323 --WorldPlan:print('|cFFFFFF00'..tostring(self.title)..'|r waiting on texture info')
Nenue@29 324 else
Nenue@29 325 if (rewardIcon and rewardName) and isPending then
Nenue@29 326 --WorldPlan:print('|cFF00FF00'..tostring(self.title)..'|r has info', rewardIcon, rewardName)
Nenue@29 327 hasUpdate = true
Nenue@29 328 end
Nenue@29 329 isPending = false
Nenue@29 330 end
Nenue@29 331
Nenue@29 332 self.title = questTitle or "|cFFFF0000Retrieving..."
Nenue@29 333 self.itemTexture = rewardIcon or self.itemTexture
Nenue@29 334 self.itemName = rewardName or self.itemName
Nenue@33 335 self.isStale = hasUpdate
Nenue@29 336 self.isPending = isPending
Nenue@29 337
Nenue@29 338
Nenue@35 339 --qprint(' |cFF00FFFF'..questID..'|r hasUpdate:', hasUpdate, 'isPending:', isPending, 'isShown', self:IsShown())
Nenue@35 340 --qprint(' ', 'rewardType:', self.rewardType, 'tag:', self.tagID)
Nenue@35 341 --qprint(' ', tostring(self.title), " |T"..tostring(self.itemTexture)..":12:12|t", tostring(self.itemName))
Nenue@29 342 end
Nenue@31 343 self.cheevos = familiars[self.questID]
Nenue@31 344
Nenue@29 345 return hasUpdate, isPending
Nenue@29 346 end
Nenue@29 347
Nenue@29 348
Nenue@7 349 function WorldPlanPOIMixin:SetAchievementProgressTooltip()
Nenue@7 350 print('cheevos')
Nenue@7 351 end
Nenue@7 352
Nenue@34 353 -- run from OnShow if .isNew is set
Nenue@34 354 function WorldPlanPOIMixin:OnNew()
Nenue@34 355
Nenue@34 356 if not self.isAnimating then
Nenue@35 357 --qprint('|cFFFFFF00'.. self.title .. ' added to quest log.')
Nenue@35 358 self:SetAlpha(0)
Nenue@35 359 if WorldPlan.db.FadeWhileGrouped then
Nenue@35 360 self.FadeIn.FadeIn:SetToAlpha(0.15)
Nenue@35 361 self.PendingFade.FadeIn:SetToAlpha(0.15)
Nenue@35 362 self.PendingFade.FadeOut:SetFromAlpha(0.15)
Nenue@35 363 else
Nenue@35 364 self.FadeIn.FadeIn:SetToAlpha(1)
Nenue@35 365 self.PendingFade.FadeIn:SetToAlpha(1)
Nenue@35 366 self.PendingFade.FadeOut:SetFromAlpha(1)
Nenue@35 367 end
Nenue@34 368 self.isAnimating = true
Nenue@35 369 self.isNew = nil
Nenue@35 370 self.FadeIn:Play()
Nenue@34 371 end
Nenue@7 372 end
Nenue@7 373
Nenue@27 374 function WorldPlanPOIMixin:OnShow ()
Nenue@27 375 -- pop this on principle
Nenue@34 376
Nenue@34 377 if self.isNew or self.isStale then
Nenue@27 378 self:Refresh()
Nenue@27 379 end
Nenue@27 380
Nenue@34 381
Nenue@34 382 -- is it a new quest?
Nenue@34 383 if self.isNew then
Nenue@36 384 qprint('|cFFFFFF00'..tostring(self:GetName())..':OnShow()|r update:', self.isStale, 'new:', self.isNew, 'animation:', self.isAnimating)
Nenue@36 385 --qprint('|cFFFFFF00popping new pin handler')
Nenue@34 386 self:OnNew()
Nenue@35 387 elseif not self.isAnimating then
Nenue@35 388 self:SetAlpha(1)
Nenue@34 389 end
Nenue@34 390
Nenue@36 391 self.Overlay:SetShown(true)
Nenue@35 392 --WorldPlan:print(self:GetAlpha())
Nenue@34 393
Nenue@27 394 end
Nenue@27 395 function WorldPlanPOIMixin:OnHide()
Nenue@35 396 --qprint('|cFFFFFF00["'..tostring(self.title)..'"]|r:OnHide()')
Nenue@34 397 if not self:IsShown() then
Nenue@34 398 self.isAnimating = nil
Nenue@35 399 self:SetAlpha(1)
Nenue@34 400 end
Nenue@34 401
Nenue@36 402 self.Overlay:SetShown(false)
Nenue@27 403 end
Nenue@27 404
Nenue@27 405 function WorldPlanPOIMixin:SetAnchor(frame, mapID, mapWidth, mapHeight)
Nenue@33 406 --qprint(' |cFF00FF00'..self:GetName()..':SetAnchor()|r', self.questID, mapID, mapWidth)
Nenue@7 407 self:ClearAllPoints()
Nenue@29 408 local dX, dY = TQ_GetQuestLocation(self.questID)
Nenue@7 409 if not dX or dX == 0 then
Nenue@7 410 local _, x, y = QuestPOIGetIconInfo(self.questID)
Nenue@7 411 if x and floor(x) ~= 0 then
Nenue@7 412 dX, dY = x, y
Nenue@7 413 else
Nenue@7 414 dX, dY = self.x, self.y
Nenue@7 415 end
Nenue@7 416 end
Nenue@7 417 self.x = dX
Nenue@7 418 self.y = dY
Nenue@7 419
Nenue@29 420 --qprint(' |cFF00FF00'..self.questID..':|r', format("%0.2f %0.2f", dX, dY))
Nenue@7 421
Nenue@7 422 local pX = (dX * mapWidth)
Nenue@7 423 local pY = (-dY * mapHeight)
Nenue@7 424
Nenue@7 425 self:SetParent(WorldMapPOIFrame)
Nenue@7 426 self:SetPoint('CENTER', frame, 'TOPLEFT', pX, pY)
Nenue@7 427 end
Nenue@7 428
Nenue@7 429
Nenue@27 430 function WorldPlanPOIMixin:OnLoad()
Nenue@27 431 qprint('|cFF00FF88'..self:GetName()..':OnLoad()|r',WorldPlan.db)
Nenue@7 432 self:RegisterEvent('SUPER_TRACKED_QUEST_CHANGED')
Nenue@36 433
Nenue@36 434 self.count = self.Overlay.count
Nenue@36 435 self.timeLabel = self.Overlay.timeLabel
Nenue@7 436 end
Nenue@7 437
Nenue@27 438 function WorldPlanPOIMixin:OnEvent(event, ...)
Nenue@7 439 if event == 'SUPER_TRACKED_QUEST_CHANGED' then
Nenue@33 440 self.isStale = true
Nenue@7 441 end
Nenue@7 442 end
Nenue@7 443
Nenue@7 444
Nenue@7 445 local PIN_UPDATE_DELAY = .016
Nenue@7 446 local TOP_PIN_ID
Nenue@27 447 function WorldPlanPOIMixin:OnUpdate (sinceLast)
Nenue@35 448 if self.isNew then
Nenue@35 449 print('|cFFFFFF00push new poi stuff')
Nenue@35 450 self:OnNew()
Nenue@30 451 end
Nenue@7 452 -- control update check intervals
Nenue@7 453 self.throttle = (self.throttle or PIN_UPDATE_DELAY) - sinceLast
Nenue@7 454 if self.throttle <= 0 then
Nenue@7 455 -- factor overtime into the throttle timer
Nenue@7 456 self.throttle = PIN_UPDATE_DELAY - self.throttle
Nenue@7 457 else
Nenue@7 458 return
Nenue@7 459 end
Nenue@35 460 if self.isStale and not self.isAnimating then
Nenue@36 461 wprint('|cFFFFFF00push poi update')
Nenue@35 462 self:Refresh()
Nenue@35 463 return
Nenue@35 464 end
Nenue@7 465
Nenue@7 466 -- query for reward data if it wasn't found in the original scan
Nenue@7 467 local questID = self.questID
Nenue@7 468 if self.isPending then
Nenue@29 469 self:RefreshData()
Nenue@7 470 if not (self.PendingFade:IsPlaying() or self.isAnimating) then
Nenue@7 471 self.PendingFade:Play()
Nenue@7 472 end
Nenue@7 473 return
Nenue@7 474 else
Nenue@7 475 if self.PendingFade:IsPlaying() then
Nenue@7 476 self.PendingFade:Stop()
Nenue@7 477 end
Nenue@7 478 end
Nenue@7 479
Nenue@7 480
Nenue@7 481 -- update time elements
Nenue@36 482 local tl = self.alertLevel
Nenue@7 483 local timeLeft = TQ_GetQuestTimeLeftMinutes(questID)
Nenue@7 484 if timeLeft > 0 then
Nenue@36 485 local text, timeState = WorldPlan:GetTimeInfo(timeLeft, self.maxAlertLevel)
Nenue@29 486 if tl ~= timeState then
Nenue@29 487 tl = timeState
Nenue@29 488 self.timeLabel:SetText(text)
Nenue@7 489 end
Nenue@7 490 else
Nenue@7 491 -- remove self in a timely manner
Nenue@9 492 if not TQ_IsActive(self.questID) then
Nenue@9 493 print('|cFFFF4400'..self:GetName()..' pin hard timeout')
Nenue@9 494 if self.worldQuestType ~= LE_QUEST_TAG_TYPE_PROFESSION then
Nenue@9 495 self:Hide()
Nenue@9 496 end
Nenue@7 497 end
Nenue@7 498 end
Nenue@36 499 self.alertLevel = tl
Nenue@7 500
Nenue@7 501 if self:IsMouseOver() then
Nenue@7 502 self.MouseGlow:Show()
Nenue@7 503 else
Nenue@7 504 self.MouseGlow:Hide()
Nenue@7 505 end
Nenue@8 506 end
Nenue@8 507
Nenue@8 508
Nenue@9 509
Nenue@27 510 function WorldPlanPOIMixin:Refresh ()
Nenue@9 511 local db = WorldPlan.db
Nenue@30 512 print('|cFF00FF88'..self:GetName()..'|r:Refresh()')
Nenue@9 513
Nenue@9 514
Nenue@9 515
Nenue@29 516 local questID = self:GetID()
Nenue@36 517 local iconBorder = self.RewardBorder
Nenue@36 518 local trackingBorder = self.HighlightBorder
Nenue@9 519 local icon = self.icon
Nenue@9 520 local count = self.count
Nenue@9 521
Nenue@9 522
Nenue@27 523
Nenue@9 524
Nenue@9 525 --WorldPlan:print(tostring(self.title), "|T"..tostring(self.itemTexture)..":16:16|t", tostring(self.itemName))
Nenue@36 526
Nenue@36 527
Nenue@9 528
Nenue@9 529 if self.itemName then
Nenue@33 530 --wqprint('filtered:', self.filtered, 'showNumber:', self.showNumber)
Nenue@30 531
Nenue@29 532 self.count:SetText(self.itemNumber)
Nenue@36 533 end
Nenue@36 534 if self.itemTexture then
Nenue@36 535 icon:SetTexture(self.itemTexture)
Nenue@36 536 icon:SetMask("Interface\\Minimap\\UI-Minimap-Background")
Nenue@9 537 end
Nenue@9 538
Nenue@30 539 local border = self:GetTypeInfo(self.rewardType)
Nenue@9 540 iconBorder:SetVertexColor(border.r, border.g, border.b, border.a)
Nenue@9 541 iconBorder:SetDesaturated(true)
Nenue@9 542
Nenue@9 543
Nenue@9 544 if questID == GetSuperTrackedQuestID() then
Nenue@9 545 trackingBorder:SetVertexColor(0,0,0,1)
Nenue@9 546 else
Nenue@9 547 trackingBorder:SetVertexColor(0,0,0,0.5)
Nenue@9 548 end
Nenue@9 549
Nenue@9 550 self.tagIcon:SetAtlas(self.tagAtlas)
Nenue@9 551 self.tagIcon:SetTexCoord(0,1,0,1)
Nenue@36 552 self.EliteBorder:SetShown(self.isElite and not self.filtered)
Nenue@30 553 --qprint('|cFF88FF00updated', questID, self.title, self.rewardType, (style.showNumber and self.itemNumber) or '')
Nenue@30 554 --print(' - subStyle:', (self.filtered == true), self.subStyle)
Nenue@9 555
Nenue@36 556 self.Overlay:SetShown(self:IsShown())
Nenue@36 557 self.Overlay:SetParent(self:GetParent())
Nenue@36 558 self.Overlay:SetFrameLevel(self:GetFrameLevel()+200)
Nenue@36 559 self.Overlay:SetAllPoints(self)
Nenue@36 560
Nenue@9 561
Nenue@9 562 self:UpdateSize()
Nenue@35 563
Nenue@33 564 self.isStale = nil
Nenue@35 565
Nenue@9 566 end
Nenue@9 567
Nenue@35 568 local cvar_check = {
Nenue@35 569 [REWARD_CASH] = 'worldQuestFilterGold',
Nenue@35 570 [REWARD_ARTIFACT_POWER] = 'worldQuestFilterArtifactPower',
Nenue@35 571 [REWARD_CURRENCY] = 'worldQuestFilterOrderResources',
Nenue@35 572 [REWARD_REAGENT]= 'worldQuestFilterProfessionMaterials',
Nenue@35 573 [REWARD_GEAR] = 'worldQuestFilterEquipment',
Nenue@35 574 }
Nenue@8 575
Nenue@33 576
Nenue@33 577 function QuestPOI:IsShowable ()
Nenue@36 578 local print = qprint
Nenue@33 579 local db = WorldPlan.db
Nenue@33 580 local qType = self.worldQuestType
Nenue@33 581 local rType = self.rewardType
Nenue@33 582 self.filtered = nil
Nenue@33 583 self.used = true
Nenue@33 584
Nenue@36 585 for filterKey, value in pairs(WorldPlan.UsedFilters) do
Nenue@36 586 print('|cFFFF4400', filterKey, self[filterKey])
Nenue@36 587 if self[filterKey] ~= value then
Nenue@36 588 self.filtered = true
Nenue@36 589 end
Nenue@36 590 end
Nenue@33 591
Nenue@33 592 self.questId = self:GetID()
Nenue@35 593 if self.rewardType then
Nenue@36 594 if cvar_check[self.rewardType] then
Nenue@36 595 if self.rewardType == REWARD_CASH then
Nenue@36 596 print('##', cvar_check[self.rewardType], GetCVarBool(cvar_check[self.rewardType]))
Nenue@36 597 end
Nenue@36 598 if not GetCVarBool(cvar_check[self.rewardType]) then
Nenue@35 599 self.filtered = true
Nenue@36 600
Nenue@35 601 end
Nenue@36 602
Nenue@35 603 end
Nenue@8 604 end
Nenue@33 605
Nenue@33 606 if not TQ_IsActive(self.questID) then
Nenue@33 607 self.used = nil
Nenue@33 608 elseif qType == LE_QUEST_TAG_TYPE_PROFESSION then
Nenue@33 609 if not (db.ShowAllProfessionQuests or (self.tradeskillLineIndex and GetProfessionInfo(self.tradeskillLineIndex))) then
Nenue@33 610 self.used = nil
Nenue@33 611 end
Nenue@33 612 end
Nenue@36 613 print(' |cFF'.. (((self.rewardType == REWARD_CASH) and 'FFFF00') or '0088FF') ..'IsShowable()|r ', cvar_check[self.rewardType], 'used:', self.used, 'filtered:', self.filtered, self.title)
Nenue@33 614 return self.used, self.filtered
Nenue@33 615 end
Nenue@33 616
Nenue@33 617 function QuestPOI:UpdateTimer (timeLeft, timeType)
Nenue@33 618 print('|cFF0088FFUpdatePinTimer()|r')
Nenue@33 619 end
Nenue@33 620
Nenue@33 621 --- Fixes icons upon size update
Nenue@36 622 function QuestPOI:UpdateSize ()
Nenue@33 623
Nenue@36 624 local style,subStyle = self:GetTypeInfo(self.rewardType)
Nenue@36 625 if self.filtered then
Nenue@36 626 subStyle = style.minimized
Nenue@36 627 end
Nenue@33 628 --qprint('|cFF00FF88'..self:GetName()..'|r:UpdateSize()', style, subStyle)
Nenue@33 629
Nenue@36 630 local icon = self.icon
Nenue@36 631 local iconBorder = self.RewardBorder
Nenue@36 632 local trackingBorder = self.HighlightBorder
Nenue@36 633 local tag = self.tagIcon
Nenue@33 634
Nenue@36 635 local iconWidth = subStyle.iconWidth
Nenue@36 636 local borderWidth = iconWidth + (subStyle.borderWidth * 2)
Nenue@36 637 local highlightWidth = borderWidth + (subStyle.highlightWidth * 2)
Nenue@33 638
Nenue@36 639 local iconTexture = self.itemTexture
Nenue@33 640
Nenue@36 641 self:SetSize(iconWidth, iconWidth)
Nenue@36 642 icon:SetSize(iconWidth, iconWidth)
Nenue@36 643 iconBorder:SetSize(borderWidth, borderWidth)
Nenue@36 644 trackingBorder:SetSize(highlightWidth, highlightWidth)
Nenue@33 645
Nenue@36 646
Nenue@36 647 iconBorder:SetPoint('CENTER', (style.x or 0), (style.y or 0))
Nenue@36 648 trackingBorder:SetPoint('CENTER', (style.x or 0), (style.y or 0))
Nenue@36 649
Nenue@36 650
Nenue@36 651 if style.hasNumeric then
Nenue@36 652 self.count:SetTextColor(unpack(style.numberRGB))
Nenue@36 653 if subStyle.numberFontObject then
Nenue@36 654 --wqprint('change font', _G[subStyle.numberFontObject]:GetName())
Nenue@36 655 self.count:SetFontObject(_G[subStyle.numberFontObject])
Nenue@36 656 end
Nenue@33 657 end
Nenue@33 658
Nenue@36 659 self.count:SetShown((subStyle.showNumber and self.itemNumber) and style.hasNumeric)
Nenue@33 660
Nenue@36 661 --[[
Nenue@33 662 if self.tagSize then
Nenue@33 663 tag:Show()
Nenue@33 664 tag:ClearAllPoints()
Nenue@33 665 tag:SetPoint('BOTTOMRIGHT', self, 'BOTTOMRIGHT', borderWidth, -borderWidth)
Nenue@33 666 else
Nenue@33 667 tag:Hide()
Nenue@33 668 end
Nenue@33 669
Nenue@36 670 if self.NoIcon then
Nenue@36 671 self.icon:Hide()
Nenue@36 672 else
Nenue@36 673 self.icon:Show()
Nenue@36 674 if style.rewardMask then
Nenue@36 675 icon:SetMask(rewardMask)
Nenue@36 676 else
Nenue@36 677 icon:SetMask(iconTexture)
Nenue@36 678 end
Nenue@36 679 if style.pinMask then
Nenue@36 680 iconBorder:Show()
Nenue@36 681 trackingBorder:Show()
Nenue@36 682 iconBorder:SetMask(pinMask)
Nenue@36 683 trackingBorder:SetMask(pinMask)
Nenue@36 684 else
Nenue@36 685 iconBorder:Hide()
Nenue@36 686 trackingBorder:Hide()
Nenue@36 687 end
Nenue@36 688 end
Nenue@36 689
Nenue@36 690
Nenue@36 691 icon:SetTexture(iconTexture)
Nenue@35 692 iconBorder:SetTexture(iconBorder:GetTexture())
Nenue@35 693 trackingBorder:SetTexture(trackingBorder:GetTexture())
Nenue@36 694 --]]
Nenue@36 695 self.currentWidth = subStyle.iconWidth
Nenue@36 696 self.borderWidth = subStyle.borderWidth
Nenue@36 697 self.highlightWidth = subStyle.highlightWidth
Nenue@36 698 self.tagSize = subStyle.TagSize
Nenue@36 699 self.maxAlertLevel = subStyle.maxAlertLevel
Nenue@36 700 self.NoIcon = subStyle.NoIcon
Nenue@36 701 self.style = style
Nenue@36 702 self.subStyle = subStyle
Nenue@36 703 if self.rewardType == REWARD_CASH then
Nenue@36 704 qprint('using mask:', pinMask or iconTexture, rewardMask or iconTexture, self.used, self.filtered)
Nenue@36 705 end
Nenue@36 706
Nenue@7 707 end