44 int currentIndex = -1;
51 currentIndex = m_Body.Insert(
m_Atts.GetWrapper());
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);
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() )
142 att_cont.InitAttachmentGrid( sort );
143 att_cont.SetAttachmentSlotID(slot_id);
148 att_cont.UpdateInterval();
151 if ( item.GetInventory().GetCargo() )
155 cont =
new CargoContainer(
this,
true );
157 cont.GetRootWidget().SetSort( sort );
158 cont.SetEntity( item,
false );
159 cont.SetAttachmentSlotID(slot_id);
169 att_cont.ShowFalseAttachmentsHeader(
true);
172 cont.ShowFalseCargoHeader(
false);
174 cont.SetAlternateFalseTextHeaderWidget(att_cont.GetFalseHeaderTextWidget());
179 cont.SetAlternateFalseTextHeaderWidget(null);
184 RecomputeOpenedContainers();
186 Inventory.GetInstance().UpdateConsoleToolbar();
210 Inventory.GetInstance().UpdateConsoleToolbar();
223 Inventory.GetInstance().UpdateConsoleToolbar();
227 RecomputeOpenedContainers();
236 bool hideCargo =
m_Entity.GetInventory().IsInventoryLockedForLockType( HIDE_INV_FROM_SCRIPT ) || !
m_Entity.CanDisplayCargo() || m_ForcedHide;
256 m_SlotIcon.GetRadialIconPanel().Show( !hide );
260 super.UpdateInterval();
295 return m_ActiveIndex == ( m_OpenedContainers.Count() - 1 );
300 return IsFirstIndex();
313 c.MoveGridCursor( direction );
314 Inventory.GetInstance().UpdateConsoleToolbar();
323 m_Atts.InitAttachmentGrid( SORT_ATTACHMENTS_OWN );
329 m_ClosableHeader.SetItemPreview(
m_Entity );
330 CheckHeaderDragability();
332 if (
m_Entity.GetInventory().GetCargo() )
335 m_CargoGrid.GetRootWidget().SetSort( SORT_CARGO_OWN );
344 m_ClosableHeader.SetName(
name );
364 bool hideCargo =
m_Entity.GetInventory().IsInventoryLockedForLockType( HIDE_INV_FROM_SCRIPT ) || !
m_Entity.CanDisplayCargo() || m_ForcedHide;
376 SetOpenState(
true );
378 SetOpenState(
false );
383 RecomputeOpenedContainers();
393 RecomputeOpenedContainers();
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 g_Game.GetPlayer().GetHumanInventory().ClearUserReservedLocationSynced(selectedItem);
483 attachmentParent.GetOnAttachmentReleaseLock().Invoke(selectedItem, icon.
GetSlotID());
485 else if (CanSplitEx(selectedItem))
487 selectedItem.OnRightClick();
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();
531 #ifndef PLATFORM_CONSOLE
545 targetCargo = targetEntity.GetInventory().GetCargo();
546 #ifdef PLATFORM_CONSOLE
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);
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 g_Game.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 ) )
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 );
784 target_cargo =
m_Entity.GetInventory().GetCargo();
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() ) )
808 if( target_entity.GetHierarchyRootPlayer() ==
g_Game.GetPlayer() )
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 );
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 ) )
927 if( receiver_itemIB.GetHierarchyRootPlayer() ==
g_Game.GetPlayer() )
938 else if( attached_entity && attached_entity.GetInventory().CanAddAttachmentEx( item, slot_id ) )
941 if( attached_entity.GetHierarchyRootPlayer() ==
g_Game.GetPlayer() )
951 else if(
m_Entity.GetInventory().CanAddAttachment( item ) )
964 else if( (
m_Entity.GetInventory().CanAddEntityInCargo( item, item.GetInventory().GetFlipCargo() ) && !
m_Entity.GetInventory().HasEntityInCargo( item ) ) )
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
override bool InspectItem()
ref map< EntityAI, ref AttachmentsWrapper > m_AttachmentAttachmentsContainers
void AttachmentAdded(EntityAI item, string slot, EntityAI parent)
void ContainerWithCargoAndAttachments(LayoutHolder parent, int sort=-1)
ref CargoContainer m_CargoGrid
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.
override bool IsDisplayable()
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.
FindInventoryLocationType
flags for searching locations in inventory