SavedInstances

SavedInstances

13M Downloads

Change emissary displays to keep completed quests

Eiltherune opened this issue ยท 0 comments

commented

I love how you got the emissaries to display, but I didn't like how the line disappeared (or was left blank) when a character completed the quest. I tweaked the code a little so that it now shows a question mark when the quest is ready to turn-in and a checkmark when the quest has been completed. I also added in compatibility for users who had already completed an emissary quest prior to updating (it defaults to showing it as completed, with "Emissary Missing" as the name).

Here are my changes (explained in the comments):

function core:RefreshDailyWorldQuestInfo()
  local t = vars.db.Toons[thisToon]
  t.DailyWorldQuest = {}
  local BountyQuest = GetQuestBountyInfoForMapID(1014)
  for BountyIndex, BountyInfo in ipairs(BountyQuest) do
    local title = GetQuestLogTitle(GetQuestLogIndexByID(BountyInfo.questID))
    local timeleft = C_TaskQuest.GetQuestTimeLeftMinutes(BountyInfo.questID)
    local _, _, isFinish, questDone, questNeed = GetQuestObjectiveInfo(BountyInfo.questID, 1, false)
    if timeleft then											-- Changed to only use timeleft
      if timeleft > 2880 then
        if t.DailyWorldQuest.days2 then else t.DailyWorldQuest.days2 = {} end				-- Don't nil the data if the quest is complete
        t.DailyWorldQuest.days2.name = title
        t.DailyWorldQuest.days2.dayleft = 2
        t.DailyWorldQuest.days2.questneed = questNeed
        t.DailyWorldQuest.days2.questdone = questDone
        t.DailyWorldQuest.days2.isfinish = isFinish							-- Needed for question mark indicator
        t.DailyWorldQuest.days2.iscompleted = IsQuestFlaggedCompleted(BountyInfo.questID)		-- Needed for checkmark indicator
      elseif timeleft > 1440 then
        if t.DailyWorldQuest.days1 then else t.DailyWorldQuest.days1 = {} end				-- Don't nil the data if the quest is complete
        t.DailyWorldQuest.days1.name = title
        t.DailyWorldQuest.days1.dayleft = 1
        t.DailyWorldQuest.days1.questneed = questNeed
        t.DailyWorldQuest.days1.questdone = questDone
        t.DailyWorldQuest.days1.isfinish = isFinish							-- Needed for question mark indicator
        t.DailyWorldQuest.days1.iscompleted = IsQuestFlaggedCompleted(BountyInfo.questID)		-- Needed for checkmark indicator
      else
        if t.DailyWorldQuest.days0 then else t.DailyWorldQuest.days0 = {} end				-- Don't nil the data if the quest is complete
        t.DailyWorldQuest.days0.name = title
        t.DailyWorldQuest.days0.dayleft = 0
        t.DailyWorldQuest.days0.questneed = questNeed
        t.DailyWorldQuest.days0.questdone = questDone
        t.DailyWorldQuest.days0.isfinish = isFinish							-- Needed for question mark indicator
        t.DailyWorldQuest.days0.iscompleted = IsQuestFlaggedCompleted(BountyInfo.questID)		-- Needed for checkmark indicator
      end
    end
  end
-- This section enables backwards compatibility by using placeholder names and a forced "true" for completion
  if IsQuestFlaggedCompleted(43341) then
    if t.DailyWorldQuest.days0 == nil then
      t.DailyWorldQuest.days0 = {}
      t.DailyWorldQuest.days0.dayleft = 0
      t.DailyWorldQuest.days0.iscompleted = true
      t.DailyWorldQuest.days0.name = "Emissary Missing"
    end
    if t.DailyWorldQuest.days1 == nil then
      t.DailyWorldQuest.days1 = {}
      t.DailyWorldQuest.days1.dayleft = 1
      t.DailyWorldQuest.days1.iscompleted = true
      t.DailyWorldQuest.days1.name = "Emissary Missing"
    end
    if t.DailyWorldQuest.days2 == nil then
      t.DailyWorldQuest.days2 = {}
      t.DailyWorldQuest.days2.dayleft = 2
      t.DailyWorldQuest.days2.iscompleted = true
      t.DailyWorldQuest.days2.name = "Emissary Missing"
    end
  end
end
  if vars.db.Tooltip.DailyWorldQuest then
    local show = {}
    for toon, t in cpairs(vars.db.Toons, true) do
      if t.DailyWorldQuest then
        for day,DailyInfo in pairs(t.DailyWorldQuest) do
          if DailyInfo.name then
            show[DailyInfo.dayleft] = DailyInfo.name
            addColumns(columns, toon, tooltip)
          end
        end
      end
    end
    for dayleft = 0 , 2 do
      if show[dayleft] then
        local showday = show[dayleft]
        if not firstcategory and vars.db.Tooltip.CategorySpaces then
          addsep()
        end
        show[dayleft] = tooltip:AddLine(YELLOWFONT .. showday .. " (+" .. dayleft .. " " .. L["Day"] .. ")" .. FONTEND)				-- The lack of spaces bothered me. Sorry.
      end
    end
    for toon, t in cpairs(vars.db.Toons, true) do
      if t.DailyWorldQuest then
        for day,DailyInfo in pairs(t.DailyWorldQuest) do
          if show[DailyInfo.dayleft] then
            local col = columns[toon..1]
            if DailyInfo.iscompleted == true then
              tooltip:SetCell(show[DailyInfo.dayleft], col, "\124T"..READY_CHECK_READY_TEXTURE..":0|t", "CENTER", maxcol)				-- If the emissary is completed (turned in), show a checkmark
            elseif DailyInfo.isfinish == true then
              tooltip:SetCell(show[DailyInfo.dayleft], col, "\124T"..READY_CHECK_WAITING_TEXTURE..":0|t", "CENTER", maxcol)				-- If the emissary is finished (not turned in), show a question mark
            else
              tooltip:SetCell(show[DailyInfo.dayleft], col, DailyInfo.questdone .. "/" .. DailyInfo.questneed , "CENTER",maxcol)				-- Otherwise, show the numbers
            end
          end
        end
      end
    end
  end