Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.93 KB | None | 0 0
  1. // CONFIG
  2.  
  3. local config = {}
  4.  
  5.  
  6. // END CONFIG
  7.  
  8.  
  9. surface.CreateFont("F4Title", {
  10. size = 27,
  11. weight = 800,
  12. antialias = true,
  13. shadow = false,
  14. font = "roboto"
  15. })
  16.  
  17. surface.CreateFont("F4Button", {
  18. size = 24,
  19. weight = 800,
  20. antialias = true,
  21. font = "roboto",
  22. })
  23.  
  24. surface.CreateFont("F4Text", {
  25. size = 18,
  26. weight = 800,
  27. antialias = true,
  28. shadow = false,
  29. font = "roboto"
  30. })
  31.  
  32. surface.CreateFont("F4TextBigger", {
  33. size = 18,
  34. weight = 800,
  35. antialias = true,
  36. shadow = false,
  37. font = "roboto"
  38. })
  39.  
  40. surface.CreateFont("F4TextFrameTitle", {
  41. size = 21,
  42. weight = 800,
  43. antialias = true,
  44. shadow = false,
  45. font = "roboto"
  46. })
  47.  
  48. surface.CreateFont("F4TextSmall", {
  49. size = 13,
  50. weight = 800,
  51. antialias = true,
  52. shadow = false,
  53. font = "roboto"
  54. })
  55.  
  56.  
  57. local PANEL = {}
  58.  
  59. function PANEL:generateTabs()
  60. DarkRP.hooks.F4MenuTabs()
  61. hook.Call("F4MenuTabs")
  62.  
  63. self:InvalidateLayout()
  64.  
  65. self.buttons[1].DoClick( self.buttons[1] )
  66. end
  67.  
  68. function PANEL:Think()
  69. if ( self.delay < CurTime() and input.IsKeyDown( KEY_F4 ) ) then
  70. self:Close()
  71. end
  72. end
  73.  
  74. function PANEL:Init()
  75. self.buttons = {}
  76.  
  77. local avatar_panel = vgui.Create( "DPanel", self )
  78. avatar_panel:SetPos( 0, 30 )
  79. avatar_panel:SetSize( 185, 65 )
  80.  
  81. function avatar_panel:Paint( w, h )
  82. local col = Color( 51, 57, 68 )
  83.  
  84. draw.RoundedBox( 2, 0, 0, w, h, col )
  85.  
  86. draw.SimpleText( string.upper( LocalPlayer():Nick() ), "F4Text", 55, h/2, Color( 230, 230, 230 ), TEXT_ALIGN_LEFT, 1 )
  87. end
  88.  
  89. local ava = vgui.Create( "AvatarMask", avatar_panel )
  90. ava.Avatar:SetPlayer( LocalPlayer(), 48 )
  91. ava:SetSize( 42, 42 )
  92. ava:SetPos( 7, 12 )
  93.  
  94. self:StretchToParent(150, 100, 150, 100)
  95. self:Center()
  96. self:SetVisible(true)
  97. self:MakePopup()
  98. self:SetTitle( "" )
  99. self:ShowCloseButton( false )
  100.  
  101. local exit = vgui.Create( "DPanel", self )
  102. exit:SetPos( self:GetWide() - 24, 5 )
  103. exit:SetSize( 20, 20 )
  104. exit:SetCursor("hand")
  105.  
  106. function exit:Paint( w, h )
  107. draw.SimpleText( "X", "F4Text", 2, 2, Color( 230, 230, 230 ) )
  108. end
  109.  
  110. exit.OnMousePressed = function()
  111. self:Close()
  112. end
  113.  
  114. local content = vgui.Create( "DPanel", self )
  115. content:SetPos( 190, 40 )
  116. content:SetSize( self:GetWide() - 200, self:GetTall() - 50 )
  117.  
  118. function content:Paint( w, h )
  119.  
  120. end
  121.  
  122. self.content = content
  123. self.oldThink = self.Think
  124. self.delay = CurTime() + 1
  125.  
  126. the_f4_menu = self
  127. end
  128.  
  129. function PANEL:setView( pnl )
  130. if ( ValidPanel( self.content.pnl ) ) then
  131. self.content.pnl:SetVisible( false )
  132. end
  133.  
  134. pnl:SetParent( self.content )
  135. pnl:SetPos( 5, 5 )
  136. pnl:SetVisible( true )
  137. pnl:SetSize( self.content:GetWide()-10, self.content:GetTall()-10 )
  138.  
  139. if ( pnl.InvalidateLayout ) then
  140. pnl:InvalidateLayout()
  141. end
  142.  
  143. self.content.pnl = pnl
  144. end
  145.  
  146. local selected
  147.  
  148. function PANEL:switchTabOrder(name, int)
  149. local key
  150.  
  151. for k,v in pairs( self.buttons ) do
  152. if ( v.name == name ) then
  153. key = k
  154. break
  155. end
  156. end
  157.  
  158. if ( !key ) then return end
  159.  
  160. self.buttons[ int ], self.buttons[ key ] = self.buttons[ key ], self.buttons[ int ]
  161.  
  162. self:InvalidateLayout(true)
  163. end
  164.  
  165. local cnt = 0
  166.  
  167. function PANEL:createTab( name, panel )
  168. if ( name == "Weapons" or name == "Ammo" or name == "Miscellaneous" or name == "Shipments" ) then
  169. panel:Remove()
  170. return
  171. end
  172.  
  173. panel:SetVisible( false )
  174.  
  175. if ( panel.shouldHide and panel:shouldHide() ) then
  176. return
  177. end
  178.  
  179. local but = vgui.Create( "DButton", self )
  180. but:SetText( "" )
  181.  
  182. but.name = name
  183.  
  184. but:SetSize( 185, 45 )
  185.  
  186. local upped = string.upper( name )
  187.  
  188. function but:Paint( w, h )
  189. local col = Color( 51, 57, 68 )
  190.  
  191. if ( but.other == true ) then
  192. col = Color( 45, 52, 66 )
  193. end
  194.  
  195. draw.RoundedBox( 2, 0 ,0, w, h, col )
  196.  
  197. draw.SimpleText( upped, "F4Button", w/2, h/2, Color( 225, 225, 225 ), 1, 1 )
  198.  
  199. if ( selected == but ) then
  200. surface.SetDrawColor( 58, 94, 228 )
  201. surface.DrawRect( 0, 0, 5, h )
  202. end
  203. end
  204.  
  205. but.da_name = name
  206.  
  207. but.DoClick = function( pnl )
  208. self:setView( panel )
  209. selected = pnl
  210. end
  211.  
  212. table.insert( self.buttons, but )
  213. end
  214.  
  215. function PANEL:InvalidateLayout()
  216. local but_y = 95
  217. local but_x = 0
  218.  
  219. for k, v in SortedPairs( self.buttons ) do
  220. v:SetPos( but_x, but_y )
  221.  
  222. v.other = string.len( tostring( k / 2 ) ) == 1
  223.  
  224.  
  225. but_y = but_y + v:GetTall()
  226. end
  227. end
  228.  
  229. function PANEL:Paint( w, h )
  230. draw.RoundedBox( 6, 0, 0, w, h, Color( 60, 60, 60, 220 ) )
  231.  
  232. surface.SetDrawColor( 52, 60, 71 )
  233. surface.DrawRect( 0, 0, w, h )
  234.  
  235. surface.SetDrawColor( 47, 52, 65 )
  236. surface.DrawRect(0,0,185,h)
  237.  
  238. surface.SetDrawColor( 47, 58, 57 )
  239. surface.DrawRect( 0, 0, w, 35 )
  240.  
  241. draw.SimpleText("REPUBLIC GAMING", "F4TextFrameTitle", 10, 5, Color( 230, 230, 230 ) )
  242. end
  243.  
  244. vgui.Register( "F4MenuFrame", PANEL, "DFrame" )
  245.  
  246.  
  247. local PANEL = {}
  248.  
  249. function PANEL:makeCate( name, color )
  250. self.cates[ name ] = {
  251. name = name,
  252. buttons = {},
  253. color = color
  254. }
  255. end
  256.  
  257. function PANEL:makeButton( text, icon, cate, func )
  258. table.insert( self.cates[ cate ][ "buttons"], {
  259. icon = Material( icon ),
  260. func = func,
  261. text = text
  262. } )
  263. end
  264.  
  265. function PANEL:Init()
  266. self.cates = {}
  267.  
  268. self.actions = vgui.Create( "DPanelList", self )
  269. self.actions:EnableVerticalScrollbar( true )
  270. self.actions:SetSpacing( 2 )
  271.  
  272. self:makeCate( "General", Color( 13,102,255, 200 ) )
  273.  
  274. self:makeButton( "Give money to <lookingat>", "icon16/money.png", "General", function()
  275. Derma_StringRequest( "Give money", "how much?", "", function( txt )
  276. RunConsoleCommand( "say", "/give "..txt )
  277. end )
  278. end )
  279.  
  280. self:makeButton( "Drop Money", "icon16/money.png", "General", function()
  281. Derma_StringRequest( "Drop money", "how much?", "", function( txt )
  282. RunConsoleCommand( "say", "/dropmoney "..txt )
  283. end )
  284. end )
  285.  
  286. self:makeButton( "Call an admin", "icon16/shield.png", "General", function()
  287. RunConsoleCommand( "say", "!report" )
  288. end )
  289.  
  290. self:makeButton( "Drop current weapon", "icon16/gun.png", "General", function()
  291. RunConsoleCommand( "say", "/dropweapon" )
  292. end )
  293.  
  294. self:makeCate( "Roleplay Options", Color( 120, 120, 120 ) )
  295.  
  296. self:makeButton( "Change your RPName", "icon16/page_white_edit.png", "Roleplay Options", function()
  297. Derma_StringRequest( "RPName", "whats the new name?", "", function( txt )
  298. RunConsoleCommand( "say", "/rpname "..txt )
  299. end )
  300. end )
  301.  
  302. self:makeButton( "Change your job title", "icon16/page_white_edit.png", "Roleplay Options", function()
  303. Derma_StringRequest( "Job", "whats the new job name?", "", function( txt )
  304. RunConsoleCommand( "say", "/job "..txt )
  305. end )
  306. end )
  307.  
  308. self:makeButton( "Demote a player", "icon16/user_delete.png", "Roleplay Options", function()
  309. local menu = DermaMenu()
  310.  
  311. for k,v in pairs( player.GetAll() ) do
  312. menu:AddOption( v:Nick(), function()
  313. Derma_StringRequest( "Demote", "why are you trying to demote?", "", function( txt )
  314. RunConsoleCommand( "say", "/demote "..v:UserID().. " "..txt )
  315. end )
  316. end )
  317. end
  318.  
  319. menu:Open()
  320. end )
  321.  
  322. self:makeButton( "Sell all your doors", "icon16/door.png", "Roleplay Options", function()
  323. RunConsoleCommand( "say", "/unownalldoors" )
  324. end )
  325.  
  326. self.info = vgui.Create( "DPanel", self )
  327.  
  328. function self.info:Paint( w, h )
  329.  
  330. end
  331.  
  332. local top = vgui.Create( "DPanel", self.info )
  333. top:SetTall( 50 )
  334.  
  335. function top:Paint( w, h )
  336. draw.RoundedBox( 4, 0, 0, w, h, team.GetColor( LocalPlayer():Team() ) )
  337. draw.SimpleText( LocalPlayer():Nick(), "F4Text", 5, 5, color_white )
  338. draw.SimpleText( team.GetName( LocalPlayer():Team()), "F4Text", 5, 25, color_white )
  339. end
  340.  
  341. local job = vgui.Create( "DPanel", self.info )
  342.  
  343. local desc = RPExtraTeams[ LocalPlayer():Team() ].description
  344.  
  345. local lbl = vgui.Create( "DLabel", job )
  346. lbl:SetText( desc )
  347. lbl:SetPos( 5, 5 )
  348. lbl:SetTextColor( color_black )
  349. lbl:SizeToContents()
  350.  
  351. function job:onResize()
  352. local max = self:GetWide()
  353.  
  354. local cur_w = 0
  355.  
  356. local new_txt = {}
  357. local last_space = 2
  358.  
  359. for k,v in pairs( string.ToTable( desc ) ) do
  360. local tw, th = surface.GetTextSize( v )
  361.  
  362. cur_w = cur_w + tw
  363.  
  364. if ( v == " " ) then
  365. last_space = k
  366. end
  367.  
  368. if ( cur_w >= max ) then
  369. new_txt[ last_space ] = "\n"
  370. cur_w = 0
  371. end
  372.  
  373. new_txt[ k ] = v
  374. end
  375.  
  376. local new_str = table.concat( new_txt )
  377.  
  378. new_str = string.gsub( new_str, "\t", "" )
  379.  
  380. lbl:SetText( new_str )
  381. lbl:SizeToContents()
  382.  
  383. job:SetTall( lbl:GetTall() + 10 )
  384. end
  385.  
  386. function job:Paint( w, h )
  387. draw.RoundedBox( 4, 0, 0, w, h, Color( 200, 200, 200 ) )
  388. end
  389. end
  390.  
  391. function PANEL:Setup()
  392. if ( !self.actions ) then return end
  393.  
  394. self.actions:Clear()
  395.  
  396. for k,v in pairs( self.cates ) do
  397. local pnl = vgui.Create( "DCollapsibleCategory" )
  398. pnl:SetLabel( v.name )
  399.  
  400. function pnl:Paint( w, h )
  401. draw.RoundedBox( 2, 0, 0, w, h, v.color )
  402. end
  403.  
  404. local dlist = vgui.Create( "DPanelList" )
  405. dlist:SetAutoSize( true )
  406. dlist:EnableHorizontal( true )
  407. dlist:SetPadding( 4 )
  408. dlist:SetSpacing( 2 )
  409.  
  410. for a,b in pairs( v.buttons ) do
  411. local but = vgui.Create( "DPanel" )
  412. but:SetSize( self:GetWide()*.293, 35 )
  413. but:SetCursor( "hand" )
  414.  
  415. function but:Paint( w, h )
  416. draw.RoundedBox( 2, 0, 0, w, h, Color( 190, 190, 190 ) )
  417.  
  418. if ( self:IsHovered() ) then
  419. draw.RoundedBox( 2, 0, 0, w, h, Color( 100, 100, 100, 100 ) )
  420. end
  421.  
  422. surface.SetDrawColor( 255, 255, 255 )
  423. surface.SetMaterial( b.icon )
  424. surface.DrawTexturedRect( 10, (h/2)-8, 16, 16 )
  425.  
  426. draw.SimpleText( b.text, "F4TextSmall", w/2, h/2, Color( 30, 30, 30 ), 1, 1 )
  427. end
  428.  
  429. function but:OnMousePressed()
  430. b.func()
  431. end
  432.  
  433. dlist:AddItem( but )
  434. end
  435.  
  436. pnl:SetContents( dlist )
  437.  
  438.  
  439. self.actions:AddItem( pnl )
  440. end
  441. end
  442.  
  443. function PANEL:InvalidateLayout()
  444. self.actions:SetSize( self:GetWide()*.6, self:GetTall() )
  445.  
  446. if ( self.info ) then
  447. self.info:SetSize( self:GetWide() - self.actions:GetWide() - 5, self:GetTall() )
  448.  
  449. local x, y = self.actions:GetPos()
  450.  
  451. self.info:SetPos( x + self.actions:GetWide() + 5, 0 )
  452.  
  453. local y = 0
  454.  
  455. for k,v in pairs( self.info:GetChildren() ) do
  456. v:SetPos( 0, y )
  457. v:SetWide( self.info:GetWide() )
  458.  
  459. y = y + v:GetTall() + 5
  460.  
  461. if ( v.onResize ) then
  462. v:onResize()
  463. end
  464. end
  465. end
  466.  
  467. self:Setup()
  468. end
  469.  
  470. vgui.Register( "F4MenuAction", PANEL )
  471.  
  472. local PANEL = {}
  473.  
  474. function PANEL:Init()
  475. self.cates = {}
  476.  
  477. self.joblist = vgui.Create( "DPanelList", self )
  478. self.joblist:EnableVerticalScrollbar( true )
  479. self.joblist:SetSpacing( 7 )
  480. self.joblist:SetPadding( 7 )
  481.  
  482. self.info = vgui.Create( "DPanel", self )
  483.  
  484.  
  485. function self.info:Paint( w, h )
  486. draw.RoundedBox( 6, 0, 0, w, h, Color( 50, 50, 50 ) )
  487.  
  488. if ( !self.filled ) then
  489. draw.SimpleText( "<-- Select a job from the left", "F4Text", 5, 25, color_white )
  490. else
  491. surface.SetDrawColor( Color( self.data.color.r,self.data.color.g,self.data.color.b,150 ) )
  492. surface.DrawRect( 0, 0, w, 25 )
  493. end
  494.  
  495. end
  496. end
  497.  
  498. local function showJobModelSelect( data )
  499. local pre_w = 20 + ( table.Count( data.model ) * 65 )
  500.  
  501. local frame = vgui.Create( "DFrame" )
  502. frame:SetTitle( "Job Model Select" )
  503. frame:SetSize( pre_w, 100 )
  504. frame:MakePopup()
  505. frame:Center()
  506. frame:SetSkin("DarkRP")
  507.  
  508. local x_pos = 10
  509.  
  510. for k,v in pairs( data.model ) do
  511. local icon = vgui.Create( "SpawnIcon", frame )
  512. icon:SetModel( v, 64 )
  513. icon:SetSize( 64, 64 )
  514. icon:SetPos( x_pos, 30 )
  515.  
  516. function icon:DoClick()
  517. DarkRP.setPreferredJobModel( data.team, v )
  518.  
  519. timer.Simple( .5, function()
  520. if ( data.vote ) then
  521. RunConsoleCommand( "say", "/vote"..data.command )
  522. else
  523. RunConsoleCommand( "say", "/"..data.command )
  524. end
  525. end )
  526.  
  527. frame:Close()
  528. end
  529.  
  530. x_pos = x_pos + icon:GetWide() + 1
  531. end
  532. end
  533.  
  534. function PANEL:Setup()
  535. if ( !self.joblist ) then return end
  536.  
  537. self.joblist:Clear()
  538.  
  539. for k,v in pairs( RPExtraTeams ) do
  540. if ( v.team == LocalPlayer():Team() ) then continue end
  541.  
  542. local pnl = vgui.Create( "DPanel" )
  543. pnl:SetTall( 84 )
  544. pnl:SetWide( (self.joblist:GetWide()/2) - 12 )
  545. pnl:SetCursor( "hand" )
  546.  
  547. local path = ( type( v.model ) == "table" and table.Random( v.model ) ) or v.model
  548.  
  549. local mdl = vgui.Create("SpawnIcon", pnl)
  550. mdl:SetModel( path, 64 )
  551. mdl:SetSize( 64, 64 )
  552. mdl:SetPos( 8, 10 )
  553. mdl:SetMouseInputEnabled( false )
  554.  
  555. function pnl:Paint( w, h )
  556. draw.RoundedBox( 6, 0, 0, w, h, Color( 40, 47, 57 ) )
  557.  
  558. if ( self:IsHovered() ) then
  559. draw.RoundedBox( 6, 0, 0, w, h, Color( 100, 100, 100, 100 ) )
  560. end
  561.  
  562. draw.SimpleText( string.upper( v.name ), "F4TextBigger", 70, 25, Color( 235, 235, 235 ), TEXT_ALIGN_LEFT, 1 )
  563. end
  564.  
  565. function pnl:OnMousePressed()
  566. if ( IsValid( the_f4_menu ) ) then
  567. the_f4_menu:Close()
  568. end
  569.  
  570. if ( type( v.model ) == "table" and table.Count( v.model ) > 1 ) then
  571. showJobModelSelect( v )
  572. else
  573. if ( v.vote ) then
  574. RunConsoleCommand( "say", "/vote"..v.command )
  575. else
  576. RunConsoleCommand( "say", "/"..v.command )
  577. end
  578. end
  579. end
  580.  
  581. pnl.OnCursorEntered = function()
  582. self.info:Clear()
  583. self.info.filled = true
  584.  
  585. self.info.data = v
  586.  
  587. local title = vgui.Create( "DLabel", self.info )
  588. title:SetText( v.name )
  589. title:SetPos( 5, 5 )
  590. title:SetFont( "F4Text" )
  591. title:SizeToContents()
  592.  
  593. local desc = vgui.Create( "DLabel", self.info )
  594. desc:SetText( v.description )
  595. desc:SetPos( 5, 35 )
  596. desc:SizeToContents()
  597.  
  598. local max = vgui.Create( "DLabel", self.info )
  599. max:SetText( "Salary: $"..v.salary.."\nMax: "..team.NumPlayers( v.team ).."/"..v.max.."\nWeapons: "..table.concat( v.weapons or {}, "\n" ) )
  600. max:SetPos( 5, 200 )
  601. max:SizeToContents()
  602. end
  603.  
  604. pnl.OnCursorExited = function()
  605. self.info:Clear()
  606. self.info.filled = nil
  607. end
  608.  
  609. self.joblist:AddItem( pnl )
  610. end
  611. end
  612.  
  613. function PANEL:InvalidateLayout()
  614. self.joblist:SetSize( self:GetWide()*.6, self:GetTall() )
  615.  
  616. if ( self.info ) then
  617. self.info:SetSize( self:GetWide() - self.joblist:GetWide() - 5, self:GetTall() )
  618.  
  619. local x, y = self.joblist:GetPos()
  620.  
  621. self.info:SetPos( x + self.joblist:GetWide() + 5, 0 )
  622.  
  623. local y = 0
  624.  
  625. for k,v in pairs( self.info:GetChildren() ) do
  626. v:SetPos( 0, y )
  627. v:SetWide( self.info:GetWide() )
  628.  
  629. y = y + v:GetTall() + 5
  630. end
  631. end
  632.  
  633. self:Setup()
  634. end
  635.  
  636.  
  637. vgui.Register( "F4MenuJobs", PANEL )
  638.  
  639. local function sendURL( url )
  640. local p = vgui.Create( "DPanel" )
  641.  
  642. function p:Paint( w, h )
  643. draw.RoundedBox( 2, 0, 0, w, h, Color( 0, 0, 0, 100 ) )
  644. draw.SimpleText( url, "F4Button", w/2, h/2, color_white, 1, 1 )
  645. end
  646.  
  647. local but = vgui.Create( "DButton", p )
  648. but:SetText("Access page")
  649. but:SetSize( 100, 25 )
  650. function but:DoClick()
  651. gui.OpenURL( url )
  652. end
  653.  
  654. function p:PerformLayout()
  655. but:SetPos( (p:GetWide()/2)-(but:GetWide()/2), (p:GetTall()/2)-(but:GetTall()/2)+35 )
  656. end
  657.  
  658. return p
  659. end
  660.  
  661. hook.Add("F4MenuTabs", "MOARTABSMOARPROBLEMS", function()
  662. DarkRP.addF4MenuTab("Actions", vgui.Create("F4MenuAction"))
  663. DarkRP.addF4MenuTab( "Entities", vgui.Create( "F4MenuEntities" ) )
  664.  
  665. DarkRP.addF4MenuTab( "Forums", sendURL("https://republicgaming.net/") )
  666. DarkRP.addF4MenuTab( "Donate", sendURL("https://republicgaming.net/forums/forumdisplay.php?fid=12") )
  667.  
  668. DarkRP.switchTabOrder("Actions", 1)
  669. DarkRP.switchTabOrder("Jobs", 2)
  670. DarkRP.switchTabOrder("Entities", 3)
  671. DarkRP.switchTabOrder("Forums", 4)
  672. end)
  673.  
  674. local PANEL = {}
  675.  
  676. function PANEL:Init()
  677. local help = vgui.Create( "DPanel", self )
  678.  
  679. function help:Paint( w, h )
  680. draw.RoundedBox( 2, 0, 0, w, h, Color( 50, 50, 50 ) )
  681. draw.SimpleText( help.txt or "Please select an item from below", "F4Text", 30, 5, Color( 230, 230, 230 ) )
  682. draw.SimpleText( "Your money: "..DarkRP.formatMoney( LocalPlayer():getDarkRPVar("money")), "F4Text", 30, 30, Color( 50, 150, 100 ) )
  683. end
  684.  
  685. self.help = help
  686.  
  687. self.itemlist = vgui.Create( "DPanelList", self )
  688. self.itemlist:SetSpacing( 7 )
  689. self.itemlist:EnableVerticalScrollbar( true )
  690. end
  691.  
  692. function PANEL:Setup()
  693. self.itemlist:Clear()
  694.  
  695. local tab = {}
  696.  
  697. for k,v in pairs( DarkRPEntities ) do
  698. tab[ #tab + 1 ] = v
  699. end
  700.  
  701. for k,v in pairs( CustomShipments ) do
  702. tab[ #tab + 1 ] = v
  703.  
  704. if ( v.seperate == false ) then
  705. tab[ #tab ].model = v.model
  706. tab[ #tab ].cmd = "buyshipment "..v.name
  707. else
  708. tab[ #tab ].cmd = "buy "..v.name
  709. end
  710. end
  711.  
  712. for k,v in pairs( CustomVehicles ) do
  713. tab[ #tab + 1 ] = v
  714. end
  715.  
  716. for k,v in pairs( GAMEMODE.AmmoTypes ) do
  717. tab[ #tab + 1 ] = v
  718. tab[ #tab ].cmd = "buyammo "..k
  719. end
  720.  
  721. local cates = {}
  722.  
  723. for k,v in pairs( tab ) do
  724. if ( v.allowed and !table.HasValue( v.allowed, LocalPlayer():Team() ) ) then continue end
  725.  
  726. if ( !cates[ v.category ] ) then
  727. cates[ v.category ] = {}
  728. end
  729.  
  730. table.insert( cates[ v.category ], v )
  731. end
  732.  
  733. for name, data in pairs( cates ) do
  734. local cate = vgui.Create( "DCollapsibleCategory" )
  735. cate:SetLabel( name )
  736.  
  737. function cate:Paint( w, h )
  738. draw.RoundedBox( 6, 0, 0, w, h, Color( 50, 50, 50 ) )
  739. end
  740.  
  741. local catelist = vgui.Create( "DPanelList" )
  742. catelist:SetAutoSize( true )
  743. catelist:SetSpacing( 4 )
  744. catelist:EnableHorizontal( true )
  745. catelist:SetPadding( 4 )
  746.  
  747. for k,v in pairs( data ) do
  748. local pnl = vgui.Create( "DPanel" )
  749. pnl:SetSize( 100, 74 )
  750. pnl:SetCursor( "hand" )
  751. pnl:SetToolTip( v.name.."\n"..DarkRP.formatMoney( v.pricesep or v.price ) )
  752.  
  753. function pnl:OnMousePressed()
  754. RunConsoleCommand( "say", "/"..v.cmd )
  755. end
  756.  
  757. local mdl = vgui.Create( "SpawnIcon", pnl )
  758. mdl:SetModel( v.model, 64 )
  759. mdl:SetSize( 64, 64 )
  760. mdl:SetMouseInputEnabled( false )
  761. mdl:SetPos( ( pnl:GetWide() / 2 ) - (mdl:GetWide()/2), 2 )
  762. pnl.OnCursorEntered = function()
  763. self.help.txt = v.name.." - "..DarkRP.formatMoney( v.pricesep or v.price )
  764. end
  765.  
  766. pnl.OnCursorExited = function()
  767. self.help.txt = nil
  768. end
  769.  
  770. mdl:SetMouseInputEnabled( false )
  771.  
  772. function pnl:Paint() end
  773.  
  774. function pnl:PaintOver( w, h )
  775. //surface.SetDrawColor( 0, 0, 0 )
  776. //surface.DrawLine( 0, 0, 0, h )
  777. //draw.RoundedBox( 2, 0, 0, w, h, Color( 150, 150, 150 ) )
  778. draw.SimpleText( v.name, "DermaDefault", w/2, h-10, Color( 235, 235, 235 ), 1, 1 )
  779. //draw.SimpleText( DarkRP.formatMoney( v.pricesep or v.price ), "F4Text", 70, 30, color_white )
  780. end
  781.  
  782.  
  783. catelist:AddItem( pnl )
  784. end
  785.  
  786. cate:SetContents( catelist )
  787.  
  788. self.itemlist:AddItem( cate )
  789. end
  790. end
  791.  
  792. function PANEL:InvalidateLayout()
  793. self.help:SetSize( self:GetWide(), 60 )
  794.  
  795. self.itemlist:SetPos( 0, 65 )
  796. self.itemlist:SetSize( self:GetWide(), self:GetTall() - 70 )
  797.  
  798. self:Setup()
  799. end
  800.  
  801. vgui.Register( "F4MenuEntities", PANEL )
  802.  
  803. local function DrawRoundedBox( _r, _x, _y, _w, _h )
  804. _r = _r > 8 and 24 or 8
  805. local _u = ( _x + _r * 1 ) - _x
  806. local _v = ( _y + _r * 1 ) - _y
  807.  
  808. local points = 64
  809. local slices = ( 2 * math.pi ) / points
  810. local poly = { }
  811.  
  812. X, Y = _w-_r, _h-_r
  813.  
  814. for i = 0, points-1 do
  815. local angle = ( slices * i ) % points
  816. local x = X + _r * math.cos( angle )
  817. local y = Y + _r * math.sin( angle )
  818.  
  819. if i == points/4-1 then
  820. X, Y = _x+_r, _h-_r
  821. table.insert( poly, { x = X, y = Y, u = _u, v = _v } )
  822. elseif i == points/2-1 then
  823. X, Y = _x, _r
  824. table.insert( poly, { x = X, y = Y, u = _u, v = _v } )
  825. X = _x+_r
  826. elseif i == 3*points/4-1 then
  827. X, Y = _w-_r, 0
  828. table.insert( poly, { x = X, y = Y, u = _u, v = _v } )
  829. Y = _r
  830. end
  831.  
  832. table.insert( poly, { x = x, y = y, u = _u, v = _v } )
  833. end
  834.  
  835. return poly
  836. end
  837.  
  838. local poly = DrawRoundedBox( 16, 0, 0, 44, 44 )
  839. local _material = Material( "effects/flashlight001" );
  840.  
  841. local PANEL = {}
  842.  
  843. function PANEL:Init()
  844. self.Avatar = vgui.Create("AvatarImage", self)
  845. self.Avatar:SetPaintedManually(true)
  846. end
  847.  
  848. function PANEL:PerformLayout()
  849. self.Avatar:SetSize(self:GetWide(), self:GetTall())
  850. end
  851.  
  852. function PANEL:Paint(w, h)
  853. render.ClearStencil()
  854. render.SetStencilEnable(true)
  855.  
  856. render.SetStencilWriteMask( 1 )
  857. render.SetStencilTestMask( 1 )
  858.  
  859. render.SetStencilFailOperation( STENCILOPERATION_REPLACE )
  860. render.SetStencilPassOperation( STENCILOPERATION_ZERO )
  861. render.SetStencilZFailOperation( STENCILOPERATION_ZERO )
  862. render.SetStencilCompareFunction( STENCILCOMPARISONFUNCTION_NEVER )
  863. render.SetStencilReferenceValue( 1 )
  864.  
  865. draw.NoTexture( );
  866. surface.SetMaterial( _material );
  867. surface.SetDrawColor( color_black )
  868. surface.DrawPoly( poly )
  869.  
  870. render.SetStencilFailOperation( STENCILOPERATION_ZERO )
  871. render.SetStencilPassOperation( STENCILOPERATION_REPLACE )
  872. render.SetStencilZFailOperation( STENCILOPERATION_ZERO )
  873. render.SetStencilCompareFunction( STENCILCOMPARISONFUNCTION_EQUAL )
  874. render.SetStencilReferenceValue( 1 )
  875.  
  876. self.Avatar:SetPaintedManually(false)
  877. self.Avatar:PaintManual()
  878. self.Avatar:SetPaintedManually(true)
  879.  
  880. render.SetStencilEnable(false)
  881. render.ClearStencil()
  882. end
  883.  
  884. vgui.Register("AvatarMask", PANEL)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement