class TarotPreviewGameController extends inkGameController
{
	private editable var m_background : inkWidgetRef;
	private editable var m_ep1Icon : inkWidgetRef;
	private editable var m_previewImage : inkImageRef;
	private editable var m_previewTitle : inkTextRef;
	private editable var m_previewDescription : inkTextRef;
	private var m_data : TarotCardPreviewData;
	private var m_isClosing : Bool;

	protected event OnInitialize()
	{
		m_data = ( ( TarotCardPreviewData )( GetRootWidget().GetUserData( 'TarotCardPreviewData' ) ) );
		RegisterToGlobalInputCallback( 'OnPostOnRelease', this, 'OnGlobalRelease' );
		Show( m_data.cardData );
	}

	protected function Show( const data : ref< TarotCardData > )
	{
		var localizedText : String;
		m_isClosing = false;
		InkImageUtils.RequestSetImage( this, m_previewImage, ( "UIIcon." + NameToString( data.imagePath ) ) + "_BIG" );
		inkTextRef.SetText( m_previewTitle, data.label );
		localizedText = GetLocalizedText( data.desc );
		inkTextRef.SetText( m_previewDescription, localizedText );
		if( data.isEp1 )
		{
			inkWidgetRef.SetVisible( m_ep1Icon, true );
		}
		PlayLibraryAnimation( 'panel_intro' );
	}

	protected event OnGlobalRelease( evt : inkPointerEvent )
	{
		var proxy : inkAnimProxy;
		if( evt.IsAction( 'cancel' ) || evt.IsAction( 'click' ) )
		{
			if( !( m_isClosing ) )
			{
				m_isClosing = true;
				proxy = PlayLibraryAnimation( 'panel_outro' );
				proxy.RegisterToCallback( inkanimEventType.OnFinish, this, 'OnOutroCompleted' );
			}
		}
	}

	protected event OnOutroCompleted( anim : inkAnimProxy )
	{
		m_data.token.TriggerCallback( NULL );
	}

}

class TarotCardPreviewData extends inkGameNotificationData
{
	var cardData : TarotCardData;
}

class TarotCardPreviewPopupEvent extends Event
{
	var m_data : TarotCardPreviewData;
}

