class StatsProgressController extends inkLogicController
{
	private editable var m_labelRef : inkTextRef;
	private editable var m_currentXpRef : inkTextRef;
	private editable var m_maxXpRef : inkTextRef;
	private editable var m_currentLevelRef : inkTextRef;
	private editable var m_currentPersentageRef : inkTextRef;
	private editable var m_XpWrapper : inkWidgetRef;
	private editable var m_maxXpWrapper : inkWidgetRef;
	private editable var m_progressBarFill : inkWidgetRef;
	private editable var m_progressBar : inkWidgetRef;
	private editable var m_progressMarkerBar : inkWidgetRef;
	private var m_barLenght : Float;

	protected event OnInitialize()
	{
		var tempSize : Vector2;
		tempSize = inkWidgetRef.GetSize( m_progressBar );
		m_barLenght = tempSize.X;
	}

	public function SetProgress( currentXp : Int32, maxXp : Int32 )
	{
		var percentage : Float;
		if( maxXp == -1 )
		{
			inkWidgetRef.SetVisible( m_maxXpWrapper, true );
			inkWidgetRef.SetVisible( m_XpWrapper, false );
			percentage = 1.0;
		}
		else
		{
			inkWidgetRef.SetVisible( m_maxXpWrapper, false );
			inkWidgetRef.SetVisible( m_XpWrapper, true );
			inkTextRef.SetText( m_currentXpRef, IntToString( currentXp ) );
			inkTextRef.SetText( m_maxXpRef, IntToString( maxXp ) );
			percentage = ( ( Float )( currentXp ) ) / ( ( Float )( maxXp ) );
		}
		inkTextRef.SetText( m_currentPersentageRef, IntToString( ( ( Int32 )( percentage * 100.0 ) ) ) + "%" );
		inkWidgetRef.SetScale( m_progressBarFill, Vector2( percentage, 1.0 ) );
		inkWidgetRef.SetMargin( m_progressMarkerBar, m_barLenght * percentage, 0.0, 0.0, 0.0 );
	}

	public function SetLevel( level : Int32 )
	{
		inkTextRef.SetText( m_currentLevelRef, IntToString( level ) );
	}

	public function SetProfiencyLevel( proficiency : ProficiencyDisplayData )
	{
		SetProgress( proficiency.m_expPoints, proficiency.m_maxExpPoints );
		SetLevel( proficiency.m_level );
		inkTextRef.SetText( m_labelRef, proficiency.m_localizedName );
	}

}

