Quantcast
local function iObjectivesShow()
	ObjectiveTrackerFrame:SetAlpha(1)
	if (D2Minimap ~= true) then
		Minimap:SetAlpha(1)
	end
	Minimap:SetPlayerTexture("Interface\\Minimap\\MinimapArrow")
end

local function iObjectivesHide()
	ObjectiveTrackerFrame:SetAlpha(.2)
	if (D2Minimap ~= true) then
		Minimap:SetAlpha(0)
	end
	Minimap:SetPlayerTexture("")
end

local function AutoToggleMinimap(self, event, ...)
	if ( event == "SUPER_TRACKED_QUEST_CHANGED" )
	or ( event == "QUEST_ACCEPT_CONFIRM" )
	then
		iObjectivesShow()
	else
		iObjectivesHide()
	end
end

local iObjectivesFrame = CreateFrame("Frame", "iObjectivesFrame", UIParent, "SecureHandlerStateTemplate")
iObjectivesFrame:SetScript("OnEvent", AutoToggleMinimap)

-- Show Events
--iObjectivesFrame:RegisterEvent("SUPER_TRACKED_QUEST_CHANGED")
--iObjectivesFrame:RegisterEvent("QUEST_ACCEPT_CONFIRM")

-- Hide Events
iObjectivesFrame:RegisterEvent("PLAYER_LOGIN")
--iObjectivesFrame:RegisterEvent("PLAYER_STARTED_MOVING")

-- Frame-Events
Minimap:HookScript("OnEnter", iObjectivesShow)
Minimap:HookScript("OnLeave", iObjectivesHide)
GarrisonLandingPageMinimapButton:HookScript("OnEnter", iObjectivesShow)
GarrisonLandingPageMinimapButton:HookScript("OnLeave", iObjectivesHide)
GameTimeFrame:HookScript("OnEnter", iObjectivesShow)
GameTimeFrame:HookScript("OnLeave", iObjectivesHide)
ObjectiveTrackerFrame:HookScript("OnEnter", iObjectivesShow)
ObjectiveTrackerFrame:HookScript("OnLeave", iObjectivesHide)
WorldMapFrame:HookScript("OnShow", iObjectivesShow)
WorldMapFrame:HookScript("OnHide", iObjectivesHide)
ContainerFrame1PortraitButton:HookScript("OnShow", iObjectivesShow)
ContainerFrame1PortraitButton:HookScript("OnHide", iObjectivesHide)