summaryrefslogtreecommitdiff
path: root/gamemode/cl_hud/vgui/mbmodel.lua
blob: 373c98a5c572429cd97a7e70a27a615f6bae047b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
local PANEL = {}
local Zero  = Vector(0,0,0)
local One   = Vector(1,1,1)

function PANEL:Init()
	self.bgcol		= MAIN_COLOR2
	
	self.Model = vgui.Create( "DModelPanel" , self )
	self.Model:SetCamPos( Vector( 30, 30, 30 ) )
	self.Model:SetLookAt( Zero )
	self.Model:SetSize( self:GetWide() , self:GetTall() )
	self.Model:SetPos( 0 , 0 )
	
	self.Model.DoRightClick 	= function(s) self:DoRightClick() end
	self.Model.DoClick 			= function(s) self:DoLeftClick() end
end

function PANEL:DoRightClick()
end

function PANEL:DoLeftClick()
end

function PANEL:SetModel( name , Texture )
	self.Model:SetModel( name )
		
	local MSize,SSize = self.Model.Entity:GetRenderBounds()
	SSize = SSize:Length()
		
	self.Model:SetCamPos( One * SSize )
	self.Model:SetLookAt( Zero )
	
	if (Texture) then self.Model.Entity:SetMaterial(Texture) end
end

function PANEL:GetModel()
	return self.Model.Entity:GetModel()
end

function PANEL:SetBGColor( col )
	self.bgcol = col
end

function PANEL:Paint(w,h)
	DrawRect( 0 , 0 , w , h , self.bgcol )
end
	
function PANEL:PerformLayout()
	self.Model:SetSize( self:GetWide() , self:GetTall() )
	self.Model:SetPos( 0 , 0 )
end
 
vgui.Register( "MBModel", PANEL , "Panel" )