15 bool show_radial_icon;
17 Widget rip = m_SlotIcon.GetRadialIconPanel();
18 rip.Show( !
m_Player.GetInventory().IsInventoryLockedForLockType( HIDE_INV_FROM_SCRIPT ) &&
m_Player.CanDisplayCargo());
19 SetOpenForSlotIcon(show_radial_icon);
49 string config_path_ghosts_slots =
"CfgVehicles SurvivorBase InventoryEquipment playerSlots";
53 for (
int i = 0; i < player_ghosts_slots.Count(); i++ )
55 string slot_name = player_ghosts_slots.Get ( i );
56 string path =
"CfgSlots" +
" " + slot_name;
69 if( row < ( player_ghosts_slots.Count() /
ITEMS_IN_ROW ) )
77 icon.GetMainWidget().Show(
true );
101 RecomputeOpenedContainers();
123 m_Player.GetOnAttachmentReleaseLock().Invoke(item, slot);
130 int sort_index =
Inventory.GetPlayerAttachmentIndex( slot );
131 int current_sort = 9999;
132 if( GetFocusedContainer() )
133 current_sort = GetFocusedContainer().GetRootWidget().GetSort();
135 if( item.GetSlotsCountCorrect() > 0 )
137 ContainerWithCargoAndAttachments iwca =
new ContainerWithCargoAndAttachments(
this, sort_index );
138 iwca.SetEntity( item );
139 iwca.SetSlotIcon( icon );
142 if( iwca.IsDisplayable() )
147 RecomputeOpenedContainers();
150 else if( item.GetInventory().GetCargo() )
152 ContainerWithCargo iwc =
new ContainerWithCargo(
this, sort_index );
153 iwc.SetEntity( item );
154 iwc.SetSlotIcon( icon );
155 iwc.UpdateInterval();
158 RecomputeOpenedContainers();
159 if( iwc.IsDisplayable() )
167 string config =
"CfgVehicles " + item.GetType() +
" GUIInventoryAttachmentsProps";
170 bool show_radial_icon = ( item.GetInventory().GetCargo() || item.GetSlotsCountCorrect() > 0 ) && !
GetGame().
ConfigIsExisting( config );
173 rip.Show( show_radial_icon );
174 SetOpenForSlotIcon(conta.
IsOpened(),icon);
177 UpdateSelectionIcons();
191 RecomputeOpenedContainers();
192 GetMainWidget().Update();
200 in.UpdateConsoleToolbar();
202 UpdateSelectionIcons();
211 icon.
Init( item,
true );
224 s_cont.SetColumnCount( row_count );
231 w.GetUserData(slots_icon);
249 #ifdef DIAG_DEVELOPER
256 GetGame().
GetPlayer().GetHumanInventory().ClearUserReservedLocationSynced( item );
271 if (
g_Game.IsLeftCtrlDown() )
273 if ( itemAtPos && itemAtPos.GetInventory().CanRemoveEntity() &&
m_Player.CanDropEntity(itemAtPos) )
275 if ( itemAtPos.GetTargetQuantityMax() < itemAtPos.GetQuantity() )
276 itemAtPos.SplitIntoStackMaxClient( null, -1 );
278 m_Player.PhysicalPredictiveDropItem( itemAtPos );
283 bool draggable = !
m_Player.GetInventory().HasInventoryReservation( item, null ) && !
m_Player.GetInventory().IsInventoryLocked() && item.GetInventory().CanRemoveEntity() && !
m_Player.IsItemsToDelete();
294 GetRootWidget().GetScreenPos(
x,
y );
302 GetRootWidget().GetScreenPos(
x,
y );
303 GetRootWidget().GetScreenSize( x2, y2 );
311 if (c_cont && m_Body.Count() > 1)
315 int curr_sort = c_cont.GetRootWidget().GetSort();
318 int prev_sort = prev.GetRootWidget().GetSort();
319 if ( prev_sort > curr_sort )
322 if ( ++index < m_Body.Count() )
328 m_Body.InsertAt( container, index );
332 m_Body.Insert( container );
336 RecomputeOpenedContainers();
342 return ent && ( ent.GetInventory().GetCargo() || ent.GetSlotsCountCorrect() > 0 );
374 if( w == null ||
m_Player.GetInventory().IsInventoryLocked() )
381 string name = w.GetName();
398 iw.GetUserData(icon);
405 if( !item.GetInventory().CanRemoveEntity() )
408 if ( player.GetInventory().HasEntityInInventory( item ) && player.GetHumanInventory().CanAddEntityInHands( item ) )
410 player.PredictiveTakeEntityToHands( item );
414 if (player.GetInventory().CanAddEntityToInventory( item ) && item.GetInventory().CanRemoveEntity())
416 if( item.GetTargetQuantityMax() < item.GetQuantity() )
417 item.SplitIntoStackMaxClient( player, -1 );
423 if( item.GetTargetQuantityMax() < item.GetQuantity() )
424 item.SplitIntoStackMaxHandsClient( player );
426 player.PredictiveTakeEntityToHands( item );
435 menu.RefreshQuickbar();
450 return GetFocusedContainer().IsInherited( ContainerWithCargo );
455 return GetFocusedContainer().IsInherited( ContainerWithCargoAndAttachments );
460 if( GetFocusedContainer().IsInherited( ContainerWithCargo ) || GetFocusedContainer().IsInherited( ContainerWithCargoAndAttachments ) )
462 return GetFocusedContainer().TransferItemToVicinity();
468 if( item && player.CanDropEntity( item ) )
470 if( item.GetTargetQuantityMax() < item.GetQuantity() )
471 item.SplitIntoStackMaxClient( null, -1 );
473 player.PhysicalPredictiveDropItem( item );
482 if( GetFocusedContainer().IsInherited( ContainerWithCargo ) || GetFocusedContainer().IsInherited( ContainerWithCargoAndAttachments ) )
484 return GetFocusedContainer().InspectItem();
501 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(
GetPlugin( PluginRecipesManager ) );
507 if( GetFocusedContainer().IsInherited( ContainerWithCargo ) || GetFocusedContainer().IsInherited( ContainerWithCargoAndAttachments ) )
509 return GetFocusedContainer().SplitItem();
517 if( GetFocusedContainer().IsInherited( ContainerWithCargo ) || GetFocusedContainer().IsInherited( ContainerWithCargoAndAttachments ) )
519 return GetFocusedContainer().EquipItem();
539 if( GetFocusedContainer().IsInherited( ContainerWithCargo ) || GetFocusedContainer().IsInherited( ContainerWithCargoAndAttachments ) )
541 return GetFocusedContainer().TransferItem();
555 if( !GetFocusedContainer().IsInherited( ContainerWithCargo ) && !GetFocusedContainer().IsInherited( ContainerWithCargoAndAttachments ) )
570 return GetFocusedContainer().GetFocusedItem();
575 if( GetFocusedContainer() && ( GetFocusedContainer().IsInherited( ContainerWithCargo ) || GetFocusedContainer().IsInherited( ContainerWithCargoAndAttachments ) ) )
577 return GetFocusedContainer().Combine();
586 if( item_in_hands && item )
596 if( GetFocusedContainer().IsInherited( ContainerWithCargo ) || GetFocusedContainer().IsInherited( ContainerWithCargoAndAttachments ) )
598 return GetFocusedContainer().Select();
604 SlotsIcon focused_slot = GetFocusedSlotsIcon();
606 if( focused_slot.
IsReserved() || focused_item != selected_item )
610 if( selected_item.GetInventory().CanRemoveEntity() )
612 if(
m_Player.GetInventory().CanAddAttachmentEx( selected_item, focused_slot.
GetSlotID() ) )
614 player.PredictiveTakeEntityToTargetAttachmentEx(
m_Player, selected_item, focused_slot.
GetSlotID());
620 else if(
m_Player.GetInventory().CanAddAttachment( selected_item ) )
622 player.PredictiveTakeEntityToTargetAttachment(
m_Player, selected_item );
631 if( focused_item && focused_item.GetInventory().CanRemoveEntity() )
633 EntityAI item_in_hands = player.GetHumanInventory().GetEntityInHands();
634 if( item_in_hands && item_in_hands.GetInventory().CanRemoveEntity() )
638 player.PredictiveSwapEntities( item_in_hands, focused_item );
648 if ( player.NeedInventoryJunctureFromServer(item_in_hands, item_in_hands.GetHierarchyParent(), il_hands_dst.
GetParent()) ||
GetGame().
GetPlayer().NeedInventoryJunctureFromServer(focused_item, focused_item.GetHierarchyParent(),
GetGame().
GetPlayer()) )
651 player.GetHumanInventory().ForceSwapEntities( invMode, focused_item, item_in_hands, il_hands_dst );
658 if( player.GetHumanInventory().CanAddEntityInHands( focused_item ) )
660 player.PredictiveTakeEntityToHands( focused_item );
690 string config_path_ghosts_slots =
"CfgVehicles SurvivorBase InventoryEquipment playerSlots";
694 for (
int i = 0; i < player_ghosts_slots.Count(); i++ )
696 string slot_name = player_ghosts_slots.Get ( i );
704 icon.GetMainWidget().Show(
true );
731 if( !item.GetInventory().CanRemoveEntity() )
745 string name = w.GetName();
799 bool is_reserved =
false;
802 receiver.GetUserData(slots_icon);
823 if( receiver_item && !is_reserved )
832 else if( receiver_item.GetInventory().CanAddAttachment(item) || receiver_item.GetInventory().CanAddEntityInCargo( item, item.GetInventory().GetFlipCargo() ) && !receiver_item.GetInventory().HasEntityInCargo( item ))
839 else if( (
ItemBase.Cast( receiver_item ) ).CanBeCombined(
ItemBase.Cast( item ) ) )
849 if( item.GetInventory().CanRemoveEntity() )
851 if(
m_Player.GetInventory().CanAddAttachment( item) )
891 bool is_reserved =
false;
897 receiver.GetUserData(slots_icon);
915 if ( receiver_item && !is_reserved )
923 menu.RefreshQuickbar();
927 else if ( receiver_item.GetInventory().CanAddAttachment( item ) )
929 GetGame().
GetPlayer().PredictiveTakeEntityToTargetAttachment( receiver_item, item );
933 menu.RefreshQuickbar();
937 else if ( receiver_item.GetInventory().CanAddEntityInCargo( item, item.GetInventory().GetFlipCargo() ) && !receiver_item.GetInventory().HasEntityInCargo( item ) )
943 menu.RefreshQuickbar();
947 else if ( (
ItemBase.Cast( receiver_item ) ).CanBeCombined(
ItemBase.Cast( item ) ) )
954 if (
m_Player.GetInventory().CanAddAttachmentEx( item, slot_id ) )
956 if (item.GetQuantity() > item.GetTargetQuantityMax(slot_id))
958 item.SplitIntoStackMaxClient( real_player, slot_id );
962 real_player.PredictiveTakeEntityToTargetAttachmentEx(
m_Player, item, slots_icon.
GetSlotID() );
965 else if (
m_Player.GetInventory().CanAddAttachment( item ) )
969 float stackable = item.GetTargetQuantityMax(-1);
973 if ( stackable == 0 || stackable >= item.GetQuantity() )
975 real_player.PredictiveTakeEntityToTargetAttachment( il.
GetParent(), item );
980 ItemBase.Cast(item).SplitIntoStackMaxToInventoryLocationClient( il );
991 menu.RefreshQuickbar();
1000 if( item1 && item2 )
1004 if( cont1 && cont2 )
1006 int sort1 = cont1.GetRootWidget().GetSort();
1007 int sort2 = cont2.GetRootWidget().GetSort();
1009 cont1.GetRootWidget().SetSort( sort2 );
1010 cont2.GetRootWidget().SetSort( sort1 );
1012 m_Body.SwapItems( m_Body.Find( cont1 ), m_Body.Find( cont2 ) );
1015 RecomputeOpenedContainers();
1043 item.GetInventory().GetCurrentInventoryLocation( il );
1073 string name = w.GetName();
1079 RecomputeOpenedContainers();
1087 super.CollapseButtonOnMouseButtonDown(w);
1092 if( GetFocusedContainer() && ( GetFocusedContainer().IsInherited( ContainerWithCargo ) || GetFocusedContainer().IsInherited( ContainerWithCargoAndAttachments ) ) )
1103 m_MainWidget.Update();
1105 UpdateSelectionIcons();
void Inventory(LayoutHolder parent)
FindInventoryLocationType
flags for searching locations in inventory
override void CombineItemsClient(EntityAI entity2, bool use_stack_max=true)
PluginBase GetPlugin(typename plugin_type)
ref Widget m_RootWidget[MAX_SIMULTANIOUS_PLAYERS]
override void SetHeader(Header header)
SlotsIcon GetSlotsIcon(int row, int column, bool include_invisible=true)
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.
proto native bool ConfigIsExisting(string path)
override bool IsDisplayable()
protected ref CollapsibleHeader m_CollapsibleHeader
override void Remove(LayoutHolder container)
override Header GetHeader()
override void SetHeader(Header header)
static ColorManager GetInstance()
void SetColor(Widget w, int color)
override void UnfocusAll()
override void UpdateInterval()
script counterpart to engine's class Inventory
static bool CanSwapEntitiesEx(notnull EntityAI item1, notnull EntityAI item2)
bool CombineItems(EntityAI entity1, EntityAI entity2)
proto native bool IsValid()
verify current set inventory location
proto native EntityAI GetParent()
returns parent of current inventory location
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 owned string GetSlotDisplayName(int id)
converts slot_id to string
EntityAI GetSelectedItem()
HandsPreview GetHandsPreview()
void SetWidgetDraggable(Widget w, bool draggable)
void SetSelectedItem(EntityAI selected_item, Container selected_container, Widget selected_widget, SlotsIcon selected_icon)
Widget GetRightDropzone()
void SetIsDragging(bool is_dragging)
static ItemManager GetInstance()
bool HasEntityContainerVisible(EntityAI entity)
override void DraggingOver(Widget w, int x, int y, Widget receiver)
override bool IsItemActive()
override bool OnChildAdd(Widget w, Widget child)
override bool InspectItem()
float GetMainContainerBottomPos()
protected ref AttachmentsGroupContainer m_PlayerAttachmentsContainer
protected ref map< int, SlotsIcon > m_InventorySlots
void ToggleContainer(Widget w, EntityAI item)
void ToggleWidget(Widget w)
void OnDropReceivedFromGhostArea(Widget w, int x, int y, Widget receiver)
override void UpdateInterval()
bool IsItemWithAttachmentsActive()
override bool TransferItem()
bool IsPlayerEquipmentActive()
protected ref map< int, ref Container > m_ShowedItemsIDs
ItemPreviewWidget GetItemPreviewWidget(Widget w)
override bool TransferItemToVicinity()
override void OnDropReceivedFromHeader(Widget w, int x, int y, Widget receiver)
void PlayerContainer(LayoutHolder parent, int sort=-1)
override bool CanOpenCloseContainerEx(EntityAI focusedEntity)
override bool OnChildRemove(Widget w, Widget child)
override void UpdateRadialIcon()
void MouseClick(Widget w, int x, int y, int button)
void DoubleClick(Widget w, int x, int y, int button)
void SetPlayer(PlayerBase player)
override void ExpandCollapseContainer()
override void DraggingOverHeader(Widget w, int x, int y, Widget receiver)
protected PlayerBase m_Player
SlotsIcon GetSlotsIcon(int row, int column)
override bool EquipItem()
override bool IsItemWithQuantityActive()
bool IsItemWithContainerActive()
void AddSlotsContainer(int row_count)
override void CollapseButtonOnMouseButtonDown(Widget w)
void SwapItemsInOrder(int slot1, int slot2)
protected ref map< EntityAI, ref Container > m_ShowedItems
override void Insert(LayoutHolder container, int pos=-1, bool immedUpdate=true)
void ItemAttached(EntityAI item, string slot_name)
void OnAttachmentReservationSet(EntityAI item, int slot_id)
protected const int HEADER_INDEX_OFFSET
void ItemDetached(EntityAI item, string slot_name)
void OnAttachmentReservationRelease(EntityAI item, int slot_id)
bool IsContainerWithCargoActive()
override EntityAI GetFocusedItem()
void UnfocusPlayerAttachmentsContainer()
override bool SplitItem()
float GetMainContainerTopPos()
int GetRecipeCount(bool recipe_anywhere, EntityAI entity1, EntityAI entity2)
static int HasItemQuantity(notnull EntityAI item)
void SetSlotDisplayName(string text)
Widget GetRadialIconPanel()
override void UpdateInterval()
void SetSlotParent(EntityAI parent)
ImageWidget GetGhostSlot()
void SetSlotID(int slot_ID)
void Init(EntityAI obj, bool reservation=false)
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()
proto int Replace(string sample, string replace)
Replace all occurrances of 'sample' in 'str' by 'replace'.