You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
150 lines
5.0 KiB
150 lines
5.0 KiB
QuillsObjectiveTracker = LibStub("AceAddon-3.0"):NewAddon("QuillsObjectiveTracker", "AceConsole-3.0", "AceEvent-3.0" );
|
|
|
|
function QuillsObjectiveTracker:OnInitialize()
|
|
-- Called when the addon is loaded
|
|
|
|
-- Print a message to the chat frame
|
|
self:Print("OnInitialize Event Fired: Hello")
|
|
self.quests = {}
|
|
end
|
|
|
|
function QuillsObjectiveTracker:OnEnable()
|
|
-- Called when the addon is enabled
|
|
|
|
-- Print a message to the chat frame
|
|
self:Print("OnEnable Event Fired: Hello, again ;)")
|
|
self:CreateQuestFrame()
|
|
end
|
|
|
|
function QuillsObjectiveTracker:OnDisable()
|
|
-- Called when the addon is disabled
|
|
end
|
|
|
|
QuillsObjectiveTracker.QuestTrackerFrame = nil
|
|
|
|
function QuillsObjectiveTracker:CreateQuestFrame()
|
|
quest_tracker_frame = CreateFrame("Frame", "QOL_Quests", UIParent)
|
|
quest_tracker_frame:Hide()
|
|
|
|
quest_tracker_frame:SetFrameStrata("LOW")
|
|
quest_tracker_frame:SetWidth(250)
|
|
quest_tracker_frame:SetHeight(310)
|
|
quest_tracker_frame:SetPoint("CENTER")
|
|
quest_tracker_frame:SetMovable(true)
|
|
quest_tracker_frame:EnableMouse(true)
|
|
quest_tracker_frame:RegisterForDrag("LeftButton")
|
|
quest_tracker_frame:SetScript("OnDragStart", quest_tracker_frame.StartMoving)
|
|
quest_tracker_frame:SetScript("OnDragStop", quest_tracker_frame.StopMovingOrSizing)
|
|
|
|
local dialogbg = quest_tracker_frame:CreateTexture()
|
|
dialogbg:SetAllPoints(quest_tracker_frame)
|
|
dialogbg:SetColorTexture(0.06, 0.06, 0.06, 0.92)
|
|
|
|
local titlebg = quest_tracker_frame:CreateTexture(nil, "BORDER")
|
|
titlebg:SetTexture(251966) --"Interface\\PaperDollInfoFrame\\UI-GearManager-Title-Background"
|
|
titlebg:SetPoint("TOPLEFT", 9, -6)
|
|
titlebg:SetPoint("BOTTOMRIGHT", quest_tracker_frame, "TOPRIGHT", -28, -24)
|
|
|
|
local close = CreateFrame("Button", nil, quest_tracker_frame, "UIPanelCloseButton")
|
|
close:SetPoint("TOPRIGHT", 2, 1)
|
|
close:SetScript("OnClick", QuillsObjectiveTracker.Close)
|
|
|
|
local minimise = CreateFrame("Button", nil, quest_tracker_frame, "UIPanelCloseButton")
|
|
minimise:SetPoint("TOPRIGHT", close, "TOPLEFT", 2, 0)
|
|
minimise:SetScript("OnClick", QuillsObjectiveTracker.Close)
|
|
|
|
sessionLabel = CreateFrame("Button", nil, quest_tracker_frame)
|
|
sessionLabel:SetNormalFontObject("GameFontNormalLeft")
|
|
sessionLabel:SetHighlightFontObject("GameFontHighlightLeft")
|
|
sessionLabel:SetPoint("TOPLEFT", titlebg, 6, -1)
|
|
sessionLabel:SetPoint("BOTTOMRIGHT", titlebg, "BOTTOMRIGHT", -26, 1)
|
|
sessionLabel:SetScript("OnHide", function()
|
|
quest_tracker_frame:StopMovingOrSizing()
|
|
end)
|
|
|
|
sessionLabel:SetScript("OnDoubleClick", function()
|
|
-- Open Quest Log
|
|
end)
|
|
|
|
local total_entries, numQuests = C_QuestLog.GetNumQuestLogEntries()
|
|
local watched_quests = C_QuestLog.GetNumQuestWatches()
|
|
|
|
sessionLabel:SetText(("Quests - %d/%d"):format(numQuests, MAX_QUESTS))
|
|
|
|
local scroll = CreateFrame("ScrollFrame", "QOL_Quests_Scroll", quest_tracker_frame, "UIPanelScrollFrameTemplate")
|
|
scroll:SetPoint("TOPLEFT", sessionLabel, "BOTTOMLEFT", 4, -4)
|
|
scroll:SetPoint("BOTTOMRIGHT", -4, 4)
|
|
scroll:SetClipsChildren(true)
|
|
--scroll:EnableMouseWheel(true)
|
|
|
|
scroll_items = CreateFrame("Frame", "QOL_Quests_ScrollItems", scroll)
|
|
scroll_items:SetWidth(250)
|
|
scroll_items:SetHeight(0)
|
|
local scroll_bg = scroll_items:CreateTexture()
|
|
scroll_bg:SetAllPoints(scroll_items)
|
|
scroll_bg:SetColorTexture(1, 0.06, 0.06, 0.92)
|
|
|
|
scroll_items.quests = {}
|
|
|
|
local flip = true
|
|
for i=1, watched_quests do
|
|
local quest_id = C_QuestLog.GetQuestIDForQuestWatchIndex(i)
|
|
local quest_log_index = C_QuestLog.GetLogIndexForQuestID(quest_id)
|
|
local quest_info = C_QuestLog.GetInfo(quest_log_index)
|
|
local numQuestLogLeaderBoards = GetNumQuestLeaderBoards(quest_id)
|
|
local isInArea, isOnMap, numObjectives = GetTaskInfo(quest_id)
|
|
self:Print(quest_info.title)
|
|
self:Print(numQuestLogLeaderBoards)
|
|
if numQuestLogLeaderBoards ~= nil then
|
|
for j=1, numQuestLogLeaderBoards do
|
|
local text, objectiveType, finished = GetQuestObjectiveInfo(quest_id, objectiveIndex, Boolean)
|
|
self:Print(text, objectiveType, finished)
|
|
end
|
|
end
|
|
|
|
local current_height = scroll_items:GetHeight()
|
|
|
|
new_entry = CreateFrame("Button", nil, scroll_items)
|
|
|
|
scroll_items.quests[i] = new_entry
|
|
new_entry:SetNormalFontObject("GameFontNormalLeft")
|
|
new_entry:SetHighlightFontObject("GameFontHighlightLeft")
|
|
new_entry:SetText(quest_info.title)
|
|
font = new_entry:GetFontString()
|
|
new_entry:SetHeight(font:GetStringHeight()+4)
|
|
new_entry:SetWidth(250)
|
|
|
|
if i == 1 then
|
|
new_entry:SetPoint("TOPLEFT", 5, 0)
|
|
else
|
|
new_entry:SetPoint("TOPLEFT", scroll_items.quests[i-1], "BOTTOMLEFT", 0, 0)
|
|
end
|
|
|
|
local bg = new_entry:CreateTexture()
|
|
bg:SetAllPoints(new_entry)
|
|
if flip then
|
|
bg:SetColorTexture(0.06, 1, 0.06, 0.92)
|
|
else
|
|
bg:SetColorTexture(0.06, 0.06, 1, 0.92)
|
|
end
|
|
|
|
flip = not flip
|
|
|
|
new_entry:Show()
|
|
|
|
local new_height = current_height + new_entry:GetHeight()
|
|
--self:Print(current_height, new_height)
|
|
scroll_items:SetHeight(new_height)
|
|
end
|
|
|
|
scroll:SetScrollChild(scroll_items)
|
|
quest_tracker_frame:Show()
|
|
end
|
|
|
|
function QuillsObjectiveTracker:Close()
|
|
--quest_tracker_frame:Hide()
|
|
end
|
|
|
|
function QuillsObjectiveTracker:AddQuest(title)
|
|
|
|
end
|