class InventoryEquipmentSlot extends inkLogicController
{
	protected editable var m_EquipSlotRef : inkWidgetRef;
	protected editable var m_EmptySlotButtonRef : inkWidgetRef;
	protected editable var m_BackgroundShape : inkImageRef;
	protected editable var m_BackgroundHighlight : inkImageRef;
	protected editable var m_BackgroundFrame : inkImageRef;
	protected editable var m_unavailableIcon : inkWidgetRef;
	protected editable var m_toggleHighlight : inkImageRef;
	protected var m_CurrentItemView : weak< InventoryItemDisplayController >;
	private var m_Empty : Bool;
	private var m_itemData : InventoryItemData;
	private var m_equipmentArea : gamedataEquipmentArea;
	private var m_slotName : String;
	private var m_slotIndex : Int32;
	private var m_DisableSlot : Bool;
	default m_DisableSlot = false;
	protected var m_smallSize : Vector2;
	protected var m_bigSize : Vector2;

	protected event OnInitialize()
	{
		m_smallSize.X = 174.0;
		m_smallSize.Y = 177.0;
		m_bigSize.X = 348.0;
		m_bigSize.Y = 177.0;
		inkWidgetRef.SetVisible( m_unavailableIcon, false );
		Clear();
	}

	public virtual function SetDisableSlot( disableSlot : Bool )
	{
		m_DisableSlot = disableSlot;
	}

	public virtual function Setup( itemData : InventoryItemData, equipmentArea : gamedataEquipmentArea, optional slotName : String, optional slotIndex : Int32, optional ownerEntity : Entity )
	{
		if( !( m_CurrentItemView ) )
		{
			if( equipmentArea == gamedataEquipmentArea.Weapon )
			{
				m_CurrentItemView = ( ( InventoryItemDisplayController )( ItemDisplayUtils.SpawnCommonSlotController( this, m_EquipSlotRef, 'weaponDisplay' ) ) );
			}
			else
			{
				m_CurrentItemView = ( ( InventoryItemDisplayController )( ItemDisplayUtils.SpawnCommonSlotController( this, m_EquipSlotRef, 'itemDisplay' ) ) );
			}
		}
		m_CurrentItemView.Setup( itemData );
		m_itemData = itemData;
		m_equipmentArea = equipmentArea;
		m_slotIndex = slotIndex;
		m_slotName = slotName;
		if( ( ( equipmentArea == gamedataEquipmentArea.Weapon || equipmentArea == gamedataEquipmentArea.HandsCW ) || equipmentArea == gamedataEquipmentArea.SystemReplacementCW ) || equipmentArea == gamedataEquipmentArea.ArmsCW )
		{
			InventoryItemData.SetItemShape( itemData, EInventoryItemShape.DoubleSlot );
		}
		inkWidgetRef.SetVisible( m_unavailableIcon, ( ( equipmentArea == gamedataEquipmentArea.HandsCW || equipmentArea == gamedataEquipmentArea.SystemReplacementCW ) || equipmentArea == gamedataEquipmentArea.ArmsCW ) && InventoryItemData.IsEmpty( itemData ) );
		SetShape( InventoryItemData.GetItemShape( itemData ) );
		Show();
	}

	public virtual function Show()
	{
		var itemData : InventoryItemData;
		if( m_CurrentItemView )
		{
			itemData = m_CurrentItemView.GetItemData();
			m_Empty = InventoryItemData.IsEmpty( itemData );
		}
		else
		{
			m_Empty = true;
		}
		RefreshUI();
	}

	public virtual function Clear()
	{
		m_Empty = true;
		RefreshUI();
	}

	protected virtual function RefreshUI()
	{
		m_Empty = false;
		if( m_CurrentItemView )
		{
			m_CurrentItemView.GetRootWidget().SetVisible( !( m_Empty ) );
		}
		inkWidgetRef.SetVisible( m_EmptySlotButtonRef, m_Empty || !( m_DisableSlot ) );
		inkWidgetRef.SetInteractive( m_EmptySlotButtonRef, m_Empty );
	}

	public function SetShape( shapeType : EInventoryItemShape )
	{
		var newSize : Vector2;
		switch( shapeType )
		{
			case EInventoryItemShape.SingleSlot:
				newSize = m_smallSize;
			break;
			case EInventoryItemShape.DoubleSlot:
				newSize = m_bigSize;
			break;
		}
		inkImageRef.SetSize( m_BackgroundShape, newSize );
		inkImageRef.SetSize( m_BackgroundHighlight, newSize );
		inkImageRef.SetSize( m_BackgroundFrame, newSize );
		inkImageRef.SetSize( m_toggleHighlight, newSize );
	}

	public function Select()
	{
		var itemData : InventoryItemData;
		itemData = m_CurrentItemView.GetItemData();
		if( !( InventoryItemData.IsEmpty( itemData ) ) )
		{
			m_CurrentItemView.SelectItem();
		}
		if( inkImageRef.IsValid( m_toggleHighlight ) )
		{
			inkImageRef.SetVisible( m_toggleHighlight, true );
		}
	}

	public function Unselect()
	{
		m_CurrentItemView.UnselectItem();
		if( inkImageRef.IsValid( m_toggleHighlight ) )
		{
			inkImageRef.SetVisible( m_toggleHighlight, false );
		}
	}

	public function GetItemData() : InventoryItemData
	{
		return m_CurrentItemView.GetItemData();
	}

	public virtual function GetSlotWidget() : weak< inkWidget >
	{
		return inkWidgetRef.Get( m_EmptySlotButtonRef );
	}

	public virtual function GetCustomizeWidget() : weak< inkWidget >
	{
		return GetRootWidget();
	}

	public function GetEquipmentArea() : gamedataEquipmentArea
	{
		return m_equipmentArea;
	}

	public function GetEquipmentAreaEnumToInt() : Int32
	{
		return ( ( Int32 )( m_equipmentArea ) );
	}

	public function GetSlotIndex() : Int32
	{
		return m_slotIndex;
	}

	public function GetSlotName() : String
	{
		return m_slotName;
	}

	public virtual function IsEmpty() : Bool
	{
		return m_Empty;
	}

}

