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);
39 #ifndef PLATFORM_CONSOLE
58 string config_path_ghosts_slots =
"CfgVehicles SurvivorBase InventoryEquipment playerSlots";
60 GetGame().ConfigGetTextArray( config_path_ghosts_slots, player_ghosts_slots );
62 for (
int i = 0; i < player_ghosts_slots.Count(); i++ )
64 string slot_name = player_ghosts_slots.Get ( i );
65 string path =
"CfgSlots" +
" " + slot_name;
70 GetGame().ConfigGetText(
path +
" ghostIcon", icon_name );
78 if( row < ( player_ghosts_slots.Count() /
ITEMS_IN_ROW ) )
86 icon.GetMainWidget().Show(
true );
101 GetGame().ConfigGetText(
path +
" name", slot_name );
110 RecomputeOpenedContainers();
132 m_Player.GetOnAttachmentReleaseLock().Invoke(item, slot);
139 int sort_index =
Inventory.GetPlayerAttachmentIndex( slot );
140 int current_sort = 9999;
141 if( GetFocusedContainer() )
142 current_sort = GetFocusedContainer().GetRootWidget().GetSort();
144 if( item.GetSlotsCountCorrect() > 0 )
146 ContainerWithCargoAndAttachments iwca =
new ContainerWithCargoAndAttachments(
this, sort_index );
147 iwca.SetEntity( item );
148 iwca.SetSlotIcon( icon );
151 if( iwca.IsDisplayable() )
156 RecomputeOpenedContainers();
159 else if( item.GetInventory().GetCargo() )
161 ContainerWithCargo iwc =
new ContainerWithCargo(
this, sort_index );
162 iwc.SetEntity( item );
163 iwc.SetSlotIcon( icon );
164 iwc.UpdateInterval();
167 RecomputeOpenedContainers();
168 if( iwc.IsDisplayable() )
176 string config =
"CfgVehicles " + item.GetType() +
" GUIInventoryAttachmentsProps";
179 bool show_radial_icon = ( item.GetInventory().GetCargo() || item.GetSlotsCountCorrect() > 0 ) && !
GetGame().ConfigIsExisting( config );
182 rip.Show( show_radial_icon );
183 SetOpenForSlotIcon(conta.
IsOpened(),icon);
186 UpdateSelectionIcons();
199 (
Container.Cast( con.m_Parent ) ).Remove( con );
200 RecomputeOpenedContainers();
201 GetMainWidget().Update();
209 in.UpdateConsoleToolbar();
211 UpdateSelectionIcons();
220 icon.
Init( item,
true );
233 container.SetColumnCount(row_count);
257 #ifdef DIAG_DEVELOPER
259 ShowActionMenu(selectedItem);
264 GetGame().GetPlayer().GetHumanInventory().ClearUserReservedLocationSynced(selectedItem);
279 if (
g_Game.IsLeftCtrlDown())
281 if (controlledPlayer.CanDropEntity(selectedItem))
283 if (selectedItem.GetTargetQuantityMax() < selectedItem.GetQuantity())
284 selectedItem.SplitIntoStackMaxClient(null, -1);
286 controlledPlayer.PhysicalPredictiveDropItem(selectedItem);
291 bool draggable = !
m_Player.GetInventory().HasInventoryReservation(selectedItem, null ) && !
m_Player.GetInventory().IsInventoryLocked() && selectedItem.GetInventory().CanRemoveEntity() && !
m_Player.IsItemsToDelete();
303 GetRootWidget().GetScreenPos(
x,
y );
311 GetRootWidget().GetScreenPos(
x,
y );
312 GetRootWidget().GetScreenSize( x2, y2 );
320 if (c_cont && m_Body.Count() > 1)
324 int curr_sort = c_cont.GetRootWidget().GetSort();
327 int prev_sort = prev.GetRootWidget().GetSort();
328 if ( prev_sort > curr_sort )
331 if ( ++index < m_Body.Count() )
337 m_Body.InsertAt( container, index );
341 m_Body.Insert( container );
345 RecomputeOpenedContainers();
351 return ent && ( ent.GetInventory().GetCargo() || ent.GetSlotsCountCorrect() > 0 );
383 if( w == null ||
m_Player.GetInventory().IsInventoryLocked() )
390 string name = w.GetName();
391 name.Replace(
"PanelWidget",
"Render" );
407 iw.GetUserData(icon);
414 if( !item.GetInventory().CanRemoveEntity() )
417 if ( player.GetInventory().HasEntityInInventory( item ) && player.GetHumanInventory().CanAddEntityInHands( item ) )
419 player.PredictiveTakeEntityToHands( item );
423 if (player.GetInventory().CanAddEntityToInventory( item ) && item.GetInventory().CanRemoveEntity())
425 if( item.GetTargetQuantityMax() < item.GetQuantity() )
426 item.SplitIntoStackMaxClient( player, -1 );
432 if( item.GetTargetQuantityMax() < item.GetQuantity() )
433 item.SplitIntoStackMaxHandsClient( player );
435 player.PredictiveTakeEntityToHands( item );
444 menu.RefreshQuickbar();
459 return GetFocusedContainer().IsInherited( ContainerWithCargo );
464 return GetFocusedContainer().IsInherited( ContainerWithCargoAndAttachments );
471 if (GetFocusedContainer().IsInherited( ContainerWithCargo ) || GetFocusedContainer().IsInherited( ContainerWithCargoAndAttachments ))
473 return GetFocusedContainer().TransferItemToVicinity();
477 Man player =
GetGame().GetPlayer();
479 if ( item && player.CanDropEntity( item ) )
481 if ( item.GetTargetQuantityMax() < item.GetQuantity() )
482 item.SplitIntoStackMaxClient( null, -1 );
484 player.PhysicalPredictiveDropItem( item );
494 if( GetFocusedContainer().IsInherited( ContainerWithCargo ) || GetFocusedContainer().IsInherited( ContainerWithCargoAndAttachments ) )
496 return GetFocusedContainer().InspectItem();
500 Man player =
GetGame().GetPlayer();
513 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(
GetPlugin( PluginRecipesManager ) );
519 if (CanTakeToInventory())
525 if (GetFocusedContainer().IsInherited( ContainerWithCargo ) || GetFocusedContainer().IsInherited( ContainerWithCargoAndAttachments ))
527 return GetFocusedContainer().TransferItem();
541 if (!GetFocusedContainer().IsInherited( ContainerWithCargo ) && !GetFocusedContainer().IsInherited( ContainerWithCargoAndAttachments ))
557 return GetFocusedContainer().GetFocusedItem();
564 if ( GetFocusedContainer() && ( GetFocusedContainer().IsInherited( ContainerWithCargo ) || GetFocusedContainer().IsInherited( ContainerWithCargoAndAttachments ) ) )
566 return GetFocusedContainer().Combine();
575 if( item_in_hands && item )
586 if( GetFocusedContainer().IsInherited( ContainerWithCargo ) || GetFocusedContainer().IsInherited( ContainerWithCargoAndAttachments ) )
588 return GetFocusedContainer().Select();
594 SlotsIcon focused_slot = GetFocusedSlotsIcon();
596 if( focused_slot.
IsReserved() || focused_item != selected_item )
600 if( selected_item.GetInventory().CanRemoveEntity() )
602 if (
m_Player.GetInventory().CanAddAttachmentEx( selected_item, focused_slot.
GetSlotID() ))
604 player.PredictiveTakeEntityToTargetAttachmentEx(
m_Player, selected_item, focused_slot.
GetSlotID());
610 else if (
m_Player.GetInventory().CanAddAttachment( selected_item ))
612 player.PredictiveTakeEntityToTargetAttachment(
m_Player, selected_item );
621 if( focused_item && focused_item.GetInventory().CanRemoveEntity() )
623 EntityAI item_in_hands = player.GetHumanInventory().GetEntityInHands();
624 if( item_in_hands && item_in_hands.GetInventory().CanRemoveEntity() )
628 player.PredictiveSwapEntities( item_in_hands, focused_item );
638 if ( player.NeedInventoryJunctureFromServer(item_in_hands, item_in_hands.GetHierarchyParent(), il_hands_dst.GetParent()) ||
GetGame().
GetPlayer().NeedInventoryJunctureFromServer(focused_item, focused_item.GetHierarchyParent(),
GetGame().
GetPlayer()) )
641 player.GetHumanInventory().ForceSwapEntities( invMode, focused_item, item_in_hands, il_hands_dst );
648 if( player.GetHumanInventory().CanAddEntityInHands( focused_item ) )
650 player.PredictiveTakeEntityToHands( focused_item );
681 string config_path_ghosts_slots =
"CfgVehicles SurvivorBase InventoryEquipment playerSlots";
683 GetGame().ConfigGetTextArray( config_path_ghosts_slots, player_ghosts_slots );
685 for (
int i = 0; i < player_ghosts_slots.Count(); i++ )
687 string slot_name = player_ghosts_slots.Get ( i );
695 icon.GetMainWidget().Show(
true );
698 GetGame().ConfigGetText(
"CfgSlots" +
" " + slot_name +
" name", slot_name );
722 if( !item.GetInventory().CanRemoveEntity() )
736 string name = w.GetName();
737 name.Replace(
"PanelWidget",
"Render" );
790 bool is_reserved =
false;
793 receiver.GetUserData(slots_icon);
814 if( receiver_item && !is_reserved )
823 else if( receiver_item.GetInventory().CanAddAttachment(item) || receiver_item.GetInventory().CanAddEntityInCargo( item, item.GetInventory().GetFlipCargo() ) && !receiver_item.GetInventory().HasEntityInCargo( item ))
830 else if( (
ItemBase.Cast( receiver_item ) ).CanBeCombined(
ItemBase.Cast( item ) ) )
840 if( item.GetInventory().CanRemoveEntity() )
842 if(
m_Player.GetInventory().CanAddAttachment( item) )
882 bool is_reserved =
false;
888 receiver.GetUserData(slots_icon);
906 if ( receiver_item && !is_reserved )
910 GetGame().GetPlayer().PredictiveSwapEntities( item, receiver_item );
914 menu.RefreshQuickbar();
918 else if ( receiver_item.GetInventory().CanAddAttachment( item ) )
920 GetGame().GetPlayer().PredictiveTakeEntityToTargetAttachment( receiver_item, item );
924 menu.RefreshQuickbar();
928 else if ( receiver_item.GetInventory().CanAddEntityInCargo( item, item.GetInventory().GetFlipCargo() ) && !receiver_item.GetInventory().HasEntityInCargo( item ) )
930 SplitItemUtils.TakeOrSplitToInventory(real_player, receiver_item,item);
934 menu.RefreshQuickbar();
938 else if ( (
ItemBase.Cast( receiver_item ) ).CanBeCombined(
ItemBase.Cast( item ) ) )
940 (
ItemBase.Cast( receiver_item ) ).CombineItemsClient(
ItemBase.Cast( item ) );
945 if (
m_Player.GetInventory().CanAddAttachmentEx( item, slot_id ) )
947 if (item.GetQuantity() > item.GetTargetQuantityMax(slot_id))
949 item.SplitIntoStackMaxClient( real_player, slot_id );
953 real_player.PredictiveTakeEntityToTargetAttachmentEx(
m_Player, item, slots_icon.
GetSlotID() );
956 else if (
m_Player.GetInventory().CanAddAttachment( item ) )
960 float stackable = item.GetTargetQuantityMax(-1);
964 if ( stackable == 0 || stackable >= item.GetQuantity() )
966 real_player.PredictiveTakeEntityToTargetAttachment( il.GetParent(), item );
971 ItemBase.Cast(item).SplitIntoStackMaxToInventoryLocationClient( il );
982 menu.RefreshQuickbar();
997 int sort1 = cont1.GetRootWidget().GetSort();
998 int sort2 = cont2.GetRootWidget().GetSort();
1000 cont1.GetRootWidget().SetSort( sort2 );
1001 cont2.GetRootWidget().SetSort( sort1 );
1003 m_Body.SwapItems( m_Body.Find( cont1 ), m_Body.Find( cont2 ) );
1006 RecomputeOpenedContainers();
1034 item.GetInventory().GetCurrentInventoryLocation( il );
1064 string name = w.GetName();
1065 name.Replace(
"PanelWidget",
"Render" );
1070 RecomputeOpenedContainers();
1078 super.CollapseButtonOnMouseButtonDown(w);
1083 if( GetFocusedContainer() && ( GetFocusedContainer().IsInherited( ContainerWithCargo ) || GetFocusedContainer().IsInherited( ContainerWithCargoAndAttachments ) ) )
1094 m_MainWidget.Update();
1096 UpdateSelectionIcons();
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
void Inventory(LayoutHolder parent)
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
override bool IsDisplayable()
ref CollapsibleHeader m_CollapsibleHeader
override Header GetHeader()
override void SetHeader(Header header)
override LayoutHolder Get(int x)
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)
provides access to slot configuration
void SetSelectedItemEx(EntityAI selected_item, Container selected_container, LayoutHolder selected_icon)
HandsPreview GetHandsPreview()
EntityAI GetSelectedItem()
Widget GetRightDropzone()
void SetWidgetDraggable(Widget w, bool draggable)
void SetIsDragging(bool is_dragging)
static ItemManager GetInstance()
override void ExpandCollapseContainer()
void OnAttachmentReservationRelease(EntityAI item, int slot_id)
override bool IsItemWithQuantityActive()
override void UpdateRadialIcon()
const int HEADER_INDEX_OFFSET
override bool OnChildRemove(Widget w, Widget child)
override bool OnChildAdd(Widget w, Widget child)
float GetMainContainerTopPos()
override void DraggingOver(Widget w, int x, int y, Widget receiver)
override bool InspectItem()
override void CollapseButtonOnMouseButtonDown(Widget w)
bool IsPlayerEquipmentActive()
void ItemAttached(EntityAI item, string slot_name)
SlotsIcon GetSlotsIcon(int row, int column)
override void Insert(LayoutHolder container, int pos=-1, bool immedUpdate=true)
void SetPlayer(PlayerBase player)
ref map< int, ref Container > m_ShowedItemsIDs
override EntityAI GetFocusedItem()
void ToggleWidget(Widget w)
override bool TransferItem()
void OnAttachmentReservationSet(EntityAI item, int slot_id)
bool HasEntityContainerVisible(EntityAI entity)
float GetMainContainerBottomPos()
bool IsItemWithContainerActive()
override void UpdateInterval()
void UnfocusPlayerAttachmentsContainer()
override void DraggingOverHeader(Widget w, int x, int y, Widget receiver)
override bool TransferItemToVicinity()
int GetRecipeCount(bool recipe_anywhere, EntityAI entity1, EntityAI entity2)
bool IsContainerWithCargoActive()
override bool CanOpenCloseContainerEx(EntityAI focusedEntity)
ref AttachmentsGroupContainer m_PlayerAttachmentsContainer
void MouseClick(Widget w, int x, int y, int button)
bool IsItemWithAttachmentsActive()
void AddSlotsContainer(int row_count)
void ToggleContainer(Widget w, EntityAI item)
void ItemDetached(EntityAI item, string slot_name)
void SwapItemsInOrder(int slot1, int slot2)
void PlayerContainer(LayoutHolder parent, int sort=-1)
void OnDropReceivedFromGhostArea(Widget w, int x, int y, Widget receiver)
override void OnDropReceivedFromHeader(Widget w, int x, int y, Widget receiver)
ItemPreviewWidget GetItemPreviewWidget(Widget w)
override bool IsItemActive()
void DoubleClick(Widget w, int x, int y, int button)
ref map< int, SlotsIcon > m_InventorySlots
ref map< EntityAI, ref Container > m_ShowedItems
void Init(EntityAI obj, bool reservation=false)
void SetSlotID(int slot_ID)
void SetSlotDisplayName(string text)
void SetSlotParent(EntityAI parent)
override void UpdateInterval()
Widget GetRadialIconPanel()
ImageWidget GetGhostSlot()
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
FindInventoryLocationType
flags for searching locations in inventory
PluginBase GetPlugin(typename plugin_type)
ref Widget m_RootWidget[MAX_SIMULTANIOUS_PLAYERS]