diff options
| author | Apickx <Apickx@cogarr.org> | 2015-12-28 19:18:30 -0500 |
|---|---|---|
| committer | Apickx <Apickx@cogarr.org> | 2015-12-28 19:18:30 -0500 |
| commit | 868e729d68b5913716bfe5ddb512f4099851e9a2 (patch) | |
| tree | 6441108754145dfd68a6e23bea382b5cb1ab63d5 /gamemode/cl_hud/vgui/mbtree.lua | |
| download | gearfox-master.tar.gz gearfox-master.tar.bz2 gearfox-master.zip | |
Diffstat (limited to 'gamemode/cl_hud/vgui/mbtree.lua')
| -rw-r--r-- | gamemode/cl_hud/vgui/mbtree.lua | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/gamemode/cl_hud/vgui/mbtree.lua b/gamemode/cl_hud/vgui/mbtree.lua new file mode 100644 index 0000000..e2be877 --- /dev/null +++ b/gamemode/cl_hud/vgui/mbtree.lua @@ -0,0 +1,92 @@ +local PANEL = {} + +function PANEL:Init() + self.bgcol = MAIN_COLOR2 + self.hovercol = MAIN_COLORD + self.foldecol = MAIN_COLORD2 + self.selecCol = MAIN_GREENCOLOR + + self.VBar.Paint = function(s) end + self.VBar.btnGrip.Paint = function(s) DrawRect( 2 , 0 , s:GetWide()-4 , s:GetTall() , self.bgcol ) end + self.VBar.btnDown.Paint = function(s) DrawRect( 2 , 2 , s:GetWide()-4 , s:GetTall()-4 , self.bgcol ) end + self.VBar.btnUp.Paint = function(s) DrawRect( 2 , 2 , s:GetWide()-4 , s:GetTall()-4 , self.bgcol ) end + + self.Delta = 0 + self.Smooth = 0 + self.BGEnabled = true +end + +function PANEL:OnMouseWheeled(Delta) + self.Delta = self.Delta+Delta +end + +function PANEL:SetVScroll(num) + self.VBar:SetScroll(num) +end + +function PANEL:AddVScroll(num) + self.VBar:AddScroll(num) +end + +function PANEL:SetBGColor( col ) + self.bgcol = col +end + +function PANEL:EnableNodeBG( bool ) + self.BGEnabled = bool +end + +function PANEL:AddNode( text ) + local V = self.BaseClass.AddNode( self, text ) + + V.BGEnabled = self.BGEnabled + + V.FolCol = self.foldecol + V.HovCol = self.hovercol + V.SelCol = self.selecCol + V.OAddNode = V.AddNode + + V.Label:SetFont("Trebuchet18") + V.Label.Paint = function(s,w,h) + if (V:HasChildren() and V.BGEnabled) then DrawRect( 0 , 1 , w , h-2 , V.FolCol ) + elseif (!V:HasChildren() and self:GetSelectedItem()==V) then DrawRect( 0 , 1 , w , h-2 , V.SelCol ) + elseif (V.Hovered) then DrawRect( 0 , 1 , w , h-2 , V.HovCol ) end + end + + V.AddNode = function(s,txt) + local D = s.OAddNode(s,txt) + + D.FolCol = s.FolCol + D.HovCol = s.HovCol + D.SelCol = s.SelCol + D.BGEnabled = s.BGEnabled + + D.Label:SetFont("Trebuchet18") + + D.Label.Paint = function(p,w,h) + if (D:HasChildren() and D.BGEnabled) then DrawRect( 0 , 1 , w , h-2 , D.FolCol ) + elseif (!D:HasChildren() and self:GetSelectedItem()==D) then DrawRect( 0 , 1 , w , h-2 , D.SelCol ) + elseif (D.Hovered) then DrawRect( 0 , 1 , w , h-2 , D.HovCol ) end + end + + D.OAddNode = D.AddNode + D.AddNode = s.AddNode + + return D + end + + return V +end + +function PANEL:Think() + if (self.Delta > 0.01 or self.Delta < -0.01 or self.Smooth > 0.01 or self.Smooth < -0.01) then + self.Delta = self.Delta - self.Delta/8 + self.Smooth = self.Smooth + (self.Delta-self.Smooth)/32 + self:AddVScroll(-self.Smooth/2) + end +end + +function PANEL:Paint() +end + +vgui.Register( "MBTree", PANEL , "DTree" )
\ No newline at end of file |
