ObjectiveTracker.lua 6.63 KB
Newer Older
Azilroka's avatar
Azilroka committed
1
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
2 3 4
local S = E:GetModule('Skins')

--Lua functions
5
local _G = _G
6
local unpack = unpack
7
--WoW API / Variables
8
local hooksecurefunc = hooksecurefunc
9

10
local function SkinOjectiveTrackerHeaders()
11
	local frame = _G.ObjectiveTrackerFrame.MODULES
12 13 14 15
	if frame then
		for i = 1, #frame do
			local modules = frame[i]
			if modules then
Simpy's avatar
Simpy committed
16
				modules.Header.Background:SetAtlas(nil)
17 18 19

				local text = modules.Header.Text
				text:FontTemplate()
Simpy's avatar
Simpy committed
20
				text:SetParent(modules.Header)
21 22 23 24 25 26 27 28 29 30 31 32 33
			end
		end
	end
end

local function ColorProgressBars(self, value)
	if not (self.Bar and self.isSkinned and value) then return end
	S:StatusBarColorGradient(self.Bar, value, 100)
end

local function SkinItemButton(_, block)
	local item = block.itemButton
	if item and not item.skinned then
Simpy's avatar
Simpy committed
34
		item:Size(25, 25)
35 36 37 38 39 40 41
		item:SetTemplate("Transparent")
		item:StyleButton()
		item:SetNormalTexture(nil)
		item.icon:SetTexCoord(unpack(E.TexCoords))
		item.icon:SetInside()
		item.Cooldown:SetInside()
		item.Count:ClearAllPoints()
Simpy's avatar
Simpy committed
42
		item.Count:Point("TOPLEFT", 1, -1)
43
		item.Count:FontTemplate(E.media.normFont, 14, "OUTLINE")
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
		item.Count:SetShadowOffset(5, -5)
		E:RegisterCooldown(item.Cooldown)
		item.skinned = true
	end
end

local function SkinProgressBars(_, _, line)
	local progressBar = line and line.ProgressBar
	local bar = progressBar and progressBar.Bar
	if not bar then return end
	local icon = bar.Icon
	local label = bar.Label

	if not progressBar.isSkinned then
		if bar.BarFrame then bar.BarFrame:Hide() end
		if bar.BarFrame2 then bar.BarFrame2:Hide() end
		if bar.BarFrame3 then bar.BarFrame3:Hide() end
		if bar.BarGlow then bar.BarGlow:Hide() end
		if bar.Sheen then bar.Sheen:Hide() end
		if bar.IconBG then bar.IconBG:SetAlpha(0) end
		if bar.BorderLeft then bar.BorderLeft:SetAlpha(0) end
		if bar.BorderRight then bar.BorderRight:SetAlpha(0) end
		if bar.BorderMid then bar.BorderMid:SetAlpha(0) end

		bar:Height(18)
		bar:StripTextures()
		bar:CreateBackdrop("Transparent")
		bar:SetStatusBarTexture(E.media.normTex)
		E:RegisterStatusBar(bar)

		if label then
			label:ClearAllPoints()
			label:Point("CENTER", bar, 0, 1)
			label:FontTemplate(E.media.normFont, 14, "OUTLINE")
		end
79

80 81 82 83 84
		if icon then
			icon:ClearAllPoints()
			icon:Point("LEFT", bar, "RIGHT", E.PixelMode and 3 or 7, 0)
			icon:SetMask("")
			icon:SetTexCoord(unpack(E.TexCoords))
85

86
			if not progressBar.backdrop then
87
				progressBar:CreateBackdrop()
88 89
				progressBar.backdrop:SetOutside(icon)
				progressBar.backdrop:SetShown(icon:IsShown())
90 91
			end
		end
92

93
		_G.BonusObjectiveTrackerProgressBar_PlayFlareAnim = E.noop
94 95 96 97 98
		progressBar.isSkinned = true

		ColorProgressBars(progressBar, bar:GetValue())
	elseif icon and progressBar.backdrop then
		progressBar.backdrop:SetShown(icon:IsShown())
99
	end
100 101
end

102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
local function SkinTimerBars(_, _, line)
	local timerBar = line and line.TimerBar
	local bar = timerBar and timerBar.Bar

	if not timerBar.isSkinned then
		bar:Height(18)
		bar:StripTextures()
		bar:CreateBackdrop("Transparent")
		bar:SetStatusBarTexture(E.media.normTex)
		E:RegisterStatusBar(bar)

		timerBar.isSkinned = true
	end
end

117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
local function PositionFindGroupButton(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
			-- this fires when there is a group button and a item button to the left of it
			-- we push the item button away from the group button (to the left)
			button:Point(a, b, c, d-(E.PixelMode and -1 or 1), e);
		elseif b == block and block.groupFinderButton and button == block.groupFinderButton then
			-- this fires when there is a group finder button
			-- we push the group finder button down slightly
			button:Point(a, b, c, d, e-(E.PixelMode and 2 or -1));
		end
	end
end

local function SkinFindGroupButton(block)
	if block.hasGroupFinderButton and block.groupFinderButton then
		if block.groupFinderButton and not block.groupFinderButton.skinned then
			S:HandleButton(block.groupFinderButton)
			block.groupFinderButton:Size(20)
			block.groupFinderButton.skinned = true
		end
	end
end
141

142 143 144
local function LoadSkin()
	if E.private.skins.blizzard.enable ~= true or E.private.skins.blizzard.objectiveTracker ~= true then return end

145
	local ObjectiveTrackerFrame = _G.ObjectiveTrackerFrame
146
	local minimizeButton = ObjectiveTrackerFrame.HeaderMenu.MinimizeButton
147 148 149
	minimizeButton:StripTextures()
	minimizeButton:Size(16, 16)
	minimizeButton.tex = minimizeButton:CreateTexture(nil, "OVERLAY")
150
	minimizeButton.tex:SetTexture(E.Media.Textures.MinusButton)
151 152
	minimizeButton.tex:SetInside()
	minimizeButton:SetHighlightTexture("Interface\\Buttons\\UI-PlusButton-Hilight", "ADD")
153
	minimizeButton:HookScript("OnClick", function()
Simpy's avatar
Simpy committed
154
		if ObjectiveTrackerFrame.collapsed then
155
			minimizeButton.tex:SetTexture(E.Media.Textures.PlusButton)
156
		else
157
			minimizeButton.tex:SetTexture(E.Media.Textures.MinusButton)
158 159 160
		end
	end)

Simpy's avatar
Simpy committed
161 162 163 164
	hooksecurefunc("BonusObjectiveTrackerProgressBar_SetValue",ColorProgressBars)			--[Color]: Bonus Objective Progress Bar
	hooksecurefunc("ObjectiveTrackerProgressBar_SetValue",ColorProgressBars)				--[Color]: Quest Progress Bar
	hooksecurefunc("ScenarioTrackerProgressBar_SetValue",ColorProgressBars)					--[Color]: Scenario Progress Bar
	hooksecurefunc("QuestObjectiveSetupBlockButton_AddRightButton",PositionFindGroupButton)	--[Move]: The eye & quest item to the left of the eye
165
	hooksecurefunc("ObjectiveTracker_Update",SkinOjectiveTrackerHeaders)					--[Skin]: Module Headers
Simpy's avatar
Simpy committed
166
	hooksecurefunc("QuestObjectiveSetupBlockButton_FindGroup",SkinFindGroupButton)			--[Skin]: The eye
167 168
	hooksecurefunc(_G.BONUS_OBJECTIVE_TRACKER_MODULE,"AddProgressBar",SkinProgressBars)		--[Skin]: Bonus Objective Progress Bar
	hooksecurefunc(_G.WORLD_QUEST_TRACKER_MODULE,"AddProgressBar",SkinProgressBars)			--[Skin]: World Quest Progress Bar
Merathilis's avatar
nothing  
Merathilis committed
169 170
	hooksecurefunc(_G.DEFAULT_OBJECTIVE_TRACKER_MODULE,"AddProgressBar",SkinProgressBars)	--[Skin]: Quest Progress Bar
	hooksecurefunc(_G.SCENARIO_TRACKER_MODULE,"AddProgressBar",SkinProgressBars)			--[Skin]: Scenario Progress Bar
171 172 173
	hooksecurefunc(_G.QUEST_TRACKER_MODULE,"AddTimerBar",SkinTimerBars)						--[Skin]: Quest Timer Bar
	hooksecurefunc(_G.SCENARIO_TRACKER_MODULE,"AddTimerBar",SkinTimerBars)					--[Skin]: Scenario Timer Bar
	hooksecurefunc(_G.ACHIEVEMENT_TRACKER_MODULE,"AddTimerBar",SkinTimerBars)				--[Skin]: Achievement Timer Bar
174 175
	hooksecurefunc(_G.QUEST_TRACKER_MODULE,"SetBlockHeader",SkinItemButton)					--[Skin]: Quest Item Buttons
	hooksecurefunc(_G.WORLD_QUEST_TRACKER_MODULE,"AddObjective",SkinItemButton)				--[Skin]: World Quest Item Buttons
176 177
end

Simpy's avatar
Simpy committed
178
S:AddCallback("ObjectiveTracker", LoadSkin)