local E, L, V, P, G = unpack(ElvUI);
local mPlugin = "mMediaTag"
local mMT = E:GetModule(mPlugin);
local EP = LibStub("LibElvUIPlugin-1.0")
local addon, ns = ...
local mTextAddons = ""

--Lua functions
local format = format

--WoW API / Variables
local IsAddOnLoaded = IsAddOnLoaded
local ReloadUI = ReloadUI

local function InstallComplete()
	StaticPopupDialogs["ReloadUI"] = {
		text = "Install Complete!",
		button1 = "ReloadUI",
		OnAccept = function()
			ReloadUI()
		end,
		timeout = 0,
		whileDead = true,
		hideOnEscape = true,
		preferredIndex = 3,  -- avoid some UI taint, see http://www.wowace.com/announcements/how-to-avoid-some-ui-taint/
	  }
	  StaticPopup_Show ("ReloadUI")
end

local function mSetupPopup()
	mTextAddons = L["Profiles are available for these Addons:"] .. "\n"

	-- AddOnSkins
	if IsAddOnLoaded('AddOnSkins') then
		mTextAddons = mTextAddons .. "\n" .. "> |cff1784d1AddOnSkins|r"
	end
	
	-- LocPlus
	if IsAddOnLoaded('ElvUI_LocPlus') then
		mTextAddons = mTextAddons .. "\n" .. "> |cff1784d1ElvUI|r Location Plus"
	end
	
	-- Deadly Boss Mods
	if IsAddOnLoaded('DBM-Core') then
		mTextAddons = mTextAddons .. "\n" .. "> |cffffd200Deadly Boss Mods|r" 
	end
	
	-- Skada
	if IsAddOnLoaded('Skada') then
		mTextAddons = mTextAddons .. "\n" .. "> Skada"
	end
	
	-- ProjectAzilroka
	if IsAddOnLoaded('ProjectAzilroka') then
		mTextAddons = mTextAddons .. "\n" .. "> |cFF16C3F2Project|r|cFFFFFFFFAzilroka|r"
	end
	
	-- Floating Combat Text
	if IsAddOnLoaded('ElvUI_FCT') then
		mTextAddons = mTextAddons .. "\n" .. "> |cff1784d1ElvUI|r |cFFdd2244Floating Combat Text|r"
	end
	
	-- Kaliel's Tracker
	if IsAddOnLoaded('!KalielsTracker') then
		mTextAddons = mTextAddons .. "\n" .. "> Kaliel's Tracker"
	end

	StaticPopupDialogs["Addon Layouts"] = {
		text = mTextAddons,
		button1 = L["Install"],
		button2 = "No",
		OnAccept = function()
			mMT:SetupAddons()
			InstallComplete()
		end,
		timeout = 0,
		whileDead = true,
		hideOnEscape = true,
		preferredIndex = 3,  -- avoid some UI taint, see http://www.wowace.com/announcements/how-to-avoid-some-ui-taint/
	  }

	  StaticPopup_Show ("Addon Layouts")
end

function mMT:mSetup()
	mSetupPopup()
end