18 m_ClosableHeader.GetMainWidget().ClearFlags(
WidgetFlags.DRAGGABLE);
20 RecomputeOpenedContainers();
40 Man player =
g_Game.GetPlayer();
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);
171 Man player =
g_Game.GetPlayer();
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()))
238 Man player =
g_Game.GetPlayer();
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)
349 if (!receiver_item.GetInventory().CanRemoveEntity())
351 g_Game.GetPlayer().PredictiveSwapEntities( receiver_item, item );
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);
421 string name = w.GetName();
422 name.Replace(
"PanelWidget",
"Render");
437 name = receiver.GetName();
438 name.Replace(
"PanelWidget",
"Render");
444 receiver.GetUserData(slots_icon);
469 else if (slots_icon && slots_icon.
GetSlotID() != -1)
473 if (item &&
m_Entity.GetInventory().CanAddAttachmentEx(item, slots_icon.
GetSlotID()))
513 target_entity = cargo.GetEntity() ;
516 target_cargo = target_entity.GetInventory().GetCargo();
521 if (target_cargo && target_entity)
529 if (c_x >
x && c_y >
y && target_entity.GetInventory().CanAddEntityInCargoEx(item, idx,
x,
y, item.GetInventory().GetFlipCargo()))
538 if (w.FindAnyWidget(
"Cursor"))
540 w.FindAnyWidget(
"Cursor").SetColor(color);
544 string name = w.GetName();
545 name.Replace(
"PanelWidget",
"Cursor");
546 if (w.FindAnyWidget(
name))
548 w.FindAnyWidget(
name).SetColor(color);
569 target_entity = cargo.GetEntity();
572 target_cargo = target_entity.GetInventory().GetCargo();
577 if (target_cargo && target_entity)
586 dst.
SetCargoAuto(target_cargo, item,
x,
y, item.GetInventory().GetFlipCargo());
588 if (c_x >
x && c_y >
y && target_entity.GetInventory().LocationCanAddEntity(dst))
594 Icon icon = cargo.GetIcon(item);
611 string name = w.GetName();
612 name.Replace(
"PanelWidget",
"Render");
643 for (row = 0; row < row_count; ++row)
647 for (col = 0; col < col_count; ++col)
656 void RefreshSlot(
int row,
int column,
int slot_id,
string slot_name)
663 if (!
m_Entity.CanDisplayAttachmentSlot(slot_id_))
666 icon.GetMainWidget().Show(
false);
677 (
Container.Cast(cont.m_Parent)).Remove(cont);
679 icon.GetMainWidget().Show(
true);
683 icon.GetMainWidget().Show(
true);
694 if (cont && cont.GetEntity() != item)
697 (
Container.Cast(cont.m_Parent)).Remove(cont);
708 cont.SetEntity(item);
709 cont.SetSlotIcon(icon);
714 SetOpenForSlotIcon(cont.IsOpened(),icon);
724 bool draggable =
true;
725 bool can_be_removed = item.GetInventory().CanRemoveEntity();
726 bool in_hands_condition =
m_Entity.GetHierarchyRoot() ==
g_Game.GetPlayer();
738 if (!
m_Entity.CanReleaseAttachment(item))
743 if ((in_hands_condition || in_vicinity_condition) && can_be_removed)
772 if (ent.MemoryPointExists(selectionName))
777 float heightDiff = posPlayer[1] -
position[1];
778 float negativeTolerance = -range / 5;
795 string name = w.GetName();
796 name.Replace(
"PanelWidget",
"Render");
806 if (icon &&
m_Entity.GetInventory().GetSlotLock(iw.GetUserID()))
815 if (!item.GetInventory().CanRemoveEntity())
819 if (controlledPlayer.GetInventory().HasEntityInInventory(item) && controlledPlayer.GetHumanInventory().CanAddEntityInHands(item))
821 controlledPlayer.PredictiveTakeEntityToHands(item);
825 if (controlledPlayer.GetInventory().CanAddEntityToInventory(item) && item.GetInventory().CanRemoveEntity())
827 if (item.GetTargetQuantityMax() < item.GetQuantity())
828 item.SplitIntoStackMaxClient(controlledPlayer, -1);
834 if (controlledPlayer.GetHumanInventory().CanAddEntityInHands(item))
836 if (item.GetTargetQuantityMax() < item.GetQuantity())
837 item.SplitIntoStackMaxHandsClient(controlledPlayer);
839 controlledPlayer.PredictiveTakeEntityToHands(item);
847 name.Replace(
"PanelWidget",
"Temperature");
848 w.FindAnyWidget(
name).Show(
false);
866 #ifdef DIAG_DEVELOPER
867 if (
g_Game.IsLeftCtrlDown())
868 ShowActionMenu(selectedItem);
871 if (CanSplitEx(selectedItem))
873 selectedItem.OnRightClick();
884 if (
g_Game.IsLeftCtrlDown())
889 if (controlledPlayer.CanDropEntity(selectedItem))
891 if (selectedItem.GetTargetQuantityMax() < selectedItem.GetQuantity())
892 selectedItem.SplitIntoStackMaxClient(null, -1);
894 controlledPlayer.PhysicalPredictiveDropItem(selectedItem);
898 bool draggable = !controlledPlayer.GetInventory().HasInventoryReservation(selectedItem, null) && !controlledPlayer.GetInventory().IsInventoryLocked() && selectedItem.GetInventory().CanRemoveEntity() && !controlledPlayer.IsItemsToDelete();
914 void Init(
int attachments_categories_count,
int i,
string attachment_category,
string config_path_attachment_categories,
EntityAI entity,
int parent_m_Body_count)
924 m_RowConfigPath = config_path_attachment_categories +
" " + attachment_category +
" attachmentSlots";
925 string config_path_category_name = config_path_attachment_categories +
" " + attachment_category +
" name";
927 g_Game.ConfigGetText(config_path_category_name, categoryName);
933 int count = player_ghosts_slots2.Count();
937 for (
int j = 0; j < count; ++j)
939 string slotName = player_ghosts_slots2.Get(j);
945 g_Game.ConfigGetText(
path +
" ghostIcon", iconName);
953 slotsContainer.GetRootWidget().SetAlpha(0.7);
960 slotsContainer.GetRootWidget().SetSort(row);
989 super.UpdateInterval();
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()
bool IsCategoryReachable(EntityAI ent, string categoryName, float range=1.5)
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 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)
override void ClearRemainSelected()
void SetContainer(Container container)
Widget GetRadialIconPanel()
Widget GetOutOfReachWidget()
void SetSlotID(int slot_ID)
ImageWidget GetGhostSlot()
ItemPreviewWidget GetRender()
void SetSlotDisplayName(string text)
Widget GetMountedWidget()
void Init(EntityAI obj, bool reservation=false)
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.
string m_SelectionName
in imageset format
Data for one attachment group.
TypeAttachmentGroupData GetAttGroupDataByClassName(string groupName)
Returns single 'GUIInventoryAttachmentsProps' subclass data based on class name.
Data holder for attachment group classes.
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
static proto float AbsFloat(float f)
Returns absolute value.