Last active
November 15, 2020 16:18
-
-
Save Wetxius/a5dee2b382feb301df55d80fae15b73c to your computer and use it in GitHub Desktop.
ShestakUI\Modules\Quests\ObjectiveTracker.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local T, C, L, _ = unpack(select(2, ...)) | |
---------------------------------------------------------------------------------------- | |
-- Move ObjectiveTrackerFrame and hide background | |
---------------------------------------------------------------------------------------- | |
local frame = CreateFrame("Frame", "ObjectiveTrackerAnchor", UIParent) | |
frame:SetPoint(unpack(C.position.quest)) | |
frame:SetSize(224, 150) | |
ObjectiveTrackerFrame:ClearAllPoints() | |
ObjectiveTrackerFrame:SetPoint("TOPLEFT", frame, "TOPLEFT", 20, 0) | |
ObjectiveTrackerFrame:SetHeight(T.screenHeight / 1.6) | |
ObjectiveTrackerFrame.IsUserPlaced = function() return true end | |
local headers = { | |
ObjectiveTrackerBlocksFrame.CampaignQuestHeader, | |
ObjectiveTrackerBlocksFrame.QuestHeader, | |
ObjectiveTrackerBlocksFrame.ScenarioHeader, | |
ObjectiveTrackerBlocksFrame.AchievementHeader, | |
BONUS_OBJECTIVE_TRACKER_MODULE.Header, | |
WORLD_QUEST_TRACKER_MODULE.Header, | |
ObjectiveTrackerFrame.BlocksFrame.UIWidgetsHeader | |
} | |
for i = 1, #headers do | |
local header = headers[i] | |
if header then | |
header.Background:Hide() | |
end | |
end | |
ObjectiveTrackerFrame.HeaderMenu.Title:SetAlpha(0) | |
local taintWarned = false | |
---------------------------------------------------------------------------------------- | |
-- Skin ObjectiveTrackerFrame item buttons | |
---------------------------------------------------------------------------------------- | |
local function SkinItemButton(_, block) | |
local item = block.itemButton | |
if item and not item.skinned then | |
item:SetSize(C.actionbar.button_size, C.actionbar.button_size) | |
item:SetTemplate("Default") | |
item:StyleButton() | |
item:SetNormalTexture(nil) | |
item.icon:SetTexCoord(0.1, 0.9, 0.1, 0.9) | |
item.icon:SetPoint("TOPLEFT", item, 2, -2) | |
item.icon:SetPoint("BOTTOMRIGHT", item, -2, 2) | |
item.Cooldown:SetAllPoints(item.icon) | |
item.Count:ClearAllPoints() | |
item.Count:SetPoint("TOPLEFT", 1, -1) | |
item.Count:SetFont(C.font.action_bars_font, C.font.action_bars_font_size, C.font.action_bars_font_style) | |
item.Count:SetShadowOffset(C.font.action_bars_font_shadow and 1 or 0, C.font.action_bars_font_shadow and -1 or 0) | |
item.HotKey:SetFontObject(NumberFont_OutlineThick_Mono_Small) | |
item.skinned = true | |
end | |
-- taint check | |
local isSecure, addon = issecurevariable(block, "id") | |
if not isSecure and not taintWarned then | |
if not IsAddOnLoaded("!QuestItemButtonFix") then | |
print("Quest Tracker tainted by " .. tostring(addon)) | |
end | |
taintWarned = true | |
end | |
end | |
hooksecurefunc(QUEST_TRACKER_MODULE, "SetBlockHeader", SkinItemButton) | |
hooksecurefunc(WORLD_QUEST_TRACKER_MODULE, "AddObjective", SkinItemButton) | |
hooksecurefunc(CAMPAIGN_QUEST_TRACKER_MODULE, "AddObjective", SkinItemButton) | |
hooksecurefunc("QuestObjectiveSetupBlockButton_AddRightButton", function(block, button) | |
if button and button.GetPoint then | |
local a, b, c, d, e = button:GetPoint() | |
if block.groupFinderButton and b == block.groupFinderButton and block.itemButton and button == block.itemButton then | |
button:SetPoint(a, b, c, d - 1, e) | |
end | |
end | |
end) | |
hooksecurefunc("QuestObjectiveSetupBlockButton_FindGroup", function(block) | |
if block.hasGroupFinderButton and block.groupFinderButton and not block.groupFinderButton.styled then | |
block.groupFinderButton:SetSize(21, 21) | |
block.groupFinderButton:SkinButton() | |
block.groupFinderButton.styled = true | |
end | |
end) | |
---------------------------------------------------------------------------------------- | |
-- Difficulty color for ObjectiveTrackerFrame lines | |
---------------------------------------------------------------------------------------- | |
hooksecurefunc(QUEST_TRACKER_MODULE, "Update", function() | |
for i = 1, C_QuestLog.GetNumQuestWatches() do | |
local questID = C_QuestLog.GetQuestIDForQuestWatchIndex(i) | |
if not questID then | |
break | |
end | |
local col = GetDifficultyColor(C_PlayerInfo.GetContentDifficultyQuestForPlayer(questID)) | |
local block = QUEST_TRACKER_MODULE:GetExistingBlock(questID) | |
if block then | |
block.HeaderText:SetTextColor(col.r, col.g, col.b) | |
block.HeaderText.col = col | |
end | |
end | |
end) | |
hooksecurefunc(DEFAULT_OBJECTIVE_TRACKER_MODULE, "AddObjective", function(_, block) | |
if block.module == ACHIEVEMENT_TRACKER_MODULE then | |
block.HeaderText:SetTextColor(0.75, 0.61, 0) | |
block.HeaderText.col = nil | |
end | |
end) | |
hooksecurefunc("ObjectiveTrackerBlockHeader_OnLeave", function(self) | |
local block = self:GetParent() | |
if block.HeaderText.col then | |
block.HeaderText:SetTextColor(block.HeaderText.col.r, block.HeaderText.col.g, block.HeaderText.col.b) | |
end | |
end) | |
---------------------------------------------------------------------------------------- | |
-- Skin ObjectiveTrackerFrame.HeaderMenu.MinimizeButton | |
---------------------------------------------------------------------------------------- | |
if C.skins.blizzard_frames == true then | |
local button = ObjectiveTrackerFrame.HeaderMenu.MinimizeButton | |
button:SetSize(17, 17) | |
button:StripTextures() | |
button:SetTemplate("Overlay") | |
button.minus = button:CreateTexture(nil, "OVERLAY") | |
button.minus:SetSize(7, 1) | |
button.minus:SetPoint("CENTER") | |
button.minus:SetTexture(C.media.blank) | |
button.plus = button:CreateTexture(nil, "OVERLAY") | |
button.plus:SetSize(1, 7) | |
button.plus:SetPoint("CENTER") | |
button.plus:SetTexture(C.media.blank) | |
button:HookScript("OnEnter", T.SetModifiedBackdrop) | |
button:HookScript("OnLeave", T.SetOriginalBackdrop) | |
button.plus:Hide() | |
hooksecurefunc("ObjectiveTracker_Collapse", function() | |
button.plus:Show() | |
button:SetNormalTexture("") | |
button:SetPushedTexture("") | |
if C.general.minimize_mouseover then | |
button:SetAlpha(0) | |
button:HookScript("OnEnter", function() button:SetAlpha(1) end) | |
button:HookScript("OnLeave", function() button:SetAlpha(0) end) | |
end | |
end) | |
hooksecurefunc("ObjectiveTracker_Expand", function() | |
button.plus:Hide() | |
button:SetNormalTexture("") | |
button:SetPushedTexture("") | |
if C.general.minimize_mouseover then | |
button:SetAlpha(1) | |
button:HookScript("OnEnter", function() button:SetAlpha(1) end) | |
button:HookScript("OnLeave", function() button:SetAlpha(1) end) | |
end | |
end) | |
local function SkinSmallMinimizeButton(button) | |
button:SetSize(15, 15) | |
button:StripTextures() | |
button:SetTemplate("Overlay") | |
button.minus = button:CreateTexture(nil, "OVERLAY") | |
button.minus:SetSize(5, 1) | |
button.minus:SetPoint("CENTER") | |
button.minus:SetTexture(C.media.blank) | |
button.plus = button:CreateTexture(nil, "OVERLAY") | |
button.plus:SetSize(1, 5) | |
button.plus:SetPoint("CENTER") | |
button.plus:SetTexture(C.media.blank) | |
button:HookScript("OnEnter", T.SetModifiedBackdrop) | |
button:HookScript("OnLeave", T.SetOriginalBackdrop) | |
button.plus:Hide() | |
hooksecurefunc(button, "SetCollapsed", function(self, collapsed) | |
if collapsed then | |
button.plus:Show() | |
else | |
button.plus:Hide() | |
end | |
button:SetNormalTexture("") | |
button:SetPushedTexture("") | |
end) | |
end | |
for i = 1, #headers do | |
local button = headers[i].MinimizeButton | |
if button then | |
SkinSmallMinimizeButton(button) | |
end | |
end | |
end | |
---------------------------------------------------------------------------------------- | |
-- Auto collapse Objective Tracker | |
---------------------------------------------------------------------------------------- | |
if C.automation.auto_collapse ~= "NONE" then | |
local collapse = CreateFrame("Frame") | |
collapse:RegisterEvent("PLAYER_ENTERING_WORLD") | |
collapse:SetScript("OnEvent", function() | |
if C.automation.auto_collapse == "RAID" then | |
if IsInInstance() then | |
ObjectiveTracker_Collapse() | |
elseif ObjectiveTrackerFrame.collapsed and not InCombatLockdown() then | |
ObjectiveTracker_Expand() | |
end | |
elseif C.automation.auto_collapse == "RELOAD" then | |
ObjectiveTracker_Collapse() | |
end | |
end) | |
end | |
---------------------------------------------------------------------------------------- | |
-- Skin bonus/world quest objective progress bar | |
---------------------------------------------------------------------------------------- | |
local function SkinBar(line) | |
local progressBar = line.ProgressBar | |
local bar = progressBar.Bar | |
local icon = bar.Icon | |
local label = bar.Label | |
if not progressBar.styled then | |
bar.BarFrame:Hide() | |
bar.BarGlow:Kill() | |
bar.Sheen:Hide() | |
bar.IconBG:Kill() | |
bar:SetSize(200, 20) | |
bar:SetStatusBarTexture(C.media.texture) | |
bar:SetTemplate("Transparent") | |
bar:SetBackdropColor(0, 0, 0, 0) | |
label:ClearAllPoints() | |
label:SetPoint("CENTER", 0, -1) | |
label:SetFont(C.media.pixel_font, C.media.pixel_font_size, C.media.pixel_font_style) | |
icon:SetPoint("RIGHT", 24, 0) | |
icon:SetSize(20, 20) | |
local border = CreateFrame("Frame", "$parentBorder", bar) | |
border:SetAllPoints(icon) | |
border:SetTemplate("Transparent") | |
border:SetBackdropColor(0, 0, 0, 0) | |
bar.newIconBg = border | |
hooksecurefunc(bar.AnimIn, "Play", function() | |
bar.AnimIn:Stop() | |
end) | |
BonusObjectiveTrackerProgressBar_PlayFlareAnim = T.dummy | |
progressBar.styled = true | |
end | |
bar.newIconBg:SetShown(icon:IsShown()) | |
end | |
hooksecurefunc(BONUS_OBJECTIVE_TRACKER_MODULE, "AddProgressBar", function(_, _, line) | |
SkinBar(line) | |
end) | |
hooksecurefunc(WORLD_QUEST_TRACKER_MODULE, "AddProgressBar", function(_, _, line) | |
SkinBar(line) | |
end) | |
---------------------------------------------------------------------------------------- | |
-- Skin default/scenario quest objective progress bar | |
---------------------------------------------------------------------------------------- | |
local function SkinSimpleBar(self, block, line) | |
local progressBar = self.usedProgressBars[block] and self.usedProgressBars[block][line] | |
local bar = progressBar.Bar | |
local label = bar.Label | |
if not progressBar.styled then | |
bar:SetSize(200, 20) | |
bar:SetStatusBarTexture(C.media.texture) | |
bar:SetTemplate("Transparent") | |
bar:SetBackdropColor(0, 0, 0, 0) | |
bar:DisableDrawLayer("ARTWORK") | |
label:ClearAllPoints() | |
label:SetPoint("CENTER", 0, -1) | |
label:SetFont(C.media.pixel_font, C.media.pixel_font_size, C.media.pixel_font_style) | |
label:SetDrawLayer("OVERLAY") | |
progressBar.styled = true | |
end | |
end | |
hooksecurefunc(DEFAULT_OBJECTIVE_TRACKER_MODULE, "AddProgressBar", function(self, block, line) | |
SkinSimpleBar(self, block, line) | |
end) | |
hooksecurefunc(SCENARIO_TRACKER_MODULE, "AddProgressBar", function(self, block, line) | |
SkinSimpleBar(self, block, line) | |
end) | |
---------------------------------------------------------------------------------------- | |
-- Skin Timer bar | |
---------------------------------------------------------------------------------------- | |
hooksecurefunc(DEFAULT_OBJECTIVE_TRACKER_MODULE, "AddTimerBar", function(self, block, line) | |
local timerBar = self.usedTimerBars[block] and self.usedTimerBars[block][line] | |
local bar = timerBar.Bar | |
if not timerBar.styled then | |
bar:SetStatusBarTexture(C.media.texture) | |
bar:SetTemplate("Transparent") | |
bar:SetBackdropColor(0, 0, 0, 0) | |
bar:DisableDrawLayer("ARTWORK") | |
timerBar.styled = true | |
end | |
end) | |
---------------------------------------------------------------------------------------- | |
-- Set tooltip depending on position | |
---------------------------------------------------------------------------------------- | |
local function IsFramePositionedLeft(frame) | |
local x = frame:GetCenter() | |
local screenWidth = GetScreenWidth() | |
local positionedLeft = false | |
if x and x < (screenWidth / 2) then | |
positionedLeft = true | |
end | |
return positionedLeft | |
end | |
hooksecurefunc("BonusObjectiveTracker_ShowRewardsTooltip", function(block) | |
if IsFramePositionedLeft(ObjectiveTrackerFrame) then | |
GameTooltip:ClearAllPoints() | |
GameTooltip:SetPoint("TOPLEFT", block, "TOPRIGHT", 0, 0) | |
end | |
end) | |
ScenarioStageBlock:HookScript("OnEnter", function(self) | |
if IsFramePositionedLeft(ObjectiveTrackerFrame) then | |
GameTooltip:ClearAllPoints() | |
GameTooltip:SetPoint("TOPLEFT", self, "TOPRIGHT", 50, -3) | |
end | |
end) | |
---------------------------------------------------------------------------------------- | |
-- Kill reward animation when finished dungeon or bonus objectives | |
---------------------------------------------------------------------------------------- | |
ObjectiveTrackerScenarioRewardsFrame.Show = T.dummy | |
hooksecurefunc("BonusObjectiveTracker_AnimateReward", function() | |
ObjectiveTrackerBonusRewardsFrame:ClearAllPoints() | |
ObjectiveTrackerBonusRewardsFrame:SetPoint("BOTTOM", UIParent, "TOP", 0, 90) | |
end) | |
---------------------------------------------------------------------------------------- | |
-- Skin ScenarioStageBlock | |
---------------------------------------------------------------------------------------- | |
local StageBlock = _G["ScenarioStageBlock"] | |
StageBlock:CreateBackdrop("Overlay") | |
StageBlock.backdrop:SetPoint("TOPLEFT", ScenarioStageBlock.NormalBG, 3, -3) | |
StageBlock.backdrop:SetPoint("BOTTOMRIGHT", ScenarioStageBlock.NormalBG, -6, 5) | |
StageBlock.NormalBG:SetAlpha(0) | |
StageBlock.FinalBG:SetAlpha(0) | |
StageBlock.GlowTexture:SetTexture("") | |
---------------------------------------------------------------------------------------- | |
-- Ctrl+Click to abandon a quest or Alt+Click to share a quest(by Suicidal Katt) | |
---------------------------------------------------------------------------------------- | |
hooksecurefunc("QuestMapLogTitleButton_OnClick", function(self) | |
if IsControlKeyDown() then | |
CloseDropDownMenus() | |
QuestMapQuestOptions_AbandonQuest(self.questID) | |
elseif IsAltKeyDown() and C_QuestLog.IsPushableQuest(self.questID) then | |
CloseDropDownMenus() | |
QuestMapQuestOptions_ShareQuest(self.questID) | |
end | |
end) | |
hooksecurefunc(QUEST_TRACKER_MODULE, "OnBlockHeaderClick", function(_, block) | |
if IsControlKeyDown() then | |
CloseDropDownMenus() | |
QuestMapQuestOptions_AbandonQuest(block.id) | |
elseif IsAltKeyDown() and C_QuestLog.IsPushableQuest(block.id) then | |
CloseDropDownMenus() | |
QuestMapQuestOptions_ShareQuest(block.id) | |
end | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment