class MenuScenario_CreditsPickerPause extends MenuScenario_BaseMenu
{

	protected event OnEnterScenario( prevScenario : CName, userData : IScriptable )
	{
		var menuState : weak< inkMenusState >;
		menuState = GetMenusState();
		m_currMenuName = 'credits_picker';
		menuState.OpenMenu( m_currMenuName );
	}

	protected event OnLeaveScenario( nextScenario : CName )
	{
		var menuState : weak< inkMenusState >;
		super.OnLeaveScenario( nextScenario );
		menuState = GetMenusState();
		menuState.CloseMenu( 'credits_picker' );
	}

	protected event OnSwitchToCredits()
	{
		m_prevMenuName = m_currMenuName;
		SwitchMenu( 'finalboards_credits' );
	}

	protected event OnSwitchToCreditsEp1()
	{
		m_prevMenuName = m_currMenuName;
		SwitchMenu( 'finalboards_credits_ep1' );
	}

	protected event OnBack()
	{
		if( m_currMenuName != 'credits_picker' )
		{
			SwitchMenu( 'credits_picker' );
		}
		else
		{
			SwitchToScenario( 'MenuScenario_PauseMenu' );
		}
	}

}

class MenuScenario_PauseMenu extends MenuScenario_BaseMenu
{

	protected event OnEnterScenario( prevScenario : CName, userData : IScriptable )
	{
		GetMenusState().OpenMenu( 'pause_menu_background' );
		SwitchMenu( 'pause_menu' );
	}

	protected event OnSwitchToPauseMenu()
	{
		SwitchMenu( 'pause_menu' );
	}

	protected event OnSwitchToSaveGame()
	{
		SwitchMenu( 'save_game' );
	}

	protected event OnSwitchToLoadGame()
	{
		SwitchMenu( 'load_game' );
	}

	protected event OnCreditsPicker()
	{
		m_prevMenuName = m_currMenuName;
		SwitchToScenario( 'MenuScenario_CreditsPickerPause' );
	}

	protected event OnSwitchToSettings()
	{
		SwitchMenu( 'settings_main' );
	}

	protected event OnSwitchToDlc()
	{
		SwitchMenu( 'dlc_menu' );
	}

	protected event OnSwitchToBrightnessSettings()
	{
		m_prevMenuName = m_currMenuName;
		SwitchMenu( 'brightness_settings' );
	}

	protected event OnSwitchToHDRSettings()
	{
		m_prevMenuName = m_currMenuName;
		SwitchMenu( 'hdr_settings' );
	}

	protected event OnSwitchToControllerPanel()
	{
		var menuState : weak< inkMenusState >;
		menuState = GetMenusState();
		m_prevMenuName = m_currMenuName;
		SwitchMenu( menuState.GetControllerMenuName() );
	}

	protected event OnOpenDebugHubMenu()
	{
		CloseSubMenu();
		SwitchToScenario( 'DebugMenuScenario_HubMenu' );
	}

	protected event OnRequestPauseMenu()
	{
		GotoIdleState();
	}

	protected event OnClosePauseMenu()
	{
		GotoIdleState();
	}

	protected event OnCloseHubMenuRequest() {}

	protected event OnCloseSettingsScreen()
	{
		GoBack( true );
	}

	protected event OnBack()
	{
		GoBack( false );
	}

	protected event OnBuyGame()
	{
		TrialHelper.ShowUpgradeTrialVersionCommerceDialog();
	}

	private function GoBack( forceCloseSettings : Bool )
	{
		var menuState : weak< inkMenusState >;
		menuState = GetMenusState();
		if( m_prevMenuName != '' )
		{
			SwitchMenu( m_prevMenuName );
			m_prevMenuName = '';
		}
		else if( m_currMenuName == 'settings_main' && !( forceCloseSettings ) )
		{
			menuState.DispatchEvent( m_currMenuName, 'OnBack' );
		}
		else if( m_currMenuName != 'pause_menu' )
		{
			SwitchMenu( 'pause_menu' );
		}
		else
		{
			GotoIdleState();
		}
	}

}

