Permalink
Browse files

Given DAdjustableModelPanel an example

It had one inherited from DModelPanel, and it was wrong displaying just
nothing initially.

Also improved the example for DModelPanel to not show an error, and gave
the model a skin as an example.
  • Loading branch information...
1 parent 893d84e commit 4cd4f3b5ca300b8a1290fc871ef5e7a0b382fc20 @robotboy655 robotboy655 committed May 13, 2016
Showing with 27 additions and 13 deletions.
  1. +17 −4 garrysmod/lua/vgui/dadjustablemodelpanel.lua
  2. +10 −9 garrysmod/lua/vgui/dmodelpanel.lua
@@ -58,13 +58,13 @@ function PANEL:FirstPersonControls()
y = y * 0.5 * scale
if ( self.MouseKey == MOUSE_LEFT ) then
-
+
if ( input.IsShiftDown() ) then y = 0 end
-
+
self.aLookAngle = self.aLookAngle + Angle( y * 4, x * 4, 0 )
-
+
self.vCamPos = self.Entity:OBBCenter() - self.aLookAngle:Forward() * self.vCamPos:Length()
-
+
return
end
@@ -102,4 +102,17 @@ function PANEL:OnMouseReleased( mousecode )
end
+function PANEL:GenerateExample( ClassName, PropertySheet, Width, Height )
+
+ local ctrl = vgui.Create( ClassName )
+ ctrl:SetSize( 300, 300 )
+ ctrl:SetModel( "models/props_junk/PlasticCrate01a.mdl" )
+ ctrl:GetEntity():SetSkin( 2 )
+ ctrl:SetLookAng( Angle( 45, 0, 0 ) )
+ ctrl:SetCamPos( Vector( -20, 0, 20 ) )
+
+ PropertySheet:AddSheet( ClassName, ctrl, nil, true, true )
+
+end
+
derma.DefineControl( "DAdjustableModelPanel", "A panel containing a model", PANEL, "DModelPanel" )
@@ -50,7 +50,7 @@ end
-----------------------------------------------------------]]
function PANEL:SetModel( strModelName )
- -- Note - there's no real need to delete the old
+ -- Note - there's no real need to delete the old
-- entity, it will get garbage collected, but this is nicer.
if ( IsValid( self.Entity ) ) then
self.Entity:Remove()
@@ -90,7 +90,7 @@ end
Name: DrawModel
-----------------------------------------------------------]]
function PANEL:DrawModel()
-
+
local curparent = self
local rightx = self:GetWide()
local leftx = 0
@@ -109,7 +109,7 @@ function PANEL:DrawModel()
render.SetScissorRect( leftx, topy, rightx, bottomy, true )
local ret = self:PreDrawModel( self.Entity )
- if ( ret != false ) then
+ if ( ret != false ) then
self.Entity:DrawModel()
self:PostDrawModel( self.Entity )
end
@@ -129,7 +129,7 @@ end
Name: PostDrawModel
-----------------------------------------------------------]]
function PANEL:PostDrawModel( ent )
-
+
end
--[[---------------------------------------------------------
@@ -145,16 +145,16 @@ function PANEL:Paint( w, h )
local ang = self.aLookAngle
if ( !ang ) then
- ang = (self.vLookatPos-self.vCamPos):Angle()
+ ang = ( self.vLookatPos - self.vCamPos ):Angle()
end
cam.Start3D( self.vCamPos, ang, self.fFOV, x, y, w, h, 5, self.FarZ )
render.SuppressEngineLighting( true )
render.SetLightingOrigin( self.Entity:GetPos() )
- render.ResetModelLighting( self.colAmbientLight.r/255, self.colAmbientLight.g/255, self.colAmbientLight.b/255 )
- render.SetColorModulation( self.colColor.r/255, self.colColor.g/255, self.colColor.b/255 )
- render.SetBlend( (self:GetAlpha()/255) * (self.colColor.a/255) )
+ render.ResetModelLighting( self.colAmbientLight.r / 255, self.colAmbientLight.g / 255, self.colAmbientLight.b / 255 )
+ render.SetColorModulation( self.colColor.r / 255, self.colColor.g / 255, self.colColor.b / 255 )
+ render.SetBlend( ( self:GetAlpha() / 255 ) * ( self.colColor.a / 255 ) )
for i=0, 6 do
local col = self.DirectionalLight[ i ]
@@ -222,7 +222,8 @@ function PANEL:GenerateExample( ClassName, PropertySheet, Width, Height )
local ctrl = vgui.Create( ClassName )
ctrl:SetSize( 300, 300 )
- ctrl:SetModel( "models/error.mdl" )
+ ctrl:SetModel( "models/props_junk/PlasticCrate01a.mdl" )
+ ctrl:GetEntity():SetSkin( 2 )
PropertySheet:AddSheet( ClassName, ctrl, nil, true, true )

0 comments on commit 4cd4f3b

Please sign in to comment.