Initial commit
This commit is contained in:
41
lua/vgui/dshape.lua
Normal file
41
lua/vgui/dshape.lua
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
local PANEL = {}
|
||||
|
||||
AccessorFunc( PANEL, "m_Color", "Color" )
|
||||
AccessorFunc( PANEL, "m_BorderColor", "BorderColor" )
|
||||
AccessorFunc( PANEL, "m_Type", "Type" )
|
||||
|
||||
local RenderTypes = {}
|
||||
|
||||
function RenderTypes.Rect( pnl )
|
||||
local pnlColor = pnl:GetColor()
|
||||
|
||||
surface.SetDrawColor( pnlColor.r, pnlColor.g, pnlColor.b, pnlColor.a )
|
||||
surface.DrawRect( 0, 0, pnl:GetSize() )
|
||||
end
|
||||
|
||||
function PANEL:Init()
|
||||
|
||||
self:SetColor( color_white )
|
||||
|
||||
self:SetMouseInputEnabled( false )
|
||||
self:SetKeyboardInputEnabled( false )
|
||||
|
||||
end
|
||||
|
||||
function PANEL:Paint()
|
||||
|
||||
RenderTypes[ self.m_Type ]( self )
|
||||
|
||||
end
|
||||
|
||||
derma.DefineControl( "DShape", "A shape", PANEL, "DPanel" )
|
||||
|
||||
-- Convenience function
|
||||
function VGUIRect( x, y, w, h )
|
||||
local shape = vgui.Create( "DShape" )
|
||||
shape:SetType( "Rect" )
|
||||
shape:SetPos( x, y )
|
||||
shape:SetSize( w, h )
|
||||
return shape
|
||||
end
|
||||
Reference in New Issue
Block a user