--[[EPEEN - Tidy Plates Theme]]--
local config = {}
local path = "Interface\\Addons\\TidyPlates_EPEEN"
local classByColor = {
C285 = "Deathknight",
C390 = "Druid",
C498 = "Hunter",
C549 = "Mage",
C571 = "Paladin",
C768 = "Priest",	
C605 = "Rogue",	
C335 = "Shaman",	
C479 = "Warlock",
C465 = "Warrior",
--C256 = "Npc",
}
function config.SetSpecialArt(unit)
	if unit.reaction == "HOSTILE" then
		local r = ceil(unit.red*256)
		local g = ceil(unit.green*256)
		local b = ceil(unit.blue*256)
		local class = nil
		local index = 0
		for index = -2, 3 do
			class = classByColor["C"..(r+g+b+index)]
			if class then return path.."\\Class\\ClassIcon_"..class end
		end
	end
	return nil
end				
--[[Textures]]--
config.frame = {
	width = 124,
	height = 30,
}
config.threatborder = {
	texture =						path.."\\artwork\\CP_Threat",
	elitetexture =					path.."\\artwork\\CP_Threat",
	width = 256,
	height = 64,
	x = 0,
	y = 5,
	anchor = "CENTER",
}

config.healthborder = {
	texture = 						path.."\\artwork\\CP_HealthBarOverlay",
	glowtexture = 					path.."\\artwork\\CP_HealthBarHighlight",
	elitetexture = 					path.."\\artwork\\CP_HealthBarEliteOverlay",
	width = 256,
	height = 64,
	x = 0,
	y = 5,
	anchor = "CENTER",
}
config.castborder = {
	texture = 						path.."\\artwork\\CP_CastBarOverlay",
	width = 256,
	height = 64,
	x = 0,
	y = -10,
	anchor = "CENTER",
}

config.castnostop = {
	texture =						path.."\\artwork\\CP_CastBarLock",
	width = 256,
	height = 64,
	x = 0,
	y = -10,
	anchor = "CENTER",
}
--[[Bar Textures]]--
config.healthbar = {
	texture =						path.."\\artwork\\CP_BarTexture",
	width =122,
	height = 12,
	x = 0,
	y = 5,
	anchor = "CENTER",
	orientation = "HORIZONTAL",
}
config.castbar = {
	texture =						path.."\\artwork\\CP_BarTexture",
	width = 122,
	height = 12,
	x = 0,
	y = -10,
	anchor = "CENTER",
	orientation = "HORIZONTAL",
}
--[[TEXT]]--

config.name = {
	typeface =						path.."\\fonts\\Accidental Presidency.ttf",
	size = 12,
	width = 105,
	height = 14,
	x = 0,
	y = 18,
	align = "CENTER",
	anchor = "CENTER",
	vertical = "CENTER",
	shadow = true,
}
config.level = {
	typeface =						path.."\\fonts\\Accidental Presidency.ttf",
	size = 12,
	width = 20,
	height = 14,
	x = 50,
	y = 5,
	align = "RIGHT",
	anchor = "CENTER",
	vertical = "TOP",
	shadow = true,
}
config.specialText = {
	typeface =						path.."\\fonts\\Accidental Presidency.ttf",
	size = 12,
	width = 90,
	height = 14,
	x = 0,
	y = 6,
	align = "CENTER",
	anchor = "CENTER",
	vertical = "CENTER",
	shadow = true,
}
config.specialText2 = {
	typeface =						path.."\\fonts\\Accidental Presidency.ttf",
	size = 12,
	width = 90,
	height = 14,
	x = 0,
	y = 0,
	align = "CENTER",
	anchor = "CENTER",
	vertical = "CENTER",
	shadow = true,
}
--[[ICONS]]--
config.dangerskull = {
	width = 14,
	height = 14,
	x = 58,
	y = 17,
	anchor = "CENTER",
}
config.specialArt = {
	width = 22,
	height = 22,
	x = -74,
	y = -2,
	anchor = "CENTER",
}
config.spellicon = {
	width = 20,
	height = 20,
	x = 75,
	y = -2,
	anchor = "CENTER",
}
config.raidicon = {
	width = 14,
	height = 14,
	x = 0,
	y = 17,
	anchor = "TOP",
}
--[[OPTIONS]]--
config.threatcolor = {
	LOW = { r = 1, g = 1, b = 1, a= 0.9, },
	MEDIUM = { r = 1, g = 1, b = 0, a = 0.2, },
	HIGH = { r = 1, g = 0, b = 0, a = 0.2, },
}
config.options = {
	showLevel = true,
	showName = true,
	showSpecialArt = true,
	showSpecialText = true,
	showSpecialText2 = true,
	showDangerSkull = true,
	showspellIcon = true,
	showNostopSpell = true,
	useOnUpdate = true,
}

config.OnUpdate = function(plate, unit)
	if not plate.widgets.EPEEN then plate.widgets.EPEEN = TidyPlatesWidgets.CreateEpeenWidget(plate) end
	plate.widgets.EPEEN:SetPoint("CENTER", plate, 0, 45)
	plate.widgets.EPEEN:Update(unit)
end

--[[Health Truncate Function]]--
local Truncate = function(value)
	if value >= 1e6 then
		return format('%.1fm', value / 1e6)
	elseif value >= 1e4 then
		return format('%.1fk', value / 1e3)
	else
		return value
	end
end
--[[Special Text]]--
function config.SetSpecialText(unit)
	healthpercent = 100* (unit.health / unit.healthmax) 				--[[Creates the health percentage number]]--
	if (unit.health / unit.healthmax) < 1 then 							--[[If Health is less than 100%]]--
		return Truncate(unit.health).." - "..ceil(healthpercent ).."%" 	--[[Display Truncated HP Amount and Percentage]]--
	else 																--[[If HP is 100%]]--
		return --[[ceil(healthpercent ).."%"]]--						--[[Display Nothing or Optional 100% text]]--
	end
end
function config.SetSpecialText2(unit)
	return 
end

if not TidyPlatesThemeList then TidyPlatesThemeList = {} end
TidyPlatesThemeList["EPEEN"] = config
--[[function config.SetAlpha(unit)
	if (unit.health / unit.healthmax) > 0.5 then return 1
	else return .6 end
end
]]--