class InventoryItemPartDisplay extends inkLogicController
{
	protected editable var m_PartIconImage : inkImageRef;
	protected editable var m_Rarity : inkWidgetRef;
	protected editable var m_TexturePartName : CName;
	protected var attachmentData : InventoryItemAttachments;

	public function Setup( attachmentDataArg : InventoryItemAttachments )
	{
		attachmentData = attachmentDataArg;
		UpdateTexture();
		UpdateMounted();
		SetRarity();
	}

	public static function GetCorrespondingTexturePartName( weaponPartType : WeaponPartType ) : CName
	{
		switch( weaponPartType )
		{
			case WeaponPartType.Silencer:
				return 'mod_silencer';
			case WeaponPartType.Magazine:
				return 'mod_magazine';
			case WeaponPartType.Scope:
				return 'mod_scope';
		}
		return 'mod_scope';
	}

	protected function UpdateTexture()
	{
		inkImageRef.SetTexturePart( m_PartIconImage, GetCorrespondingTexturePartName( InventoryUtils.GetPartType( this.attachmentData ) ) );
	}

	protected function UpdateMounted()
	{
		if( !( InventoryItemData.IsEmpty( this.attachmentData.ItemData ) ) )
		{
			this.GetRootWidget().SetState( 'Mounted' );
		}
		else
		{
			this.GetRootWidget().SetState( 'Default' );
		}
	}

	protected function SetRarity()
	{
		inkWidgetRef.SetState( m_Rarity, InventoryItemData.GetQuality( this.attachmentData.ItemData ) );
	}

}

