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" );
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
564 dst.
SetCargoAuto(targetCargo, item,
x,
y, item.GetInventory().GetFlipCargo());
568 item.GetInventory().GetCurrentInventoryLocation(src);
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"))
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 )
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()
Attachments m_Attachments
represents base for cargo storage for entities
proto native int GetWidth()
proto native int GetItemCount()
proto native int GetHeight()
Super root of all classes in Enforce script.
override void UnfocusAll()
override void DraggingOver(Widget w, int x, int y, Widget receiver)
override EntityAI GetFocusedContainerEntity()
void TakeAsAttachment(Widget w, Widget receiver)
override bool InspectItem()
void DropReceived(Widget w, int x, int y, CargoContainer cargo)
NOTE Used for mouse only.
ItemPreviewWidget GetItemPreviewWidgetDragOrDrop(Widget w)
CargoContainer GetCargo()
ref array< int > m_AttachmentSlotsSorted
void RecomputeContainers()
override void UpdateInterval()
override bool IsLastContainerFocused()
void AttachmentAdded(EntityAI item, string slot, EntityAI parent)
Widget GetItemPreviewWidget(Widget w)
override void OnDropReceivedFromHeader(Widget w, int x, int y, Widget receiver)
EntityAI GetItemPreviewItem(Widget w)
override void MoveGridCursor(int direction)
void ~ContainerWithCargoAndAttachments()
void DoubleClick(Widget w, int x, int y, int button)
override bool IsLastIndex()
ref map< EntityAI, ref Attachments > m_AttachmentAttachments
override void DraggingOverHeader(Widget w, int x, int y, Widget receiver)
map< EntityAI, ref CargoContainer > GetAttachmentCargos()
void ContainerWithCargoAndAttachments(LayoutHolder parent, int sort=-1)
override bool IsFirstContainerFocused()
void MouseClick2(Widget w, int x, int y, int button)
ref CargoContainer m_CargoGrid
void AttachmentRemoved(EntityAI item, string slot, EntityAI parent)
ref map< EntityAI, ref CargoContainer > m_AttachmentCargos
bool DraggingOverGrid(Widget w, int x, int y, Widget reciever, CargoContainer cargo)
map< EntityAI, ref AttachmentsWrapper > GetAttachmentAttachmentsContainers()
ref map< EntityAI, ref AttachmentsWrapper > m_AttachmentAttachmentsContainers
void OnDropReceivedFromHeader2(Widget w, int x, int y, Widget receiver)
override bool IsDisplayable()
void SetEntity(EntityAI entity, bool immedUpdate=true)
void AttachmentAddedEx(EntityAI item, string slot, EntityAI parent, bool immedUpdate=true)
static ColorManager GetInstance()
void SetColor(Widget w, int color)
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.
proto native int GetSlot()
returns slot id if current type is Attachment
proto native bool GetFlip()
returns flip status of cargo
proto native bool IsValid()
verify current set inventory location
proto native void SetCargoAuto(notnull CargoBase cargo, EntityAI e, int row, int col, bool flip)
proto native bool CompareLocationOnly(notnull InventoryLocation other)
provides access to slot configuration
static proto native owned string GetSlotName(int id)
static proto native int GetSlotIdFromString(string slot_name)
override bool CanBeSplit()
override bool CanBeCombined(EntityAI other_item, bool reservation_check=true, bool stack_max_limit=false)
void ShowSourceDropzone(EntityAI item)
void SetWidgetDraggable(Widget w, bool draggable)
Widget GetRightDropzone()
void SetIsDragging(bool is_dragging)
static ItemManager GetInstance()
EntityAI GetDraggedItem()
static void TakeOrSplitToInventory(notnull PlayerBase player, notnull EntityAI target, notnull EntityAI item)
static void TakeOrSplitToInventoryLocation(notnull PlayerBase player, notnull InventoryLocation dst)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
FindInventoryLocationType
flags for searching locations in inventory