summaryrefslogtreecommitdiff
path: root/gamemode/vgui/vgui_playerpanel.lua
blob: 9779466db0f2b7f09f70e127c4a5cd4f4835167f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
local PANEL = {}

function PANEL:Init()

	//self:ShowCloseButton( false )
	
	self.Avatar = vgui.Create( "AvatarImage", self )
	self.PlayerName = "N/A"
	self.Desc = ""
	
	self:PerformLayout()
	
end

function PANEL:SetPlayerEnt( ply )

	self.Avatar:SetPlayer( ply )
	
	if IsValid( ply ) then
	
		self.PlayerName = ply:Nick()
	
	end

end

function PANEL:SetCount( num )

	self.Count = num

end

function PANEL:SetDescription( text )

	self.Desc = text

end

function PANEL:GetPadding()

	return 5

end

function PANEL:PerformLayout()
	
	self.Avatar:SetSize( 16, 16 )
	self.Avatar:SetPos( self:GetPadding(), self:GetPadding() )
	
	self:SetTall( 16 + self:GetPadding() * 2 )
	
end

function PANEL:Paint()

	draw.RoundedBox( 4, 2, 2, self:GetWide() - 4, self:GetTall() - 4, Color( 100, 100, 100, 255 ) )
	
	draw.SimpleText( self.PlayerName .. " " .. self.Desc, "EndGame", self:GetPadding() * 3 + 16, self:GetTall() * 0.4 - self:GetPadding(), Color( 255, 255, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT )
	
	if self.Count then
	
		draw.SimpleText( self.Count, "EndGame", self:GetWide() - self:GetPadding() * 2, self:GetTall() * 0.4 - self:GetPadding(), Color( 255, 50, 50 ), TEXT_ALIGN_RIGHT, TEXT_ALIGN_RIGHT )
	
	end

end

derma.DefineControl( "PlayerPanel", "A HUD Element with a player name and avatar", PANEL, "PanelBase" )