class InventoryWeaponDisplayController extends InventoryItemDisplayController
{
	protected editable var m_weaponSpecyficModsRoot : inkCompoundRef;
	protected editable var m_silencerIcon : inkWidgetRef;
	protected editable var m_scopeIcon : inkWidgetRef;
	protected editable var m_ammoIcon : inkImageRef;
	protected var weaponAttachmentsDisplay : array< weak< InventoryItemPartDisplay > >;

	protected override function NewRefreshUI( itemData : UIInventoryItem )
	{
		super.NewRefreshUI( itemData );
		NewUpdateWeaponParts( itemData );
		UpdateAmmoIcon( itemData.GetItemData() );
	}

	protected function UpdateAmmoIcon( itemData : weak< gameItemData > )
	{
		var type : gamedataItemType;
		var icon : CName;
		if( itemData )
		{
			type = itemData.GetItemType();
			icon = UIItemsHelper.GetAmmoIconByType( type );
			inkImageRef.SetTexturePart( m_ammoIcon, icon );
		}
	}

	protected virtual function NewUpdateWeaponParts( itemData : UIInventoryItem )
	{
		var hasScopeSlot, hasSilencerSlot, hasScopeInstalled, hasSilencerInstalled : Bool;
		if( itemData )
		{
			hasScopeSlot = itemData.HasScopeSlot();
			hasSilencerSlot = itemData.HasSilencerSlot();
			hasScopeInstalled = itemData.HasScopeInstalled();
			hasSilencerInstalled = itemData.HasSilencerInstalled();
		}
		inkWidgetRef.SetVisible( m_scopeIcon, hasScopeSlot );
		inkWidgetRef.SetState( m_scopeIcon, ( ( hasScopeInstalled ) ? ( 'Default' ) : ( 'Empty' ) ) );
		inkWidgetRef.SetVisible( m_silencerIcon, hasSilencerSlot );
		inkWidgetRef.SetState( m_silencerIcon, ( ( hasSilencerInstalled ) ? ( 'Default' ) : ( 'Empty' ) ) );
	}

	protected override function RefreshUI()
	{
		super.RefreshUI();
		UpdateWeaponParts();
		UpdateAmmoIcon( InventoryItemData.GetGameItemData( m_itemData ) );
	}

	protected virtual function UpdateWeaponParts()
	{
		var i, attachmentsSize : Int32;
		var itemData : InventoryItemData;
		var hasSilencerSlot, hasScopeSlot : Bool;
		var attachment, scopeAttachment, silencerAttachment : InventoryItemAttachments;
		itemData = GetItemData();
		attachmentsSize = itemData.Attachments.Size();
		for( i = 0; i < attachmentsSize; i += 1 )
		{
			attachment = itemData.Attachments[ i ];
			if( attachment.SlotID == T"AttachmentSlots.Scope" )
			{
				scopeAttachment = attachment;
				hasScopeSlot = true;
			}
			else if( attachment.SlotID == T"AttachmentSlots.PowerModule" )
			{
				silencerAttachment = attachment;
				hasSilencerSlot = true;
			}
		}
		inkWidgetRef.SetVisible( m_scopeIcon, hasScopeSlot );
		inkWidgetRef.SetState( m_scopeIcon, ( ( scopeAttachment.ItemData.Empty ) ? ( 'Empty' ) : ( 'Default' ) ) );
		inkWidgetRef.SetVisible( m_silencerIcon, hasSilencerSlot );
		inkWidgetRef.SetState( m_silencerIcon, ( ( silencerAttachment.ItemData.Empty ) ? ( 'Empty' ) : ( 'Default' ) ) );
	}

}

