Advertisement
Guest User

Untitled

a guest
Jun 20th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 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( TOP )
  12. self.Navigation:SetHeight( 40 )
  13. self.Navigation:DockMargin( 10, 10, 10, 10 )
  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:SetWidth( 100 )
  44. Sheet.Button.Paint = function(self, w, h)
  45. surface.SetDrawColor(F4Config.ButtonColor)
  46. surface.DrawRect( 0, 0, w, h )
  47. surface.SetDrawColor(F4Config.OutlineButtonColor)
  48. surface.DrawOutlinedRect( 0, 0, w, h )
  49.  
  50. end
  51.  
  52. Sheet.Button.DoClick = function()
  53. self:SetActiveButton( Sheet.Button )
  54. end
  55.  
  56. Sheet.Panel = panel
  57. Sheet.Panel:SetParent( self.Content )
  58. Sheet.Panel:SetVisible( false )
  59.  
  60. if ( self.ButtonOnly ) then
  61. Sheet.Button:SizeToContents()
  62. --Sheet.Button:SetColor( Color( 150, 150, 150, 100 ) )
  63. end
  64.  
  65. table.insert( self.Items, Sheet )
  66.  
  67. if ( !IsValid( self.ActiveButton ) ) then
  68. self:SetActiveButton( Sheet.Button )
  69. end
  70.  
  71. end
  72.  
  73. function PANEL:SetActiveButton( active )
  74.  
  75. if ( self.ActiveButton == active ) then return end
  76.  
  77. if ( self.ActiveButton && self.ActiveButton.Target ) then
  78. self.ActiveButton.Target:SetVisible( false )
  79. self.ActiveButton:SetSelected( false )
  80. self.ActiveButton:SetToggle( false )
  81. end
  82.  
  83. self.ActiveButton = active
  84. active.Target:SetVisible( true )
  85. active:SetSelected( true )
  86. active:SetToggle( true )
  87.  
  88. self.Content:InvalidateLayout()
  89.  
  90. end
  91.  
  92. derma.DefineControl( "CSDColSheet", "", PANEL, "Panel" )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement