Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated deprecated CPanel calls #2184

Merged
merged 10 commits into from
Jan 21, 2025
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ SWEP.Spawnable = true
util.PrecacheModel( SWEP.ViewModel )
util.PrecacheModel( SWEP.WorldModel )

-- Todo, make/find a better sound.
SWEP.ShootSound = Sound( "Airboat.FireGunRevDown" )

SWEP.Tool = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function ToolObj:RebuildControlPanel( ... )
local cPanel = controlpanel.Get( self.Mode )
if ( !cPanel ) then ErrorNoHalt( "Couldn't find control panel to rebuild!" ) return end

cPanel:ClearControls()
cPanel:Clear()
self.BuildCPanel( cPanel, ... )

end
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,19 @@ local ConVarsDefault = TOOL:BuildConVarList()

function TOOL.BuildCPanel( CPanel )

CPanel:AddControl( "Header", { Description = "#tool.axis.help" } )
CPanel:Help( "#tool.axis.help" )
CPanel:ToolPresets( "axis", ConVarsDefault )

CPanel:AddControl( "ComboBox", { MenuButton = 1, Folder = "axis", Options = { [ "#preset.default" ] = ConVarsDefault }, CVars = table.GetKeys( ConVarsDefault ) } )
CPanel:NumSlider( "#tool.forcelimit", "axis_forcelimit", 0, 50000, 2 )
CPanel:ControlHelp( "#tool.forcelimit.help" )

CPanel:AddControl( "Slider", { Label = "#tool.forcelimit", Command = "axis_forcelimit", Type = "Float", Min = 0, Max = 50000, Help = true } )
CPanel:AddControl( "Slider", { Label = "#tool.torquelimit", Command = "axis_torquelimit", Type = "Float", Min = 0, Max = 50000, Help = true } )
CPanel:AddControl( "Slider", { Label = "#tool.hingefriction", Command = "axis_hingefriction", Type = "Float", Min = 0, Max = 200, Help = true } )
CPanel:AddControl( "CheckBox", { Label = "#tool.nocollide", Command = "axis_nocollide", Help = true } )
CPanel:NumSlider( "#tool.torquelimit", "axis_torquelimit", 0, 50000, 2 )
CPanel:ControlHelp( "#tool.torquelimit.help" )

CPanel:NumSlider( "#tool.hingefriction", "axis_hingefriction", 0, 200, 2 )
CPanel:ControlHelp( "#tool.hingefriction.help" )

CPanel:CheckBox( "#tool.nocollide", "axis_nocollide" )
CPanel:ControlHelp( "#tool.nocollide.help" )

end
Original file line number Diff line number Diff line change
Expand Up @@ -218,15 +218,17 @@ local ConVarsDefault = TOOL:BuildConVarList()

function TOOL.BuildCPanel( CPanel )

CPanel:AddControl( "Header", { Description = "#tool.balloon.help" } )
CPanel:Help( "#tool.balloon.help" )
CPanel:ToolPresets( "balloon", ConVarsDefault )

CPanel:AddControl( "ComboBox", { MenuButton = 1, Folder = "balloon", Options = { [ "#preset.default" ] = ConVarsDefault }, CVars = table.GetKeys( ConVarsDefault ) } )
CPanel:NumSlider( "#tool.balloon.ropelength", "balloon_ropelength", 5, 1000, 2 )

CPanel:AddControl( "Slider", { Label = "#tool.balloon.ropelength", Type = "Float", Command = "balloon_ropelength", Min = 5, Max = 1000 } )
CPanel:AddControl( "Slider", { Label = "#tool.balloon.force", Type = "Float", Command = "balloon_force", Min = -1000, Max = 2000, Help = true } )
CPanel:AddControl( "Color", { Label = "#tool.balloon.color", Red = "balloon_r", Green = "balloon_g", Blue = "balloon_b" } )
CPanel:NumSlider( "#tool.balloon.force", "balloon_force", -1000, 2000, 2 )
CPanel:ControlHelp( "#tool.balloon.force.help" )

CPanel:AddControl( "PropSelect", { Label = "#tool.balloon.model", ConVar = "balloon_model", Height = 0, ModelsTable = list.Get( "BalloonModels" ) } )
CPanel:ColorPicker( "#tool.balloon.color", "balloon_r", "balloon_g", "balloon_b" )

CPanel:PropSelect( "#tool.balloon.model", "balloon_model", list.Get( "BalloonModels" ), 0 )

end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,16 @@ local ConVarsDefault = TOOL:BuildConVarList()

function TOOL.BuildCPanel( CPanel )

CPanel:AddControl( "Header", { Description = "#tool.ballsocket.help" } )
CPanel:Help( "#tool.ballsocket.help" )
CPanel:ToolPresets( "ballsocket", ConVarsDefault )

CPanel:AddControl( "ComboBox", { MenuButton = 1, Folder = "ballsocket", Options = { [ "#preset.default" ] = ConVarsDefault }, CVars = table.GetKeys( ConVarsDefault ) } )
CPanel:NumSlider( "#tool.forcelimit", "ballsocket_forcelimit", 0, 50000, 2 )
CPanel:ControlHelp( "#tool.forcelimit.help" )

CPanel:AddControl( "Slider", { Label = "#tool.forcelimit", Command = "ballsocket_forcelimit", Type = "Float", Min = 0, Max = 50000, Help = true } )
--CPanel:AddControl( "Slider", { Label = "#tool.torquelimit", Command = "ballsocket_torquelimit", Type = "Float", Min = 0, Max = 50000, Help = true } )
CPanel:AddControl( "CheckBox", { Label = "#tool.nocollide", Command = "ballsocket_nocollide", Help = true } )
--CPanel:NumSlider( "#tool.torquelimit", "ballsocket_torquelimit", 0, 50000, 2 )
--CPanel:ControlHelp( "#tool.torquelimit.help" )

CPanel:CheckBox( "#tool.nocollide", "ballsocket_nocollide" )
CPanel:ControlHelp( "#tool.nocollide.help" )

end
Original file line number Diff line number Diff line change
Expand Up @@ -171,17 +171,17 @@ local ConVarsDefault = TOOL:BuildConVarList()

function TOOL.BuildCPanel( CPanel )

CPanel:AddControl( "Header", { Description = "#tool.button.desc" } )
CPanel:Help( "#tool.button.desc" )
CPanel:ToolPresets( "button", ConVarsDefault )

CPanel:AddControl( "ComboBox", { MenuButton = 1, Folder = "button", Options = { [ "#preset.default" ] = ConVarsDefault }, CVars = table.GetKeys( ConVarsDefault ) } )
CPanel:KeyBinder( "#tool.button.key", "button_keygroup" )

CPanel:AddControl( "Numpad", { Label = "#tool.button.key", Command = "button_keygroup" } )
CPanel:TextEntry( "#tool.button.text", "button_description" )

CPanel:AddControl( "TextBox", { Label = "#tool.button.text", Command = "button_description", MaxLenth = "20" } )
CPanel:CheckBox( "#tool.button.toggle", "button_toggle" )
CPanel:ControlHelp( "#tool.button.toggle.help" )

CPanel:AddControl( "CheckBox", { Label = "#tool.button.toggle", Command = "button_toggle", Help = true } )

CPanel:AddControl( "PropSelect", { Label = "#tool.button.model", ConVar = "button_model", Height = 0, Models = list.Get( "ButtonModels" ) } )
CPanel:PropSelect( "#tool.button.model", "button_model", list.Get( "ButtonModels" ), 0 )

end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,13 @@ local ConVarsDefault = TOOL:BuildConVarList()

function TOOL.BuildCPanel( CPanel )

CPanel:AddControl( "ComboBox", { MenuButton = 1, Folder = "camera", Options = { [ "#preset.default" ] = ConVarsDefault }, CVars = table.GetKeys( ConVarsDefault ) } )
CPanel:ToolPresets( "camera", ConVarsDefault )

CPanel:AddControl( "Numpad", { Label = "#tool.camera.key", Command = "camera_key" } )
CPanel:AddControl( "CheckBox", { Label = "#tool.camera.static", Command = "camera_locked", Help = true } )
CPanel:AddControl( "CheckBox", { Label = "#tool.toggle", Command = "camera_toggle" } )
CPanel:KeyBinder( "#tool.camera.key", "camera_key" )

CPanel:CheckBox( "#tool.camera.static", "camera_locked" )
CPanel:ControlHelp( "#tool.camera.static.help" )

CPanel:CheckBox( "#tool.toggle", "camera_toggle" )

end
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,13 @@ local ConVarsDefault = TOOL:BuildConVarList()

function TOOL.BuildCPanel( CPanel )

CPanel:AddControl( "Header", { Description = "#tool.colour.desc" } )

CPanel:Help( "#tool.colour.desc" )
CPanel:ToolPresets( "colour", ConVarsDefault )

CPanel:ColorPicker( "#tool.colour.color", "colour_r", "colour_g", "colour_b", "colour_a" )

CPanel:AddControl( "ListBox", { Label = "#tool.colour.mode", Options = list.Get( "RenderModes" ) } )
CPanel:AddControl( "ListBox", { Label = "#tool.colour.fx", Options = list.Get( "RenderFX" ) } )
CPanel:ComboBoxMulti( "#tool.colour.mode", list.Get( "RenderModes" ) )
CPanel:ComboBoxMulti( "#tool.colour.fx", list.Get( "RenderFX" ) )

end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,26 +139,26 @@ if ( CLIENT ) then
--
function TOOL.BuildCPanel( CPanel, tool )

CPanel:ClearControls()
CPanel:Clear()

CPanel:AddControl( "Header", { Description = "#tool.duplicator.desc" } )
CPanel:Help( "#tool.duplicator.desc" )

CPanel:AddControl( "Button", { Text = "#tool.duplicator.showsaves", Command = "dupe_show" } )
CPanel:Button( "#tool.duplicator.showsaves", "dupe_show" )

if ( !tool && IsValid( LocalPlayer() ) ) then tool = LocalPlayer():GetTool( "duplicator" ) end
if ( !tool || !tool.CurrentDupeName ) then return end

local info = "Name: " .. tool.CurrentDupeName
info = info .. "\nEntities: " .. tool.CurrentDupeEntCount

CPanel:AddControl( "Label", { Text = info } )
CPanel:Help( info )

if ( tool.CurrentDupeWSIDs && #tool.CurrentDupeWSIDs > 0 ) then
CPanel:AddControl( "Label", { Text = "Required workshop content:" } )
CPanel:Help( "Required workshop content:" )
for _, wsid in pairs( tool.CurrentDupeWSIDs ) do
local subbed = ""
if ( steamworks.IsSubscribed( wsid ) ) then subbed = " (Subscribed)" end
local b = CPanel:AddControl( "Button", { Text = wsid .. subbed } )
local b = CPanel:Button( wsid .. subbed )
b.DoClick = function( s, ... ) steamworks.ViewFile( wsid ) end
steamworks.FileInfo( wsid, function( result )
if ( !IsValid( b ) ) then return end
Expand All @@ -168,7 +168,7 @@ if ( CLIENT ) then
end

if ( tool.CurrentDupeCanSave ) then
local b = CPanel:AddControl( "Button", { Text = "#dupes.savedupe", Command = "dupe_save" } )
local b = CPanel:Button( "#dupes.savedupe", "dupe_save" )
hook.Add( "DupeSaveUnavailable", b, function() b:Remove() end )
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,16 +162,20 @@ local ConVarsDefault = TOOL:BuildConVarList()

function TOOL.BuildCPanel( CPanel )

CPanel:AddControl( "Header", { Description = "#tool.dynamite.help" } )
CPanel:Help( "#tool.dynamite.help" )
CPanel:ToolPresets( "dynamite", ConVarsDefault )

CPanel:AddControl( "ComboBox", { MenuButton = 1, Folder = "dynamite", Options = { [ "#preset.default" ] = ConVarsDefault }, CVars = table.GetKeys( ConVarsDefault ) } )
CPanel:KeyBinder( "#tool.dynamite.explode", "dynamite_group" )

CPanel:AddControl( "Numpad", { Label = "#tool.dynamite.explode", Command = "dynamite_group" } )
CPanel:AddControl( "Slider", { Label = "#tool.dynamite.damage", Command = "dynamite_damage", Type = "Float", Min = 0, Max = 500, Help = true } )
CPanel:AddControl( "Slider", { Label = "#tool.dynamite.delay", Command = "dynamite_delay", Type = "Float", Min = 0, Max = 10, Help = true } )
CPanel:AddControl( "CheckBox", { Label = "#tool.dynamite.remove", Command = "dynamite_remove" } )
CPanel:NumSlider( "#tool.dynamite.damage", "dynamite_damage", 0, 500, 2 )
CPanel:ControlHelp( "#tool.dynamite.damage.help" )

CPanel:AddControl( "PropSelect", { Label = "#tool.dynamite.model", ConVar = "dynamite_model", Height = 0, Models = list.Get( "DynamiteModels" ) } )
CPanel:NumSlider( "#tool.dynamite.delay", "dynamite_delay", 0, 10, 2 )
CPanel:ControlHelp( "#tool.dynamite.delay.help" )

CPanel:CheckBox( "#tool.dynamite.remove", "dynamite_remove" )

CPanel:PropSelect( "#tool.dynamite.model", "dynamite_model", list.Get( "DynamiteModels" ), 0 )

end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function TOOL:Think()
local CPanel = controlpanel.Get( "editentity" )
if ( !CPanel ) then return end

CPanel:ClearControls()
CPanel:Clear()
self.BuildCPanel( CPanel, CurrentEditing )

end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,25 @@ local ConVarsDefault = TOOL:BuildConVarList()

function TOOL.BuildCPanel( CPanel )

CPanel:AddControl( "Header", { Description = "#tool.elastic.help" } )
CPanel:Help( "#tool.elastic.help" )
CPanel:ToolPresets( "elastic", ConVarsDefault )

CPanel:AddControl( "ComboBox", { MenuButton = 1, Folder = "elastic", Options = { [ "#preset.default" ] = ConVarsDefault }, CVars = table.GetKeys( ConVarsDefault ) } )
CPanel:NumSlider( "#tool.elastic.constant", "elastic_constant", 0, 4000, 2 )
CPanel:ControlHelp( "#tool.elastic.constant.help" )

CPanel:AddControl( "Slider", { Label = "#tool.elastic.constant", Command = "elastic_constant", Type = "Float", Min = 0, Max = 4000, Help = true } )
CPanel:AddControl( "Slider", { Label = "#tool.elastic.damping", Command = "elastic_damping", Type = "Float", Min = 0, Max = 50, Help = true } )
CPanel:AddControl( "Slider", { Label = "#tool.elastic.rdamping", Command = "elastic_rdamping", Type = "Float", Min = 0, Max = 1, Help = true } )
CPanel:AddControl( "CheckBox", { Label = "#tool.elastic.stretchonly", Command = "elastic_stretch_only", Help = true } )
CPanel:NumSlider( "#tool.elastic.damping", "elastic_damping", 0, 50, 2 )
CPanel:ControlHelp( "#tool.elastic.damping.help" )

CPanel:AddControl( "Slider", { Label = "#tool.elastic.width", Command = "elastic_width", Type = "Float", Min = 0, Max = 20 } )
CPanel:AddControl( "RopeMaterial", { Label = "#tool.elastic.material", ConVar = "elastic_material" } )
CPanel:AddControl( "Color", { Label = "#tool.elastic.color", Red = "elastic_color_r", Green = "elastic_color_g", Blue = "elastic_color_b" } )
CPanel:NumSlider( "#tool.elastic.rdamping", "elastic_rdamping", 0, 1, 2 )
CPanel:ControlHelp( "#tool.elastic.rdamping.help" )

CPanel:CheckBox( "#tool.elastic.stretchonly", "elastic_stretch_only" )
CPanel:ControlHelp( "#tool.elastic.stretchonly.help" )

CPanel:NumSlider( "#tool.elastic.width", "elastic_width", 0, 20, 2 )

CPanel:RopeSelect( "elastic_material" )

CPanel:ColorPicker( "#tool.elastic.color", "elastic_color_r", "elastic_color_g", "elastic_color_b" )

end
Original file line number Diff line number Diff line change
Expand Up @@ -184,17 +184,17 @@ local ConVarsDefault = TOOL:BuildConVarList()

function TOOL.BuildCPanel( CPanel )

CPanel:AddControl( "Header", { Description = "#tool.emitter.desc" } )
CPanel:Help( "#tool.emitter.desc" )
CPanel:ToolPresets( "emitter", ConVarsDefault )

CPanel:AddControl( "ComboBox", { MenuButton = 1, Folder = "emitter", Options = { [ "#preset.default" ] = ConVarsDefault }, CVars = table.GetKeys( ConVarsDefault ) } )
CPanel:KeyBinder( "#tool.emitter.key", "emitter_key" )
CPanel:NumSlider( "#tool.emitter.delay", "emitter_delay", 0.01, 2, 2 )

CPanel:AddControl( "Numpad", { Label = "#tool.emitter.key", Command = "emitter_key" } )
CPanel:NumSlider( "#tool.emitter.scale", "emitter_scale", 0, 6, 2 )
CPanel:ControlHelp( "#tool.emitter.scale.help" )

CPanel:AddControl( "Slider", { Label = "#tool.emitter.delay", Command = "emitter_delay", Type = "Float", Min = 0.01, Max = 2 } )
CPanel:AddControl( "Slider", { Label = "#tool.emitter.scale", Command = "emitter_scale", Type = "Float", Min = 0, Max = 6, Help = true } )

CPanel:AddControl( "Checkbox", { Label = "#tool.emitter.toggle", Command = "emitter_toggle" } )
CPanel:AddControl( "Checkbox", { Label = "#tool.emitter.starton", Command = "emitter_starton" } )
CPanel:CheckBox( "#tool.emitter.toggle", "emitter_toggle" )
CPanel:CheckBox( "#tool.emitter.starton", "emitter_starton" )

local matselect = CPanel:MatSelect( "emitter_effect", nil, true, 0.25, 0.25 )
for k, v in pairs( list.Get( "EffectType" ) ) do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ function TOOL:DrawHUD()
local Leye = ( attachment.Pos + attachment.Ang:Right() * 1.5 ):ToScreen()
local Reye = ( attachment.Pos - attachment.Ang:Right() * 1.5 ):ToScreen()

-- Todo, make the line look less like ass
-- TODO: make the line look less like ass
local scrhit = trace.HitPos:ToScreen()
local x = scrhit.x
local y = scrhit.y
Expand Down Expand Up @@ -295,7 +295,7 @@ end

function TOOL.BuildCPanel( CPanel, hasEntity )

CPanel:AddControl( "Header", { Description = "#tool.eyeposer.desc" } )
CPanel:Help( "#tool.eyeposer.desc" )

if ( hasEntity ) then

Expand Down Expand Up @@ -325,10 +325,11 @@ function TOOL.BuildCPanel( CPanel, hasEntity )
surface.DrawRect( w / 2 - 2, h / 2 - 2, 5, 5 )
end

CPanel:AddControl( "Slider", { Label = "#tool.eyeposer.strabismus", Command = "eyeposer_strabismus", Type = "Float", Min = -1, Max = 1, Default = 0 } )
CPanel:NumSlider( "#tool.eyeposer.strabismus", "eyeposer_strabismus", -1, 1, 2 )

end

CPanel:AddControl( "Slider", { Label = "#tool.eyeposer.size_eyes", Command = "r_eyesize", Type = "Float", Min = -0.5, Max = 2, Help = true, Default = 0 } )
CPanel:NumSlider( "#tool.eyeposer.size_eyes", "r_eyesize", -0.5, 2, 2 )
CPanel:ControlHelp( "#tool.eyeposer.size_eyes.help" )

end
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,11 @@ local ConVarsDefault = TOOL:BuildConVarList()

function TOOL.BuildCPanel( CPanel, faceEntity )

CPanel:AddControl( "Header", { Description = "#tool.faceposer.desc" } )
CPanel:Help( "#tool.faceposer.desc" )

if ( !IsValid( faceEntity ) || faceEntity:GetFlexNum() == 0 ) then return end

CPanel:AddControl( "ComboBox", { MenuButton = 1, Folder = "face", Options = { [ "#preset.default" ] = ConVarsDefault }, CVars = table.GetKeys( ConVarsDefault ) } )
CPanel:ToolPresets( "face", ConVarsDefault )

local QuickFace = vgui.Create( "MatSelect", CPanel )
QuickFace:SetItemWidth( 64 )
Expand Down Expand Up @@ -335,10 +335,12 @@ function TOOL.BuildCPanel( CPanel, faceEntity )

CPanel:AddItem( QuickFace )

CPanel:AddControl( "Slider", { Label = "#tool.faceposer.scale", Command = "faceposer_scale", Type = "Float", Min = -5, Max = 5, Help = true, Default = 1 } ):SetHeight( 16 )
CPanel:AddControl( "Button", { Text = "#tool.faceposer.randomize", Command = "faceposer_randomize" } )
CPanel:NumSlider( "#tool.faceposer.scale", "faceposer_scale", -5, 5, 2 ):SetHeight( 16 )
CPanel:ControlHelp( "#tool.faceposer.scale.help" )

local filter = CPanel:AddControl( "TextBox", { Label = "#spawnmenu.quick_filter_tool" } )
CPanel:Button( "#tool.faceposer.randomize", "faceposer_randomize" )

local filter = CPanel:TextEntry( "#spawnmenu.quick_filter_tool" )
filter:SetUpdateOnType( true )

-- Group flex controllers by their type..
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -571,11 +571,11 @@ local ConVarsDefault = TOOL:BuildConVarList()

function TOOL.BuildCPanel( CPanel, ent, hand )

CPanel:AddControl( "Header", { Description = "#tool.finger.desc" } )
CPanel:Help( "#tool.finger.desc" )

if ( !IsValid( ent ) ) then return end

CPanel:AddControl( "ComboBox", { MenuButton = 1, Folder = "finger", Options = { [ "#preset.default" ] = ConVarsDefault }, CVars = table.GetKeys( ConVarsDefault ) } )
CPanel:ToolPresets( "finger", ConVarsDefault )

SetupFingers( ent )

Expand All @@ -584,9 +584,11 @@ function TOOL.BuildCPanel( CPanel, ent, hand )
-- Detect mitten hands
local NumVars = table.Count( ent.FingerIndex )

CPanel:AddControl( "fingerposer", { hand = hand, numvars = NumVars } )
local fingerPoser = vgui.Create( "fingerposer", CPanel )
fingerPoser:ControlValues( { hand = hand, numvars = NumVars } )
CPanel:AddPanel( fingerPoser )

CPanel:AddControl( "Checkbox", { Label = "#tool.finger.restrict_axis", Command = "finger_restrict" } )
CPanel:CheckBox( "#tool.finger.restrict_axis", "finger_restrict" )

end

Expand Down
Loading