Advertisement
Guest User

Untitled

a guest
Jun 29th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.32 KB | None | 0 0
  1. bleur.tabs[ 0 ] = { name = "Métiers", hoverColor = Color( 80, 201, 198 ), loadPanels = function( parent, filter )
  2.     local scrollPanel = vgui.Create( "bleur_menu_scrollpanel", parent )
  3.     scrollPanel:SetSize( parent:GetWide(), parent:GetTall() )
  4.  
  5.     filter.keywords = {}
  6.     for i, data in pairs( RPExtraTeams ) do
  7.         local job = vgui.Create( "DPanel", scrollPanel )
  8.         job:SetSize( scrollPanel:GetWide(), 60 )
  9.         job:SetPos( 0, 0 + ( 61 * ( i - 1 ) ) )
  10.         job.hoverMul = 0
  11.  
  12.         filter.keywords[ job ] = { data.name, data.command, data.category }
  13.  
  14.         function job:OnMousePressed()
  15.             if type( data.model ) == "table" and table.Count( data.model ) > 1 then
  16.                 local modelSelect = vgui.Create( "DPanel" )
  17.                 modelSelect:SetSize( 10 + #data.model * 52, 60 )
  18.                 modelSelect:Center()
  19.                 modelSelect:MakePopup()
  20.                 modelSelect.alpha = 0
  21.  
  22.                 function modelSelect:Paint( w, h )
  23.                     self.alpha = Lerp( 0.1, self.alpha, 1 )
  24.                     bleur:drawPanelBlur( self, bleur.settings.blurLayers, bleur.settings.blurDensity, 255 * self.alpha )
  25.                     draw.RoundedBoxEx( 6, 0, 0, w, h, Color( 0, 0, 0, bleur.settings.darkSheetAlpha * self.alpha ), true, true, true, true )
  26.                     draw.RoundedBox( 0, 0, 0, w, h, Color( 255, 255, 255, 5 ) )
  27.                     for n = 1, #data.model do
  28.                         draw.RoundedBox( 0, 5 + ( n - 1 ) * 52, 5, 50, 50, Color( 255, 255, 255, 5 ) )
  29.                     end
  30.                 end
  31.  
  32.                 for j, mdl in pairs( data.model ) do
  33.                     local model = vgui.Create( "DModelPanel", modelSelect )
  34.                     model:SetSize( 50, 50 )
  35.                     model:SetPos( 5 + ( j - 1 ) * 52, 5 )
  36.                     model:SetModel( mdl )
  37.                     model:SetFOV( 45 )
  38.                     model:SetCamPos( Vector( 20, 15, 64 ) )
  39.                     model:SetLookAt( Vector( 0, 0, 64 ) )
  40.                     function model:LayoutEntity()
  41.                         return false
  42.                     end
  43.  
  44.                     function model:OnMousePressed()
  45.                         DarkRP.setPreferredJobModel( i, mdl )
  46.                         modelSelect:Remove()
  47.  
  48.                         timer.Simple( 0.25, function()
  49.                             if data.vote then
  50.                                 RunConsoleCommand( "say", "/vote" .. data.command )
  51.                             else
  52.                                 RunConsoleCommand( "say", "/" .. data.command )
  53.                             end
  54.                         end )
  55.                     end
  56.                 end
  57.             else
  58.                 timer.Simple( 0.25, function()
  59.                     if data.vote then
  60.                         RunConsoleCommand( "say", "/vote" .. data.command )
  61.                     else
  62.                         RunConsoleCommand( "say", "/" .. data.command )
  63.                     end
  64.                 end )
  65.             end
  66.             bleur.menu:Remove()
  67.         end
  68.  
  69.         function job:OnCursorEntered()
  70.             self:SetCursor( "hand" )
  71.         end
  72.  
  73.         function job:OnCursorExited()
  74.             self:SetCursor( "arrow" )
  75.         end
  76.  
  77.         function job:Paint( w, h )
  78.             draw.RoundedBox( 0, 0, 0, w, h, Color( 255, 255, 255, 5 ) )
  79.             draw.RoundedBox( 0, 5, 5, 50, 50, Color( 255, 255, 255, 5 ) )
  80.             surface.SetDrawColor( Color( 255, 255, 255, 25 ) )
  81.             surface.SetMaterial( bleur.materials.job )
  82.             surface.DrawTexturedRect( 60, 9, 16, 16 )
  83.             surface.SetMaterial( bleur.materials.salary )
  84.             surface.DrawTexturedRect( 60, 35, 16, 16 )
  85.  
  86.             if data.max > 0 then
  87.                 surface.SetMaterial( bleur.materials.jobsOccupied )
  88.                 surface.DrawTexturedRect( 120, 35, 16, 16 )
  89.  
  90.                 for j = 1, data.max do
  91.                     surface.SetDrawColor( Color( 255, 255, 255, 25 ) )
  92.                     if j <= team.NumPlayers( i ) then
  93.                         surface.SetDrawColor( Color( 255, 255, 255, 200 ) )
  94.                     end
  95.                     surface.SetMaterial( bleur.materials.man )
  96.                     surface.DrawTexturedRect( 120 + ( 18 * j ), 35, 16, 16 )
  97.                 end
  98.             end
  99.             draw.SimpleText( data.name, "bleur_menu16", 80, 9, Color( 255, 255, 255, 200 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP)
  100.             draw.SimpleText( "$" .. data.salary, "bleur_menu16", 80, 35, Color( 255, 255, 255, 200 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP)
  101.             if self:IsHovered() then
  102.                 self.hoverMul = Lerp( 0.1, self.hoverMul, 1 )
  103.             else
  104.                 self.hoverMul = Lerp( 0.1, self.hoverMul, 0 )
  105.             end
  106.             draw.RoundedBox( 0, 0, 0, 5 * self.hoverMul, h, Color( data.color.r, data.color.g, data.color.b, 255 ) )
  107.         end
  108.  
  109.         local model = vgui.Create( "DModelPanel", job )
  110.         model:SetSize( 50, 50 )
  111.         model:SetPos( 5, 5 )
  112.         model:SetFOV( 45 )
  113.         model:SetCamPos( Vector( 20, 15, 64 ) )
  114.         model:SetLookAt( Vector( 0, 0, 64 ) )
  115.         local text = string.Replace( data.description, "\t", "" )
  116.         if #data.weapons > 0 then
  117.             text = text .. "\n\nWeapons: " .. string.Implode( ", ", data.weapons )
  118.         end
  119.         model:SetTooltip( text )
  120.         if type( data.model ) == "string" then
  121.             model:SetModel( data.model )
  122.         else
  123.             model:SetModel( table.Random( data.model ) )
  124.         end
  125.         function model:LayoutEntity()
  126.             return false
  127.         end
  128.  
  129.         local icons = 0
  130.         if #data.weapons > 0 then
  131.             local icon = vgui.Create( "DImage", job )
  132.             icon:SetSize( 32, 32 )
  133.             icon:SetPos( job:GetWide() - 54 - ( 40 * icons ), job:GetTall() / 2 - 16 )
  134.             icon:SetMaterial( bleur.materials.weapons )
  135.             icon:SetImageColor( Color( 255, 255, 255, 25 ) )
  136.             icons = icons + 1
  137.         end
  138.         if data.hasLicense then
  139.             local icon = vgui.Create( "DImage", job )
  140.             icon:SetSize( 32, 32 )
  141.             icon:SetPos( job:GetWide() - 54 - ( 40 * icons ), job:GetTall() / 2 - 16 )
  142.             icon:SetMaterial( bleur.materials.gunLicense )
  143.             icon:SetImageColor( Color( 255, 255, 255, 25 ) )
  144.             icons = icons + 1
  145.         end
  146.         if data.vote then
  147.             local icon = vgui.Create( "DImage", job )
  148.             icon:SetSize( 32, 32 )
  149.             icon:SetPos( job:GetWide() - 54 - ( 40 * icons ), job:GetTall() / 2 - 16 )
  150.             icon:SetMaterial( bleur.materials.voteOnly )
  151.             icon:SetImageColor( Color( 255, 255, 255, 25 ) )
  152.             icons = icons + 1
  153.         end
  154.     end
  155. end }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement