class DamagePreviewController extends inkLogicController
{
	editable var m_fullBar : inkWidgetRef;
	editable var m_stippedBar : inkWidgetRef;
	editable var m_rootCanvas : inkWidgetRef;
	private var m_width : Float;
	private var m_height : Float;
	private var m_heightStripped : Float;
	private var m_heightRoot : Float;
	private var m_animProxy : inkAnimProxy;

	protected event OnInitialize()
	{
		var tempSize : Vector2;
		tempSize = inkWidgetRef.GetSize( m_fullBar );
		m_width = tempSize.X;
		m_height = tempSize.Y;
		tempSize = inkWidgetRef.GetSize( m_stippedBar );
		m_heightStripped = tempSize.Y;
		tempSize = inkWidgetRef.GetSize( m_rootCanvas );
		m_heightRoot = tempSize.Y;
	}

	public function SetPreview( damageScale : Float, positionOffset : Float )
	{
		inkWidgetRef.SetSize( m_rootCanvas, Vector2( damageScale * m_width, m_heightRoot ) );
		inkWidgetRef.SetSize( m_fullBar, Vector2( damageScale * m_width, m_height ) );
		inkWidgetRef.SetSize( m_stippedBar, Vector2( damageScale * m_width, m_heightStripped ) );
		GetRootWidget().SetMargin( ( positionOffset - damageScale ) * m_width, 0.0, 0.0, 0.0 );
		inkWidgetRef.SetVisible( m_rootCanvas, true );
		m_animProxy = PlayLibraryAnimation( 'damage_preview' );
		m_animProxy.RegisterToCallback( inkanimEventType.OnFinish, this, 'OnAnimationEnd' );
	}

	protected event OnAnimationEnd( e : inkAnimProxy )
	{
		inkWidgetRef.SetVisible( m_rootCanvas, false );
	}

}

