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 GetGame().
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() )
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() ) )
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 ) )
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 ) ) )
void Inventory(LayoutHolder parent)
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
FindInventoryLocationType
flags for searching locations in inventory
int GetAttachmentSlotID()
Attachments m_Attachments
proto native DayZPlayer GetPlayer()
proto native int GetItemCount()
proto native int GetWidth()
proto native int GetHeight()
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()
void SetColor(Widget w, int color)
static ColorManager GetInstance()
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.
script counterpart to engine's class Inventory
proto native bool IsValid()
verify current set inventory location
proto native int GetSlot()
returns slot id if current type is Attachment
proto native void SetCargoAuto(notnull CargoBase cargo, EntityAI e, int row, int col, bool flip)
based on Cargo.IsProxyCargo uses SetProxyCargo or SetCargo respectively
proto native bool CompareLocationOnly(notnull InventoryLocation other)
proto native bool GetFlip()
returns flip status of cargo
static proto native int GetSlotIdFromString(string slot_name)
converts string to slot_id
static proto native owned string GetSlotName(int id)
converts slot_id to string
provides access to slot configuration
override bool CanBeCombined(EntityAI other_item, bool reservation_check=true, bool stack_max_limit=false)
override bool CanBeSplit()
EntityAI GetDraggedItem()
void ShowSourceDropzone(EntityAI item)
Widget GetRightDropzone()
void SetWidgetDraggable(Widget w, bool draggable)
void SetIsDragging(bool is_dragging)
static ItemManager GetInstance()
static void TakeOrSplitToInventoryLocation(notnull PlayerBase player, notnull InventoryLocation dst)
static void TakeOrSplitToInventory(notnull PlayerBase player, notnull EntityAI target, notnull EntityAI item)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.