From 2736f498f30220b858fc6fac23e7ddc4a597df6d Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Mon, 30 May 2016 14:42:09 -0400 Subject: Inital commit --- gamemode/vgui/vgui_playerpanel.lua | 68 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 gamemode/vgui/vgui_playerpanel.lua (limited to 'gamemode/vgui/vgui_playerpanel.lua') diff --git a/gamemode/vgui/vgui_playerpanel.lua b/gamemode/vgui/vgui_playerpanel.lua new file mode 100644 index 0000000..9779466 --- /dev/null +++ b/gamemode/vgui/vgui_playerpanel.lua @@ -0,0 +1,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" ) -- cgit v1.2.3-70-g09d2