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 )
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() )
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 );
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();
725 bool in_hands_condition =
m_Entity.GetHierarchyRoot() ==
g_Game.GetPlayer();
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";
902 g_Game.ConfigGetText(config_path_category_name, categoryName);
908 int count = player_ghosts_slots2.Count();
912 for (
int j = 0; j < count; j++ )
914 string slotName = player_ghosts_slots2.Get(j);
920 g_Game.ConfigGetText(
path +
" ghostIcon", iconName);
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
override void UnfocusAll()
override bool IsItemActive()
void DropReceived(Widget w, int x, int y, CargoContainer cargo)
void AttachmentCategoriesRow(LayoutHolder parent, int sort=-1)
string m_CategoryIdentifier
override void UpdateInterval()
override bool TransferItem()
void Init(int attachments_categories_count, int i, string attachment_category, string config_path_attachment_categories, EntityAI entity, int parent_m_Body_count)
override bool TransferItemToVicinity()
void RefreshSlot(int row, int column, int slot_id, string slot_name)
override void OnDropReceivedFromHeader(Widget w, int x, int y, Widget receiver)
override bool CanCombine()
EntityAI GetItemPreviewItem(Widget w)
string GetCategoryIdentifier()
void MouseClick(Widget w, int x, int y, int button)
void DoubleClick(Widget w, int x, int y, int button)
override void DraggingOverHeader(Widget w, int x, int y, Widget receiver)
override bool CanCombineAmmo()
override bool EquipItem()
override bool IsItemWithQuantityActive()
ref map< int, ref ContainerWithCargo > m_AttachmentCargos
bool DraggingOverGrid(Widget w, int x, int y, Widget reciever, CargoContainer cargo)
ref AttachmentsGroupContainer m_AttachmentsContainer
static bool IsAttachmentReachable(EntityAI e, string att_slot_name="", int slot_id=-1, float range=1.5)
represents base for cargo storage for entities
proto native int GetWidth()
proto native int GetHeight()
Super root of all classes in Enforce script.
override bool InspectItem()
void ContainerWithCargo(LayoutHolder parent, int sort=-1)
static ColorManager GetInstance()
void SetColor(Widget w, int color)
script counterpart to engine's class Inventory
static bool CanSwapEntitiesEx(notnull EntityAI item1, notnull EntityAI item2)
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)
provides access to slot configuration
static proto native int GetStackMaxForSlotId(int slot_Id)
static proto native owned string GetSlotName(int id)
static proto native int GetSlotIdFromString(string slot_name)
static proto native owned string GetSlotDisplayName(int id)
override bool CanBeSplit()
override bool CanBeCombined(EntityAI other_item, bool reservation_check=true, bool stack_max_limit=false)
EntityAI GetSelectedItem()
void ShowSourceDropzone(EntityAI item)
void SetWidgetDraggable(Widget w, bool draggable)
void SetIsDragging(bool is_dragging)
static ItemManager GetInstance()
EntityAI GetDraggedItem()
SlotsIcon GetSlotIcon(int index)
void SetSlotDisplayName(string text)
Widget GetRadialIconPanel()
ItemPreviewWidget GetRender()
Widget GetOutOfReachWidget()
Widget GetMountedWidget()
ImageWidget GetGhostSlot()
void SetSlotID(int slot_ID)
void Init(EntityAI obj, bool reservation=false)
void SetContainer(Container container)
void ClearRemainSelected()
static void TakeOrSplitToInventory(notnull PlayerBase player, notnull EntityAI target, notnull EntityAI item)
static void TakeOrSplitToInventoryLocation(notnull PlayerBase player, notnull InventoryLocation dst)
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.
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