4 protected ref CargoContainer m_CargoGrid;
20 m_Entity.GetOnItemAttached().Remove( AttachmentAdded );
21 m_Entity.GetOnItemDetached().Remove( AttachmentRemoved );
32 if ( m_AttachmentAttachments )
33 m_AttachmentAttachments.Clear();
35 if ( m_AttachmentAttachmentsContainers )
36 m_AttachmentAttachmentsContainers.Clear();
38 if ( m_AttachmentCargos )
39 m_AttachmentCargos.Clear();
44 int currentIndex = -1;
51 currentIndex = m_Body.Insert(m_Atts.GetWrapper());
56 currentIndex = m_Body.Insert(m_CargoGrid);
70 if(m_Atts && m_Atts.GetSlotsSorted().Count())
75 if(bodyAttachmentSortIndex.Find(currentIndex, slotIndex))
77 if(slotIndex > sortIndex)
79 m_Body.InsertAt(att, currentIndex);
80 bodyAttachmentSortIndex.Set(currentIndex, sortIndex);
84 currentIndex = m_Body.Insert(att);
85 bodyAttachmentSortIndex.Insert(currentIndex, sortIndex);
90 currentIndex = m_Body.Insert(att);
91 bodyAttachmentSortIndex.Insert(currentIndex, sortIndex);
95 CargoContainer cargo = m_AttachmentCargos.Get(ent);
98 if(m_Atts && m_Atts.GetSlotsSorted().Count())
100 sortIndex = m_Atts.GetSlotsSorted().Find(cargo.GetAttachmentSlotID());
103 if (bodyAttachmentSortIndex.Find(currentIndex, slotIndex))
105 if(slotIndex > sortIndex)
107 m_Body.InsertAt(cargo, currentIndex);
108 bodyAttachmentSortIndex.Set(currentIndex, sortIndex);
112 currentIndex = m_Body.Insert(cargo);
113 bodyAttachmentSortIndex.Insert(currentIndex, sortIndex);
118 currentIndex = m_Body.Insert(cargo);
119 bodyAttachmentSortIndex.Insert(currentIndex, sortIndex);
125 bodyAttachmentSortIndex.Clear();
132 bool updateNeeded =
false;
134 ref CargoContainer cont = null;
136 if ( item.GetInventory().GetAttachmentSlotsCount() > 0 && item.CanDisplayAnyAttachmentSlot() )
141 sort = (m_AttachmentSlotsSorted.Find( slot_id ) * 2) + SORT_ATTACHMENTS_NEXT_OFFSET;
142 att_cont.InitAttachmentGrid( sort );
143 att_cont.SetAttachmentSlotID(slot_id);
145 m_AttachmentAttachments.Insert( item, att_cont );
146 m_AttachmentAttachmentsContainers.Insert( item, att_cont.GetWrapper() );
148 att_cont.UpdateInterval();
151 if ( item.GetInventory().GetCargo() )
155 cont =
new CargoContainer(
this,
true );
156 sort = (m_AttachmentSlotsSorted.Find( slot_id ) * 2) + SORT_CARGO_NEXT_OFFSET;
157 cont.GetRootWidget().SetSort( sort );
158 cont.SetEntity( item,
false );
159 cont.SetAttachmentSlotID(slot_id);
160 Insert( cont, m_Atts.GetAttachmentHeight() + m_AttachmentCargos.Count() + 1 );
162 m_AttachmentCargos.Insert( item, cont );
169 att_cont.ShowFalseAttachmentsHeader(
true);
172 cont.ShowFalseCargoHeader(
false);
174 cont.SetAlternateFalseTextHeaderWidget(att_cont.GetFalseHeaderTextWidget());
179 cont.SetAlternateFalseTextHeaderWidget(null);
183 RecomputeContainers();
184 RecomputeOpenedContainers();
186 Inventory.GetInstance().UpdateConsoleToolbar();
195 AttachmentAddedEx(item, slot, parent);
202 CargoContainer old_cont = m_AttachmentCargos.Get( item );
205 m_AttachmentCargos.Remove( item );
210 Inventory.GetInstance().UpdateConsoleToolbar();
217 m_AttachmentAttachmentsContainers.Remove( item );
218 m_AttachmentAttachments.Remove( item );
223 Inventory.GetInstance().UpdateConsoleToolbar();
226 RecomputeContainers();
227 RecomputeOpenedContainers();
236 bool hideCargo =
m_Entity.GetInventory().IsInventoryLockedForLockType( HIDE_INV_FROM_SCRIPT ) || !
m_Entity.CanDisplayCargo() || m_ForcedHide;
237 if (m_CargoGrid.IsVisible() && hideCargo)
241 else if (!m_CargoGrid.IsVisible() && !hideCargo)
246 m_CargoGrid.UpdateInterval();
256 m_SlotIcon.GetRadialIconPanel().Show( !hide );
260 super.UpdateInterval();
278 m_CargoGrid.UnfocusAll();
281 foreach(
EntityAI e1, CargoContainer cargo : m_AttachmentCargos )
295 return m_ActiveIndex == ( m_OpenedContainers.Count() - 1 );
300 return IsFirstIndex();
305 return IsLastIndex();
313 c.MoveGridCursor( direction );
314 Inventory.GetInstance().UpdateConsoleToolbar();
323 m_Atts.InitAttachmentGrid( SORT_ATTACHMENTS_OWN );
324 m_AttachmentSlotsSorted = m_Atts.GetSlotsSorted();
326 m_Entity.GetOnItemAttached().Insert( AttachmentAdded );
327 m_Entity.GetOnItemDetached().Insert( AttachmentRemoved );
329 m_ClosableHeader.SetItemPreview(
m_Entity );
330 CheckHeaderDragability();
332 if (
m_Entity.GetInventory().GetCargo() )
334 m_CargoGrid =
new CargoContainer(
this,
false );
335 m_CargoGrid.GetRootWidget().SetSort( SORT_CARGO_OWN );
336 m_CargoGrid.SetEntity(
m_Entity, 0, immedUpdate );
337 m_CargoGrid.UpdateHeaderText();
338 Insert( m_CargoGrid );
344 m_ClosableHeader.SetName(
name );
353 foreach (
int slot_id : m_AttachmentSlotsSorted )
360 RecomputeContainers();
364 bool hideCargo =
m_Entity.GetInventory().IsInventoryLockedForLockType( HIDE_INV_FROM_SCRIPT ) || !
m_Entity.CanDisplayCargo() || m_ForcedHide;
365 if (m_CargoGrid.IsVisible() && hideCargo)
369 else if (!m_CargoGrid.IsVisible() && !hideCargo)
375 if( IsDisplayable() )
376 SetOpenState(
true );
378 SetOpenState(
false );
383 RecomputeOpenedContainers();
390 if(m_CargoGrid.IsVisible())
392 m_CargoGrid.OnHide();
393 RecomputeOpenedContainers();
402 if(!m_CargoGrid.IsVisible())
404 m_CargoGrid.OnShow();
405 RecomputeOpenedContainers();
417 string name = w.GetName();
418 name.Replace(
"PanelWidget",
"Render" );
427 string name = w.GetName();
428 name.Replace(
"PanelWidget",
"Render" );
439 return ipw.GetItem();
447 string name = w.GetName();
448 name.Replace(
"PanelWidget",
"Render" );
474 #ifdef DIAG_DEVELOPER
476 ShowActionMenu(selectedItem);
482 GetGame().GetPlayer().GetHumanInventory().ClearUserReservedLocationSynced(selectedItem);
483 attachmentParent.GetOnAttachmentReleaseLock().Invoke(selectedItem, icon.
GetSlotID());
485 else if (CanSplitEx(selectedItem))
487 selectedItem.OnRightClick();
494 InspectItem(selectedItem);
502 if (
g_Game.IsLeftCtrlDown())
504 if (controlledPlayer.CanDropEntity(selectedItem))
506 if (selectedItem.CanBeSplit() && selectedItem.GetTargetQuantityMax() < selectedItem.GetQuantity())
507 selectedItem.SplitIntoStackMaxClient(null, -1);
509 controlledPlayer.PhysicalPredictiveDropItem(selectedItem);
514 bool draggable = !controlledPlayer.GetInventory().HasInventoryReservation(selectedItem, null ) && !controlledPlayer.GetInventory().IsInventoryLocked() && selectedItem.GetInventory().CanRemoveEntity() && !controlledPlayer.IsItemsToDelete();
527 EntityAI item = GetItemPreviewItem(w);
531 #ifndef PLATFORM_CONSOLE
538 if (cargo != m_CargoGrid)
540 targetEntity = m_AttachmentCargos.GetKeyByValue(cargo);
545 targetCargo = targetEntity.GetInventory().GetCargo();
546 #ifdef PLATFORM_CONSOLE
547 if (m_CargoGrid && m_CargoGrid.HasItem(item))
552 if (!targetCargo || !targetEntity)
556 #ifdef PLATFORM_CONSOLE
558 y = targetCargo.GetItemCount();
561 c_x = targetCargo.GetHeight();
562 c_y = targetCargo.GetWidth();
564 dst.SetCargoAuto(targetCargo, item,
x,
y, item.GetInventory().GetFlipCargo());
568 item.GetInventory().GetCurrentInventoryLocation(src);
569 if (src.CompareLocationOnly(dst) && src.GetFlip() == dst.GetFlip())
572 #ifdef PLATFORM_CONSOLE
573 if (dst.IsValid() && targetEntity.GetInventory().LocationCanAddEntity(dst))
575 if (c_x >
x && c_y >
y && targetEntity.GetInventory().LocationCanAddEntity(dst))
582 Icon icon = cargo.GetIcon(item);
585 if (w && w.FindAnyWidget(
"Cursor"))
586 w.FindAnyWidget(
"Cursor").SetColor(
ColorManager.BASE_COLOR);
604 bool is_reserved =
false;
606 receiver.GetUserData(slots_icon);
619 EntityAI item = GetItemPreviewItem( w );
629 if( !item.GetInventory().CanRemoveEntity() || !player.CanManipulateInventory() )
637 if( player.GetWeaponManager().CanAttachMagazine( wpn, mag ) )
639 player.GetWeaponManager().AttachMagazine( mag );
642 else if( receiver_item && !is_reserved )
644 if( (
ItemBase.Cast( receiver_item ) ).CanBeCombined(
ItemBase.Cast( item ) ) )
646 (
ItemBase.Cast( receiver_item ) ).CombineItemsClient(
ItemBase.Cast( item ) );
650 if( !receiver_item.GetInventory().CanRemoveEntity() )
652 GetGame().GetPlayer().PredictiveSwapEntities( receiver_item, item );
654 else if( receiver_item.GetInventory().CanAddAttachment( item ) )
656 player.PredictiveTakeEntityToTargetAttachment(receiver_item, item);
659 else if( attached_entity && attached_entity.GetInventory().CanAddAttachmentEx( item, slot_id ) )
661 player.PredictiveTakeEntityToTargetAttachmentEx(attached_entity, item, slot_id);
663 else if(attached_entity && attached_entity.GetInventory().CanAddAttachment(item))
666 player.PredictiveTakeEntityToTargetAttachmentEx(attached_entity, item, il.GetSlot());
668 else if(
m_Entity.GetInventory().CanAddAttachment(item) )
671 player.PredictiveTakeEntityToTargetAttachmentEx(
m_Entity, item, il.GetSlot());
673 else if(
m_Entity.GetInventory().CanAddEntityInCargo( item, item.GetInventory().GetFlipCargo() ) && !
m_Entity.GetInventory().HasEntityInCargo( item ) )
685 TakeAsAttachment( w, receiver );
690 TakeAsAttachment( w, receiver );
698 if( w == NULL || player.GetInventory().IsInventoryLocked() )
705 string name = w.GetName();
706 name.Replace(
"PanelWidget",
"Render" );
723 iw.GetUserData(icon);
730 if( !item.GetInventory().CanRemoveEntity() || !player.CanManipulateInventory() )
733 if( player.GetInventory().HasEntityInInventory( item ) && player.GetHumanInventory().CanAddEntityInHands( item ) )
735 player.PredictiveTakeEntityToHands( item );
739 if(player.GetInventory().CanAddEntityToInventory( item ) && item.GetInventory().CanRemoveEntity())
745 if( player.GetHumanInventory().CanAddEntityInHands( item ) )
747 player.PredictiveTakeEntityToHands( item );
755 name.Replace(
"PanelWidget",
"Temperature" );
756 w.FindAnyWidget(
name ).Show(
false );
767 EntityAI item = GetItemPreviewItem( w );
781 if( cargo == m_CargoGrid )
784 target_cargo =
m_Entity.GetInventory().GetCargo();
788 target_entity = m_AttachmentCargos.GetKeyByValue( cargo );
791 target_cargo = target_entity.GetInventory().GetCargo();
797 if( target_cargo && target_entity )
799 c_x = target_cargo.GetHeight();
800 c_y = target_cargo.GetWidth();
805 if( c_x >
x && c_y >
y && target_entity.GetInventory().CanAddEntityInCargoEx( item, idx,
x,
y, item.GetInventory().GetFlipCargo() ) )
822 if( w.FindAnyWidget(
"Cursor") )
824 w.FindAnyWidget(
"Cursor").SetColor( color );
828 string name = w.GetName();
829 name.Replace(
"PanelWidget",
"Cursor" );
830 if( w.FindAnyWidget(
name ) )
832 w.FindAnyWidget(
name ).SetColor( color );
841 DraggingOverHeader( w,
x,
y, receiver );
850 EntityAI item = GetItemPreviewItem( w );
857 receiver.GetUserData(slots_icon);
861 bool is_reserved =
false;
880 if( player.GetWeaponManager().CanAttachMagazine( wpn, mag ) )
894 else if( receiver_item && !is_reserved )
898 if( receiver_itemIB && itemIB && receiver_itemIB.CanBeCombined( itemIB ) )
924 else if( receiver_itemIB.GetInventory().CanAddAttachment( item ) )
938 else if( attached_entity && attached_entity.GetInventory().CanAddAttachmentEx( item, slot_id ) )
951 else if(
m_Entity.GetInventory().CanAddAttachment( item ) )
964 else if( (
m_Entity.GetInventory().CanAddEntityInCargo( item, item.GetInventory().GetFlipCargo() ) && !
m_Entity.GetInventory().HasEntityInCargo( item ) ) )
992 return m_AttachmentCargos;
997 return m_AttachmentAttachmentsContainers;
void Inventory(LayoutHolder parent)
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
int GetAttachmentSlotID()
represents base for cargo storage for entities
Super root of all classes in Enforce script.
Widget GetItemPreviewWidget(Widget w)
ref map< EntityAI, ref CargoContainer > m_AttachmentCargos
void TakeAsAttachment(Widget w, Widget receiver)
void AttachmentAddedEx(EntityAI item, string slot, EntityAI parent, bool immedUpdate=true)
override bool IsFirstContainerFocused()
void DoubleClick(Widget w, int x, int y, int button)
override void DraggingOverHeader(Widget w, int x, int y, Widget receiver)
override bool IsLastContainerFocused()
void AttachmentRemoved(EntityAI item, string slot, EntityAI parent)
void RecomputeContainers()
void OnDropReceivedFromHeader2(Widget w, int x, int y, Widget receiver)
override void DraggingOver(Widget w, int x, int y, Widget receiver)
ref map< EntityAI, ref Attachments > m_AttachmentAttachments
ref map< EntityAI, ref AttachmentsWrapper > m_AttachmentAttachmentsContainers
void AttachmentAdded(EntityAI item, string slot, EntityAI parent)
void ContainerWithCargoAndAttachments(LayoutHolder parent, int sort=-1)
map< EntityAI, ref AttachmentsWrapper > GetAttachmentAttachmentsContainers()
override bool IsLastIndex()
override void UpdateInterval()
override void MoveGridCursor(int direction)
map< EntityAI, ref CargoContainer > GetAttachmentCargos()
void MouseClick2(Widget w, int x, int y, int button)
bool DraggingOverGrid(Widget w, int x, int y, Widget reciever, CargoContainer cargo)
CargoContainer GetCargo()
void ~ContainerWithCargoAndAttachments()
ItemPreviewWidget GetItemPreviewWidgetDragOrDrop(Widget w)
EntityAI GetItemPreviewItem(Widget w)
ref array< int > m_AttachmentSlotsSorted
override EntityAI GetFocusedContainerEntity()
override void OnDropReceivedFromHeader(Widget w, int x, int y, Widget receiver)
override void UnfocusAll()
void SetEntity(EntityAI entity, bool immedUpdate=true)
void DropReceived(Widget w, int x, int y, CargoContainer cargo)
NOTE Used for mouse only.
script counterpart to engine's class Inventory
proto native EntityAI GetAttachmentFromIndex(int index)
static bool CanSwapEntitiesEx(notnull EntityAI item1, notnull EntityAI item2)
proto native int AttachmentCount()
Returns count of attachments attached to this item.
provides access to slot configuration
EntityAI GetDraggedItem()
void ShowSourceDropzone(EntityAI item)
Widget GetRightDropzone()
void SetWidgetDraggable(Widget w, bool draggable)
void SetIsDragging(bool is_dragging)
static ItemManager GetInstance()
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
FindInventoryLocationType
flags for searching locations in inventory