Advertisement
Guest User

Untitled

a guest
Jun 18th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.94 KB | None | 0 0
  1. if not Delicate_UI.Scoreboard.Enabled or not CLIENT then return end
  2.  
  3. include( 'delicate_ui/delicate_core/delicate_ui_themes.lua' )
  4.  
  5. local delicate_base = nil
  6. local _s, theme, base_screen_w = 'Disconnected', Delicate_UI.Scoreboard.Themes[ Delicate_UI.Scoreboard.Theme ], 1366
  7.  
  8. function Delicate_UI.CreateIconHeader( str, font, x, y, icon, align )
  9. Delicate_UI.DrawText( str, font, x, y, Color( 255, 255, 255 ), align and align or TEXT_ALIGN_CENTER )
  10. if icon then Delicate_UI.DrawIcon( icon, x - 27, y - 3 ) end
  11. end
  12.  
  13. function Delicate_UI.GetPlayerSize()
  14. if not Delicate_UI.Scoreboard.Enable_Spy_Mode then return #player.GetAll() end
  15. local counter = 0
  16. for k, v in pairs( player.GetAll() ) do
  17. if Delicate_UI.Scoreboard.Spy_Mode_Groups[ v:GetUserGroup() ] then continue end
  18. counter = counter + 1
  19. end
  20. return counter
  21. end
  22.  
  23. function Delicate_UI.CreateDiagBox( self, title, reason, time, args )
  24. local base = vgui.Create( 'DFrame' )
  25. base:SetSize( 325, time and reason and 165 or 114 )
  26. base:SetTitle( '' )
  27. base:ShowCloseButton( false )
  28. base:SetDraggable( false )
  29. base:Center()
  30. base:MakePopup()
  31.  
  32. local newTitle = string.gsub( title, '#name', self:Nick() )
  33.  
  34. base.Paint = function( me, w, h )
  35. if Delicate_UI.Scoreboard.Enable_Blur then Delicate_UI.BlurMenu( me, 16, 16, 255 ) end
  36. Delicate_UI.DrawRect( 0, 0, w, h, theme.background )
  37. Delicate_UI.DrawRect( 0, 0, w, 25, theme.interface_seperator )
  38. Delicate_UI.DrawRect( 0, 26, w, 2, theme.line_seperator )
  39. Delicate_UI.DrawIcon( Delicate_UI.Materials[ 'punish_tag' ], -3, -3 )
  40. Delicate_UI.DrawText( newTitle, 'Delicate.Font.21', 27, 3, theme.title_color, TEXT_ALIGN_LEFT )
  41. if reason then Delicate_UI.DrawText( Delicate_UI.Language.SCOREBOARD_INPUT_DISPLAY, 'Delicate.Font.19', 10, 30, theme.interface_headers, TEXT_ALIGN_LEFT ) end
  42. if time then Delicate_UI.DrawText( Delicate_UI.Language.SCOREBOARD_TIME_DISPLAY, 'Delicate.Font.19', 10, reason and 80 or 35, theme.interface_headers, TEXT_ALIGN_LEFT ) end
  43. end
  44.  
  45. local close_bounds = vgui.Create( 'DLabel', base )
  46. close_bounds:SetSize( 21, 19 )
  47. close_bounds:SetPos( base:GetWide() - 24, 2 )
  48. close_bounds:SetText( ' x' )
  49. close_bounds:SetFont( 'Delicate.Font.24' )
  50. close_bounds:SetTextColor( Color( 224, 118, 118, 120 ) )
  51. close_bounds:SetMouseInputEnabled( true )
  52. close_bounds:SetCursor( 'hand' )
  53. close_bounds.DoClick = function() base:Close() end
  54.  
  55. local reason_input, time_input
  56.  
  57. if reason then
  58. reason_input = vgui.Create( 'DTextEntry', base )
  59. reason_input:SetFont( 'Delicate.Font.18' )
  60. reason_input:SetSize( 310, 25 )
  61. reason_input:SetText( '' )
  62. reason_input:SetPos( 10, 52 )
  63. reason_input.Paint = function( me, w, h )
  64. Delicate_UI.DrawRect( 0, 0, w, h, Color( 250, 250, 250, 200 ) )
  65. me:DrawTextEntryText( Color( 40, 40, 40 ), Color( 60, 60, 60 ), Color( 60, 60, 60 ) )
  66. end
  67. end
  68.  
  69. if time then
  70. time_input = vgui.Create( 'DTextEntry', base )
  71. time_input:SetFont( 'Delicate.Font.18' )
  72. time_input:SetSize( 90, 25 )
  73. time_input:SetText( '' )
  74. time_input:SetPos( 10, not reason and 55 or 102 )
  75. time_input:SetNumeric( true )
  76. time_input.Paint = function( me, w, h )
  77. Delicate_UI.DrawRect( 0, 0, w, h, Color( 250, 250, 250, 200 ) )
  78. me:DrawTextEntryText( Color( 40, 40, 40 ), Color( 60, 60, 60 ), Color( 60, 60, 60 ) )
  79. end
  80. end
  81.  
  82. local confirm = Delicate_UI.CreateButton( base, base:GetWide() / 2 - 60, time and reason and base:GetTall() / 2 + 48 or base:GetTall() - 33, 110, 30, 'Delicate.Font.19', Delicate_UI.Language.SCOREBOARD_CONFIRM_BUTTON )
  83. confirm.Paint = function( me, w, h )
  84. Delicate_UI.DrawRect( 0, 0, w, h, theme.confirm_button )
  85. if me:IsHovered() then
  86. local white_flash = 100 + math.abs( math.sin( CurTime() * 2 ) * 255 )
  87. Delicate_UI.DrawOutline( 0, 0, w, h, 2, Color( white_flash, white_flash, white_flash ) )
  88. end
  89. end
  90.  
  91. confirm.DoClick = function()
  92. local _r, _t = reason and reason_input:GetValue(), time and tonumber( time_input:GetValue() )
  93. if not _r then _r = '' end
  94. if time and not _t or time and not _t and not isnumber( _t ) or not IsValid( self ) then LocalPlayer():ChatPrint( Delicate_UI.Language.SCOREBOARD_DATA_ERROR ) return end
  95. self:ConCommand( reason and time and string.format( '%s %s %i %s', args, self:Nick(), _t, _r ) or reason and string.format( '%s %s %s', args, self:Nick(), _r ) or time and string.format( '%s %s %i', args, self:Nick(), _t ) )
  96. base:Close()
  97. end
  98. end
  99.  
  100. function Delicate_UI.CreateHeader( me, w, h, self )
  101. local row_y = 43
  102. Delicate_UI.DrawRect( 5, 40, w - 10, 2, theme.line_seperator )
  103. Delicate_UI.DrawRect( 5, 70, w - 10, 2, theme.line_seperator )
  104.  
  105. Delicate_UI.CreateIconHeader( Delicate_UI.Language.SCOREBOARD_NAME_HEADER, 'Delicate.Font.23', 26, row_y, Delicate_UI.Materials[ 'name_tag' ], TEXT_ALIGN_LEFT )
  106. Delicate_UI.CreateIconHeader( Delicate_UI.Language.SCOREBOARD_JOB_HEADER, 'Delicate.Font.23', ScrW() <= base_screen_w and ScrW() * 0.24 or ScrW() * 0.17, row_y, Delicate_UI.Materials[ 'job_tag' ], TEXT_ALIGN_LEFT )
  107. Delicate_UI.CreateIconHeader( Delicate_UI.Language.SCOREBOARD_RANK_HEADER, 'Delicate.Font.23', ScrW() <= base_screen_w and ScrW() * 0.37 or ScrW() * 0.27, row_y, Delicate_UI.Materials[ 'law_tag' ], TEXT_ALIGN_LEFT )
  108. Delicate_UI.CreateIconHeader( Delicate_UI.Language.SCOREBOARD_KD_HEADER, 'Delicate.Font.23', ScrW() <= base_screen_w and ScrW() * 0.46 or ScrW() * 0.36, row_y, Delicate_UI.Materials[ 'gun_tag' ], TEXT_ALIGN_LEFT )
  109. Delicate_UI.CreateIconHeader( Delicate_UI.Language.SCOREBOARD_PING_HEADER, 'Delicate.Font.23', ScrW() <= base_screen_w and ScrW() * 0.55 or ScrW() * 0.42, row_y, Delicate_UI.Materials[ 'ping_tag' ], TEXT_ALIGN_LEFT )
  110. end
  111.  
  112. function Delicate_UI.CreateScoreboard()
  113. local size_w = ScrW() <= base_screen_w and ScrW() * 0.63 or ScrW() * 0.47
  114. local self = LocalPlayer()
  115. gui.EnableScreenClicker( true )
  116.  
  117. delicate_base = vgui.Create( 'DFrame' )
  118. delicate_base:SetSize( size_w, ScrH() * 0.8 )
  119. delicate_base:SetTitle( '' )
  120. delicate_base:ShowCloseButton( false )
  121. delicate_base:SetDraggable( false )
  122.  
  123. delicate_base:SetPos( ( ScrW() * 0.5 ) - size_w * 0.5, ( ScrH() * 1.5 ) )
  124. delicate_base:MoveTo( ( ScrW() * 0.5 ) - size_w * 0.5, ( ScrH() * 0.5 ) - ScrH() * 0.4, 0.2 )
  125.  
  126. delicate_base.Paint = function( me, w, h )
  127. if Delicate_UI.Scoreboard.Enable_Blur then Delicate_UI.BlurMenu( me, 16, 16, 255 ) end
  128. Delicate_UI.DrawRect( 0, 0, w, h, theme.background )
  129. Delicate_UI.DrawText( Delicate_UI.Server_Name, 'Delicate.Font.40', w / 2 - 20, -2, theme.title_color )
  130. Delicate_UI.CreateHeader( me, w, h, self )
  131. Delicate_UI.DrawText( string.format( 'There is currently %i out of %i %s online.', Delicate_UI.GetPlayerSize(), game.MaxPlayers(), 'players' ), 'Delicate.Font.20', w / 2 - 20, h - 25, theme.title_color )
  132. --Delicate_UI.DrawRect( 5, h - 35, w - 10, 30, theme.player_count_section )
  133. Delicate_UI.DrawRect( 20, h - 30, w - 40, 2, theme.line_seperator )
  134. --Delicate_UI.DrawRect( 0, h - 2, w, 2, theme.line_seperator )
  135. end
  136.  
  137. local delicate_scroll = vgui.Create( 'DScrollPanel', delicate_base )
  138. delicate_scroll:SetPos( 5, 80 )
  139. delicate_scroll:SetSize( delicate_base:GetWide(), delicate_base:GetTall() - 115 )
  140. Delicate_UI.PaintBar( delicate_scroll, nil, nil, Color( 255, 255, 255 ) )
  141.  
  142. local player_list = vgui.Create( 'DListLayout', delicate_scroll )
  143. player_list:SetSize( delicate_scroll:GetWide() - 10, delicate_scroll:GetTall() )
  144. --delicate_scroll.Paint = function( me, w, h ) Delicate_UI.DrawRect( 0, 0, w, h, Color( 200, 0, 0 ) ) end
  145.  
  146.  
  147. local my_table = DarkRP.getCategories()[ 'jobs' ]
  148.  
  149. table.sort( my_table, function( tableA, tableB )
  150. if tableA.sortOrder and tableB.sortOrder then
  151. return tableA.sortOrder < tableB.sortOrder
  152. end
  153. return false
  154. end )
  155. -- This might be overcomplicated, but it works.
  156. for x, o in pairs( my_table ) do
  157. if not o[ 'members' ] then continue end
  158. for i = 1, #o[ 'members' ] do
  159. for j = 1, #player.GetAll() do
  160. local targ = player.GetAll()[ j ]
  161. if Delicate_UI.Scoreboard.Enable_Spy_Mode and Delicate_UI.Scoreboard.Spy_Mode_Groups[ targ:GetUserGroup() ] then continue end
  162. if o[ 'members' ][ i ].name == team.GetName( targ:Team() ) then
  163. local increase, split_value = 1, ( delicate_scroll:GetWide() - 10 ) / 100
  164. local pan = vgui.Create( 'DCollapsibleCategory', player_list )
  165. pan:SetExpanded( 0 )
  166. pan:SetLabel( '' )
  167. pan:SetSize( player_list:GetWide(), 25 )
  168. pan:GetChildren()[1]:SetTall( 25 )
  169. pan.Paint = function( me, w, h )
  170. if not IsValid( targ ) then return end
  171. local clr, y = team.GetColor( targ:Team() ), 2
  172. Delicate_UI.DrawRect( 0, 0, w, h, Color( clr.r, clr.g, clr.b, 50 ) )
  173. Delicate_UI.DrawText( targ:Nick(), 'Delicate.Font.18', 10, y, Delicate_UI.Staff[ targ:GetUserGroup() ] and Delicate_UI.Staff[ targ:GetUserGroup() ].color or theme.player_name, TEXT_ALIGN_LEFT )
  174. Delicate_UI.DrawText( Delicate_UI.Staff[ targ:GetUserGroup() ] and Delicate_UI.Staff[ targ:GetUserGroup() ].name or 'User', 'Delicate.Font.18', ScrW() <= base_screen_w and ScrW() * 0.37 or ScrW() * 0.275, y, Delicate_UI.Staff[ targ:GetUserGroup() ] and Delicate_UI.Staff[ targ:GetUserGroup() ].color or theme.player_name )
  175. Delicate_UI.DrawText( team.GetName( targ:Team() ), 'Delicate.Font.18', ScrW() <= base_screen_w and ScrW() * 0.24 or ScrW() * 0.17, y, theme.player_job )
  176. Delicate_UI.DrawText( string.format( '%i:%i', targ:Frags() < 0 and 0 or targ:Frags(), targ:Deaths() < 0 and 0 or targ:Deaths() ), 'Delicate.Font.18', ScrW() <= base_screen_w and ScrW() * 0.46 or ScrW() * 0.36, y, theme.player_kd )
  177. Delicate_UI.DrawText( targ:Ping() .. ' ms', 'Delicate.Font.18', ScrW() <= base_screen_w and ScrW() * 0.55 or ScrW() * 0.42, y, theme.player_ping )
  178. end
  179.  
  180. local mute = vgui.Create( 'DImageButton', pan )
  181. mute:SetSize( 16, 16 )
  182. mute:SetPos( player_list:GetWide() - 25, 5 )
  183. mute:SetImage( targ:IsMuted() and 'delicate_muted.png' or 'delicate_unmuted.png' )
  184. mute:SetColor( Color( 255, 255, 255 ) )
  185.  
  186. mute.DoClick = function()
  187. if targ:IsMuted() then targ:SetMuted( false ) else targ:SetMuted( true ) end
  188. mute:SetImage( targ:IsMuted() and 'delicate_muted.png' or 'delicate_unmuted.png' )
  189. end
  190.  
  191. local zone = vgui.Create( 'DPanelList' )
  192. zone:SetSize( pan:GetWide(), pan:GetTall() )
  193. zone:SetSpacing( 1 )
  194. pan:SetContents( zone )
  195.  
  196. local pnl = vgui.Create( 'DPanel' )
  197. pnl:SetSize( delicate_scroll:GetWide(), #Delicate_UI.Scoreboard.Buttons < split_value and 37 or 60 )
  198. zone:AddItem( pnl )
  199. pnl.Paint = function( me, w, h ) Delicate_UI.DrawRect( 0, 0, w, h, Color( 70, 70, 70, 100 ) ) end
  200.  
  201. for button_key, button_value in pairs( Delicate_UI.Scoreboard.Buttons ) do
  202. if button_key > split_value then increase = increase + 1 end -- Work around to reset the buttons x position multi
  203. local x_pos, y_pos = button_key < split_value and -100 + ( button_key * 103 ) or -203 + ( increase * 103 ), button_key < split_value and 8 or 34
  204. local btn = Delicate_UI.CreateButton( pnl, x_pos, y_pos, 100, 25, 'Delicate.Font.16', button_value.buttonName )
  205. btn.Paint = function( me, w, h )
  206. Delicate_UI.DrawRect( 0, 0, w, h, Color( 4, 4, 4, 200 ) )
  207. if me:IsHovered() then
  208. local white_flash = 100 + math.abs( math.sin( CurTime() * 2 ) * 255 )
  209. Delicate_UI.DrawOutline( 0, 0, w, h, 2, Color( white_flash, white_flash, white_flash ) )
  210. end
  211. end
  212. btn.DoClick = function()
  213. if not IsValid( targ ) then return end
  214. if button_value.func then button_value.func( targ ) return end -- This is for the copying of Steam IDs.
  215. if button_value.title then -- If no title, then we assume they just want to instantly exec.
  216. Delicate_UI.CreateDiagBox( targ, button_value.title, button_value.reason, button_value.time, button_value.cmd )
  217. else
  218. LocalPlayer():ConCommand( button_value.cmd .. ' ' .. targ:Nick() )
  219. end
  220. end
  221. end
  222.  
  223. player_list:Add( pan )
  224. end
  225. end
  226. end
  227. end
  228. end
  229.  
  230. function Delicate_UI.ShowScoreboard()
  231. if IsValid( delicate_base ) then delicate_base:Close() end
  232. Delicate_UI.CreateScoreboard()
  233. return true
  234. end
  235. hook.Add( 'ScoreboardShow', 'Delicate_UI.Handle.ScoreboardShow', Delicate_UI.ShowScoreboard )
  236.  
  237. function Delicate_UI.HideScoreboard()
  238. if IsValid( delicate_base ) then
  239. local size_w = ScrW() <= base_screen_w and ScrW() * 0.63 or ScrW() * 0.47
  240. delicate_base:MoveTo( ( ScrW() * 0.5 ) - size_w * 0.5, ScrH() + size_w, 0.2 )
  241. gui.EnableScreenClicker( false )
  242. end
  243. return true
  244. end
  245. hook.Add( 'ScoreboardHide', 'Delicate_UI.Handle.ScoreboardHide', Delicate_UI.HideScoreboard )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement