Advertisement
Guest User

Untitled

a guest
Jul 25th, 2014
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. /**
  2. -----------------------------------------
  3. MODULE: Client Side Menu.
  4. PURPOSE: Creates the Main Menu.
  5. CREDITS: Thanks to Garry Newman for the base code.
  6. -----------------------------------------
  7. **/
  8.  
  9. local MENU = {}
  10.  
  11. function MENU:Init()
  12.  
  13. self.menuGamemode = "modstation"
  14. self.menuLocation = "asset://garrysmod/gamemodes/"..self.menuGamemode.."/gamemode/modules/modstationCore/client/menu/html/menu.html"
  15.  
  16. self:Dock( FILL )
  17. self:SetKeyboardInputEnabled( true )
  18. self:SetMouseInputEnabled( true )
  19.  
  20. self.HTML = vgui.Create( "DHTML", self )
  21.  
  22. JS_Language( self.HTML )
  23. JS_Utility( self.HTML )
  24.  
  25. self.HTML:Dock( FILL )
  26. self.HTML:OpenURL( self.menuLocation )
  27. self.HTML:SetKeyboardInputEnabled( true )
  28. self.HTML:SetMouseInputEnabled( true )
  29. self.HTML:SetAllowLua( true )
  30. self.HTML:RequestFocus()
  31.  
  32. self:MakePopup()
  33. self:SetPopupStayAtBack( false )
  34.  
  35. end
  36.  
  37. /**
  38. -----------------------------------------
  39. METHOD: Call.
  40. PURPOSE: Calls Javascript in the browser.
  41. -----------------------------------------
  42. **/
  43.  
  44. function MENU:Call()
  45.  
  46. self.HTML:QueueJavascript( js )
  47.  
  48. end
  49.  
  50. vgui.Register( "modstationMenuPanel", MENU, "EditablePanel" )
  51.  
  52. /**
  53. -----------------------------------------
  54. METHOD: Timers.
  55. PURPOSE: Loads the menu straight away on client connection.
  56. -----------------------------------------
  57. **/
  58.  
  59. timer.Simple( 0, function()
  60. modstationMainMenu = vgui.Create( "modstationMenuPanel" )
  61. end )
  62.  
  63. /**
  64. -----------------------------------------
  65. METHOD: Create Menu.
  66. PURPOSE: Client side command, creates a new instance of a menu.
  67. -----------------------------------------
  68. **/
  69.  
  70. function CreateMenu( player,commandName,args )
  71. if modstationMainMenu then return end
  72. modstationMainMenu = vgui.Create( "modstationMenuPanel" )
  73. end
  74.  
  75. /**
  76. -----------------------------------------
  77. METHOD: Close Menu.
  78. PURPOSE: Client side command, Removes the menu.
  79. -----------------------------------------
  80. **/
  81.  
  82. function CloseMenu( player,commandName,args )
  83. modstationMainMenu:Remove()
  84. end
  85.  
  86. concommand.Add("modstation_openmenu", CreateMenu)
  87. concommand.Add("modstation_closemenu", CloseMenu)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement