summaryrefslogtreecommitdiff
path: root/gamemode/cl_hud/vgui/mbframe.lua
blob: ab99fd7aefd215e5bc5f2efbda2153b4ea4498dd (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
local PANEL = {}
local Close = surface.GetTextureID("gearfox/vgui/close")

function PANEL:Init()
	self.bgcol		= MAIN_COLOR
	self.fgcol		= MAIN_COLOR2
	
	self.Font 		= "Trebuchet18"
	self.Text		= "No-Title MBFrame"
	self.TextCol	= MAIN_TEXTCOLOR
	self.BrigCol	= MAIN_WHITECOLOR
	self.CloseRem   = false
	self.ShowClose 	= true
	
	self:SetPaintBackgroundEnabled( false )
	self:SetPaintBorderEnabled( false )
end

function PANEL:OnClose()
end

function PANEL:SetDeleteOnClose( bool )
	self.CloseRem = bool
end

function PANEL:SetTitle( name )
	self.Text = name
end

function PANEL:SetFGColor( col )
	self.fgcol = col
end

function PANEL:SetBGColor( col )
	self.bgcol = col
end

function PANEL:SetTextColor( col )
	self.TextCol = col
end

function PANEL:SetTextFont( font )
	self.Font = font
end

function PANEL:ShowCloseButton( bool )
	self.ShowClose = bool
end

function PANEL:OnMousePressed()
	if (!self.ShowClose) then return end
	
	local x,y = self:LocalToScreen( self:GetWide()-17 , 3 )
	
	if (input.IsMouseInBox( x , y , 14 , 14 )) then
		self:OnClose()
		
		if (self.CloseRem) then self:Remove()
		else self:SetVisible(false) end
	end
end

function PANEL:Paint(w,h)
	DrawBoxy( 0 , 0 , w , h , self.bgcol )
	DrawLine( 0 , 20 , w , 20 , self.fgcol )
end

function PANEL:PaintOver(w,h)
	DrawText( self.Text , self.Font , 2 , 2 , self.TextCol )
	
	if (self.ShowClose) then 
		local x,y = self:GetPos()
	
		if (input.IsMouseInBox(x+w-17 , y+3 , 14 , 14)) then DrawTexturedRect( w-17 , 3 , 14 , 14 , self.BrigCol , Close )
		else DrawTexturedRect( w-17 , 3 , 14 , 14 , self.TextCol , Close ) end
	end
	
	return true
end
	
function PANEL:PerformLayout()
end
 
vgui.Register( "MBFrame", PANEL, "EditablePanel" )