Hey guys, just looking to see if anyone is able to provide some insight on how to properly paint a DListView. I've asked around before alot of people recommended making a custom Derma Item but I'm not quite sure how to do that. I'm currently just trying to stylise a DListView to look something like image I made in photoshop. I just want to know how I can paint my DListView to look the way this image does, I'm not looking to bottom feed and get direct copy and paste answers thanks.
Desired Result or thereabouts Image:
https://files.facepunch.com/forum/upload/314674/28fece5d-b2b1-4a9d-9b14-930aec94287a/Untitled-1.png
Quite literally just looking how to convert a default derma panel to something similar to that, I've looked through quite a few threads and most are just related to text color etc.
What I've currently got so far for the Panel:
local Regiment_Player_List = vgui.Create( "DListView", RegPanel )
Regiment_Player_List:SetPos( RegPanel:GetWide() / 30, RegPanel:GetTall() / 20 + PromoPanel_Title:GetTall() )
Regiment_Player_List:SetSize( RegPanel:GetWide() - (RegPanel:GetWide() / 30) * 2, PromoPanel_Title:GetTall() * 8 )
Regiment_Player_List:SetMultiSelect( false )
Regiment_Player_List:AddColumn( "Name" )
Regiment_Player_List:AddColumn( "SteamID" )
Regiment_Player_List:AddColumn( "Regiment" )
Regiment_Player_List:AddColumn( "Rank" )
Regiment_Player_List.OnRowSelected = function( self, line )
local ply = self:GetLine( line ):GetValue( 2 )
selPlayer = player.GetBySteamID( ply )
end
for k, v in pairs( player.GetAll() ) do
Regiment_Player_List:AddLine( v:Nick(), v:SteamID(), TeamTable[ v:Team() ].Regiment, TeamTable[ v:Team() ].Name )
Regiment_Player_List:SortByColumn( 1, false )
end
Try this:
for k , v in pairs( player.GetAll() ) do
playerlist:AddLine( v:Nick() , v:SteamID() )
playerlist:GetLine( k ).Paint = function( s , w , h )
end
Is that editing the lines or the column headers?
The way I paint the lines is
for k, v in pairs( PlayerList.Lines ) do -- Paint lines and change font
for id, lbl in pairs(v.Columns) do -- Change the font of the lines
lbl:SetFont("DermaDefault")
lbl:SetContentAlignment(5)
lbl:SetColor(Color(0,0,0))
end
function v:Paint(w, h) -- Paint the lines
surface.SetDrawColor(Color(255,255,255))
surface.DrawRect(0, 0, w, h)
surface.SetDrawColor(Color(0,0,0))
surface.DrawRect(0, h-3, w, 3)
end
end
To paint the headers
for k, v in pairs(PlayerList.Columns) do -- Paint headers
v.Header:SetFont("DermaDefault") -- Change header text font
v.Header:SetColor(Color(255,255,255)) -- Change header text color
function v.Header:Paint(w, h) -- Paint header
surface.SetDrawColor(Color(0,0,0))
surface.DrawRect(0, 0, w, h)
end
end
Just adding this in just in case you or someone else finds this via google, To paint the scroll bar
local plyBar = PlayerList.VBar -- Paint vbar
function plyBar:Paint( w, h )
surface.SetDrawColor(Color(80,80,80))
surface.DrawRect(0, 0, w, h)
end
function plyBar.btnUp:Paint( w, h )
surface.SetDrawColor(Color(150,150,150))
surface.DrawRect(0, 0, w, h)
end
function plyBar.btnDown:Paint( w, h )
surface.SetDrawColor(Color(150,150,150))
surface.DrawRect(0, 0, w, h)
end
function plyBar.btnGrip:Paint( w, h )
surface.SetDrawColor(Color(255,255,255))
surface.DrawRect(0, 0, w, h)
end
Sorry, you need to Log In to post a reply to this thread.