DImage/SetImage

From Garry's Mod
Jump to: navigation, search
 DImage:SetImage( )

Contents

DescriptionPanelFunc

Sets the image to load into the frame. If the first image can't be loaded and strBackup is set, that image will be loaded instead.

This eventually calls DImage:SetMaterial.

Arguments

string strImage

The path of the image to load. When no file extension is supplied the VMT file extension is used.

Arguments

string strBackup=nil

The path of the backup image.

Examples

Example

Creates a frame with a map of de_inferno inside, with the default avatar image loaded as a backup.

-- Frame
MainFrame = vgui.Create( "DFrame" )
MainFrame:SetSize( 300, 300 )
MainFrame:Center()
MainFrame:SetTitle( "Map of de_inferno" )

-- Map of de_inferno (requires CS:S)
local css_map = vgui.Create( "DImage", MainFrame )
css_map:SetPos( 25, 40 )
css_map:SetSize( 250, 250 )

-- Set image to de_inferno map
-- If it can't be loaded, load the [?] avatar image instead
css_map:SetImage("overviews/de_inferno", "vgui/avatar_default")

Output:

If CS:S is mounted then the left image is shown, otherwise the right image is shown.

DImage SetImage example1.jpg DImage SetImage example2.jpg
Personal tools
Navigation