Initial commit

This commit is contained in:
2026-03-15 14:54:49 +03:00
commit 64f8029c06
4027 changed files with 254888 additions and 0 deletions

59
lua/vgui/prop_entity.lua Normal file
View File

@@ -0,0 +1,59 @@
--
-- prop_generic is the base for all other properties.
-- All the business should be done in :Setup using inline functions.
-- So when you derive from this class - you should ideally only override Setup.
--
DEFINE_BASECLASS( "DProperty_Generic" )
local PANEL = {}
function PANEL:Init()
end
function PANEL:Setup( vars )
vars = vars or {}
BaseClass.Setup( self, vars )
local btn = self:Add( "DButton" )
btn:Dock( LEFT )
btn:DockMargin( 0, 1, 4, 1 )
btn:SetWide( 24 )
btn:SetText( "" )
btn:SetImage( "icon16/wand.png" )
-- Use the world picked to select an entity
btn.DoClick = function( s )
-- Make it look different when selecting things
s:SetEnabled( false )
util.worldpicker.Start( function( tr )
self:SetEnabled( true )
if ( !IsValid( tr.Entity ) ) then return end
-- TODO: Maybe this should be EntSerial()?
self:ValueChanged( tr.Entity:EntIndex(), true )
end )
end
-- Enabled/disabled support
self.IsEnabled = function( slf )
return btn:IsEnabled()
end
local oldSetEnabled = self.SetEnabled
self.SetEnabled = function( slf, b )
btn:SetEnabled( b )
oldSetEnabled( b ) -- Also handle the text entry
end
end
derma.DefineControl( "DProperty_Entity", "", PANEL, "DProperty_Generic" )