comparison QuestPOI.lua @ 75:78d78dc77822

update conditional tweaks
author Nenue
date Mon, 10 Apr 2017 07:13:29 -0400
parents 2ba11b25aa7f
children fadf00b437fb
comparison
equal deleted inserted replaced
74:2ba11b25aa7f 75:78d78dc77822
43 local pinBaseIndex = 1500 43 local pinBaseIndex = 1500
44 local overlayBaseIndex = 1580 44 local overlayBaseIndex = 1580
45 local previousHighlight 45 local previousHighlight
46 46
47 local DATA_DEBUG = false 47 local DATA_DEBUG = false
48 local PIN_REFRESH_DELAY = .5 48 local PIN_REFRESH_DELAY = 1
49 local PIN_REQUEST_DELAY = .1 49 local PIN_REQUEST_DELAY = .2
50 local ICON_UNKNOWN = "Interface\\ICONS\\inv_misc_questionmark" 50 local ICON_UNKNOWN = "Interface\\ICONS\\inv_misc_questionmark"
51 local ICON_MONEY = "Interface\\Buttons\\UI-GroupLoot-Coin-Up" 51 local ICON_MONEY = "Interface\\Buttons\\UI-GroupLoot-Coin-Up"
52 52
53 local WORLD_QUEST_BORDER = "Interface\\UNITPOWERBARALT\\Generic1Target_Circular_Frame" 53 local WORLD_QUEST_BORDER = "Interface\\UNITPOWERBARALT\\Generic1Target_Circular_Frame"
54 local PENDING_BORDER = "Interface\\BUTTONS\\YELLOWORANGE64" 54 local PENDING_BORDER = "Interface\\BUTTONS\\YELLOWORANGE64"
336 WorldMapTooltip:Hide(); 336 WorldMapTooltip:Hide();
337 end 337 end
338 338
339 -- attempt to pull pin data 339 -- attempt to pull pin data
340 function QuestPOI:GetData () 340 function QuestPOI:GetData ()
341 dprint('|cFF00FF88'..self:GetID()..':GetData()|r') 341 --dprint('|cFF00FF88'..self:GetID()..':GetData()|r')
342 local questID = self.questID 342 local questID = self.questID
343 if not questID then 343 if not questID then
344 dprint('|cFFFF4400bad pin|r', self:GetName()) 344 --dprint('|cFFFF4400bad pin|r', self:GetName())
345 return nil 345 return nil
346 end 346 end
347 347
348 local questTitle, factionID, capped = TQ_GetQuestInfoByQuestID(questID) 348 local questTitle, factionID, capped = TQ_GetQuestInfoByQuestID(questID)
349 -- if the title is nil, then wait and try later 349 -- if the title is nil, then wait and try later
350 if not questTitle then 350 if not questTitle then
351 dprint('|cFFBB8844dataLoaded|r = false|cFF00FFFF', self.questId) 351 --dprint('|cFFBB8844dataLoaded|r = false|cFF00FFFF', self.questId)
352 return false 352 return false
353 else 353 else
354 self.title, self.factionID, self.capped = questTitle, factionID, capped 354 self.title, self.factionID, self.capped = questTitle, factionID, capped
355 dprint(questTitle, factionID, capped) 355 print(questTitle, factionID, capped)
356 -- set tag details 356 -- set tag details
357 local worldQuestType 357 local worldQuestType
358 self.tagID, self.tagName, worldQuestType, self.rarity, self.isElite, self.tradeskillLineIndex = GetQuestTagInfo(questID); 358 self.tagID, self.tagName, worldQuestType, self.rarity, self.isElite, self.tradeskillLineIndex = GetQuestTagInfo(questID);
359 local tagAtlas 359 local tagAtlas
360 if worldQuestType == LE_QUEST_TAG_TYPE_PET_BATTLE then 360 if worldQuestType == LE_QUEST_TAG_TYPE_PET_BATTLE then
364 elseif worldQuestType == LE_QUEST_TAG_TYPE_PROFESSION then 364 elseif worldQuestType == LE_QUEST_TAG_TYPE_PROFESSION then
365 self.isKnownProfession = nil 365 self.isKnownProfession = nil
366 local id = self.tradeskillLineIndex and select(7, GetProfessionInfo(self.tradeskillLineIndex)) 366 local id = self.tradeskillLineIndex and select(7, GetProfessionInfo(self.tradeskillLineIndex))
367 if id then 367 if id then
368 self.isKnownProfession = true 368 self.isKnownProfession = true
369 qprint('profession' , self.title, id) 369 --qprint('profession' , self.title, id)
370 tagAtlas = WORLD_QUEST_ICONS_BY_PROFESSION[id] 370 tagAtlas = WORLD_QUEST_ICONS_BY_PROFESSION[id]
371 end 371 end
372 elseif worldQuestType == LE_QUEST_TAG_TYPE_DUNGEON then 372 elseif worldQuestType == LE_QUEST_TAG_TYPE_DUNGEON then
373 tagAtlas = "worldquest-icon-dungeon" 373 tagAtlas = "worldquest-icon-dungeon"
374 end 374 end
375 self.worldQuestType = worldQuestType 375 self.worldQuestType = worldQuestType
376 self.tagAtlas = tagAtlas 376 self.tagAtlas = tagAtlas
377 377
378 local dataLoaded, rewardType, itemName, itemTexture, itemNumber, quality, xpType, xpName, xpIcon, xpCount = self:UpdateRewards() 378 local dataLoaded, rewardType, itemName, itemTexture, itemNumber, quality, xpType, xpName, xpIcon, xpCount = self:UpdateRewards()
379 dprint('|cFFBB8844 dataLoaded|r =', dataLoaded, rewardType, itemName, itemTexture, itemNumber, quality) 379 --dprint('|cFFBB8844 dataLoaded|r =', dataLoaded, rewardType, itemName, itemTexture, itemNumber, quality)
380 if dataLoaded then 380 if dataLoaded then
381 self.rewardType = rewardType 381 self.rewardType = rewardType
382 self.itemName = itemName 382 self.itemName = itemName
383 self.itemTexture = itemTexture 383 self.itemTexture = itemTexture
384 self.itemNumber = itemNumber 384 self.itemNumber = itemNumber
424 if artifactXP > 0 then 424 if artifactXP > 0 then
425 rewardAP = artifactXP 425 rewardAP = artifactXP
426 rewardIcon = "Interface\\ICONS\\inv_7xp_inscription_talenttome01" 426 rewardIcon = "Interface\\ICONS\\inv_7xp_inscription_talenttome01"
427 rewardCount = artifactXP 427 rewardCount = artifactXP
428 rewardType = REWARD_ARTIFACT_POWER 428 rewardType = REWARD_ARTIFACT_POWER
429 qprint(' artifactXP', artifactXP) 429 --dprint(' artifactXP', artifactXP)
430 foundPrimary = true 430 foundPrimary = true
431 end 431 end
432 432
433 local numQuestCurrencies = GetNumQuestLogRewardCurrencies(questID); 433 local numQuestCurrencies = GetNumQuestLogRewardCurrencies(questID);
434 for i = 1, numQuestCurrencies do 434 for i = 1, numQuestCurrencies do
439 texture = texture, 439 texture = texture,
440 numItems = numItems, 440 numItems = numItems,
441 text = text 441 text = text
442 }) 442 })
443 443
444 qprint(' currency', i, currencyID, name, " |T"..tostring(texture)..":12:12|t") 444 --dprint(' currency', i, currencyID, name, " |T"..tostring(texture)..":12:12|t")
445 if currencyID == ID_RESOURCES then 445 if currencyID == ID_RESOURCES then
446 rewardIcon = texture 446 rewardIcon = texture
447 rewardCount = numItems 447 rewardCount = numItems
448 rewardName = name 448 rewardName = name
449 rewardType = REWARD_CURRENCY 449 rewardType = REWARD_CURRENCY
492 local line = _G['WorldPlanTooltipTextLeft' .. i] 492 local line = _G['WorldPlanTooltipTextLeft' .. i]
493 local text = line and line:GetText() 493 local text = line and line:GetText()
494 local ap = text and text:gsub(',', ''):gsub(' million', '000000'):match('(%d+) '..ARTIFACT_POWER) 494 local ap = text and text:gsub(',', ''):gsub(' million', '000000'):match('(%d+) '..ARTIFACT_POWER)
495 if ap then 495 if ap then
496 rewardCount = tonumber(ap) 496 rewardCount = tonumber(ap)
497 print(ap) 497 --dprint(ap)
498 end 498 end
499 499
500 end 500 end
501 501
502 if WorldPlanTooltipTextLeft2 then 502 if WorldPlanTooltipTextLeft2 then
503 local text = WorldPlanTooltipTextLeft2:GetText() 503 local text = WorldPlanTooltipTextLeft2:GetText()
504 end 504 end
505 505
506 print('is an AP token') 506 --dprint('is an AP token')
507 elseif classID == LE_ITEM_CLASS_TRADEGOODS then 507 elseif classID == LE_ITEM_CLASS_TRADEGOODS then
508 rewardType = REWARD_REAGENT 508 rewardType = REWARD_REAGENT
509 rewardIcon = texture 509 rewardIcon = texture
510 rewardName = name 510 rewardName = name
511 rewardCount = numItems 511 rewardCount = numItems
512 foundPrimary = true 512 foundPrimary = true
513 end 513 end
514 514
515 515
516 qprint(' reward', i, name, " |T"..tostring(texture)..":12:12|t", quality, isUsable, itemID) 516 --dprint(' reward', i, name, " |T"..tostring(texture)..":12:12|t", quality, isUsable, itemID)
517 tinsert(rewardItems, { 517 tinsert(rewardItems, {
518 name = name, 518 name = name,
519 texture = texture, 519 texture = texture,
520 numItems = numItems, 520 numItems = numItems,
521 quality = quality, 521 quality = quality,
522 isUsable = isUsable 522 isUsable = isUsable
523 }) 523 })
524 if not foundPrimary then 524 if not foundPrimary then
525 print(' -updating primary') 525 --print(' -updating primary')
526 rewardType = REWARD_GEAR 526 rewardType = REWARD_GEAR
527 527
528 rewardIcon = texture 528 rewardIcon = texture
529 rewardName = name 529 rewardName = name
530 rewardCount = numItems 530 rewardCount = numItems
533 end 533 end
534 534
535 end 535 end
536 end 536 end
537 537
538 qprint(' '..self.questID..':|cFFFFFF00SetRewardInfo():', numQuestRewards, rewardType) 538 --dprint(' '..self.questID..':|cFFFFFF00UpdateRewards():', numQuestRewards, rewardType)
539 qprint(' ', tostring(self.title), " |T"..tostring(self.itemTexture)..":12:12|t", tostring(self.itemName)) 539 --dprint(' ', tostring(self.title), " |T"..tostring(self.itemTexture)..":12:12|t", tostring(self.itemName))
540 540
541 if (self.itemNumber ~= rewardCount) or (self.rewardType ~= rewardType) or (self.itemName ~= rewardName) or (self.itemTexture ~= rewardIcon) then 541 if (self.itemNumber ~= rewardCount) or (self.rewardType ~= rewardType) or (self.itemName ~= rewardName) or (self.itemTexture ~= rewardIcon) then
542 if DATA_DEBUG and (self.debugTimer <= 0) then 542 if DATA_DEBUG and (self.debugTimer <= 0) then
543 return false 543 return false
544 end 544 end
569 end 569 end
570 end 570 end
571 571
572 -- run from OnShow if .isNew is set 572 -- run from OnShow if .isNew is set
573 573
574 function QuestPOI:StartFade() 574 function QuestPOI:OnAnimStart()
575 if not self.isAnimating then 575 --qprint('|cFFFFFF00OnAnimStart(|r'..self:GetID()..'|cFFFFFF00)|r', self.fadeEvent)
576 qprint('|cFFFFFF00clearing new status') 576 self.isAnimating = true
577 self.isNew = nil
578 end
579
580 function QuestPOI:TryToFade(event)
581 if self.FadeIn:IsPlaying() then
582 --qprint('|cFFFF4400TryToFade('..self:GetID()..'|cFFFF4400)|r stopping because already in progress')
583 return
584 end
585
586 self.fadeEvent = event
587 if self.dataLoaded then
588 --qprint('|cFFFFFF00TryToFade('..self:GetID()..'|cFFFFFF00)|r', event)
577 self:SetAlpha(0) 589 self:SetAlpha(0)
578 if self.dataLoaded then 590 self:Refresh(event)
579 self:Refresh('POI_ISNEW') 591 self.FadeIn.FadeIn:SetToAlpha(db.PinAlpha)
580 self.FadeIn.FadeIn:SetToAlpha(db.PinAlpha) 592 self.isStale = true
581 self.PendingFade.FadeIn:SetToAlpha(db.PinAlpha) 593 self.FadeIn:Play()
582 self.PendingFade.FadeOut:SetFromAlpha(db.PinAlpha) 594 else
583 595
584 self.isAnimating = true 596 --qprint('|cFFFF4400TryToFade('..self:GetID()..'|cFFFF4400)|r stopping because not loaded')
585 self.isNew = nil 597 end
586 self.isStale = true 598 end
587 self.FadeIn:Play() 599
588 end 600 function QuestPOI:OnAnimStop()
589 end
590 end
591
592 function QuestPOI:EndFade()
593 self.isAnimating = nil 601 self.isAnimating = nil
594 self:SetAlpha(db.PinAlpha) 602 self:SetAlpha(db.PinAlpha)
595 end 603 end
596 604
597 function QuestPOI:OnShow () 605 function QuestPOI:OnShow ()
598 606
599 if self.isNew then 607 if self.isNew then
600 self:StartFade() 608 self:TryToFade('POI_ONSHOW_NEW')
601 else 609 else
602 if not self.isAnimating then 610 if not self.isAnimating then
603 print('|cFF00FF00Alpha correction') 611 --print('|cFF00FF00Alpha correction')
604 self:SetAlpha(db.PinAlpha) -- fix stuck alpha 612 self:SetAlpha(db.PinAlpha) -- fix stuck alpha
605 end 613 end
606 if self.isStale then 614 if self.isStale then
607 print('|cFF00FF00refresh on show') 615 --print('|cFF00FF00refresh on show')
608 self:Refresh('POI_SCRIPT') 616 self:Refresh('POI_ONSHOW_STALE')
609 end 617 end
610 end 618 end
611 self:ShowFrames() 619 self:ShowFrames()
612 end 620 end
613 621
623 self.hideReason = nil 631 self.hideReason = nil
624 end 632 end
625 633
626 -- Applies position and sizing parameters to the pin data 634 -- Applies position and sizing parameters to the pin data
627 function QuestPOI:SetAnchor(owner, dX, dY, mapWidth, mapHeight, scaleFactor) 635 function QuestPOI:SetAnchor(owner, dX, dY, mapWidth, mapHeight, scaleFactor)
628 dprint(self:GetName()..':SetAnchor()', owner, dX, dY, scaleFactor, self.filtered, self.used) 636 --dprint(self:GetName()..':SetAnchor()', owner, dX, dY, scaleFactor, self.filtered, self.used)
629 if not self.used then 637 if not self.used then
630 self.hideReason = 'SetAnchor() on an unused frame.' 638 self.hideReason = 'SetAnchor() on an unused frame.'
631 self:HideFrames() 639 self:HideFrames()
632 return 640 return
633 end 641 end
634 642
643
635 if owner then 644 if owner then
636 self:SetParent(owner) 645 self:SetParent(owner)
637 self.Overlay:SetParent(owner) 646 self.Overlay:SetParent(owner)
638 self.isStale = true 647 self.isStale = true
639 else 648 else
640 owner = self:GetParent() 649 owner = self:GetParent()
641 end 650 end
642
643 self:SetFrameLevel(pinBaseIndex + self:GetID())
644 self.Overlay:SetFrameLevel(overlayBaseIndex + self:GetID())
645 651
646 652
647 if scaleFactor then 653 if scaleFactor then
648 --print('scaleFactor') 654 --print('scaleFactor')
649 self:SetScale(scaleFactor) 655 self:SetScale(scaleFactor)
670 end 676 end
671 677
672 -- Show/Hide the text overlays associated with the quest pin; they aren't hierarchically linked 678 -- Show/Hide the text overlays associated with the quest pin; they aren't hierarchically linked
673 function QuestPOI:ShowFrames() 679 function QuestPOI:ShowFrames()
674 if not self:IsShown() then 680 if not self:IsShown() then
675 print('|cFFFFFF00' ..self:GetName()..':ShowFrames()') 681 -- print('|cFFFFFF00' ..self:GetName()..':ShowFrames()')
676 -- do not SetShown() here 682 -- do not SetShown() here
677 end 683 end
678 self.Overlay:SetShown(true) 684 self.Overlay:SetShown(true)
679 self.count:SetShown(true) 685 self.count:SetShown(true)
680 self.timeLabel:SetShown(true) 686 self.timeLabel:SetShown(true)
683 function QuestPOI:HideFrames() 689 function QuestPOI:HideFrames()
684 if self:IsShown() then 690 if self:IsShown() then
685 if not self.hideReason then 691 if not self.hideReason then
686 self.hideReason = "HideFrames() called" 692 self.hideReason = "HideFrames() called"
687 end 693 end
688 --print(self:GetName()..':HideFrames()')
689 self:SetShown(false)
690 end 694 end
691 self.Overlay:SetShown(false) 695 self.Overlay:SetShown(false)
692 self.count:SetShown(false) 696 self.count:SetShown(false)
693 self.timeLabel:SetShown(false) 697 self.timeLabel:SetShown(false)
694 self.used = nil 698 self.used = nil
695 end 699 end
696 700
697 function QuestPOI:OnLoad() 701 function QuestPOI:OnLoad()
698 qprint('|cFF00FF88'..self:GetName()..':OnLoad()|r',db.Config) 702 --qprint('|cFF00FF88'..self:GetName()..':OnLoad()|r',db.Config)
699 self.debugTimer = 4 703 self.debugTimer = 4
700 self.title = '|cFF0088FF' .. RETRIEVING_DATA..'|r' 704 self.title = '|cFF0088FF' .. RETRIEVING_DATA..'|r'
701 self.isPending = true 705 self.isPending = true
702 self.count = self.Overlay.count 706 self.count = self.Overlay.count
703 self.timeLabel = self.Overlay.timeLabel 707 self.timeLabel = self.Overlay.timeLabel
715 else 719 else
716 TaskPOI_OnClick(self, button) 720 TaskPOI_OnClick(self, button)
717 end 721 end
718 end 722 end
719 723
720 724 local updateTime, markTime
721 function QuestPOI:OnUpdate (sinceLast) 725 function QuestPOI:OnUpdate (sinceLast)
722 -- control update check intervals 726 -- control update check intervals
723 727
724 728
725 self.throttle = (self.throttle or self.updateRate) + sinceLast 729 self.throttle = (self.throttle or self.updateRate) + sinceLast
732 --@debug@ 736 --@debug@
733 if DATA_DEBUG then 737 if DATA_DEBUG then
734 self.debugTimer = self.debugTimer - sinceLast 738 self.debugTimer = self.debugTimer - sinceLast
735 if self.debugTimer >= 0 then 739 if self.debugTimer >= 0 then
736 print(self.debugTimer) 740 print(self.debugTimer)
741 return
737 end 742 end
738 end 743 end
739 --@end-debug@ 744 --@end-debug@
740 745
741 -- query for reward data if it wasn't found in the original scan 746 -- query for reward data if it wasn't found in the original scan
742 747
743 if not self.dataLoaded then 748 if not self.dataLoaded then
744 print('|cFFFF4400'..self:GetID()..':|r polling reward info')
745 749
746 local dataLoaded = self:GetData() 750 local dataLoaded = self:GetData()
747 if dataLoaded and not tContains(db.UpdatedPins, self) then 751 if dataLoaded and not tContains(db.UpdatedPins, self) then
748 self.PendingFade:Stop() 752 -- self.PendingFade:Stop()
749 -- scale info from the parent module is needed, so deal with it there 753 -- scale info from the parent module is needed, so deal with it there
754 --print('|cFF00FF88 queueing for update')
750 tinsert(db.UpdatedPins, self) 755 tinsert(db.UpdatedPins, self)
756 else
757
758 --print('|cFFFF4400OnUpdate(|r'..self:GetID()..'|cFFFF4400)|r poll failed')
751 end 759 end
752 return 760 return
753 end 761 end
754 762
755 if self.maxAlertLevel then 763 if self.maxAlertLevel then
759 end 767 end
760 768
761 function QuestPOI:GetCriteriaState() 769 function QuestPOI:GetCriteriaState()
762 local isCriteria, isBounty, isSpellTarget 770 local isCriteria, isBounty, isSpellTarget
763 if self.factionID then 771 if self.factionID then
764 772 for index, bounty in pairs(db.Bounties) do
765 local bounties = db.BountiesByFactionID 773 if IsQuestCriteriaForBounty(self.questID, bounty.questID) then
766 if bounties then 774 isCriteria = true
767 for factionID, bounty in pairs(bounties) do 775 if db.selectedBounty == bounty then
768 776 isBounty = true
769 if IsQuestCriteriaForBounty(self.questID, bounty.questID) then
770 isCriteria = true
771 if db.selectedBounty == bounty then
772 isBounty = true
773 end
774 print('|cFF00FF88Criteria:|r', self.questID, bounty.questID, isCriteria, isBounty)
775 end 777 end
776 end 778 --dprint('|cFF00FF88Criteria:|r', self.questID, bounty.questID, isCriteria, isBounty)
777 779 end
778
779 print('|cFFFF4400Criteria:|r', self.questID, self.isCriteria, self.isBounty)
780
781 end 780 end
782 end 781 end
783 isSpellTarget = IsQuestIDValidSpellTarget(self.questID) 782 isSpellTarget = IsQuestIDValidSpellTarget(self.questID)
784 783
785 if (self.isBounty ~= isBounty) or (self.isCriteria ~= isCriteria) or (self.isSpellTarget ~= isSpellTarget) then 784 if (self.isBounty ~= isBounty) or (self.isCriteria ~= isCriteria) or (self.isSpellTarget ~= isSpellTarget) then
786 785 --wqprint('|cFF00FF00criteria state changed')
787 self.isBounty = isBounty 786 self.isBounty = isBounty
788 self.isCriteria = isCriteria 787 self.isCriteria = isCriteria
789 self.isSpellTarget = isSpellTarget 788 self.isSpellTarget = isSpellTarget
789 self.isStale = true
790 return true 790 return true
791 end 791 end
792
793 end 792 end
794 793
795 -- Called at static intervals and with Refresh 794 -- Called at static intervals and with Refresh
796 function QuestPOI:UpdateStatus() 795 function QuestPOI:UpdateStatus()
797 -- update time elements 796 -- update time elements
826 end 825 end
827 826
828 827
829 function QuestPOI:Refresh (event) 828 function QuestPOI:Refresh (event)
830 829
831 print('|cFF00FF88'..self:GetID()..'|r:Refresh()', event) 830 print('|cFF00FF88Refresh(|r'..self:GetID()..'|cFF00FF88)|r', event, self.title)
832 831
833 local style = DEFAULT_STYLE 832 local style = DEFAULT_STYLE
834 if self.dataLoaded and not self.filtered then 833 if self.dataLoaded and not self.filtered then
835 style = REWARD_TYPE_STYLES[self.rewardType] 834 style = REWARD_TYPE_STYLES[self.rewardType]
836 else 835 else
940 self:UpdateSize() 939 self:UpdateSize()
941 self:UpdateStatus() 940 self:UpdateStatus()
942 self.isStale = nil 941 self.isStale = nil
943 942
944 if self.isBounty then 943 if self.isBounty then
945 print('is bounty') 944 --print('is bounty')
946 iconBorder:SetVertexColor(trackingBorder:GetVertexColor()) 945 iconBorder:SetVertexColor(trackingBorder:GetVertexColor())
947 trackingBorder:SetVertexColor(unpack(BORDER_SELECTED_BOUNTY)) 946 trackingBorder:SetVertexColor(unpack(BORDER_SELECTED_BOUNTY))
948 elseif self.isCriteria then 947 elseif self.isCriteria then
949 print('is criteria of a bounty') 948 --print('is criteria of a bounty')
950 iconBorder:SetVertexColor(trackingBorder:GetVertexColor()) 949 iconBorder:SetVertexColor(trackingBorder:GetVertexColor())
951 trackingBorder:SetVertexColor(unpack(BORDER_CRITERIA)) 950 trackingBorder:SetVertexColor(unpack(BORDER_CRITERIA))
952 else 951 else
953 952
954 iconBorder:SetVertexColor(unpack(borderColor)) 953 iconBorder:SetVertexColor(unpack(borderColor))