Category:ContentIcon

From Garry's Mod
Jump to: navigation, search

Contents

DescriptionPanelPage

The spawn icon used for SWEPs and other SENTs, commonly featured as part of the spawn menu. Do note that at least one of your ContentIcon's parents must either be an EditablePanel or derived from it (like a DFrame, for example), else it won't be able to focus and thus be unclickable.

This control only exists in Sandbox derived gamemodes.

Inherited Functions

Inherits the following functions from DButton and its parents up to 3 levels deep:


Examples

Example

Creates a button to spawn one or multiple pistols on top of a custom DFrame.

local frame = vgui.Create( "DFrame" )
frame:SetSize( 400, 200 )
frame:Center()
frame:SetTitle( "Secret SWEP Spawn Menu" )
frame:MakePopup()

local icon = vgui.Create( "ContentIcon", frame )
icon:Center()
icon:SetMaterial( "entities/weapon_pistol.png" )
icon:SetName( "Pistol" )
icon.DoClick = function() RunConsoleCommand( "gm_spawnswep", "weapon_pistol" ) end
icon.OpenMenu = function()
	local menu = DermaMenu()
	menu:AddOption( "Copy to clipboard", function() SetClipboardText( "weapon_pistol" ) end )
	menu:AddOption( "Spawn 5", function() for i=1,5 do RunConsoleCommand( "gm_spawnswep", "weapon_pistol" ) end end )
	menu:AddOption( "Spawn 10", function() for i=1,10 do RunConsoleCommand( "gm_spawnswep", "weapon_pistol" ) end end )
	menu:Open()
end

Output:


ContentIconExample.png
Personal tools
Navigation