//Copyright (C) Ben Parbury - All Rights Reserved. Unauthorized copying of this file, via any medium is strictly prohibited. Written by Ben Parbury <ben@gridlockinteractive.com> 2014
function PauseMenu()
{
	this.__proto__ = new Menu("PauseMenu", EMenuLayout.Vertical)
	

	
	this.Registered = function()
	{

		var index = 2;
		if (gMenuSystem.CanRestart())
		{
			this.AddMenuItemAtIndex(new Button("Restart",
			function() { gMenuSystem.Restart(); }),
			EMenuItemStyle.Medium, index);
			index++;
		}

		if (gMenuSystem.CanHub())
		{
			this.AddMenuItemAtIndex(new Button("Level Select",
			function() { gMenuSystem.Hub(); }),
			EMenuItemStyle.Medium, index);
			index++;
		}
		
		if(gDemo)
		{
			this.AddMenuItemAtIndex(new Button("Skip Level",
			function()
			{
				gMenuSystem.Unregister(gPauseMenu);
				gCompleteOverlay.LoadNextLevel();
			}),
			EMenuItemStyle.Medium, index);
			index++;
		}
		
		this.__proto__.Registered.call(this);
		gPause.Pause(EPauseReason.Player, true);

	}
	
	this.Unregistered = function()
	{
		this.RemoveMenuItem("Level Select");
		this.RemoveMenuItem("Restart");
		if(gDemo)
		{
			this.RemoveMenuItem("Skip Level");	
		}
		
		gPause.Pause(EPauseReason.Player, false);
		this.__proto__.Unregistered.call(this);
	}

	this.AddMenuItem(new Button("Continue",
		function()
		{
			gSounds.Get("pauseClose").Play();
			gMenuSystem.Unregister(gPauseMenu);
		}),
		EMenuItemStyle.Medium);

	this.AddMenuItem(new Button("Options",
		function()
		{
			gMenuSystem.Unregister(gPauseMenu);
			gMenuSystem.Register(gOptionsMenu);
			gOptionsMenu.SetParentMenu(gPauseMenu);
		}),
		EMenuItemStyle.Medium);

	this.AddMenuItem(new Button((gDemo ? "Exit Demo" : "Main Menu"),
		function()
		{
			gMenuSystem.Unregister(gPauseMenu);
			gLevelSystem.LoadLevel("Menu", gDemo ? "Demo" : "Title");
		}),
		EMenuItemStyle.Medium);
}

