61 SCR_InventoryStorageManagerComponent m_pStorageMan;
63 BaseInventoryStorageComponent m_pStorageToDrop;
64 BaseInventoryStorageComponent m_pStorageToPickUp;
69 ResourceName m_sItemToFocus;
72 bool m_bUpdateSlotOnly;
73 bool m_bShouldUpdateQuickSlots;
75 void InternalComplete()
80 protected override void OnFailed()
82 if (m_pMenu && m_pItem && m_bShouldEquip)
84 m_pMenu.GetCharacterController().TryEquipRightHandItem(m_pItem,
EEquipItemType.EEquipTypeWeapon,
false);
85 m_bShouldEquip =
false;
89 m_pMenu.Action_DeselectItem();
93 protected override void OnComplete()
95 if (m_pMenu && m_pItem && m_bShouldEquip)
97 m_pMenu.GetCharacterController().TryEquipRightHandItem(m_pItem,
EEquipItemType.EEquipTypeWeapon,
false);
98 m_bShouldEquip =
false;
109 m_pStorageMan.PlayItemSound(m_pItem,
SCR_SoundEvent.SOUND_UNEQUIP);
114 bool shouldUpdateStorageList;
115 if ( m_pStorageFrom )
119 if ( m_pStorageFrom == m_pMenu.GetStorageList() )
121 shouldUpdateStorageList =
true;
125 if (m_bUpdateSlotOnly)
127 m_pStorageFrom.UpdateSlotUI(m_sItemToFocus);
128 m_bUpdateSlotOnly =
false;
132 BaseInventoryStorageComponent storage = m_pStorageFrom.GetCurrentNavigationStorage();
133 auto open = m_pMenu.GetOpenedStorage(storage);
139 auto itemStorage = BaseInventoryStorageComponent.Cast(m_pItem.FindComponent(BaseInventoryStorageComponent));
140 open = m_pMenu.GetOpenedStorage(itemStorage);
146 m_pStorageFrom.Refresh();
155 shouldUpdateStorageList =
true;
163 if ( m_pStorageTo == m_pMenu.GetStorageList() )
165 shouldUpdateStorageList =
true;
167 auto itemStorage = BaseInventoryStorageComponent.Cast(m_pItem.FindComponent(BaseInventoryStorageComponent));
174 m_pStorageTo.Refresh();
175 BaseInventoryStorageComponent storage = m_pStorageTo.GetCurrentNavigationStorage();
176 auto open = m_pMenu.GetOpenedStorage(storage);
183 if (shouldUpdateStorageList)
185 m_pMenu.ShowStoragesList();
186 m_pMenu.ShowAllStoragesInList();
191 if ( m_pStorageFrom != m_pMenu.GetLootStorage() && m_pStorageTo != m_pMenu.GetLootStorage() )
192 m_pMenu.RefreshLootUIListener();
198 pStorage = m_pMenu.GetStorageList();
202 m_pMenu.NavigationBarUpdate();
203 m_pMenu.RefreshPlayerWidget();
206 if (m_pStorageToFocus)
208 m_pMenu.FocusOnSlotInStorage(m_pStorageToFocus, m_iSlotToFocus);
215 if (m_pStorageToDrop)
217 if (m_pMenu && m_bShouldUpdateQuickSlots)
218 m_pMenu.ShowQuickSlotStorage();
219 m_pStorageToDrop =
null;
222 if (m_pStorageToPickUp)
224 if (m_pMenu && m_bShouldUpdateQuickSlots)
225 m_pMenu.ShowQuickSlotStorage();
226 m_pStorageToPickUp =
null;
229 m_bShouldUpdateQuickSlots =
false;
235 protected void ResetVariables()
237 m_pStorageToFocus =
null;
239 m_pStorageFrom =
null;
250 #ifndef DISABLE_INVENTORY
251 static protected ResourceName m_ItemPreviewManagerPrefab =
"{9F18C476AB860F3B}Prefabs/World/Game/ItemPreviewManager.et";
252 protected SCR_InventoryStorageManagerComponent m_InventoryManager =
null;
253 protected SCR_CharacterInventoryStorageComponent m_StorageManager =
null;
254 protected ChimeraCharacter m_Player;
255 protected Widget m_wContainer;
256 protected Widget m_wStorageList, m_wGadgetStorage, m_wLootStorage, m_wOpenedStorage, m_wWeaponSlots;
257 protected Widget m_wAttachmentStorage;
258 protected Widget m_widget;
275 protected EquipedWeaponStorageComponent m_pWeaponStorageComp =
null;
276 protected ref array<SCR_InventoryOpenedStorageUI> m_aOpenedStoragesUI = {};
284 protected ref array<SCR_InventorySlotUI> m_aShownStorages =
new array<SCR_InventorySlotUI>();
285 protected GridLayoutWidget m_wStoragesContainer;
286 protected const int STORAGE_AREA_COLUMNS = 2;
287 protected int m_iStorageListCounter = 0;
288 protected int m_iVicinityDiscoveryRadius = 0;
293 protected Widget m_wAttachmentContainer =
null;
295 protected ProgressBarWidget m_wProgressBarWeight;
296 protected ProgressBarWidget m_wProgressBarWeightItem;
298 const string ARSENAL_STORAGE_LAYOUT =
"{1DA3820E61D50EA1}UI/layouts/Menus/Inventory/ArsenalInventoryContainerGrid.layout";
299 const string BACKPACK_STORAGE_LAYOUT =
"{06E9285D68D190EF}UI/layouts/Menus/Inventory/InventoryContainerGrid.layout";
300 const string WEAPON_STORAGE_LAYOUT =
"{7B28D87B8A1ADD41}UI/layouts/Menus/Inventory/InventoryWeaponSlots.layout";
301 const string GADGETS_STORAGE_LAYOUT =
"{265189B87ED5CD10}UI/layouts/Menus/Inventory/InventoryGadgetsPanel.layout";
302 const string STORAGES_LIST_LAYOUT =
"{FC579324F5E4B3A3}UI/layouts/Menus/Inventory/InventoryCharacterGrid.layout";
303 const string ITEM_INFO =
"{AE8B7B0A97BB0BA8}UI/layouts/Menus/Inventory/InventoryItemInfo.layout";
304 const string DAMAGE_INFO =
"{55AFA256E1C20FB2}UI/layouts/Menus/Inventory/InventoryDamageInfo.layout";
305 const string ACTION_LAYOUT =
"{81BB7785A3987196}UI/layouts/Menus/Inventory/InventoryActionNew.layout";
307 const string STORAGE_LAYOUT_CLOSE_WIDGET_NAME =
"CloseStorageBtn";
309 const ResourceName HITZONE_CONTAINER_LAYOUT=
"{36DB099B4CDF8FC2}UI/layouts/Menus/Inventory/Medical/HitZonePointContainer.layout";
311 [
Attribute(
"{01E150D909447632}Configs/Damage/DamageStateConfig.conf",
desc:
"Config to get visual data from",
params:
"conf class=SCR_DamageStateConfig")]
317 protected string m_sFSMStatesNames[10]={
"init",
"idle",
"item selected",
"storage selected",
"STATE_STORAGE_OPENED",
"storage unfolded",
"move started",
"move finished",
"closing",
"STATE_UNKNOWN" };
321 protected ResourceName m_sSupplyCostUIInfoPrefab =
"{4D8296CB3CB3B8BF}Configs/Inventory/SupplyCost_ItemUIInfo.conf";
325 protected IEntity m_pItem;
326 protected BaseInventoryStorageComponent m_pDisplayedStorage, m_pLastCurrentNavStorage;
327 protected BaseInventoryStorageComponent m_pStorageFrom, m_pStorageTo;
330 protected SCR_CharacterVicinityComponent m_pVicinity;
333 protected ButtonWidget m_wButtonShowAll;
335 protected ItemPreviewManagerEntity m_pPreviewManager;
336 protected bool m_bDraggingEnabled;
337 protected FrameWidget m_wDragDropContainer;
340 protected ref array<SCR_InventoryStorageBaseUI> m_aStorages = {};
341 protected TextWidget m_wTotalWeightText;
342 protected bool m_bLocked =
false;
346 protected Widget m_wQuickSlotStorage;
348 const int WEAPON_SLOTS_COUNT = 4;
350 protected bool m_bIsUsingGamepad;
351 protected float m_fX, m_fY;
352 protected bool m_bShowIt =
true;
353 protected int m_iMouseX, m_iMouseY
354 const int DRAG_THRESHOLD = 5;
358 protected Widget m_wCharFeatureBleeding;
359 protected Widget m_wCharFeatureWounded;
361 protected ref array<HitZone> m_aBleedingHitZones = {};
363 protected bool m_bWasJustTraversing;
364 protected bool m_bStorageSwitchMode;
367 protected Widget m_wAttachmentPointsContainer;
368 protected ref array<SCR_InventoryHitZonePointContainerUI> m_aHitZonePoints = {};
370 protected SCR_InventoryHitZonePointUI m_bleedingHandlerGlobal;
371 protected SCR_InventoryHitZonePointUI m_fractureHandlerGlobal;
376 protected const int CHARACTER_HITZONES_COUNT = 7;
380 protected bool m_bProcessInitQueue =
false;
385 ItemPreviewManagerEntity GetItemPreviewManager()
387 return m_pPreviewManager;
391 protected void InitializeCharacterHitZones()
393 if (m_AttachmentSpinBox)
394 m_AttachmentSpinBox.ClearAll();
396 Widget bleeding = m_widget.FindAnyWidget(
"BleedingGlobal");
397 Widget fracture = m_widget.FindAnyWidget(
"FractureGlobal");
398 Widget morphineTimer = m_widget.FindAnyWidget(
"MorphineTimer");
399 Widget salineTimer = m_widget.FindAnyWidget(
"SalineTimer");
404 m_bleedingHandlerGlobal = SCR_InventoryHitZonePointUI.Cast(bleeding.FindHandler(SCR_InventoryHitZonePointUI));
407 m_fractureHandlerGlobal = SCR_InventoryHitZonePointUI.Cast(fracture.FindHandler(SCR_InventoryHitZonePointUI));
416 protected bool InitHitZones()
418 int hzToInit = m_aHitZonePoints.Count();
419 if (hzToInit == CHARACTER_HITZONES_COUNT)
422 Widget w =
GetGame().GetWorkspace().CreateWidgets(HITZONE_CONTAINER_LAYOUT, m_wAttachmentPointsContainer);
424 point.InitializeHitZoneUI(m_pStorageListUI.GetStorage(),
this, hzToInit + 1,
m_Player);
425 m_aHitZonePoints.Insert(point);
431 protected void HideCharacterHitZones()
433 if (m_AttachmentSpinBox)
434 m_AttachmentSpinBox.ClearAll();
435 if (m_bleedingHandlerGlobal)
436 m_bleedingHandlerGlobal.GetRootWidget().SetVisible(
false);
438 if (m_fractureHandlerGlobal)
439 m_fractureHandlerGlobal.GetRootWidget().SetVisible(
false);
441 if (m_morphineTimerHandlerGlobal)
442 m_morphineTimerHandlerGlobal.GetRootWidget().SetVisible(
false);
444 if (m_salineTimerHandlerGlobal)
445 m_salineTimerHandlerGlobal.GetRootWidget().SetVisible(
false);
449 point.GetRootWidget().RemoveFromHierarchy();
452 m_aHitZonePoints.Clear();
457 protected void InitializeCharacterInformation()
460 charBloodHZ.GetOnDamageStateChanged().Insert(OnDamageStateChanged);
462 m_CharDamageManager.GetOnDamageOverTimeRemoved().Insert(OnDamageStateChanged);
463 m_CharDamageManager.GetOnDamageOverTimeAdded().Insert(OnDamageStateChanged);
464 m_CharDamageManager.GetOnDamageStateChanged().Insert(OnDamageStateChanged);
465 OnDamageStateChanged();
469 void AddItemToAttachmentSelection(
string item, Managed
data =
null)
473 if (m_AttachmentSpinBox.FindItem(item) < 0)
474 m_AttachmentSpinBox.AddItem(item,
false,
data);
480 void RemoveItemFromAttachmentSelection(
string item)
482 int index = m_AttachmentSpinBox.FindItem(item);
484 m_AttachmentSpinBox.RemoveItem(
index,
false);
486 if (m_pDamageInfo && m_pDamageInfo.GetName() == item)
487 m_pDamageInfo.Destroy();
495 return m_AttachmentSpinBox;
500 void OnDamageStateChanged()
505 bool bleedingVisible = (charBloodHZ.GetHealthScaled() <= charBloodHZ.GetDamageStateThreshold(
ECharacterBloodState.STRONG));
506 float bleedingAmount = Math.InverseLerp(
509 charBloodHZ.GetHealthScaled());
511 if (m_bleedingHandlerGlobal)
513 m_bleedingHandlerGlobal.GetRootWidget().SetVisible(bleedingVisible);
514 m_bleedingHandlerGlobal.SetBloodLevelProgress(bleedingAmount);
517 if (m_fractureHandlerGlobal)
518 m_fractureHandlerGlobal.GetRootWidget().SetVisible(m_CharDamageManager.GetMovementDamage() > 0);
520 if (m_morphineTimerHandlerGlobal)
524 m_morphineTimerHandlerGlobal.GetRootWidget().SetVisible(headHZ.GetDamageOverTime(
EDamageType.HEALING) < 0);
527 if (m_salineTimerHandlerGlobal)
528 m_salineTimerHandlerGlobal.GetRootWidget().SetVisible(charBloodHZ.GetDamageOverTime(
EDamageType.HEALING) < 0);
535 if ( m_aShownStorages.Find( pStorageUI ) > -1 )
539 m_aShownStorages.Insert( pStorageUI );
547 m_aShownStorages.RemoveItem( pStorageUI );
553 m_pPrevActiveStorageUI = m_pActiveStorageUI;
554 m_pActiveStorageUI = storageUI;
555 if( m_pActiveStorageUI )
557 m_pFocusedSlotUI = m_pActiveStorageUI.GetFocusedSlot();
563 protected float GetTotalWeight()
572 SCR_InventoryStorageManagerComponent GetInventoryStorageManager()
585 bool GetCanInteract()
587 if (GetInspectionScreen())
594 void RefreshPlayerWidget()
596 if (!m_pPreviewManager || m_pInspectedSlot)
599 m_pPreviewManager.SetPreviewItem(m_wPlayerRender,
m_Player, m_PlayerRenderAttributes,
true);
600 if (m_wPlayerRenderSmall)
601 m_pPreviewManager.SetPreviewItem(m_wPlayerRenderSmall,
m_Player, m_PlayerRenderAttributes);
604 protected bool ProcessInitQueue()
606 switch (m_eInitStage)
615 m_pNavigationBar.SetAllButtonEnabled(
false);
616 m_pNavigationBar.FillFromConfig();
617 NavigationBarUpdate();
629 ShowEquipedWeaponStorage();
641 ShowAllStoragesInList();
649 m_wPlayerRender.SetVisible(
true);
665 protected void OnQueueProcessed()
667 m_bProcessInitQueue =
false;
668 m_wAttachmentPointsContainer.SetVisible(
true);
669 UpdateCharacterPreview();
676 override void OnMenuUpdate(
float tDelta)
678 super.OnMenuUpdate(tDelta);
680 if (m_bProcessInitQueue)
682 if (!ProcessInitQueue())
686 if (m_InspectionScreen)
688 m_InspectionScreen.UpdateView(tDelta);
692 if (m_pCharacterWidgetHelper && m_pPreviewManager && m_PlayerRenderAttributes && m_pCharacterWidgetHelper.Update(tDelta, m_PlayerRenderAttributes))
701 if (m_pInspectedSlot)
702 UpdateGearInspectionPreview();
704 UpdateCharacterPreview();
708 protected void UpdateCharacterPreview()
710 if (!m_wPlayerRender)
713 m_pPreviewManager.SetPreviewItem(m_wPlayerRender,
m_Player, m_PlayerRenderAttributes);
715 for (
int i, count = m_aHitZonePoints.Count(); i < count; i++)
720 TNodeId
id = hp.GetBoneIndex();
723 Math3D.MatrixIdentity4(transform);
729 if (m_wPlayerRender.TryGetItemNodePositionInWidgetSpace(
id, transform, screenPos))
731 FrameSlot.SetPos(hp.GetRootWidget(), screenPos[0] + xOffset, screenPos[1]);
737 void UpdateGearInspectionPreview()
739 if (!m_pInspectedSlot)
753 m_pPreviewManager.SetPreviewItem(m_wPlayerRender, itemComp.GetOwner(), m_PlayerRenderAttributes,
true);
755 if (m_wPlayerRender && m_pGearInspectionPointUI)
756 m_pGearInspectionPointUI.UpdatePreviewSlotWidgets(m_wPlayerRender);
760 override void OnMenuOpen()
764 Action_CloseInventory();
772 m_bProcessInitQueue =
true;
774 if (m_pPreviewManager)
776 m_wPlayerRender =
ItemPreviewWidget.Cast( m_widget.FindAnyWidget(
"playerRender" ) );
777 auto collection = m_StorageManager.GetAttributes();
780 SizeLayoutWidget wPlayerRenderSmallRoot = SizeLayoutWidget.Cast( m_widget.FindAnyWidget(
"playerRenderSmallRoot" ) );
781 if ( wPlayerRenderSmallRoot )
782 m_wPlayerRenderSmall =
ItemPreviewWidget.Cast( wPlayerRenderSmallRoot.FindAnyWidget(
"item" ) );
787 Widget wrap = m_widget.FindAnyWidget(
"WrapLayoutShow" );
788 m_wButtonShowAll = ButtonWidget.Cast( wrap.FindAnyWidget(
"ItemButton" ) );
789 if( m_wButtonShowAll )
794 if( m_pNavigationBar )
795 m_pNavigationBar.m_OnAction.Insert(OnAction);
797 GetGame().GetInputManager().AddActionListener(
"Inventory_Drag", EActionTrigger.DOWN, Action_DragDown);
798 GetGame().GetInputManager().AddActionListener(
"Inventory", EActionTrigger.DOWN, Action_CloseInventory);
799 InitAttachmentSpinBox();
801 GetGame().OnInputDeviceIsGamepadInvoker().Insert(OnInputDeviceIsGamepad);
805 ResetHighlightsOnAvailableStorages();
807 UpdateTotalWeightText();
809 InitializeCharacterHitZones();
810 InitializeCharacterInformation();
811 UpdateCharacterPreview();
814 void InitAttachmentSpinBox()
816 if (m_AttachmentSpinBox)
818 m_AttachmentSpinBox.ClearAll();
822 Widget w = m_widget.FindAnyWidget(
"AttachmentSpinBox");
825 Print(
"Cannot find AttachmentSpinBox widget in hierarchy!", LogLevel.ERROR);
830 m_AttachmentSpinBox.m_OnChanged.Insert(NavigationBarUpdateGamepad);
835 protected void SetStorageSwitchMode(
bool enabled)
837 m_bStorageSwitchMode = enabled;
841 storage.ActivateStorageButton(m_bStorageSwitchMode);
844 m_pStorageLootUI.ActivateStorageButton(m_bStorageSwitchMode);
845 if (m_pStorageListUI)
846 m_pStorageListUI.ActivateStorageButton(m_bStorageSwitchMode);
850 storage.ActivateStorageButton(m_bStorageSwitchMode);
853 if (m_bStorageSwitchMode)
856 Widget btnToFocus = m_pStorageLootUI.GetButtonWidget();
857 if (m_pActiveStorageUI)
858 btnToFocus = m_pActiveStorageUI.GetButtonWidget();
859 GetGame().GetWorkspace().SetFocusedWidget(btnToFocus);
863 if (m_pActiveStorageUI)
865 m_pActiveStorageUI.ShowContainerBorder(
false);
866 FocusOnSlotInStorage(m_pActiveStorageUI);
870 NavigationBarUpdate();
874 protected void ToggleStorageSwitchMode()
876 SetStorageSwitchMode(!m_bStorageSwitchMode);
879 protected void SetAttachmentSpinBoxActive(
bool enable)
881 if (!m_AttachmentSpinBox)
884 int itemCount = m_AttachmentSpinBox.GetNumItems();
885 bool shouldBeActive = (enable && (itemCount > 0));
886 m_AttachmentSpinBox.SetEnabled(shouldBeActive);
887 m_AttachmentSpinBox.GetRootWidget().SetVisible(shouldBeActive);
889 Widget leftArea = m_widget.FindAnyWidget(
"LeftArea");
890 Widget rightArea = m_widget.FindAnyWidget(
"StoragesListSlot");
895 leftArea.SetNavigation(WidgetNavigationDirection.RIGHT, WidgetNavigationRuleType.EXPLICIT,
"AttachmentSpinBox");
896 rightArea.SetNavigation(WidgetNavigationDirection.LEFT, WidgetNavigationRuleType.EXPLICIT,
"AttachmentSpinBox");
897 m_AttachmentSpinBox.GetRootWidget().SetNavigation(WidgetNavigationDirection.RIGHT, WidgetNavigationRuleType.EXPLICIT,
"StoragesListSlot");
898 m_AttachmentSpinBox.GetRootWidget().SetNavigation(WidgetNavigationDirection.LEFT, WidgetNavigationRuleType.EXPLICIT,
"StorageLootSlot");
902 leftArea.SetNavigation(WidgetNavigationDirection.RIGHT, WidgetNavigationRuleType.EXPLICIT,
"StoragesListSlot");
903 rightArea.SetNavigation(WidgetNavigationDirection.LEFT, WidgetNavigationRuleType.EXPLICIT,
"StorageLootSlot");
913 array<SCR_InventorySlotUI> slots = {};
914 storage.GetSlots(slots);
915 return slots.IsIndexValid(slotIndex);
924 array<SCR_InventorySlotUI> slots = {};
925 storage.GetSlots(slots);
927 if (slots.IsIndexValid(slotIndex) && slots[slotIndex])
929 Widget slotToFocus = slots[slotIndex].GetButtonWidget();
932 while (slots.IsIndexValid(++slotIndex) && !slotToFocus)
934 slotToFocus = slots[slotIndex].GetButtonWidget();
938 GetGame().GetWorkspace().SetFocusedWidget(slotToFocus);
942 int slotToFocus = (slots.Count()-1);
943 if (slots.IsIndexValid(slotToFocus) && slots[slotToFocus])
944 GetGame().GetWorkspace().SetFocusedWidget(slots[slotToFocus].GetButtonWidget());
946 GetGame().GetWorkspace().SetFocusedWidget(
null);
952 protected bool Init()
956 if ( m_widget ==
null )
959 Widget loading = m_widget.FindAnyWidget(
"LoadingOverlay");
962 loading.SetVisible(
true);
967 PlayerController playerController =
GetGame().GetPlayerController();
968 if ( playerController !=
null )
970 m_Player = ChimeraCharacter.Cast(playerController.GetControlledEntity());
977 m_pPreviewManager = world.GetItemPreviewManager();
978 if (!m_pPreviewManager)
980 Resource rsc = Resource.Load(m_ItemPreviewManagerPrefab);
982 GetGame().SpawnEntityPrefabLocal(rsc, world);
984 m_pPreviewManager = world.GetItemPreviewManager();
997 gameMode.GetOnControllableDeleted().Insert(OnControllableDeleted);
1000 m_InventoryManager = SCR_InventoryStorageManagerComponent.Cast(
m_Player.FindComponent( SCR_InventoryStorageManagerComponent ) );
1001 m_StorageManager = SCR_CharacterInventoryStorageComponent.Cast(
m_Player.FindComponent( SCR_CharacterInventoryStorageComponent ) );
1002 if( !m_StorageManager )
1004 m_pWeaponStorageComp = EquipedWeaponStorageComponent.Cast(m_StorageManager.GetWeaponStorage());
1005 if( !m_pWeaponStorageComp )
1013 m_wProgressBarWeight = ProgressBarWidget.Cast( m_widget.FindAnyWidget(
"ProgressBarWeight" ) );
1014 if( m_wProgressBarWeight )
1016 m_wProgressBarWeight.SetMin( 0.0 );
1017 m_wProgressBarWeight.SetMax( m_StorageManager.GetMaxLoad() );
1021 m_wProgressBarWeightItem = ProgressBarWidget.Cast( m_widget.FindAnyWidget(
"ProgressBarWeightItem" ) );
1022 if( m_wProgressBarWeightItem )
1024 m_wProgressBarWeightItem.SetMin( 0.0 );
1025 m_wProgressBarWeightItem.SetMax( m_StorageManager.GetMaxLoad() );
1026 m_wProgressBarWeightItem.SetCurrent( 0.0 );
1029 Widget wNaviBar = m_widget.FindAnyWidget(
"Footer" );
1032 m_pVicinity = SCR_CharacterVicinityComponent.Cast(
m_Player.FindComponent(SCR_CharacterVicinityComponent));
1035 m_pVicinity.OnVicinityUpdateInvoker.Insert(RefreshLootUIListener);
1036 m_iVicinityDiscoveryRadius = m_pVicinity.GetDiscoveryRadius();
1037 IEntity itemOfInterest = m_pVicinity.GetItemOfInterest();
1038 if (itemOfInterest && itemOfInterest.IsInherited(SCR_ChimeraCharacter))
1040 SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(itemOfInterest);
1043 charCtrl.m_OnLifeStateChanged.Insert(OnLootedCharacterLifeStateChanged);
1047 m_wStoragesContainer = GridLayoutWidget.Cast( m_widget.FindAnyWidget(
"StorageGrid" ) );
1048 m_wTotalWeightText = TextWidget.Cast( m_widget.FindAnyWidget(
"TotalWeightText") );
1061 m_wDragDropContainer = FrameWidget.Cast( m_widget.FindAnyWidget(
"DragDropContainer" ) );
1062 if ( m_wDragDropContainer )
1065 m_pDragDropPreviewImage =
ItemPreviewWidget.Cast( m_wDragDropContainer.FindAnyWidget(
"item" ) );
1068 m_wAttachmentPointsContainer = m_widget.FindAnyWidget(
"AttachmentPoints");
1077 IEntity itemOfInterest = m_pVicinity.GetItemOfInterest();
1078 if (itemOfInterest && itemOfInterest.IsInherited(SCR_ChimeraCharacter))
1080 SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(itemOfInterest);
1083 charCtrl.m_OnLifeStateChanged.Remove(OnLootedCharacterLifeStateChanged);
1086 m_pVicinity.SetItemOfInterest(
null);
1087 RefreshLootUIListener();
1098 Action_CloseInventory();
1102 case "Inventory_UnassignFromQuickSlot":
1104 Action_QuickSlotUnassign();
1107 case "Inventory_EnterStorage":
1109 SetStorageSwitchMode(
false);
1112 case "Inventory_AssignToQuickSlot":
1114 Action_QuickSlotAssign();
1117 case "Inventory_Drop":
1119 Action_MoveBetween();
1122 case "Inventory_Equip":
1127 case "Inventory_Select":
1129 if (m_pAttachmentStorageUI && m_AttachmentSpinBox.IsFocused())
1131 FocusOnSlotInStorage(m_pAttachmentStorageUI);
1137 SetStorageSwitchMode(
false);
1140 if (m_pFocusedSlotUI && !m_pFocusedSlotUI.IsSlotSelected())
1141 Action_SelectItem();
1143 Action_DeselectItem();
1146 case "Inventory_Deselect":
1148 Action_DeselectItem();
1151 case "Inventory_OpenStorage":
1153 Action_UnfoldItem();
1156 case "Inventory_OpenNewStorage":
1158 Action_OpenContainer();
1161 case "Inventory_StepBack":
1163 Action_StepBack( pParentStorage, traverseStorageIndex );
1166 case "Inventory_Inspect":
1171 case "Inventory_Use":
1176 case "Inventory_Move":
1178 if (m_bStorageSwitchMode)
1183 else if (m_pSelectedSlotUI)
1189 Action_MoveItemToStorage();
1192 case "Inventory_Swap":
1194 if (m_bStorageSwitchMode)
1196 ToggleStorageSwitchMode();
1197 FocusOnSlotInStorage(m_pActiveStorageUI);
1200 Action_SwapItems(m_pSelectedSlotUI, m_pFocusedSlotUI);
1203 case "Inventory_DetachItem":
1207 hzContainer.RemoveTourniquetFromSlot();
1210 case "InventoryEscape":
1212 Action_TryCloseInventory();
1221 ShowEquipedWeaponStorage();
1222 if ( !m_pSelectedSlotStorageUI )
1227 m_pSelectedSlotStorageUI.SetSelected(
false );
1229 if ( m_pSelectedSlotUI )
1231 m_pSelectedSlotUI.SetSelected(
false );
1232 m_pSelectedSlotUI =
null;
1234 if ( m_pSelectedSlotStorageUI )
1235 m_pSelectedSlotStorageUI =
null;
1237 FilterOutStorages(
false );
1241 protected int CloseOpenedStorage()
1243 if ( !m_wContainer )
1245 return CloseStorage( m_wContainer );
1253 Widget w = pStorageUI.GetRootWidget();
1258 CloseLinkedStorages(pStorageUI.GetStorage());
1260 return CloseStorage( w );
1264 protected int CloseStorage( notnull Widget w )
1267 if ( !storageUIHandler )
1270 int iLastShownPage = storageUIHandler.GetLastShownPage();
1271 m_pLastCurrentNavStorage = storageUIHandler.GetCurrentNavigationStorage();
1272 w.RemoveHandler( storageUIHandler );
1273 w.RemoveFromHierarchy();
1275 return iLastShownPage;
1282 BaseInventoryStorageComponent pStorage = pSlot.GetAsStorage();
1288 pStorageUI.ToggleShow();
1295 if( !m_StorageManager )
1298 array<SCR_UniversalInventoryStorageComponent> pStorages =
new array<SCR_UniversalInventoryStorageComponent>();
1299 m_StorageManager.GetStorages( pStorages );
1301 if( pStorages.Count() == 0 )
1304 ShowStorage( pStorage );
1309 void ShowStorage( BaseInventoryStorageComponent storage,
LoadoutAreaType area =
null )
1311 if ( !m_wStoragesContainer )
1313 m_wContainer =
GetGame().GetWorkspace().CreateWidgets( BACKPACK_STORAGE_LAYOUT, m_wStoragesContainer );
1314 int iRow = Math.Floor( m_iStorageListCounter / STORAGE_AREA_COLUMNS );
1315 int iCol = m_iStorageListCounter % STORAGE_AREA_COLUMNS;
1316 m_iStorageListCounter++;
1318 m_wStoragesContainer.SetRowFillWeight( iRow, 0 );
1319 m_wStoragesContainer.SetColumnFillWeight( iCol, 0 );
1321 GridSlot.SetColumn( m_wContainer, iCol );
1322 GridSlot.SetRow( m_wContainer, iRow );
1323 GridSlot.SetColumnSpan( m_wContainer, 1 );
1324 GridSlot.SetRowSpan( m_wContainer, 1 );
1326 if ( !m_wContainer )
1328 if ( storage.Type() == ClothNodeStorageComponent )
1333 else if ( storage.Type() == EquipedWeaponStorageComponent )
1344 m_aStorages.Insert( m_pStorageBaseUI );
1348 void ShowVicinity(
bool compact =
false)
1352 Print(
"No vicnity component on character!", LogLevel.DEBUG);
1356 if ( m_wLootStorage )
1359 m_wLootStorage.RemoveFromHierarchy();
1362 Widget parent = m_widget.FindAnyWidget(
"StorageLootSlot" );
1363 m_wLootStorage =
GetGame().GetWorkspace().CreateWidgets( BACKPACK_STORAGE_LAYOUT, parent );
1364 if ( !m_wLootStorage )
1375 void ShowAttachmentStorage(InventorySearchPredicate searchPredicate,
bool closeOnly =
false)
1377 if (m_wAttachmentStorage)
1380 m_wAttachmentStorage.RemoveFromHierarchy();
1385 Widget parent = m_widget.FindAnyWidget(
"AttachmentStorage");
1389 m_wAttachmentStorage =
GetGame().GetWorkspace().CreateWidgets(BACKPACK_STORAGE_LAYOUT, parent);
1390 if (!m_wAttachmentStorage)
1394 m_wAttachmentStorage.AddHandler(handler);
1395 m_pAttachmentStorageUI = handler;
1399 void CloseAttachmentStorage()
1401 if (m_wAttachmentStorage)
1404 m_wAttachmentStorage.RemoveFromHierarchy();
1411 return m_pAttachmentStorageUI;
1417 CloseStorage(attStorage);
1422 void OpenStorageAsContainer(BaseInventoryStorageComponent storage,
bool showVicinity =
true,
bool hideCloseButton =
false)
1426 if (openedStorage.GetStorage() == storage)
1429 RemoveOpenStorage(openedStorage);
1436 Widget parent = m_widget.FindAnyWidget(
"OpenedStorages");
1441 newStorage =
GetGame().GetWorkspace().CreateWidgets(ARSENAL_STORAGE_LAYOUT, parent);
1443 newStorage =
GetGame().GetWorkspace().CreateWidgets(BACKPACK_STORAGE_LAYOUT, parent);
1445 newStorage.AddHandler(handler);
1447 ButtonWidget closeBtn = handler.ActivateCloseStorageButton();
1449 ScrollLayoutWidget scroll = ScrollLayoutWidget.Cast(m_widget.FindAnyWidget(
"LeftAreaScroll"));
1452 scroll.SetSliderPos(0, 0);
1454 m_aOpenedStoragesUI.Insert(handler);
1459 if (hideCloseButton)
1461 Widget closeButton = newStorage.FindAnyWidget(STORAGE_LAYOUT_CLOSE_WIDGET_NAME);
1463 closeButton.SetVisible(
false);
1466 OpenLinkedStorages(storage, showVicinity,
true);
1467 FocusOnSlotInStorage(handler);
1473 CloseStorage(openedStorage);
1474 m_aOpenedStoragesUI.RemoveItem(openedStorage);
1475 if (m_aOpenedStoragesUI.IsEmpty())
1482 void RefreshLootUIListener()
1484 if (!m_pVicinity || !m_pStorageLootUI)
1487 m_pStorageLootUI.Refresh();
1488 if (m_aOpenedStoragesUI.IsEmpty())
1491 vector playerOrigin =
m_Player.GetOrigin();
1492 vector entityBoundsMaxs, entityBoundsMins;
1494 for (
int index = m_aOpenedStoragesUI.Count() - 1;
index >= 0;
index--)
1496 storageUI = m_aOpenedStoragesUI.Get(
index);
1501 Vehicle vehicleRoot = Vehicle.Cast(storageUI.GetStorage().GetOwner().GetRootParent());
1503 vehicleRoot.GetWorldBounds(entityBoundsMins, entityBoundsMaxs);
1506 storageUI.GetStorage().GetOwner().GetWorldBounds(entityBoundsMins, entityBoundsMaxs);
1509 if (entityBoundsMins - entityBoundsMaxs == vector.Zero && !vehicleRoot)
1512 if (storageUI.GetStorage().GetOwner().GetParent())
1513 storageUI.GetStorage().GetOwner().GetParent().GetWorldBounds(entityBoundsMins, entityBoundsMaxs);
1516 if (entityBoundsMins - entityBoundsMaxs == vector.Zero)
1518 Print(
"SCR_InventoryMenuUI: RefreshLootUIListener storage owner has no bounds and it could not find a valid parent with bounds!", LogLevel.ERROR);
1519 RemoveOpenStorage(storageUI);
1524 if (!Math3D.IntersectionSphereAABB(playerOrigin, m_iVicinityDiscoveryRadius, entityBoundsMins, entityBoundsMaxs))
1525 RemoveOpenStorage(storageUI);
1530 void ShowStoragesList()
1532 if( m_wStorageList )
1535 m_wStorageList.RemoveFromHierarchy();
1538 Widget parent = m_widget.FindAnyWidget(
"StoragesListSlot" );
1539 m_wStorageList =
GetGame().GetWorkspace().CreateWidgets( STORAGES_LIST_LAYOUT, parent );
1541 if( !m_wStorageList )
1549 void ShowAllStoragesInList()
1551 m_iStorageListCounter = 0;
1552 array<SCR_InventorySlotUI> aSlotsUI = {};
1553 m_pStorageListUI.GetSlots( aSlotsUI );
1554 if ( !m_aStorages.IsEmpty() )
1560 CloseStorage( pStorage );
1563 SortSlotsByLoadoutArea( aSlotsUI );
1564 m_aStorages.Resize( aSlotsUI.Count() );
1571 BaseInventoryStorageComponent pStorage = pSlot.GetAsStorage();
1574 ShowStorage( pStorage, pSlot.GetLoadoutArea() );
1591 array<SCR_InventorySlotUI> slots = {};
1592 m_pStorageLootUI.GetSlots(slots);
1595 if (slot && slot.GetStorageComponent() == storage)
1596 return slot.GetStorageUI();
1605 IEntity storageOwner = storage.GetOwner();
1607 SCR_ArsenalInventoryStorageManagerComponent arsenalManagerComponent
1608 = SCR_ArsenalInventoryStorageManagerComponent.Cast(storageOwner.FindComponent(SCR_ArsenalInventoryStorageManagerComponent));
1610 if (arsenalManagerComponent)
1613 SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.FindResourceComponent(storageOwner);
1615 if (resourceComponent)
1631 return m_pStorageLootUI;
1633 if (pStorage == m_pWeaponStorageComp)
1634 return m_pWeaponStorage;
1636 BaseInventoryStorageComponent parentStorage;
1638 if (pStorage && pStorage.GetParentSlot())
1639 parentStorage = pStorage.GetParentSlot().GetStorage();
1641 if (ClothNodeStorageComponent.Cast(parentStorage))
1645 if (pStorageUI && pStorageUI.GetStorage() == parentStorage)
1652 if (pStorageUI && pStorageUI.GetStorage() == pStorage)
1658 if (pStorageUI && pStorageUI.GetStorage() == pStorage)
1666 protected void SortSlotsByLoadoutArea( out array<SCR_InventorySlotUI> aSlots )
1668 array<SCR_InventorySlotUI> tmpSlots = {};
1669 tmpSlots.Copy( aSlots );
1676 aSlots.Insert(pSlotUI);
1681 protected void ShowGadgetStorage()
1683 if( m_wGadgetStorage && m_wContainer )
1686 m_wGadgetStorage.RemoveFromHierarchy();
1689 Widget parent = m_widget.FindAnyWidget(
"GadgetsGridSlot" );
1690 m_wGadgetStorage =
GetGame().GetWorkspace().CreateWidgets( GADGETS_STORAGE_LAYOUT, parent );
1692 if( !m_wGadgetStorage )
1700 protected void ShowEquipedWeaponStorage()
1703 if ( m_wWeaponSlots )
1706 m_wWeaponSlots.RemoveFromHierarchy();
1709 Widget parent = m_widget.FindAnyWidget(
"WeaponSlots" );
1710 m_wWeaponSlots =
GetGame().GetWorkspace().CreateWidgets( WEAPON_STORAGE_LAYOUT, parent );
1712 if ( !m_wWeaponSlots )
1718 m_pWeaponStorageComp = EquipedWeaponStorageComponent.Cast( m_pWeaponStorage.GetStorage() );
1722 void ShowItemInfo(
string sName =
"",
string sDescr =
"",
float sWeight = 0.0,
SCR_InventoryUIInfo uiInfo =
null )
1727 Widget infoWidget =
GetGame().GetWorkspace().CreateWidgets(ITEM_INFO, m_widget);
1738 Widget w = WidgetManager.GetWidgetUnderCursor();
1741 w = m_pFocusedSlotUI.GetButtonWidget();
1745 m_pItemInfo.SetName( sName );
1746 m_pItemInfo.SetDescription( sDescr );
1748 m_pItemInfo.SetWeight( sWeight );
1749 if (uiInfo && uiInfo.IsIconVisible())
1750 m_pItemInfo.SetIcon(uiInfo.GetIconPath(), uiInfo.GetIconColor());
1752 m_pItemInfo.ShowIcon(
false);
1754 array<SCR_InventoryItemHintUIInfo> hintsInfo = {};
1758 uiInfo.GetItemHintArray(hintsInfo);
1761 if (m_SupplyCostUIInfo)
1766 m_SupplyCostUIInfo.SetSupplyCost(arsenalSlot.GetItemSupplyCost());
1767 hintsInfo.InsertAt(m_SupplyCostUIInfo, 0);
1772 if (!hintsInfo.IsEmpty())
1773 m_pItemInfo.SetItemHints(m_pFocusedSlotUI.GetInventoryItemComponent(), hintsInfo, m_pFocusedSlotUI);
1775 int targetPosX, targetPosY;
1778 w.GetScreenPos(x, y);
1780 float width, height;
1781 w.GetScreenSize(width, height);
1784 m_pItemInfo.GetInfoWidget().Update();
1786 float screenSizeX, screenSizeY;
1787 GetGame().GetWorkspace().GetScreenSize(screenSizeX, screenSizeY);
1789 float infoWidth, infoHeight;
1790 m_pItemInfo.GetInfoWidget().GetScreenSize(infoWidth, infoHeight);
1793 targetPosY = y + height;
1795 float offsetX = (screenSizeX - infoWidth - targetPosX);
1797 targetPosX += offsetX;
1798 float offsetY = (screenSizeY - infoHeight - targetPosY);
1800 targetPosY += offsetY;
1803 GetGame().GetWorkspace().DPIUnscale(targetPosX),
1804 GetGame().GetWorkspace().DPIUnscale(targetPosY));
1810 Widget w = WidgetManager.GetWidgetUnderCursor();
1811 if (!w && m_AttachmentSpinBox)
1814 if (currentHZContainer)
1815 w = currentHZContainer.GetRootWidget().FindAnyWidget(
"HitZoneButton");
1835 m_pDamageInfo.SetName( sName );
1839 m_pDamageInfo.SetDamageStateVisible(damageInfo.m_bDamageIconVisible, damageInfo.m_bDamageRegenerating, damageInfo.m_sDamageIntensity, damageInfo.m_sDamageText);
1840 m_pDamageInfo.SetBleedingStateVisible(damageInfo.m_bBleedingIconVisible, damageInfo.m_sBleedingText);
1841 m_pDamageInfo.SetTourniquetStateVisible(damageInfo.m_bTourniquetIconVisible);
1842 m_pDamageInfo.SetSalineBagStateVisible(damageInfo.m_bSalineBagIconVisible);
1843 m_pDamageInfo.SetFractureStateVisible(damageInfo.m_bFractureIconVisible, damageInfo.m_bFractureIcon2Visible);
1846 int iMouseX, iMouseY;
1849 w.GetScreenPos(x, y);
1851 float width, height;
1852 w.GetScreenSize(width, height);
1854 float screenSizeX, screenSizeY;
1855 GetGame().GetWorkspace().GetScreenSize(screenSizeX, screenSizeY);
1857 float infoWidth, infoHeight;
1858 m_pDamageInfo.GetInfoWidget().GetScreenSize(infoWidth, infoHeight);
1861 iMouseY = y + height;
1862 if (x + infoWidth > screenSizeX)
1863 iMouseX = screenSizeX - infoWidth - width * 0.5;
1865 m_pDamageInfo.Move(
GetGame().GetWorkspace().DPIUnscale( iMouseX ),
GetGame().GetWorkspace().DPIUnscale( iMouseY ) );
1869 protected bool GetDamageInfo()
1878 return m_pDamageInfo;
1881 void DestroyDamageInfo()
1884 m_pItemInfo.Destroy();
1896 void HideDamageInfo()
1898 if ( !m_pDamageInfo )
1900 m_pDamageInfo.Hide();
1908 InputManager pInputManager =
GetGame().GetInputManager();
1909 if ( !( pInputManager && pInputManager.IsUsingMouseAndKeyboard() ) )
1911 if ( m_pActiveStorageUI != pFromStorageUI )
1913 if ( m_pActiveStorageUI )
1916 pFromStorageUI.SetSlotFocused( pLastFocusedSlot );
1917 if ( pLastFocusedSlot )
1920 GetGame().GetWorkspace().SetFocusedWidget( pLastFocusedSlot.GetButtonWidget(),
true );
1925 m_pActiveStorageUI = pFromStorageUI;
1929 m_pFocusedSlotUI = pFocusedSlot;
1930 SetFocusedSlotEffects();
1936 if ( m_pActiveStorageUI )
1937 m_pActiveStorageUI.SetLastFocusedSlot( pFocusedSlot );
1940 m_pFocusedSlotUI =
null;
1941 NavigationBarUpdate();
1947 protected void SetFocusedSlotEffects()
1949 if( !m_pFocusedSlotUI )
1951 if( m_wProgressBarWeightItem )
1952 m_wProgressBarWeightItem.SetCurrent( 0.0 );
1964 UIInfo itemInfo = attribs.GetUIInfo();
1972 ShowItemInfo( inventoryInfo.GetInventoryItemName(invItemComp), inventoryInfo.GetInventoryItemDescription(invItemComp), invItemComp.GetTotalWeight(), inventoryInfo);
1974 ShowItemInfo( itemInfo.GetName(), itemInfo.GetDescription(), invItemComp.GetTotalWeight(),
null);
1979 if( m_wProgressBarWeightItem )
1981 float weight = invItemComp.GetTotalWeight();
1982 m_wProgressBarWeightItem.SetCurrent( weight );
1985 NavigationBarUpdate();
1992 if ( !m_pActiveHoveredStorageUI )
1994 if ( m_pActiveHoveredStorageUI.GetFocusedSlot() == m_pFocusedSlotUI )
2003 if (!slot1 || !slot2)
2007 slot1.GetInventoryItemComponent().GetOwner(),
2008 slot2.GetInventoryItemComponent().GetOwner()
2015 if (!slot1 || !slot2)
2019 slot1.GetInventoryItemComponent().GetOwner(),
2020 slot2.GetStorageComponent()
2027 if (!slot1 || !slot2)
2031 slot1.GetInventoryItemComponent().GetOwner(),
2037 void NavigationBarUpdate()
2039 if (!m_pNavigationBar)
2044 NavigationBarUpdateGamepad();
2048 m_pNavigationBar.SetAllButtonEnabled(
false );
2049 m_pNavigationBar.SetButtonEnabled(
"ButtonBack",
true );
2052 m_pNavigationBar.SetButtonEnabled(
"ButtonRemoveTourniquet", (hzSlot && hzSlot.IsTourniquetted()));
2054 if ( !m_pFocusedSlotUI )
2058 if (itemComp && itemComp.GetOwner()
2059 && m_pActiveHoveredStorageUI != m_pStorageListUI
2060 && m_pActiveHoveredStorageUI != m_pStorageLootUI)
2062 bool canUse = m_StorageManager.CanUseItem_Inventory(itemComp.GetOwner());
2063 bool canEquip = m_StorageManager.CanEquipItem_Inventory(itemComp.GetOwner());
2065 m_pNavigationBar.SetButtonEnabled(
"ButtonUse", canUse);
2066 m_pNavigationBar.SetButtonEnabled(
"ButtonEquip", canEquip);
2069 if ( m_pFocusedSlotUI.GetStorageUI() == m_pQuickSlotStorage )
2071 if (m_pFocusedSlotUI.GetInventoryItemComponent())
2072 m_pNavigationBar.SetButtonEnabled(
"ButtonQuickSlotUnassign",
true);
2076 bool arsenalItem = IsStorageArsenal(m_pFocusedSlotUI.GetStorageUI().GetCurrentNavigationStorage());
2077 if (itemComp && itemComp.GetOwner() && !arsenalItem)
2078 m_pNavigationBar.SetButtonEnabled(
"ButtonInspect", (itemComp.GetOwner().FindComponent(SCR_WeaponAttachmentsStorageComponent) !=
null));
2080 m_pNavigationBar.SetButtonEnabled(
"ButtonSelect",
true );
2081 m_pNavigationBar.SetButtonEnabled(
"ButtonDrop", m_pFocusedSlotUI.IsDraggable() );
2083 bool flag = m_pFocusedSlotUI.GetStorageUI() == m_pStorageLootUI;
2084 bool isArsenal = IsStorageArsenal(m_pStorageLootUI.GetCurrentNavigationStorage());
2094 m_pNavigationBar.SetButtonEnabled(
"ButtonBuy", flag);
2095 m_pNavigationBar.SetButtonEnabled(
"ButtonSell", !flag);
2096 m_pNavigationBar.SetButtonEnabled(
"ButtonPickup",
false);
2097 m_pNavigationBar.SetButtonEnabled(
"ButtonDrop",
false);
2101 m_pNavigationBar.SetButtonEnabled(
"ButtonBuy",
false);
2102 m_pNavigationBar.SetButtonEnabled(
"ButtonSell",
false);
2103 m_pNavigationBar.SetButtonEnabled(
"ButtonPickup", flag);
2104 m_pNavigationBar.SetButtonEnabled(
"ButtonDrop", !flag);
2107 m_pNavigationBar.SetButtonEnabled(
"ButtonStepBack",
true );
2109 HandleSlottedItemFunction();
2113 void HandleSlottedItemFunction()
2115 string sAction =
"#AR-Inventory_Select";
2116 bool arsenalItem = IsStorageArsenal(m_pFocusedSlotUI.GetStorageUI().GetCurrentNavigationStorage());
2118 switch ( m_pFocusedSlotUI.GetSlotedItemFunction() )
2131 IEntity item = itemComp.GetOwner();
2135 WeaponComponent weaponComp = WeaponComponent.Cast(item.FindComponent(WeaponComponent));
2138 weaponComp.GetWeaponType() !=
EWeaponType.WT_FRAGGRENADE &&
2139 weaponComp.GetWeaponType() !=
EWeaponType.WT_SMOKEGRENADE &&
2140 weaponComp.Type() != SCR_MineWeaponComponent)
2142 m_pNavigationBar.SetButtonEnabled(
"ButtonOpenStorage", !arsenalItem );
2143 m_pNavigationBar.SetButtonEnabled(
"ButtonOpenAsContainer", !arsenalItem );
2154 m_pNavigationBar.SetButtonEnabled(
"ButtonUse",
true );
2158 if( m_EStateMenuItem ==
EStateMenuItem.STATE_MOVING_ITEM_STARTED && m_pFocusedSlotUI != m_pSelectedSlotUI )
2160 sAction =
"#AR-Inventory_Move";
2171 m_pNavigationBar.SetButtonEnabled(
"ButtonOpenStorage", !arsenalItem );
2172 m_pNavigationBar.SetButtonEnabled(
"ButtonOpenAsContainer", !arsenalItem );
2179 m_pNavigationBar.SetButtonEnabled(
"ButtonUse",
true );
2184 HandleSelectButtonState( sAction );
2188 protected void CreateItemSplitDialog(
int maxVal, IEntity entityTo, IEntity entityFrom)
2192 dialog.m_OnConfirm.Insert(OnItemSplitDialogConfirm);
2198 if (OnItemSplitDialogConfirm_Merge(dialog))
2201 if (OnItemSplitDialogConfirm_Create(dialog))
2210 if (!resourceInventoryComp)
2213 IEntity entityFrom = dialog.GetEntityFrom();
2214 IEntity entityTo = dialog.GetEntityTo();
2216 SCR_ResourceComponent resourceComponentFrom = SCR_ResourceComponent.FindResourceComponent(entityFrom);
2218 if (!resourceComponentFrom)
2224 SCR_ResourceComponent resourceComponentTo = SCR_ResourceComponent.FindResourceComponent(entityTo);
2226 if (!resourceComponentTo)
2229 resourceInventoryComp.Rpc(resourceInventoryComp.RpcAsk_MergeContainerWithContainerPartial, Replication.FindId(resourceComponentFrom), Replication.FindId(resourceComponentTo),
EResourceType.SUPPLIES, dialog.GetSliderValue());
2239 if (!resourceInventoryComp)
2242 IEntity entityFrom = dialog.GetEntityFrom();
2243 IEntity entityTo = dialog.GetEntityTo();
2245 SCR_ResourceComponent resourceComponentFrom = SCR_ResourceComponent.FindResourceComponent(entityFrom);
2247 if (!resourceComponentFrom)
2252 resourceInventoryComp.Rpc(resourceInventoryComp.RpcAsk_CreatePhysicalContainerWithContainer, Replication.FindId(resourceComponentFrom), Replication.FindId(
null), Replication.FindId(
null),
EResourceType.SUPPLIES, dialog.GetSliderValue());
2257 SCR_ResourceComponent resourceComponentTo = SCR_ResourceComponent.FindResourceComponent(entityTo);
2260 if (resourceComponentTo)
2263 SCR_InventoryStorageManagerComponent invManagerTo;
2264 IEntity entityParentTo = entityTo.GetParent();
2267 invManagerTo = SCR_InventoryStorageManagerComponent.Cast(entityParentTo.FindComponent(SCR_InventoryStorageManagerComponent));
2272 BaseInventoryStorageComponent storageTo = BaseInventoryStorageComponent.Cast(entityTo.FindComponent(BaseInventoryStorageComponent));
2277 resourceInventoryComp.Rpc(resourceInventoryComp.RpcAsk_CreatePhysicalContainerWithContainer, Replication.FindId(resourceComponentFrom), Replication.FindId(invManagerTo), Replication.FindId(storageTo),
EResourceType.SUPPLIES, dialog.GetSliderValue());
2285 void NavigationBarUpdateGamepad()
2287 m_pNavigationBar.SetAllButtonEnabled(
false);
2288 m_pNavigationBar.SetButtonEnabled(
"ButtonBack",
true);
2289 m_pNavigationBar.SetButtonEnabled(
"ButtonSelect",
true);
2293 m_pNavigationBar.SetButtonEnabled(
"ButtonRemoveTourniquet",
2294 (hzSlot && hzSlot.IsTourniquetted()) &&
2295 m_AttachmentSpinBox.IsFocused()
2298 if (m_pActiveStorageUI == m_pAttachmentStorageUI)
2300 m_pNavigationBar.SetButtonEnabled(
"ButtonUse",
true);
2304 if (m_bStorageSwitchMode)
2306 m_pNavigationBar.SetButtonActionName(
"ButtonBack",
"#AR-Inventory_Close");
2307 bool shouldShowMove = (m_pSelectedSlotUI !=
null) && m_pSelectedSlotUI.IsDraggable();
2308 if (m_pSelectedSlotUI)
2309 m_pNavigationBar.SetButtonActionName(
"ButtonBack",
"#AR-Inventory_Deselect");
2310 if (m_pActiveStorageUI)
2311 shouldShowMove &= m_pActiveStorageUI.IsStorageHighlighted();
2312 m_pNavigationBar.SetButtonEnabled(
"ButtonMove", shouldShowMove);
2313 m_pNavigationBar.SetButtonEnabled(
"ButtonSelect", !m_pSelectedSlotUI);
2314 m_pNavigationBar.SetButtonEnabled(
"ButtonEnterStorage", m_pSelectedSlotUI !=
null)
2318 m_pNavigationBar.SetButtonEnabled(
"ButtonMove", m_pSelectedSlotUI !=
null);
2319 m_pNavigationBar.SetButtonEnabled(
"ButtonSwap", m_pSelectedSlotUI !=
null);
2322 if (!m_bStorageSwitchMode &&
2323 m_pActiveStorageUI != m_pStorageLootUI &&
2324 m_pActiveStorageUI != m_pStorageListUI &&
2327 m_pNavigationBar.SetButtonEnabled(
"ButtonQuickSlotAssign",
true);
2330 bool isQuickSlotStorage = (m_pActiveStorageUI == m_pQuickSlotStorage);
2331 if (isQuickSlotStorage)
2333 bool itmToAssign = m_pItemToAssign !=
null;
2334 m_pNavigationBar.SetAllButtonEnabled(
false);
2335 m_pNavigationBar.SetButtonEnabled(
"ButtonMove", m_pSelectedSlotUI !=
null);
2336 m_pNavigationBar.SetButtonEnabled(
"ButtonClose",
true);
2337 if (m_bStorageSwitchMode)
2338 m_pNavigationBar.SetButtonEnabled(
"ButtonSelect",
true);
2340 m_pNavigationBar.SetButtonEnabled(
"ButtonQuickSlotAssign", itmToAssign);
2341 m_pNavigationBar.SetButtonEnabled(
"ButtonQuickSlotUnassign",
2343 m_pFocusedSlotUI !=
null
2347 if (!m_pFocusedSlotUI)
2351 bool arsenalItem = IsStorageArsenal(m_pFocusedSlotUI.GetStorageUI().GetCurrentNavigationStorage());
2352 if (itemComp && itemComp.GetOwner() && !arsenalItem)
2353 m_pNavigationBar.SetButtonEnabled(
"ButtonInspect", (itemComp.GetOwner().FindComponent(SCR_WeaponAttachmentsStorageComponent) !=
null));
2356 && m_pActiveStorageUI != m_pStorageListUI
2357 && m_pActiveStorageUI != m_pStorageLootUI)
2359 bool canUse = m_StorageManager.CanUseItem_Inventory(itemComp.GetOwner());
2360 bool canEquip = m_StorageManager.CanEquipItem_Inventory(itemComp.GetOwner());
2362 m_pNavigationBar.SetButtonEnabled(
"ButtonUse", canUse);
2363 m_pNavigationBar.SetButtonEnabled(
"ButtonEquip", canEquip);
2366 if (!m_pSelectedSlotUI)
2367 m_pNavigationBar.SetButtonActionName(
"ButtonBack",
"#AR-Menu_Back");
2369 m_pNavigationBar.SetButtonEnabled(
"ButtonDrop",
2370 (m_pFocusedSlotUI !=
null) &&
2371 !isQuickSlotStorage &&
2372 m_pFocusedSlotUI.IsDraggable() &&
2373 !m_AttachmentSpinBox.IsFocused()
2376 bool flag = m_pFocusedSlotUI.GetStorageUI() == m_pStorageLootUI;
2377 m_pNavigationBar.SetButtonEnabled(
"ButtonPickup", flag);
2379 if (!isQuickSlotStorage)
2381 m_pNavigationBar.SetButtonEnabled(
"ButtonDrop", !flag);
2382 HandleSlottedItemFunction();
2387 protected void HandleSelectButtonState(
string sAction =
"#AR-Inventory_Select" )
2390 if ( sAction ==
"#AR-Inventory_Move" )
2391 m_pNavigationBar.SetButtonActionName(
"ButtonSelect", sAction );
2394 if ( !m_pFocusedSlotUI.IsSlotSelected() )
2395 m_pNavigationBar.SetButtonActionName(
"ButtonSelect", sAction );
2397 m_pNavigationBar.SetButtonActionName(
"ButtonSelect",
"#AR-Inventory_Deselect" );
2405 return m_InspectionScreen;
2412 if (m_pGearInspectionPointUI)
2414 m_pGearInspectionPointUI.ClearSlots();
2415 m_wAttachmentContainer.RemoveHandler(m_pGearInspectionPointUI);
2416 m_pGearInspectionPointUI =
null;
2417 m_pInspectedSlot =
null;
2422 CloseAttachmentStorage();
2424 m_PlayerRenderAttributes.RotateItemCamera(Vector(0, 0, 0), Vector(0, 0, 0), Vector(0, 0, 0));
2425 InitializeCharacterHitZones();
2426 UpdateCharacterPreview();
2434 InitializeCharacterHitZones();
2435 CloseAttachmentStorage();
2437 UpdateCharacterPreview();
2441 IEntity item = itemComp.GetOwner();
2443 SCR_WeaponAttachmentsStorageComponent weaponAttachmentStorage = SCR_WeaponAttachmentsStorageComponent.Cast(item.FindComponent(SCR_WeaponAttachmentsStorageComponent));
2445 if (weaponAttachmentStorage)
2447 m_PlayerRenderAttributes.RotateItemCamera(Vector(0, 90, 0), Vector(0, 90, 0), Vector(0, 90, 0));
2448 m_pInspectedSlot = itemSlot;
2449 InspectWeapon(weaponAttachmentStorage);
2450 UpdateGearInspectionPreview();
2467 void InspectWeapon(SCR_WeaponAttachmentsStorageComponent weaponAttachmentStorage)
2469 CloseAttachmentStorage();
2470 HideCharacterHitZones();
2472 Widget inspectionFrame = m_widget.FindAnyWidget(
"AttachmentPoints");
2473 m_wAttachmentContainer =
GetGame().GetWorkspace().CreateWidgets(BACKPACK_STORAGE_LAYOUT, inspectionFrame);
2475 m_wAttachmentContainer.AddHandler(m_pGearInspectionPointUI);
2489 return m_pGearInspectionPointUI;
2494 protected void FilterOutStorages(
bool bShow =
true )
2497 array<SCR_InventorySlotUI> pSlotsInListUI =
new array<SCR_InventorySlotUI>();
2498 m_pStorageListUI.GetSlots( pSlotsInListUI );
2502 if ( m_pStorageLootUI )
2503 m_pStorageLootUI.GetSlots( pSlotsInListUI );
2504 if ( GetActualStorageInCharacterStorageUI() )
2505 GetActualStorageInCharacterStorageUI().GetSlots( pSlotsInListUI );
2506 if ( m_pQuickSlotStorage )
2507 m_pQuickSlotStorage.GetSlots( pSlotsInListUI );
2508 if ( m_pWeaponStorage )
2509 m_pWeaponStorage.GetSlots( pSlotsInListUI );
2511 BaseInventoryStorageComponent pStorageTo;
2514 if ( !pStorageSlotUI )
2517 pStorageTo = pStorageSlotUI.GetAsStorage();
2521 if ( !m_pSelectedSlotUI )
2523 if ( pStorageSlotUI.GetAsStorage() == m_pSelectedSlotUI.GetStorageUI().GetCurrentNavigationStorage() )
2525 pStorageSlotUI.SetEnabledForMove( 0 );
2530 if ( !pInventoryItem )
2533 IEntity pItem = pInventoryItem.GetOwner();
2537 bool bCanStore =
true;
2542 if ( !m_pWeaponStorageComp.Contains( pStorageTo.GetOwner() ) )
2546 pStorageSlotUI.SetEnabledForMove( 1 );
2548 pStorageSlotUI.SetEnabledForMove( 0 );
2552 pStorageSlotUI.SetEnabledForMove( 0 );
2557 pStorageSlotUI.SetEnabledForMove( 0 );
2563 pStorageSlotUI.SetEnabledForMove( 2 );
2569 protected void FilterOutItems(
bool bFilterOut )
2571 array<SCR_InventorySlotUI> aItemsUIInLoot = {};
2575 if ( m_pStorageListUI )
2576 aItemsUIInLoot.InsertAll( m_pStorageListUI.GetUISlots() );
2580 PrintFormat(
"INV: Filtering out items %1", 1.5 );
2584 if ( !pSlot.GetStorageComponent() )
2588 PrintFormat(
"INV: Disabling slot %1", pSlot );
2589 pSlot.SetEnabledForMove( 0 );
2593 PrintFormat(
"INV: Reseting slot %1", pSlot );
2594 pSlot.SetEnabledForMove( 2 );
2601 protected void Action_TryCloseInventory()
2603 if (m_bWasJustTraversing)
2605 m_bWasJustTraversing =
false;
2611 if (!m_bStorageSwitchMode)
2613 SetStorageSwitchMode(
true);
2618 if (m_pSelectedSlotUI)
2624 Action_CloseInventory();
2628 SetStorageSwitchMode(
false);
2629 ResetHighlightsOnAvailableStorages();
2630 FocusOnSlotInStorage(m_pActiveStorageUI);
2639 Action_CloseInventory();
2643 protected void Action_CloseInventory()
2645 array<BaseInventoryStorageComponent> traverseStorage = {};
2649 storageUIHandler.GetTraverseStorage(traverseStorage);
2652 if (!traverseStorage.IsEmpty())
2654 BaseInventoryStorageComponent storage = traverseStorage[0];
2657 IEntity entity = storage.GetOwner();
2666 GetGame().GetInputManager().RemoveActionListener(
"Inventory_Drag", EActionTrigger.DOWN, Action_DragDown);
2667 GetGame().GetInputManager().RemoveActionListener(
"Inventory", EActionTrigger.DOWN, Action_CloseInventory);
2671 m_pVicinity.ManipulationComplete();
2672 m_iVicinityDiscoveryRadius = 0;
2675 auto menuManager =
GetGame().GetMenuManager();
2678 auto inventoryMenu = menuManager.FindMenuByPreset( menu );
2680 menuManager.CloseMenuByPreset( menu );
2682 if (m_PlayerRenderAttributes)
2683 m_PlayerRenderAttributes.ResetDeltaRotation();
2694 gameMode.GetOnControllableDeleted().Remove(OnControllableDeleted);
2696 if (m_pCharacterWidgetHelper)
2697 m_pCharacterWidgetHelper.Destroy();
2699 m_pCharacterWidgetHelper =
null;
2705 m_pItemInfo.Destroy();
2707 if ( m_pDamageInfo )
2708 m_pDamageInfo.Destroy();
2711 m_pDamageInfo =
null;
2723 Action_CloseInventory();
2728 protected void OnControllableDeleted(IEntity controllable)
2731 Action_CloseInventory();
2742 Action_MoveItemToStorage(m_pActiveStorageUI);
2744 SetStorageSwitchMode(
true);
2745 NavigationBarUpdate();
2746 if (m_pSelectedSlotUI)
2748 m_pSelectedSlotUI.SetSelected(
false);
2749 m_pSelectedSlotUI =
null;
2751 FocusOnSlotInStorage(m_pActiveStorageUI);
2752 ResetHighlightsOnAvailableStorages();
2757 if (!m_pFocusedSlotUI)
2760 if (m_pSelectedSlotUI)
2761 m_pSelectedSlotUI.SetSelected(
false);
2765 m_pSelectedSlotUI = m_pFocusedSlotUI;
2766 m_pSelectedSlotUI.SetSelected(
true);
2767 HighlightAvailableStorages(m_pSelectedSlotUI);
2770 NavigationBarUpdate();
2772 SetStorageSwitchMode(
true);
2777 if (m_pSelectedSlotUI)
2779 ResetHighlightsOnAvailableStorages();
2780 m_pSelectedSlotUI.SetSelected(
false);
2781 m_pSelectedSlotUI =
null;
2784 NavigationBarUpdate();
2795 if (m_pActiveHoveredStorageUI)
2796 m_pActiveHoveredStorageUI.ShowContainerBorder(
false);
2803 if (m_pFocusedSlotUI == m_pInspectedSlot)
2808 if (m_pFocusedSlotUI)
2810 m_pSelectedSlotUI = m_pFocusedSlotUI;
2815 MoveBetweenFromVicinity();
2818 else if (pStorage != m_pStorageLootUI)
2820 MoveBetweenToVicinity();
2825 MoveBetweenFromVicinity();
2828 m_pSelectedSlotUI =
null;
2830 ResetHighlightsOnAvailableStorages();
2835 if ( m_pFocusedSlotUI.GetStorageUI() == m_pStorageListUI )
2837 if ( BaseInventoryStorageComponent.Cast( m_pFocusedSlotUI.GetAsStorage() ) )
2840 ToggleStorageContainerVisibility( m_pFocusedSlotUI );
2853 TraverseActualSlot();
2854 NavigationBarUpdate();
2861 OpenAsNewContainer();
2866 m_pSelectedSlotUI = m_pFocusedSlotUI;
2872 protected void Action_OpenContainer()
2879 protected void Action_Drop()
2881 bool onDrop =
false;
2882 if (m_pFocusedSlotUI)
2883 onDrop = m_pFocusedSlotUI.OnDrop(m_pSelectedSlotUI);
2885 Widget underCursor = WidgetManager.GetWidgetUnderCursor();
2886 if (underCursor && underCursor.GetName() ==
"HitZoneButton")
2889 if (m_pSelectedSlotUI && hzContainer)
2891 hzContainer.GetStorage().OnDrop(m_pSelectedSlotUI);
2895 if ( !onDrop && IsFocusedItemInsideDropContainer() !=
EDropContainer.NOCONTAINER )
2897 if (m_pSelectedSlotUI == m_pInspectedSlot)
2900 if ( m_pFocusedSlotUI )
2902 if ( IsFocusedItemInsideDropContainer() ==
EDropContainer.ISINSIDE )
2906 MoveItemToStorageSlot();
2910 EquipWeaponIntoWeaponSlot();
2917 SetItemToQuickSlotDrop();
2921 MoveItemToStorageSlot();
2941 if (m_pActiveHoveredStorageUI)
2942 m_pActiveHoveredStorageUI.OnDrop(m_pSelectedSlotUI);
2949 if (WidgetManager.GetWidgetUnderCursor() == m_wPlayerRender)
2951 EquipDraggedItem(
true);
2956 RemoveItemFromQuickSlotDrop();
2960 ResetHighlightsOnAvailableStorages();
2964 void Action_QuickSlotAssign()
2966 if (m_pItemToAssign && m_pActiveStorageUI == m_pQuickSlotStorage)
2968 int slotId = m_pQuickSlotStorage.GetFocusedSlotId() + 1;
2969 SetItemToQuickSlot(slotId, m_pItemToAssign);
2970 FocusOnSlotInStorage(m_pQuickSlotStorage, slotId - 1);
2971 m_pItemToAssign =
null;
2975 if (m_pActiveStorageUI != m_pStorageLootUI && m_pActiveStorageUI != m_pQuickSlotStorage)
2977 m_pItemToAssign = m_pFocusedSlotUI;
2978 FocusOnSlotInStorage(m_pQuickSlotStorage, 4);
2982 NavigationBarUpdate();
2986 void Action_QuickSlotUnassign()
2988 if (!m_pFocusedSlotUI)
2995 IEntity item = itemComp.GetOwner();
2999 int slotId = m_pQuickSlotStorage.GetFocusedSlotId();
3000 slotId = Math.Clamp(slotId, 0, m_StorageManager.GetQuickSlotItems().Count());
3001 m_pItemToAssign =
null;
3002 m_StorageManager.RemoveItemFromQuickSlot(item);
3003 ShowQuickSlotStorage();
3004 FocusOnSlotInStorage(m_pQuickSlotStorage, slotId);
3005 NavigationBarUpdate();
3010 void MoveItemToStorageSlot()
3012 if (MoveItemToStorageSlot_VirtualArsenal())
3015 if (MoveItemToStorageSlot_ResourceContainer())
3017 if (m_pSelectedSlotUI)
3019 m_pSelectedSlotUI.SetSelected(
false);
3020 m_pSelectedSlotUI =
null;
3026 if (!m_pSelectedSlotUI)
3033 IEntity pItem = pComp.GetOwner();
3037 m_pCallBack.m_pItem = pItem;
3038 m_pCallBack.m_pMenu =
this;
3039 m_pCallBack.m_pStorageFrom = m_pSelectedSlotUI.GetStorageUI();
3040 m_pCallBack.m_pStorageTo = m_pFocusedSlotUI.GetStorageUI();
3042 BaseInventoryStorageComponent pStorageFromComponent = m_pCallBack.m_pStorageFrom.GetCurrentNavigationStorage();
3043 BaseInventoryStorageComponent pStorageToComponent = m_pFocusedSlotUI.GetAsStorage();
3045 if (!pStorageToComponent)
3046 pStorageToComponent = m_pCallBack.m_pStorageTo.GetStorage();
3048 if (IsStorageArsenal(pStorageToComponent))
3054 bool shouldEquip = m_pCallBack.m_pStorageTo == m_pStorageListUI;
3055 bool equip = shouldEquip &&
m_InventoryManager.EquipAny(m_StorageManager , pItem, 0, m_pCallBack);
3058 m_InventoryManager.InsertItem( pItem, pStorageToComponent, pStorageFromComponent, m_pCallBack );
3070 void EquipWeaponIntoWeaponSlot()
3072 if (EquipWeaponIntoWeaponSlot_VirtualArsenal())
3075 if (!m_pSelectedSlotUI)
3086 IEntity pItem = pComp.GetOwner();
3090 m_pCallBack.m_pItem = pItem;
3091 m_pCallBack.m_pMenu =
this;
3092 m_pCallBack.m_pStorageFrom = m_pSelectedSlotUI.GetStorageUI();
3093 m_pCallBack.m_pStorageTo = m_pFocusedSlotUI.GetStorageUI();
3096 IEntity pItemToReplace;
3097 if (pItemToReplaceComp)
3098 pItemToReplace = pItemToReplaceComp.GetOwner();
3102 BaseInventoryStorageComponent itemToReplaceStorage = BaseInventoryStorageComponent.Cast(pItemToReplace.FindComponent(BaseInventoryStorageComponent));
3104 if (itemToReplaceStorage &&
m_InventoryManager.CanInsertItemInStorage(pItem, itemToReplaceStorage, -1))
3106 m_InventoryManager.TryInsertItemInStorage(pItem, itemToReplaceStorage, -1, m_pCallBack);
3113 if (pItemToReplace && pItem)
3115 if (itemParentSlot && IsStorageArsenal(itemParentSlot.GetStorage()))
3117 m_InventoryManager.TryReplaceAndDropItemAtSlot(m_pWeaponStorageComp, pItem, weaponSlot.GetWeaponSlotIndex(), m_pCallBack,
true,
true);
3120 else if (pItemToReplace != pItem)
3131 BaseInventoryStorageComponent pStorageToComponent = m_pWeaponStorageComp;
3133 if (!
m_InventoryManager.TryMoveItemToStorage( pItem, m_pWeaponStorageComp, weaponSlot.GetWeaponSlotIndex(), m_pCallBack ))
3135 if (!
m_InventoryManager.TryInsertItemInStorage(pItem, m_pWeaponStorageComp, weaponSlot.GetWeaponSlotIndex(), m_pCallBack))
3147 if (MoveItem_VirtualArsenal(pStorageBaseUI))
3150 if (MoveItem_ResourceContainer(pStorageBaseUI))
3152 if (m_pSelectedSlotUI)
3154 m_pSelectedSlotUI.SetSelected(
false);
3155 m_pSelectedSlotUI =
null;
3161 if ( !m_pSelectedSlotUI )
3166 IEntity pItem = pComp.GetOwner();
3170 m_pCallBack.m_pItem = pItem;
3171 m_pCallBack.m_pMenu =
this;
3172 m_pCallBack.m_pStorageToFocus = m_pSelectedSlotUI.GetStorageUI();
3173 m_pCallBack.m_pStorageFrom = m_pSelectedSlotUI.GetStorageUI();
3175 if ( pStorageBaseUI )
3176 m_pCallBack.m_pStorageTo = pStorageBaseUI;
3178 m_pCallBack.m_pStorageTo = m_pActiveHoveredStorageUI;
3180 BaseInventoryStorageComponent pStorageTo = m_pActiveHoveredStorageUI.GetCurrentNavigationStorage();
3181 if (IsStorageArsenal(pStorageTo))
3187 if (pStorageTo && pStorageTo.IsInherited(SCR_WeaponAttachmentsStorageComponent))
3189 m_pCallBack.m_pStorageMan = GetInventoryStorageManager();
3193 if (m_pCallBack.m_pStorageFrom)
3195 BaseInventoryStorageComponent storageFrom = m_pCallBack.m_pStorageFrom.GetStorage();
3196 if (storageFrom && storageFrom.IsInherited(SCR_WeaponAttachmentsStorageComponent))
3198 m_pCallBack.m_pStorageMan = GetInventoryStorageManager();
3203 if ( pStorageTo && EquipedWeaponStorageComponent.Cast( pStorageTo ) )
3205 m_InventoryManager.EquipWeapon( pItem, m_pCallBack, m_pCallBack.m_pStorageFrom == m_pStorageLootUI );
3208 else if ( pStorageTo && CharacterInventoryStorageComponent.Cast( pStorageTo ) )
3212 else if ( m_pCallBack.m_pStorageTo == m_pStorageLootUI )
3214 MoveToVicinity( pItem );
3217 else if ( m_pCallBack.m_pStorageFrom == m_pCallBack.m_pStorageTo)
3223 if ( m_pCallBack.m_pStorageFrom == m_pStorageLootUI )
3226 m_InventoryManager.InsertItem( pItem, m_pActiveHoveredStorageUI.GetCurrentNavigationStorage(), m_pCallBack.m_pStorageFrom.GetStorage(), m_pCallBack );
3232 protected void EquipWeapon()
3234 if ( !m_pSelectedSlotUI )
3236 IEntity pItem = m_pSelectedSlotUI.GetInventoryItemComponent().GetOwner();
3246 protected void MoveToVicinity( IEntity pItem )
3248 BaseInventoryStorageComponent pStorageFrom = m_pSelectedSlotUI.GetStorageUI().GetStorage();
3253 m_pCallBack.m_pStorageFrom = GetStorageUIByBaseStorageComponent(pStorageFrom);
3254 if (!m_pCallBack.m_pStorageFrom)
3255 m_pCallBack.m_pStorageFrom = m_pSelectedSlotUI.GetStorageUI();
3257 BaseInventoryStorageComponent isStorage = BaseInventoryStorageComponent.Cast(pItem.FindComponent(BaseInventoryStorageComponent));
3259 m_pCallBack.m_pStorageToDrop = isStorage;
3261 m_pCallBack.m_pStorageTo = m_pStorageLootUI;
3262 auto storage = m_pStorageLootUI.GetCurrentNavigationStorage();
3264 if ( storage && !IsStorageArsenal(storage) )
3265 m_InventoryManager.InsertItem( pItem, m_pStorageLootUI.GetCurrentNavigationStorage(), pStorageFrom, m_pCallBack );
3269 auto pSlot = m_pSelectedSlotUI.GetInventoryItemComponent().GetParentSlot();
3272 if (pStorageFrom && pStorageFrom.IsInherited(SCR_WeaponAttachmentsStorageComponent))
3274 m_pCallBack.m_pStorageMan = GetInventoryStorageManager();
3277 m_InventoryManager.TryRemoveItemFromInventory(pItem, pSlot.GetStorage(), m_pCallBack);
3289 protected void MoveFromVicinity()
3291 IEntity pItem = m_pSelectedSlotUI.GetInventoryItemComponent().GetOwner();
3295 m_pCallBack.m_pItem = pItem;
3296 m_pCallBack.m_pMenu =
this;
3298 m_pCallBack.m_pStorageFrom = m_pStorageLootUI;
3299 m_pCallBack.m_pStorageTo = m_pActiveHoveredStorageUI;
3301 if (ShouldSpawnItem())
3303 m_pCallBack.m_bUpdateSlotOnly =
true;
3304 BaseInventoryStorageComponent storageTo =
m_InventoryManager.FindStorageForInsert(pItem, m_pActiveHoveredStorageUI.GetCurrentNavigationStorage(),
EStoragePurpose.PURPOSE_ANY);
3310 if (m_pActiveHoveredStorageUI.GetCurrentNavigationStorage() &&
3311 m_pActiveHoveredStorageUI.GetCurrentNavigationStorage().IsInherited(SCR_WeaponAttachmentsStorageComponent))
3313 m_pCallBack.m_pStorageMan = GetInventoryStorageManager();
3317 BaseInventoryStorageComponent storagefrom = m_pStorageLootUI.GetCurrentNavigationStorage();
3320 IEntity ent = m_pVicinity.GetItemOfInterest();
3322 storagefrom = BaseInventoryStorageComponent.Cast(ent.FindComponent(BaseInventoryStorageComponent));
3325 m_InventoryManager.InsertItem(pItem, m_pActiveHoveredStorageUI.GetCurrentNavigationStorage(), storagefrom, m_pCallBack);
3331 protected void MoveBetweenFromVicinity()
3333 if (MoveBetweenFromVicinity_VirtualArsenal())
3336 IEntity pItem = m_pSelectedSlotUI.GetInventoryItemComponent().GetOwner();
3345 m_pCallBack.m_pItem = pItem;
3346 m_pCallBack.m_pMenu =
this;
3348 InventoryStorageSlot parentSlotFrom = m_pSelectedSlotUI.GetInventoryItemComponent().GetParentSlot();
3349 BaseInventoryStorageComponent storageFrom;
3351 storageFrom = parentSlotFrom.GetStorage();
3354 storageFrom = m_pStorageLootUI.GetCurrentNavigationStorage();
3356 m_pCallBack.m_pStorageFrom = GetStorageUIByBaseStorageComponent(storageFrom);
3357 m_pCallBack.m_pStorageTo = m_pStorageListUI;
3358 m_pCallBack.m_pStorageToFocus = m_pSelectedSlotUI.GetStorageUI();
3359 m_pCallBack.m_sItemToFocus = m_pSelectedSlotUI.GetItemResource();
3360 m_pCallBack.m_iSlotToFocus = m_pFocusedSlotUI.GetStorageUI().GetFocusedSlotId();
3361 m_pCallBack.m_bUpdateSlotOnly = m_pSelectedSlotUI.IsStacked();
3363 BaseInventoryStorageComponent pStorageTo = m_StorageManager;
3364 if ( pItem.FindComponent( SCR_GadgetComponent ) )
3368 pStorageTo = pStorageComp;
3373 pStorageTo = pStorageComp;
3377 if (ShouldSpawnItem())
3379 m_pCallBack.m_bUpdateSlotOnly =
true;
3385 BaseInventoryStorageComponent isStorage = BaseInventoryStorageComponent.Cast(pItem.FindComponent(BaseInventoryStorageComponent));
3387 m_pCallBack.m_pStorageToPickUp = isStorage;
3389 m_InventoryManager.InsertItem( pItem,
null, m_pStorageLootUI.GetCurrentNavigationStorage(), m_pCallBack );
3393 protected bool ShouldSpawnItem()
3395 if (!m_pSelectedSlotUI)
3397 if (!m_pSelectedSlotUI.GetStorageUI())
3400 BaseInventoryStorageComponent currStorage = m_pSelectedSlotUI.GetStorageUI().GetCurrentNavigationStorage();
3401 return IsStorageArsenal(currStorage);
3405 protected bool IsStorageArsenal(BaseInventoryStorageComponent storage)
3413 protected void EquipDraggedItem(
bool forceEquip =
false)
3415 if (EquipDraggedItem_VirtualArsenal(forceEquip))
3418 if (!m_pSelectedSlotUI || !m_pSelectedSlotUI.GetInventoryItemComponent())
3421 IEntity pItem = m_pSelectedSlotUI.GetInventoryItemComponent().GetOwner();
3425 m_pCallBack.m_pItem = pItem;
3426 m_pCallBack.m_pMenu =
this;
3427 m_pCallBack.m_pStorageFrom = m_pSelectedSlotUI.GetStorageUI();
3429 m_pCallBack.m_pStorageToFocus = m_pSelectedSlotUI.GetStorageUI();
3430 m_pCallBack.m_sItemToFocus = m_pSelectedSlotUI.GetItemResource();
3431 m_pCallBack.m_bShouldEquip = forceEquip;
3433 BaseInventoryStorageComponent pStorageTo = m_StorageManager;
3436 m_pCallBack.m_pStorageTo = m_pWeaponStorage;
3440 m_pCallBack.m_pStorageTo = m_pStorageListUI;
3443 if (pItem.FindComponent(SCR_GadgetComponent))
3447 pStorageTo = pStorageComp;
3452 pStorageTo = pStorageComp;
3456 if (pItem.FindComponent(WeaponComponent))
3460 pStorageTo = pStorageComp;
3465 pStorageTo = pStorageComp;
3470 if (!equip && m_pSelectedSlotUI)
3472 m_InventoryManager.InsertItem(pItem,
null, m_pSelectedSlotUI.GetStorageUI().GetCurrentNavigationStorage(), m_pCallBack);
3482 protected void MoveBetweenToVicinity()
3488 IEntity pItem = pInvComponent.GetOwner();
3492 m_pCallBack.m_pItem = pItem;
3493 m_pCallBack.m_pMenu =
this;
3495 m_pCallBack.m_pStorageToFocus = GetStorageUIByBaseStorageComponent(m_pSelectedSlotUI.GetStorageUI().GetCurrentNavigationStorage());
3496 m_pCallBack.m_sItemToFocus = m_pSelectedSlotUI.GetItemResource();
3497 m_pCallBack.m_iSlotToFocus = m_pFocusedSlotUI.GetStorageUI().GetFocusedSlotId();
3498 m_pCallBack.m_bUpdateSlotOnly = m_pSelectedSlotUI.IsStacked();
3500 if (MoveBetweenToVicinity_VirtualArsenal())
3503 MoveToVicinity( pItem );
3507 protected bool MoveBetweenToVicinity_VirtualArsenal()
3509 BaseInventoryStorageComponent storageComponent = m_pStorageLootUI.GetCurrentNavigationStorage();
3511 if (!storageComponent && m_aOpenedStoragesUI)
3519 storageComponent = storageUI.GetStorage();
3521 if (storageComponent)
3526 if (!storageComponent || !IsStorageArsenal(storageComponent))
3530 IEntity arsenalEntity = storageComponent.GetOwner();
3532 SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.FindResourceComponent(arsenalEntity);
3535 if (!resourceInventoryComponent)
3538 resourceInventoryComponent.Rpc(resourceInventoryComponent.RpcAsk_ArsenalRefundItem, Replication.FindId(resourceComponent), Replication.FindId(inventoryItemComponent),
EResourceType.SUPPLIES);
3548 if (m_pSelectedSlotUI)
3553 if (!arsenalInventorySlotUI)
3555 if (m_pActiveHoveredStorageUI)
3559 BaseInventoryStorageComponent storageComponent = m_pStorageLootUI.GetCurrentNavigationStorage();
3561 if (!storageComponent)
3562 storageComponent = m_pActiveHoveredStorageUI.GetStorage();
3564 if (!storageComponent || !IsStorageArsenal(storageComponent) )
3567 IEntity arsenalEntity = storageComponent.GetOwner();
3569 SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.FindResourceComponent(arsenalEntity);
3573 resourceInventoryComponent.Rpc(resourceInventoryComponent.RpcAsk_ArsenalRefundItem, Replication.FindId(resourceComponent), Replication.FindId(inventoryItemComponent),
EResourceType.SUPPLIES);
3590 BaseInventoryStorageComponent storageComponent = m_pActiveHoveredStorageUI.GetCurrentNavigationStorage();
3592 if (arsenalInventorySlotUI && storageComponent.GetOwner().FindComponent(SCR_ArsenalInventoryStorageManagerComponent))
3595 SCR_InventoryStorageManagerComponent invManagerTo = m_pActiveHoveredStorageUI.GetInventoryManager();
3596 BaseInventoryStorageComponent storageTo = m_pActiveHoveredStorageUI.GetStorage();
3598 SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.FindResourceComponent(arsenalEntity);
3599 ResourceName resourceName = arsenalInventorySlotUI.GetItemResource();
3602 if (invManagerTo.CanInsertItemInStorage(arsenalInventorySlotUI.GetInventoryItemComponent().GetOwner(), storageTo))
3603 resourceInventoryComponent.Rpc(resourceInventoryComponent.RpcAsk_ArsenalRequestItem, Replication.FindId(resourceComponent), Replication.FindId(invManagerTo), Replication.FindId(storageTo), resourceName,
EResourceType.SUPPLIES);
3609 protected bool EquipWeaponIntoWeaponSlot_VirtualArsenal()
3613 if (m_pSelectedSlotUI)
3615 else if (!m_pSelectedSlotUI || !arsenalInventorySlotUI)
3623 SCR_InventoryStorageManagerComponent invManagerTo = weaponSlot.GetStorageUI().GetInventoryManager();
3624 BaseInventoryStorageComponent storageTo = weaponSlot.GetStorageUI().GetStorage();
3628 SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.FindResourceComponent(arsenalEntity);
3629 ResourceName resourceName = arsenalInventorySlotUI.GetItemResource();
3632 if (invManagerTo.CanInsertItemInStorage(arsenalInventorySlotUI.GetInventoryItemComponent().GetOwner(), storageTo))
3633 resourceInventoryComponent.Rpc(resourceInventoryComponent.RpcAsk_ArsenalRequestItem, Replication.FindId(resourceComponent), Replication.FindId(invManagerTo), Replication.FindId(storageTo), resourceName,
EResourceType.SUPPLIES);
3643 protected bool MoveItemToStorageSlot_VirtualArsenal()
3647 if (m_pSelectedSlotUI)
3652 if (!arsenalInventorySlotUI)
3659 BaseInventoryStorageComponent storageComponent = m_pStorageLootUI.GetCurrentNavigationStorage();
3661 if (!storageComponent)
3662 storageComponent = m_pActiveHoveredStorageUI.GetStorage();
3664 if (!storageComponent || !IsStorageArsenal(storageComponent) )
3667 IEntity arsenalEntity = storageComponent.GetOwner();
3669 SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.FindResourceComponent(arsenalEntity);
3672 resourceInventoryComponent.Rpc(resourceInventoryComponent.RpcAsk_ArsenalRefundItem, Replication.FindId(resourceComponent), Replication.FindId(inventoryItemComponent),
EResourceType.SUPPLIES);
3684 SCR_InventoryStorageManagerComponent invManagerTo = m_pFocusedSlotUI.GetStorageUI().GetInventoryManager();
3685 BaseInventoryStorageComponent storageTo = m_pFocusedSlotUI.GetStorageUI().GetStorage();
3687 SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.FindResourceComponent(arsenalEntity);
3688 ResourceName resourceName = arsenalInventorySlotUI.GetItemResource();
3691 if (invManagerTo.CanInsertItemInStorage(arsenalInventorySlotUI.GetInventoryItemComponent().GetOwner(), storageTo))
3692 resourceInventoryComponent.Rpc(resourceInventoryComponent.RpcAsk_ArsenalRequestItem, Replication.FindId(resourceComponent), Replication.FindId(invManagerTo), Replication.FindId(storageTo), resourceName,
EResourceType.SUPPLIES);
3698 protected bool EquipDraggedItem_VirtualArsenal(
bool forceEquip =
false)
3702 if (m_pSelectedSlotUI)
3705 if (!m_pSelectedSlotUI || !arsenalInventorySlotUI)
3709 IEntity slotEntity = arsenalInventorySlotUI.GetInventoryItemComponent().GetOwner();
3712 SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.FindResourceComponent(arsenalEntity);
3713 ResourceName resourceName = arsenalInventorySlotUI.GetItemResource();
3716 if (invManagerTo.CanInsertItemInStorage(slotEntity, storageTo))
3717 resourceInventoryComponent.Rpc(resourceInventoryComponent.RpcAsk_ArsenalRequestItem, Replication.FindId(resourceComponent), Replication.FindId(invManagerTo), Replication.FindId(storageTo), resourceName,
EResourceType.SUPPLIES);
3723 protected bool MoveBetweenFromVicinity_VirtualArsenal()
3727 if (m_pSelectedSlotUI)
3730 if (!m_pSelectedSlotUI || !arsenalInventorySlotUI)
3734 IEntity slotEntity = arsenalInventorySlotUI.GetInventoryItemComponent().GetOwner();
3737 SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.FindResourceComponent(arsenalEntity);
3738 ResourceName resourceName = arsenalInventorySlotUI.GetItemResource();
3741 if (invManagerTo.CanInsertItemInStorage(slotEntity, storageTo))
3742 resourceInventoryComponent.Rpc(resourceInventoryComponent.RpcAsk_ArsenalRequestItem, Replication.FindId(resourceComponent), Replication.FindId(invManagerTo), Replication.FindId(storageTo), resourceName,
EResourceType.SUPPLIES);
3750 if (!m_pSelectedSlotUI)
3753 IEntity draggedEntity = m_pSelectedSlotUI.GetInventoryItemComponent().GetOwner();
3758 SCR_ResourceComponent resourceComponentFrom = SCR_ResourceComponent.FindResourceComponent(draggedEntity);
3760 if (!resourceComponentFrom)
3764 SCR_BaseCompartmentManagerComponent compartmentManager = SCR_BaseCompartmentManagerComponent.Cast(resourceComponentFrom.GetOwner().FindComponent(SCR_BaseCompartmentManagerComponent));
3765 if (compartmentManager && compartmentManager.BlockSuppliesIfOccupied() && compartmentManager.GetOccupantCount() > 0)
3768 if (!m_pActiveHoveredStorageUI)
3771 SCR_InventoryStorageManagerComponent invManagerTo = m_pActiveHoveredStorageUI.GetInventoryManager();
3778 if (!interactorFrom)
3781 if (!interactorFrom)
3784 BaseInventoryStorageComponent storageTo = m_pActiveHoveredStorageUI.GetStorage();
3790 array<SCR_EntityCatalogEntry> entries = {};
3791 array<SCR_BaseEntityCatalogData>
data = {};
3796 float maxStoredResources = Math.Min(interactorFrom.GetAggregatedResourceValue(), datum.GetMaxResourceValue());
3798 if (maxStoredResources <= 0)
3801 CreateItemSplitDialog(maxStoredResources,
null, draggedEntity);
3806 IEntity targetEntity = storageTo.GetOwner();
3810 SCR_ResourceComponent targetResourceComponent = SCR_ResourceComponent.FindResourceComponent(targetEntity);
3814 if (targetResourceComponent)
3815 return MoveItemToStorageSlot_ResourceContainer();
3819 if (draggedEntity == targetEntity || resourceComponentFrom == targetResourceComponent)
3823 array<SCR_EntityCatalogEntry> entries = {};
3824 array<SCR_BaseEntityCatalogData>
data = {};
3825 float maxResourceValueTo = 0.0;
3833 if (invManagerTo.CanInsertResourceInStorage(entry.GetPrefab(), storageTo))
3835 maxResourceValueTo = datum.GetMaxResourceValue();
3840 float maxStoredResources = Math.Min(interactorFrom.GetAggregatedResourceValue(), maxResourceValueTo);
3842 if (maxStoredResources <= 0)
3845 CreateItemSplitDialog(maxStoredResources, targetEntity, draggedEntity);
3851 protected bool MoveItemToStorageSlot_ResourceContainer()
3853 if (!m_pSelectedSlotUI)
3856 IEntity draggedEntity = m_pSelectedSlotUI.GetInventoryItemComponent().GetOwner();
3861 SCR_ResourceComponent resourceComponentFrom = SCR_ResourceComponent.FindResourceComponent(draggedEntity);
3863 if (!resourceComponentFrom)
3866 IEntity targetEntity;
3868 if (m_pFocusedSlotUI && m_pFocusedSlotUI.GetInventoryItemComponent())
3869 targetEntity = m_pFocusedSlotUI.GetInventoryItemComponent().GetOwner();
3870 else if (m_pActiveHoveredStorageUI && m_pActiveHoveredStorageUI.GetStorage())
3871 targetEntity = m_pActiveHoveredStorageUI.GetStorage().GetOwner();
3876 SCR_ResourceComponent resourceComponentTo = SCR_ResourceComponent.FindResourceComponent(targetEntity);
3878 if (!resourceComponentTo)
3882 SCR_BaseCompartmentManagerComponent compartmentManager = SCR_BaseCompartmentManagerComponent.Cast(resourceComponentTo.GetOwner().FindComponent(SCR_BaseCompartmentManagerComponent));
3883 if (compartmentManager && compartmentManager.BlockSuppliesIfOccupied() && compartmentManager.GetOccupantCount() > 0)
3888 if (!interactorFrom)
3891 if (!interactorFrom)
3904 if (m_pSelectedSlotUI == m_pFocusedSlotUI)
3907 float maxStoredResources = Math.Min(interactorFrom.GetAggregatedResourceValue(), interactorTo.GetAggregatedMaxResourceValue() - interactorTo.GetAggregatedResourceValue());
3909 if (maxStoredResources <= 0)
3912 CreateItemSplitDialog(maxStoredResources, targetEntity, draggedEntity);
3920 if (m_pSelectedSlotUI)
3922 m_pSelectedSlotUI.SetSelected(
false);
3923 m_pSelectedSlotUI =
null;
3929 protected void HandleItemSelection()
3931 if ( m_pFocusedSlotUI && m_pSelectedSlotUI && m_pFocusedSlotUI != m_pSelectedSlotUI )
3933 if ( m_bDraggingEnabled )
3935 m_pFocusedSlotUI.SetSelected(
true );
3936 m_pSelectedSlotUI.SetSelected(
false );
3937 m_pSelectedSlotUI = m_pFocusedSlotUI;
3938 FilterOutStorages(
true );
3944 if ( m_bDraggingEnabled )
3946 if ( m_pSelectedSlotUI )
3947 m_pSelectedSlotUI.SetSelected(
false );
3948 m_pSelectedSlotUI =
null;
3949 FilterOutStorages(
false );
3956 void SetOpenStorage()
3958 IEntity m_pStorageToOpen = GetInventoryStorageManager().GetStorageToOpen();
3960 if (!m_pStorageToOpen)
3966 BaseInventoryStorageComponent comp = BaseInventoryStorageComponent.Cast(m_pStorageToOpen.FindComponent(BaseInventoryStorageComponent));
3976 if (storageUI.IsTraversalAllowed())
3977 storageUI.Traverse(comp);
3979 SetStorageSwitchMode(
false);
3981 ButtonWidget lastCloseTraverseButton = storageUI.GetLastCloseTraverseButton();
3983 if (
m_bIsUsingGamepad && lastCloseTraverseButton && !CanFocusOnSlotInStorage(storageUI, 0))
3984 GetGame().GetWorkspace().SetFocusedWidget(lastCloseTraverseButton);
3986 FocusOnSlotInStorage(storageUI);
3991 protected void TraverseActualSlot()
3993 m_pSelectedSlotUI = m_pFocusedSlotUI;
3994 auto storage = m_pFocusedSlotUI.GetAsStorage();
3999 if (parentUIContainer.IsTraversalAllowed() && ShouldAllowTraverseActualSlot())
4000 parentUIContainer.Traverse(storage);
4002 ButtonWidget lastCloseTraverseButton = parentUIContainer.GetLastCloseTraverseButton();
4004 if (
m_bIsUsingGamepad && lastCloseTraverseButton && !CanFocusOnSlotInStorage(parentUIContainer, 0))
4005 GetGame().GetWorkspace().SetFocusedWidget(lastCloseTraverseButton);
4007 FocusOnSlotInStorage(parentUIContainer);
4014 protected bool ShouldAllowTraverseActualSlot()
4019 if (inventoryItemComponent && inventoryItemComponent.GetParentSlot() && inventoryItemComponent.GetOwner().FindComponent(SCR_ArsenalInventoryStorageManagerComponent))
4026 protected void OpenAsNewContainer()
4028 m_pSelectedSlotUI = m_pFocusedSlotUI;
4029 auto storage = m_pFocusedSlotUI.GetAsStorage();
4032 OpenStorageAsContainer(storage);
4033 OpenLinkedStorages(storage);
4043 void OpenLinkedStorages(BaseInventoryStorageComponent parentStorage,
bool showVicinity =
true,
bool hideCloseButton =
true)
4049 OpenLinkedStoragesDelayed(scrStorage, showVicinity, hideCloseButton);
4059 array<BaseInventoryStorageComponent> linkedStorages = {};
4060 if (scrStorage.GetLinkedStorages(linkedStorages) <= 0)
4065 foreach (BaseInventoryStorageComponent linkedStorage : linkedStorages)
4068 if (m_pStorageLootUI && m_pStorageLootUI.GetCurrentNavigationStorage() == linkedStorage)
4071 alreadyOpen =
false;
4076 if (openedStorage.GetStorage() == linkedStorage)
4086 OpenStorageAsContainer(linkedStorage, showVicinity, hideCloseButton);
4095 void CloseLinkedStorages(BaseInventoryStorageComponent parentStorage)
4102 GetGame().GetCallqueue().CallLater(CloseLinkedStoragesDelayed, param1: scrStorage);
4109 array<BaseInventoryStorageComponent> linkedStorages = {};
4110 if (scrStorage.GetLinkedStorages(linkedStorages) <= 0)
4114 if (m_pStorageLootUI && m_pStorageLootUI.GetCurrentNavigationStorage() == scrStorage)
4120 if (openedStorage.GetStorage() == scrStorage)
4125 foreach (BaseInventoryStorageComponent linkedStorage : linkedStorages)
4130 if (openedStorage.GetStorage() == linkedStorage)
4132 RemoveOpenStorage(openedStorage);
4141 protected void Action_SelectItem()
4144 if (!GetCanInteract())
4150 void Action_DeselectItem()
4153 ResetHighlightsOnAvailableStorages();
4157 protected void Action_MoveInsideStorage()
4160 ResetHighlightsOnAvailableStorages();
4164 protected void Action_EquipItem()
4166 if (m_pFocusedSlotUI)
4167 m_pFocusedSlotUI.UseItem(
m_Player);
4171 protected void Action_MoveBetween()
4174 if (!GetCanInteract())
4177 ResetHighlightsOnAvailableStorages();
4181 void Action_Inspect()
4183 if (m_pFocusedSlotUI == m_pInspectedSlot)
4186 InspectItem(m_pFocusedSlotUI);
4191 protected void Action_UseItem()
4193 if (m_pFocusedSlotUI)
4203 IEntity item = m_pFocusedSlotUI.GetInventoryItemComponent().GetOwner();
4207 if (hzStorage.CanApplyItem(item))
4209 hzStorage.OnDrop(m_pFocusedSlotUI);
4216 for (
int i = 0, max = m_AttachmentSpinBox.GetNumItems(); i < max; i++)
4222 hzStorage = hzContainer.GetStorage();
4223 if (hzStorage && hzStorage.CanApplyItem(item))
4224 hzStorage.OnDrop(m_pFocusedSlotUI)
4232 m_pGearInspectionPointUI.SetSlotFocused(point);
4233 point.OnDrop(m_pFocusedSlotUI);
4236 if (!hzContainer || !point)
4238 m_pFocusedSlotUI.UseItem(
m_Player);
4245 protected void Action_UnfoldItem()
4254 if (pParentStorage && pParentStorage.IsTraversalAllowed())
4256 pParentStorage.Back(traverseStorageIndex);
4257 FilterOutStorages(
false);
4260 FocusOnSlotInStorage(pParentStorage);
4261 m_bWasJustTraversing =
true;
4263 ResetHighlightsOnAvailableStorages();
4267 void Action_DragDown()
4269 if ( m_bDraggingEnabled )
4271 if ( !m_pFocusedSlotUI )
4273 if (!m_pFocusedSlotUI.IsDraggable())
4276 if ( m_pFocusedSlotUI && WidgetManager.GetWidgetUnderCursor() != m_pFocusedSlotUI.GetButtonWidget() )
4292 m_bDraggingEnabled =
false;
4293 WidgetManager.GetMousePos( m_iMouseX, m_iMouseY );
4294 GetGame().GetInputManager().AddActionListener(
"Inventory_Drag", EActionTrigger.PRESSED, Action_OnDrag );
4298 void Action_OnDrag()
4300 int iMouseX, iMouseY;
4301 WidgetManager.GetMousePos( iMouseX, iMouseY );
4302 if ( !m_bDraggingEnabled )
4304 int dX = Math.AbsInt( iMouseX - m_iMouseX );
4305 int dY = Math.AbsInt( iMouseY - m_iMouseY );
4306 if ( ( dX < DRAG_THRESHOLD ) && ( dY < DRAG_THRESHOLD ) )
4308 if ( !m_pFocusedSlotUI )
4310 if (!m_pFocusedSlotUI.IsDraggable())
4313 if (!focusedItemComp)
4319 IEntity owner = slot.GetOwner();
4328 owner = owner.GetParent();
4338 m_bDraggingEnabled =
true;
4340 m_wDragDropContainer.SetVisible(
true );
4342 if ( m_pPreviewManager && m_pSelectedSlotUI )
4344 HighlightAvailableStorages(m_pSelectedSlotUI);
4345 IEntity previewEntity =
null;
4349 previewEntity = pComp.GetOwner();
4350 if (m_pDragDropPreviewImage)
4351 m_pPreviewManager.SetPreviewItem(m_pDragDropPreviewImage, previewEntity);
4354 ContainerSetPos( iMouseX, iMouseY );
4355 GetGame().GetInputManager().AddActionListener(
"Inventory_Drag", EActionTrigger.UP, Action_DragUp );
4359 ContainerSetPos( iMouseX, iMouseY );
4364 void Action_DragUp()
4366 GetGame().GetInputManager().RemoveActionListener(
"Inventory_Drag", EActionTrigger.PRESSED, Action_OnDrag );
4367 GetGame().GetInputManager().RemoveActionListener(
"Inventory_Drag", EActionTrigger.UP, Action_DragUp );
4368 if (m_pPreviewManager)
4369 m_pPreviewManager.SetPreviewItem(m_pDragDropPreviewImage,
null);
4370 GetGame().GetCallqueue().CallLater(m_wDragDropContainer.SetVisible, 0,
false,
false);
4372 m_bDraggingEnabled =
false;
4373 ResetHighlightsOnAvailableStorages();
4377 void ContainerSetPos(
int iMouseX,
int iMouseY )
4379 float fWidth, fHeight;
4380 WorkspaceWidget wWorkSpace =
GetGame().GetWorkspace();
4381 m_wDragDropContainer.GetScreenSize( fWidth, fHeight );
4382 fWidth = wWorkSpace.DPIUnscale( fWidth ) / 2;
4383 fHeight = wWorkSpace.DPIUnscale( fHeight ) / 2;
4385 m_pDragDropFrameSlotUI.SetPosX( wWorkSpace.DPIUnscale( iMouseX ) - fWidth );
4386 m_pDragDropFrameSlotUI.SetPosY( wWorkSpace.DPIUnscale( iMouseY ) - fHeight );
4393 IEntity pItem = m_pSelectedSlotUI.GetInventoryItemComponent().GetOwner();
4394 m_InventoryManager.InsertItem( pItem, pStorageBase.GetCurrentNavigationStorage(), m_pFocusedSlotUI.GetStorageUI().GetCurrentNavigationStorage() );
4395 ResetHighlightsOnAvailableStorages();
4406 if (openedStorage.GetStorage() == storage)
4407 return openedStorage;
4414 protected void Action_LootMove()
4416 if ( !m_pFocusedSlotUI )
4418 IEntity pItem = m_pFocusedSlotUI.GetInventoryItemComponent().GetOwner();
4422 m_pCallBack.m_pItem = pItem;
4423 m_pCallBack.m_pMenu =
this;
4426 if ( m_pFocusedSlotUI.GetStorageUI() == m_pStorageLootUI )
4428 m_pCallBack.m_pStorageFrom = m_pStorageLootUI;
4429 m_pCallBack.m_pStorageTo = m_pFocusedSlotUI.GetStorageUI();
4431 if ( m_pDisplayedStorage.Type() == EquipedWeaponStorageComponent )
4437 m_InventoryManager.InsertItem( pItem, m_pStorageBaseUI.GetCurrentNavigationStorage(), m_pStorageLootUI.GetCurrentNavigationStorage(), m_pCallBack );
4443 m_pCallBack.m_pStorageFrom = m_pFocusedSlotUI.GetStorageUI();
4444 m_pCallBack.m_pStorageTo = m_pStorageLootUI;
4445 auto storage = m_pStorageLootUI.GetCurrentNavigationStorage();
4447 m_InventoryManager.InsertItem( pItem, m_pStorageLootUI.GetCurrentNavigationStorage(), m_pDisplayedStorage, m_pCallBack );
4451 auto pSlot = m_pFocusedSlotUI.GetInventoryItemComponent().GetParentSlot();
4453 m_InventoryManager.TryRemoveItemFromInventory(pItem, pSlot.GetStorage(), m_pCallBack);
4456 ResetHighlightsOnAvailableStorages();
4461 protected bool IsStorageInsideLBS( BaseInventoryStorageComponent pStorage, ClothNodeStorageComponent pLBSStorage )
4465 array<BaseInventoryStorageComponent> aOutStorages =
new array<BaseInventoryStorageComponent>();
4466 pLBSStorage.GetOwnedStorages( aOutStorages, 1,
false );
4467 return aOutStorages.Find(pStorage) != -1;
4471 protected void OnItemAddedListener( IEntity item, notnull BaseInventoryStorageComponent storage )
4473 if ( storage == m_StorageManager.GetLootStorage() )
4476 if (m_pCallBack.m_pStorageToPickUp)
4478 if (item.FindComponent(BaseInventoryStorageComponent) != m_pCallBack.m_pStorageToPickUp)
4480 int quickSlotIndex = m_StorageManager.GetEntityQuickSlot(item);
4481 if (quickSlotIndex > -1)
4482 m_pQuickSlotStorage.RefreshSlot(quickSlotIndex);
4487 if ( storage.Type() == EquipedWeaponStorageComponent )
4489 if ( m_pWeaponStorage )
4490 m_pWeaponStorage.Refresh();
4492 else if ( storage.Type() == WeaponAttachmentsStorageComponent )
4495 if ( m_pWeaponStorage )
4496 m_pWeaponStorage.Refresh();
4502 storageUI.Refresh();
4505 if (m_StorageManager.IsItemAlreadyInQuickSlot(item))
4506 ShowQuickSlotStorage();
4508 UpdateTotalWeightText();
4512 protected void OnItemRemovedListener( IEntity item, notnull BaseInventoryStorageComponent storage )
4517 if (m_pCallBack.m_pStorageToDrop)
4519 if (item.FindComponent(BaseInventoryStorageComponent) != m_pCallBack.m_pStorageToDrop)
4521 int quickSlotIndex = m_StorageManager.GetEntityQuickSlot(item);
4522 if (quickSlotIndex > -1)
4523 m_pCallBack.m_bShouldUpdateQuickSlots =
true;
4528 SCR_ConsumableItemComponent consumable = SCR_ConsumableItemComponent.Cast(item.FindComponent(SCR_ConsumableItemComponent));
4529 if (consumable && consumable.GetConsumableEffect() && consumable.GetConsumableEffect().GetDeleteOnUse())
4531 if (m_wAttachmentStorage && m_pAttachmentStorageUI)
4532 m_pAttachmentStorageUI.Refresh();
4535 storageUI.Refresh();
4536 ShowQuickSlotStorage();
4539 if ( storage == m_StorageManager.GetLootStorage() )
4542 if (m_StorageManager.GetLastQuickSlotId(item) > -1)
4543 ShowQuickSlotStorage();
4547 storageUI.Refresh();
4549 UpdateTotalWeightText();
4555 if ( m_bDraggingEnabled )
4556 pContainer.ShowContainerBorder(
true );
4557 m_pActiveHoveredStorageUI = pContainer;
4558 pContainer.SetPagingActive(
true);
4559 NavigationBarUpdate();
4568 if (!m_pActiveHoveredStorageUI)
4575 IEntity itemEntity = itemComp.GetOwner();
4580 BaseInventoryStorageComponent originStorage;
4582 originStorage = itemParentSlot.GetStorage();
4585 SCR_InventoryStorageManagerComponent invManagerTo = m_pActiveHoveredStorageUI.GetInventoryManager();
4590 SCR_EntityCatalogManagerComponent entityCatalogManager = SCR_EntityCatalogManagerComponent.GetInstance();
4591 string smallestContainerPrefab =
"";
4593 if (entityCatalogManager)
4596 array<SCR_EntityCatalogEntry> entries = {};
4597 array<SCR_BaseEntityCatalogData>
data = {};
4601 if (!entries.IsEmpty())
4603 int minResourceValue;
4604 int currentEntryValue;
4608 minResourceValue = datum.GetMaxResourceValue();
4610 if (!minResourceValue)
4611 minResourceValue = 0;
4616 currentEntryValue = datum.GetMaxResourceValue();
4618 if (currentEntryValue > minResourceValue)
4621 minResourceValue = currentEntryValue;
4626 smallestContainerPrefab = entry.GetPrefab();
4631 BaseInventoryStorageComponent contStorage;
4632 array<BaseInventoryStorageComponent> contStorageOwnedStorages = {};
4633 SCR_EquipmentStorageComponent equipmentStorage;
4634 IEntity smallestContainerEntity;
4636 if (smallestContainerPrefab !=
"")
4637 smallestContainerEntity =
GetGame().SpawnEntityPrefabLocal(Resource.Load(smallestContainerPrefab));
4645 contStorage = storageBaseUI.GetStorage();
4648 if (originStorage && contStorage == originStorage)
4650 if (IsStorageInsideLBS(originStorage, ClothNodeStorageComponent.Cast(contStorage)))
4653 float itemWeight = itemComp.GetTotalWeight();
4654 float totalWeightWithInsertedItem;
4656 totalWeightWithInsertedItem = storageBaseUI.GetTotalRoundedUpWeight(contStorage);
4657 totalWeightWithInsertedItem += Math.Round(itemWeight * 100) * 0.01;
4659 storageBaseUI.UpdateTotalWeight(totalWeightWithInsertedItem);
4661 float totalOccupiedVolumeWithInsertedItem;
4662 totalOccupiedVolumeWithInsertedItem = storageBaseUI.GetOccupiedVolume(contStorage);
4663 totalOccupiedVolumeWithInsertedItem += itemComp.GetTotalVolume();
4665 contStorageOwnedStorages.Clear();
4666 contStorage.GetOwnedStorages(contStorageOwnedStorages, 1,
false);
4667 contStorageOwnedStorages.Insert(contStorage);
4669 bool shouldUpdateVolumePercentage =
true;
4672 for (
int i = 0, count = contStorageOwnedStorages.Count(); i < count; i++)
4674 equipmentStorage = SCR_EquipmentStorageComponent.Cast(contStorageOwnedStorages.Get(i));
4675 if (!equipmentStorage)
4678 bool canInsert =
m_InventoryManager.CanInsertItemInStorage(itemEntity, equipmentStorage, -1);
4679 bool canMove =
m_InventoryManager.CanMoveItemToStorage(itemEntity, equipmentStorage, -1);
4681 if (canInsert || canMove)
4683 shouldUpdateVolumePercentage =
false;
4688 if (!
m_InventoryManager.CanInsertItemInActualStorage(itemEntity, contStorage) && itemEntity.FindComponent(SCR_ResourceComponent))
4689 shouldUpdateVolumePercentage =
false;
4691 if (shouldUpdateVolumePercentage)
4692 storageBaseUI.UpdateVolumePercentage(storageBaseUI.GetOccupiedVolumePercentage(contStorage, totalOccupiedVolumeWithInsertedItem));
4694 bool canInsert =
m_InventoryManager.CanInsertItemInActualStorage(itemEntity, contStorage);
4696 if (!canInsert && SCR_ResourceComponent.FindResourceComponent(itemEntity))
4697 canInsert =
m_InventoryManager.CanInsertItemInActualStorage(smallestContainerEntity, contStorage);
4700 storageBaseUI.SetStorageAsHighlighted(
true);
4702 storageBaseUI.SetStorageAsHighlighted(
false);
4705 delete smallestContainerEntity;
4709 void ResetHighlightsOnAvailableStorages()
4716 storageBaseUI.UpdateVolumePercentage(storageBaseUI.GetOccupiedVolumePercentage(storageBaseUI.GetStorage()));
4717 storageBaseUI.UpdateTotalWeight(storageBaseUI.GetTotalRoundedUpWeight(storageBaseUI.GetStorage()));
4718 storageBaseUI.SetStorageAsHighlighted(
true);
4725 pContainer.ShowContainerBorder(
false );
4726 m_pActiveHoveredStorageUI =
null;
4727 pContainer.SetPagingActive(
false);
4728 NavigationBarUpdate();
4734 pContainer.ShowContainerBorder(
true);
4735 SetActiveStorage(pContainer);
4736 m_pActiveStorageUI = pContainer;
4737 NavigationBarUpdate();
4743 pContainer.ShowContainerBorder(
false);
4744 SetActiveStorage(pContainer);
4745 m_pActiveStorageUI =
null;
4746 NavigationBarUpdate();
4757 protected bool MoveOperation(
InventoryItemComponent pItemComponent, BaseInventoryStorageComponent pStorageTo )
4759 if ( !pItemComponent || !pStorageTo )
4761 Print(
"INV: Cannot perform move operation. Either item or storage doesn't exist", LogLevel.DEBUG );
4773 if (!m_pFocusedSlotUI)
4776 m_pCallBack.m_pStorageFrom = m_pFocusedSlotUI.GetStorageUI();
4778 m_InventoryManager.EquipWeapon( m_pFocusedSlotUI.GetInventoryItemComponent().GetOwner(), m_pCallBack );
4783 protected void RefreshUISlotStorages()
4793 protected void UpdateTotalWeightText()
4795 if (!m_wTotalWeightText)
4798 float weight = Math.Round(GetTotalWeight() * 100) * 0.01;
4803 m_wTotalWeightText.SetTextFormat(
"#AR-ValueUnit_Short_Kilograms", weight);
4806 protected void InitQuickSlots()
4808 ShowQuickSlotStorage();
4810 int quickSlotCount = m_StorageManager.GetQuickSlotItems().Count();
4811 for (
int slotId = 1; slotId <= quickSlotCount; ++slotId)
4813 GetGame().GetInputManager().AddActionListener(
"InventoryQuickSlot" + slotId, EActionTrigger.PRESSED, Action_SelectQuickSlot);
4819 void ShowQuickSlotStorage()
4821 if( m_wQuickSlotStorage )
4824 m_wQuickSlotStorage.RemoveFromHierarchy();
4827 Widget parent = m_widget.FindAnyWidget(
"QuickSlots" );
4828 m_wQuickSlotStorage =
GetGame().GetWorkspace().CreateWidgets(
"{A1E61EF091EAC47C}UI/layouts/Menus/Inventory/InventoryQuickSlotsGrid.layout", parent );
4830 if( !m_wQuickSlotStorage )
4833 OverlaySlot.SetVerticalAlign( m_wQuickSlotStorage, LayoutVerticalAlign.Bottom );
4834 OverlaySlot.SetHorizontalAlign(m_wQuickSlotStorage, LayoutHorizontalAlign.Left);
4842 void Action_SelectQuickSlot()
4848 int quickSlotCount = m_StorageManager.GetQuickSlotItems().Count();
4849 for (
int id = 1;
id <= quickSlotCount; ++id)
4856 SetItemToQuickSlot( iSlot );
4861 protected void RemoveItemFromQuickSlotDrop()
4863 if ( !m_pSelectedSlotUI )
4866 if ( !pInventoryComponent )
4868 m_StorageManager.StoreItemToQuickSlot( pInventoryComponent.GetOwner(), m_pSelectedSlotUI.GetSlotIndex() );
4869 ShowQuickSlotStorage();
4877 slot = m_pFocusedSlotUI;
4880 if (iSlotIndex < WEAPON_SLOTS_COUNT)
4886 || IsStorageArsenal(storageUI.GetCurrentNavigationStorage()))
4892 if ( !pInventoryComponent )
4894 IEntity pItem = pInventoryComponent.GetOwner();
4897 if (m_pWeaponStorageComp.Contains(pItem))
4900 if ( pItemAttributes && ( pItemAttributes.GetQuickSlotItemSize() !=
ESlotSize.SLOT_1x1 && pItemAttributes.GetQuickSlotItemSize() !=
ESlotSize.SLOT_2x1 ) )
4903 m_StorageManager.StoreItemToQuickSlot( pItem, --iSlotIndex );
4904 ShowQuickSlotStorage();
4909 protected void SetItemToQuickSlotDrop()
4911 if ( !m_pFocusedSlotUI )
4913 if ( !m_pSelectedSlotUI )
4917 if (selectedSlotStorage &&
4919 IsStorageArsenal(selectedSlotStorage.GetCurrentNavigationStorage()))
4924 IEntity pOriginalEntity;
4930 pOriginalEntity = pComp.GetOwner();
4935 if ( !pInventoryComponent )
4938 if ( pItemAttributes && ( pItemAttributes.GetQuickSlotItemSize() !=
ESlotSize.SLOT_1x1 && pItemAttributes.GetQuickSlotItemSize() !=
ESlotSize.SLOT_2x1 ) )
4943 int iSlotIndex = m_pFocusedSlotUI.GetSlotIndex();
4945 if (iSlotIndex < WEAPON_SLOTS_COUNT || m_pWeaponStorageComp.Contains(pInventoryComponent.GetOwner()))
4947 ShowQuickSlotStorage();
4952 m_StorageManager.StoreItemToQuickSlot( pInventoryComponent.GetOwner(), iSlotIndex );
4953 if ( pOriginalEntity )
4954 m_StorageManager.StoreItemToQuickSlot( pOriginalEntity, m_pSelectedSlotUI.GetSlotIndex() );
4955 ShowQuickSlotStorage();
4959 SetStorageSwitchMode(
false);
4960 Action_DeselectItem();
4961 FocusOnSlotInStorage(m_pQuickSlotStorage, iSlotIndex);
4967 if (!item1 || !item2)
4970 IEntity from = item1.GetInventoryItemComponent().GetOwner();
4971 IEntity to = item2.GetInventoryItemComponent().GetOwner();
4976 m_pCallBack.m_pStorageFrom = m_pSelectedSlotUI.GetStorageUI();
4977 m_pCallBack.m_pStorageTo = m_pFocusedSlotUI.GetStorageUI();
4978 m_pCallBack.m_pItem = from;
4979 m_pCallBack.m_pMenu =
this;
4980 m_pCallBack.m_pStorageToFocus = m_pCallBack.m_pStorageFrom;
4990 toStorage = m_pFocusedSlotUI.GetStorageUI();
4992 if (!toStorage || !m_pSelectedSlotUI)
4995 MoveItem(toStorage);
4996 ResetHighlightsOnAvailableStorages();
4999 void OnAttachmentSpinboxFocused()
5001 NavigationBarUpdate();
5005 bool IsUsingGamepad()
5011 void OnInputDeviceIsGamepad(
bool isGamepad)
5015 SetAttachmentSpinBoxActive(isGamepad);
5016 NavigationBarUpdate();
5034 BaseContainer vs =
GetGame().GetGameUserSettings().GetModule(
"SCR_VideoSettings");
5038 vs.Get(
"m_iViewDistance", dist);
5039 GetGame().SetViewDistance(dist);
5044 protected float GetTotalLoadWeight();
5045 SCR_InventoryStorageManagerComponent GetInventoryStorageManager();
5046 bool GetCanInteract();
5047 override void OnMenuOpen();
5048 protected void Init();
5050 void ShowStorage( BaseInventoryStorageComponent storage );
5051 protected void ShowStoragesList();
5053 protected void ShowEquipedWeaponStorage();
5054 void ShowItemInfo(
string sName =
"",
string sDescr =
"",
float sWeight = 0.0 );
5055 void HideItemInfo();
5059 void FilterOutStorages();
5060 protected void Action_CloseInventory();
5061 protected void Action_SelectItem();
5062 protected void Action_EquipItem();
5063 protected void Action_Drop();
5064 protected void Action_Inspect();
5065 protected void OnItemAddedListener( IEntity item, BaseInventoryStorageComponent storage );
5066 protected void OnItemRemovedListener( IEntity item, BaseInventoryStorageComponent storage );
5067 override bool OnClick( Widget w,
int x,
int y,
int button );
5068 void FilterOutStorages(
false );