class LoadingScreenProgressBarController extends inkLogicController
{
	private editable var progressBarRoot : inkWidgetRef;
	private editable var progressBarFill : inkWidgetRef;
	private editable var progressSpinerRoot : inkWidgetRef;
	private var rotationAnimationProxy : inkAnimProxy;
	private var rotationAnimation : inkAnimDef;
	private var rotationInterpolator : inkAnimRotation;

	protected event OnInitialize()
	{
		var animOptions : inkAnimOptions;
		animOptions.loopType = inkanimLoopType.Cycle;
		animOptions.loopInfinite = true;
		rotationAnimation = new inkAnimDef;
		rotationInterpolator = new inkAnimRotation;
		rotationInterpolator.SetDuration( 1.0 );
		rotationInterpolator.SetDirection( inkanimInterpolationDirection.To );
		rotationInterpolator.SetType( inkanimInterpolationType.Linear );
		rotationInterpolator.SetMode( inkanimInterpolationMode.EasyIn );
		rotationInterpolator.SetEndRotation( 180.0 );
		rotationAnimation.AddInterpolator( rotationInterpolator );
		rotationAnimationProxy = inkWidgetRef.PlayAnimationWithOptions( progressSpinerRoot, rotationAnimation, animOptions );
	}

	public function SetSpinnerVisibility( visible : Bool )
	{
		inkWidgetRef.SetVisible( progressSpinerRoot, visible );
	}

	public function SetProgressBarVisiblity( visible : Bool )
	{
		inkWidgetRef.SetVisible( progressBarRoot, visible );
	}

	public function SetProgress( progress : Float )
	{
		var scale : Vector2;
		scale = inkWidgetRef.GetScale( progressBarFill );
		scale.X = progress;
		inkWidgetRef.SetScale( progressBarFill, scale );
	}

}

import abstract class ILoadingLogicController extends inkLogicController
{
}

import class LoadingScreenLogicController extends ILoadingLogicController
{
	private editable var progressBarRoot : inkWidgetRef;
	private editable var progressBarController : weak< LoadingScreenProgressBarController >;

	protected event OnInitialize()
	{
		progressBarController = ( ( LoadingScreenProgressBarController )( inkWidgetRef.GetController( progressBarRoot ) ) );
	}

	protected function SetProgressIndicatorVisibility( visible : Bool )
	{
		progressBarController.SetSpinnerVisibility( visible );
	}

	protected function SetSpinnerVisiblility( visible : Bool )
	{
		progressBarController.SetProgressBarVisiblity( visible );
	}

	protected function SetLoadProgress( progress : Float )
	{
		progressBarController.SetProgress( progress );
	}

}

