class MessageTooltip extends AGenericTooltipController
{
	protected editable var m_Title : inkTextRef;
	protected editable var m_Description : inkTextRef;
	private var m_animProxy : inkAnimProxy;

	public override function SetData( tooltipData : ATooltipData )
	{
		var messageData : MessageTooltipData;
		messageData = ( ( MessageTooltipData )( tooltipData ) );
		if( messageData )
		{
			inkTextRef.SetText( m_Title, messageData.Title );
			if( messageData.TitleLocalizationPackage.GetParamsCount() > 0 )
			{
				inkTextRef.SetTextParameters( m_Title, messageData.TitleLocalizationPackage.GetTextParams() );
			}
			inkTextRef.SetText( m_Description, messageData.Description );
			if( messageData.DescriptionLocalizationPackage.GetParamsCount() > 0 )
			{
				inkTextRef.SetTextParameters( m_Description, messageData.DescriptionLocalizationPackage.GetTextParams() );
			}
		}
	}

	public override function Show()
	{
		if( !( m_Root.IsVisible() ) )
		{
			PlayAnim( 'description_tooltip_intro', 'OnIntroComplete', true );
			m_Root.SetAffectsLayoutWhenHidden( true );
		}
	}

	private function PlayAnim( animName : CName, callback : CName, optional forceVisible : Bool )
	{
		if( forceVisible )
		{
			m_Root.SetVisible( true );
		}
		if( m_animProxy != NULL )
		{
			m_animProxy.Stop( true );
			m_animProxy = NULL;
		}
		m_animProxy = PlayLibraryAnimation( animName );
		if( m_animProxy )
		{
			m_animProxy.RegisterToCallback( inkanimEventType.OnFinish, this, callback );
		}
	}

	protected event OnIntroComplete( proxy : inkAnimProxy ) {}

	protected event OnOutroComplete( proxy : inkAnimProxy )
	{
		m_Root.SetVisible( false );
		m_Root.SetAffectsLayoutWhenHidden( false );
	}

}

class MessageDescTooltip extends MessageTooltip
{
	protected editable var m_titleWrapper : inkWidgetRef;
	protected editable var m_descriptionWrapper : inkWidgetRef;
	protected editable var m_descriptionLine : inkWidgetRef;

	public override function SetData( tooltipData : ATooltipData )
	{
		var messageData : MessageTooltipData;
		super.SetData( tooltipData );
		messageData = ( ( MessageTooltipData )( tooltipData ) );
		if( messageData )
		{
			inkWidgetRef.SetVisible( m_descriptionWrapper, messageData.Description != "" );
			inkWidgetRef.SetVisible( m_descriptionLine, messageData.Description != "" && messageData.Title != "" );
			inkWidgetRef.SetVisible( m_titleWrapper, messageData.Title != "" );
		}
	}

}

class TransmogMessageDescTooltip extends MessageTooltip
{
	protected editable var m_titleWrapper : inkWidgetRef;
	protected editable var m_descriptionWrapper : inkWidgetRef;
	protected editable var m_descriptionLine : inkWidgetRef;
	protected editable var m_icon : inkImageRef;

	public override function SetData( tooltipData : ATooltipData )
	{
		var messageData : TransmogMessageTooltipData;
		var useNoIcon : Bool;
		super.SetData( tooltipData );
		messageData = ( ( TransmogMessageTooltipData )( tooltipData ) );
		useNoIcon = messageData && messageData.NoIcon;
		InkImageUtils.RequestSetImage( this, m_icon, ( ( useNoIcon ) ? ( "UIIcon.WardrobeNoAppearanceTransmog" ) : ( messageData.IconPath ) ) );
		inkImageRef.SetState( m_icon, ( ( useNoIcon ) ? ( 'NoIcon' ) : ( 'Default' ) ) );
		if( messageData )
		{
			inkWidgetRef.SetVisible( m_descriptionWrapper, messageData.Description != "" );
			inkWidgetRef.SetVisible( m_descriptionLine, messageData.Description != "" && messageData.Title != "" );
			inkWidgetRef.SetVisible( m_titleWrapper, messageData.Title != "" );
		}
	}

}

class MessageTooltipData extends ATooltipData
{
	var Title : String;
	var Description : String;
	var TitleLocalizationPackage : UILocalizationDataPackage;
	var DescriptionLocalizationPackage : UILocalizationDataPackage;
}

class TransmogMessageTooltipData extends MessageTooltipData
{
	var TransmogItem : ItemID;
	var IconPath : CName;
	var NoIcon : Bool;
}

