-- Stuffz I carry around with scripts to make stuff more simple for me. ;)

function draw.DrawBar( x, y, w, w2, h, ColA, ColB )
    draw.RoundedBox( 0, x, y, w, h, Color( 0, 0, 0, 200 ) );
    
    draw.RoundedBox( 0, x + 2, y + 2, math.Clamp( ( w - 4 ) * w2, 0, ( w - 4 ) ), h - 4, ColA );
    draw.RoundedBox( 0, x + 2, y + 2, math.Clamp( ( w - 4 ) * w2, 0, ( w - 4 ) ), h - 14, ColB );
end;

function draw.DrawSimpleRect( w, h, x, y, col )
	surface.SetDrawColor( col );
	surface.DrawRect( w, h, x, y );
end;

function draw.DrawSimpleOutlined( w, h, x, y, col )
	surface.SetDrawColor( col );
	surface.DrawOutlinedRect( w, h, x, y );
end;

function draw.DrawDoubleOutlined( w, h, x, y, col )
	surface.SetDrawColor( col );
	surface.DrawOutlinedRect( w, h, x, y );
	surface.DrawOutlinedRect( w + 1, h + 1, x - 2, y - 2 );
end;

function SimpleLabel( parent, title, col, font, x, y )
	local DLabel = "";
	
	if ( parent != nil ) then
		DLabel = vgui.Create( "DLabel", parent );
	else
		DLabel = vgui.Create( "DLabel" );
	end;
	
	if ( x and y ) then
		DLabel:SetPos( x, y );
	end;
	
	DLabel:SetText( title );
	DLabel:SetFont( font );
	DLabel:SetTextColor( col );
	DLabel:SizeToContents();
	
	return DLabel;
end;

function SimpleButton( parent, x, y, w, h, title, func, disabled )
	local Button = "";
	
	if ( parent != nil ) then
		Button = vgui.Create( "eps_button", parent );
	else
		Button = vgui.Create( "eps_button" );
	end;
	
	Button:SetText( title );
	
	if ( w and h ) then
		Button:SetSize( w, h );
	end;
	
	if ( x and y ) then
		Button:SetPos( x, y );
	end;
	
	if ( disabled ) then
		Button:SetDisabled( disabled );
	end;
	
	Button:SetCallback( func );
	
	return Button;
end;

function SimpleDFrame( w, h, x, y, popup, title )
	local Frame = vgui.Create( "DFrame" );
	Frame:SetSize( w, h );
	Frame:SetTitle( title );
	
	if ( popup ) then
		Frame:MakePopup();
	end;
	
	if ( x and y ) then
		Frame:SetPos( x, y );
	else
		Frame:Center();
	end;
	
	return Frame;
end;

-- kthx
function draw.DrawTextGlowing( text, font, x, y, colour, xalign, yalign, passes, outlinecolour )
 	for _x = - 1, 1 do 
 		for _y = - 1, 1 do 
 			for n = 1, passes do
 				draw.DrawText( text, font, x + (_x * ( n / 2 ) ), y + ( _y * ( n / 2 ) ), Color( outlinecolour.r, outlinecolour.g, outlinecolour.b, math.Clamp( ( ( 1 / n ) * 255 ), 0, outlinecolour.a ) ), xalign, yalign ) 
 			end
 		end 
 	end 

 	draw.DrawText( text, font, x, y, colour, xalign, yalign ) 
end

-- Fixed one.
function eps_DermaQuery( font, strText, strTitle, ... )
	local Window = vgui.Create( "DFrame" )
	Window:SetTitle( strTitle or "Message Title (First Parameter)" )
	Window:SetDraggable( false )
	Window:ShowCloseButton( false )
	Window:SetBackgroundBlur( true )
	Window:SetDrawOnTop( true )
	Window:MakePopup()
	
	local InnerPanel = vgui.Create( "DPanel", Window )
	
	local Text = vgui.Create( "DLabel", InnerPanel )
	Text:SetText( strText or "Message Text (Second Parameter)" )
	Text:SizeToContents()
	Text:SetContentAlignment( 5 )
	Text:SetFont( font or "Default" )
	Text:SetTextColor( color_white )

	local ButtonPanel = vgui.Create( "DPanel", Window )
	ButtonPanel:SetTall( 30 )

	-- Loop through all the options and create buttons for them.
	local NumOptions = 0
	local x = 5
	for k = 1, 8, 2 do
		if ( arg[ k ] == nil ) then break end
		
		local Text = arg[ k ]
		local Func = arg[ k + 1 ] or function() end
		
		local Button = vgui.Create( "DButton", ButtonPanel )
		Button:SetText( Text )
		Button:SizeToContents()
		Button:SetTall( 20 )
		Button:SetWide( Button:GetWide() + 20 )
		Button.DoClick = function() Window:Close() Func() end
		Button:SetPos( x, 5 )
		
		x = x + Button:GetWide() + 5
		
		ButtonPanel:SetWide( x ) 
		NumOptions = NumOptions + 1
	end

	local w, h = Text:GetSize()
	
	w = math.max( w, ButtonPanel:GetWide() )
	
	Window:SetSize( w + 50, h + 25 + 45 + 10 )
	Window:Center()
	
	InnerPanel:StretchToParent( 5, 27, 5, 45 )
	
	Text:StretchToParent( 5, 5, 5, 5 )	
	
	ButtonPanel:CenterHorizontal()
	ButtonPanel:AlignBottom( 8 )
	
	Window:DoModal()
	
	if ( NumOptions == 0 ) then
		Window:Close()
		Error( "Derma_Query: Created Query with no Options!?" )
	end
end