-----------------------
-- Class Icon Widget --
-----------------------
local path = "Interface\\AddOns\\TidyPlates_ThreatPlates\\Widgets\\ClassIconWidget\\"

local function UpdateClassIconWidget(frame, unit)
	local db = TidyPlatesThreat.db.profile.classWidget
	if unit.class and (unit.class ~= "UNKNOWN") and TidyPlatesThreat.db.profile.classWidget.ON then
		frame.Icon:SetTexture(path..db.theme.."\\"..unit.class) 
		frame:Show()
	else frame:Hide() end
end

local function CreateClassIconWidget(parent)
	local db = TidyPlatesThreat.db.profile.classWidget
	local frame = CreateFrame("Frame", nil, parent)
	frame:SetHeight(64)
	frame:SetWidth(64)
	frame.Icon = frame:CreateTexture(nil, "OVERLAY")
	frame.Icon:SetAllPoints(frame)
	frame:Hide()
	frame.Update = UpdateClassIconWidget
	return frame
end

ThreatPlatesWidgets.CreateClassIconWidget = CreateClassIconWidget
