class MaterialTooltip extends AGenericTooltipController
{
	protected editable var m_titleWrapper : inkWidgetRef;
	protected editable var m_descriptionWrapper : inkWidgetRef;
	protected editable var m_descriptionLine : inkWidgetRef;
	protected editable var m_Title : inkTextRef;
	protected editable var m_BasePrice : inkTextRef;
	protected editable var m_Price : inkTextRef;
	private var m_animProxy : inkAnimProxy;

	public override function SetData( tooltipData : ATooltipData )
	{
		var messageData : MaterialTooltipData;
		var priceReducted : Bool;
		messageData = ( ( MaterialTooltipData )( tooltipData ) );
		if( messageData )
		{
			inkTextRef.SetText( m_Title, messageData.Title );
			priceReducted = messageData.BaseMaterialQuantity != messageData.MaterialQuantity;
			inkTextRef.SetText( m_BasePrice, IntToString( messageData.BaseMaterialQuantity ) );
			inkTextRef.SetText( m_Price, IntToString( messageData.MaterialQuantity ) );
			inkWidgetRef.SetVisible( m_descriptionWrapper, priceReducted );
			inkWidgetRef.SetVisible( m_descriptionLine, priceReducted && messageData.Title != "" );
			inkWidgetRef.SetVisible( m_titleWrapper, messageData.Title != "" );
		}
	}

	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 MaterialTooltipData extends ATooltipData
{
	var Title : String;
	var BaseMaterialQuantity : Int32;
	var MaterialQuantity : Int32;
	var TitleLocalizationPackage : UILocalizationDataPackage;
	var DescriptionLocalizationPackage : UILocalizationDataPackage;
}

