Advertisement
trickstarog

Untitled

Jun 20th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. include("config.lua")
  2. AddCSLuaFile("config.lua")
  3.  
  4. local PANEL = {}
  5.  
  6. AccessorFunc( PANEL, "ActiveButton", "ActiveButton" )
  7.  
  8. function PANEL:Init()
  9.  
  10. self.Navigation = vgui.Create( "DScrollPanel", self )
  11. self.Navigation:Dock( LEFT )
  12. self.Navigation:SetWidth( 100 )
  13. self.Navigation:DockMargin( 10, 10, 10, 0 )
  14.  
  15. self.Content = vgui.Create( "Panel", self )
  16. self.Content:Dock( FILL )
  17.  
  18. self.Items = {}
  19.  
  20. end
  21.  
  22. function PANEL:UseButtonOnlyStyle()
  23. self.ButtonOnly = true
  24. end
  25.  
  26. function PANEL:AddSheet( label, panel, material )
  27.  
  28. if ( !IsValid( panel ) ) then return end
  29.  
  30. local Sheet = {}
  31.  
  32. if ( self.ButtonOnly ) then
  33. Sheet.Button = vgui.Create( "DImageButton", self.Navigation )
  34. else
  35. Sheet.Button = vgui.Create( "DButton", self.Navigation )
  36. end
  37.  
  38. Sheet.Button:SetImage( material )
  39. Sheet.Button.Target = panel
  40. Sheet.Button:Dock( TOP )
  41. Sheet.Button:SetText( label )
  42. Sheet.Button:DockMargin( 4, 1, 0, 4 )
  43. Sheet.Button.Paint = function(self, w, h)
  44. surface.SetDrawColor(F4Config.ButtonColor)
  45. surface.DrawRect( 0, 0, w, h )
  46. surface.SetDrawColor(F4Config.OutlineButtonColor)
  47. surface.DrawOutlinedRect( 0, 0, w, h )
  48.  
  49. end
  50.  
  51. Sheet.Button.DoClick = function()
  52. self:SetActiveButton( Sheet.Button )
  53. end
  54.  
  55. Sheet.Panel = panel
  56. Sheet.Panel:SetParent( self.Content )
  57. Sheet.Panel:SetVisible( false )
  58.  
  59. if ( self.ButtonOnly ) then
  60. Sheet.Button:SizeToContents()
  61. --Sheet.Button:SetColor( Color( 150, 150, 150, 100 ) )
  62. end
  63.  
  64. table.insert( self.Items, Sheet )
  65.  
  66. if ( !IsValid( self.ActiveButton ) ) then
  67. self:SetActiveButton( Sheet.Button )
  68. end
  69.  
  70. end
  71.  
  72. function PANEL:SetActiveButton( active )
  73.  
  74. if ( self.ActiveButton == active ) then return end
  75.  
  76. if ( self.ActiveButton && self.ActiveButton.Target ) then
  77. self.ActiveButton.Target:SetVisible( false )
  78. self.ActiveButton:SetSelected( false )
  79. self.ActiveButton:SetToggle( false )
  80. end
  81.  
  82. self.ActiveButton = active
  83. active.Target:SetVisible( true )
  84. active:SetSelected( true )
  85. active:SetToggle( true )
  86.  
  87. self.Content:InvalidateLayout()
  88.  
  89. end
  90.  
  91. derma.DefineControl( "CSDColSheet", "", PANEL, "Panel" )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement