3     protected bool                                          m_Hidden;
 
    8     protected ref CargoContainer                            m_CargoGrid;
 
   13     protected ref 
array<int>                                m_AttachmentSlotsSorted;
 
   15     protected int                                           m_StaticAttCount = 0;
 
   16     protected int                                           m_StaticCargoCount = 0;
 
   18     protected ScrollWidget                                  m_ScrollWidget;
 
   26         m_CollapsibleHeader = 
new HandsHeader( 
this, 
"CollapseButtonOnMouseButtonDown" );
 
   27         GetMainWidget().SetFlags( 
WidgetFlags.IGNOREPOINTER );
 
   28         m_MainWidget = m_MainWidget.FindWidget( 
"body" );
 
   29         GetMainWidget().SetFlags( 
WidgetFlags.IGNOREPOINTER );
 
   32         ItemManager.GetInstance().SetHandsPreview( m_HandsPreview );
 
   33         m_Body.Insert( m_HandsPreview );
 
   37             m_HandsPreview.CreateNewIcon( hands_item );
 
   39         m_ScrollWidget                      = ScrollWidget.Cast( 
m_RootWidget.GetParent().GetParent() );
 
   40         RecomputeOpenedContainers();
 
   47             m_Entity.GetOnItemAttached().Remove( AttachmentAdded );
 
   48             m_Entity.GetOnItemDetached().Remove( AttachmentRemoved );
 
   51         m_AttachmentCargos.Clear();
 
   52         m_AttachmentAttachmentsContainers.Clear();
 
   53         m_AttachmentAttachments.Clear();
 
   59         m_Body.Insert( m_HandsPreview );
 
   62     override Header GetHeader()
 
   64         return m_CollapsibleHeader;
 
   67     override bool IsLastIndex()
 
   69         return m_ActiveIndex == m_OpenedContainers.Count() - 1;
 
   72     void SetFocusToIndex()
 
   74         int index = m_ActiveIndex - 1;
 
   75         int attachment_start_index = -1;
 
   76         int cargo_start_index = -1;
 
   77         int attachment_end_index = -1;
 
   78         int cargo_end_index = -1;
 
   80         if ( m_Atts || m_AttachmentAttachments.Count() > 0 )
 
   82             attachment_start_index = 0;
 
   84                 attachment_end_index++;
 
   85             attachment_end_index += m_AttachmentAttachments.Count();
 
   88         if ( m_CargoGrid || m_AttachmentCargos.Count() > 0 )
 
   90             cargo_start_index = attachment_end_index + 1;
 
   93             cargo_end_index += cargo_start_index + m_AttachmentCargos.Count();
 
   96         if ( m_ActiveIndex > m_OpenedContainers.Count() )
 
   98             m_ActiveIndex = m_OpenedContainers.Count();
 
  103             #ifdef PLATFORM_CONSOLE 
  104             if ( m_MainWidget.FindAnyWidget(
"Cursor") )
 
  105                 m_MainWidget.FindAnyWidget(
"Cursor").Show( 
true );
 
  107             m_ScrollWidget.VScrollToPos01( 0 );
 
  111             if( index.InRange( 0, attachment_end_index ) )
 
  117                         m_Atts.SetDefaultFocus();
 
  118                         SetFocusedContainer( m_Atts.GetWrapper() );
 
  122                         m_AttachmentAttachments.GetElement( index - 1 ).SetDefaultFocus();
 
  123                         SetFocusedContainer( m_AttachmentAttachments.GetElement( index - 1 ).GetWrapper() );
 
  128                     m_AttachmentAttachments.GetElement( index ).SetDefaultFocus();
 
  129                     SetFocusedContainer( m_AttachmentAttachments.GetElement( index ).GetWrapper() );
 
  132             else if( index.InRange( cargo_start_index, cargo_end_index ) )
 
  136                     if( index == cargo_start_index )
 
  138                         m_CargoGrid.SetDefaultFocus();
 
  139                         SetFocusedContainer( m_CargoGrid );
 
  143                         m_AttachmentCargos.GetElement( index - 1 - cargo_start_index ).SetDefaultFocus();
 
  144                         SetFocusedContainer( m_AttachmentCargos.GetElement( index - 1 - cargo_start_index ) );
 
  149                     m_AttachmentCargos.GetElement( index - cargo_start_index ).SetDefaultFocus();
 
  150                     SetFocusedContainer( m_AttachmentCargos.GetElement( index - cargo_start_index ) );
 
  154             if( m_MainWidget.FindAnyWidget(
"Cursor") )
 
  155                 m_MainWidget.FindAnyWidget(
"Cursor").Show( 
false );
 
  156             ScrollToActiveContainer( GetFocusedContainer() );
 
  160     void ScrollToActiveContainer( 
Container active_container )
 
  162         if( !active_container )
 
  165         m_ScrollWidget.GetScreenPos( 
x, 
y );
 
  166         m_ScrollWidget.GetScreenSize( 
x, y_s );
 
  168         float next_pos  = active_container.GetFocusedContainerYScreenPos( 
true ) + active_container.GetFocusedContainerHeight( 
true );
 
  170         if( next_pos > ( 
y + y_s ) )
 
  172             amount  = 
y + active_container.GetFocusedContainerYScreenPos( 
true );
 
  173             m_ScrollWidget.VScrollToPos( m_ScrollWidget.GetVScrollPos() + active_container.GetFocusedContainerHeight( 
true ) + 2 );
 
  175         else if( active_container.GetFocusedContainerYScreenPos( 
true ) < 
y )
 
  177             amount = active_container.GetFocusedContainerYScreenPos( 
true ) - 
y;
 
  178             m_ScrollWidget.VScrollToPos( m_ScrollWidget.GetVScrollPos() + amount - 2 );
 
  182     override void Insert( 
LayoutHolder container, 
int pos = -1, 
bool immedUpdate = 
true )
 
  184         super.Insert( container, pos, immedUpdate );
 
  187     override bool TransferItem()
 
  189         if (m_ActiveIndex == 0)
 
  191             if (CanTakeToInventory())
 
  193                 EntityAI item_in_hands = 
GetGame().GetPlayer().GetHumanInventory().GetEntityInHands();
 
  194                 if (item_in_hands && 
GetGame().
GetPlayer().GetHumanInventory().CanRemoveEntityInHands() && !
GetGame().
GetPlayer().GetInventory().HasInventoryReservation(item_in_hands, 
null))
 
  198                         m_MainWidget.FindAnyWidget(
"Cursor").Show( 
false );
 
  199                         m_MainWidget.FindAnyWidget(
"hands_preview_root").SetAlpha( 0.7 );
 
  205         else if (GetFocusedContainer())
 
  207             return GetFocusedContainer().TransferItem();
 
  212     override bool SplitItem()
 
  216             if (m_ActiveIndex == 0)
 
  221                     if ( item_in_hands.CanBeSplit() )
 
  223                         item_in_hands.OnRightClick();
 
  227             else if( GetFocusedContainer() )
 
  229                 return GetFocusedContainer().SplitItem();
 
  235     override bool EquipItem()
 
  239             if (m_ActiveIndex == 0)
 
  244                     if ( 
GetGame().
GetPlayer().GetHumanInventory().CanRemoveEntityInHands() && !
GetGame().
GetPlayer().GetInventory().HasInventoryReservation(item_in_hands, 
null)  )
 
  248                             m_MainWidget.FindAnyWidget(
"Cursor").Show( 
false );
 
  249                             m_MainWidget.FindAnyWidget(
"hands_preview_root").SetAlpha( 0.7 );
 
  255             else if (GetFocusedContainer())
 
  257                 return GetFocusedContainer().EquipItem();
 
  263     override void SetActive( 
bool active )
 
  265         super.SetActive(active);
 
  267         EntityAI item_in_hands = player.GetHumanInventory().GetEntityInHands();
 
  271             if( m_MainWidget.FindAnyWidget( 
"Cursor" ) )
 
  273                 m_MainWidget.FindAnyWidget( 
"Cursor" ).Show( active );
 
  279                 GetMainWidget().GetScreenPos( 
x, 
y );
 
  280                 PrepareOwnedTooltip( item_in_hands, -1, 
y );
 
  286                 m_MainWidget.FindAnyWidget( 
"hands_preview_root" ).SetAlpha( 0.85 );
 
  288                 m_MainWidget.FindAnyWidget( 
"hands_preview_root" ).SetAlpha( 0.7 );
 
  292     override void SetLastActive()
 
  294         super.SetLastActive();
 
  296         EntityAI item_in_hands = player.GetHumanInventory().GetEntityInHands();
 
  300             if ( m_ActiveIndex == 0)
 
  302                 if( m_MainWidget.FindAnyWidget( 
"Cursor" ) )
 
  304                     m_MainWidget.FindAnyWidget( 
"Cursor" ).Show( 
true );
 
  308                 GetMainWidget().GetScreenPos( 
x, 
y );
 
  309                 PrepareOwnedTooltip( item_in_hands, 
x, 
y );
 
  314             m_MainWidget.FindAnyWidget( 
"hands_preview_root" ).SetAlpha( 0.85 );
 
  318     override void Refresh()
 
  324     override bool IsItemActive()
 
  327         ItemBase item = 
ItemBase.Cast( player.GetHumanInventory().GetEntityInHands() );
 
  335     override bool IsItemWithQuantityActive()
 
  338         ItemBase item = 
ItemBase.Cast( player.GetHumanInventory().GetEntityInHands() );
 
  346     override bool IsEmpty()
 
  349         return player.GetHumanInventory().GetEntityInHands() == 
null;
 
  352     override bool TransferItemToVicinity()
 
  356             if (m_ActiveIndex == 0)
 
  359                 ItemBase item_in_hands = 
ItemBase.Cast(player.GetHumanInventory().GetEntityInHands());
 
  360                 if ( item_in_hands && player.CanDropEntity( item_in_hands ) && 
GetGame().
GetPlayer().GetHumanInventory().CanRemoveEntityInHands() && !player.GetInventory().HasInventoryReservation(item_in_hands, 
null) )
 
  362                     if ( item_in_hands.GetTargetQuantityMax() < item_in_hands.GetQuantity() )
 
  363                         item_in_hands.SplitIntoStackMaxClient( 
null, -1 );
 
  365                         player.PhysicalPredictiveDropItem( item_in_hands );
 
  366                     m_MainWidget.FindAnyWidget(
"Cursor").Show( 
false );
 
  367                     m_MainWidget.FindAnyWidget(
"hands_preview_root").SetAlpha( 0.7 );
 
  371             else if ( GetFocusedContainer() )
 
  373                     return GetFocusedContainer().TransferItemToVicinity();
 
  379     override bool InspectItem()
 
  381         if(m_ActiveIndex == 0)
 
  384             EntityAI item_in_hands = player.GetHumanInventory().GetEntityInHands();
 
  387                 InspectItem( item_in_hands );
 
  391         else if( GetFocusedContainer() )
 
  393             return GetFocusedContainer().InspectItem();
 
  398     override bool OnSelectButton()
 
  400         if(m_ActiveIndex == 0)
 
  402             if (
ItemManager.GetInstance().IsMicromanagmentMode())
 
  405                 if( selectedItem == GetFocusedItem() )
 
  407                     Inventory.GetInstance().DisableMicromanagement();
 
  417                 Inventory.GetInstance().EnableMicromanagement();
 
  423             if( GetFocusedContainer() )
 
  425                 return GetFocusedContainer().OnSelectButton();
 
  436             string name = w.GetName();
 
  437             name.Replace( 
"PanelWidget", 
"Render" );
 
  451         return ipw.GetItem();
 
  454     override void DraggingOverHeader( 
Widget w, 
int x, 
int y, 
Widget receiver )
 
  464         string name = w.GetName();
 
  465         name.Replace( 
"PanelWidget", 
"Render" );
 
  478         receiver.GetUserData(slots_icon);
 
  482             receiver_item   = slots_icon.GetEntity();
 
  483             slot_id         = slots_icon.GetSlotID();
 
  484             slot_owner      = slots_icon.GetSlotParent();
 
  496         if( receiver_entity )
 
  502                 if( receiver_itemIB && itemIB && receiver_itemIB.CanBeCombined( itemIB ) )
 
  507                         ItemManager.GetInstance().GetRightDropzone().SetAlpha( 1 );
 
  511                         ItemManager.GetInstance().GetLeftDropzone().SetAlpha( 1 );
 
  518                     Magazine mag = Magazine.Cast(receiver_item);
 
  523                         if( player.GetWeaponManager().CanSwapMagazine( wpn,  Magazine.Cast(w_entity) ) )
 
  526                             if( w_entity.GetHierarchyRootPlayer() == player )
 
  528                                 ItemManager.GetInstance().GetRightDropzone().SetAlpha( 1 );
 
  532                                 ItemManager.GetInstance().GetLeftDropzone().SetAlpha( 1 );
 
  538                             ItemManager.GetInstance().ShowSourceDropzone( w_entity );
 
  543                         if( 
GameInventory.CanSwapEntitiesEx( receiver_item, w_entity ) )
 
  548                                 ItemManager.GetInstance().GetRightDropzone().SetAlpha( 1 );
 
  552                                 ItemManager.GetInstance().GetLeftDropzone().SetAlpha( 1 );
 
  556                         else if( receiver_itemIB.GetInventory().CanAddAttachment( w_entity ) )
 
  561                                 ItemManager.GetInstance().GetRightDropzone().SetAlpha( 1 );
 
  565                                 ItemManager.GetInstance().GetLeftDropzone().SetAlpha( 1 );
 
  572             else if( slot_owner && slot_owner.GetInventory().CanAddAttachment( w_entity ) )
 
  575                 ItemManager.GetInstance().GetCenterDropzone().SetAlpha( 1 );
 
  578             else if( receiver_entity.GetInventory().CanAddAttachment( w_entity ) )
 
  583                     ItemManager.GetInstance().GetRightDropzone().SetAlpha( 1 );
 
  587                     ItemManager.GetInstance().GetLeftDropzone().SetAlpha( 1 );
 
  594                 ItemManager.GetInstance().ShowSourceDropzone( w_entity );
 
  609                 ItemManager.GetInstance().ShowSourceDropzone( w_entity );
 
  614     void OnDropReceivedFromHeader2( 
Widget w, 
int x, 
int y, 
Widget receiver )
 
  616         TakeAsAttachment( w, receiver );
 
  619     void OnPerformCombination(
int combinationFlags)
 
  622         if ( m_am_entity1 == 
null || m_am_entity2 == 
null ) 
return;
 
  629             if ( 
Class.CastTo(mag,  m_am_entity2 ) )
 
  631                 m_player.GetWeaponManager().LoadBullet( mag );
 
  640                 m_Body.RemoveItem( m_Atts.GetWrapper() );
 
  643             if( m_am_entity2.GetSlotsCountCorrect() > 0 )
 
  646                 m_Atts.InitAttachmentGrid( 1 );
 
  655             if ( 
Class.CastTo(wpn1,  m_am_entity1 ) && 
Class.CastTo(mag1,  m_am_entity2 ) )
 
  657                 if( 
m_player.GetWeaponManager().CanAttachMagazine(wpn1, mag1) )
 
  659                     m_player.GetWeaponManager().AttachMagazine(mag1);
 
  670             m_player.PredictiveTakeEntityToTargetCargo( m_am_entity1, m_am_entity2 );
 
  677             if (
Class.CastTo(swapmag1,  m_am_entity1) && 
Class.CastTo(swapmag2,  m_am_entity2 ) )
 
  679                 if( 
m_player.GetWeaponManager().CanSwapMagazine( 
Weapon_Base.Cast( swapmag1.GetParent() ), Magazine.Cast( swapmag2 ) ) )
 
  681                     m_player.GetWeaponManager().SwapMagazine(swapmag2);
 
  685                 if( 
m_player.GetWeaponManager().CanSwapMagazine(
Weapon_Base.Cast( swapmag2.GetParent() ), Magazine.Cast( swapmag1 )) )
 
  687                     m_player.GetWeaponManager().SwapMagazine(swapmag1);
 
  691             if ( !
m_player.PredictiveSwapEntities( m_am_entity1, m_am_entity2 ) && 
m_player.GetHumanInventory().CanAddEntityInHands( m_am_entity1 ) )
 
  693                 m_player.PredictiveTakeEntityToHands( m_am_entity1 );
 
  701                 m_Body.RemoveItem( m_Atts.GetWrapper() );
 
  705             if ( m_am_entity2.GetSlotsCountCorrect() > 0 )
 
  708                 m_Atts.InitAttachmentGrid( 1 );
 
  714             if ( 
m_player.GetHumanInventory().CanAddEntityInHands( m_am_entity2 ) )
 
  716                 m_player.PredictiveTakeEntityToHands( m_am_entity2 );
 
  721     void ShowActionMenuCombine( 
EntityAI entity1, 
EntityAI entity2, 
int combinationFlags )
 
  723         if ( entity1 && entity2 ) 
PrintString( 
"Showing action menu for " + entity1.GetDisplayName() + 
" and " + entity2.GetDisplayName() );
 
  726         m_am_entity1 = entity1;
 
  727         m_am_entity2 = entity2;
 
  734             entity.CombineItemsClient( 
ItemBase.Cast( entity2 ) );
 
  738         if ( entity1 == 
null || entity2 == 
null ) 
return;
 
  744             cmenu.Add( 
"#inv_context_add_as_attachment", 
this, 
"OnPerformCombination", 
new Param1<int>( 
InventoryCombinationFlags.ADD_AS_ATTACHMENT ) );
 
  748             cmenu.Add( 
"#inv_context_load_chamber", 
this, 
"OnPerformCombination", 
new Param1<int>( 
InventoryCombinationFlags.LOAD_CHAMBER ) );
 
  753             cmenu.Add( 
"#inv_context_add_as_cargo", 
this, 
"OnPerformCombination", 
new Param1<int>( 
InventoryCombinationFlags.ADD_AS_CARGO ) );
 
  763             cmenu.Add( 
"#inv_context_take_to_hands", 
this, 
"OnPerformCombination", 
new Param1<int>( 
InventoryCombinationFlags.TAKE_TO_HANDS ) );
 
  768             cmenu.Add( 
"#inv_context_combine", 
this, 
"OnPerformCombination", 
new Param1<int>( 
InventoryCombinationFlags.COMBINE_QUANTITY2 ) );
 
  771         int m_am_pos_x,  m_am_pos_y;
 
  776         cmenu.Show( m_am_pos_x, m_am_pos_y );
 
  780     override void OnDropReceivedFromHeader( 
Widget w, 
int x, 
int y, 
Widget receiver )
 
  782         TakeAsAttachment( w, receiver );
 
  791         if (!entity1 || !entity2) 
return flags;
 
  795         bool skipSwap = 
false;
 
  797         if (
Class.CastTo(swapmag1, entity1) && 
Class.CastTo(swapmag2, entity2))
 
  801             if (
Class.CastTo(parentWpn, swapmag1.GetHierarchyParent()))
 
  804                 if (
m_player.GetWeaponManager().CanSwapMagazine(parentWpn,swapmag2))
 
  808             if (
Class.CastTo(parentWpn, swapmag2.GetHierarchyParent()))
 
  811                 if (
m_player.GetWeaponManager().CanSwapMagazine(parentWpn,swapmag1))
 
  820             else if (
GameInventory.CanSwapEntitiesEx( entity1, entity2 ))
 
  822                 if (!entity1.IsInherited( 
ZombieBase ) && !entity1.IsInherited( Car ))
 
  835         else if (entity1.GetInventory().CanAddAttachment( entity2 ))
 
  837             if (!entity1.IsInherited( 
ZombieBase ) && !entity1.IsInherited( Car ) && !entity2.IsInherited( 
ZombieBase ) && !entity2.IsInherited( Car ))
 
  842         if (!entity1.GetInventory().HasEntityInInventory(entity2) && entity1.GetInventory().CanAddEntityInCargo( entity2, entity2.GetInventory().GetFlipCargo() )) flags = flags | 
InventoryCombinationFlags.ADD_AS_CARGO;
 
  844         if (entity1 == 
m_player.GetHumanInventory().GetEntityInHands() || entity2 == 
m_player.GetHumanInventory().GetEntityInHands())
 
  848             if (entity1 == 
m_player.GetHumanInventory().GetEntityInHands())
 
  850                 if (amc.CanSetActionFromInventory( 
ItemBase.Cast( entity1 ), 
ItemBase.Cast( entity2 ) ))
 
  857                 if (amc.CanSetActionFromInventory( 
ItemBase.Cast( entity2 ), 
ItemBase.Cast( entity1 ) ))
 
  864         if (GetRecipeCount( 
true, entity1, entity2 ) > 0)
 
  871     int GetRecipeCount( 
bool recipe_anywhere, 
EntityAI entity1, 
EntityAI entity2 )
 
  873         PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast( 
GetPlugin( PluginRecipesManager ) );
 
  880         m_CollapsibleHeader.ShowCollapseButtons( 
false, 
true );
 
  887             m_Body.RemoveItem( m_Atts.GetWrapper() );
 
  892                 m_Entity.GetOnItemAttached().Remove( AttachmentAdded );
 
  893                 m_Entity.GetOnItemDetached().Remove( AttachmentRemoved );
 
  897         if( m_AttachmentAttachmentsContainers )
 
  901                 m_Body.RemoveItem( att );
 
  902                 m_AttachmentAttachments.Remove( ent );
 
  907         m_AttachmentAttachmentsContainers.Clear();
 
  910         RecomputeOpenedContainers();
 
  913     override void UnfocusGrid()
 
  922             m_CargoGrid.UnfocusAll();
 
  925         if( m_AttachmentCargos )
 
  927             foreach( 
EntityAI e1, CargoContainer cargo : m_AttachmentCargos )
 
  934         if( m_AttachmentCargos )
 
  943     override void UnfocusAll()
 
  952             m_Body.RemoveItem( m_CargoGrid );
 
  956         if( m_AttachmentCargos )
 
  958             foreach( CargoContainer cargo : m_AttachmentCargos )
 
  960                 m_Body.RemoveItem( cargo );
 
  965         m_AttachmentCargos.Clear();
 
  968         RecomputeOpenedContainers();
 
  971     void DropReceived( 
Widget w,  
int x, 
int y, CargoContainer cargo )
 
  974         EntityAI item_in_hands = player.GetHumanInventory().GetEntityInHands();
 
  976         EntityAI item = GetItemPreviewItem( w );
 
  988         if( cargo == m_CargoGrid )
 
  991             target_cargo    = 
m_Entity.GetInventory().GetCargo();
 
  992             #ifdef PLATFORM_CONSOLE 
  993             if( m_CargoGrid.HasItem( item ) )
 
 1001             target_entity   = m_AttachmentCargos.GetKeyByValue( cargo );
 
 1004                 target_cargo    = target_entity.GetInventory().GetCargo();
 
 1005                 #ifdef PLATFORM_CONSOLE 
 1006                 if( cargo.HasItem( item ) )
 
 1016         if( target_cargo && target_entity )
 
 1018             c_x = target_cargo.GetHeight();
 
 1019             c_y = target_cargo.GetWidth();
 
 1025         #ifdef PLATFORM_CONSOLE 
 1027         y = target_cargo.GetItemCount();
 
 1030         dst.SetCargoAuto(target_cargo, item, 
x, 
y, item.GetInventory().GetFlipCargo());
 
 1034         item.GetInventory().GetCurrentInventoryLocation(src);
 
 1035         if(src.CompareLocationOnly(dst) && src.GetFlip() == dst.GetFlip())
 
 1038         #ifdef PLATFORM_CONSOLE 
 1039         if(dst.IsValid() && target_entity.GetInventory().LocationCanAddEntity(dst))
 
 1041         if( c_x > 
x && c_y > 
y && target_entity.GetInventory().LocationCanAddEntity(dst))
 
 1046             Icon icon = cargo.GetIcon( item );
 
 1050                 if( w && w.FindAnyWidget(
"Cursor") )
 
 1051                     w.FindAnyWidget(
"Cursor").SetColor( 
ColorManager.BASE_COLOR );
 
 1060     bool DraggingOverGrid( 
Widget w,  
int x, 
int y, 
Widget reciever, CargoContainer cargo )
 
 1062         EntityAI item_in_hands = 
GetGame().GetPlayer().GetHumanInventory().GetEntityInHands();
 
 1067         EntityAI item = GetItemPreviewItem( w );
 
 1068         if( !item || !item_in_hands )
 
 1077         if( item_in_hands.GetInventory().GetCargo() )
 
 1079             c_x = item_in_hands.GetInventory().GetCargo().GetHeight();
 
 1080             c_y = item_in_hands.GetInventory().GetCargo().GetWidth();
 
 1083         if( c_x > 
x && c_y > 
y && item_in_hands.GetInventory().CanAddEntityInCargoEx( item, 0, 
x, 
y, item.GetInventory().GetFlipCargo() ) )
 
 1086             ItemManager.GetInstance().GetCenterDropzone().SetAlpha( 1 );
 
 1092             ItemManager.GetInstance().ShowSourceDropzone( item );
 
 1095         if( w.FindAnyWidget(
"Cursor") )
 
 1097             w.FindAnyWidget(
"Cursor").SetColor( color );
 
 1101             string name = w.GetName();
 
 1102             name.Replace( 
"PanelWidget", 
"Cursor" );
 
 1103             w.FindAnyWidget( 
name ).SetColor( color );
 
 1116         receiver.GetUserData(slots_icon);
 
 1119             receiver_item   = slots_icon.GetEntity();
 
 1120             slot_id         = slots_icon.GetSlotID();
 
 1121             slot_owner      = slots_icon.GetSlotParent();
 
 1124         EntityAI item = GetItemPreviewItem( w );
 
 1131         float stack_max = item_base.GetTargetQuantityMax(slot_id);
 
 1134         if( !item.GetInventory().CanRemoveEntity() || !player.CanManipulateInventory() )
 
 1142             if( player.GetWeaponManager().CanAttachMagazine( wpn, mag ) )
 
 1144                 player.GetWeaponManager().AttachMagazine( mag );
 
 1146             else if(player.GetWeaponManager().CanSwapMagazine( wpn, mag ))
 
 1148                 player.GetWeaponManager().SwapMagazine( mag );
 
 1151         else if( receiver_item )
 
 1153             if( receiver_item != item )
 
 1155                 if( ( 
ItemBase.Cast( receiver_item ) ).CanBeCombined( 
ItemBase.Cast( item ) ) )
 
 1159                 else if( 
GameInventory.CanSwapEntitiesEx( receiver_item, item ) )
 
 1161                     if( !receiver_item.GetInventory().CanRemoveEntity() )
 
 1163                     GetGame().GetPlayer().PredictiveSwapEntities( item, receiver_item );
 
 1167         else if( slot_owner && slot_owner.GetInventory().CanAddAttachmentEx( item, slot_id ) )
 
 1169             if( stack_max == 0 || stack_max >= item_base.GetQuantity() )
 
 1171                 player.PredictiveTakeEntityToTargetAttachmentEx(slot_owner, item, slot_id);
 
 1173             else if( stack_max != 0 && stack_max < item_base.GetQuantity() )
 
 1175                 item_base.SplitIntoStackMaxClient( 
m_Entity, slot_id );
 
 1178         else if( slot_owner && slot_owner.GetInventory().CanAddAttachment( item ) )
 
 1180             if( stack_max == 0 || stack_max >= item_base.GetQuantity() )
 
 1182                 player.PredictiveTakeEntityToTargetAttachment(slot_owner, item);
 
 1184             else if( stack_max != 0 && stack_max < item_base.GetQuantity() )
 
 1186                 item_base.SplitIntoStackMaxClient( 
m_Entity, -1 );
 
 1189         else if( 
m_Entity.GetInventory().CanAddAttachment( item ) )
 
 1191             if( stack_max == 0 || stack_max >= item_base.GetQuantity() )
 
 1193                 player.PredictiveTakeEntityToTargetAttachment(
m_Entity, item);
 
 1195             else if( stack_max != 0 && stack_max < item_base.GetQuantity() )
 
 1197                 item_base.SplitIntoStackMaxClient( 
m_Entity, -1 );
 
 1200         else if( ( 
m_Entity.GetInventory().CanAddEntityInCargo( item, item.GetInventory().GetFlipCargo() ) && ( !player.GetInventory().HasEntityInInventory( item ) || !
m_Entity.GetInventory().HasEntityInCargo( item )) ) || player.GetHumanInventory().HasEntityInHands( item ) )
 
 1216         m_StaticCargoCount = 0;
 
 1219         if( entity.GetSlotsCountCorrect() > 0 )
 
 1222             m_Atts.InitAttachmentGrid( 1 );
 
 1223             m_AttachmentSlotsSorted = m_Atts.GetSlotsSorted();
 
 1224             m_StaticAttCount = m_Atts.GetAttachmentHeight();
 
 1225             m_Entity.GetOnItemAttached().Insert( AttachmentAdded );
 
 1226             m_Entity.GetOnItemDetached().Insert( AttachmentRemoved );
 
 1230             m_StaticAttCount = 0;
 
 1233         if( entity.GetInventory().GetCargo() )
 
 1235             m_CargoGrid = 
new CargoContainer( 
this, 
false );
 
 1236             m_CargoGrid.SetEntity( entity );
 
 1237             m_CargoGrid.GetRootWidget().SetSort( 1 );
 
 1238             Insert( m_CargoGrid );
 
 1239             m_StaticCargoCount++;
 
 1242         if (m_AttachmentSlotsSorted)
 
 1244             foreach( 
int slot_id : m_AttachmentSlotsSorted )
 
 1254             bool hideCargo = 
m_Entity.GetInventory().IsInventoryLockedForLockType( HIDE_INV_FROM_SCRIPT ) || !
m_Entity.CanDisplayCargo() || m_ForcedHide;
 
 1255             if (m_CargoGrid.IsVisible() && hideCargo)
 
 1259             else if (!m_CargoGrid.IsVisible() && !hideCargo)
 
 1265         m_CollapsibleHeader.ShowCollapseButtons(
false);
 
 1267         RecomputeOpenedContainers();
 
 1274         for (
int i = 0; i < m_Body.Count(); i++)
 
 1276             m_Body.Get( i ).OnShow();
 
 1287         CargoContainer cont = 
null;
 
 1289         if( item.GetInventory().GetAttachmentSlotsCount() > 0  )
 
 1292             sort = (m_AttachmentSlotsSorted.Find( slot_id ) * 2) + SORT_ATTACHMENTS_NEXT_OFFSET;
 
 1293             att_cont.InitAttachmentGrid( sort );
 
 1295             m_AttachmentAttachments.Insert( item, att_cont );
 
 1296             m_AttachmentAttachmentsContainers.Insert( item, att_cont.GetWrapper() );
 
 1298             att_cont.UpdateInterval();
 
 1301             Inventory.GetInstance().UpdateConsoleToolbar();
 
 1304         if( item.GetInventory().GetCargo() )
 
 1306             cont = 
new CargoContainer( 
this, 
true );
 
 1307             sort = (m_AttachmentSlotsSorted.Find( slot_id ) * 2) + SORT_CARGO_NEXT_OFFSET; 
 
 1308             cont.GetRootWidget().SetSort( sort );
 
 1309             cont.SetEntity( item );
 
 1313             m_AttachmentCargos.Insert( item, cont );
 
 1316             Inventory.GetInstance().UpdateConsoleToolbar();
 
 1321             att_cont.ShowFalseAttachmentsHeader(
true);
 
 1324                 cont.ShowFalseCargoHeader(
false);
 
 1326                 cont.SetAlternateFalseTextHeaderWidget(att_cont.GetFalseHeaderTextWidget());
 
 1331             cont.SetAlternateFalseTextHeaderWidget(
null); 
 
 1334         RecomputeOpenedContainers();
 
 1341         CargoContainer old_cont = m_AttachmentCargos.Get( item );
 
 1344             m_Body.RemoveItem( old_cont );
 
 1345             m_AttachmentCargos.Remove( item );
 
 1349             Inventory.GetInstance().UpdateConsoleToolbar();
 
 1355             m_AttachmentAttachmentsContainers.Remove( item );
 
 1356             m_AttachmentAttachments.Remove( item );
 
 1357             m_Body.RemoveItem( old_att_cont );
 
 1358             delete old_att_cont;
 
 1361             Inventory.GetInstance().UpdateConsoleToolbar();
 
 1363         RecomputeOpenedContainers();
 
 1366     override void UpdateInterval()
 
 1368         super.UpdateInterval();
 
 1374                 bool hideCargo = 
m_Entity.GetInventory().IsInventoryLockedForLockType( HIDE_INV_FROM_SCRIPT ) || !
m_Entity.CanDisplayCargo() || m_ForcedHide;
 
 1375                 if (m_CargoGrid.IsVisible() && hideCargo)
 
 1379                 else if (!m_CargoGrid.IsVisible() && !hideCargo)
 
 1384                 m_CargoGrid.UpdateInterval();
 
 1389                 m_Atts.UpdateInterval();
 
 1392             for ( 
int i = 0; i < m_AttachmentCargos.Count(); i++ )
 
 1394                 m_AttachmentCargos.GetElement( i ).UpdateInterval();
 
 1399         m_CollapsibleHeader.UpdateInterval();
 
 1402     override void SetLayoutName()
 
 1407     override void OnShow()
 
 1411         for ( 
int i = 0; i < m_Body.Count(); i++ )
 
 1413             m_Body.Get( i ).OnShow();
 
 1417     void MouseClick2(
Widget w, 
int x, 
int y, 
int button)
 
 1419         string name = w.GetName();
 
 1420         name.Replace(
"PanelWidget", 
"Render");
 
 1432                         #ifdef DIAG_DEVELOPER 
 1433                         if (
g_Game.IsLeftCtrlDown())
 
 1434                             ShowActionMenu(selectedItem);
 
 1440                         InspectItem(selectedItem);
 
 1445                         if (
g_Game.IsLeftCtrlDown())
 
 1447                             if (controlledPlayer.CanDropEntity(selectedItem))
 
 1449                                 if (selectedItem.GetTargetQuantityMax() < selectedItem.GetQuantity())
 
 1450                                     selectedItem.SplitIntoStackMaxClient(
null, -1);
 
 1452                                     controlledPlayer.PhysicalPredictiveDropItem(selectedItem);
 
 1456                                 bool draggable = !controlledPlayer.GetInventory().HasInventoryReservation(selectedItem, 
null ) && !controlledPlayer.GetInventory().IsInventoryLocked() && selectedItem.GetInventory().CanRemoveEntity() && !controlledPlayer.IsItemsToDelete();
 
 1457                                 ItemManager.GetInstance().SetWidgetDraggable(w, draggable);
 
 1467     void DoubleClick(
Widget w, 
int x, 
int y, 
int button)
 
 1474               string name = w.GetName();
 
 1475               name.Replace(
"PanelWidget", 
"Render");
 
 1486                 EntityAI itemInHands = controlledPlayer.GetHumanInventory().GetEntityInHands();
 
 1488                 if (!item.GetInventory().CanRemoveEntity())
 
 1491                 if (controlledPlayer.GetInventory().HasEntityInInventory(item) && controlledPlayer.GetHumanInventory().CanAddEntityInHands(item))
 
 1493                     controlledPlayer.PredictiveTakeEntityToHands(item);
 
 1497                     if (controlledPlayer.GetInventory().CanAddEntityToInventory(item) && controlledPlayer.GetHumanInventory().CanRemoveEntityInHands())
 
 1503                         if (controlledPlayer.GetHumanInventory().CanAddEntityInHands(item))
 
 1504                             controlledPlayer.PredictiveTakeEntityToHands(item);
 
 1511                 name.Replace(
"PanelWidget", 
"Temperature");
 
 1512                 w.FindAnyWidget(
name).Show(
false);
 
 1517     void DraggingOverHeader2(
Widget w, 
int x, 
int y, 
Widget receiver )
 
 1519         DraggingOverHeader(w, 
x, 
y, receiver );
 
 1522     void ElectricityIcon()
 
 1524         EntityAI item_in_hands = 
GetGame().GetPlayer().GetHumanInventory().GetEntityInHands();
 
 1525         if( item_in_hands && item_in_hands.GetCompEM() )
 
 1529                 bool show_electricity_icon = item_in_hands.GetCompEM().HasElectricityIcon();
 
 1530                 GetRootWidget().FindAnyWidget( 
"electricity" ).Show( show_electricity_icon );
 
 1533             if( GetRootWidget().
FindAnyWidget( 
"electricity_can_work" ) )
 
 1535                 bool show_electricity_can_work_icon = item_in_hands.GetCompEM().CanWork() && !item_in_hands.IsRuined();
 
 1536                 GetRootWidget().FindAnyWidget( 
"electricity_can_work" ).Show( show_electricity_can_work_icon );
 
 1541             GetRootWidget().FindAnyWidget( 
"electricity" ).Show( 
false );
 
 1545     void CollapseButtonOnMouseButtonDown( 
Widget w )
 
 1550             for (i = 0; i < m_Body.Count(); i++)
 
 1552                 m_Body.Get( i ).OnHide();
 
 1558             for (i = 0; i < m_Body.Count(); i++)
 
 1560                 m_Body.Get( i ).OnShow();
 
 1565         w.FindAnyWidget(
"opened").Show(m_Hidden);
 
 1566         w.FindAnyWidget(
"closed").Show(!m_Hidden);
 
 1575             m_CargoGrid.OnHide();
 
 1576             RecomputeOpenedContainers();
 
 1584             m_CargoGrid.OnShow();
 
 1585             RecomputeOpenedContainers();