Guest User

Tool Categories

a guest
Dec 4th, 2016
102
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- This can be found at garrysmod\gamemodes\sandbox\gamemode\spawnmenu
  2. include( "spawnmenu/spawnmenu.lua" )
  3.  
  4. --[[---------------------------------------------------------
  5.     If false is returned then the spawn menu is never created.
  6.     This saves load times if your mod doesn't actually use the
  7.     spawn menu for any reason.
  8. -----------------------------------------------------------]]
  9. function GM:SpawnMenuEnabled()
  10.     return true
  11. end
  12.  
  13. --[[---------------------------------------------------------
  14.     Called when spawnmenu is trying to be opened.
  15.     Return false to dissallow it.
  16. -----------------------------------------------------------]]
  17. function GM:SpawnMenuOpen()
  18.  
  19.     GAMEMODE:SuppressHint( "OpeningMenu" )
  20.     GAMEMODE:AddHint( "OpeningContext", 20 )
  21.  
  22.     return true
  23.  
  24. end
  25.  
  26. --[[---------------------------------------------------------
  27.     Called when context menu is trying to be opened.
  28.     Return false to dissallow it.
  29. -----------------------------------------------------------]]
  30. function GM:ContextMenuOpen()
  31.  
  32.     GAMEMODE:SuppressHint( "OpeningContext" )
  33.     GAMEMODE:AddHint( "ContextClick", 20 )
  34.  
  35.     return true
  36.  
  37. end
  38.  
  39. --[[---------------------------------------------------------
  40.     Backwards compatibility. Do Not Use!!!
  41. -----------------------------------------------------------]]
  42. function GM:GetSpawnmenuTools( name )
  43.     return spawnmenu.GetToolMenu( name )
  44. end
  45.  
  46. --[[---------------------------------------------------------
  47.     Backwards compatibility. Do Not Use!!!
  48. -----------------------------------------------------------]]
  49. function GM:AddSTOOL( category, itemname, text, command, controls, cpanelfunction )
  50.     self:AddToolmenuOption( "Main", category, itemname, text, command, controls, cpanelfunction )
  51. end
  52.  
  53. --[[---------------------------------------------------------
  54.     Don't hook or override this function.
  55.     Hook AddToolMenuTabs instead!
  56. -----------------------------------------------------------]]
  57. function GM:AddGamemodeToolMenuTabs()
  58.  
  59.     -- This is named like this to force it to be the first tab
  60.     spawnmenu.AddToolTab( "Main",       "#spawnmenu.tools_tab", "icon16/wrench.png" )
  61.     spawnmenu.AddToolTab( "Utilities",  "#spawnmenu.utilities_tab", "icon16/page_white_wrench.png" )
  62.  
  63. end
  64.  
  65. --[[---------------------------------------------------------
  66.     Add your custom tabs here.
  67. -----------------------------------------------------------]]
  68. function GM:AddToolMenuTabs()
  69.  
  70.     -- Hook me!
  71.  
  72. end
  73.  
  74. --[[---------------------------------------------------------
  75.     Add categories to your tabs. FROM ME THE GUY WHO BUT DIS IN DA PASTEBIN: I don't suppose you have these categories.
  76. -----------------------------------------------------------]]
  77. function GM:AddGamemodeToolMenuCategories()
  78.  
  79.     spawnmenu.AddToolCategory( "Main", "Constraints",   "#spawnmenu.tools.constraints" )
  80.     spawnmenu.AddToolCategory( "Main", "Construction",  "#spawnmenu.tools.construction" )
  81.     spawnmenu.AddToolCategory( "Main", "Poser",         "#spawnmenu.tools.posing" )
  82.     spawnmenu.AddToolCategory( "Main", "Render",        "#spawnmenu.tools.render" )
  83.  
  84. end
  85.  
  86. --[[---------------------------------------------------------
  87.     Add categories to your tabs
  88. -----------------------------------------------------------]]
  89. function GM:AddToolMenuCategories()
  90.  
  91.     -- Hook this function to add custom stuff
  92.  
  93. end
  94.  
  95. --[[---------------------------------------------------------
  96.     Add categories to your tabs
  97. -----------------------------------------------------------]]
  98. function GM:PopulatePropMenu()
  99.  
  100.     -- This function makes the engine load the spawn menu text files.
  101.     -- We call it here so that any gamemodes not using the default
  102.     -- spawn menu can totally not call it.
  103.     spawnmenu.PopulateFromEngineTextFiles()
  104.  
  105. end
RAW Paste Data