class InventoryWideItemDisplay extends InventoryItemDisplay
{
	protected editable var m_itemNameText : inkTextRef;
	protected editable var m_rarityBackground : inkWidgetRef;
	protected editable var m_iconWrapper : inkWidgetRef;
	protected editable var m_statsWrapper : inkWidgetRef;
	protected editable var m_dpsText : inkTextRef;
	protected editable var m_damageIndicatorRef : inkWidgetRef;
	protected editable var m_additionalInfoText : inkTextRef;
	protected var singleIconSize : Vector2;
	private var m_damageTypeIndicator : weak< DamageTypeIndicator >;
	protected var additionalInfoToShow : ItemAdditionalInfoType;

	protected event OnInitialize()
	{
		super.OnInitialize();
		singleIconSize = Vector2( 186.0, 166.0 );
		m_smallSize.X = 540.0;
		m_smallSize.Y = 177.0;
		m_bigSize.X = ( m_smallSize.X * 2.0 ) + 64.0;
		m_bigSize.Y = 177.0;
		RefreshUI();
		m_damageTypeIndicator = ( ( DamageTypeIndicator )( inkWidgetRef.GetController( m_damageIndicatorRef ) ) );
	}

	public virtual function SetAdditinalInfoType( infoType : ItemAdditionalInfoType )
	{
		additionalInfoToShow = infoType;
	}

	public virtual function Setup( const itemData : ref< InventoryItemData >, additionalInfo : ItemAdditionalInfoType )
	{
		super.Setup( itemData );
		SetAdditinalInfoType( additionalInfo );
		UpdateAdditionalInfo();
	}

	protected virtual function GetPriceText() : String
	{
		var price, vendorPrice, stackPrice, vendorStackPrice : String;
		var euroDolarText : String;
		euroDolarText = GetLocalizedText( "Common-Characters-EuroDollar" );
		if( InventoryItemData.IsVendorItem( m_ItemData ) )
		{
			vendorPrice = ( RoundF( InventoryItemData.GetBuyPrice( m_ItemData ) ) + " " ) + euroDolarText;
			if( InventoryItemData.GetQuantity( m_ItemData ) > 1 )
			{
				vendorStackPrice = ( ( RoundF( InventoryItemData.GetBuyPrice( m_ItemData ) ) * InventoryItemData.GetQuantity( m_ItemData ) ) + " " ) + euroDolarText;
				return ( ( vendorStackPrice + " (" ) + vendorPrice ) + ")";
			}
			return vendorPrice;
		}
		else
		{
			price = ( RoundF( InventoryItemData.GetPrice( m_ItemData ) ) + " " ) + euroDolarText;
			if( InventoryItemData.GetQuantity( m_ItemData ) > 1 )
			{
				stackPrice = ( ( RoundF( InventoryItemData.GetPrice( m_ItemData ) ) * InventoryItemData.GetQuantity( m_ItemData ) ) + " " ) + euroDolarText;
				return ( ( stackPrice + " (" ) + price ) + ")";
			}
			return price;
		}
		return "";
	}

	protected virtual function UpdateAdditionalInfo()
	{
		if( additionalInfoToShow == ItemAdditionalInfoType.NONE || InventoryItemData.IsEmpty( m_ItemData ) )
		{
			inkTextRef.SetVisible( m_additionalInfoText, false );
			return;
		}
		inkTextRef.SetVisible( m_additionalInfoText, true );
		switch( additionalInfoToShow )
		{
			case ItemAdditionalInfoType.PRICE:
				inkTextRef.SetText( m_additionalInfoText, GetPriceText() );
			break;
			case ItemAdditionalInfoType.TYPE:
				inkTextRef.SetLocalizedTextScript( m_additionalInfoText, InventoryItemData.GetLocalizedItemType( m_ItemData ) );
			break;
		}
	}

	protected override function RefreshUI()
	{
		super.RefreshUI();
		SetItemNameText();
		UpdateItemStats();
		UpdateAdditionalInfo();
	}

	protected virtual function UpdateItemStats()
	{
		var record : Item_Record;
		record = TweakDBInterface.GetItemRecord( ItemID.GetTDBID( InventoryItemData.GetID( m_ItemData ) ) );
		switch( record.ItemCategory().Type() )
		{
			case gamedataItemCategory.Weapon:
				inkTextRef.SetText( m_dpsText, IntToString( GetDPS( m_ItemData ) ) );
			inkWidgetRef.SetVisible( m_statsWrapper, true );
			break;
			default:
				inkWidgetRef.SetVisible( m_statsWrapper, false );
			break;
		}
	}

	protected virtual function GetDPS( const data : ref< InventoryItemData > ) : Int32
	{
		var i, limit : Int32;
		var stat : StatViewData;
		if( !( InventoryItemData.IsEmpty( data ) ) )
		{
			for( i = 0, limit = InventoryItemData.GetPrimaryStatsSize( data ); i < limit; i += 1 )
			{
				stat = InventoryItemData.GetPrimaryStat( data, i );
				if( stat.type == gamedataStatType.DPS )
				{
					return stat.value;
				}
			}
		}
		return 0;
	}

	protected virtual function SetItemNameText()
	{
		inkTextRef.SetText( m_itemNameText, InventoryItemData.GetName( m_ItemData ) );
	}

	protected virtual function UpdateDamageType()
	{
		m_damageTypeIndicator.Setup( InventoryItemData.GetDamageType( m_ItemData ) );
	}

	protected override function SetShape( shapeType : EInventoryItemShape )
	{
		var iconSize, newSize : Vector2;
		iconSize = GetIconSize( shapeType );
		newSize = GetShapeSize( shapeType );
		inkImageRef.SetSize( m_BackgroundShape, newSize );
		inkImageRef.SetSize( m_BackgroundHighlight, newSize );
		inkImageRef.SetSize( m_BackgroundFrame, newSize );
		inkWidgetRef.SetSize( m_iconWrapper, iconSize );
		if( inkWidgetRef.IsValid( m_toggleHighlight ) )
		{
			inkWidgetRef.SetSize( m_toggleHighlight, newSize );
		}
		if( InventoryItemData.IsEmpty( m_ItemData ) )
		{
			inkImageRef.SetTexturePart( m_BackgroundFrame, 'item_grid_frame' );
		}
		else
		{
			inkImageRef.SetTexturePart( m_BackgroundFrame, 'item_frame' );
		}
	}

	protected virtual function GetIconSize( shapeType : EInventoryItemShape ) : Vector2
	{
		var newSize : Vector2;
		switch( shapeType )
		{
			case EInventoryItemShape.SingleSlot:
				newSize = Vector2( singleIconSize.X, singleIconSize.Y );
			break;
			case EInventoryItemShape.DoubleSlot:
				newSize = Vector2( m_bigSize.X / 2.0, singleIconSize.Y );
			break;
		}
		return newSize;
	}

}

enum ItemAdditionalInfoType
{
	NONE = 0,
	PRICE = 1,
	TYPE = 2,
}

