comparison 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
comparison
equal deleted inserted replaced
32:e8679ecb48d8 33:be4db60219ca
2 -- QuestPOI.lua 2 -- QuestPOI.lua
3 -- Created: 10/1/2016 7:21 PM 3 -- Created: 10/1/2016 7:21 PM
4 -- %file-revision% 4 -- %file-revision%
5 -- 5 --
6 6
7 WorldPlanPOIMixin = {}
7 local TQ_GetQuestInfoByQuestID = C_TaskQuest.GetQuestInfoByQuestID -- Return the name of a quest with a given ID 8 local TQ_GetQuestInfoByQuestID = C_TaskQuest.GetQuestInfoByQuestID -- Return the name of a quest with a given ID
8 local TQ_GetQuestLocation = C_TaskQuest.GetQuestLocation 9 local TQ_GetQuestLocation = C_TaskQuest.GetQuestLocation
9 local TQ_GetQuestTimeLeftMinutes = C_TaskQuest.GetQuestTimeLeftMinutes 10 local TQ_GetQuestTimeLeftMinutes = C_TaskQuest.GetQuestTimeLeftMinutes
10 local TQ_IsActive = C_TaskQuest.IsActive 11 local TQ_IsActive = C_TaskQuest.IsActive
11 local TQ_RequestPreloadRewardData = C_TaskQuest.RequestPreloadRewardData 12 local TQ_RequestPreloadRewardData = C_TaskQuest.RequestPreloadRewardData
12 local QuestPOIGetIconInfo, WorldMapPOIFrame = QuestPOIGetIconInfo, WorldMapPOIFrame 13 local QuestPOIGetIconInfo, WorldMapPOIFrame = QuestPOIGetIconInfo, WorldMapPOIFrame
13 14 local WorldMap_DoesWorldQuestInfoPassFilters = WorldMap_DoesWorldQuestInfoPassFilters
14 local print = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or function() end 15 local QuestMapFrame_IsQuestWorldQuest = QuestMapFrame_IsQuestWorldQuest
16 local GameTooltip = GameTooltip
17 local GetItemIcon = GetItemIcon
18
19 local print = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or function() end
15 local qprint = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or function() end 20 local qprint = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or function() end
21 local wprint = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or function() end
16 local wqprint = DEVIAN_WORKSPACE and function(...) _G.print('WorldQuests', ...) end or function() end 22 local wqprint = DEVIAN_WORKSPACE and function(...) _G.print('WorldQuests', ...) end or function() end
17 local iprint = DEVIAN_WORKSPACE and function(...) _G.print('ItemScan', ...) end or function() end 23 local iprint = DEVIAN_WORKSPACE and function(...) _G.print('ItemScan', ...) end or function() end
18 local QuestPOI = WorldPlanPOIMixin 24 local QuestPOI = WorldPlanPOIMixin
19 25
20 local ICON_UNKNOWN = "Interface\\ICONS\\inv_misc_questionmark" 26 local ICON_UNKNOWN = "Interface\\ICONS\\inv_misc_questionmark"
75 } 81 }
76 } 82 }
77 83
78 -- Pin color/display variables 84 -- Pin color/display variables
79 85
80 local familiars = { 86 local familiars = {
81 [42159] = {npc = 106552, name = 'Nightwatcher Merayl'}, 87 [42159] = {npc = 106552, name = 'Nightwatcher Merayl'},
82 [40277] = {npc = 97804, name = 'Tiffany Nelson'}, 88 [40277] = {npc = 97804, name = 'Tiffany Nelson'},
83 [40298] = {npc = 99182, name = 'Sir Galveston'}, 89 [40298] = {npc = 99182, name = 'Sir Galveston'},
84 [40282] = {npc= 99150, name = 'Grixis Tinypop'}, 90 [40282] = {npc= 99150, name = 'Grixis Tinypop'},
85 [40278] = {npc = 98270, name = 'Robert Craig'}, 91 [40278] = {npc = 98270, name = 'Robert Craig'},
86 [48195] = {npc = 105250, name = 'Aulier'}, 92 [48195] = {npc = 105250, name = 'Aulier'},
87 [41990] = {npc = 105674, name = 'Varenne'}, 93 [41990] = {npc = 105674, name = 'Varenne'},
88 [41860] = {npc = 104970, name = 'Xorvasc'}, 94 [41860] = {npc = 104970, name = 'Xorvasc'},
89 [40299] = {npc = 99210, name = 'Bodhi Sunwayver'}, 95 [40299] = {npc = 99210, name = 'Bodhi Sunwayver'},
90 [42442] = {npc = 107489, name = 'Amalia'}, 96 [42442] = {npc = 107489, name = 'Amalia'},
91 [40280] = {npc = 99077, name = 'Bredda Tenderhide'}, 97 [40280] = {npc = 99077, name = 'Bredda Tenderhide'},
92 [41687] = {npc = 104553, name = 'Odrogg'}, 98 [41687] = {npc = 104553, name = 'Odrogg'},
93 [41944] = {npc = 105455, name = 'Trapper Jarrun'}, 99 [41944] = {npc = 105455, name = 'Trapper Jarrun'},
94 [40337] = {npc = 97709, name = 'Master Tamer Flummox'}, 100 [40337] = {npc = 97709, name = 'Master Tamer Flummox'},
95 [40279] = {npc = 99035, name = 'Durian Strongfruit'} 101 [40279] = {npc = 99035, name = 'Durian Strongfruit'}
96 } 102 }
97 local familiars_id = 9696 103 local familiars_id = 9696
104
105
106 -- update a masked texture without messing up its blending mask
98 107
99 108
100 -- update a masked texture without messing up its blending mask 109 -- update a masked texture without messing up its blending mask
101 local SetMaskedTexture = function(region, file, mask) 110 local SetMaskedTexture = function(region, file, mask)
102 mask = mask or POI_BORDER_MASK 111 mask = mask or "Interface\\Minimap\\UI-Minimap-Background"
103 region:SetMask(nil) 112 region:SetMask(nil)
104 region:SetTexture(file) 113 region:SetTexture(file)
105 region:SetMask(mask) 114 region:SetMask(mask)
106 end 115 end
107 116
240 end 249 end
241 250
242 251
243 local questID = self:GetID() 252 local questID = self:GetID()
244 local questTitle, rewardIcon, rewardName, rewardCount, rewardStyle, rewardType, itemID, quantity, quality, _ 253 local questTitle, rewardIcon, rewardName, rewardCount, rewardStyle, rewardType, itemID, quantity, quality, _
245 local hasUpdate, isPending = (self.hasUpdate or self.isNew), self.isPending 254 local hasUpdate, isPending = (self.isStale or self.isNew), self.isPending
246 255
247 256
248 if not HaveQuestData(questID) then 257 if not HaveQuestData(questID) then
249 TQ_RequestPreloadRewardData(questID) 258 TQ_RequestPreloadRewardData(questID)
250 isPending = true 259 isPending = true
315 end 324 end
316 325
317 self.title = questTitle or "|cFFFF0000Retrieving..." 326 self.title = questTitle or "|cFFFF0000Retrieving..."
318 self.itemTexture = rewardIcon or self.itemTexture 327 self.itemTexture = rewardIcon or self.itemTexture
319 self.itemName = rewardName or self.itemName 328 self.itemName = rewardName or self.itemName
320 self.hasUpdate = hasUpdate 329 self.isStale = hasUpdate
321 self.isPending = isPending 330 self.isPending = isPending
322 331
323 332
324 qprint(' |cFF00FFFF'..questID..'|r hasUpdate:', hasUpdate, 'isPending:', isPending) 333 qprint(' |cFF00FFFF'..questID..'|r hasUpdate:', hasUpdate, 'isPending:', isPending)
325 qprint(' ', 'rewardType:', self.rewardType, 'tag:', self.tagID) 334 qprint(' ', 'rewardType:', self.rewardType, 'tag:', self.tagID)
336 end 345 end
337 346
338 function WorldPlanPOIMixin:ShowNew() 347 function WorldPlanPOIMixin:ShowNew()
339 self:SetShown(true) 348 self:SetShown(true)
340 self.isNew = nil 349 self.isNew = nil
341 self.hasUpdate = true 350 self.isStale = true
342 self.FadeIn:Play() 351 self.FadeIn:Play()
343 end 352 end
344 353
345 function WorldPlanPOIMixin:OnShow () 354 function WorldPlanPOIMixin:OnShow ()
346 qprint('|cFFFFFF00["'..tostring(self.title)..'"]|r:OnShow() update:', self.hasUpdate, 'new:', self.isNew, 'animation:', self.isAnimating) 355 qprint('|cFFFFFF00["'..tostring(self.title)..'"]|r:OnShow() update:', self.isStale, 'new:', self.isNew, 'animation:', self.isAnimating)
347 -- pop this on principle 356 -- pop this on principle
348 if self.hasUpdate then 357 if self.isStale then
349 self:Refresh() 358 self:Refresh()
350 end 359 end
351 360
352 end 361 end
353 function WorldPlanPOIMixin:OnHide() 362 function WorldPlanPOIMixin:OnHide()
354 qprint('|cFFFFFF00["'..tostring(self.title)..'"]|r:OnHide()') 363 qprint('|cFFFFFF00["'..tostring(self.title)..'"]|r:OnHide()')
355 end 364 end
356 365
357 function WorldPlanPOIMixin:SetAnchor(frame, mapID, mapWidth, mapHeight) 366 function WorldPlanPOIMixin:SetAnchor(frame, mapID, mapWidth, mapHeight)
358 qprint(' |cFF00FF00'..self:GetName()..':SetAnchor()|r', self.questID, mapID, mapWidth) 367 --qprint(' |cFF00FF00'..self:GetName()..':SetAnchor()|r', self.questID, mapID, mapWidth)
359 self:ClearAllPoints() 368 self:ClearAllPoints()
360 local dX, dY = TQ_GetQuestLocation(self.questID) 369 local dX, dY = TQ_GetQuestLocation(self.questID)
361 if not dX or dX == 0 then 370 if not dX or dX == 0 then
362 local _, x, y = QuestPOIGetIconInfo(self.questID) 371 local _, x, y = QuestPOIGetIconInfo(self.questID)
363 if x and floor(x) ~= 0 then 372 if x and floor(x) ~= 0 then
386 self.subStyle = WorldPlan.db.defaultPinStyle.continent 395 self.subStyle = WorldPlan.db.defaultPinStyle.continent
387 end 396 end
388 397
389 function WorldPlanPOIMixin:OnEvent(event, ...) 398 function WorldPlanPOIMixin:OnEvent(event, ...)
390 if event == 'SUPER_TRACKED_QUEST_CHANGED' then 399 if event == 'SUPER_TRACKED_QUEST_CHANGED' then
391 self.hasUpdate = true 400 self.isStale = true
392 end 401 end
393 end 402 end
394 403
395 404
396 local PIN_UPDATE_DELAY = .016 405 local PIN_UPDATE_DELAY = .016
397 local TOP_PIN_ID 406 local TOP_PIN_ID
398 function WorldPlanPOIMixin:OnUpdate (sinceLast) 407 function WorldPlanPOIMixin:OnUpdate (sinceLast)
399 408
400 if self.hasUpdate then 409 if self.isStale then
401 wqprint('|cFFFFFF00push poi update') 410 print('|cFFFFFF00push poi update')
402 self:Refresh() 411 self:Refresh()
403 return 412 return
404 end 413 end
405 -- control update check intervals 414 -- control update check intervals
406 self.throttle = (self.throttle or PIN_UPDATE_DELAY) - sinceLast 415 self.throttle = (self.throttle or PIN_UPDATE_DELAY) - sinceLast
455 464
456 465
457 466
458 function WorldPlanPOIMixin:Refresh () 467 function WorldPlanPOIMixin:Refresh ()
459 local db = WorldPlan.db 468 local db = WorldPlan.db
460 local print = wqprint
461 print('|cFF00FF88'..self:GetName()..'|r:Refresh()') 469 print('|cFF00FF88'..self:GetName()..'|r:Refresh()')
462 470
463 471
464 472
465 local questID = self:GetID() 473 local questID = self:GetID()
490 if self.itemName then 498 if self.itemName then
491 499
492 500
493 if self.hasNumeric then 501 if self.hasNumeric then
494 if subStyle.numberFontObject then 502 if subStyle.numberFontObject then
495 wqprint('change font', _G[subStyle.numberFontObject]:GetName()) 503 --wqprint('change font', _G[subStyle.numberFontObject]:GetName())
496 self.count:SetFontObject(_G[subStyle.numberFontObject]) 504 self.count:SetFontObject(_G[subStyle.numberFontObject])
497 end 505 end
498 wqprint('filtered:', self.filtered, 'showNumber:', self.showNumber) 506 --wqprint('filtered:', self.filtered, 'showNumber:', self.showNumber)
499 507
500 self.count:SetShown(self.showNumber) 508 self.count:SetShown(self.showNumber)
501 self.count:SetText(self.itemNumber) 509 self.count:SetText(self.itemNumber)
502 self.count:SetTextColor(unpack(self.numberRGB)) 510 self.count:SetTextColor(unpack(self.numberRGB))
503 else 511 else
538 --qprint('|cFF88FF00updated', questID, self.title, self.rewardType, (style.showNumber and self.itemNumber) or '') 546 --qprint('|cFF88FF00updated', questID, self.title, self.rewardType, (style.showNumber and self.itemNumber) or '')
539 --print(' - subStyle:', (self.filtered == true), self.subStyle) 547 --print(' - subStyle:', (self.filtered == true), self.subStyle)
540 548
541 549
542 self:UpdateSize() 550 self:UpdateSize()
543 self.hasUpdate = nil 551 self.isStale = nil
544 end 552 end
545 553
546 function WorldPlanFilterPinMixin:OnEnter () 554
547 local filter = WorldPlan.FilterOptions[self:GetID()] 555
548 local mapID = GetCurrentMapAreaID() 556
549 local quests = (mapID == WorldPlan.BrokenIsleID) and WorldPlan.QuestsByID or WorldPlan.QuestsByZone[mapID] 557 function QuestPOI:IsShowable ()
550 if quests then 558 local print = wqprint
551 GameTooltip:SetOwner(self, 'ANCHOR_RIGHT') 559 local db = WorldPlan.db
552 GameTooltip:AddLine(filter.label) 560 local qType = self.worldQuestType
553 local filterKey = self.filterKey 561 local rType = self.rewardType
554 local filterValue = self.filterValue 562 self.filtered = nil
555 if filterKey then 563 self.used = true
556 for questID, pin in pairs(quests) do 564
557 if pin.used and not pin.filtered then 565
558 if pin[filterKey] == filterValue then 566 self.questId = self:GetID()
559 local style = pin.style or WorldPlan.FilterStyle 567 if not (WorldMap_DoesWorldQuestInfoPassFilters(self, false, true)) then
560 568 self.filtered = true
561 if familiars[questID] then 569 end
562 GameTooltip:AddLine(pin.title,0,1,0) 570
563 else 571 for filterKey, value in pairs(WorldPlan.UsedFilters) do
564 GameTooltip:AddLine(pin.title,1,1,1) 572 if self[filterKey] ~= value then
565 end 573 self.filtered = true
566 574 end
567 end 575 end
568 end 576
569 end 577 if not TQ_IsActive(self.questID) then
570 else 578 self.used = nil
571 GameTooltip:AddLine('Reset all filters') 579 elseif qType == LE_QUEST_TAG_TYPE_PROFESSION then
572 end 580 if not (db.ShowAllProfessionQuests or (self.tradeskillLineIndex and GetProfessionInfo(self.tradeskillLineIndex))) then
573 GameTooltip:Show() 581 self.used = nil
574 end 582 end
575 end 583 end
584 print(' |cFFFF4400IsShowable()|r', self.used, self.filtered, self.title)
585 return self.used, self.filtered
586 end
587
588 function QuestPOI:UpdateTimer (timeLeft, timeType)
589 print('|cFF0088FFUpdatePinTimer()|r')
590 end
591
592 --- Fixes icons upon size update
593 function QuestPOI:UpdateSize (style, subStyle)
594 style = style or self.style
595 subStyle = subStyle or self.subStyle
596
597 --qprint('|cFF00FF88'..self:GetName()..'|r:UpdateSize()', style, subStyle)
598
599 self.currentWidth = subStyle.PinSize
600 self.borderSize = subStyle.Border
601 self.trackingBorderSize = subStyle.TrackingBorder
602 self.tagSize = subStyle.TagSize
603 self.TimeleftStage = subStyle.TimeleftStage
604 self.NoIcon = subStyle.NoIcon
605
606
607 self:SetSize(self.currentWidth, self.currentWidth)
608
609 local icon = self.icon
610 local iconBorder = self.iconBorder
611 local trackingBorder = self.supertrackBorder
612 local tag = self.tagIcon
613 local pinMask = style.pinMask
614 local rewardMask = style.rewardMask
615
616 if self.NoIcon then
617 self.icon:Hide()
618 else
619 self.icon:Show()
620 icon:SetMask(nil)
621 icon:SetMask(rewardMask)
622 icon:SetTexture(self.icon:GetTexture())
623 end
624 iconBorder:SetMask(nil)
625 trackingBorder:SetMask(nil)
626
627
628 local borderWidth = self.borderSize
629 local trackingWidth = self.trackingBorderSize
630
631 iconBorder:ClearAllPoints()
632 iconBorder:SetPoint('BOTTOMLEFT', self, 'BOTTOMLEFT', -borderWidth + (style.x or 0), -borderWidth + (style.y or 0))
633 iconBorder:SetPoint('TOPRIGHT', self, 'TOPRIGHT', borderWidth + (style.x or 0), borderWidth + (style.y or 0))
634
635 trackingBorder:ClearAllPoints()
636 trackingBorder:SetPoint('BOTTOMLEFT', iconBorder, 'BOTTOMLEFT', -trackingWidth, -trackingWidth)
637 trackingBorder:SetPoint('TOPRIGHT', iconBorder, 'TOPRIGHT', trackingWidth, trackingWidth)
638
639 if self.tagSize then
640 tag:Show()
641 tag:ClearAllPoints()
642 tag:SetPoint('BOTTOMRIGHT', self, 'BOTTOMRIGHT', borderWidth, -borderWidth)
643 else
644 tag:Hide()
645 end
646
647 --qprint('using mask:', mask, self.name )
648 iconBorder:SetMask(pinMask)
649 trackingBorder:SetMask(pinMask)
650 end