Skip to content

Commit

Permalink
Clean up the rest of the tools
Browse files Browse the repository at this point in the history
* Almost full consistency between tools
* Removed all semicolons, trailing whitespace, unnecessary whitespace,
unnecessary code
* Tweaked default values for some of the tools, tweaked limits in
context panels for some of the tools
* Added right click option for lamp tool to copy settings of another
lamp
* Deprecated settings/controls/* stuff, noone uses it, serves no
benefit.
  • Loading branch information
robotboy655 committed May 29, 2014
1 parent 2f1fd73 commit 05d0429
Show file tree
Hide file tree
Showing 41 changed files with 1,317 additions and 1,936 deletions.
@@ -1,6 +1,6 @@

TOOL.Category = "Constraints"
TOOL.Name = "#tool.axis.name"
TOOL.Category = "Constraints"
TOOL.Name = "#tool.axis.name"

TOOL.ClientConVar[ "forcelimit" ] = 0
TOOL.ClientConVar[ "torquelimit" ] = 0
Expand Down Expand Up @@ -43,15 +43,15 @@ function TOOL:LeftClick( trace )
end

-- Get client's CVars
local nocollide = self:GetClientNumber( "nocollide", 0 )
local forcelimit = self:GetClientNumber( "forcelimit", 0 )
local torquelimit = self:GetClientNumber( "torquelimit", 0 )
local friction = self:GetClientNumber( "hingefriction", 0 )

local Ent1, Ent2 = self:GetEnt( 1 ), self:GetEnt( 2 )
local Bone1, Bone2 = self:GetBone( 1 ), self:GetBone( 2 )
local Norm1, Norm2 = self:GetNormal( 1 ), self:GetNormal( 2 )
local LPos1, LPos2 = self:GetLocalPos( 1 ), self:GetLocalPos( 2 )
local nocollide = self:GetClientNumber( "nocollide", 0 )
local forcelimit = self:GetClientNumber( "forcelimit", 0 )
local torquelimit = self:GetClientNumber( "torquelimit", 0 )
local friction = self:GetClientNumber( "hingefriction", 0 )

local Ent1, Ent2 = self:GetEnt( 1 ), self:GetEnt( 2 )
local Bone1, Bone2 = self:GetBone( 1 ), self:GetBone( 2 )
local Norm1, Norm2 = self:GetNormal( 1 ), self:GetNormal( 2 )
local LPos1, LPos2 = self:GetLocalPos( 1 ), self:GetLocalPos( 2 )
local Phys1 = self:GetPhys( 1 )
local WPos2 = self:GetPos( 2 )

Expand All @@ -77,8 +77,8 @@ function TOOL:LeftClick( trace )
local constraint = constraint.Axis( Ent1, Ent2, Bone1, Bone2, LPos1, LPos2, forcelimit, torquelimit, friction, nocollide )

undo.Create( "Axis" )
undo.AddEntity( constraint )
undo.SetPlayer( self:GetOwner() )
undo.AddEntity( constraint )
undo.SetPlayer( self:GetOwner() )
undo.Finish()

self:GetOwner():AddCleanup( "constraints", constraint )
Expand Down Expand Up @@ -125,15 +125,15 @@ function TOOL:RightClick( trace )
end

-- Get client's CVars
local nocollide = self:GetClientNumber( "nocollide", 0 )
local forcelimit = self:GetClientNumber( "forcelimit", 0 )
local torquelimit = self:GetClientNumber( "torquelimit", 0 )
local friction = self:GetClientNumber( "hingefriction", 0 )

local Ent1, Ent2 = self:GetEnt( 1 ), self:GetEnt( 2 )
local Bone1, Bone2 = self:GetBone( 1 ), self:GetBone( 2 )
local Norm1, Norm2 = self:GetNormal( 1 ), self:GetNormal( 2 )
local LPos1, LPos2 = self:GetLocalPos( 1 ), self:GetLocalPos( 2 )
local nocollide = self:GetClientNumber( "nocollide", 0 )
local forcelimit = self:GetClientNumber( "forcelimit", 0 )
local torquelimit = self:GetClientNumber( "torquelimit", 0 )
local friction = self:GetClientNumber( "hingefriction", 0 )

local Ent1, Ent2 = self:GetEnt( 1 ), self:GetEnt( 2 )
local Bone1, Bone2 = self:GetBone( 1 ), self:GetBone( 2 )
local Norm1, Norm2 = self:GetNormal( 1 ), self:GetNormal( 2 )
local LPos1, LPos2 = self:GetLocalPos( 1 ), self:GetLocalPos( 2 )
local Phys1 = self:GetPhys( 1 )
local WPos2 = self:GetPos( 2 )

Expand All @@ -153,8 +153,8 @@ function TOOL:RightClick( trace )
local constraint = constraint.Axis( Ent1, Ent2, Bone1, Bone2, LPos1, LPos2, forcelimit, torquelimit, friction, nocollide )

undo.Create( "Axis" )
undo.AddEntity( constraint )
undo.SetPlayer( self:GetOwner() )
undo.AddEntity( constraint )
undo.SetPlayer( self:GetOwner() )
undo.Finish()

self:GetOwner():AddCleanup( "constraints", constraint )
Expand Down Expand Up @@ -204,9 +204,9 @@ function TOOL.BuildCPanel( CPanel )

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

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( "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" } )

end
@@ -1,13 +1,13 @@

TOOL.Category = "Construction"
TOOL.Name = "#tool.balloon.name"
TOOL.Category = "Construction"
TOOL.Name = "#tool.balloon.name"

TOOL.ClientConVar[ "ropelength" ] = "64"
TOOL.ClientConVar[ "force" ] = "500"
TOOL.ClientConVar[ "r" ] = "255"
TOOL.ClientConVar[ "g" ] = "255"
TOOL.ClientConVar[ "b" ] = "0"
TOOL.ClientConVar[ "model" ] = "models/MaxOfS2D/balloon_classic.mdl"
TOOL.ClientConVar[ "ropelength" ] = "64"
TOOL.ClientConVar[ "force" ] = "500"
TOOL.ClientConVar[ "r" ] = "255"
TOOL.ClientConVar[ "g" ] = "255"
TOOL.ClientConVar[ "b" ] = "0"
TOOL.ClientConVar[ "model" ] = "models/maxofs2d/balloon_classic.mdl"

cleanup.Register( "balloons" )

Expand All @@ -19,25 +19,25 @@ function TOOL:LeftClick( trace, attach )
--
-- Right click calls this with attach = false
--
if ( attach == nil ) then
attach = true
if ( attach == nil ) then
attach = true
end

-- If there's no physics object then we can't constraint it!
if ( SERVER && attach && !util.IsValidPhysicsObject( trace.Entity, trace.PhysicsBone ) ) then
return false
if ( SERVER && attach && !util.IsValidPhysicsObject( trace.Entity, trace.PhysicsBone ) ) then
return false
end

local ply = self:GetOwner()
local length = self:GetClientNumber( "ropelength", 64 )
local material = "cable/rope"
local force = self:GetClientNumber( "force", 500 )
local r = self:GetClientNumber( "r", 255 )
local g = self:GetClientNumber( "g", 0 )
local b = self:GetClientNumber( "b", 0 )
local model = self:GetClientInfo( "model" )
local ply = self:GetOwner()
local material = "cable/rope"
local r = self:GetClientNumber( "r", 255 )
local g = self:GetClientNumber( "g", 0 )
local b = self:GetClientNumber( "b", 0 )
local model = self:GetClientInfo( "model" )
local force = self:GetClientNumber( "force", 500 )
local length = self:GetClientNumber( "ropelength", 64 )

local modeltable = list.Get( "BalloonModels" )[ model ]
local modeltable = list.Get( "BalloonModels" )[ model ]

--
-- Model is a table index on BalloonModels
Expand Down Expand Up @@ -84,7 +84,7 @@ function TOOL:LeftClick( trace, attach )
balloon:SetPos( Pos )

undo.Create( "Balloon" )
undo.AddEntity( balloon )
undo.AddEntity( balloon )

if ( attach ) then

Expand All @@ -110,7 +110,7 @@ function TOOL:LeftClick( trace, attach )

end

undo.SetPlayer( ply )
undo.SetPlayer( ply )
undo.Finish()

ply:AddCleanup( "balloons", balloon )
Expand All @@ -133,7 +133,7 @@ if ( SERVER ) then

local balloon = ents.Create( "gmod_balloon" )

if ( !balloon:IsValid() ) then return end
if ( !IsValid( balloon ) ) then return end

duplicator.DoGeneric( balloon, Data )

Expand Down Expand Up @@ -170,7 +170,7 @@ function TOOL:UpdateGhostBalloon( ent, ply )

if ( !IsValid( ent ) ) then return end

local tr = util.GetPlayerTrace( ply )
local tr = util.GetPlayerTrace( ply )
local trace = util.TraceLine( tr )
if ( !trace.Hit ) then return end

Expand Down Expand Up @@ -212,64 +212,30 @@ function TOOL:Think()

end

local ConVarsDefault = TOOL:BuildConVarList()

function TOOL.BuildCPanel( CPanel )

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

CPanel:AddControl( "ComboBox", { Label = "#tool.presets",
MenuButton = 1,
Folder = "balloon",
CVars = { "balloon_ropelength", "balloon_force", "balloon_r", "balloon_g", "balloon_b", "balloon_skin" } } )

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", ShowAlpha = "0", ShowHSV = "1", ShowRGB = "1" } )

CPanel:AddControl( "PropSelect", { Label = "#tool.balloon.model",
ConVar = "balloon_model",
Height = 4,
ModelsTable = list.Get( "BalloonModels" ) } )

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

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:AddControl( "PropSelect", { Label = "#tool.balloon.model", ConVar = "balloon_model", Height = 4, ModelsTable = list.Get( "BalloonModels" ) } )

end

list.Set( "BalloonModels", "normal", {
model = "models/MaxOfS2D/balloon_classic.mdl",
skin = 0,
})

list.Set( "BalloonModels", "normal_skin1", {
model = "models/MaxOfS2D/balloon_classic.mdl",
skin = 1,
})

list.Set( "BalloonModels", "normal_skin2", {
model = "models/MaxOfS2D/balloon_classic.mdl",
skin = 2,
})

list.Set( "BalloonModels", "normal_skin3", {
model = "models/MaxOfS2D/balloon_classic.mdl",
skin = 3,
})

list.Set( "BalloonModels", "gman", {
model = "models/MaxOfS2D/balloon_gman.mdl",
nocolor = true,
})

list.Set( "BalloonModels", "mossman", {
model = "models/MaxOfS2D/balloon_mossman.mdl",
nocolor = true,
})

list.Set( "BalloonModels", "dog", {
model = "models/balloons/balloon_dog.mdl"
})

list.Set( "BalloonModels", "heart", {
model = "models/balloons/balloon_classicheart.mdl"
})

list.Set( "BalloonModels", "star", {
model = "models/balloons/balloon_star.mdl"
})
list.Set( "BalloonModels", "normal", { model = "models/maxofs2d/balloon_classic.mdl", skin = 0 } )
list.Set( "BalloonModels", "normal_skin1", { model = "models/maxofs2d/balloon_classic.mdl", skin = 1 } )
list.Set( "BalloonModels", "normal_skin2", { model = "models/maxofs2d/balloon_classic.mdl", skin = 2 } )
list.Set( "BalloonModels", "normal_skin3", { model = "models/maxofs2d/balloon_classic.mdl", skin = 3 } )

list.Set( "BalloonModels", "gman", { model = "models/maxofs2d/balloon_gman.mdl", nocolor = true } )
list.Set( "BalloonModels", "mossman", { model = "models/maxofs2d/balloon_mossman.mdl", nocolor = true } )

list.Set( "BalloonModels", "dog", { model = "models/balloons/balloon_dog.mdl" } )
list.Set( "BalloonModels", "heart", { model = "models/balloons/balloon_classicheart.mdl" } )
list.Set( "BalloonModels", "star", { model = "models/balloons/balloon_star.mdl" } )
@@ -1,6 +1,6 @@

TOOL.Category = "Constraints"
TOOL.Name = "#tool.ballsocket.name"
TOOL.Category = "Constraints"
TOOL.Name = "#tool.ballsocket.name"

TOOL.ClientConVar[ "forcelimit" ] = "0"
TOOL.ClientConVar[ "torquelimit" ] = "0"
Expand All @@ -27,9 +27,9 @@ function TOOL:LeftClick( trace )
end

-- Get client's CVars
local nocollide = self:GetClientNumber( "nocollide", 0 )
local forcelimit = self:GetClientNumber( "forcelimit", 0 )
local torquelimit = self:GetClientNumber( "torquelimit", 0 )
local nocollide = self:GetClientNumber( "nocollide", 0 )
local forcelimit = self:GetClientNumber( "forcelimit", 0 )
local torquelimit = self:GetClientNumber( "torquelimit", 0 )

-- Get information we're about to use
local Ent1, Ent2 = self:GetEnt( 1 ), self:GetEnt( 2 )
Expand All @@ -39,8 +39,8 @@ function TOOL:LeftClick( trace )
local constraint = constraint.Ballsocket( Ent1, Ent2, Bone1, Bone2, LPos, forcelimit, torquelimit, nocollide )

undo.Create( "BallSocket" )
undo.AddEntity( constraint )
undo.SetPlayer( self:GetOwner() )
undo.AddEntity( constraint )
undo.SetPlayer( self:GetOwner() )
undo.Finish()

self:GetOwner():AddCleanup( "constraints", constraint )
Expand Down Expand Up @@ -81,8 +81,8 @@ function TOOL.BuildCPanel( CPanel )

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

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( "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 } )

end

0 comments on commit 05d0429

Please sign in to comment.