local CK = CreateFrame("Frame", "CK", PlayerFrame.PlayerFrameContainer);
CK:SetSize(60, 60)
CK:SetPoint("CENTER",PlayerFrame.PlayerFrameContainer.PlayerPortrait,"CENTER",0,0); 
--CK:RegisterForClicks("AnyUp");
--CK:SetScript("OnClick", function() print("点击") end)




CK.T = CK:CreateTexture()
CK.T:SetAllPoints(CK)
CK.T:Hide()

CK.text = CK:CreateFontString(nil)
CK.text:SetFont(SystemFont_Outline_Small:GetFont(), 30, "OUTLINE")	--施法时间文字大小
CK.text:SetPoint("BOTTOM", CK, "TOP", 60, -10)
CK.text:Hide()

CK.Cooldown = CreateFrame("Cooldown", nil, CK, "CooldownFrameTemplate")
CK.Cooldown:SetAllPoints(CK.T)
CK.Cooldown:SetHideCountdownNumbers(false)
CK.Cooldown:SetUseCircularEdge(true)
CK.Cooldown:SetReverse(true)
CK.Cooldown:SetSwipeTexture("Interface/CHARACTERFRAME/TempPortraitAlphaMask")

local regon = CK.Cooldown:GetRegions()
if regon.GetText then 
	regon:SetFont(STANDARD_TEXT_FONT, 20, "OUTLINE")
end

CK.mask = CK:CreateMaskTexture()
CK.mask:SetAllPoints(CK.T)
CK.mask:SetTexture("Interface/CHARACTERFRAME/TempPortraitAlphaMask", "CLAMPTOBLACKADDITIVE", "CLAMPTOBLACKADDITIVE")
CK.T:AddMaskTexture(CK.mask)

local auraid = {
[342246] = true,	--操控时间
[414658] = true,	--新冰箱
[113862] = true,	--隐身减伤
}

local function HELPAURA(per)
local id,icon,count,dispelType,duration,expirationTime,source
	AuraUtil.ForEachAura("player", "HELPFUL", nil, function(...)
		local name1,icon1,count1,dispelType1,duration1,expirationTime1,source1,_,_,spellid = ...
		if auraid[spellid] then
			id,icon,count,dispelType,duration,expirationTime,source = spellid,icon1,count1,dispelType1,duration1,expirationTime1,source1
		end
	end)
return id,icon,count,dispelType,duration,expirationTime,source
end
local function MYAURA(per)	
	local id,icon,count,dispelType,duration,expirationTime,source = HELPAURA("player")
	if id == 342246 then
		source = per
		CK.text:Show()
		CK.text:SetText(source)
	else
		CK.text:Hide()
	end
	if id then
		CK.T:Show()
		CK.T:SetTexture(icon)
		CK.Cooldown:SetCooldown(expirationTime-duration,duration)
	else
		CK.T:SetTexture(nil)
		CK.text:Hide()
		CK.Cooldown:SetCooldown(0,0)
	end

end
local per = ""
local T=CreateFrame("frame")
T:RegisterEvent('UNIT_AURA')
T:RegisterEvent('UNIT_SPELLCAST_SUCCEEDED')
T:SetScript("OnEvent",function(_,event,unit,_,spellId)
	if unit ~= "player" then return end
	if event == 'UNIT_SPELLCAST_SUCCEEDED' and spellId == 342247 then
		per = format("%.0f",UnitHealth("player")/UnitHealthMax("player")*100) .."%"
	end
	if event == 'UNIT_AURA' then
		MYAURA(per)
	end
end)



