18 m_ClosableHeader.GetMainWidget().ClearFlags(
WidgetFlags.DRAGGABLE );
20 RecomputeOpenedContainers();
41 SlotsIcon focused_icon = GetFocusedSlotsIcon();
42 EntityAI focused_item = GetFocusedItem();
43 Container focused_cont = GetFocusedContainer();
46 if( selected_item && focused_item != selected_item)
48 if( selected_item.GetInventory().CanRemoveEntity() )
59 else if( !focused_item &&
m_Entity &&
m_Entity.GetInventory().CanAddAttachmentEx( selected_item, focused_icon.
GetSlotID() ) )
62 float quantity = selected_item.GetQuantity();
63 if( stack_max == 0 || stack_max >= quantity || !selected_item.
CanBeSplit() )
65 player.PredictiveTakeEntityToTargetAttachmentEx(
m_Entity, selected_item, focused_icon.
GetSlotID() );
76 if (focused_item && focused_item.GetHierarchyParent() && focused_item.GetHierarchyParent().GetInventory().CanAddAttachment(selected_item))
79 focused_item.GetInventory().GetCurrentInventoryLocation( inv_loc );
81 quantity = focused_item.GetQuantity();
82 if( focused_item.CanBeCombined(
ItemBase.Cast( selected_item ) ) )
84 focused_item.CombineItemsClient( selected_item,
true );
89 player.PredictiveSwapEntities( selected_item, focused_item );
94 if( focused_item.GetInventory().CanAddEntityInCargo( selected_item, selected_item.GetInventory().GetFlipCargo() ) )
106 if( focused_item && focused_item.GetInventory().CanRemoveEntity() && (!focused_icon || !focused_icon.
IsOutOfReach()) )
109 if( item_in_hands && item_in_hands.GetInventory().CanRemoveEntity() )
113 player.PredictiveSwapEntities( item_in_hands, focused_item );
119 if( player.GetHumanInventory().CanAddEntityInHands( focused_item ) )
121 player.PredictiveTakeEntityToHands( focused_item );
133 if (CanTakeToInventory())
136 SlotsIcon focused_icon = GetFocusedSlotsIcon();
137 if( entity && !entity.IsLockedInSlot() && (!focused_icon || !focused_icon.
IsOutOfReach()) )
153 SlotsIcon focused_icon = GetFocusedSlotsIcon();
155 if (item && !item.IsLockedInSlot() && (focused_icon && !focused_icon.
IsOutOfReach()))
157 if (item.GetTargetQuantityMax() < item.GetQuantity())
158 item.SplitIntoStackMaxClient( null, -1 );
160 player.PhysicalPredictiveDropItem( item );
173 ItemBase selected_item =
ItemBase.Cast( player.GetHumanInventory().GetEntityInHands() );
174 SlotsIcon focused_icon = GetFocusedSlotsIcon();
180 if( selected_item && selected_item.GetInventory().CanRemoveEntity() && (focused_icon && !focused_icon.
IsOutOfReach()) )
182 if( !prev_item &&
m_Entity.GetInventory().CanAddAttachmentEx( selected_item, selected_slot ) )
185 float quantity = selected_item.GetQuantity();
186 if( stack_max == 0 || stack_max >= quantity || !selected_item.
CanBeSplit() )
188 player.PredictiveTakeEntityToTargetAttachmentEx(
m_Entity, selected_item, selected_slot );
193 selected_item.SplitIntoStackMaxClient(
m_Entity, selected_slot );
197 else if( selected_slot != -1 )
202 prev_item.GetInventory().GetCurrentInventoryLocation( inv_loc );
204 quantity = prev_item.GetQuantity();
207 prev_item.CombineItemsClient( selected_item,
true );
212 player.PredictiveSwapEntities( selected_item, prev_item );
217 if( prev_item.GetInventory().CanAddEntityInCargo( selected_item, selected_item.GetInventory().GetFlipCargo() ) )
240 ItemBase selected_item =
ItemBase.Cast( player.GetHumanInventory().GetEntityInHands() );
241 SlotsIcon focused_icon = GetFocusedSlotsIcon();
247 if( selected_item && selected_item.GetInventory().CanRemoveEntity() && (focused_icon && !focused_icon.
IsOutOfReach()) )
249 if(
m_Entity.GetInventory().CanAddAttachmentEx( selected_item, selected_slot ) )
252 float quantity = selected_item.GetQuantity();
253 if( stack_max == 0 || stack_max >= quantity || !selected_item.
CanBeSplit() )
262 else if( selected_slot != -1 )
267 prev_item.GetInventory().GetCurrentInventoryLocation( inv_loc );
269 quantity = prev_item.GetQuantity();
289 return GetFocusedItem() != null && (!icon || !icon.
IsOutOfReach());
306 bool is_reserved =
false;
308 receiver.GetUserData(slots_icon);
309 float stackable = 0.0;
328 if( !item.GetInventory().CanRemoveEntity() || !player.CanManipulateInventory() )
336 if( player.GetWeaponManager().CanAttachMagazine( wpn, mag ) )
338 player.GetWeaponManager().AttachMagazine( mag );
341 else if( receiver_item && !is_reserved )
343 if( (
ItemBase.Cast( receiver_item ) ).CanBeCombined(
ItemBase.Cast( item ) ) )
345 (
ItemBase.Cast( receiver_item ) ).CombineItemsClient(
ItemBase.Cast( item ) );
349 if( !receiver_item.GetInventory().CanRemoveEntity() )
353 else if( receiver_item.GetInventory().CanAddAttachment( item ) )
355 player.PredictiveTakeEntityToTargetAttachment(receiver_item, item);
358 else if( attached_entity && slot_id != -1 && attached_entity.GetInventory().CanAddAttachmentEx( item, slot_id ) )
361 stackable = item_base.GetTargetQuantityMax( slot_id );
363 if( stackable == 0 || stackable >= item_base.GetQuantity() )
365 player.PredictiveTakeEntityToTargetAttachmentEx(attached_entity, item, slot_id);
367 else if( stackable != 0 && stackable < item_base.GetQuantity() )
369 item_base.SplitIntoStackMaxClient(
m_Entity, slot_id );
372 else if(attached_entity && slot_id == -1 && attached_entity.GetInventory().FindFreeLocationFor(item,
FindInventoryLocationType.ATTACHMENT,il))
375 stackable = item_base.GetTargetQuantityMax( il.
GetSlot() );
377 if( stackable == 0 || stackable >= item_base.GetQuantity() )
379 player.PredictiveTakeEntityToTargetAttachmentEx(attached_entity, item, il.
GetSlot());
381 else if( stackable != 0 && stackable < item_base.GetQuantity() )
395 for ( i = 1; i <
Count(); i++ )
399 Widget w =
Get( i ).GetMainWidget().FindAnyWidget(
"Cursor" + j );
420 string name = w.GetName();
421 name.Replace(
"PanelWidget",
"Render");
436 name = receiver.GetName();
437 name.Replace(
"PanelWidget",
"Render");
443 receiver.GetUserData(slots_icon);
468 else if( slots_icon && slots_icon.
GetSlotID() != -1 )
472 if( item &&
m_Entity.GetInventory().CanAddAttachmentEx( item, slots_icon.
GetSlotID() ) )
512 target_entity = cargo.GetEntity() ;
515 target_cargo = target_entity.GetInventory().GetCargo();
520 if( target_cargo && target_entity )
528 if( c_x >
x && c_y >
y && target_entity.GetInventory().CanAddEntityInCargoEx( item, idx,
x,
y, item.GetInventory().GetFlipCargo() ) )
537 if( w.FindAnyWidget(
"Cursor") )
539 w.FindAnyWidget(
"Cursor").SetColor( color );
543 string name = w.GetName();
544 name.Replace(
"PanelWidget",
"Cursor" );
545 if( w.FindAnyWidget(
name ) )
547 w.FindAnyWidget(
name ).SetColor( color );
568 target_entity = cargo.GetEntity();
571 target_cargo = target_entity.GetInventory().GetCargo();
576 if( target_cargo && target_entity )
585 dst.
SetCargoAuto(target_cargo, item,
x,
y, item.GetInventory().GetFlipCargo());
587 if( c_x >
x && c_y >
y && target_entity.GetInventory().LocationCanAddEntity(dst))
593 Icon icon = cargo.GetIcon( item );
610 string name = w.GetName();
611 name.Replace(
"PanelWidget",
"Render" );
642 for (row = 0; row < row_count; row++)
646 for (col = 0; col < col_count; col++)
655 void RefreshSlot(
int row,
int column,
int slot_id,
string slot_name )
662 if (!
m_Entity.CanDisplayAttachmentSlot(slot_id_))
665 icon.GetMainWidget().Show(
false );
676 (
Container.Cast( cont.m_Parent ) ).Remove( cont );
678 icon.GetMainWidget().Show(
true);
682 icon.GetMainWidget().Show(
true );
693 if( cont && cont.GetEntity() != item)
696 (
Container.Cast( cont.m_Parent ) ).Remove( cont );
707 cont.SetEntity( item );
708 cont.SetSlotIcon( icon );
713 SetOpenForSlotIcon(cont.IsOpened(),icon);
723 bool draggable =
true;
724 bool can_be_removed = item.GetInventory().CanRemoveEntity();
737 if( !
m_Entity.CanReleaseAttachment( item ) )
742 if ((in_hands_condition || in_vicinity_condition) && can_be_removed)
770 string name = w.GetName();
771 name.Replace(
"PanelWidget",
"Render");
781 if (icon &&
m_Entity.GetInventory().GetSlotLock(iw.GetUserID()))
790 if (!item.GetInventory().CanRemoveEntity())
794 if (controlledPlayer.GetInventory().HasEntityInInventory(item) && controlledPlayer.GetHumanInventory().CanAddEntityInHands(item))
796 controlledPlayer.PredictiveTakeEntityToHands(item);
800 if (controlledPlayer.GetInventory().CanAddEntityToInventory(item) && item.GetInventory().CanRemoveEntity())
802 if (item.GetTargetQuantityMax() < item.GetQuantity())
803 item.SplitIntoStackMaxClient(controlledPlayer, -1);
809 if (controlledPlayer.GetHumanInventory().CanAddEntityInHands(item))
811 if (item.GetTargetQuantityMax() < item.GetQuantity())
812 item.SplitIntoStackMaxHandsClient(controlledPlayer);
814 controlledPlayer.PredictiveTakeEntityToHands(item);
822 name.Replace(
"PanelWidget",
"Temperature");
823 w.FindAnyWidget(
name).Show(
false);
841 #ifdef DIAG_DEVELOPER
842 if (
g_Game.IsLeftCtrlDown())
843 ShowActionMenu(selectedItem);
846 if (CanSplitEx(selectedItem))
848 selectedItem.OnRightClick();
859 if (
g_Game.IsLeftCtrlDown())
864 if (controlledPlayer.CanDropEntity(selectedItem))
866 if (selectedItem.GetTargetQuantityMax() < selectedItem.GetQuantity())
867 selectedItem.SplitIntoStackMaxClient(null, -1);
869 controlledPlayer.PhysicalPredictiveDropItem(selectedItem);
873 bool draggable = !controlledPlayer.GetInventory().HasInventoryReservation(selectedItem, null ) && !controlledPlayer.GetInventory().IsInventoryLocked() && selectedItem.GetInventory().CanRemoveEntity() && !controlledPlayer.IsItemsToDelete();
889 void Init(
int attachments_categories_count,
int i,
string attachment_category,
string config_path_attachment_categories,
EntityAI entity,
int parent_m_Body_count )
899 m_RowConfigPath = config_path_attachment_categories +
" " + attachment_category +
" attachmentSlots";
900 string config_path_category_name = config_path_attachment_categories +
" " + attachment_category +
" name";
908 int count = player_ghosts_slots2.Count();
912 for (
int j = 0; j < count; j++ )
914 string slotName = player_ghosts_slots2.Get(j);
928 slotsContainer.GetRootWidget().SetAlpha(0.7);
935 slotsContainer.GetRootWidget().SetSort(row);
964 super.UpdateInterval();
void Remove(Object object)
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
PlayerSpawnPreset slotName
FindInventoryLocationType
flags for searching locations in inventory
void MouseClick(Widget w, int x, int y, int button)
override void UpdateInterval()
override bool TransferItemToVicinity()
override void OnDropReceivedFromHeader(Widget w, int x, int y, Widget receiver)
override bool IsItemWithQuantityActive()
override bool IsItemActive()
override bool CanCombineAmmo()
ref AttachmentsGroupContainer m_AttachmentsContainer
void Init(int attachments_categories_count, int i, string attachment_category, string config_path_attachment_categories, EntityAI entity, int parent_m_Body_count)
override void UnfocusAll()
void DoubleClick(Widget w, int x, int y, int button)
override bool TransferItem()
ref map< int, ref ContainerWithCargo > m_AttachmentCargos
string m_CategoryIdentifier
void AttachmentCategoriesRow(LayoutHolder parent, int sort=-1)
void RefreshSlot(int row, int column, int slot_id, string slot_name)
void DropReceived(Widget w, int x, int y, CargoContainer cargo)
override void DraggingOverHeader(Widget w, int x, int y, Widget receiver)
bool DraggingOverGrid(Widget w, int x, int y, Widget reciever, CargoContainer cargo)
string GetCategoryIdentifier()
override bool CanCombine()
override bool EquipItem()
EntityAI GetItemPreviewItem(Widget w)
static bool IsAttachmentReachable(EntityAI e, string att_slot_name="", int slot_id=-1, float range=1.5)
proto native void ConfigGetTextArray(string path, out TStringArray values)
Get array of strings from config on path.
proto bool ConfigGetText(string path, out string value)
Get string value from config on path.
proto native DayZPlayer GetPlayer()
proto native int GetWidth()
proto native int GetHeight()
represents base for cargo storage for entities
Super root of all classes in Enforce script.
override bool InspectItem()
void ContainerWithCargo(LayoutHolder parent, int sort=-1)
void SetColor(Widget w, int color)
static ColorManager GetInstance()
static bool CanSwapEntitiesEx(notnull EntityAI item1, notnull EntityAI item2)
script counterpart to engine's class Inventory
void RefreshPos(int row, int column)
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
static proto native owned string GetSlotDisplayName(int id)
converts slot_id to string
static proto native int GetSlotIdFromString(string slot_name)
converts string to slot_id
static proto native int GetStackMaxForSlotId(int 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)
EntityAI GetSelectedItem()
void SetWidgetDraggable(Widget w, bool draggable)
void SetIsDragging(bool is_dragging)
static ItemManager GetInstance()
SlotsIcon GetSlotIcon(int index)
void ClearRemainSelected()
ItemPreviewWidget GetRender()
void Init(EntityAI obj, bool reservation=false)
void SetSlotID(int slot_ID)
void SetSlotDisplayName(string text)
void SetContainer(Container container)
Widget GetMountedWidget()
Widget GetOutOfReachWidget()
Widget GetRadialIconPanel()
ImageWidget GetGhostSlot()
static void TakeOrSplitToInventoryLocation(notnull PlayerBase player, notnull InventoryLocation dst)
static void TakeOrSplitToInventory(notnull PlayerBase player, notnull EntityAI target, notnull EntityAI item)
static const int IMAGESETGROUP_INVENTORY
static string VerifyIconImageString(int imageset_group=IMAGESETGROUP_INVENTORY, string icon_name="")
Checks for improperly formated, legacy image names and corrects them to default format.
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.