Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- -----------------------------------------
- MODULE: Client Side Menu.
- PURPOSE: Creates the Main Menu.
- CREDITS: Thanks to Garry Newman for the base code.
- -----------------------------------------
- **/
- local MENU = {}
- function MENU:Init()
- self.menuGamemode = "modstation"
- self.menuLocation = "asset://garrysmod/gamemodes/"..self.menuGamemode.."/gamemode/modules/modstationCore/client/menu/html/menu.html"
- self:Dock( FILL )
- self:SetKeyboardInputEnabled( true )
- self:SetMouseInputEnabled( true )
- self.HTML = vgui.Create( "DHTML", self )
- JS_Language( self.HTML )
- JS_Utility( self.HTML )
- self.HTML:Dock( FILL )
- self.HTML:OpenURL( self.menuLocation )
- self.HTML:SetKeyboardInputEnabled( true )
- self.HTML:SetMouseInputEnabled( true )
- self.HTML:SetAllowLua( true )
- self.HTML:RequestFocus()
- self:MakePopup()
- self:SetPopupStayAtBack( false )
- end
- /**
- -----------------------------------------
- METHOD: Call.
- PURPOSE: Calls Javascript in the browser.
- -----------------------------------------
- **/
- function MENU:Call()
- self.HTML:QueueJavascript( js )
- end
- vgui.Register( "modstationMenuPanel", MENU, "EditablePanel" )
- /**
- -----------------------------------------
- METHOD: Timers.
- PURPOSE: Loads the menu straight away on client connection.
- -----------------------------------------
- **/
- timer.Simple( 0, function()
- modstationMainMenu = vgui.Create( "modstationMenuPanel" )
- end )
- /**
- -----------------------------------------
- METHOD: Create Menu.
- PURPOSE: Client side command, creates a new instance of a menu.
- -----------------------------------------
- **/
- function CreateMenu( player,commandName,args )
- if modstationMainMenu then return end
- modstationMainMenu = vgui.Create( "modstationMenuPanel" )
- end
- /**
- -----------------------------------------
- METHOD: Close Menu.
- PURPOSE: Client side command, Removes the menu.
- -----------------------------------------
- **/
- function CloseMenu( player,commandName,args )
- modstationMainMenu:Remove()
- end
- concommand.Add("modstation_openmenu", CreateMenu)
- concommand.Add("modstation_closemenu", CloseMenu)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement