view QuestPOI.lua @ 42:f494175a2d15

Added tag v1.0-rc10 for changeset 79e5e96e5f18
author Nenue
date Sun, 25 Dec 2016 15:18:06 -0500
parents 79e5e96e5f18
children db570c6a0ffb
line wrap: on
line source
-- WorldPlan
-- QuestPOI.lua
-- Created: 10/1/2016 7:21 PM
-- %file-revision%
--
local _, db = ...

local TQ_GetQuestInfoByQuestID = C_TaskQuest.GetQuestInfoByQuestID -- Return the name of a quest with a given ID
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 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 function() end
local qprint = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or function() end
local wprint = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or function() end
local wqprint = DEVIAN_WORKSPACE and function(...) _G.print('WorldQuests', ...) end or function() end
local iprint = DEVIAN_WORKSPACE and function(...) _G.print('ItemScan', ...) end or function() end
local rprint = DEVIAN_WORKSPACE and function(...) _G.print('WQRefresh', ...) end or function() end
local QuestPOI = WorldPlanPOIMixin


local PIN_REFRESH_DELAY = .5
local PIN_REQUEST_DELAY = .2
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
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 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 STYLE_TYPE_PENDING = 768


-- Pin color/display variables
db.TooltipExtras = db.TooltipExtras or {} -- idiot-proofing


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

    WorldMapTooltip:AddLine(" ")
    WorldMapTooltip:AddLine("Achievements:")
    WorldMapTooltip:AddLine(' |T'..icon..':20:20|t '..name)

    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 numNeeded >= 1 then
      for i, line in ipairs(tooltipLines) do
        WorldMapTooltip:AddLine(line)
      end
    else
      WorldMapTooltip:AddLine('Criteria completed!', 0, 1, 0)
    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

local GetFactionInfoByID, GetQuestObjectiveInfo = GetFactionInfoByID, GetQuestObjectiveInfo

function QuestPOI:OnEnter()
  if not WorldMapFrame:IsVisible() then
    WorldMap_HijackTooltip(self.owningFrame)
  else
    if self.filtered then
      return
    end
  end
  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
  WorldMap_AddQuestRewardsToTooltip(questID)

  self.MouseGlow:Show()
  WorldMapTooltip:Show()
  --WorldMapTooltip.recalculatePadding = true;
  --print(WorldMapTooltip:GetParent())
  --print(WorldMapTooltip:IsVisible())
end
function QuestPOI:OnLeave()
  WorldMap_RestoreTooltip()
  self.MouseGlow:Hide()
  WorldMapTooltip:Hide();
end

-- attempt to pull pin data
local GetQuestTagInfo, GetProfessionInfo = GetQuestTagInfo, GetProfessionInfo
function QuestPOI:GetData ()
  qprint('|cFF00FF88'..self:GetName()..':GetWorldQuestInfo()|r')
  local questID = self.questID
  if not questID then
    rprint('|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
    self.isPending = true
    rprint('|cFFBB8844nodata|r|cFF00FFFF', self.questId)
  else
    self.title, self.factionID, self.capped = questTitle, factionID, capped
    rprint('|cFFBB8844  data|r|cFF00FFFF', (self.isPending and 'late|r' or 'jit|r'), self.title, '|r', self.factionID)
    -- 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


    self:SetRewardInfo()

    -- force throttle on success
    --qprint('  |cFF00FFFF'..questID..'|r hasUpdate:', hasUpdate, 'isPending:', isPending, 'isShown', self:IsShown())
    --qprint('  ', 'rewardType:', self.rewardType, 'tag:', self.tagID)
    qprint('  ', tostring(self.title), " |T"..tostring(self.itemTexture)..":12:12|t", tostring(self.itemName))

    if self.itemTexture and self.itemName and self.title then
      self.isPending = nil
      self.throttle = 1
      self.updateRate = PIN_REFRESH_DELAY
    end
  end

  self.isCriteria = WorldMapFrame.UIElementsFrame.BountyBoard:IsWorldQuestCriteriaForSelectedBounty(questID)

  return self.isStale, self.isPending
end

local GetNumQuestLogRewards, GetNumQuestLogRewardCurrencies, HaveQuestData = GetNumQuestLogRewards, GetNumQuestLogRewardCurrencies, HaveQuestData
local GetQuestLogRewardMoney, GetQuestLogRewardCurrencyInfo, GetMoneyString = GetQuestLogRewardMoney, GetQuestLogRewardCurrencyInfo, GetMoneyString
function QuestPOI:SetRewardInfo()
  local questID = self.questID
  if not HaveQuestData(questID) then
    self.isPending = true
  else

    local rewardIcon, rewardName, rewardCount, rewardStyle, rewardType, itemID, quantity, quality
    -- 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
      rewardIcon = ICON_MONEY
      rewardName = GetMoneyString(money)
      rewardType = REWARD_CASH
    end

  print('  '..self.questID..':|cFFFFFF00SetRewardInfo():', rewardType)
    self.itemNumber = tonumber(rewardCount or self.itemNumber)
    self.rewardType = rewardType or REWARD_GEAR
    self.quality = quality

    self.itemTexture = rewardIcon or self.itemTexture
    self.itemName = rewardName or self.itemName

    -- flag unresolved info
    if not (rewardIcon and rewardName) then
      self.isPending = true
      return true, nil
      --WorldPlan:print('|cFFFFFF00'..tostring(self.title)..'|r waiting on texture info')
    else
      if (rewardIcon and rewardName) and self.isPending then
        --WorldPlan:print('|cFF00FF00'..tostring(self.title)..'|r has info', rewardIcon, rewardName)
        self.isStale = true
      end
      self.isPending = nil
    end

  end
  return self.isStale, self.isPending

end

-- run from OnShow if .isNew is set
function QuestPOI:OnNew()

  if not self.isAnimating then
    --qprint('|cFFFFFF00'.. self.title .. ' added to quest log.')
    self:SetAlpha(0)
    if db.Config.FadeWhileGrouped then
      self.FadeIn.FadeIn:SetToAlpha(0.15)
      self.PendingFade.FadeIn:SetToAlpha(0.15)
      self.PendingFade.FadeOut:SetFromAlpha(0.15)
    else
      self.FadeIn.FadeIn:SetToAlpha(1)
      self.PendingFade.FadeIn:SetToAlpha(1)
      self.PendingFade.FadeOut:SetFromAlpha(1)
    end
    self.isAnimating = true
    self.isNew = nil
    self.isStale = true
    self.FadeIn:Play()
  end
end

function QuestPOI:OnShow ()
  -- pop this on principle

  if self.isNew or self.isStale then
    self:Refresh()
  end


  -- is it a new quest?
  if self.isNew then
    qprint('|cFFFFFF00'..tostring(self:GetName())..':OnShow()|r update:', self.isStale, 'new:', self.isNew, 'animation:', self.isAnimating)
    --qprint('|cFFFFFF00popping new pin handler')
    self:OnNew()
  elseif not self.isAnimating then
    self:SetAlpha(1)
  end

  self.Overlay:SetShown(true)
  --WorldPlan:print(self:GetAlpha())

end
function QuestPOI:OnHide()
  --qprint('|cFFFFFF00["'..tostring(self.title)..'"]|r:OnHide()')
  if not self:IsShown() then
    self.isAnimating = nil
    self:SetAlpha(1)
  end

  self.Overlay:SetShown(false)
end

function QuestPOI:SetAnchor(frame, mapID, mapWidth, mapHeight)
  qprint('  |cFF00FF00'..self:GetName()..':SetAnchor()|r', self.questID, mapID)
  self:ClearAllPoints()
  local dX, dY = TQ_GetQuestLocation(self.questID)
  if not dX or dX == 0 then
    local _, x, y = QuestPOIGetIconInfo(self.questID)
    if x and floor(x) ~= 0 then
      dX, dY = x, y
    else
      dX, dY = self.x, self.y
    end
  end
  local oX, oY = self.x, self.y
  self.x = dX
  self.y = dY


  local pX = (dX * mapWidth)
  local pY = (-dY * mapHeight)

  if oX ~= dX then
    wqprint('  |cFF00FF00'..self.questID..':|r', oX, dX, format("%0.2f %0.2f", pX, pY))
  end

  self:SetParent(WorldMapPOIFrame)
  self:SetPoint('CENTER', frame, 'TOPLEFT', pX, pY)
end

function QuestPOI:OnLoad()
  qprint('|cFF00FF88'..self:GetName()..':OnLoad()|r',db.Config)
  self:RegisterEvent('SUPER_TRACKED_QUEST_CHANGED')

  self.title = '|cFF0088FF' .. RETRIEVING_DATA..'|r'
  self.isPending = true
  self.count = self.Overlay.count
  self.timeLabel = self.Overlay.timeLabel
  self.updateRate = PIN_REQUEST_DELAY
  self.itemName = '|cFF0088FF' .. RETRIEVING_DATA..'|r'

  self:SetScript('OnMouseDown', TaskPOI_OnClick)
end

function QuestPOI:OnEvent(event, ...)
  if event == 'SUPER_TRACKED_QUEST_CHANGED' then
    self.isStale = true
  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
  if self.isNew then
    print('|cFFFFFF00push new poi stuff')
    self:OnNew()
  elseif (self.isStale or (not self.title)) and not self.isAnimating then
    wprint('|cFFFFFF00push poi update')
    self:Refresh()
    return
  end

  -- query for reward data if it wasn't found in the original scan
  local questID = self.questID
  if self.isPending then
      self:GetData()
    if not (self.PendingFade:IsPlaying() or self.isAnimating) then
      self.PendingFade:Play()
    end
    return
  else
    if self.PendingFade:IsPlaying() then
      self.PendingFade:Stop()
    end
  end


  -- update time elements
  if TQ_IsActive(self.questID) then

    local tl = self.alertLevel
    local timeLeft = TQ_GetQuestTimeLeftMinutes(questID)
    if timeLeft > 0 then

      local text, timeState = WorldPlan:GetTimeInfo(timeLeft, self.maxAlertLevel)
      if tl ~= timeState then
        tl = timeState
        self.timeLabel:SetText(text)
      end
    else
      if self.worldQuestType ~= LE_QUEST_TAG_TYPE_PROFESSION then
        self:SetShown(false)
      end
    end
    self.alertLevel = tl
  end
  self.timeLabel:SetShown(self.worldQuest and (self.maxAlertLevel >= 1))
end



function QuestPOI:Refresh ()
  print('|cFF00FF88'..self:GetName()..'|r:Refresh()')

  local styleType = (self.isPending and STYLE_TYPE_PENDING) or self.rewardType
  local style,subStyle =  self:GetTypeInfo(self.rewardType)
  if self.filtered then
    subStyle = style.minimized
  end
  self.style = style
  self.subStyle = subStyle
  --print(style, subStyle)
  self.currentWidth = subStyle.iconWidth
  self.borderWidth = subStyle.borderWidth
  self.highlightWidth = subStyle.highlightWidth
  self.tagSize = subStyle.TagSize
  self.maxAlertLevel = subStyle.maxAlertLevel
  self.NoIcon = subStyle.NoIcon

  local questID = self:GetID()
  local iconBorder = self.RewardBorder
  local trackingBorder = self.HighlightBorder
  local icon = self.icon
  local count = self.count
  --WorldPlan:print(tostring(self.title), "|T"..tostring(self.itemTexture)..":16:16|t", tostring(self.itemName))

  if self.itemName then
      --wqprint('filtered:', self.filtered, 'showNumber:', self.showNumber)
      if self.itemNumber and self.itemNumber >= 1000 then
        local numeral = floor(self.itemNumber/1000)
        local decimal = mod(self.itemNumber, 1000)
        local numberString = numeral
        if decimal > 100 then
          numberString = numberString .. '.' .. tostring(floor(decimal/100))
        end
        numberString = numberString .. 'k'
        self.count:SetText(numberString)
      else
        self.count:SetText(self.itemNumber)
      end


  end
  icon:SetMask("Interface\\Minimap\\UI-Minimap-Background")
  if self.itemTexture then
    iconBorder:SetTexture(WORLD_QUEST_BORDER)

    if self.NoIcon then
      icon:SetTexture(PENDING_ICON)
      icon:SetDesaturated(true)
      icon:SetVertexColor(style.r, style.g, style.b, style.a)
    else

      icon:SetTexture(self.itemTexture)
      icon:SetDesaturated(false)
      icon:SetVertexColor(1, 1, 1)
    end
  else
    iconBorder:SetTexture(PENDING_BORDER)
    icon:SetTexture(PENDING_ICON)
    icon:SetDesaturated(true)
    icon:SetVertexColor(style.r, style.g, style.b, style.a)
  end

  local borderStyle = style
  if self.rarity and WORLD_QUEST_QUALITY_COLORS[self.rarity] then
    borderStyle = WORLD_QUEST_QUALITY_COLORS[self.rarity]
  end

  iconBorder:SetVertexColor(borderStyle.r, borderStyle.g, borderStyle.b, 1)
  iconBorder:SetDesaturated(true)
  iconBorder:SetAlpha(subStyle.alpha or 1)

  if questID == GetSuperTrackedQuestID() then
    trackingBorder:SetVertexColor(0,0,0,1)
  else
    trackingBorder:SetVertexColor(0,0,0,0.5)
  end

  self.tagIcon:SetShown(self.tagSize and true or false)
  self.tagIcon:SetAtlas(self.tagAtlas)
  self.tagIcon:SetAlpha(subStyle.alpha or 1)
  self.EliteBorder:SetShown(self.isElite and not self.filtered)
  self.Overlay:SetShown(self:IsShown())
  self.Overlay:SetParent(self:GetParent())
  self.Overlay:SetFrameLevel(self:GetFrameLevel()+200)
  self.Overlay:SetAllPoints(self)


  self:UpdateSize()
  self.isStale = nil
end

local cvar_check = {
  [REWARD_CASH] = 'worldQuestFilterGold',
  [REWARD_ARTIFACT_POWER] = 'worldQuestFilterArtifactPower',
  [REWARD_CURRENCY] = 'worldQuestFilterOrderResources',
  [REWARD_REAGENT]= 'worldQuestFilterProfessionMaterials',
  [REWARD_GEAR] = 'worldQuestFilterEquipment',
}


function QuestPOI:IsFiltered ()
  local filtered
  local usingFilters
  for filterKey, value in pairs(db.UsedFilters) do
    usingFilters = true
    print('|cFFFF4400', filterKey, self[filterKey])
    if self[filterKey] ~= value then
      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
  return filtered
end

function QuestPOI:IsShowable ()
  local print = qprint
  local qType = self.worldQuestType

  if not self.worldQuest then
    print('ignoring showable check')
    return self.used, self.filtered
  end
  self.used = TQ_IsActive(self.questID)

  if qType == LE_QUEST_TAG_TYPE_PROFESSION then
    qprint('hide flags:', (not self.isKnownProfession), (db.Config.ShowAllProfessionQuests == false))
    if (not self.isKnownProfession) and  (db.Config.ShowAllProfessionQuests == false) then
      qprint(self.used)
      self.used = nil
      qprint(self.used)
    end
  end
  print('  '..self.questID..':|cFFFFFF00IsShowable()|r ', self.used, self.title)
  return self.used
end

function QuestPOI:UpdateTimer (timeLeft, timeType)
  print('|cFF0088FFUpdatePinTimer()|r')
end

--- Fixes icons upon size update
function QuestPOI:UpdateSize ()

  qprint('|cFF00FF88'..self:GetName()..'|r:UpdateSize()', self.style, self.subStyle)

  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.tagIcon:SetSize(self.tagSize, self.tagSize)
  self:SetSize(iconWidth, iconWidth)
  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 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
  end

  self.count:SetShown((subStyle.showNumber and self.itemNumber) and style.hasNumeric)


end