Using my own image with DImage goes wrong

Hey there,

So i’m busy with a little loadingscreen for my own gamemode, but I’d like to add my community it’s logo into the frame.
I have already converted the PNG to .vtf and placed it into the following folder: content/materials/logo.vtf
I made a script wich should let the player download the file with resource.AddFile(“path”)
My script looks this right now but appears to be purple and black.


	local logo = vgui.Create( "DImage", Frame )
	logo:SetPos( 10, 35 )
	logo:SetSize( 150, 150 )	
	logo:SetImage( "content/materials/logo" )

Any idea to fix?

Remove “content/materials/” It already looks in the materials folder.

Didn’t work at all :frowning:

No clue if this will work, but try



logo:SetImage( "logo.vtf" )


[editline]17th May 2016[/editline]

The wiki says it assumes it’s a .VMT file if no extension is put at the end, and I assume you haven’t made a .VMT for it yet

Didn’t work :frowning:

Okay. this is my folder setup: Gamemode -> Content -> Materials -> logo.vtf
I got a cl_autodownload.lua file located in the Gamemode folder wich has : resource.AddFile( “content/materials/primeturtles_logo.vtf” )

My code looks this right now.



function SpawnMenu()
	local Frame = vgui.Create( "DFrame" )
	Frame:SetPos( 0, 0 )
	Frame:SetSize( ScrW() * 1.0, ScrH() * 1.0 )
	Frame:SetTitle( "" )
	Frame:SetVisible( true )
	Frame:SetDraggable( false )
	Frame:ShowCloseButton( false )
	Frame:MakePopup()
	Frame.Paint = function( self, w, h )
	draw.RoundedBox( 0, 0, 0, w, h, Color( 61, 61, 61, 255 ) )
	end
	
	if Frame:IsValid() then 
		timer.Simple( 5, function()
			Frame:Close() 
			SecondSpawnMenu()		
		end )
	end
	
	local logo = vgui.Create( "DImage", Frame )
	logo:SetPos( 10, 35 )
	logo:SetSize( 150, 150 )	
	logo:SetImage( "logo.vtf" )
	
	local DLabel = vgui.Create( "DLabel", Frame )
	DLabel:SetPos( ScrW()/2, ScrH()/2 )
	DLabel:SetText( "Welcome on my server! Player data is being loaded!" )
	DLabel:SizeToContents()
	DLabel:Center()
end
usermessage.Hook( "SpawnMenu", SpawnMenu )

function SecondSpawnMenu()
	local SecondFrame = vgui.Create( "DFrame" )
	SecondFrame:SetPos( 0, 0 )
	SecondFrame:SetSize( ScrW() * 1.0, ScrH() * 1.0 )
	SecondFrame:SetTitle( "" )
	SecondFrame:SetVisible( true )
	SecondFrame:SetDraggable( false )
	SecondFrame:ShowCloseButton( false )
	SecondFrame:MakePopup()
	SecondFrame.Paint = function( self, w, h )
	draw.RoundedBox( 0, 0, 0, w, h, Color( 61, 61, 61, 255 ) )
	end
	
	if SecondFrame:IsValid() then
		timer.Simple( 3, function() SecondFrame:Close() end )
	end
	
	local SecondDLabel = vgui.Create( "DLabel", SecondFrame )
	SecondDLabel:SetPos( ScrW()/2, ScrH()/2 )
	SecondDLabel:SetText( "Setting player data up..." )
	SecondDLabel:SizeToContents()
	SecondDLabel:Center()
end


cl_init.lua has include(“cl_autodownload.lua”)
and init.lua has AddCSLuaFile(“cl_autodownload.lua”)

primeturtles_logo isn’t the same as logo…

Are you seeing purple and black textures? You can’t just resource addfile you need to make sure you’ve got FastDL or another medium to download it through.

Also what is the actual file name you’ve named it differently in the resource code and differently in the SetImage. That’s obviously not going to work, seems like you made a mistake.

I’ve fixed it already. I looked a bit further on the web and found this.



	-- Load post process effect thumbnail
	local postprocess = vgui.Create( "DImage", Frame )
	postprocess:SetSize( 436, 128 )
	postprocess:Center()

	local materials = file.Find( "content/materials/primeturtles_logo.png", "GAME" )

	postprocess:SetImage( "content/materials/primeturtles_logo.png" )


I made an addon wich has the file included and it works fine :smiley: