Commit 3ad43371 authored by Tukz's avatar Tukz

Update ObjectiveTracker.lua

parent f339fb7d
......@@ -2,6 +2,7 @@ local T, C, L = select(2, ...):unpack()
local ObjectiveTracker = CreateFrame("Frame", nil, UIParent)
local Misc = T["Miscellaneous"]
local Movers = T["Movers"]
local Noop = function() return end
-- Lib Globals
local _G = _G
......@@ -20,8 +21,7 @@ local SCENARIO_TRACKER_MODULE = SCENARIO_TRACKER_MODULE
-- Locals
local Class = select(2, UnitClass("player"))
local CustomClassColor = T.Colors.class[Class]
local PreviousPOI
local ClassColor = T.Colors.class[Class]
function ObjectiveTracker:Disable()
ObjectiveTrackerFrameHeaderMenuMinimizeButton:Hide()
......@@ -49,6 +49,7 @@ end
function ObjectiveTracker:CreateToggleButtons()
local Button = CreateFrame("Button", nil, UIParent)
Button:Size(32)
Button:SetPoint("TOPRIGHT", ObjectiveTrackerFrame, 13, 20)
Button:SetAlpha(0)
......@@ -75,9 +76,6 @@ function ObjectiveTracker:SetDefaultPosition()
ObjectiveTrackerFrame:ClearAllPoints()
ObjectiveTrackerFrame:SetPoint("TOP", ObjectiveFrameHolder)
ObjectiveTrackerFrame:Height(396)
-- Force IsUserPlaced to always be true, which will avoid tracker to move
-- https://git.tukui.org/Blazeflack/BlizzardUserInterface/blob/master/Interface/FrameXML/UIParent.lua#L2939
ObjectiveTrackerFrame.IsUserPlaced = function() return true end
Movers:RegisterFrame(ObjectiveFrameHolder)
......@@ -116,7 +114,7 @@ function ObjectiveTracker:Skin()
HeaderBar:Size(263, 2)
HeaderBar:SetPoint("CENTER", HeaderPanel, 0, -9)
HeaderBar:SetStatusBarTexture(C.Medias.Blank)
HeaderBar:SetStatusBarColor(unpack(CustomClassColor))
HeaderBar:SetStatusBarColor(unpack(ClassColor))
HeaderBar:CreateBackdrop()
HeaderBar:CreateShadow()
......@@ -249,6 +247,7 @@ end
function ObjectiveTracker:UpdateProgressBarColors(Min)
if (self.Bar and Min) then
local R, G, B = T.ColorGradient(Min, 100, 0.8, 0, 0, 0.8, 0.8, 0, 0, 0.8, 0)
self.Bar:SetStatusBarColor(R, G, B)
end
end
......@@ -339,105 +338,72 @@ function ObjectiveTracker:AddDash(block)
local questIndex = C_QuestLog.GetQuestIDForQuestWatchIndex(i)
if questIndex then
local id = GetQuestWatchInfo(i)
local block = QUEST_TRACKER_MODULE:GetBlock(id)
local title, level, _, _, _, _, frequency = GetQuestLogTitle(questIndex)
local block = QUEST_TRACKER_MODULE:GetBlock(questIndex)
local title = C_QuestLog.GetTitleForQuestID(questIndex)
local level = C_QuestLog.GetQuestDifficultyLevel(questIndex)
if block.lines then
for key, line in pairs(block.lines) do
if frequency == LE_QUEST_FREQUENCY_DAILY then
local red, green, blue = 1/4, 6/9, 1
line.Dash:SetText("— ")
line.Dash:SetVertexColor(red, green, blue)
elseif frequency == LE_QUEST_FREQUENCY_WEEKLY then
local red, green, blue = 0, 252/255, 177/255
line.Dash:SetText("— ")
line.Dash:SetVertexColor(red, green, blue)
else
local col = GetQuestDifficultyColor(level)
line.Dash:SetText("— ")
line.Dash:SetVertexColor(col.r, col.g, col.b)
end
local col = GetQuestDifficultyColor(level)
line.Dash:SetText("— ")
line.Dash:SetVertexColor(col.r, col.g, col.b)
end
end
end
end
end
function ObjectiveTracker:SkinPOI(questID, style, index)
local Incomplete = self.poiTable["numeric"]
local Complete = self.poiTable["completed"]
for i = 1, #Incomplete do
local Button = ObjectiveTrackerBlocksFrame.poiTable["numeric"][i]
if Button and not Button.IsSkinned then
Button.NormalTexture:SetTexture("")
Button.PushedTexture:SetTexture("")
Button.HighlightTexture:SetTexture("")
Button.Glow:SetAlpha(0)
Button:CreateBackdrop()
Button:StyleButton()
Button:CreateShadow()
Button.IsSkinned = true
end
function ObjectiveTracker:UpdatePOI()
if self:GetParent() ~= ObjectiveTrackerBlocksFrame then
QuestPOI_UpdateButtonStyle_Old(self)
return
end
if not self.IsSkinned then
self.NormalTexture:SetTexture("")
self.PushedTexture:SetTexture("")
self.HighlightTexture:SetTexture("")
self:CreateBackdrop()
self:StyleButton()
self:CreateShadow()
for i = 1, #Complete do
local Button = ObjectiveTrackerBlocksFrame.poiTable["completed"][i]
if Button and not Button.IsSkinned then
Button.NormalTexture:SetTexture("")
Button.PushedTexture:SetTexture("")
Button.FullHighlightTexture:SetTexture("")
Button.Glow:SetAlpha(0)
Button:CreateBackdrop()
Button:StyleButton()
Button:CreateShadow()
Button.IsSkinned = true
end
self.IsSkinned = true
end
end
function ObjectiveTracker:SelectPOI(color)
local Shadow = self.Shadow
if Shadow then
local ID = GetQuestLogIndexByID(self.questID)
local Level = select(2, GetQuestLogTitle(ID))
local Color = GetQuestDifficultyColor(Level) or {r = 1, g = 1, b = 0, a = 1}
local Number = self.Number
if PreviousPOI then
PreviousPOI:SetBackdropColor(unpack(C.Medias.BackdropColor))
PreviousPOI.Shadow:SetBackdropBorderColor(unpack(C.Medias.BorderColor))
end
Shadow:SetBackdropBorderColor(Color.r, Color.g, Color.b)
self:SetBackdropColor(0/255, 152/255, 34/255, 1)
PreviousPOI = self
if self.Glow then
self.Glow:SetAlpha(0)
end
if self.selected then
local R, G, B = unpack(T.Colors.class[T.MyClass])
self.Shadow:SetBackdropBorderColor(R, G, B)
self.Backdrop:SetBackdropColor(0/255, 152/255, 34/255, 1)
else
self.Shadow:SetBackdropBorderColor(unpack(C.Medias.BorderColor))
self.Backdrop:SetBackdropColor(unpack(C.Medias.BackdropColor))
end
if self.style == "numeric" then
self.Display:SetNumber(self.index)
end
end
function ObjectiveTracker:ShowObjectiveTrackerLevel()
for i = 1, GetNumQuestWatches() do
local questID, title, questLogIndex = GetQuestWatchInfo(i)
for i = 1, C_QuestLog.GetNumQuestWatches() do
local questIndex = C_QuestLog.GetQuestIDForQuestWatchIndex(i)
if ( not questID ) then
if ( not questIndex ) then
break
end
local block = QUEST_TRACKER_MODULE:GetExistingBlock(questID)
local block = QUEST_TRACKER_MODULE:GetExistingBlock(questIndex)
if block then
local title, level = GetQuestLogTitle(questLogIndex)
local title = C_QuestLog.GetTitleForQuestID(questIndex)
local level = C_QuestLog.GetQuestDifficultyLevel(questIndex)
local color = GetQuestDifficultyColor(level)
local hex = T.RGBToHex(color.r, color.g, color.b) or OBJECTIVE_TRACKER_COLOR["Header"]
local text = hex.."["..level.."]|r "..title
......@@ -475,39 +441,6 @@ function ObjectiveTracker:SkinRewards()
end
end
function ObjectiveTracker:SkinWorldQuestsPOI(worldQuestType, rarity, isElite, tradeskillLineIndex, inProgress, selected, isCriteria, isSpellTarget, isEffectivelyTracked)
if not self.IsSkinned then
self:CreateBackdrop()
self:CreateShadow()
self.Underlay:SetAlpha(0)
self.Glow:SetAlpha(0)
self.SelectedGlow:SetAlpha(0)
self.IsSkinned = true
end
self:SetNormalTexture("")
self:SetPushedTexture("")
self:SetHighlightTexture("")
if selected then
self:SetBackdropColor(0/255, 152/255, 34/255, 1)
else
self:SetBackdropColor(unpack(C.Medias.BackdropColor))
end
if rarity == LE_WORLD_QUEST_QUALITY_RARE then
self.Shadow:SetBackdropBorderColor(0.00, 0.44, 0.87)
elseif rarity == LE_WORLD_QUEST_QUALITY_EPIC then
self.Shadow:SetBackdropBorderColor(0.64, 0.21, 0.93)
end
if PreviousPOI and PreviousPOI.IsSkinned then
PreviousPOI:SetBackdropColor(unpack(C.Medias.BackdropColor))
PreviousPOI.Shadow:SetBackdropBorderColor(unpack(C.Medias.BorderColor))
end
end
function ObjectiveTracker:AddHooks()
hooksecurefunc("ObjectiveTracker_Update", self.Skin)
hooksecurefunc("ScenarioBlocksFrame_OnLoad", self.SkinScenario)
......@@ -525,32 +458,45 @@ function ObjectiveTracker:AddHooks()
hooksecurefunc("QuestObjectiveSetupBlockButton_FindGroup", SkinGroupFindButton)
hooksecurefunc("QuestObjectiveSetupBlockButton_AddRightButton", UpdatePositions)
hooksecurefunc(AUTO_QUEST_POPUP_TRACKER_MODULE, "Update", self.UpdatePopup)
--hooksecurefunc(QUEST_TRACKER_MODULE, "Update", self.AddDash)
--hooksecurefunc("QuestPOI_GetButton", self.SkinPOI)
--hooksecurefunc("QuestPOI_SelectButton", self.SelectPOI)
hooksecurefunc(QUEST_TRACKER_MODULE, "Update", self.AddDash)
hooksecurefunc("BonusObjectiveTracker_AnimateReward", self.SkinRewards)
if T.WoWBuild < 28724 then
hooksecurefunc("WorldMap_SetupWorldQuestButton", self.SkinWorldQuestsPOI)
else
hooksecurefunc(QuestUtil, "SetupWorldQuestButton", self.SkinWorldQuestsPOI)
end
-- Currently there is display a bug with this hook
-- hooksecurefunc(QUEST_TRACKER_MODULE, "Update", self.ShowObjectiveTrackerLevel)
hooksecurefunc(QUEST_TRACKER_MODULE, "Update", self.ShowObjectiveTrackerLevel)
end
function ObjectiveTracker:Enable()
OBJECTIVE_TRACKER_COLOR["Header"] = {r = CustomClassColor[1], g = CustomClassColor[2], b = CustomClassColor[3]}
OBJECTIVE_TRACKER_COLOR["HeaderHighlight"] = {r = CustomClassColor[1]*1.2, g = CustomClassColor[2]*1.2, b = CustomClassColor[3]*1.2}
OBJECTIVE_TRACKER_COLOR["Complete"] = { r = 0, g = 1, b = 0 }
OBJECTIVE_TRACKER_COLOR["Normal"] = { r = 1, g = 1, b = 1 }
OBJECTIVE_TRACKER_COLOR["Header"] = {
r = ClassColor[1],
g = ClassColor[2],
b = ClassColor[3],
}
OBJECTIVE_TRACKER_COLOR["HeaderHighlight"] = {
r = ClassColor[1]*1.2,
g = ClassColor[2]*1.2,
b = ClassColor[3]*1.2,
}
OBJECTIVE_TRACKER_COLOR["Complete"] = {
r = 0,
g = 1,
b = 0,
}
OBJECTIVE_TRACKER_COLOR["Normal"] = {
r = 1,
g = 1,
b = 1,
}
self:AddHooks()
self:Disable()
self:CreateToggleButtons()
self:SetDefaultPosition()
self:SkinScenario()
-- POI Updates
QuestPOI_UpdateButtonStyle_Old = QuestPOI_UpdateButtonStyle
QuestPOI_UpdateButtonStyle = self.UpdatePOI
end
Misc.ObjectiveTracker = ObjectiveTracker
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment