Mercurial > wow > worldplan
view QuestPOI.lua @ 73:25f7dbc20a72
fix WorldMapTooltip getting stranded when flightmap is closed
- quests that are not valid spell targets will have their icon go red
- auto-complete scrolls will no longer hide pin frames; instead they become click through and blizzard POIs are activated beneath for taint-free interaction
author | Nenue |
---|---|
date | Fri, 07 Apr 2017 07:20:28 -0400 |
parents | 6db0b9696936 |
children | 2ba11b25aa7f |
line wrap: on
line source
-- WorldPlan -- QuestPOI.lua -- Created: 10/1/2016 7:21 PM -- %file-revision% -- Big TODOs: -- -- generate frames using `WorldMap_GetOrCreateTaskPOI' to remove tainting issues -- local _, db = ... local TQ_GetQuestInfoByQuestID = C_TaskQuest.GetQuestInfoByQuestID local TQ_GetQuestLocation = C_TaskQuest.GetQuestLocation local TQ_GetQuestTimeLeftMinutes = C_TaskQuest.GetQuestTimeLeftMinutes local TQ_IsActive = C_TaskQuest.IsActive local TQ_RequestPreloadRewardData = C_TaskQuest.RequestPreloadRewardData local QuestPOIGetIconInfo, WorldMapPOIFrame = QuestPOIGetIconInfo, WorldMapPOIFrame local WorldMap_DoesWorldQuestInfoPassFilters = WorldMap_DoesWorldQuestInfoPassFilters local QuestMapFrame_IsQuestWorldQuest = QuestMapFrame_IsQuestWorldQuest local GetAchievementNumCriteria, GetAchievementCriteriaInfo, GetAchievementInfo = GetAchievementNumCriteria, GetAchievementCriteriaInfo, GetAchievementInfo local IsQuestFlaggedCompleted = IsQuestFlaggedCompleted local GetFactionInfoByID, GetQuestObjectiveInfo = GetFactionInfoByID, GetQuestObjectiveInfo local GetQuestTagInfo, GetProfessionInfo = GetQuestTagInfo, GetProfessionInfo local GetNumQuestLogRewards, GetNumQuestLogRewardCurrencies, HaveQuestData = GetNumQuestLogRewards, GetNumQuestLogRewardCurrencies, HaveQuestData local GetQuestLogRewardMoney, GetQuestLogRewardCurrencyInfo, GetMoneyString = GetQuestLogRewardMoney, GetQuestLogRewardCurrencyInfo, GetMoneyString local SpellCanTargetQuest, GetCVarBool = SpellCanTargetQuest, GetCVarBool local SetSuperTrackedQuestID = SetSuperTrackedQuestID local HaveQuestRewardData = HaveQuestRewardData local pairs, ipairs, tinsert, unpack, select = pairs, ipairs, tinsert, unpack, select local floor, mod, tostring, tonumber, GetSuperTrackedQuestID = floor, mod, tostring, tonumber, GetSuperTrackedQuestID local GameTooltip = GameTooltip local GetItemIcon = GetItemIcon local print = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or nop local qprint = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or nop local wprint = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or nop local wqprint = DEVIAN_WORKSPACE and function(...) _G.print('WorldQuests', ...) end or nop local iprint = DEVIAN_WORKSPACE and function(...) _G.print('ItemScan', ...) end or nop local rprint = DEVIAN_WORKSPACE and function(...) _G.print('WQRefresh', ...) end or nop local dprint = DEVIAN_WORKSPACE and function(...) _G.print('WQData', ...) end or nop local QuestPOI = WorldPlanPOIMixin local pinBaseIndex = 1500 local overlayBaseIndex = 1580 local previousHighlight local DATA_DEBUG = false local PIN_REFRESH_DELAY = .5 local PIN_REQUEST_DELAY = .1 local ICON_UNKNOWN = "Interface\\ICONS\\inv_misc_questionmark" local ICON_MONEY = "Interface\\Buttons\\UI-GroupLoot-Coin-Up" local WORLD_QUEST_BORDER = "Interface\\UNITPOWERBARALT\\Generic1Target_Circular_Frame" local PENDING_BORDER = "Interface\\BUTTONS\\YELLOWORANGE64" local PENDING_ICON = "Interface\\BUTTONS\\YELLOWORANGE64" local REWARD_CASH = WORLD_QUEST_REWARD_TYPE_FLAG_GOLD local REWARD_ARTIFACT_POWER = WORLD_QUEST_REWARD_TYPE_FLAG_ARTIFACT_POWER local REWARD_GEAR = WORLD_QUEST_REWARD_TYPE_FLAG_EQUIPMENT local REWARD_CURRENCY = WORLD_QUEST_REWARD_TYPE_FLAG_ORDER_RESOURCES local REWARD_REAGENT = WORLD_QUEST_REWARD_TYPE_FLAG_MATERIALS local REWARD_TYPE_NAMES = { [REWARD_CASH] = 'Money', [REWARD_ARTIFACT_POWER] = 'AP', [REWARD_GEAR] = 'Equipment', [REWARD_CURRENCY] = 'Currency', [REWARD_REAGENT] = 'Trade Goods' } local LE_QUEST_TAG_TYPE_PVP = LE_QUEST_TAG_TYPE_PVP local LE_QUEST_TAG_TYPE_PET_BATTLE = LE_QUEST_TAG_TYPE_PET_BATTLE local LE_QUEST_TAG_TYPE_DUNGEON = LE_QUEST_TAG_TYPE_DUNGEON local LE_QUEST_TAG_TYPE_PROFESSION = LE_QUEST_TAG_TYPE_PROFESSION local LE_QUEST_TAG_TYPE_NORMAL = LE_QUEST_TAG_TYPE_NORMAL local LE_QUEST_TAG_TYPE_PVP = LE_QUEST_TAG_TYPE_PVP local LE_QUEST_TAG_TYPE_PET_BATTLE = LE_QUEST_TAG_TYPE_PET_BATTLE local LE_QUEST_TAG_TYPE_DUNGEON = LE_QUEST_TAG_TYPE_DUNGEON local LE_QUEST_TAG_TYPE_PROFESSION = LE_QUEST_TAG_TYPE_PROFESSION local LE_QUEST_TAG_TYPE_NORMAL = LE_QUEST_TAG_TYPE_NORMAL local DEFAULT_STYLE = { border = {1,1,1}, textColor = {1,1,1,1}, x = 0, y = 0, desaturated = true, iconMask = "Interface\\Minimap\\UI-Minimap-Background", borderMask = "Interface\\Minimap\\UI-Minimap-Background", rewardMark = "Interface\\Minimap\\UI-Minimap-Background", scaleFactors = {0.25, 0.7, 1}, iconWidth = 18, borderWidth = 2, highlightWidth = 2, TagSize = 8, maxAlertLevel = 0, numberFontObject = 'WorldPlanFont' } local MINIMIZED_STYLE = { hideNumber = true, hideIcon = true, iconWidth = 3, } local REWARD_TYPE_STYLES = { [REWARD_CASH] = { border = {1,1,0}, hideNumber = true, }, [REWARD_ARTIFACT_POWER] = {}, [REWARD_GEAR] = { hideNumber = true, }, [REWARD_CURRENCY] = { textColor = {1,1,0,.5} }, [REWARD_REAGENT] = { hideNumber = true, }, } local LE_ITEM_CLASS_WEAPON, LE_ITEM_CLASS_ARMOR, LE_ITEM_CLASS_GEM, LE_ITEM_GEM_ARTIFACTRELIC, LE_ITEM_CLASS_TRADEGOODS = LE_ITEM_CLASS_WEAPON, LE_ITEM_CLASS_ARMOR, LE_ITEM_CLASS_GEM, LE_ITEM_GEM_ARTIFACTRELIC, LE_ITEM_CLASS_TRADEGOODS local STYLE_TYPE_PENDING = 768 -- Pin color/display variables db.TooltipExtras = db.TooltipExtras or {} -- idiot-proofing db.PinAlpha = 1 local familiars = { [42159] = 'Nightwatcher Merayl', [40277] = 'Tiffany Nelson', [40298] = 'Sir Galveston', [40282] = 'Grixis Tinypop', [40278] = 'Robert Craig', [48195] = 'Aulier', [41990] = 'Varenne', [41860] = 'Xorvasc', [40299] = 'Bodhi Sunwayver', [42442] = 'Amalia', [40280] = 'Bredda Tenderhide', [41687] = 'Odrogg', [41944] = 'Trapper Jarrun', [40337] = 'Master Tamer Flummox', [40279] = 'Durian Strongfruit' } local falcosaurs = { [44895] = {44881, 'Sharptalon Hatchling', 115786}, [44894] = {44882, 'Bloodgazer Hatchling', 115787}, [44893] = {44880, 'Direbeak Hatchling', 115785}, [44892] = {44879, 'Snowfeather Hatchling', 115784}, } local familiars_id = 9696 for questID, name in pairs(familiars) do db.TooltipExtras[questID] = {{ achievementID = familiars_id, name = name }} end for questID, info in pairs(falcosaurs) do local trackingQuestID, petName, petID = unpack(info) db.TooltipExtras[questID] = {{ questID = trackingQuestID, pet = petName, petID = petID }} end local GetAchievementTooltipExtras = function(info) local hasInfo local achievementID = info.achievementID local _, name, _, completed, _, _, _, _, _, icon = GetAchievementInfo(achievementID) if not completed then local numItems = GetAchievementNumCriteria(achievementID) local numNeeded = 0 local tooltipLines = {} for i =1, numItems do local criteriaName, criteriaType, completed, _, _, _, _, subAchievementID = GetAchievementCriteriaInfo(achievementID, i) --print(GetAchievementCriteriaInfo(achievementID, i)) if not completed then --print('::', criteriaName, completed, subAchievementID) if criteriaType == 8 then local _, _, _, completed, _, _, _, _, _, subIcon = GetAchievementInfo(subAchievementID) --print(' -', criteriaName, completed, subIcon) if not completed then local numCompleted = 0 local numSubItems = GetAchievementNumCriteria(subAchievementID) local subCriteriaLine for j = 1, numSubItems do local subName, _, completed = GetAchievementCriteriaInfo(subAchievementID, j) --print(' -',subName, completed) if completed then numCompleted = numCompleted + 1 else numNeeded = numNeeded + 1 if subName:match(info.name) then hasInfo = true subCriteriaLine = ' |T'..subIcon..':16:16|t ' .. criteriaName end end end if subCriteriaLine then tinsert(tooltipLines, subCriteriaLine .. ' ('..numCompleted..'/'..numSubItems..')') end end elseif criteriaName:match(info.name) and (not completed) then numNeeded = numNeeded + 1 tinsert(tooltipLines, criteriaName) end end end if hasInfo then WorldMapTooltip:AddLine(" ") WorldMapTooltip:AddLine("Achievements:") WorldMapTooltip:AddLine(' |T'..icon..':20:20|t '..name) for i, line in ipairs(tooltipLines) do WorldMapTooltip:AddLine(line) end end end return hasInfo end local GetQuestTooltipExtras = function(info) local questID = info.questID local hasInfo if info.pet then local index, guid = C_PetJournal.FindPetIDByName(info.pet) if not index then hasInfo = true WorldMapTooltip:AddLine('Pets:') WorldMapTooltip:AddLine(' - ' .. info.petName) if not IsQuestFlaggedCompleted(questID) then WorldMapTooltip:AddLine(' Required Quest Flags', 1, 1, 0) else WorldMapTooltip:AddLine(' Quest Flags Complete!', 0, 1, 0) end end end end function QuestPOI:OnEnter() if self.filtered and (self.questID ~= GetSuperTrackedQuestID()) then return end WorldMap_HijackTooltip(self.owningFrame); self:SetFrameLevel(pinBaseIndex+100) self.Overlay:SetFrameLevel(pinBaseIndex+101) if previousHighlight then previousHighlight:SetFrameLevel(pinBaseIndex+previousHighlight:GetID()) previousHighlight.Overlay:SetFrameLevel(overlayBaseIndex+previousHighlight:GetID()) end previousHighlight = self WorldMapTooltip:SetOwner(self, "ANCHOR_RIGHT"); --print('doing tooltip stuff') -- Can't add stuff after, so most of the blizzard tooltip hook is simply copied over local questID = self.questID local color = WORLD_QUEST_QUALITY_COLORS[self.rarity] or NORMAL_FONT_COLOR; WorldMapTooltip:SetText(self.title, color.r, color.g, color.b); QuestUtils_AddQuestTypeToTooltip(WorldMapTooltip, questID, NORMAL_FONT_COLOR); if ( self.factionID ) then local factionName = GetFactionInfoByID(self.factionID); if ( factionName ) then if (self.capped) then WorldMapTooltip:AddLine(factionName, GRAY_FONT_COLOR:GetRGB()); else WorldMapTooltip:AddLine(factionName); end end end if self.worldQuest then WorldMap_AddQuestTimeToTooltip(questID); end for objectiveIndex = 1, self.numObjectives do local objectiveText, objectiveType, finished = GetQuestObjectiveInfo(questID, objectiveIndex, false); if ( objectiveText and #objectiveText > 0 ) then local color = finished and GRAY_FONT_COLOR or HIGHLIGHT_FONT_COLOR; WorldMapTooltip:AddLine(QUEST_DASH .. objectiveText, color.r, color.g, color.b, true); end end local percent = C_TaskQuest.GetQuestProgressBarInfo(self.questID); if ( percent ) then GameTooltip_InsertFrame(WorldMapTooltip, WorldMapTaskTooltipStatusBar); WorldMapTaskTooltipStatusBar.Bar:SetValue(percent); WorldMapTaskTooltipStatusBar.Bar.Label:SetFormattedText(PERCENTAGE_STRING, percent); end if db.TooltipExtras[self.questID] then for index, info in pairs(db.TooltipExtras[questID]) do if info.achievementID then GetAchievementTooltipExtras(info) end if info.questID then GetQuestTooltipExtras(info) end end end GameTooltip_AddQuestRewardsToTooltip(WorldMapTooltip, questID) WorldMapTooltip:Show() --WorldMapTooltip.recalculatePadding = true; --print(WorldMapTooltip:GetParent()) --print(WorldMapTooltip:IsVisible()) end function QuestPOI:OnLeave() if self.filtered and (self.questID ~= GetSuperTrackedQuestID()) then return end WorldMap_RestoreTooltip() WorldMapTooltip:Hide(); end -- attempt to pull pin data function QuestPOI:GetData () dprint('|cFF00FF88'..self:GetID()..':GetData()|r') local questID = self.questID if not questID then dprint('|cFFFF4400bad pin|r', self:GetName()) return nil end local questTitle, factionID, capped = TQ_GetQuestInfoByQuestID(questID) -- if the title is nil, then wait and try later if not questTitle then dprint('|cFFBB8844dataLoaded|r = false|cFF00FFFF', self.questId) return false else self.title, self.factionID, self.capped = questTitle, factionID, capped dprint(questTitle, factionID, capped) -- set tag details local worldQuestType self.tagID, self.tagName, worldQuestType, self.rarity, self.isElite, self.tradeskillLineIndex = GetQuestTagInfo(questID); local tagAtlas if worldQuestType == LE_QUEST_TAG_TYPE_PET_BATTLE then tagAtlas = "worldquest-icon-petbattle" elseif worldQuestType == LE_QUEST_TAG_TYPE_PVP then tagAtlas = "worldquest-icon-pvp-ffa" elseif worldQuestType == LE_QUEST_TAG_TYPE_PROFESSION then self.isKnownProfession = nil local id = self.tradeskillLineIndex and select(7, GetProfessionInfo(self.tradeskillLineIndex)) if id then self.isKnownProfession = true qprint('profession' , self.title, id) tagAtlas = WORLD_QUEST_ICONS_BY_PROFESSION[id] end elseif worldQuestType == LE_QUEST_TAG_TYPE_DUNGEON then tagAtlas = "worldquest-icon-dungeon" end self.worldQuestType = worldQuestType self.tagAtlas = tagAtlas local dataLoaded, rewardType, itemName, itemTexture, itemNumber, quality, xpType, xpName, xpIcon, xpCount = self:UpdateRewards() dprint('|cFFBB8844 dataLoaded|r =', dataLoaded, rewardType, itemName, itemTexture, itemNumber, quality) if dataLoaded then self.rewardType = rewardType self.itemName = itemName self.itemTexture = itemTexture self.itemNumber = itemNumber self.itemQuality = quality self.dataLoaded = true self.isStale = true self.xpType, self.xpName, self.xpIcon, self.xpCount = xpType, xpName, xpIcon, xpCount end end return self.dataLoaded end local ID_RESOURCES = 1220 local ID_LEGIONFALL = 1342 --- Returns true if data has changed (either from loading in or qualifications changed) function QuestPOI:UpdateRewards() local questID = self.questID if not HaveQuestRewardData(questID) then C_TaskQuest.RequestPreloadRewardData(questID); return false; else local rewardMoney, rewardAP, rewardHonor local rewardItems, rewardCurrency = {}, {} local rewardIcon, rewardName, rewardCount, rewardStyle, rewardType, itemID, quantity, quality local xpIcon, xpName, xpCount, xpType local foundPrimary if (GetNumQuestLogRewardCurrencies(questID) > 0 or GetNumQuestLogRewards(questID) > 0 or GetQuestLogRewardMoney(questID) > 0 or GetQuestLogRewardArtifactXP(questID) > 0 or GetQuestLogRewardHonor(questID)) then local money = GetQuestLogRewardMoney(questID) if money > 0 then rewardMoney = money rewardIcon = ICON_MONEY rewardName = GetMoneyString(money) rewardCount = floor(money/10000) rewardType = REWARD_CASH end local artifactXP = GetQuestLogRewardArtifactXP(questID); if artifactXP > 0 then rewardAP = artifactXP rewardIcon = "Interface\\ICONS\\inv_7xp_inscription_talenttome01" rewardCount = artifactXP rewardType = REWARD_ARTIFACT_POWER qprint(' artifactXP', artifactXP) foundPrimary = true end local numQuestCurrencies = GetNumQuestLogRewardCurrencies(questID); for i = 1, numQuestCurrencies do local name, texture, numItems, currencyID = GetQuestLogRewardCurrencyInfo(i, questID); local text = BONUS_OBJECTIVE_REWARD_WITH_COUNT_FORMAT:format(texture, numItems, name); tinsert(rewardCurrency, { name = name, texture = texture, numItems = numItems, text = text }) qprint(' currency', i, currencyID, name, " |T"..tostring(texture)..":12:12|t") if currencyID == ID_RESOURCES then rewardIcon = texture rewardCount = numItems rewardName = name rewardType = REWARD_CURRENCY foundPrimary = true elseif currencyID == ID_LEGIONFALL then xpIcon = texture xpCount = numItems xpName = name xpType = REWARD_CURRENCY end end local honorAmount = GetQuestLogRewardHonor(questID); if honorAmount > 0 then xpIcon = "Interface\\ICONS\\Achievement_LegionPVPTier4" xpCount = honorAmount xpName = HONOR xpType = HONOR_CURRENCY end local numQuestRewards = GetNumQuestLogRewards(questID); if numQuestRewards > 0 then for i = 1, numQuestRewards do local name, texture, numItems, quality, isUsable, itemID = GetQuestLogRewardInfo(i, questID) if itemID then local itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture, sellPrice, classID, subclassID = GetItemInfo(itemID); if ( classID == LE_ITEM_CLASS_WEAPON or classID == LE_ITEM_CLASS_ARMOR or (classID == LE_ITEM_CLASS_GEM and subclassID == LE_ITEM_GEM_ARTIFACTRELIC) ) then rewardType = REWARD_GEAR rewardIcon = texture rewardName = name rewardCount = numItems foundPrimary = true elseif IsArtifactPowerItem(itemID) then rewardType = REWARD_ARTIFACT_POWER rewardIcon = texture rewardName = name rewardCount = 1 foundPrimary = true WorldPlanTooltip:SetOwner(self, 'ANCHOR_NONE') WorldPlanTooltip:SetHyperlink(itemLink) for i = 1, WorldPlanTooltip:NumLines() do local line = _G['WorldPlanTooltipTextLeft' .. i] local text = line and line:GetText() local ap = text and text:gsub(',', ''):match('(%d+) '..ARTIFACT_POWER) if ap then rewardCount = tonumber(ap) print(ap) end end if WorldPlanTooltipTextLeft2 then local text = WorldPlanTooltipTextLeft2:GetText() end print('is an AP token') elseif classID == LE_ITEM_CLASS_TRADEGOODS then rewardType = REWARD_REAGENT rewardIcon = texture rewardName = name rewardCount = numItems foundPrimary = true end qprint(' reward', i, name, " |T"..tostring(texture)..":12:12|t", quality, isUsable, itemID) tinsert(rewardItems, { name = name, texture = texture, numItems = numItems, quality = quality, isUsable = isUsable }) if not foundPrimary then print(' -updating primary') rewardType = REWARD_GEAR rewardIcon = texture rewardName = name rewardCount = numItems end end end end qprint(' '..self.questID..':|cFFFFFF00SetRewardInfo():', numQuestRewards, rewardType) qprint(' ', tostring(self.title), " |T"..tostring(self.itemTexture)..":12:12|t", tostring(self.itemName)) if (self.itemNumber ~= rewardCount) or (self.rewardType ~= rewardType) or (self.itemName ~= rewardName) or (self.itemTexture ~= rewardIcon) then if DATA_DEBUG and (self.debugTimer <= 0) then return false end return true, rewardType, rewardName, rewardIcon, rewardCount, quality, xpType, xpName, xpIcon, xpCount else return false end end --[[ set reward category local numRewards = GetNumQuestLogRewards(questID) local numCurrency = GetNumQuestLogRewardCurrencies(questID) local money = GetQuestLogRewardMoney(questID) if numRewards >= 1 then rewardType, rewardIcon, rewardCount, rewardName, itemID, quality = WorldPlanQuests:GetRewardHeader(questID) elseif numCurrency >= 1 then rewardName, rewardIcon, rewardCount = GetQuestLogRewardCurrencyInfo(1, questID) rewardType = REWARD_CURRENCY elseif money >= 1 then rewardName = GetMoneyString(money) end --]] end end -- run from OnShow if .isNew is set function QuestPOI:StartFade() if not self.isAnimating then qprint('|cFFFFFF00clearing new status') self:SetAlpha(0) if self.dataLoaded then self:Refresh() self.FadeIn.FadeIn:SetToAlpha(db.PinAlpha) self.PendingFade.FadeIn:SetToAlpha(db.PinAlpha) self.PendingFade.FadeOut:SetFromAlpha(db.PinAlpha) self.isAnimating = true self.isNew = nil self.isStale = true self.FadeIn:Play() end end end function QuestPOI:EndFade() self.isAnimating = nil self:SetAlpha(db.PinAlpha) end function QuestPOI:OnShow () if self.isNew then self:StartFade() else if not self.isAnimating then print('|cFF00FF00Alpha correction') self:SetAlpha(db.PinAlpha) -- fix stuck alpha end if self.isStale then print('|cFF00FF00refresh on show') self:Refresh() end end self:ShowFrames() end function QuestPOI:OnHide() --DEFAULT_CHAT_FRAME:AddMessage('|cFFFFFF00'..self:GetName()..'|r:OnHide()') self:HideFrames() -- reset flags self:SetAlpha(db.PinAlpha) self.isAnimating = nil if db.Config.DebugEnabled then db.log(tostring(self.questID) .. ' ' .. tostring(self.title) .. "\n" .. tostring(REWARD_TYPE_NAMES[self.rewardType]) .. ' ' .. tostring(self.itemName) .. ' ' .. tostring(self.itemNumber) .. "\n|cFFFF4400" .. (self.hideReason or 'NO_MESSAGE') .. "|r\n|cFF00FFFF" .. debugstack(2,3,0) .. '|r') end self.hideReason = nil end -- Applies position and sizing parameters to the pin data function QuestPOI:SetAnchor(owner, dX, dY, mapWidth, mapHeight, scaleFactor) dprint(self:GetName()..':SetAnchor()', owner, dX, dY, scaleFactor, self.filtered, self.used) if not self.used then self.hideReason = 'SetAnchor() on an unused frame.' self:HideFrames() return end if owner then local prevOwner = self:GetParent() if prevOwner ~= owner then self.isStale = true end self:SetParent(owner) self.Overlay:SetParent(owner) else owner = self:GetParent() end self:ClearAllPoints() self:SetFrameLevel(pinBaseIndex + self:GetID()) self.Overlay:SetFrameLevel(overlayBaseIndex + self:GetID()) local scaleChanged if scaleFactor and (self.scaleFactor ~= scaleFactor) then --print('scaleFactor') self:SetScale(scaleFactor) self.Overlay:SetScale(scaleFactor) self.scaleFactor = scaleFactor scaleChanged = true end if (dX and dY) then if not (mapHeight and mapWidth) then mapWidth, mapHeight = owner:GetSize() end if (self.x ~= dY) or (self.y ~= dY) or scaleChanged then self.x = dX self.y = dY local pX = (dX * mapWidth) * (1 / scaleFactor) local pY = (-dY * mapHeight) * (1 / scaleFactor) self:SetPoint('CENTER', owner, 'TOPLEFT', pX, pY) end end end -- Show/Hide the text overlays associated with the quest pin; they aren't hierarchically linked function QuestPOI:ShowFrames() if not self:IsShown() then print('|cFFFFFF00' ..self:GetName()..':ShowFrames()') -- do not SetShown() here end self.Overlay:SetShown(true) self.count:SetShown(true) self.timeLabel:SetShown(true) end function QuestPOI:HideFrames() if self:IsShown() then if not self.hideReason then self.hideReason = "HideFrames() called" end --print(self:GetName()..':HideFrames()') self:SetShown(false) end self.Overlay:SetShown(false) self.count:SetShown(false) self.timeLabel:SetShown(false) self.used = nil end function QuestPOI:OnLoad() qprint('|cFF00FF88'..self:GetName()..':OnLoad()|r',db.Config) self.debugTimer = 4 self.title = '|cFF0088FF' .. RETRIEVING_DATA..'|r' self.isPending = true self.count = self.Overlay.count self.timeLabel = self.Overlay.timeLabel self.Description = self.Overlay.Description self.updateRate = PIN_REQUEST_DELAY self.itemName = '|cFF0088FF' .. RETRIEVING_DATA..'|r' self.Overlay:SetPoint('TOPLEFT', self, 'TOPLEFT', 0, 4) self.Overlay:SetPoint('BOTTOMRIGHT', self, 'BOTTOMRIGHT', 0, -4) end function QuestPOI:OnMouseDown(button) if button == 'RightButton' then SetSuperTrackedQuestID(nil) else TaskPOI_OnClick(self, button) end end function QuestPOI:OnUpdate (sinceLast) -- control update check intervals self.throttle = (self.throttle or self.updateRate) + sinceLast if self.throttle >= self.updateRate then -- factor overtime into the throttle timer self.throttle = self.throttle - self.updateRate else return end --@debug@ if DATA_DEBUG then self.debugTimer = self.debugTimer - sinceLast if self.debugTimer >= 0 then print(self.debugTimer) end end --@end-debug@ -- query for reward data if it wasn't found in the original scan if not self.dataLoaded then print('|cFFFF4400'..self:GetID()..':|r polling reward info') local dataLoaded = self:GetData() if dataLoaded and not tContains(db.UpdatedPins, self) then print('|cFF00FF88'..self:GetID()..':|r delayed reward info, queueing for update') self.PendingFade:Stop() tinsert(db.UpdatedPins, self) end return end if self.maxAlertLevel then self:UpdateStatus() end end -- Called at static intervals and with Refresh function QuestPOI:UpdateStatus() -- update time elements self.isActive = TQ_IsActive(self.questID) if self.isActive then local tl = self.alertLevel local timeLeft = TQ_GetQuestTimeLeftMinutes(self.questID) if timeLeft > 0 then local text, timeState = WorldPlan:GetTimeInfo(timeLeft, self.maxAlertLevel) if tl ~= timeState then tl = timeState self.timeLabel:SetText(text) end end if tl and (timeLeft < 120) then self.HighlightBorder:SetVertexColor(1,0,0,0.7) elseif self.isBounty then self.HighlightBorder:SetVertexColor(1,1,0,1) elseif self.isCriteria then self.HighlightBorder:SetVertexColor(.25,.5,1,1) else self.HighlightBorder:SetVertexColor(0,0,0,0.7) end self.alertLevel = tl self.timeLabel:SetShown(self.worldQuest and (self.maxAlertLevel >= 1)) else self.hideReason = "No longer active." self:HideFrames() end end function QuestPOI:Refresh () rprint('|cFF00FF88'..self:GetID()..'|r:Refresh() type =', self.rewardType, 'title =', self.title) local style = DEFAULT_STYLE if self.dataLoaded and not self.filtered then style = REWARD_TYPE_STYLES[self.rewardType] else style = MINIMIZED_STYLE end local currentWidth = style.iconWidth or DEFAULT_STYLE.iconWidth local borderWidth = style.borderWidth or DEFAULT_STYLE.borderWidth local highlightWidth = style.highlightWidth or DEFAULT_STYLE.highlightWidth local tagSize = style.TagSize or DEFAULT_STYLE.TagSize local hideIcon = style.hideIcon or DEFAULT_STYLE.hideIcon local borderColor = style.border or DEFAULT_STYLE.border local textColor = style.textColor or DEFAULT_STYLE.textColor local questID = self.questID local iconBorder = self.RewardBorder local trackingBorder = self.HighlightBorder local icon = self.icon local count = self.count local hideNumbers = style.hideNumber or DEFAULT_STYLE.hideNumber local tagIcon = self.tagIcon self.maxAlertLevel = style.maxAlertLevel or DEFAULT_STYLE.maxAlertLevel if self.itemName then if self.itemNumber and (self.itemNumber > 1) and (not hideNumbers) then local numberString = self.itemNumber if self.itemNumber >= 1000000 then numberString = (floor(self.itemNumber/100000)/10) .. 'M' elseif self.itemNumber >= 10000 then numberString = floor(self.itemNumber/1000) .. 'k' elseif self.itemNumber >= 1000 then local numeral = floor(self.itemNumber/1000) local decimal = mod(self.itemNumber, 1000) numberString = numeral if decimal > 100 then numberString = numberString .. '.' .. tostring(floor(decimal/100)) end numberString = numberString .. 'k' end self.count:SetText(numberString) self.count:SetTextColor(unpack(textColor)) self.count:Show() else self.count:SetText(nil) self.count:Hide() end else self.count:Hide() end if db.Config.ShowVerboseInfo then self.Description:SetText(self.title .. "\n" .. floor(self.x*100+.5) .. "," .. floor(self.y*100+.5)) end icon:SetSize(currentWidth, currentWidth) icon:SetMask(style.iconMask or DEFAULT_STYLE.iconMask) if self.itemTexture then --iconBorder:SetTexture(WORLD_QUEST_BORDER) if hideIcon then icon:SetTexture(PENDING_ICON) icon:SetDesaturated(true) icon:SetVertexColor(unpack(borderColor)) else icon:SetTexture(self.itemTexture) icon:SetDesaturated(false) icon:SetVertexColor(1, 1, 1) end else -- icon:SetTexture(PENDING_ICON) icon:SetDesaturated(true) icon:SetVertexColor(unpack(borderColor)) end local borderMask = style.borderMask or DEFAULT_STYLE.borderMask local borderSize = currentWidth + (borderWidth * 2) iconBorder:SetSize(borderSize, borderSize) iconBorder:SetMask(borderMask) iconBorder:SetTexture(PENDING_BORDER) iconBorder:SetVertexColor(unpack(borderColor)) iconBorder:SetDesaturated(true) local highlightSize = borderSize + (highlightWidth * 2) trackingBorder:SetSize(highlightSize, highlightSize) trackingBorder:SetMask(borderMask) trackingBorder:SetTexture(PENDING_BORDER) self:SetSize(borderSize, borderSize) iconBorder:SetPoint('CENTER', (style.x or 0), (style.y or 0)) trackingBorder:SetPoint('CENTER', (style.x or 0), (style.y or 0)) self.tagIcon:SetShown((not self.filtered) and true or false) self.tagIcon:SetAtlas(self.tagAtlas) self.EliteBorder:SetShown(self.isElite and not self.filtered) self:UpdateSize() self:UpdateStatus() self.isStale = nil if SpellCanTargetQuest() then if IsQuestIDValidSpellTarget(self.questID) then icon:SetVertexColor(1,1,1) else icon:SetVertexColor(1,0,0,1) end self:EnableMouse(false) else self:EnableMouse(true) end -- signal filter info update WorldPlanSummary.isStale = true end local cvar_check = { [REWARD_CASH] = 'worldQuestFilterGold', [REWARD_ARTIFACT_POWER] = 'worldQuestFilterArtifactPower', [REWARD_CURRENCY] = 'worldQuestFilterOrderResources', [REWARD_REAGENT]= 'worldQuestFilterProfessionMaterials', [REWARD_GEAR] = 'worldQuestFilterEquipment', } function QuestPOI:CheckFilterRules () local print = qprint local qType = self.worldQuestType local filtered local canShow = TQ_IsActive(self.questID) if qType == LE_QUEST_TAG_TYPE_PROFESSION then if not(self.isKnownProfession or db.Config.ShowAllProfessionQuests) then canShow = nil end end if canShow then for filterKey, value in pairs(db.UsedFilters) do if self[filterKey] ~= value then if not self.filtered then print('|cFFFF4400filtering', filterKey, value, '~=', self[filterKey], self.title) end filtered = true end end if self.rewardType and cvar_check[self.rewardType] then if not GetCVarBool(cvar_check[self.rewardType]) then filtered = true end end if canShow and self.filtered ~= filtered then self.isStale = true print(' '..self.questID..':|cFFFFFF00CheckFilterRules()|r ', canShow, filtered, self.title) end self.filtered = filtered end self.used = canShow if not canShow then self.hideReason = "Failed filter check." end self:SetShown(canShow) end --- Fixes icons upon size update function QuestPOI:UpdateSize () --qprint('|cFF00BB88'..self:GetID()..'|r:UpdateSize()', self.style, self.subStyle) return --[[ local style = self.style local subStyle = self.subStyle local icon = self.icon local iconBorder = self.RewardBorder local trackingBorder = self.HighlightBorder local tag = self.tagIcon local iconWidth = subStyle.iconWidth local borderWidth = iconWidth + (subStyle.borderWidth * 2) local highlightWidth = borderWidth + (subStyle.highlightWidth * 2) local iconTexture = self.itemTexture self:SetSize(highlightWidth, highlightWidth) if self.questID == GetSuperTrackedQuestID() then highlightWidth = highlightWidth + 2 if self.filtered then self:SetAlpha(db.PinAlpha * 0.5) else self:SetAlpha(db.PinAlpha) end end if self.rarity and WORLD_QUEST_QUALITY_COLORS[self.rarity] then highlightWidth = highlightWidth + self.rarity end self.tagIcon:SetSize(self.tagSize, self.tagSize) icon:SetSize(iconWidth, iconWidth) iconBorder:SetSize(borderWidth, borderWidth) trackingBorder:SetSize(highlightWidth, highlightWidth) iconBorder:SetPoint('CENTER', (style.x or 0), (style.y or 0)) trackingBorder:SetPoint('CENTER', (style.x or 0), (style.y or 0)) if (subStyle.showNumber and self.itemNumber) and style.hasNumeric then self.count:SetTextColor(unpack(style.numberRGB)) if subStyle.numberFontObject then --wqprint('change font', _G[subStyle.numberFontObject]:GetName()) self.count:SetFontObject(_G[subStyle.numberFontObject]) end else self.count:SetText(nil) end --]] end