class PlayPauseActionWidgetController extends NextPreviousActionWidgetController
{
	[ category = "Widget Refs" ]
	protected editable var m_playContainer : inkWidgetRef;
	private var m_isPlaying : Bool;
	default m_isPlaying = true;

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

	public override function FinalizeActionExecution( executor : GameObject, action : DeviceAction )
	{
		var contextAction : TogglePlay;
		contextAction = ( ( TogglePlay )( action ) );
		if( !( contextAction.CanPayCost( executor ) ) )
		{
			Decline();
		}
		else
		{
			TogglePlay( ( ( Bool )contextAction.prop.first ) );
		}
	}

	public override function Reset()
	{
		super.Reset();
		DetermineState();
	}

	protected function DetermineState()
	{
		if( m_isPlaying )
		{
			inkWidgetRef.SetVisible( m_playContainer, false );
			inkWidgetRef.SetVisible( m_defaultContainer, true );
		}
		else
		{
			inkWidgetRef.SetVisible( m_playContainer, true );
			inkWidgetRef.SetVisible( m_defaultContainer, false );
		}
	}

	public function TogglePlay( value : Bool )
	{
		m_isPlaying = value;
		DetermineState();
	}

}

