G.GetLoadPanel

From GMod Wiki

Jump to: navigation, search
Function
Syntax GetLoadPanel( )
Where is this used?
Description:
Gets the panel object for the server loading/disconnect screen, creates it if it does not exist.
Returns: Panel
Part of Library: Global Functions
Realm: Menu.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=G.GetLoadPanel]G.GetLoadPanel [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


Examples

DescriptionOverrides the loading screen's Paint function and sets the background of the loading screen to a texture
Used onMenu.png
Code
// Gott'a let the panel be created before we can fetch it. Let's wait for a second
timer.Simple( 1, 
	function()
		// Make sure this function exists( Doesn't exist when you are on a server )
		if ( GetLoadPanel == nil ) then return; end
 
		// Get the panel object for the loading screen
		local loadPanel = GetLoadPanel( );
 
		// And don't forget to store the old paint function, we need it later.
		local oldPaint = loadPanel.Paint;
		function loadPanel:Paint( )
			// Make sure to call the old paint function
			oldPaint( self );
 
			// Now we can start drawing our stuff!
			// Draw the background
				surface.SetDrawColor( 0, 0, 0, 255 ); // Set this to what you want, I like black.
				surface.DrawRect( 0, 0, ScrW( ), ScrH( ) );
 
			// Draw the portal
				surface.SetDrawColor( 255, 255, 255, 255 );
				surface.SetTexture( surface.GetTextureID( "models/props_combine/combine_citadelcloudcenter" ) ); // Feel free to replace this texture
				surface.DrawTexturedRect( 0, 0, ScrW( ), ScrH( ) );
		end
	end
);
OutputA combine portal as a loading screen background!
Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox