Garry's Mod Wiki

IconEditor

Description

An icon editor that permits a user to modify a SpawnIcon and re-render it. This is used by the spawn menu and is what is shown when you right-click an icon and select Edit Icon.

This makes use of the DAdjustableModelPanel element.

This panel is only available in Sandbox and Sandbox derived gamemodes!

Parent

Derives from DFrame.

Methods

IconEditor:AboveLayout()
Applies the top-down view camera settings for the model in the DAdjustableModelPanel. Called when a user clicks the Above (third) button (See the ).
IconEditor:BestGuessLayout()
Applies the best camera settings for the model in the DAdjustableModelPanel, using the values returned by PositionSpawnIcon. Called when a user clicks the wand button (See the ) and when IconEditor:Refresh is called.
IconEditor:FillAnimations( Entity ent )
This is used internally - although you're able to use it you probably shouldn't. Fills the DListView on the left of the editor with the model entity's animation list. Called by IconEditor:Refresh.
IconEditor:FullFrontalLayout()
Applies the front view camera settings for the model in the DAdjustableModelPanel. Called when a user clicks the Front (second) button (See the ).
IconEditor:OriginLayout()
Places the camera at the origin (0,0,0), relative to the entity, in the DAdjustableModelPanel. Called when a user clicks the Center (fifth) button (See the ).
IconEditor:Refresh()
Updates the internal DAdjustableModelPanel and SpawnIcon. This should be called immediately after setting the SpawnIcon with IconEditor:SetIcon.
IconEditor:RenderIcon()
Re-renders the SpawnIcon. Called when a user clicks the RENDER button, this retrieves the render data from the internal DAdjustableModelPanel and passes it as a table to Panel:RebuildSpawnIconEx.
IconEditor:RightLayout()
Applies the right side view camera settings for the model in the DAdjustableModelPanel. Called when a user clicks the Right (fourth) button (See the ). (Note: The icon for this points left.)
IconEditor:SetDefaultLighting()
This is used internally - although you're able to use it you probably shouldn't. Sets up the default ambient and directional lighting for the DAdjustableModelPanel. Called by IconEditor:Refresh.
IconEditor:SetFromEntity( Entity ent )
Sets the editor's model and icon from an entity. Alternative to IconEditor:SetIcon, with uses a SpawnIcon. You do not need to call IconEditor:Refresh after this.
IconEditor:SetIcon( Panel icon )
Sets the SpawnIcon to modify. You should call Panel:Refresh immediately after this, as the user will not be able to make changes to the icon beforehand.
IconEditor:UpdateEntity( Entity ent )
This is used internally - although you're able to use it you probably shouldn't. Updates the entity being rendered in the internal DAdjustableModelPanel. Called by the model panel's DModelPanel:LayoutEntity method.

Example

Creates a SpawnIcon with model "models/props_borealis/bluebarrel001.mdl" and an IconEditor to modify it.

local frame = vgui.Create( "DFrame" ) -- Container for the SpawnIcon frame:SetPos( 200, 200 ) frame:SetSize( 200, 200 ) frame:SetTitle( "Icon Editor Example" ) frame:MakePopup() local icon = vgui.Create( "SpawnIcon" , frame ) -- SpawnIcon, with blue barrel model icon:Center() -- It is important below to include the SkinID (0 = default skin); the IconEditor will not work otherwise icon:SetModel( "models/props_borealis/bluebarrel001.mdl", 0 ) local editor = vgui.Create( "IconEditor" ) -- Create IconEditor editor:SetIcon( icon ) -- Set the SpawnIcon to modify editor:Refresh() -- Sets up the internal DAdjustableModelPanel and SpawnIcon editor:MakePopup() editor:Center()
Output: A DFrame containing a SpawnIcon, and a window identical to that in the preview above.

Page Links


Special Pages


Wikis

?

Render Time: 73ms

DB GetPage 43
Generate Html 6
SaveChanges (1) 8
Render Body 0
Render Sidebar 13