class CyberEquipGameController extends ArmorEquipGameController
{
	private var eyesTags : array< CName >;
	private var brainTags : array< CName >;
	private var musculoskeletalTags : array< CName >;
	private var nervousTags : array< CName >;
	private var cardiovascularTags : array< CName >;
	private var immuneTags : array< CName >;
	private var integumentaryTags : array< CName >;
	private var handsTags : array< CName >;
	private var armsTags : array< CName >;
	private var legsTags : array< CName >;
	private var quickSlotTags : array< CName >;
	private var weaponsQuickSlotTags : array< CName >;
	private var fragmentTags : array< CName >;

	protected event OnInitialize()
	{
		var currWidget : weak< inkWidget >;
		panelPlayer.SetVisible( true );
		player = ( ( PlayerPuppet )( GetOwnerEntity() ) );
		m_inventoryManager = new InventoryDataManager;
		m_inventoryManager.Initialize( player );
		GameInstance.GetTransactionSystem( player.GetGame() ).GetItemList( player, m_inventory );
		m_equipmentSystem = ( ( EquipmentSystem )( GameInstance.GetScriptableSystemsContainer( player.GetGame() ).Get( 'EquipmentSystem' ) ) );
		m_transactionSystem = GameInstance.GetTransactionSystem( player.GetGame() );
		m_operationsMode = operationsMode.PLAYER;
		m_tooltipContainer = ( ( inkCompoundWidget )( GetWidget( 'tooltipContainer' ) ) );
		CreateButton( "SYSTEM REPLACEMENT", "cyberware/slotBrain", gamedataEquipmentArea.SystemReplacementCW, 3 );
		CreateButton( "EYES", "cyberware/slotEyes", gamedataEquipmentArea.EyesCW, 3 );
		CreateButton( "CARDIOVASCULAR SYSTEM", "cyberware/slotCardiovascular", gamedataEquipmentArea.CardiovascularSystemCW, 3 );
		CreateButton( "MUSCULOSKELETAL SYSTEM", "cyberware/slotMuscoskeletal0", gamedataEquipmentArea.MusculoskeletalSystemCW, 3 );
		CreateButton( "NERVOUS SYSTEM", "cyberware/slotNervous", gamedataEquipmentArea.NervousSystemCW, 3 );
		CreateButton( "IMMUNE SYSTEM", "cyberware/slotImmune", gamedataEquipmentArea.ImmuneSystemCW, 3 );
		CreateButton( "HANDS", "cyberware/slotHands", gamedataEquipmentArea.HandsCW, 3 );
		CreateButton( "ARMS", "cyberware/slotArms", gamedataEquipmentArea.ArmsCW, 3 );
		CreateButton( "LEGS", "cyberware/slotLegs", gamedataEquipmentArea.LegsCW, 3 );
		CreateButton( "INTEGUMENTARY SYSTEM", "cyberware/slotIntegumentary", gamedataEquipmentArea.IntegumentarySystemCW, 3 );
		CreateButton( "QUICK SLOT", "cyberware/quickSlot", gamedataEquipmentArea.QuickSlot, 5 );
		buttonScrollUp = ( ( inkCanvas )( GetWidget( 'scrollUp' ) ) );
		buttonScrollUp.RegisterToCallback( 'OnRelease', this, 'OnScrollUp' );
		buttonScrollDn = ( ( inkCanvas )( GetWidget( 'scrollDn' ) ) );
		buttonScrollDn.RegisterToCallback( 'OnRelease', this, 'OnScrollDn' );
		buttonScrollUp.SetVisible( false );
		SetCursorOverWidget( currWidget );
		m_uiBB_Equipment = GetAllBlackboardDefs().UI_Equipment;
		m_uiBB_EquipmentBlackboard = GetBlackboardSystem().Get( m_uiBB_Equipment );
		CreateTooltip( m_tooltipLeft );
		CreateTooltip( m_tooltipRight );
	}

	private function CreateButton( const title : ref< String >, const btnPath : ref< String >, area : gamedataEquipmentArea, numSlots : Int32 )
	{
		var currButton : weak< inkCanvas >;
		var i : Int32;
		for( i = 0; i < numSlots; i += 1 )
		{
			currButton = ( ( inkCanvas )( GetWidget( StringToName( btnPath + ( ( String )( i ) ) ) ) ) );
			currButton.SetVisible( true );
			HelperAddPaperdollButton( title, currButton, area, i, headTags );
			m_paperDollList.PushBack( StringToName( btnPath + ( ( String )( i ) ) ) );
		}
	}

	private function GetPartialViewData( itemID : ItemID ) : ItemViewData
	{
		var itemRecord : Item_Record;
		var viewData : ItemViewData;
		var locMgr : UILocalizationMap;
		locMgr = new UILocalizationMap;
		locMgr.Init();
		itemRecord = TweakDBInterface.GetItemRecord( ItemID.GetTDBID( itemID ) );
		viewData.id = itemID;
		viewData.itemName = LocKeyToString( itemRecord.DisplayName() );
		viewData.categoryName = locMgr.Localize( itemRecord.ItemCategory().Name() );
		viewData.description = LocKeyToString( itemRecord.LocalizedDescription() );
		viewData.quality = itemRecord.Quality().Name();
		return viewData;
	}

	protected override function RefreshInventoryList()
	{
		var i : Int32;
		var validItems : array< weak< gameItemData > >;
		var inventorySlotId : Int32;
		m_transactionSystem.GetItemList( player, validItems );
		validItems = RemovedEverythingButCyberware( validItems );
		for( i = 0; i < 30; i += 1 )
		{
			HelperClearButton( i );
		}
		inventorySlotId = 0;
		if( scrollOffset > validItems.Size() )
		{
			scrollOffset = validItems.Size();
			buttonScrollDn.SetVisible( false );
		}
		else
		{
			buttonScrollDn.SetVisible( true );
		}
		for( i = scrollOffset; i < ( scrollOffset + validItems.Size() ); i += 1 )
		{
			if( !( m_equipmentSystem.IsEquipped( player, validItems[ i ].GetID() ) ) )
			{
				HelperAddInventoryButton( validItems[ i ], inventorySlotId );
				inventorySlotId += 1;
			}
		}
	}

	protected function RemovedEverythingButCyberware( const items : ref< array< weak< gameItemData > > > ) : array< weak< gameItemData > >
	{
		var validItems : array< weak< gameItemData > >;
		var i : Int32;
		for( i = 0; i < items.Size(); i += 1 )
		{
			if( m_transactionSystem.HasTag( player, 'Cyberware', items[ i ].GetID() ) )
			{
				validItems.PushBack( items[ i ] );
			}
		}
		return validItems;
	}

}

