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.

118 lines
3.5 KiB

4 years ago
--- Kaliel's Tracker
--- Copyright (c) 2012-2026, Marouan Sabbagh <mar.sabbagh@gmail.com>
4 years ago
--- All Rights Reserved.
---
--- This file is part of addon Kaliel's Tracker.
6 months ago
---@type KT
4 years ago
local addonName, KT = ...
6 months ago
---@class QuestLog
local M = KT:NewModule("QuestLog")
4 years ago
KT.QuestLog = M
local _DBG = function(...) if _DBG then _DBG("KT", ...) end end
local db, dbChar
4 years ago
local dropDownFrame
6 months ago
-- Internal ------------------------------------------------------------------------------------------------------------
4 years ago
local function QuestMapQuestOptionsDropDown_Initialize(self)
local info = KT.Menu_CreateInfo()
KT.Menu_AddTitle(C_QuestLog.GetTitleForQuestID(self.questID))
local text, func
if C_SuperTrack.GetSuperTrackedQuestID() ~= self.questID then
text = SUPER_TRACK_QUEST
func = function()
C_SuperTrack.SetSuperTrackedQuestID(self.questID)
end
else
text = STOP_SUPER_TRACK_QUEST
func = function()
C_SuperTrack.SetSuperTrackedQuestID(0)
end
end
KT.Menu_AddButton(text, func)
KT.Menu_AddButton(QuestUtils_IsQuestWatched(self.questID) and UNTRACK_QUEST or TRACK_QUEST, function()
QuestMapQuestOptions_TrackQuest(self.questID)
end, (dbChar.filterAuto[1] ~= nil))
4 years ago
info.disabled = false
4 years ago
KT.Menu_AddButton(SHARE_QUEST, function()
QuestMapQuestOptions_ShareQuest(self.questID)
end, (not C_QuestLog.IsPushableQuest(self.questID) or not IsInGroup()))
4 years ago
info.disabled = false
4 years ago
if C_QuestLog.CanAbandonQuest(self.questID) then
KT.Menu_AddButton(ABANDON_QUEST, function()
QuestMapQuestOptions_AbandonQuest(self.questID)
end)
end
4 years ago
KT:SendSignal("CONTEXT_MENU_UPDATE", info, "quest", self.questID)
end
4 years ago
local function SetHooks()
-- DropDown - QuestMapFrame.lua
function QuestMapLogTitleButton_OnClick(self, button) -- R
if ChatFrameUtil.TryInsertQuestLinkForQuestID(self.questID) then
4 years ago
return;
end
PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON);
if IsShiftKeyDown() then
self:ToggleTracking();
4 years ago
else
local isDisabledQuest = C_QuestLog.IsQuestDisabledForSession(self.questID);
4 years ago
if not isDisabledQuest and button == "RightButton" then
if ( self.questID ~= dropDownFrame.questID ) then
MSA_CloseDropDownMenus();
end
dropDownFrame.questID = self.questID;
MSA_ToggleDropDownMenu(1, nil, dropDownFrame, "cursor", 6, -6);
4 years ago
elseif button == "LeftButton" then
if IsModifiedClick(db.menuWowheadURLModifier) then
KT:Alert_WowheadURL("quest", self.questID)
elseif IsModifiedClick(db.menuYouTubeURLModifier) then
KT:Alert_YouTubeURL("quest", self.questID)
4 years ago
else
QuestMapFrame_ShowQuestDetails(self.questID);
end
end
end
end
6 months ago
hooksecurefunc("QuestMapQuestOptions_TrackQuest", function(questID)
if db.questAutoFocusClosest and not C_SuperTrack.GetSuperTrackedQuestID() then
KT.QuestSuperTracking_ChooseClosestQuest()
end
end)
4 years ago
end
local function SetFrames()
-- DropDown frame
dropDownFrame = MSA_DropDownMenu_Create(addonName.."QuestLogDropDown", QuestMapFrame)
dropDownFrame.questID = 0 -- for QuestMapQuestOptionsDropDown_Initialize
MSA_DropDownMenu_Initialize(dropDownFrame, QuestMapQuestOptionsDropDown_Initialize, "MENU")
end
6 months ago
-- External ------------------------------------------------------------------------------------------------------------
4 years ago
function M:OnInitialize()
_DBG("|cffffff00Init|r - "..self:GetName(), true)
db = KT.db.profile
dbChar = KT.db.char
self.isAvailable = true
if self.isAvailable then
SetHooks()
SetFrames()
end
4 years ago
end