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 );
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 );
134 SlotsIcon focused_icon = GetFocusedSlotsIcon();
135 if( entity && !entity.IsLockedInSlot() && (!focused_icon || !focused_icon.
IsOutOfReach()) )
148 SlotsIcon focused_icon = GetFocusedSlotsIcon();
150 if( item && !item.IsLockedInSlot() && (focused_icon && !focused_icon.
IsOutOfReach()) )
152 if( item.GetTargetQuantityMax() < item.GetQuantity() )
153 item.SplitIntoStackMaxClient( null, -1 );
155 player.PhysicalPredictiveDropItem( item );
165 ItemBase selected_item =
ItemBase.Cast( player.GetHumanInventory().GetEntityInHands() );
166 SlotsIcon focused_icon = GetFocusedSlotsIcon();
172 if( selected_item && selected_item.GetInventory().CanRemoveEntity() && (focused_icon && !focused_icon.
IsOutOfReach()) )
174 if( !prev_item &&
m_Entity.GetInventory().CanAddAttachmentEx( selected_item, selected_slot ) )
177 float quantity = selected_item.GetQuantity();
178 if( stack_max == 0 || stack_max >= quantity || !selected_item.CanBeSplit() )
180 player.PredictiveTakeEntityToTargetAttachmentEx(
m_Entity, selected_item, selected_slot );
185 selected_item.SplitIntoStackMaxClient(
m_Entity, selected_slot );
189 else if( selected_slot != -1 )
194 prev_item.GetInventory().GetCurrentInventoryLocation( inv_loc );
196 quantity = prev_item.GetQuantity();
199 prev_item.CombineItemsClient( selected_item,
true );
204 player.PredictiveSwapEntities( selected_item, prev_item );
209 if( prev_item.GetInventory().CanAddEntityInCargo( selected_item, selected_item.GetInventory().GetFlipCargo() ) )
241 ItemBase selected_item =
ItemBase.Cast( player.GetHumanInventory().GetEntityInHands() );
242 SlotsIcon focused_icon = GetFocusedSlotsIcon();
248 if( selected_item && selected_item.GetInventory().CanRemoveEntity() && (focused_icon && !focused_icon.
IsOutOfReach()) )
250 if(
m_Entity.GetInventory().CanAddAttachmentEx( selected_item, selected_slot ) )
253 float quantity = selected_item.GetQuantity();
254 if( stack_max == 0 || stack_max >= quantity || !selected_item.CanBeSplit() )
263 else if( selected_slot != -1 )
268 prev_item.GetInventory().GetCurrentInventoryLocation( inv_loc );
270 quantity = prev_item.GetQuantity();
290 return GetFocusedItem() != null && (!icon || !icon.
IsOutOfReach());
297 return item && ( !icon || !icon.
IsOutOfReach()) && item.CanBeSplit();
307 bool is_reserved =
false;
309 receiver.GetUserData(slots_icon);
310 float stackable = 0.0;
329 if( !item.GetInventory().CanRemoveEntity() || !player.CanManipulateInventory() )
337 if( player.GetWeaponManager().CanAttachMagazine( wpn, mag ) )
339 player.GetWeaponManager().AttachMagazine( mag );
342 else if( receiver_item && !is_reserved )
344 if( (
ItemBase.Cast( receiver_item ) ).CanBeCombined(
ItemBase.Cast( item ) ) )
350 if( !receiver_item.GetInventory().CanRemoveEntity() )
354 else if( receiver_item.GetInventory().CanAddAttachment( item ) )
356 player.PredictiveTakeEntityToTargetAttachment(receiver_item, item);
359 else if( attached_entity && slot_id != -1 && attached_entity.GetInventory().CanAddAttachmentEx( item, slot_id ) )
362 stackable = item_base.GetTargetQuantityMax( slot_id );
364 if( stackable == 0 || stackable >= item_base.GetQuantity() )
366 player.PredictiveTakeEntityToTargetAttachmentEx(attached_entity, item, slot_id);
368 else if( stackable != 0 && stackable < item_base.GetQuantity() )
370 item_base.SplitIntoStackMaxClient(
m_Entity, slot_id );
373 else if(attached_entity && slot_id == -1 && attached_entity.GetInventory().FindFreeLocationFor(item,
FindInventoryLocationType.ATTACHMENT,il))
376 stackable = item_base.GetTargetQuantityMax( il.
GetSlot() );
378 if( stackable == 0 || stackable >= item_base.GetQuantity() )
380 player.PredictiveTakeEntityToTargetAttachmentEx(attached_entity, item, il.
GetSlot());
382 else if( stackable != 0 && stackable < item_base.GetQuantity() )
396 for ( i = 1; i <
Count(); i++ )
400 Widget w =
Get( i ).GetMainWidget().FindAnyWidget(
"Cursor" + j );
421 string name = w.GetName();
437 name = receiver.GetName();
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() ) )
503 string name = w.GetName();
517 w.GetUserData(slots_icon);
519 if( slots_icon &&
m_Entity.GetInventory().GetSlotLock( iw.GetUserID() ) )
526 if( !item.GetInventory().CanRemoveEntity() )
531 if( player.GetInventory().HasEntityInInventory( item ) && player.GetHumanInventory().CanAddEntityInHands( item ) )
533 player.PredictiveTakeEntityToHands( item );
537 if(player.GetInventory().CanAddEntityToInventory( item ) && item.GetInventory().CanRemoveEntity())
539 if( item.GetTargetQuantityMax() < item.GetQuantity() )
541 item.SplitIntoStackMaxClient( player, -1 );
550 if( player.GetHumanInventory().CanAddEntityInHands( item ) )
552 if( item.GetTargetQuantityMax() < item.GetQuantity() )
554 item.SplitIntoStackMaxHandsClient( player );
558 player.PredictiveTakeEntityToHands( item );
568 w.FindAnyWidget(
name ).Show(
false );
593 target_entity = cargo.GetEntity() ;
596 target_cargo = target_entity.GetInventory().GetCargo();
601 if( target_cargo && target_entity )
609 if( c_x >
x && c_y >
y && target_entity.GetInventory().CanAddEntityInCargoEx( item, idx,
x,
y, item.GetInventory().GetFlipCargo() ) )
618 if( w.FindAnyWidget(
"Selected") )
620 w.FindAnyWidget(
"Selected").SetColor( color );
624 string name = w.GetName();
626 if( w.FindAnyWidget(
name ) )
628 w.FindAnyWidget(
name ).SetColor( color );
649 target_entity = cargo.GetEntity();
652 target_cargo = target_entity.GetInventory().GetCargo();
657 if( target_cargo && target_entity )
666 dst.
SetCargoAuto(target_cargo, item,
x,
y, item.GetInventory().GetFlipCargo());
668 if( c_x >
x && c_y >
y && target_entity.GetInventory().LocationCanAddEntity(dst))
674 Icon icon = cargo.GetIcon( item );
691 string name = w.GetName();
723 for (row = 0; row < row_count; row++)
727 for (col = 0; col < col_count; col++)
736 void RefreshSlot(
int row,
int column,
int slot_id,
string slot_name )
743 if( !
m_Entity.CanDisplayAttachmentSlot( slot_id_ ) )
746 icon.GetMainWidget().Show(
false );
751 icon.GetMainWidget().Show(
true );
762 icon.GetMainWidget().Show(
true );
774 if( cont && cont.GetEntity() != item)
788 cont.SetEntity( item );
789 cont.SetSlotIcon( icon );
797 SetOpenForSlotIcon(cont.IsOpened(),icon);
807 bool draggable =
true;
808 bool can_be_removed = item.GetInventory().CanRemoveEntity();
821 if( !
m_Entity.CanReleaseAttachment( item ) )
826 if ((in_hands_condition || in_vicinity_condition) && can_be_removed)
849 super.OnMouseButtonDown(w,
x,
y, button);
852 w.GetUserData(slots_icon);
867 #ifdef DIAG_DEVELOPER
871 w.GetUserData(user_data);
874 ShowActionMenu( user_data.
GetItem() );
882 void Init(
int attachments_categories_count,
int i,
string attachment_category,
string config_path_attachment_categories,
EntityAI entity,
int parent_m_Body_count )
890 string category_name;
892 m_RowConfigPath = config_path_attachment_categories +
" " + attachment_category +
" attachmentSlots";
893 string config_path_category_name = config_path_attachment_categories +
" " + attachment_category +
" name";
901 int count = player_ghosts_slots2.Count();
905 for (
int j = 0; j < count; j++ )
907 string slot_name = player_ghosts_slots2.
Get(j);
909 string path =
"CfgSlots" +
" Slot_" + slot_name;
921 ic.GetRootWidget().SetAlpha(0.7);
931 ic.GetRootWidget().SetSort( row );
960 super.UpdateInterval();
void Remove(Object object)
FindInventoryLocationType
flags for searching locations in inventory
override void CombineItemsClient(EntityAI entity2, bool use_stack_max=true)
array< ref PlayerStatBase > Get()
class PluginItemDiagnosticEventHandler extends ScriptedWidgetEventHandler m_Entity
override void UnfocusAll()
override bool IsItemActive()
void DropReceived(Widget w, int x, int y, CargoContainer cargo)
void AttachmentCategoriesRow(LayoutHolder parent, int sort=-1)
protected ref map< int, ref ContainerWithCargo > m_AttachmentCargos
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()
protected ref AttachmentsGroupContainer m_AttachmentsContainer
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)
protected bool m_Refreshing
string GetCategoryIdentifier()
override bool CanSplitEx(EntityAI focusedItem)
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()
protected string m_RowConfigPath
bool DraggingOverGrid(Widget w, int x, int y, Widget reciever, CargoContainer cargo)
protected string m_CategoryIdentifier
override bool OnMouseButtonDown(Widget w, int x, int y, int button)
override bool SplitItem()
int GetRowCount(bool include_invisible=true)
int GetColumnCountForRow(int row, bool include_invisible=true)
override void SetHeader(Header header)
SlotsIcon GetSlotsIcon(int row, int column, bool include_invisible=true)
static bool IsAttachmentReachable(EntityAI e, string att_slot_name="", int slot_id=-1, float range=1.5)
proto native DayZPlayer GetPlayer()
proto bool ConfigGetText(string path, out string value)
Get string value from config on path.
proto native void ConfigGetTextArray(string path, out TStringArray values)
Get array of strings from config on path.
represents base for cargo storage for entities
proto native int GetHeight()
proto native int GetWidth()
Super root of all classes in Enforce script.
void ContainerWithCargo(Container parent, int sort=-1)
static ColorManager GetInstance()
void SetColor(Widget w, int color)
override LayoutHolder Get(int x)
bool PredictiveSwapEntities(notnull EntityAI item1, notnull EntityAI item2)
script counterpart to engine's class Inventory
static bool CanSwapEntitiesEx(notnull EntityAI item1, notnull EntityAI item2)
void RefreshPos(int row, int column)
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 int GetSlot()
returns slot id if current type is Attachment
provides access to slot configuration
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
static proto native owned string GetSlotDisplayName(int id)
converts slot_id to string
override bool CanBeCombined(EntityAI other_item, bool reservation_check=true, bool stack_max_limit=false)
EntityAI GetSelectedItem()
void ShowSourceDropzone(EntityAI item)
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)
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.
proto native CGame GetGame()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
proto int Replace(string sample, string replace)
Replace all occurrances of 'sample' in 'str' by 'replace'.