11 protected ref
array<int> m_AttachmentIDOrdered;
13 protected int m_RowIndex;
21 m_AttachmentSlotNames = GetItemSlots( entity );
23 m_Entity.GetOnItemAttached().Insert( AttachmentAdded );
24 m_Entity.GetOnItemDetached().Insert( AttachmentRemoved );
25 m_Entity.GetOnAttachmentSetLock().Insert( OnAttachmentReservationSet );
26 m_Entity.GetOnAttachmentReleaseLock().Insert( OnAttachmentReservationRelease );
34 m_Entity.GetOnItemAttached().Remove( AttachmentAdded );
35 m_Entity.GetOnItemDetached().Remove( AttachmentRemoved );
36 m_Entity.GetOnAttachmentSetLock().Remove( OnAttachmentReservationSet );
37 m_Entity.GetOnAttachmentReleaseLock().Remove( OnAttachmentReservationRelease );
40 delete m_AttachmentsContainer;
45 return m_AttachmentsContainer;
50 return m_AttachmentsContainer.IsEmpty();
63 bool IsItemWithQuantityActive()
75 m_AttachmentsContainer.UnfocusAll();
78 void SetDefaultFocus(
bool while_micromanagment_mode =
false )
80 m_AttachmentsContainer.SetDefaultFocus(while_micromanagment_mode);
85 m_AttachmentsContainer.SetLastActive();
88 void SetActive(
bool active )
90 m_AttachmentsContainer.SetActive(active);
95 m_AttachmentsContainer.SetFirstActive();
100 return m_AttachmentsContainer.GetFocusedSlotsIcon();
105 return m_AttachmentsContainer.GetFocusedItem();
110 SlotsIcon icon = m_AttachmentsContainer.GetFocusedSlotsIcon();
112 return icon.GetSlotID();
121 if (icon && !icon.IsOutOfReach())
123 if (item && item.CanPutIntoHands(
null))
125 ItemManager.GetInstance().SetSelectedItemEx(item,
null, icon);
129 ItemManager.GetInstance().SetSelectedItemEx(
null,
null, icon);
140 SlotsIcon focused_slot = GetFocusedSlotsIcon();
141 EntityAI focused_item = GetFocusedItem();
142 Man player =
GetGame().GetPlayer();
144 if( focused_slot.IsReserved() || focused_item != selected_item && !(selected_slot && selected_slot.IsOutOfReach() ) )
148 if( selected_item.GetInventory().CanRemoveEntity() )
150 if(
m_Entity.GetInventory().CanAddAttachmentEx( selected_item, focused_slot.GetSlotID() ) )
152 player.PredictiveTakeEntityToTargetAttachmentEx(
m_Entity, selected_item, focused_slot.GetSlotID() );
153 ItemManager.GetInstance().SetSelectedItemEx(
null,
null,
null);
157 else if(
m_Entity.GetInventory().CanAddAttachment( selected_item ) )
159 player.PredictiveTakeEntityToTargetAttachment(
m_Entity, selected_item);
160 ItemManager.GetInstance().SetSelectedItemEx(
null,
null,
null);
167 if ( focused_item && !focused_slot.IsOutOfReach() )
169 EntityAI item_in_hands =
GetGame().GetPlayer().GetHumanInventory().GetEntityInHands();
171 focused_item.GetInventory().GetCurrentInventoryLocation( il );
173 if( reachable && focused_item.GetInventory().CanRemoveEntity() )
175 if( item_in_hands && item_in_hands.GetInventory().CanRemoveEntity() )
177 if(
GameInventory.CanSwapEntitiesEx( item_in_hands, focused_item ) )
179 player.PredictiveSwapEntities( item_in_hands, focused_item );
185 if( player.GetHumanInventory().CanAddEntityInHands( focused_item ) )
187 player.PredictiveTakeEntityToHands( focused_item );
198 int GetRecipeCount(
bool recipe_anywhere,
EntityAI entity1,
EntityAI entity2 )
200 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(
GetPlugin( PluginRecipesManager ) );
209 return (
ItemManager.GetCombinationFlags( item_in_hands, ent ) != 0 );
212 bool CanCombineAmmo()
220 return ( amc.CanPerformActionFromInventory( item_in_hands, ent ) );
227 if( !entity || entity.IsInherited( Magazine ) )
238 Icon hands_icon =
ItemManager.GetInstance().GetHandsPreview().GetIcon();
240 if ( item_in_hands && ent && hands_icon )
242 return hands_icon.CombineItems( item_in_hands, ent );
251 if( entity && !entity.IsInherited( Magazine ) && !GetFocusedSlotsIcon().IsOutOfReach() )
253 if( entity.HasQuantity() )
255 entity.OnRightClick();
265 if( entity && !entity.IsInherited( Magazine ) && !GetFocusedSlotsIcon().IsOutOfReach() )
276 if( entity && !GetFocusedSlotsIcon().IsOutOfReach() )
295 bool TransferItemToVicinity()
299 if (item && !GetFocusedSlotsIcon().IsOutOfReach() )
301 if (item.GetTargetQuantityMax() < item.GetQuantity())
302 item.SplitIntoStackMaxClient(
null, -1 );
304 player.PhysicalPredictiveDropItem(item);
312 return m_Parent.GetMainWidget().FindAnyWidget(
"AttachmentsWrapper").GetAlpha() > 0;
315 int GetAttachmentHeight()
317 return m_AttachmentsContainer.Count();
320 void UpdateInterval()
324 m_AttachmentSlotDisplayable.Clear();
326 for (i = m_AttachmentSlotNames.Count() - 1; i >=0; --i)
328 slot_id =
InventorySlots.GetSlotIdFromString( m_AttachmentSlotNames[i] );
329 if (
m_Entity.CanDisplayAttachmentSlot(slot_id))
331 m_AttachmentSlotDisplayable.Insert(m_AttachmentSlotNames[i]);
338 icon.GetMainWidget().Show(
false );
339 if( GetFocusedSlotsIcon() == icon )
344 icon.UpdateInterval();
350 if ( m_AttachmentSlotDisplayable.Count() == 0 )
359 for (i = 0; i < m_AttachmentSlotDisplayable.Count(); ++i)
361 slot_id =
InventorySlots.GetSlotIdFromString( m_AttachmentSlotDisplayable[i] );
364 icon.GetMainWidget().Show(
true );
365 icon.UpdateInterval();
368 bool draggable =
true;
369 if(icon.IsReserved())
374 if(
m_Entity.GetInventory().GetSlotLock( slot_id ) &&
ItemManager.GetInstance().GetDraggedItem() != item )
376 icon.GetMountedWidget().Show(
true );
381 icon.GetMountedWidget().Show(
false );
385 bool in_hands_condition =
m_Entity.GetHierarchyRoot() && item.GetInventory().CanRemoveEntity();
387 if( in_hands_condition || in_vicinity_condition )
389 icon.GetOutOfReachWidget().Show(
false );
393 icon.GetOutOfReachWidget().Show(
true );
399 icon.GetPanelWidget().SetFlags(
WidgetFlags.DRAGGABLE );
403 icon.GetPanelWidget().ClearFlags(
WidgetFlags.DRAGGABLE );
407 m_AttachmentsContainer.GetRootWidget().Update();
412 return m_AttachmentIDOrdered;
421 icon.SetSlotID(slot_id);
422 icon.SetSlotDisplayName(
InventorySlots.GetSlotDisplayName(slot_id));
440 void OnAttachmentReservationSet(
EntityAI item,
int slot_id )
446 icon.Init( item,
true );
450 void OnAttachmentReservationRelease(
EntityAI item,
int slot_id )
457 void InitAttachmentGrid(
int att_row_index )
461 m_RowIndex = att_row_index;
463 int number_of_rows =
Math.Ceil( m_AttachmentSlotNames.Count() /
ITEMS_IN_ROW );
468 m_AttachmentsContainer.SetParent(
this );
469 m_AttachmentsContainer.SetFalseAttachmentsHeaderText(
name);
470 m_AttachmentsContainer.GetRootWidget().SetSort( att_row_index );
471 m_Parent.Insert( m_AttachmentsContainer, att_row_index );
473 for ( i = 0; i < number_of_rows; i++ )
476 m_AttachmentsContainer.Insert( ic );
478 if( i == ( number_of_rows - 1 ) && m_AttachmentSlotNames.Count() %
ITEMS_IN_ROW != 0 )
480 ic.SetColumnCount( m_AttachmentSlotNames.Count() %
ITEMS_IN_ROW );
489 icon = ic.GetSlotIcon( j );
504 for ( i = 0; i < m_AttachmentSlotNames.Count(); i++ )
509 string path =
"CfgSlots" +
" Slot_" + m_AttachmentSlotNames[i];
512 if ( m_AttachmentSlotNames[i] ==
"magazine" )
515 path =
"CfgSlots" +
" Slot_" +
"magazine2";
518 string icon_name =
"";
519 if(
GetGame().ConfigGetText(
path +
" ghostIcon", icon_name ) && icon_name !=
"" )
521 int slot_id =
InventorySlots.GetSlotIdFromString( m_AttachmentSlotNames[i] );
523 m_AttachmentIDOrdered.Insert(slot_id);
525 icon.SetSlotID(slot_id);
526 icon.SetSlotDisplayName(
InventorySlots.GetSlotDisplayName(slot_id));
530 AttachmentAdded( item, m_AttachmentSlotNames[i],
m_Entity );
534 if (
m_Entity.CanDisplayAttachmentSlot(slot_id))
536 icon.GetMainWidget().Show(
true );
540 icon.GetMainWidget().Show(
false );
544 if( m_AttachmentSlotNames.Count() > 0 )
546 int row_index = number_of_rows - 1;
552 row_last.GetSlotIcon( k ).GetMainWidget().Show(
false );
554 row_last.GetRootWidget().Update();
555 row_last.GetRootWidget().GetParent().Update();
559 m_AttachmentsContainer.RecomputeOpenedContainers();
571 for (
int s = 0; s < searching_in.Count(); ++s )
573 string cfg_name = searching_in.Get( s );
574 string path = cfg_name +
" " + e.GetType();
578 GetGame().ConfigGetTextArray(
path +
" attachments", attachments_slots );
579 if ( e.IsWeapon() && (!e.ConfigIsExisting(
"DisplayMagazine") || e.ConfigGetBool(
"DisplayMagazine")) )
581 attachments_slots.Insert(
"magazine" );
584 return attachments_slots;
587 if ( e.IsWeapon() && (!e.ConfigIsExisting(
"DisplayMagazine") || e.ConfigGetBool(
"DisplayMagazine")) )
589 attachments_slots.Insert(
"magazine" );
592 return attachments_slots;
595 void ShowFalseAttachmentsHeader(
bool show)
597 m_AttachmentsContainer.ShowFalseAttachmentsHeader(show);
600 void SetFalseAttachmentsHeaderText(
string text)
602 m_AttachmentsContainer.SetFalseAttachmentsHeaderText(text);
607 return m_AttachmentsContainer.GetFalseHeaderTextWidget();