Advertisement
Epilepsys

Untitled

Dec 17th, 2018
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.90 KB | None | 0 0
  1.  
  2. if IsValid(menubar.Control) then
  3.  
  4. menubar.Control:SetSkin("DarkRP")
  5.  
  6.  
  7.  
  8. menubar.Control.Paint = function(s,w,h)
  9.  
  10. end
  11.  
  12. end
  13.  
  14.  
  15.  
  16. function menubar.ParentTo( pnl )
  17.  
  18. if not IsValid(menubar.Control) then
  19.  
  20. return
  21.  
  22. end
  23.  
  24. menubar.Control:SetParent( pnl )
  25.  
  26. menubar.Control:MoveToBack()
  27.  
  28. menubar.Control:SetHeight( 24 )
  29.  
  30. menubar.Control:SetVisible( true )
  31.  
  32. end
  33.  
  34.  
  35.  
  36. for k, v in pairs(g_ContextMenu:GetChildren()) do
  37.  
  38. if v.ClassName == "DIconLayout" then
  39.  
  40. v:Remove()
  41.  
  42. end
  43.  
  44. end
  45.  
  46.  
  47.  
  48. g_ContextMenu:SetWorldClicker(false)
  49.  
  50.  
  51.  
  52. -- shameless copy
  53.  
  54. function g_ContextMenu:Open()
  55.  
  56.  
  57.  
  58. self:SetHangOpen( false )
  59.  
  60.  
  61.  
  62. -- If the spawn menu is open, try to close it..
  63.  
  64. if ( g_SpawnMenu:IsVisible() ) then
  65.  
  66. g_SpawnMenu:Close( true )
  67.  
  68. end
  69.  
  70.  
  71.  
  72. if ( self:IsVisible() ) then return end
  73.  
  74.  
  75.  
  76. CloseDermaMenus()
  77.  
  78.  
  79.  
  80. self:MakePopup()
  81.  
  82. self:SetVisible( true )
  83.  
  84. self:SetKeyboardInputEnabled( false )
  85.  
  86. self:SetMouseInputEnabled( true )
  87.  
  88.  
  89.  
  90. RestoreCursorPosition()
  91.  
  92.  
  93.  
  94. hook.Run("MidContextMenuOpening")
  95.  
  96. local wep = LocalPlayer():GetActiveWeapon()
  97.  
  98. local bShouldShow = wep:IsValid() and wep:GetClass() == "gmod_tool"
  99.  
  100.  
  101.  
  102. -- TODO: Any situation in which we shouldn't show the tool menu on the context menu?
  103.  
  104.  
  105.  
  106. -- Set up the active panel..
  107.  
  108. if ( bShouldShow && IsValid( spawnmenu.ActiveControlPanel() ) ) then
  109.  
  110.  
  111.  
  112. self.OldParent = spawnmenu.ActiveControlPanel():GetParent()
  113.  
  114. self.OldPosX, self.OldPosY = spawnmenu.ActiveControlPanel():GetPos()
  115.  
  116. spawnmenu.ActiveControlPanel():SetParent( self )
  117.  
  118. self.Canvas:Clear()
  119.  
  120. self.Canvas:AddItem( spawnmenu.ActiveControlPanel() )
  121.  
  122. self.Canvas:Rebuild()
  123.  
  124. self.Canvas:SetVisible( true )
  125.  
  126.  
  127.  
  128. else
  129.  
  130.  
  131.  
  132. self.Canvas:SetVisible( false )
  133.  
  134.  
  135.  
  136. end
  137.  
  138.  
  139.  
  140. self:InvalidateLayout( true )
  141.  
  142.  
  143.  
  144. end
  145.  
  146.  
  147.  
  148. function g_ContextMenu:PerformLayout()
  149.  
  150.  
  151.  
  152. if ( IsValid( spawnmenu.ActiveControlPanel() ) ) then
  153.  
  154.  
  155.  
  156. spawnmenu.ActiveControlPanel():InvalidateLayout( true )
  157.  
  158.  
  159.  
  160. local Tall = math.min( spawnmenu.ActiveControlPanel():GetTall() + 10, ScrH() * 0.8 )
  161.  
  162. if ( self.Canvas:GetTall() != Tall ) then self.Canvas:SetTall( Tall ) end
  163.  
  164. if ( self.Canvas:GetWide() != 320 ) then self.Canvas:SetWide( 320 ) end
  165.  
  166.  
  167.  
  168. self.Canvas:SetPos( ScrW() - self.Canvas:GetWide() - 50, ScrH() - 50 - Tall - yscale(150) )
  169.  
  170. self.Canvas:InvalidateLayout( true )
  171.  
  172.  
  173.  
  174. end
  175.  
  176.  
  177.  
  178. end
  179.  
  180.  
  181.  
  182. concommand.Add( "+menu_context", function()
  183.  
  184. if IsValid(_G.cmenuspawnedframe) and _G.cmenuspawnedframe:IsVisible() then
  185.  
  186. return
  187.  
  188. end
  189.  
  190.  
  191.  
  192. if g_ContextMenu:IsVisible() then
  193.  
  194. if ( input.IsKeyTrapping() ) then return end
  195.  
  196. hook.Call( "OnContextMenuClose", GAMEMODE )
  197.  
  198. else
  199.  
  200. hook.Call( "OnContextMenuOpen", GAMEMODE ) end
  201.  
  202. end
  203.  
  204. , nil, "Toggles the context menu", { FCVAR_DONTRECORD } )
  205.  
  206. concommand.Add( "-menu_context", function() end, nil, "Absolutely nothing", { FCVAR_DONTRECORD } )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement