class RadioInkGameController extends DeviceInkGameControllerBase
{
	[ category = "Widget Refs" ]
	protected editable var m_stationNameWidget : inkTextRef;
	[ category = "Widget Refs" ]
	protected editable var m_stationLogoWidget : inkImageRef;

	public override function Refresh( state : EDeviceStatus )
	{
		SetupWidgets();
		switch( state )
		{
			case EDeviceStatus.ON:
				TurnOn();
			break;
			case EDeviceStatus.OFF:
				TurnOff();
			break;
			case EDeviceStatus.UNPOWERED:
				break;
			case EDeviceStatus.DISABLED:
				break;
			default:
				break;
		}
		super.Refresh( state );
	}

	protected override function GetOwner() : Radio
	{
		return ( ( Radio )( GetOwnerEntity() ) );
	}

	private function TurnOff()
	{
		inkTextRef.SetVisible( m_stationNameWidget, false );
		m_rootWidget.SetState( 'Off' );
		TriggerAnimationByName( 'eqLoop2', EInkAnimationPlaybackOption.GO_TO_START );
		TriggerAnimationByName( 'eqLoop3', EInkAnimationPlaybackOption.GO_TO_START );
		TriggerAnimationByName( 'eqLoop5', EInkAnimationPlaybackOption.GO_TO_START );
		TriggerAnimationByName( 'eqLoop7', EInkAnimationPlaybackOption.GO_TO_START );
		inkImageRef.SetTexturePart( m_stationLogoWidget, 'no_station' );
	}

	private function TurnOn()
	{
		if( m_cashedState != EDeviceStatus.ON )
		{
			m_rootWidget.SetState( 'Default' );
			TriggerAnimationByName( 'eqLoop2', EInkAnimationPlaybackOption.PLAY );
			TriggerAnimationByName( 'eqLoop3', EInkAnimationPlaybackOption.PLAY );
			TriggerAnimationByName( 'eqLoop5', EInkAnimationPlaybackOption.PLAY );
			TriggerAnimationByName( 'eqLoop7', EInkAnimationPlaybackOption.PLAY );
			inkTextRef.SetVisible( m_stationNameWidget, true );
		}
		inkTextRef.SetLocalizedTextScript( m_stationNameWidget, GetOwner().GetDevicePS().GetActiveStationName() );
		SetupStationLogo();
	}

	private function SetupStationLogo()
	{
		var stationID : ERadioStationList;
		var texturePart : CName;
		stationID = GetOwner().GetDevicePS().GetActiveRadioStation();
		switch( stationID )
		{
			case ERadioStationList.DOWNTEMPO:
				texturePart = 'pacific_dreams';
			break;
			case ERadioStationList.AGGRO_INDUSTRIAL:
				texturePart = 'vexElsTrom';
			break;
			case ERadioStationList.GROWL:
				texturePart = 'growl_fm';
			break;
			case ERadioStationList.JAZZ:
				texturePart = 'royal_blue';
			break;
			case ERadioStationList.ELECTRO_INDUSTRIAL:
				texturePart = 'night_fm';
			break;
			case ERadioStationList.MINIMAL_TECHNO:
				texturePart = 'radio_samizdat';
			break;
			case ERadioStationList.METAL:
				texturePart = 'ritual';
			break;
			case ERadioStationList.POP:
				texturePart = 'body_heat';
			break;
			case ERadioStationList.IMPULSE_FM:
				texturePart = 'impulse_999';
			break;
			case ERadioStationList.HIP_HOP:
				texturePart = 'the_dirge';
			break;
			case ERadioStationList.AGGRO_TECHNO:
				texturePart = 'radio_pebkac';
			break;
			case ERadioStationList.LATINO:
				texturePart = '30_principales';
			break;
			case ERadioStationList.ATTITUDE_ROCK:
				texturePart = 'morro_rock';
			break;
			case ERadioStationList.DARK_STAR:
				texturePart = 'dark_star';
			break;
			default:
				texturePart = 'no_station';
			break;
		}
		inkImageRef.SetTexturePart( m_stationLogoWidget, texturePart );
	}

}

