class CyberwareTooltip extends AGenericTooltipController
{
	private editable var m_slotList : inkCompoundRef;
	private editable var m_label : inkTextRef;
	private var m_data : CyberwareTooltipData;

	protected event OnInitialize()
	{
		super.OnInitialize();
		inkCompoundRef.RemoveAllChildren( m_slotList );
	}

	public override function SetData( tooltipData : ATooltipData )
	{
		SetData( ( ( CyberwareTooltipData )( tooltipData ) ) );
	}

	public function SetData( data : CyberwareTooltipData )
	{
		if( data )
		{
			m_data = data;
			UpdateLayout();
		}
	}

	private function UpdateLayout()
	{
		var i : Int32;
		var slot : weak< CyberwareTooltipSlotListItem >;
		inkTextRef.SetText( m_label, m_data.label );
		inkCompoundRef.RemoveAllChildren( m_slotList );
		for( i = 0; i < m_data.slotData.Size(); i += 1 )
		{
			slot = ( ( CyberwareTooltipSlotListItem )( SpawnFromLocal( inkCompoundRef.Get( m_slotList ), 'cyberware_slot_list_item' ).GetController() ) );
			slot.SetupData( m_data.slotData[ i ] );
		}
	}

	public function OnOutro()
	{
		m_Root.SetVisible( false );
	}

}

class CyberwareTooltipSlotListItem extends AGenericTooltipController
{
	private editable var m_icon : inkImageRef;
	private editable var m_label : inkTextRef;
	private editable var m_desc : inkTextRef;
	private var m_data : CyberwareSlotTooltipData;

	protected event OnInitialize() {}

	public function SetupData( data : CyberwareSlotTooltipData )
	{
		m_data = data;
		if( m_data.Empty )
		{
			inkTextRef.SetVisible( m_desc, false );
			inkImageRef.SetTexturePart( m_icon, StringToName( m_data.IconPath ) );
			inkTextRef.SetText( m_label, GetLocalizedText( "UI-ScriptExports-EmptySlot0" ) );
		}
		else
		{
			inkTextRef.SetVisible( m_desc, true );
			inkImageRef.SetTexturePart( m_icon, StringToName( m_data.IconPath ) );
			inkTextRef.SetLetterCase( m_label, textLetterCase.UpperCase );
			inkTextRef.SetText( m_label, m_data.Name );
			inkTextRef.SetText( m_desc, m_data.Description );
		}
	}

}

