Debug inv tweaks

This commit is contained in:
Fesiug 2023-11-18 03:40:42 -05:00
parent 9d25f5751c
commit 838319327d
1 changed files with 60 additions and 15 deletions

View File

@ -225,7 +225,6 @@ if CLIENT then
table.insert( createlist[Class.Type], { ClassName = ClassName, Class = Class } )
end
for i, v in SortedPairs( createlist ) do
local Collapse = itemlist:Add( "DCollapsibleCategory" )
Collapse:Dock( TOP )
@ -278,18 +277,61 @@ if CLIENT then
local inv = ply:INV_Get()
local active = GetConVar("benny_hud_tempactive"):GetString()
itemlist:Clear()
local maidlist = {}
local catesmade = {}
for i, v in pairs( ply:INV_ListFromBuckets() ) do
local class = inv[v].Class
local Class = WEAPONS[class]
if !catesmade[Class.Type] then
catesmade[Class.Type] = true
local cate = vgui.Create( "DButton" )
itemlist:AddItem( cate )
cate:SetSize( 1, ss(12) )
cate:Dock( TOP )
cate:DockMargin( 0, 0, 0, ss(2) )
cate.Text_Name = Class.Type
function cate:Paint( w, h )
surface.SetDrawColor( schemes[active]["bg"] )
surface.DrawRect( 0, 0, w, h )
surface.SetDrawColor( schemes[active]["fg"] )
surface.DrawOutlinedRect( 0, 0, w, h, ss(0.5) )
surface.SetTextColor( schemes[active]["fg"] )
surface.SetFont( "Benny_10" )
surface.SetTextPos( ss(2), ss(2) )
surface.DrawText( self.Text_Name )
return true
end
end
local button = vgui.Create( "DButton" )
itemlist:AddItem( button )
button:SetSize( 1, ss(30) )
button:SetSize( 1, ss(24) )
button:Dock( TOP )
button:DockMargin( 0, 0, 0, ss(4) )
button:DockMargin( 0, 0, 0, ss(2) )
button.ID = v
local Class = WEAPONS[inv[v].Class]
local mag = false
if class:Left( 4 ) == "mag_" then
mag = true
button:SetTall( ss(11) )
end
if !maidlist[class] then
maidlist[class] = table.Flip( ply:INV_Find( class ) )
end
local ml = maidlist[class]
button.Text_Name = Class.Name
button.Text_Desc = Class.Description
button.Text_ID = "[" .. ml[v] .. "] " .. button.ID
-- PROTO: These functions don't need to be remade over and over like this.
function button:DoClick()
@ -351,18 +393,20 @@ if CLIENT then
surface.SetTextColor( schemes[active]["bg"] )
surface.SetFont( "Benny_16" )
surface.SetTextPos( ss(4), ss(4) )
surface.SetFont( !mag and "Benny_16" or "Benny_10" )
surface.SetTextPos( ss(2), ss(2) )
surface.DrawText( self.Text_Name )
surface.SetFont( "Benny_12" )
surface.SetTextPos( ss(4), ss(4 + 12) )
surface.DrawText( self.Text_Desc )
if !mag then
surface.SetFont( "Benny_12" )
surface.SetTextPos( ss(2), ss(2 + 11) )
surface.DrawText( self.Text_Desc )
end
surface.SetFont( "Benny_12" )
local tx = surface.GetTextSize( self.ID )
surface.SetTextPos( w - ss(4) - tx, ss(4) )
surface.DrawText( self.ID )
surface.SetFont( "Benny_10" )
local tx = surface.GetTextSize( self.Text_ID )
surface.SetTextPos( w - ss(2) - tx, ss(2) )
surface.DrawText( self.Text_ID )
return true
end
end
@ -370,13 +414,14 @@ if CLIENT then
concommand.Add("benny_debug_inv", function()
if IsValid( base ) then base:Remove() end
base = vgui.Create("DFrame")
base:SetSize( ss(400), ss(240) )
base:SetSize( ss(400), ss(400) )
base:MakePopup()
base:SetKeyboardInputEnabled( false )
base:Center()
local active = GetConVar("benny_hud_tempactive"):GetString()
function base:Paint( w, h )
surface.SetDrawColor( schemes["benny"]["bg"] )
surface.SetDrawColor( schemes[active]["bg"] )
surface.DrawRect( 0, 0, w, h )
return true
end