local curPanels = {}

net.Receive("PLibs:Player:DoNotify",function()
	vgui.Create("AnimPanel"):SetTxt(net.ReadString())
end)

local PANEL = {}

function PANEL:Init()
	curPanels = curPanels or {}

	local i = table.insert(curPanels, self)
	
	for k,v in pairs(curPanels) do if !IsValid(v) then table.remove(curPanels, k) end end

	self.yPos = ScrH()-(#curPanels*60)-140
	self:SetPos(PLibs.SizeToClient(-200, self.yPos))

	local x,y = PLibs.SizeToClient(50, self.yPos)
	self:MoveTo(x,y,1,0,-1)


	local x,y = PLibs.SizeToClient(-500, self.yPos)
	self:MoveTo(x,y,0.5,6,2,function()
		table.remove(curPanels, i)
		self:Remove()
	end)
	--PLibs.CreateHtmlIcon(self,9,9,32,32,"http://www.ordiathome.ch/wp-content/uploads/2017/03/001-signs-1.png")
end

function PANEL.Paint(self,w,h)
	surface.SetDrawColor(color_white)
	surface.SetMaterial(notif_add_prp)
	surface.DrawTexturedRect(0,0,w,h)
	local w,h = PLibs.SizeToClient(50,50)
	--draw.RoundedBox(0,0,0,w,h,Color(41, 128, 185))
	local x = PLibs.SizeToClient(60)
	draw.SimpleText(self.Txt,"PLibs:Size:26",x,h/2,Color(52, 73, 94),TEXT_ALIGN_LEFT,TEXT_ALIGN_CENTER)
end

function PANEL:SetTxt(txt)
	self:SetSize(PLibs.SizeToClient((markup.Parse("<font=PLibs:Size:20>"..txt.."</font>"):GetWidth()*1.5)+100, 50))
	self.Txt = txt
end

vgui.Register("AnimPanel",PANEL,"Panel")