importonly struct TutorialOverlayData
{
	import var itemName : CName;
	import var widgetLibraryResource : ResRef;
}

importonly class TutorialOverlayUserData extends inkUserData
{
	import var hideOnInput : Bool;
	import var overlayId : Uint32;
}

import class TutorialOverlayLogicController extends inkLogicController
{
	private import var hideOnInput : Bool;
	private editable var m_showAnimation : CName;
	private editable var m_hideAnimation : CName;
	private var m_animProxy : inkAnimProxy;
	private var m_tutorialManager : weak< questTutorialManager >;

	protected event OnUninitialize()
	{
		if( hideOnInput )
		{
			UnregisterFromGlobalInputCallback( 'OnPostOnRelease', this, 'OnButtonRelease' );
		}
	}

	protected event OnButtonRelease( evt : inkPointerEvent )
	{
		var overlayUserData : TutorialOverlayUserData;
		if( evt.IsAction( 'close_tutorial' ) )
		{
			overlayUserData = ( ( TutorialOverlayUserData )( GetRootWidget().GetUserData( 'gameTutorialOverlayUserData' ) ) );
			m_tutorialManager.RequestToCloseOverlay( overlayUserData.overlayId );
			evt.Handle();
		}
	}

	private function SetupTutorialOverlayLogicController( tutorialManager : questITutorialManager )
	{
		m_tutorialManager = ( ( questTutorialManager )( tutorialManager ) );
		if( hideOnInput )
		{
			RegisterToGlobalInputCallback( 'OnPostOnRelease', this, 'OnButtonRelease' );
		}
	}

	private function PlayShowAnimation() : inkAnimProxy
	{
		var anim : inkAnimProxy;
		anim = PlayLibraryAnimation( m_showAnimation );
		if( anim != NULL )
		{
			anim.RegisterToCallback( inkanimEventType.OnFinish, this, 'OnShowFinished' );
		}
		return anim;
	}

	private function PlayHideAnimation() : inkAnimProxy
	{
		if( m_animProxy )
		{
			m_animProxy.Stop();
		}
		return PlayLibraryAnimation( m_hideAnimation );
	}

	protected event OnShowFinished( e : inkAnimProxy )
	{
		var options : inkAnimOptions;
		options.loopType = inkanimLoopType.None;
		options.loopInfinite = false;
		m_animProxy = PlayLibraryAnimation( 'BracketLoop', options );
	}

}

