Garry's Mod Wiki

GM:SpawniconGenerated

  GM:SpawniconGenerated( string lastmodel, string imagename, number modelsleft )

Description

Called when spawn icon is generated.

Arguments

1 string lastmodel
File path of previously generated model.
2 string imagename
File path of the generated icon.
3 number modelsleft
Amount of models left to generate.

Example

That's how it is used in garrysmod/lua/includes/gui/icon_progress.lua for show progress of generating icons

local g_Progress = nil hook.Add( "SpawniconGenerated", "SpawniconGenerated", function( lastmodel, imagename, modelsleft ) if ( !IsValid( g_Progress ) ) then g_Progress = vgui.Create( "DPanel" ) g_Progress:SetSize( 64+10, 64+10+20 ) g_Progress:SetBackgroundColor( Color( 0, 0, 0, 100 ) ) g_Progress:SetDrawOnTop( true ) g_Progress:DockPadding( 5, 0, 5, 5 ) g_Progress.Think = function() if ( SysTime() - g_Progress.LastTouch < 3 ) then return end g_Progress:Remove() g_Progress.LastTouch = SysTime() end local label = g_Progress:Add( "DLabel" ) label:Dock( BOTTOM ) label:SetText( "remaining" ) label:SetTextColor( Color( 255, 255, 255, 255 ) ) label:SetExpensiveShadow( 1, Color( 0, 0, 0, 200 ) ) label:SetContentAlignment( 5 ) label:SetHeight( 14 ) label:SetFont( "DefaultSmall" ) g_Progress.Label = g_Progress:Add( "DLabel" ) g_Progress.Label:Dock( BOTTOM ) g_Progress.Label:SetTextColor( Color( 255, 255, 255, 255 ) ) g_Progress.Label:SetExpensiveShadow( 1, Color( 0, 0, 0, 200 ) ) g_Progress.Label:SetContentAlignment( 5 ) g_Progress.Label:SetFont( "DermaDefaultBold" ) g_Progress.Label:SetHeight( 14 ) g_Progress.icon = vgui.Create( "DImage", g_Progress ) g_Progress.icon:SetSize( 64, 64 ) g_Progress.icon:Dock( TOP ) end g_Progress.LastTouch = SysTime() imagename = imagename:Replace( "materials\\", "" ) imagename = imagename:Replace( "materials/", "" ) g_Progress.icon:SetImage( imagename ) g_Progress:AlignRight( 10 ) g_Progress:AlignBottom( 10 ) g_Progress.Label:SetText( modelsleft ) end )
Output: