class NextPreviousActionWidgetController extends DeviceActionWidgetControllerBase
{
	[ category = "Widget Refs" ]
	protected editable var m_defaultContainer : inkWidgetRef;
	[ category = "Widget Refs" ]
	protected editable var m_declineContainer : inkWidgetRef;
	[ category = "Animations" ]
	protected editable var m_moneyStatusAnimName : CName;
	default m_moneyStatusAnimName = 'no_money';
	protected var m_isProcessing : Bool;

	public override function Initialize( gameController : DeviceInkGameControllerBase, const widgetData : ref< SActionWidgetPackage > )
	{
		super.Initialize( gameController, widgetData );
		inkWidgetRef.SetVisible( m_declineContainer, false );
	}

	public override function FinalizeActionExecution( executor : GameObject, action : DeviceAction )
	{
		var contextAction : BaseScriptableAction;
		contextAction = ( ( BaseScriptableAction )( action ) );
		if( !( contextAction.CanPayCost( executor ) ) )
		{
			Decline();
		}
	}

	public virtual function Decline()
	{
		if( !( m_isProcessing ) )
		{
			m_isProcessing = true;
			m_targetWidget.SetInteractive( false );
			PlayLibraryAnimation( m_moneyStatusAnimName ).RegisterToCallback( inkanimEventType.OnFinish, this, 'OnNoMoneyShowed' );
		}
	}

	public virtual function Reset()
	{
		m_isProcessing = false;
		m_targetWidget.SetInteractive( true );
		m_targetWidget.SetState( 'Default' );
	}

	protected event OnNoMoneyShowed( e : inkAnimProxy )
	{
		e.UnregisterFromCallback( inkanimEventType.OnFinish, this, 'OnNoMoneyShowed' );
		Reset();
	}

	public function Deactivate()
	{
		m_targetWidget.SetInteractive( false );
		m_targetWidget.SetState( 'Off' );
	}

	public const override function CanExecuteAction() : Bool
	{
		return super.CanExecuteAction() && !( m_isProcessing );
	}

}

