class CallActionWidgetController extends DeviceActionWidgetControllerBase
{
	[ category = "Widget Refs" ]
	protected editable var m_statusText : inkTextRef;
	[ category = "Animations" ]
	protected editable var m_callingAnimName : CName;
	default m_callingAnimName = 'calling_animation_maelstrom';
	[ category = "Animations" ]
	protected editable var m_talkingAnimName : CName;
	default m_talkingAnimName = 'talking_animation_maelstrom';
	protected var m_status : IntercomStatus;

	public override function Initialize( gameController : DeviceInkGameControllerBase, const widgetData : ref< SActionWidgetPackage > )
	{
		super.Initialize( gameController, widgetData );
		inkTextRef.SetLocalizedTextScript( m_statusText, "LocKey#279" );
	}

	public override function FinalizeActionExecution( executor : GameObject, action : DeviceAction )
	{
		var contextAction : StartCall;
		contextAction = ( ( StartCall )( action ) );
		if( contextAction )
		{
			CallStarted();
		}
	}

	public function CallStarted()
	{
		m_status = IntercomStatus.CALLING;
		m_targetWidget.SetInteractive( false );
		m_targetWidget.SetState( 'Calling' );
		inkTextRef.SetLocalizedTextScript( m_statusText, "LocKey#2142" );
		PlayLibraryAnimation( m_callingAnimName );
	}

	public function CallPickedUp()
	{
		m_status = IntercomStatus.TALKING;
		m_targetWidget.SetState( 'Talking' );
		inkTextRef.SetLocalizedTextScript( m_statusText, "LocKey#312" );
		PlayLibraryAnimation( m_talkingAnimName );
	}

	public function CallEnded()
	{
		m_status = IntercomStatus.CALL_ENDED;
		inkTextRef.SetLocalizedTextScript( m_statusText, "LocKey#2143" );
	}

	public function CallMissed()
	{
		m_status = IntercomStatus.CALL_MISSED;
		inkTextRef.SetLocalizedTextScript( m_statusText, "LocKey#2145" );
	}

	public function ResetIntercom()
	{
		m_status = IntercomStatus.DEFAULT;
		m_targetWidget.SetInteractive( true );
		m_targetWidget.SetState( 'Default' );
		inkTextRef.SetLocalizedTextScript( m_statusText, "LocKey#279" );
	}

	protected event OnHoverOver( e : inkPointerEvent )
	{
		if( m_status == IntercomStatus.DEFAULT )
		{
			m_targetWidget.SetState( 'Hover' );
		}
	}

	protected event OnHoverOut( e : inkPointerEvent )
	{
		if( m_status == IntercomStatus.DEFAULT )
		{
			m_targetWidget.SetState( 'Default' );
		}
	}

}

