Im stuck on how to get my .vtf to show and also how to position them.
http://img268.imageshack.us/img268/4017/dimagebutton.jpg
as you can see my image is in the top left and without its image. Any help on how to get it to show and also how to evenly space my images on my panel (left panel). Thanks.
here is my code.
[lua]
local PANEL = { }
local PANEL = { }
function PANEL:Init( )
self.Label = vgui.Create( “DLabel”, self )
self.Label:SetText( “Click on an item to buy it” )
self.Label:SetTextColor( Color( 255, 255, 255, 255 ) )
self.Label:SizeToContents( )
self.ListList = vgui.Create( "DPanelList", self )
for k, v in pairs(ItemInfo) do
local trails = vgui.Create("DImageButton")
trails:SetImage(v.IMG)
trails:SetToolTip(v.Tip)
trails.DoClick = function()
RunConsoleCommand("Purchase", v.Item)
trails:SetVisible(false)
RememberCursorPosition()
gui.EnableScreenClicker(false)
end
end
end
function PANEL:PerformLayout( )
self:StretchToParent( 2, 24, 2, 2 )
self.Label:SetPos( 2, 2 )
self.ListList:StretchToParent( 4, 26, 4, 4 )
self.ListList:InvalidateLayout()
end
vgui.Register( “buy”, PANEL, “DPanel” )
[/lua]
here is a part of my table
[lua]ItemInfo[1] = {
IMG = “materials/trails/angry.vtf”,
Item = “angry”,
Tip = “Name: Angry trail
Cost: $30000”
}[/lua]
thanks for all help and yes I did try to use http://wiki.garrysmod.com before posting.