Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_InventoryMenuUI.c
Go to the documentation of this file.
13
20
27
34
41
54
56{
57 OK = 1 << 0,
58 SIZE = 1 << 1,
59 WEIGHT = 1 << 2,
60 CAPACITY = 1 << 3
61};
62
63//------------------------------------------------------------------------------------------------
65{
66 SCR_InventoryStorageBaseUI m_pStorageFrom;
67 SCR_InventoryStorageBaseUI m_pStorageTo;
68 SCR_InventoryStorageBaseUI m_pStorageToFocus;
69 SCR_InventoryStorageManagerComponent m_pStorageMan;
70
71 BaseInventoryStorageComponent m_pStorageToDrop;
72 BaseInventoryStorageComponent m_pStorageToPickUp;
73
74 EAttachAction m_eAttachAction = EAttachAction.NONE;
75 IEntity m_pItem;
76 SCR_InventoryMenuUI m_pMenu;
77 ResourceName m_sItemToFocus;
78 int m_iSlotToFocus;
79 bool m_bShouldEquip;
80 bool m_bUpdateSlotOnly;
81 bool m_bShouldUpdateQuickSlots;
82
83 //------------------------------------------------------------------------------------------------
85 void InternalComplete()
86 {
87 OnComplete();
88 }
89
90 //------------------------------------------------------------------------------------------------
92 void InternalFailed()
93 {
94 OnFailed();
95 }
96
97 //------------------------------------------------------------------------------------------------
98 protected override void OnFailed()
99 {
100 if (m_pMenu && m_pItem && m_bShouldEquip)
101 {
102 m_pMenu.GetCharacterController().TryEquipRightHandItem(m_pItem, EEquipItemType.EEquipTypeWeapon, false);
103 m_bShouldEquip = false;
104 }
105
106 if (m_pMenu)
107 m_pMenu.Action_DeselectItem();
108 }
109
110 //------------------------------------------------------------------------------------------------
111 protected override void OnComplete()
112 {
113 if (m_pMenu && m_pItem && m_bShouldEquip)
114 {
115 m_pMenu.GetCharacterController().TryEquipRightHandItem(m_pItem, EEquipItemType.EEquipTypeWeapon, false);
116 m_bShouldEquip = false;
117 }
118
119 if (m_eAttachAction == EAttachAction.ATTACH)
120 {
121 if (m_pStorageMan)
122 m_pStorageMan.PlayItemSound(m_pItem, SCR_SoundEvent.SOUND_EQUIP);
123 }
124 else if (m_eAttachAction == EAttachAction.DETACH)
125 {
126 if (m_pStorageMan)
127 m_pStorageMan.PlayItemSound(m_pItem, SCR_SoundEvent.SOUND_UNEQUIP);
128 }
129
130 m_eAttachAction = EAttachAction.NONE;
131
132 bool shouldUpdateStorageList;
133 if ( m_pStorageFrom )
134 {
135 if ( m_pMenu )
136 {
137 if ( m_pStorageFrom == m_pMenu.GetStorageList() )
138 {
139 shouldUpdateStorageList = true;
140 }
141 else
142 {
143 if (m_bUpdateSlotOnly)
144 {
145 m_pStorageFrom.UpdateSlotUI(m_sItemToFocus);
146 m_bUpdateSlotOnly = false;
147 }
148 else
149 {
150 BaseInventoryStorageComponent storage = m_pStorageFrom.GetCurrentNavigationStorage();
151 auto open = m_pMenu.GetOpenedStorage(storage);
152 if (open)
153 open.Refresh();
154
155 if (m_pItem)
156 {
157 auto itemStorage = BaseInventoryStorageComponent.Cast(m_pItem.FindComponent(BaseInventoryStorageComponent));
158 open = m_pMenu.GetOpenedStorage(itemStorage);
159 if (open)
160 open.CloseStorage();
161 }
162
163 if (m_pStorageFrom)
164 m_pStorageFrom.Refresh();
165 }
166 }
167 }
168 }
169 else
170 {
171 if ( m_pMenu )
172 {
173 shouldUpdateStorageList = true;
174 }
175 }
176
177 if ( m_pStorageTo )
178 {
179 if ( m_pMenu )
180 {
181 if ( m_pStorageTo == m_pMenu.GetStorageList() )
182 {
183 shouldUpdateStorageList = true;
184
185 auto itemStorage = BaseInventoryStorageComponent.Cast(m_pItem.FindComponent(BaseInventoryStorageComponent));
186 SCR_InventoryOpenedStorageUI open = m_pMenu.GetOpenedStorage(itemStorage);
187 if (open)
188 open.CloseStorage();
189 }
190 else
191 {
192 m_pStorageTo.Refresh();
193 BaseInventoryStorageComponent storage = m_pStorageTo.GetCurrentNavigationStorage();
194 auto open = m_pMenu.GetOpenedStorage(storage);
195 if (open)
196 open.Refresh();
197 }
198 }
199 }
200
201 if (m_pItem)
202 {
203 InventoryItemComponent inventoryItemComp = InventoryItemComponent.Cast(m_pItem.FindComponent(InventoryItemComponent));
204 InventoryStorageSlot parentSlot;
205 if (inventoryItemComp)
206 parentSlot = inventoryItemComp.GetParentSlot();
207
208 SCR_HandSlotStorageComponent handSlotStorage;
209 if (parentSlot)
210 handSlotStorage = SCR_HandSlotStorageComponent.Cast(parentSlot.GetStorage());
211
212 if (handSlotStorage)
213 handSlotStorage.SkipAnimation_S();
214 }
215
216 if (shouldUpdateStorageList)
217 {
218 m_pMenu.ShowStoragesList();
219 m_pMenu.ShowAllStoragesInList();
220 }
221
222 if ( m_pMenu )
223 {
224 if ( m_pStorageFrom != m_pMenu.GetLootStorage() && m_pStorageTo != m_pMenu.GetLootStorage() )
225 m_pMenu.RefreshLootUIListener();
226
227 SCR_InventoryStorageBaseUI pStorage = m_pMenu.GetActualStorageInCharacterStorageUI();
228 if ( pStorage )
229 {
230 if ( pStorage.Type() == SCR_InventoryStorageWeaponsUI )
231 pStorage = m_pMenu.GetStorageList();
232 //pStorage.Refresh();
233 }
234
235 m_pMenu.NavigationBarUpdate();
236 m_pMenu.RefreshPlayerWidget();
237 }
238
239 if (m_pStorageToFocus)
240 {
241 m_pMenu.FocusOnSlotInStorage(m_pStorageToFocus, m_iSlotToFocus);
242 m_iSlotToFocus = -1;
243 }
244
245 if (!m_bShouldEquip && m_pStorageTo && m_pStorageTo.IsInherited(SCR_InventoryStorageLootUI))
246 SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_INV_CONTAINER_DIFR_DROP);
247
248 if (m_pStorageToDrop)
249 {
250 if (m_pMenu && m_bShouldUpdateQuickSlots)
251 m_pMenu.ShowQuickSlotStorage();
252 m_pStorageToDrop = null;
253 }
254
255 if (m_pStorageToPickUp)
256 {
257 if (m_pMenu && m_bShouldUpdateQuickSlots)
258 m_pMenu.ShowQuickSlotStorage();
259 m_pStorageToPickUp = null;
260 }
261
262 m_bShouldUpdateQuickSlots = false;
263
265 }
266
267 //------------------------------------------------------------------------------------------------
268 protected void ResetVariables()
269 {
270 m_pStorageToFocus = null;
271 m_pStorageTo = null;
272 m_pStorageFrom = null;
273 }
274
275};
276
277//------------------------------------------------------------------------------------------------
280
283typedef ScriptInvokerBase<InventorySlotHoverMethod> ScriptInvokerInventorySlotHover;
284
286{
287
288 #ifndef DISABLE_INVENTORY
289 static protected ResourceName m_ItemPreviewManagerPrefab = "{9F18C476AB860F3B}Prefabs/World/Game/ItemPreviewManager.et";
290 protected SCR_InventoryStorageManagerComponent m_InventoryManager = null;
296 protected Widget m_widget;
297
299
303
307
314 protected ref array<SCR_InventoryOpenedStorageUI> m_aOpenedStoragesUI = {};
316
322 protected ref array<SCR_InventorySlotUI> m_aShownStorages = new array<SCR_InventorySlotUI>(); //used for storing pointers on storages which are displayed on screen ( for the refreshing purposes )
324 protected const int STORAGE_AREA_COLUMNS = 2;
325 protected int m_iStorageListCounter = 0;
326 protected int m_iVicinityDiscoveryRadius = 0;
327
331
332 const string ARSENAL_STORAGE_LAYOUT = "{5C4812D758C0EDB8}UI/layouts/Menus/Inventory/SupplyInventoryContainerGrid.layout";
333 const string BACKPACK_STORAGE_LAYOUT = "{E61475CBB560757F}UI/layouts/Menus/Inventory/InventoryContainerGrid.layout";
334 const string WEAPON_STORAGE_LAYOUT = "{7B28D87B8A1ADD42}UI/layouts/Menus/Inventory/InventoryWeaponSlots.layout";
335 const string STORAGES_LIST_LAYOUT = "{FC579324F5E4B3A4}UI/layouts/Menus/Inventory/InventoryCharacterGrid.layout";
336 const string ITEM_INFO = "{7BA9AFEC71DAC3CF}UI/layouts/Menus/Inventory/InventoryInfo.layout";
337 const string DAMAGE_INFO = "{55AFA256E1C20FB2}UI/layouts/Menus/Inventory/InventoryDamageInfo.layout";
338
339 const string STORAGE_LAYOUT_CLOSE_WIDGET_NAME = "CloseStorageBtn";
340
341 const ResourceName HITZONE_CONTAINER_LAYOUT= "{36DB099B4CDF8FC2}UI/layouts/Menus/Inventory/Medical/HitZonePointContainer.layout";
342
343 [Attribute("{01E150D909447632}Configs/Damage/DamageStateConfig.conf", desc: "Config to get visual data from", params: "conf class=SCR_DamageStateConfig")]
345
346
347 protected EStateMenuStorage m_EStateMenuStorage = EStateMenuStorage.STATE_IDLE; // is this useful for anything?
349 protected string m_sFSMStatesNames[10]={"init", "idle", "item selected", "storage selected", "STATE_STORAGE_OPENED", "storage unfolded", "move started", "move finished", "closing", "STATE_UNKNOWN" };
352
353 const protected ResourceName m_sSupplyCostUIInfoPrefab = "{4D8296CB3CB3B8BF}Configs/Inventory/SupplyCost_ItemUIInfo.conf";
355 const protected ResourceName m_sSupplyRefundUIInfoPrefab = "{6FD3DF5A3B2C6D30}Configs/Inventory/ItemHints/SupplySell_ItemHint.conf";
357 const protected ResourceName m_sNonrefundableUIInfoPrefab = "{B3E94EB9D0F0EAC6}Configs/Inventory/ItemHints/Nonrefundable_ItemHint.conf";
359 protected const ResourceName ITEM_RANK_PREFAB = "{B329E7CABD481EF6}Configs/Inventory/ItemHints/ArsenalItemRank_ItemHint.conf";
361 protected const ResourceName VALUABLE_INTEL_UIINFO_PREFAB = "{5EE3196892CA5142}Configs/Inventory/ItemHints/ValuableIntel_ItemHint.conf";
363 protected const ResourceName PLAYER_SUPPLY_ALLOCATION_UIINFO_PREFAB = "{4A370E79EF2FCC54}Configs/Inventory/ItemHints/MSARCost_ItemHint.conf";
365
366 protected const ResourceName ITEM_FACTION_INFO_CONFIG = "{80DCFB729B7255F7}Configs/Inventory/ItemHints/ItemFaction_ItemHint.conf";
368
369 //variables dedicated to move an item from storage to storage
370 protected IEntity m_pItem;
371 protected BaseInventoryStorageComponent m_pDisplayedStorage, m_pLastCurrentNavStorage;
372 protected BaseInventoryStorageComponent m_pStorageFrom, m_pStorageTo; //last known storages from the last move operation
373// protected SCR_InventorySlotUI m_pStorageUIFrom;
374 protected SCR_InventorySlotStorageUI m_pStorageUITo; //last known storagesUI from the last move operation
380 protected ItemPreviewManagerEntity m_pPreviewManager;
381 protected bool m_bDraggingEnabled;
385 protected ref array<SCR_InventoryStorageBaseUI> m_aStorages = {};
387 protected bool m_bLocked = false; //helper variable
388
389 //Item/Weapon Switching
393 const int WEAPON_SLOTS_COUNT = 4;
394
395 protected bool m_bIsUsingGamepad;
396 protected float m_fX, m_fY; //debug;
397 protected bool m_bShowIt = true;
398 protected int m_iMouseX, m_iMouseY
399 const int DRAG_THRESHOLD = 1;
400
401 //other character's information
403 //protected ProgressBarWidget m_wInfoStamina; // Preparation for showing the stamina level in inventory
404 protected ref array<HitZone> m_aBleedingHitZones = {};
405
407 protected bool m_bWasJustTraversing;
408 protected bool m_bStorageSwitchMode;
410
412 protected ref array<SCR_InventoryHitZonePointContainerUI> m_aHitZonePoints = {};
413
414 protected SCR_InventoryHitZonePointUI m_bleedingHandlerGlobal;
415 protected SCR_InventoryHitZonePointUI m_fractureHandlerGlobal;
418
420 protected const int CHARACTER_HITZONES_COUNT = 7;
421
423
424 protected bool m_bProcessInitQueue = false;
427
428 protected const string BUTTON_USE = "ButtonUse";
429 protected const string BUTTON_BUY = "ButtonBuy";
430 protected const string BUTTON_SELL = "ButtonSell";
431 protected const string BUTTON_BACK = "ButtonBack";
432 protected const string BUTTON_DROP = "ButtonDrop";
433 protected const string BUTTON_MOVE = "ButtonMove";
434 protected const string BUTTON_SWAP = "ButtonSwap";
435 protected const string BUTTON_EQUIP = "ButtonEquip";
436 protected const string BUTTON_SELECT = "ButtonSelect";
437 protected const string BUTTON_PICK_UP = "ButtonPickup";
438 protected const string BUTTON_INSPECT = "ButtonInspect";
439 protected const string BUTTON_STEP_BACK = "ButtonStepBack";
440 protected const string BUTTON_OPEN_STORAGE = "ButtonOpenStorage";
441 protected const string BUTTON_QUICK_ASSIGN = "ButtonQuickSlotAssign";
442 protected const string BUTTON_ENTER_STORAGE = "ButtonEnterStorage";
443 protected const string BUTTON_QUICK_UNASSIGN = "ButtonQuickSlotUnassign";
444 protected const string BUTTON_OPEN_NEW_CONTAINER = "ButtonOpenAsContainer";
445 protected const string BUTTON_REMOVE_TOURNIQUET = "ButtonRemoveTourniquet";
446
447 protected const LocalizedString GAMEPAD_HINT_BACK = "#AR-Menu_Back";
448 protected const LocalizedString GAMEPAD_HINT_MOVE = "#AR-Inventory_Move";
449 protected const LocalizedString GAMEPAD_HINT_CLOSE = "#AR-Inventory_Close";
450 protected const LocalizedString GAMEPAD_HINT_SELECT = "#AR-Inventory_Select";
451 protected const LocalizedString GAMEPAD_HINT_DESELECT = "#AR-Inventory_Deselect";
452
454 protected static ref ScriptInvoker m_OnItemHoverEnd;
455
456 //------------------------------------------------------------------------------------------------
464
465 //------------------------------------------------------------------------------------------------
467 {
470
471 return m_OnItemHoverEnd;
472 }
473
474 //------------------------------------------------------------------------------------------------
475 ItemPreviewManagerEntity GetItemPreviewManager()
476 {
477 return m_pPreviewManager;
478 }
479
480 //------------------------------------------------------------------------------------------------
482 {
484 m_AttachmentSpinBox.ClearAll();
485
486 const Widget bleeding = m_widget.FindAnyWidget("BleedingGlobal");
487 const Widget fracture = m_widget.FindAnyWidget("FractureGlobal");
488 const Widget morphineTimer = m_widget.FindAnyWidget("MorphineTimer");
489 const Widget salineTimer = m_widget.FindAnyWidget("SalineTimer");
490
491 m_CharController = SCR_CharacterControllerComponent.Cast(m_Player.GetCharacterController());
493 if (bleeding)
494 m_bleedingHandlerGlobal = SCR_InventoryHitZonePointUI.Cast(bleeding.FindHandler(SCR_InventoryHitZonePointUI));
495
496 if (fracture)
497 m_fractureHandlerGlobal = SCR_InventoryHitZonePointUI.Cast(fracture.FindHandler(SCR_InventoryHitZonePointUI));
498
499 if (morphineTimer)
501
502 if (salineTimer)
504 }
505
506 protected bool InitHitZones(bool batchProcessing = false)
507 {
508 const int hzToInit = m_aHitZonePoints.Count();
509 if (hzToInit >= CHARACTER_HITZONES_COUNT)
510 return true;
511
512 const bool updateAttachmentStorage = !batchProcessing || hzToInit + 1 == CHARACTER_HITZONES_COUNT;
513 const Widget w = GetGame().GetWorkspace().CreateWidgets(HITZONE_CONTAINER_LAYOUT, m_wAttachmentPointsContainer);
515 point.InitializeHitZoneUI(m_pStorageListUI.GetStorage(), this, hzToInit + 1, m_Player, updateAttachmentStorage);
516 m_aHitZonePoints.Insert(point);
517
518 return false;
519 }
520
521 //------------------------------------------------------------------------------------------------
524 protected void InitializeAllHitZonesUI(bool startingTheProcess = true)
525 {
526 if (startingTheProcess)
527 {
528 if (!m_aHitZonePoints.IsEmpty())
529 return;
530
531 InitializeCharacterHitZones(); // clear existing data and prepare sources for fetching new data
532 }
533
534 InitHitZones(true);
536 {
537 GetGame().GetCallqueue().CallLater(InitializeAllHitZonesUI, param1: false); //spread the initialization onto different frames as initialization of HZ is expensive
538 return;
539 }
540
541 OnDamageStateChanged(); // update the visualization of current effects
542 UpdateCharacterPreview(); // update the preview and the position of the hit zone indicators
543 }
544
545 //------------------------------------------------------------------------------------------------
546 protected void HideCharacterHitZones()
547 {
549 m_AttachmentSpinBox.ClearAll();
551 m_bleedingHandlerGlobal.GetRootWidget().SetVisible(false);
552
554 m_fractureHandlerGlobal.GetRootWidget().SetVisible(false);
555
557 m_morphineTimerHandlerGlobal.GetRootWidget().SetVisible(false);
558
560 m_salineTimerHandlerGlobal.GetRootWidget().SetVisible(false);
561
563 {
564 point.GetRootWidget().RemoveFromHierarchy();
565 }
566
567 m_aHitZonePoints.Clear();
568 }
569
570 //------------------------------------------------------------------------------------------------
571 // !
573 {
574 SCR_CharacterBloodHitZone charBloodHZ = m_CharDamageManager.GetBloodHitZone();
575 charBloodHZ.GetOnDamageStateChanged().Insert(OnDamageStateChanged);
576
577 m_CharDamageManager.GetOnDamageEffectAdded().Insert(OnDamageStateChanged);
578 m_CharDamageManager.GetOnDamageEffectRemoved().Insert(OnDamageStateChanged);
579 m_CharDamageManager.GetOnDamageStateChanged().Insert(OnDamageStateChanged);
581 }
582
583 //------------------------------------------------------------------------------------------------
585
586 //------------------------------------------------------------------------------------------------
588
589 //------------------------------------------------------------------------------------------------
591
592 //------------------------------------------------------------------------------------------------
594
595 //------------------------------------------------------------------------------------------------
596 void AddItemToAttachmentSelection(string item, Managed data = null)
597 {
598 if (item.IsEmpty())
599 return;
600 if (m_AttachmentSpinBox.FindItem(item) < 0)
601 m_AttachmentSpinBox.AddItem(item, false, data);
602
604 }
605
606 //------------------------------------------------------------------------------------------------
608 {
609 int index = m_AttachmentSpinBox.FindItem(item);
610 if (index > -1)
611 m_AttachmentSpinBox.RemoveItem(index, false);
612
613 if (m_pDamageInfo && m_pDamageInfo.GetName() == item)
614 m_pDamageInfo.Destroy();
615
617 }
618
619 //------------------------------------------------------------------------------------------------
624
625 //------------------------------------------------------------------------------------------------
626 // !
628 {
629 SCR_CharacterBloodHitZone charBloodHZ = m_CharDamageManager.GetBloodHitZone();
630
631 //TODO@FAC change this strong treshold and make better condition when effects work
632 const bool bleedingVisible = (charBloodHZ.GetHealthScaled() <= charBloodHZ.GetDamageStateThreshold(ECharacterBloodState.STRONG));
633 float bleedingAmount = Math.InverseLerp(
634 charBloodHZ.GetDamageStateThreshold(ECharacterBloodState.UNCONSCIOUS),
635 charBloodHZ.GetDamageStateThreshold(ECharacterBloodState.UNDAMAGED),
636 charBloodHZ.GetHealthScaled());
637
639 {
640 m_bleedingHandlerGlobal.GetRootWidget().SetVisible(bleedingVisible);
641 m_bleedingHandlerGlobal.SetBloodLevelProgress(bleedingAmount);
642 }
643
645 m_fractureHandlerGlobal.GetRootWidget().SetVisible(m_CharDamageManager.GetMovementDamage() > 0);
646
647 bool visible = false;
649 {
650 array<ref SCR_PersistentDamageEffect> effects = {};
651 m_CharDamageManager.FindAllDamageEffectsOfTypeOnHitZone(SCR_MorphineDamageEffect, m_CharDamageManager.GetDefaultHitZone(), effects);
652
653 foreach (SCR_PersistentDamageEffect effect : effects)
654 {
655 visible = true;
656 break;
657 }
658
659 m_morphineTimerHandlerGlobal.GetRootWidget().SetVisible(visible);
660 }
661
663 {
664 visible = false;
665 array<ref SCR_PersistentDamageEffect> effects = {};
666 m_CharDamageManager.FindAllDamageEffectsOfTypeOnHitZone(SCR_SalineDamageEffect, charBloodHZ, effects);
667
668 foreach (SCR_PersistentDamageEffect effect : effects)
669 {
670 visible = true;
671 break;
672 }
673
674 m_salineTimerHandlerGlobal.GetRootWidget().SetVisible(visible);
675 }
676 }
677
678 //------------------------------------------------------------------------------------------------
679 // !
681 {
682 if ( m_aShownStorages.Find( pStorageUI ) > -1 )
683 return;
684
685 if ( SCR_InventorySlotStorageUI.Cast( pStorageUI ) || SCR_InventorySlotWeaponUI.Cast( pStorageUI ) )
686 m_aShownStorages.Insert( pStorageUI );
687 }
688
689 //------------------------------------------------------------------------------------------------
690 // !
692 {
693 if ( pStorageUI )
694 m_aShownStorages.RemoveItem( pStorageUI );
695 }
696
697 //------------------------------------------------------------------------------------------------
705
706 //------------------------------------------------------------------------------------------------
707 //---Get total weight from all storages (weapon, gadget, deposit)
708 protected float GetTotalWeight()
709 {
711 return 0;
712
713 return m_InventoryManager.GetTotalWeightOfAllStorages();
714 }
715
716 //------------------------------------------------------------------------------------------------
717 SCR_InventoryStorageManagerComponent GetInventoryStorageManager()
718 {
719 return m_InventoryManager;
720 }
721
722 //------------------------------------------------------------------------------------------------
727
728 //------------------------------------------------------------------------------------------------
731 {
733 return false;
734
735 return true;
736 }
737
738 //------------------------------------------------------------------------------------------------
740 {
742 return;
743
745 {
747 return;
748 }
749
750 if (m_wPlayerRender)
754 }
755
756 protected bool ProcessInitQueue()
757 {
758 switch (m_eInitStage)
759 {
760 case EInvInitStage.BEGIN:
761 {
762 m_eInitStage = EInvInitStage.NAVIGATION_BAR;
763 } break;
764
765 case EInvInitStage.NAVIGATION_BAR:
766 {
767 m_pNavigationBar.SetAllButtonEnabled(false);
768 m_pNavigationBar.FillFromConfig();
770 m_eInitStage = EInvInitStage.QUICK_SLOTS;
771 } break;
772
773 case EInvInitStage.QUICK_SLOTS:
774 {
776 m_eInitStage = EInvInitStage.WEAPON_STORAGE;
777 } break;
778
779 case EInvInitStage.WEAPON_STORAGE:
780 {
782 m_eInitStage = EInvInitStage.STORAGE_LIST;
783 } break;
784
785 case EInvInitStage.STORAGE_LIST:
786 {
788 m_eInitStage = EInvInitStage.STORAGES;
789 } break;
790
791 case EInvInitStage.STORAGES:
792 {
794 m_eInitStage = EInvInitStage.HIT_ZONES;
795 } break;
796
797 case EInvInitStage.HIT_ZONES:
798 {
799 if (InitHitZones())
800 {
801 m_wPlayerRender.SetVisible(true);
802
804 }
805 } break;
806
807 case EInvInitStage.DONE:
808 {
810 return true;
811 }
812 }
813
814 return false;
815 }
816
817 protected void OnQueueProcessed()
818 {
819 m_bProcessInitQueue = false;
820 m_wAttachmentPointsContainer.SetVisible(true);
824 m_LoadingOverlay.GetRootWidget().RemoveFromHierarchy();
825 }
826
827 //------------------------------------------------------------------------------------------------
828 override void OnMenuUpdate(float tDelta)
829 {
830 super.OnMenuUpdate(tDelta);
831
833 {
834 if (!ProcessInitQueue())
835 return;
836 }
837
839 GetGame().GetInputManager().ActivateContext("InventoryPagingContext");
840
841 GetGame().GetInputManager().ActivateContext("InventoryMenuContext");
842
844 {
845 m_InspectionScreen.UpdateView(tDelta);
846 return;
847 }
848
850 {
852 }
853 }
854
855 //------------------------------------------------------------------------------------------------
857 {
860 else
862 }
863
864 //------------------------------------------------------------------------------------------------
865 protected void UpdateCharacterPreview()
866 {
867 if (!m_wPlayerRender)
868 return;
869
871
872 for (int i, count = m_aHitZonePoints.Count(); i < count; i++)
873 {
875 if (!hp)
876 continue;
877 TNodeId id = hp.GetBoneIndex();
878
879 vector transform[4];
880 Math3D.MatrixIdentity4(transform);
881 float xOffset = 0;
883 xOffset = -40;
884
885 vector screenPos;
886 if (m_wPlayerRender.TryGetItemNodePositionInWidgetSpace(id, transform, screenPos))
887 {
888 FrameSlot.SetPos(hp.GetRootWidget(), screenPos[0] + xOffset, screenPos[1]);
889 }
890 }
891 }
892
893 //------------------------------------------------------------------------------------------------
895 {
896 if (!m_pInspectedSlot)
897 {
898 InspectItem(null);
899 return;
900 }
901
902 InventoryItemComponent itemComp = m_pInspectedSlot.GetInventoryItemComponent();
903
904 if (!itemComp)
905 {
906 InspectItem(null);
907 return;
908 }
909
910 m_pPreviewManager.SetPreviewItem(m_wPlayerRender, itemComp.GetOwner(), m_PlayerRenderAttributes, true);
911
913 m_pGearInspectionPointUI.UpdatePreviewSlotWidgets(m_wPlayerRender);
914 }
915
916 //------------------------------------------------------------------------------------------------
917 override void OnMenuOpen()
918 {
919 if( !Init() )
920 {
922 return;
923 }
924
925 GetGame().SetViewDistance(GetGame().GetMinimumViewDistance());
926
927 ShowVicinity();
928
929 m_bProcessInitQueue = true;
930
932 {
933 m_wPlayerRender = ItemPreviewWidget.Cast( m_widget.FindAnyWidget( "playerRender" ) );
934 auto collection = m_StorageManager.GetAttributes();
935 if (collection)
937
939 }
940
941 if( m_pNavigationBar )
942 m_pNavigationBar.m_OnAction.Insert(OnAction);
943
944 GetGame().GetInputManager().AddActionListener("Inventory_Drag", EActionTrigger.DOWN, Action_DragDown);
945 GetGame().GetInputManager().AddActionListener("Inventory", EActionTrigger.DOWN, Action_CloseInventory);
947 OnInputDeviceIsGamepad(!GetGame().GetInputManager().IsUsingMouseAndKeyboard());
948 GetGame().OnInputDeviceIsGamepadInvoker().Insert(OnInputDeviceIsGamepad);
949
951
953 if (!SetOpenStorage())
954 SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_INV_OPEN);
956
960 }
961
963 {
965 {
966 m_AttachmentSpinBox.ClearAll();
967 return;
968 }
969
970 Widget w = m_widget.FindAnyWidget("AttachmentSpinBox");
971 if (!w)
972 {
973 Print("Cannot find AttachmentSpinBox widget in hierarchy!", LogLevel.ERROR);
974 return;
975 }
976
978 m_AttachmentSpinBox.m_OnChanged.Insert(NavigationBarUpdate);
979 }
980
981
982 //------------------------------------------------------------------------------------------------
983 protected void SetStorageSwitchMode(bool enabled, bool updateNavBar = true)
984 {
985 m_bStorageSwitchMode = enabled;
986 foreach (SCR_InventoryStorageBaseUI storage : m_aStorages)
987 {
988 if (storage)
989 storage.ActivateStorageButton(m_bStorageSwitchMode);
990 }
991
992 m_pStorageLootUI.ActivateStorageButton(m_bStorageSwitchMode);
994 m_pStorageListUI.ActivateStorageButton(m_bStorageSwitchMode);
995
997 {
998 storage.ActivateStorageButton(m_bStorageSwitchMode);
999 }
1000
1002 {
1003 HideItemInfo();
1006 focusedStorage = m_pActiveStorageUI;
1007
1008 // delay by one frame or else when you are selecting an item for transfer (specifically observed with supplies), then game might think that you depressed the transfer button with focus being on this storage, thus instantly dropping that selected item into this storage
1009 GetGame().GetCallqueue().Call(FocusWidget, param1: focusedStorage.GetButtonWidget());
1010 }
1011 else if (m_pActiveStorageUI)
1012 {
1013 const SCR_InventoryStorageBaseUI previouslyFocusedStorage = m_pActiveStorageUI; // store locally a reference to it as when focus is transfered, then m_pActiveStorageUI may change or even become null
1015 previouslyFocusedStorage.ShowContainerBorder(false);
1016 }
1017
1018 if (updateNavBar)
1020 }
1021
1022 //------------------------------------------------------------------------------------------------
1027
1028 protected void SetAttachmentSpinBoxActive(bool enable)
1029 {
1031 return;
1032
1033 const int itemCount = m_AttachmentSpinBox.GetNumItems();
1034 const bool shouldBeActive = (enable && (itemCount > 0));
1035
1036 m_AttachmentSpinBox.SetEnabled(shouldBeActive);
1037
1038 const Widget rootWidget = m_AttachmentSpinBox.GetRootWidget();
1039 rootWidget.SetVisible(shouldBeActive);
1040
1041 const Widget leftArea = m_widget.FindAnyWidget("LeftArea");
1042 const Widget rightArea = m_widget.FindAnyWidget("StoragesListSlot");
1043
1044 // Switches navigation targets based on the presence of the spinbox in the center
1045 if (shouldBeActive)
1046 {
1047 leftArea.SetNavigation(WidgetNavigationDirection.RIGHT, WidgetNavigationRuleType.EXPLICIT, "AttachmentSpinBox");
1048 rightArea.SetNavigation(WidgetNavigationDirection.LEFT, WidgetNavigationRuleType.EXPLICIT, "AttachmentSpinBox");
1049 rootWidget.SetNavigation(WidgetNavigationDirection.RIGHT, WidgetNavigationRuleType.EXPLICIT, "StoragesListSlot");
1050 rootWidget.SetNavigation(WidgetNavigationDirection.LEFT, WidgetNavigationRuleType.EXPLICIT, "StorageLootSlot");
1051 }
1052 else
1053 {
1054 leftArea.SetNavigation(WidgetNavigationDirection.RIGHT, WidgetNavigationRuleType.EXPLICIT, "StoragesListSlot");
1055 rightArea.SetNavigation(WidgetNavigationDirection.LEFT, WidgetNavigationRuleType.EXPLICIT, "StorageLootSlot");
1056 }
1057 }
1058
1059 //------------------------------------------------------------------------------------------------
1061 {
1062 if (!storage)
1063 return false;
1064
1065 array<SCR_InventorySlotUI> slots = {};
1066 storage.GetSlots(slots);
1067 return slots.IsIndexValid(slotIndex);
1068 }
1069
1070 //------------------------------------------------------------------------------------------------
1075 bool FocusOnSlotInStorage(SCR_InventoryStorageBaseUI storageUi, int slotIndex = 0)
1076 {
1077 if (!storageUi)
1078 return false;
1079
1080 array<SCR_InventorySlotUI> slots = {};
1081 storageUi.GetSlots(slots);
1082
1083 if (slots.IsEmpty())
1084 {
1085 if (!m_bIsUsingGamepad) // in case of M&K dont go back to the storage mode, as M&K doesnt support that mode, and user will not be able to turn it off
1086 return true;
1087
1088 SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.CLICK);
1089 SetStorageSwitchMode(true, false); // if this storage doesnt have any slots on which we could focus, then lets go back to the storage switch mode
1090 return false;
1091 }
1092
1093 if (!slots.IsIndexValid(slotIndex))
1094 slotIndex = 0; // if provided index is invalid then use first slot
1095
1096 SCR_InventorySlotUI uiSlot = slots[slotIndex];
1097 Widget button;
1098 if (uiSlot)
1099 button = uiSlot.GetButtonWidget();
1100
1101 if (!button || !button.IsEnabled())
1102 uiSlot = FindFirstFocusableUiSlot(slots, button, slotIndex);
1103
1104 if (!uiSlot)
1105 {
1106 if (!m_bIsUsingGamepad)
1107 return true;
1108
1109 SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.CLICK);
1110 SetStorageSwitchMode(true, false); // since we dont have a button to focus on we switch back to the storage mode
1111 return false;
1112 }
1113
1114 GetGame().GetWorkspace().SetFocusedWidget(button);
1115 return true;
1116 }
1117
1118 //------------------------------------------------------------------------------------------------
1124 protected SCR_InventorySlotUI FindFirstFocusableUiSlot(notnull array<SCR_InventorySlotUI> slots, out Widget button = null, int ignoredId = -1)
1125 {
1126 foreach (int i, SCR_InventorySlotUI uiSlot : slots)
1127 {
1128 if (ignoredId == i)
1129 continue;
1130
1131 if (!uiSlot || !uiSlot.IsSlotEnabled())
1132 continue;
1133
1134 button = uiSlot.GetButtonWidget();
1135 if (button && button.IsEnabled())
1136 return uiSlot;
1137 }
1138
1139 button = null;
1140 return null;
1141 }
1142
1143 //------------------------------------------------------------------------------------------------
1145 protected bool Init()
1146 {
1148
1149 if ( m_widget == null )
1150 return false;
1151
1152 Widget loading = m_widget.FindAnyWidget("LoadingOverlay");
1153 if (loading)
1154 {
1155 loading.SetVisible(true);
1156 m_LoadingOverlay = SCR_LoadingOverlay.Cast(loading.FindHandler(SCR_LoadingOverlay));
1157 }
1158
1159 //Get player
1160 PlayerController playerController = GetGame().GetPlayerController();
1161 if ( playerController != null )
1162 {
1163 m_Player = ChimeraCharacter.Cast(playerController.GetControlledEntity());
1164 if ( m_Player != null )
1165 {
1166 ChimeraWorld world = ChimeraWorld.CastFrom(m_Player.GetWorld());
1167 if (!world)
1168 return false;
1169
1170 m_pPreviewManager = world.GetItemPreviewManager();
1171 if (!m_pPreviewManager)
1172 {
1174 if (rsc.IsValid())
1175 GetGame().SpawnEntityPrefabLocal(rsc, world);
1176
1177 m_pPreviewManager = world.GetItemPreviewManager();
1178 }
1179
1180 m_CharController = SCR_CharacterControllerComponent.Cast(m_Player.GetCharacterController());
1181 if (m_CharController)
1182 {
1183 m_CharController.m_OnLifeStateChanged.Insert(LifeStateChanged);
1184 if (m_CharController.GetLifeState() != ECharacterLifeState.ALIVE)
1185 return false;
1186 }
1187
1189 if (gameMode)
1191
1192 //Inventory Manager
1193 m_InventoryManager = SCR_InventoryStorageManagerComponent.Cast( m_Player.FindComponent( SCR_InventoryStorageManagerComponent ) );
1195 if( !m_StorageManager )
1196 return false;
1199 return false;
1200 if ( m_InventoryManager )
1201 {
1202 m_InventoryManager.m_OnItemAddedInvoker.Insert(OnItemAddedListener);
1203 m_InventoryManager.m_OnItemRemovedInvoker.Insert(OnItemRemovedListener);
1204 }
1205
1206 Widget wNaviBar = m_widget.FindAnyWidget( "Footer" );
1207 if( wNaviBar )
1208 m_pNavigationBar = SCR_NavigationBarUI.Cast( wNaviBar.FindHandler( SCR_NavigationBarUI ) );
1210 if (m_pVicinity)
1211 {
1212 m_pVicinity.OnVicinityUpdateInvoker.Insert(RefreshLootUIListener);
1213 m_iVicinityDiscoveryRadius = m_pVicinity.GetDiscoveryRadius();
1214 IEntity itemOfInterest = m_pVicinity.GetItemOfInterest();
1215 if (itemOfInterest && itemOfInterest.IsInherited(SCR_ChimeraCharacter))
1216 {
1217 SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(itemOfInterest);
1218 SCR_CharacterControllerComponent charCtrl = SCR_CharacterControllerComponent.Cast(character.GetCharacterController());
1219 if (charCtrl)
1221 }
1222 }
1223
1224 m_wStoragesContainer = GridLayoutWidget.Cast( m_widget.FindAnyWidget( "StorageGrid" ) );
1225 m_wTotalWeightText = TextWidget.Cast( m_widget.FindAnyWidget("TotalWeightText") );
1226 }
1227 else
1228 {
1229 return false;
1230 }
1231
1232 }
1233 else
1234 {
1235 return false;
1236 }
1237
1238 m_wDragDropContainer = FrameWidget.Cast( m_widget.FindAnyWidget( "DragDropContainer" ) );
1240 {
1242 m_pDragDropPreviewImage = ItemPreviewWidget.Cast( m_wDragDropContainer.FindAnyWidget( "item" ) );
1243 }
1244
1245 m_wAttachmentPointsContainer = m_widget.FindAnyWidget("AttachmentPoints");
1246
1247 return true;
1248 }
1249
1250 protected void OnLootedCharacterLifeStateChanged(ECharacterLifeState previousLifeState, ECharacterLifeState newLifeState)
1251 {
1252 if (newLifeState == ECharacterLifeState.ALIVE)
1253 {
1254 IEntity itemOfInterest = m_pVicinity.GetItemOfInterest();
1255 if (itemOfInterest && itemOfInterest.IsInherited(SCR_ChimeraCharacter))
1256 {
1257 SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(itemOfInterest);
1258 SCR_CharacterControllerComponent charCtrl = SCR_CharacterControllerComponent.Cast(character.GetCharacterController());
1259 if (charCtrl)
1261 }
1262
1263 m_pVicinity.SetItemOfInterest(null);
1265 }
1266 }
1267
1268 //---- REFACTOR NOTE START: This code will need to be refactored as current implementation is not conforming to the standards ----
1269 //------------------------------------------------------------------------------------------------
1270 void OnAction( SCR_InputButtonComponent comp, string action, SCR_InventoryStorageBaseUI pParentStorage = null, int traverseStorageIndex = -1 )
1271 {
1272 switch (action)
1273 {
1274 case "Inventory":
1275 {
1277 }
1278 break;
1279
1280 case "Inventory_UnassignFromQuickSlot":
1281 {
1283 } break;
1284
1285 case "Inventory_EnterStorage":
1286 {
1287 SetStorageSwitchMode(false);
1288 } break;
1289
1290 case "Inventory_AssignToQuickSlot":
1291 {
1293 } break;
1294
1295 case "Inventory_Drop":
1296 {
1298 } break;
1299
1300 case "Inventory_Equip":
1301 {
1303 } break;
1304
1305 case "Inventory_Select":
1306 {
1308 {
1310 return;
1311 }
1312
1314 {
1315 SetStorageSwitchMode(false);
1316 return;
1317 }
1318 if (m_pFocusedSlotUI && !m_pFocusedSlotUI.IsSelected())
1320 else
1322 } break;
1323
1324 case "Inventory_Deselect":
1325 {
1327 } break;
1328
1329 case "Inventory_OpenStorage":
1330 {
1332 } break;
1333
1334 case "Inventory_OpenNewStorage":
1335 {
1337 } break;
1338
1339 case "Inventory_StepBack":
1340 {
1341 Action_StepBack( pParentStorage, traverseStorageIndex );
1342 } break;
1343
1344 case "Inventory_Inspect":
1345 {
1347 } break;
1348
1349 case "Inventory_Use":
1350 {
1352 } break;
1353
1354 case "Inventory_Move":
1355 {
1357 {
1358 Action_Drop();
1359 return;
1360 }
1361 else if (m_pSelectedSlotUI)
1362 {
1363 Action_Drop();
1364 return;
1365 }
1366
1368 } break;
1369
1370 case "Inventory_Swap":
1371 {
1373 {
1376 return;
1377 }
1379 } break;
1380
1381 case "Inventory_DetachItem":
1382 {
1384 if (hzContainer)
1385 hzContainer.RemoveTourniquetFromSlot();
1386 } break;
1387
1388 case "InventoryEscape":
1389 {
1391 } break;
1392 }
1393 }
1394 //---- REFACTOR NOTE END ----
1395
1396 //------------------------------------------------------------------------------------------------
1397 protected int CloseOpenedStorage()
1398 {
1399 if ( !m_wContainer ) // what?
1400 return -1; //any storage opened
1401 return CloseStorage( m_wContainer );
1402 }
1403
1404 //------------------------------------------------------------------------------------------------
1405 protected int CloseStorage( SCR_InventoryStorageBaseUI pStorageUI )
1406 {
1407 //if (!pStorageUI)
1408 //return -1;
1409 Widget w = pStorageUI.GetRootWidget();
1410 if ( !w )
1411 return -1;
1412
1413 //~ Close linked storages one frame later to make sure the the current storage is closed
1414 CloseLinkedStorages(pStorageUI.GetStorage());
1415
1416 return CloseStorage( w );
1417 }
1418
1419 //------------------------------------------------------------------------------------------------
1420 protected int CloseStorage( notnull Widget w )
1421 {
1422 auto storageUIHandler = SCR_InventoryStorageBaseUI.Cast( w.FindHandler( SCR_InventoryStorageBaseUI ) );
1423 if ( !storageUIHandler )
1424 return -1; //some storage opened, but it does not have any handler ( wrong )
1425
1426 int iLastShownPage = storageUIHandler.GetLastShownPage();
1427 m_pLastCurrentNavStorage = storageUIHandler.GetCurrentNavigationStorage();
1428 w.RemoveHandler( storageUIHandler ); //remove the handler from the widget
1429 w.RemoveFromHierarchy();
1430
1431 return iLastShownPage;
1432 }
1433
1434 //------------------------------------------------------------------------------------------------
1435 // ! Hides/Unhides ( not closes ) the storage
1437 {
1438 BaseInventoryStorageComponent pStorage = pSlot.GetAsStorage();
1439 if ( !pStorage )
1440 return;
1442 if ( !pStorageUI )
1443 return;
1444 pStorageUI.ToggleShow();
1445 }
1446
1447 //------------------------------------------------------------------------------------------------
1448 // ! Shows the content of the 1st available storage
1450 {
1451 if( !m_StorageManager )
1452 return;
1453
1454 array<SCR_UniversalInventoryStorageComponent> pStorages = new array<SCR_UniversalInventoryStorageComponent>();
1455 m_StorageManager.GetStorages( pStorages );
1456
1457 if( pStorages.Count() == 0 )
1458 return;
1459 SCR_UniversalInventoryStorageComponent pStorage = pStorages.Get( 0 );
1460 ShowStorage( pStorage );
1461 }
1462
1463 //------------------------------------------------------------------------------------------------
1465 void ShowStorage( BaseInventoryStorageComponent storage, LoadoutAreaType area = null )
1466 {
1467 if ( !m_wStoragesContainer )
1468 return;
1469 m_wContainer = GetGame().GetWorkspace().CreateWidgets( BACKPACK_STORAGE_LAYOUT, m_wStoragesContainer );
1470 int iRow = Math.Floor( m_iStorageListCounter / STORAGE_AREA_COLUMNS );
1473
1474 m_wStoragesContainer.SetRowFillWeight( iRow, 0 );
1475 m_wStoragesContainer.SetColumnFillWeight( iCol, 0 );
1476
1477 GridSlot.SetColumn( m_wContainer, iCol );
1478 GridSlot.SetRow( m_wContainer, iRow );
1479 GridSlot.SetColumnSpan( m_wContainer, 1 );
1480 GridSlot.SetRowSpan( m_wContainer, 1 );
1481
1482 if ( !m_wContainer )
1483 return;
1484 if ( storage.Type() == ClothNodeStorageComponent )
1485 {
1486 m_wContainer.AddHandler( new SCR_InventoryStorageLBSUI( storage, area, this, 0, null) );
1488 }
1489 else if ( storage.Type() == EquipedWeaponStorageComponent )
1490 {
1491 m_wContainer.AddHandler( new SCR_InventoryStorageWeaponsUI( m_StorageManager.GetWeaponStorage(), area, this ) );
1493 }
1494 else
1495 {
1496 m_wContainer.AddHandler( new SCR_InventoryStorageBackpackUI( storage, area, this, 0, null ) );
1498 }
1499
1500 m_aStorages.Insert( m_pStorageBaseUI );
1501 }
1502
1503 //------------------------------------------------------------------------------------------------
1504 void ShowVicinity(bool compact = false) // if true, vicinity will have only 4 rows instead of 6
1505 {
1506 if (!m_pVicinity)
1507 {
1508 Print("No vicnity component on character!", LogLevel.DEBUG);
1509 return;
1510 }
1511
1512 if ( m_wLootStorage )
1513 {
1514 m_wLootStorage.RemoveHandler( m_wLootStorage.FindHandler( SCR_InventoryStorageLootUI ) ); //remove the handler from the widget
1515 m_wLootStorage.RemoveFromHierarchy();
1516 }
1517
1518 Widget parent = m_widget.FindAnyWidget( "StorageLootSlot" );
1519 m_wLootStorage = GetGame().GetWorkspace().CreateWidgets( BACKPACK_STORAGE_LAYOUT, parent );
1520 if ( !m_wLootStorage )
1521 return;
1522
1523 if (compact)
1524 m_wLootStorage.AddHandler( new SCR_InventoryStorageLootUI( null, null, this, 0, null, m_Player, 4, 6 ) );
1525 else
1526 m_wLootStorage.AddHandler( new SCR_InventoryStorageLootUI( null, null, this, 0, null, m_Player ) );
1528 }
1529
1530 //------------------------------------------------------------------------------------------------
1531 void ShowAttachmentStorage(InventorySearchPredicate searchPredicate, bool closeOnly = false)
1532 {
1534 {
1536 if (closeOnly)
1537 return;
1538 }
1539
1541 {
1542 const Widget parent = m_widget.FindAnyWidget("AttachmentStorage");
1543 if (!parent)
1544 return;
1545
1546 m_wAttachmentStorage = GetGame().GetWorkspace().CreateWidgets(BACKPACK_STORAGE_LAYOUT, parent);
1548 return;
1549 }
1550
1551 SCR_InventoryAttachmentStorageUI handler = new SCR_InventoryAttachmentStorageUI(m_pStorageListUI.GetStorage(), null, this, 0, null, searchPredicate);
1552 m_wAttachmentStorage.AddHandler(handler);
1553 m_pAttachmentStorageUI = handler;
1554 }
1555
1556 //------------------------------------------------------------------------------------------------
1558 {
1560 return;
1561
1563 }
1564
1565 //------------------------------------------------------------------------------------------------
1570
1571 //------------------------------------------------------------------------------------------------
1573 {
1574 CloseStorage(attStorage);
1575 }
1576
1577 //------------------------------------------------------------------------------------------------
1578 // shows opened storage in a new container
1579 void OpenStorageAsContainer(BaseInventoryStorageComponent storage, bool showVicinity = true, bool hideCloseButton = false)
1580 {
1581 foreach (SCR_InventoryOpenedStorageUI openedStorage : m_aOpenedStoragesUI)
1582 {
1583 if (openedStorage.GetStorage() == storage)
1584 {
1585 // if storage is already open, close it instead
1586 RemoveOpenStorage(openedStorage);
1587 return;
1588 }
1589 }
1590
1592
1593 Widget parent = m_widget.FindAnyWidget("OpenedStorages");
1594 Widget newStorage;
1595
1596 if (SCR_InventoryOpenedStorageArsenalUI.Cast(handler))
1597 newStorage = GetGame().GetWorkspace().CreateWidgets(ARSENAL_STORAGE_LAYOUT, parent);
1598 else
1599 newStorage = GetGame().GetWorkspace().CreateWidgets(BACKPACK_STORAGE_LAYOUT, parent);
1600
1601 newStorage.AddHandler(handler);
1602
1603 ButtonWidget closeBtn = handler.ActivateCloseStorageButton();
1604
1605 ScrollLayoutWidget scroll = ScrollLayoutWidget.Cast(m_widget.FindAnyWidget("LeftAreaScroll"));
1606
1607 if (scroll)
1608 scroll.SetSliderPos(0, 0);
1609
1610 m_aOpenedStoragesUI.Insert(handler);
1611
1612 if (showVicinity)
1613 ShowVicinity(true);
1614
1615 if (hideCloseButton)
1616 {
1617 Widget closeButton = newStorage.FindAnyWidget(STORAGE_LAYOUT_CLOSE_WIDGET_NAME);
1618 if (closeButton)
1619 closeButton.SetVisible(false);
1620 }
1621
1622 OpenLinkedStorages(storage, showVicinity, true);
1623 FocusOnSlotInStorage(handler);
1624 }
1625
1626 //------------------------------------------------------------------------------------------------
1628 {
1629 CloseStorage(openedStorage);
1630 m_aOpenedStoragesUI.RemoveItem(openedStorage);
1631 if (m_aOpenedStoragesUI.IsEmpty())
1632 {
1633 ShowVicinity();
1634 }
1635 }
1636
1637 //------------------------------------------------------------------------------------------------
1639 {
1641 return;
1642
1643 m_pStorageLootUI.Refresh();
1644 if (m_aOpenedStoragesUI.IsEmpty())
1645 return;
1646
1647 vector playerOrigin = m_Player.GetOrigin();
1648 vector entityBoundsMaxs, entityBoundsMins;
1650 for (int index = m_aOpenedStoragesUI.Count() - 1; index >= 0; index--)
1651 {
1652 storageUI = m_aOpenedStoragesUI.Get(index);
1653 if (!storageUI)
1654 continue;
1655
1656 //~ If root entity is a vehicle than always take bounds of the vehicle this is because the cargo could be further away than the vehicle but the vehicle is the only one showing in the inventory
1657 Vehicle vehicleRoot = Vehicle.Cast(storageUI.GetStorage().GetOwner().GetRootParent());
1658 if (vehicleRoot)
1659 vehicleRoot.GetWorldBounds(entityBoundsMins, entityBoundsMaxs);
1660 //~ Root parent is not a vehicle so take bounds of self
1661 else
1662 storageUI.GetStorage().GetOwner().GetWorldBounds(entityBoundsMins, entityBoundsMaxs);
1663
1664 //~ No bounds on storage and rootparent is not avehicle than try to get bounds of parent instead
1665 if (entityBoundsMins - entityBoundsMaxs == vector.Zero && !vehicleRoot)
1666 {
1667 //~ Get the bounds from parents instead if root is not a vehicle
1668 if (storageUI.GetStorage().GetOwner().GetParent())
1669 storageUI.GetStorage().GetOwner().GetParent().GetWorldBounds(entityBoundsMins, entityBoundsMaxs);
1670
1671 //~ Check if bounds were found
1672 if (entityBoundsMins - entityBoundsMaxs == vector.Zero)
1673 {
1674 Print("SCR_InventoryMenuUI: RefreshLootUIListener storage owner has no bounds and it could not find a valid parent with bounds!", LogLevel.ERROR);
1675 RemoveOpenStorage(storageUI);
1676 return;
1677 }
1678 }
1679
1680 if (!Math3D.IntersectionSphereAABB(playerOrigin, m_iVicinityDiscoveryRadius, entityBoundsMins, entityBoundsMaxs))
1681 RemoveOpenStorage(storageUI);
1682 }
1683 }
1684
1685 //------------------------------------------------------------------------------------------------
1687 {
1688 if( m_wStorageList )
1689 {
1690 m_wStorageList.RemoveHandler( m_wStorageList.FindHandler( SCR_InventoryStoragesListUI ) ); //remove the handler from the widget
1691 m_wStorageList.RemoveFromHierarchy();
1692 }
1693
1694 Widget parent = m_widget.FindAnyWidget( "StoragesListSlot" );
1695 m_wStorageList = GetGame().GetWorkspace().CreateWidgets( STORAGES_LIST_LAYOUT, parent );
1696
1697 if( !m_wStorageList )
1698 return;
1699
1700 m_wStorageList.AddHandler( new SCR_InventoryStoragesListUI( m_StorageManager, null, this ) );
1702 }
1703
1704 //------------------------------------------------------------------------------------------------
1706 {
1707 BaseInventoryStorageComponent lastFocusedStorage;
1708 int lastFocusedSlotId = -1;
1710 {
1711 lastFocusedStorage = m_pFocusedSlotUI.GetStorageUI().GetStorage();
1712 lastFocusedSlotId = m_pFocusedSlotUI.GetStorageUI().GetFocusedSlotId();
1713 }
1714
1715 if (m_bIsUsingGamepad && lastFocusedSlotId < 0 && !lastFocusedStorage)
1716 m_bStorageSwitchMode = true;
1717
1719 lastFocusedStorage = m_pActiveHoveredStorageUI.GetStorage(); // if we weren't targeting specific slot, but we were 'focused' on a specific storage, then lets try to stay focused on it
1720
1722 array<SCR_InventorySlotUI> aSlotsUI = {};
1723 m_pStorageListUI.GetSlots( aSlotsUI );
1724 if ( !m_aStorages.IsEmpty() )
1725 {
1726 foreach ( SCR_InventoryStorageBaseUI pStorage : m_aStorages )
1727 {
1728 if ( !pStorage )
1729 continue;
1730 CloseStorage( pStorage );
1731 }
1732 }
1733
1734 SortSlotsByLoadoutArea( aSlotsUI );
1735 m_aStorages.Resize( aSlotsUI.Count() );
1736
1737 foreach (SCR_InventorySlotUI pSlot : aSlotsUI)
1738 {
1739 if (!pSlot)
1740 continue;
1741
1742 BaseInventoryStorageComponent pStorage = pSlot.GetAsStorage();
1743 if (!pStorage)
1744 continue;
1745
1746 ShowStorage(pStorage, pSlot.GetLoadoutArea());
1747 if (pStorage != lastFocusedStorage)
1748 continue;
1749
1750 if (lastFocusedSlotId > -1)
1751 FocusOnSlotInStorage(m_pStorageBaseUI, lastFocusedSlotId);
1752
1754 }
1755
1756 if (m_bStorageSwitchMode) // since we just recreated all storages and their slots, we need to inform them that we are in storage switch mode
1758
1760 }
1761
1762 //------------------------------------------------------------------------------------------------
1763 protected SCR_InventoryStorageBaseUI GetStorageUIFromVicinity(BaseInventoryStorageComponent storage)
1764 {
1765 if (!storage)
1766 return null;
1767 array<SCR_InventorySlotUI> slots = {};
1768 m_pStorageLootUI.GetSlots(slots);
1769 foreach (SCR_InventorySlotUI slot : slots)
1770 {
1771 if (slot && slot.GetStorageComponent() == storage)
1772 return slot.GetStorageUI();
1773 }
1774
1775 return null;
1776 }
1777
1778 //------------------------------------------------------------------------------------------------
1779 protected SCR_InventoryOpenedStorageUI CreateOpenedStorageUI(BaseInventoryStorageComponent storage)
1780 {
1781 IEntity storageOwner = storage.GetOwner();
1782
1783 SCR_ArsenalInventoryStorageManagerComponent arsenalManagerComponent
1784 = SCR_ArsenalInventoryStorageManagerComponent.Cast(storageOwner.FindComponent(SCR_ArsenalInventoryStorageManagerComponent));
1785
1786 if (arsenalManagerComponent)
1787 return new SCR_InventoryOpenedStorageArsenalUI(storage, null, this, 0, {storage});
1788
1789 SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.FindResourceComponent(storageOwner);
1790
1791 if (resourceComponent)
1792 {
1793 //% Remove the hard coded type for the resources type.
1794 SCR_ResourceContainer container = resourceComponent.GetContainer(EResourceType.SUPPLIES);
1795
1796 if (container)
1797 return new SCR_InventoryStorageContainerUI(storage, null, this, 0, {storage});
1798 }
1799
1800 return new SCR_InventoryOpenedStorageUI(storage, null, this, 0, {storage});
1801 }
1802
1803 //------------------------------------------------------------------------------------------------
1804 SCR_InventoryStorageBaseUI GetStorageUIByBaseStorageComponent( BaseInventoryStorageComponent pStorage )
1805 {
1806 if (!pStorage)
1807 return m_pStorageLootUI;
1808
1809 if (pStorage == m_pWeaponStorageComp)
1810 return m_pWeaponStorage;
1811
1812 if (pStorage == m_StorageManager)
1813 return m_pStorageListUI;
1814
1815 if (pStorage && m_StorageManager && pStorage.GetOwner() == m_StorageManager.GetOwner())
1816 return m_pStorageListUI;
1817
1818 BaseInventoryStorageComponent parentStorage;
1819
1820 if (pStorage && pStorage.GetParentSlot())
1821 parentStorage = pStorage.GetParentSlot().GetStorage();
1822
1823 if (ClothNodeStorageComponent.Cast(parentStorage))
1824 {
1825 foreach (SCR_InventoryStorageBaseUI pStorageUI : m_aStorages)
1826 {
1827 if (pStorageUI && pStorageUI.GetStorage() == parentStorage)
1828 return pStorageUI;
1829 }
1830 }
1831
1832 foreach (SCR_InventoryStorageBaseUI pStorageUI : m_aStorages)
1833 {
1834 if (pStorageUI && pStorageUI.GetStorage() == pStorage)
1835 return pStorageUI;
1836 }
1837
1838 foreach (SCR_InventoryStorageBaseUI pStorageUI : m_aOpenedStoragesUI)
1839 {
1840 if (pStorageUI && pStorageUI.GetStorage() == pStorage)
1841 return pStorageUI;
1842 }
1843
1844 return null;
1845 }
1846
1847 //------------------------------------------------------------------------------------------------
1848 protected void SortSlotsByLoadoutArea( out array<SCR_InventorySlotUI> aSlots )
1849 {
1850 array<SCR_InventorySlotUI> tmpSlots = {};
1851 tmpSlots.Copy( aSlots );
1852 aSlots.Clear();
1853
1854 foreach ( SCR_InventorySlotUI pSlotUI : tmpSlots )
1855 {
1856 if ( !SCR_InventorySlotStorageUI.Cast( pSlotUI ) || pSlotUI.GetLoadoutArea() == null )
1857 continue;
1858 aSlots.Insert(pSlotUI);
1859 }
1860 }
1861
1862 //------------------------------------------------------------------------------------------------
1864 {
1865 if ( m_wWeaponSlots )
1866 {
1867 m_wWeaponSlots.RemoveHandler( m_wWeaponSlots.FindHandler( SCR_InventoryWeaponSlotsUI ) ); //remove the handler from the widget
1868 m_wWeaponSlots.RemoveFromHierarchy();
1869 }
1870
1871 Widget parent = m_widget.FindAnyWidget( "WeaponSlots" );
1872 m_wWeaponSlots = GetGame().GetWorkspace().CreateWidgets( WEAPON_STORAGE_LAYOUT, parent );
1873
1874 if ( !m_wWeaponSlots )
1875 return;
1876
1877 m_wWeaponSlots.AddHandler( new SCR_InventoryWeaponSlotsUI( m_StorageManager.GetWeaponStorage(), null, this ) );
1881 }
1882
1883 //------------------------------------------------------------------------------------------------
1884 //~ Add any general hints not found on the item itself such as arsenal cost when the item is in an arsenal
1885 protected void GetGeneralItemHintsInfos(out notnull array<SCR_InventoryItemHintUIInfo> hintsInfo)
1886 {
1887 bool arsenalCostSet;
1888
1889 //~ Arsenal supply cost hint if item is in an arsenal storage
1891 {
1893 if (arsenalSlot)
1894 {
1895 m_SupplyCostUIInfo.SetSupplyCost(arsenalSlot.GetItemSupplyCost());
1896 hintsInfo.InsertAt(m_SupplyCostUIInfo, 0);
1897 arsenalCostSet = true;
1898
1899 //~ Set arsenal rank icon
1901 {
1902 SCR_ECharacterRank requiredItemRank = arsenalSlot.GetRequiredRank();
1903
1904 //~ Add required rank hint if higher then SCR_ECharacterRank.PRIVATE or player is Renegade
1905 if (requiredItemRank > SCR_ECharacterRank.PRIVATE || SCR_CharacterRankComponent.GetCharacterRank(SCR_PlayerController.GetLocalControlledEntity()) <= SCR_ECharacterRank.RENEGADE)
1906 {
1907 m_ArsenalItemRankUIInfo.SetRequiredRank(requiredItemRank);
1908 hintsInfo.InsertAt(m_ArsenalItemRankUIInfo, arsenalCostSet);
1909 }
1910 }
1911
1912 //~ Set MSAR cost info
1914 {
1916 hintsInfo.Insert(m_PlayerSupplyAllocationUIInfo);
1917 }
1918
1919 }
1920 }
1921
1922 //~ Add refund cost
1923 if (!arsenalCostSet && m_SupplyRefundUIInfo && IsStorageArsenal(m_pStorageLootUI.GetCurrentNavigationStorage()))
1924 {
1925 bool isNonRefundable;
1926 bool nonrefundableItemInStorage = false;
1927 if (DoesSlotContainNonRefundableItems(m_pFocusedSlotUI, nonrefundableItemInStorage))
1928 {
1929 m_NonrefundableUIInfo.SetContainsNonrefundableItem(nonrefundableItemInStorage);
1930 hintsInfo.InsertAt(m_NonrefundableUIInfo, 0);
1931 isNonRefundable = true;
1932 }
1933
1934 if (!isNonRefundable)
1935 {
1936 BaseInventoryStorageComponent storage = m_pStorageLootUI.GetCurrentNavigationStorage();
1937 if (storage)
1938 {
1939 SCR_ArsenalComponent arsenalComp = SCR_ArsenalComponent.Cast(storage.GetOwner().FindComponent(SCR_ArsenalComponent));
1940 if (arsenalComp)
1941 {
1942 bool isSupplyStorageAvailable;
1943 float supplyRefundAmount = SCR_ArsenalManagerComponent.GetItemRefundAmount(m_pFocusedSlotUI.GetInventoryItemComponent().GetOwner(), arsenalComp, true, isSupplyStorageAvailable: isSupplyStorageAvailable);
1944
1945 if (supplyRefundAmount >= 0)
1946 {
1947 m_SupplyRefundUIInfo.SetSupplyRefund(supplyRefundAmount, isSupplyStorageAvailable);
1948 hintsInfo.InsertAt(m_SupplyRefundUIInfo, 0);
1949 }
1950
1951 //~ Set MSAR cost info
1953 {
1954 InventoryItemComponent item = m_pFocusedSlotUI.GetInventoryItemComponent();
1955 if (item)
1956 {
1957 IEntity itemEntity = item.GetOwner();
1958 if (itemEntity)
1959 {
1960 SCR_ArsenalManagerComponent arsenalManager;
1961 if (SCR_ArsenalManagerComponent.GetArsenalManager(arsenalManager))
1962 {
1963 m_PlayerSupplyAllocationUIInfo.SetMSARCost(arsenalManager.GetItemMilitarySupplyAllocationRefundAmount(itemEntity, arsenalComp));
1964 hintsInfo.Insert(m_PlayerSupplyAllocationUIInfo);
1965 }
1966 }
1967 }
1968 }
1969 }
1970 }
1971 }
1972 }
1973
1974 //~ Faction hint for items with a faction
1975 if (!m_mItemFactionUIInfos.IsEmpty())
1976 {
1977 InventoryItemComponent itemInventory = m_pFocusedSlotUI.GetInventoryItemComponent();
1978 if (itemInventory)
1979 {
1980 SCR_ItemOutfitFactionComponent outfitFaction = SCR_ItemOutfitFactionComponent.Cast(itemInventory.GetOwner().FindComponent(SCR_ItemOutfitFactionComponent));
1981 if (outfitFaction && outfitFaction.IsValid())
1982 {
1983 array<SCR_OutfitFactionData> outfitValues = {};
1984 outfitFaction.GetOutfitFactionDataArray(outfitValues);
1985
1987
1988 foreach (SCR_OutfitFactionData data : outfitValues)
1989 {
1990 if (!m_mItemFactionUIInfos.Find(data.GetAffiliatedFactionKey(), foundInfo))
1991 continue;
1992
1993 foundInfo.SetFaction(data.GetAffiliatedFaction(), data);
1994 hintsInfo.Insert(foundInfo);
1995 }
1996 }
1997 }
1998 }
1999
2000 //~ Character identity item valuable intel hint
2001 SCR_IdentityInventoryItemComponent identityInventoryItem = SCR_IdentityInventoryItemComponent.Cast(m_pFocusedSlotUI.GetInventoryItemComponent().GetOwner().FindComponent(SCR_IdentityInventoryItemComponent));
2002 if (identityInventoryItem && identityInventoryItem.HasValuableIntel(true))
2003 {
2004 m_ValuableIntelUIInfo.SetIntel(identityInventoryItem);
2005 hintsInfo.Insert(m_ValuableIntelUIInfo);
2006 }
2007 }
2008
2009 //---- REFACTOR NOTE START: This code will need to be refactored as current implementation is not conforming to the standards ----
2010 //------------------------------------------------------------------------------------------------
2011 void ShowItemInfo( string sName = "", string sDescr = "", float sWeight = 0.0, SCR_InventoryUIInfo uiInfo = null )
2012 {
2013 if ( !m_pItemInfo )
2014 {
2015 //Widget parent = m_widget.FindAnyWidget( "SoldierInfo" );
2016 Widget infoWidget = GetGame().GetWorkspace().CreateWidgets(ITEM_INFO, m_widget);
2017 if ( !infoWidget )
2018 return;
2019
2020 infoWidget.AddHandler( new SCR_InventoryItemInfoUI() );
2021 m_pItemInfo = SCR_InventoryItemInfoUI.Cast( infoWidget.FindHandler( SCR_InventoryItemInfoUI ) );
2022 }
2023
2024 if( !m_pItemInfo )
2025 return;
2026
2027 Widget w = m_pFocusedSlotUI.GetButtonWidget();
2028
2029 m_pItemInfo.Show( 0.6, w, true );
2030 m_pItemInfo.SetName( sName );
2031 m_pItemInfo.SetDescription( sDescr );
2032
2033 m_pItemInfo.SetWeight( sWeight );
2034 if (uiInfo && uiInfo.IsIconVisible())
2035 m_pItemInfo.SetIcon(uiInfo.GetIconPath(), uiInfo.GetIconColor());
2036 else
2037 m_pItemInfo.ShowIcon(false);
2038
2039 array<SCR_InventoryItemHintUIInfo> hintsInfo = {};
2040
2041 //~ Add hints
2042 if (uiInfo)
2043 uiInfo.GetItemHintArray(hintsInfo);
2044
2045 //~ Add general hints that are not found on the item but are more generic depending where the item is (eg: arsenal) and the components on the item
2046 //~ These hints cover a wide arrange of items so that each item does not need to be set up individually
2047 GetGeneralItemHintsInfos(hintsInfo);
2048
2049 //~ If has hints show them
2050 if (!hintsInfo.IsEmpty())
2051 m_pItemInfo.SetItemHints(m_pFocusedSlotUI.GetInventoryItemComponent(), hintsInfo, m_pFocusedSlotUI);
2052 else
2053 m_pItemInfo.SetItemHints(m_pFocusedSlotUI.GetInventoryItemComponent());
2054
2055 //~ Create Identity UI
2056 m_pItemInfo.CreateIdentityUI(SCR_IdentityInventoryItemComponent.Cast(m_pFocusedSlotUI.GetInventoryItemComponent()));
2057
2059 }
2060
2061 //------------------------------------------------------------------------------------------------
2064 protected void UpdateItemInfoPosition(bool postponed = false)
2065 {
2066 if (!m_pFocusedSlotUI)
2067 return;
2068
2069 Widget w = m_pFocusedSlotUI.GetButtonWidget();
2070 if (!w)
2071 return;
2072
2073 float x, y;
2074 w.GetScreenPos(x, y);
2075
2076 float width, height;
2077 w.GetScreenSize(width, height);
2078 if (!postponed && x == 0 && y == 0 && width == 0 && height == 0)
2079 {
2080 HideItemInfo();
2081 // delay, because for some reason it is possible that UI will exist, but it won't be ready, as everything will be at 0 0 with 0 width and height ¯\_(-.-)_/¯
2082 GetGame().GetCallqueue().CallLater(UpdateItemInfoPosition, 100, param1: true);
2083 return;
2084 }
2085
2086 m_pItemInfo.Show(0.2, w, true);
2087
2088 // Needed to update the widget to the correct size before requesting its size here.
2089 m_pItemInfo.GetInfoWidget().Update();
2090
2091 float screenSizeX, screenSizeY;
2092 GetGame().GetWorkspace().GetScreenSize(screenSizeX, screenSizeY);
2093
2094 float infoWidth, infoHeight;
2095 m_pItemInfo.GetInfoWidget().GetScreenSize(infoWidth, infoHeight);
2096
2097 int targetPosX = x;
2098 int targetPosY = y + height;
2099
2100 float offsetX = (screenSizeX - infoWidth - targetPosX);
2101 if (offsetX < 0)
2102 targetPosX += offsetX;
2103 float offsetY = (screenSizeY - infoHeight - targetPosY);
2104 if (offsetY < 0)
2105 targetPosY += offsetY;
2106
2107 m_pItemInfo.Move(
2108 GetGame().GetWorkspace().DPIUnscale(targetPosX),
2109 GetGame().GetWorkspace().DPIUnscale(targetPosY));
2110 }
2111
2112 //------------------------------------------------------------------------------------------------
2113 void ShowDamageInfo(string sName, SCR_InventoryDamageUIInfo damageInfo)
2114 {
2115 Widget w = WidgetManager.GetWidgetUnderCursor();
2116 if (!w && m_AttachmentSpinBox)
2117 {
2119 if (currentHZContainer)
2120 w = currentHZContainer.GetRootWidget().FindAnyWidget("HitZoneButton");
2121 }
2122
2123 if (!w)
2124 return;
2125
2126 if (!m_pDamageInfo)
2127 {
2128 Widget infoWidget = GetGame().GetWorkspace().CreateWidgets(DAMAGE_INFO, m_widget);
2129 if ( !infoWidget )
2130 return;
2131
2132 infoWidget.AddHandler( new SCR_InventoryDamageInfoUI() );
2133 m_pDamageInfo = SCR_InventoryDamageInfoUI.Cast( infoWidget.FindHandler( SCR_InventoryDamageInfoUI ) );
2134 }
2135
2136 if (!m_pDamageInfo)
2137 return;
2138
2139 m_pDamageInfo.Show( 0.6, w, m_bIsUsingGamepad );
2140 m_pDamageInfo.SetName( sName );
2141
2142 if (damageInfo)
2143 {
2144 m_pDamageInfo.SetDamageStateVisible(damageInfo.m_bDamageIconVisible, damageInfo.m_bDamageRegenerating, damageInfo.m_sDamageIntensity, damageInfo.m_sDamageText);
2145 m_pDamageInfo.SetBleedingStateVisible(damageInfo.m_bBleedingIconVisible, damageInfo.m_sBleedingText);
2146 m_pDamageInfo.SetTourniquetStateVisible(damageInfo.m_bTourniquetIconVisible);
2147 m_pDamageInfo.SetSalineBagStateVisible(damageInfo.m_bSalineBagIconVisible);
2148 m_pDamageInfo.SetFractureStateVisible(damageInfo.m_bFractureIconVisible, damageInfo.m_bFractureIcon2Visible);
2149 }
2150
2151 int iMouseX, iMouseY;
2152
2153 float x, y;
2154 w.GetScreenPos(x, y);
2155
2156 float width, height;
2157 w.GetScreenSize(width, height);
2158
2159 float screenSizeX, screenSizeY;
2160 GetGame().GetWorkspace().GetScreenSize(screenSizeX, screenSizeY);
2161
2162 float infoWidth, infoHeight;
2163 m_pDamageInfo.GetInfoWidget().GetScreenSize(infoWidth, infoHeight);
2164
2165 iMouseX = x;
2166 iMouseY = y + height;
2167 if (x + infoWidth > screenSizeX)
2168 iMouseX = screenSizeX - infoWidth - width * 0.5; // offset info if it would go outside of the screen
2169
2170 m_pDamageInfo.Move( GetGame().GetWorkspace().DPIUnscale( iMouseX ), GetGame().GetWorkspace().DPIUnscale( iMouseY ) );
2171 }
2172 //---- REFACTOR NOTE END ----
2173
2174 //------------------------------------------------------------------------------------------------
2176 {
2177 if (m_pDamageInfo)
2178 m_pDamageInfo.Destroy();
2179 }
2180
2181 //------------------------------------------------------------------------------------------------
2183 {
2184 if ( !m_pItemInfo )
2185 return;
2186 m_pItemInfo.Hide();
2187 }
2188
2189 //------------------------------------------------------------------------------------------------
2191 {
2192 if ( !m_pDamageInfo )
2193 return;
2194 m_pDamageInfo.Hide();
2195 }
2196
2197 //------------------------------------------------------------------------------------------------
2202
2203 //------------------------------------------------------------------------------------------------
2204 void SetSlotFocused( SCR_InventorySlotUI pFocusedSlot, SCR_InventoryStorageBaseUI pFromStorageUI, bool bFocused )
2205 {
2206 if (m_pFocusedSlotUI && (m_pFocusedSlotUI != pFocusedSlot || !bFocused))
2207 {
2208 SCR_InventorySlotUI oldFocusedSlot = m_pFocusedSlotUI;
2209 m_pFocusedSlotUI = null;
2210 oldFocusedSlot.OnSlotFocusLost();
2211 }
2212
2213 if( bFocused )
2214 {
2215 InputManager pInputManager = GetGame().GetInputManager();
2216 if ( !( pInputManager && pInputManager.IsUsingMouseAndKeyboard() ) )
2217 {
2218 if ( m_pActiveStorageUI != pFromStorageUI )
2219 {
2220 if ( m_pActiveStorageUI )
2221 {
2222 SCR_InventorySlotUI pLastFocusedSlot = pFromStorageUI.GetLastFocusedSlot();
2223 pFromStorageUI.SetSlotFocused(pLastFocusedSlot);
2224 }
2225
2226 m_pActiveStorageUI = pFromStorageUI;
2227 }
2228 }
2229
2230 if (m_DraggedSlot)
2231 pFocusedSlot.CheckCompatibility(m_DraggedSlot);
2232
2233 m_pFocusedSlotUI = pFocusedSlot;
2234 if (m_OnItemHover)
2235 m_OnItemHover.Invoke(pFocusedSlot);
2236
2238 }
2239 else
2240 {
2241 if ( !m_bLocked )
2242 {
2243 if ( m_pActiveStorageUI )
2244 m_pActiveStorageUI.SetLastFocusedSlot( pFocusedSlot );
2245
2246 HideItemInfo();
2247 m_pFocusedSlotUI = null;
2248 m_pNavigationBar.SetAllButtonEnabled(false);
2249 }
2250
2251 if (m_OnItemHoverEnd)
2252 m_OnItemHoverEnd.Invoke();
2253
2254 pFocusedSlot.CheckCompatibility(null);
2255 }
2256 }
2257
2258 //------------------------------------------------------------------------------------------------
2259 protected void SetFocusedSlotEffects()
2260 {
2261 if( !m_pFocusedSlotUI )
2262 return;
2263
2264 //show info about the item
2265 InventoryItemComponent invItemComp = m_pFocusedSlotUI.GetInventoryItemComponent();
2266 if ( !invItemComp )
2267 return;
2268 auto attribs = SCR_ItemAttributeCollection.Cast( invItemComp.GetAttributes() );
2269
2270 if ( !attribs )
2271 return;
2272 UIInfo itemInfo = attribs.GetUIInfo();
2273 if ( !itemInfo )
2274 HideItemInfo();
2275 else
2276 {
2277 SCR_InventoryUIInfo inventoryInfo = SCR_InventoryUIInfo.Cast(itemInfo);
2278
2279 if (inventoryInfo)
2280 ShowItemInfo( inventoryInfo.GetInventoryItemName(invItemComp), inventoryInfo.GetInventoryItemDescription(invItemComp), invItemComp.GetTotalWeight(), inventoryInfo);
2281 else
2282 ShowItemInfo( itemInfo.GetName(), itemInfo.GetDescription(), invItemComp.GetTotalWeight(), null);
2283 }
2284
2286 }
2287
2288 //------------------------------------------------------------------------------------------------
2291 {
2293 return EDropContainer.NOCONTAINER;
2294 if ( m_pActiveHoveredStorageUI.GetFocusedSlot() == m_pFocusedSlotUI )
2295 return EDropContainer.ISINSIDE;
2296
2297 return EDropContainer.ISNOTINSIDE;
2298 }
2299
2300 //------------------------------------------------------------------------------------------------
2302 {
2303 if (!slot1 || !slot2)
2304 return false;
2305
2306 return m_InventoryManager.CanSwapItemStorages(
2307 slot1.GetInventoryItemComponent().GetOwner(),
2308 slot2.GetInventoryItemComponent().GetOwner()
2309 );
2310 }
2311
2312 //------------------------------------------------------------------------------------------------
2314 {
2315 if (!slot1 || !slot2)
2316 return false;
2317
2318 return m_InventoryManager.CanMoveItemToStorage(
2319 slot1.GetInventoryItemComponent().GetOwner(),
2320 slot2.GetStorageComponent()
2321 );
2322 }
2323
2324 //------------------------------------------------------------------------------------------------
2326 {
2327 if (!slot1 || !slot2)
2328 return false;
2329
2330 return m_InventoryManager.CanMoveItemToStorage(
2331 slot1.GetInventoryItemComponent().GetOwner(),
2332 slot2.GetStorage()
2333 );
2334 }
2335
2336 //------------------------------------------------------------------------------------------------
2340 protected bool ItemBelongsToThePlayer(notnull IEntity item)
2341 {
2342 if (!m_Player)
2343 return false;
2344
2345 IEntity parent = item.GetParent();
2346 while (parent)
2347 {
2348 if (parent == m_Player)
2349 return true;
2350
2351 parent = parent.GetParent();
2352 }
2353
2354 return false;
2355 }
2356
2357 //---- REFACTOR NOTE START: This code will need to be refactored as current implementation is not conforming to the standards ----
2358 //------------------------------------------------------------------------------------------------
2361 {
2362 if (!m_pNavigationBar)
2363 return;
2364
2366 {
2369 return;
2370 }
2371 else
2372 {
2373 m_pNavigationBar.SetAllButtonEnabled(false);
2374 m_pNavigationBar.SetButtonEnabled(BUTTON_BACK, true);
2375 m_pNavigationBar.SetButtonEnabled(BUTTON_SELECT, !m_DraggedSlot);
2376
2378 m_pNavigationBar.SetButtonEnabled(BUTTON_REMOVE_TOURNIQUET, (hzSlot && hzSlot.IsTourniquetted()));
2379 }
2380
2381 //if player is dragging a slotted item then we dont want to show hints for items that will happen to be under the cursor
2382 if (m_DraggedSlot)
2383 return;
2384
2385 //if there is no slot under the cursor then there are no hints to show
2386 if (!m_pFocusedSlotUI)
2387 return;
2388
2389 InventoryItemComponent itemComp = m_pFocusedSlotUI.GetInventoryItemComponent();
2390 if (!itemComp)
2391 return;
2392
2393 IEntity item = itemComp.GetOwner();
2394 if (!item)
2395 return;
2396
2397 bool isItemInCharacter;
2399 if (!arsenalSlot)
2400 {
2401 isItemInCharacter = ItemBelongsToThePlayer(item);
2402 }
2403 else if (!arsenalSlot.IsAvailable())
2404 {
2405 m_pNavigationBar.SetButtonEnabled(BUTTON_SELECT, false);
2406 return;
2407 }
2408
2409 if (isItemInCharacter && !m_pSelectedSlotUI)
2410 {
2411 m_pNavigationBar.SetButtonEnabled(BUTTON_USE, m_StorageManager.CanUseItem_Inventory(item));
2412
2413 m_pNavigationBar.SetButtonEnabled(BUTTON_EQUIP, !m_pItemToAssign && m_StorageManager.CanEquipItem_Inventory(item));
2414 m_pNavigationBar.SetButtonEnabled(BUTTON_INSPECT, CanInspectItemInInventory(item, itemComp));
2415 }
2416
2417 BaseInventoryStorageComponent desiredStorage = m_pStorageLootUI.GetCurrentNavigationStorage();
2418 //is targeted item going to be transfered into the arsenal
2419 bool isTargetingArsenal = isItemInCharacter && IsStorageArsenal(desiredStorage);
2420
2421 //if there is no specific storage open as main target, then check if any of the open containers is not an arsenal, as in such case it has the priority when item is transfered
2422 if (isItemInCharacter && !isTargetingArsenal && !desiredStorage && m_aOpenedStoragesUI)
2423 isTargetingArsenal = GetOpenArsenalStorage();
2424
2425 //check if currently focused item is not in a arsenal
2426 if (isTargetingArsenal && m_aOpenedStoragesUI.Contains(SCR_InventoryOpenedStorageUI.Cast(m_pActiveHoveredStorageUI)))
2427 isTargetingArsenal = false;
2428
2429 if (isTargetingArsenal && DoesSlotContainNonRefundableItems(m_pFocusedSlotUI))
2430 isTargetingArsenal = false;
2431
2432 bool allowItemTransfer = !m_bIsUsingGamepad || m_pActiveStorageUI != m_pQuickSlotStorage;
2433
2435 {
2436 m_pNavigationBar.SetButtonEnabled(BUTTON_BUY, arsenalSlot != null);
2437 m_pNavigationBar.SetButtonEnabled(BUTTON_SELL, allowItemTransfer && isItemInCharacter && isTargetingArsenal);
2438 m_pNavigationBar.SetButtonEnabled(BUTTON_PICK_UP, !isItemInCharacter && !arsenalSlot);
2439 m_pNavigationBar.SetButtonEnabled(BUTTON_DROP, allowItemTransfer && m_pFocusedSlotUI.IsDraggable() && isItemInCharacter && !isTargetingArsenal);
2440 }
2441
2442 m_pNavigationBar.SetButtonEnabled(BUTTON_STEP_BACK, true);
2443
2445 }
2446
2447 //------------------------------------------------------------------------------------------------
2450 {
2451 if (!m_pNavigationBar)
2452 return;
2453
2454 m_pNavigationBar.SetAllButtonEnabled(false);
2455 m_pNavigationBar.SetButtonEnabled(BUTTON_BACK, true);
2457
2458 SCR_InventoryHitZoneUI hzSlot = m_AttachmentSpinBox.GetFocusedHZPoint();
2459 m_pNavigationBar.SetButtonEnabled(BUTTON_REMOVE_TOURNIQUET, hzSlot && hzSlot.IsTourniquetted() && m_AttachmentSpinBox.IsFocused());
2460
2462 {
2463 m_pNavigationBar.SetButtonEnabled(BUTTON_USE, !m_pSelectedSlotUI);
2464 return;
2465 }
2466
2468 if (m_pFocusedSlotUI)
2469 iic = m_pFocusedSlotUI.GetInventoryItemComponent();
2470
2471 IEntity focusedItem;
2472 bool isItemInCharacter;
2473 if (iic)
2474 {
2475 focusedItem = iic.GetOwner();
2476 if(focusedItem)
2477 isItemInCharacter = ItemBelongsToThePlayer(focusedItem);
2478 }
2479
2480 if (m_pFocusedSlotUI)
2481 m_pNavigationBar.SetButtonEnabled(BUTTON_SELECT, !m_pSelectedSlotUI && focusedItem && m_pFocusedSlotUI.IsDraggable());
2482 else
2484
2485 SCR_InventoryStorageBaseUI selectedStorage;
2487 selectedStorage = m_pSelectedSlotUI.GetStorageUI();
2488
2489 const bool hoveringOverQuickSlots = m_pActiveStorageUI == m_pQuickSlotStorage;
2490 const bool transferringSupplies = SCR_SupplyInventorySlotUI.Cast(m_pSelectedSlotUI) && m_pSelectedSlotUI != m_pFocusedSlotUI;
2491 const bool isTargetingDifferentSlot = m_pSelectedSlotUI != m_pFocusedSlotUI;
2492 bool isTargetingDifferentStorage = selectedStorage != m_pActiveStorageUI;
2493 if (!isTargetingDifferentStorage && selectedStorage && (selectedStorage == m_pWeaponStorage || selectedStorage == m_pQuickSlotStorage))
2494 isTargetingDifferentStorage = isTargetingDifferentSlot; // weapon slots and quick slots should be treated as separate storages, despite them being one
2495
2497 {
2500 else
2501 m_pNavigationBar.SetButtonActionName(BUTTON_BACK, GAMEPAD_HINT_CLOSE);
2502
2503 bool shouldShowMove = m_pSelectedSlotUI && m_pSelectedSlotUI.IsDraggable() && isTargetingDifferentSlot;
2504 if (shouldShowMove && m_pActiveStorageUI)
2505 shouldShowMove &= m_pActiveStorageUI.IsStorageHighlighted() && (transferringSupplies || isTargetingDifferentStorage);
2506
2507 m_pNavigationBar.SetButtonEnabled(BUTTON_MOVE, shouldShowMove);
2508
2509 m_pNavigationBar.SetButtonEnabled(BUTTON_ENTER_STORAGE, m_pSelectedSlotUI != null && !hoveringOverQuickSlots && m_pActiveStorageUI && m_pActiveStorageUI.IsStorageHighlighted() && !m_pActiveStorageUI.IsArsenal());
2510 }
2511 else
2512 {
2513 m_pNavigationBar.SetButtonEnabled(BUTTON_SWAP, m_pSelectedSlotUI && isTargetingDifferentSlot && isTargetingDifferentStorage && SCR_ArsenalInventorySlotUI.Cast(m_pSelectedSlotUI) == null);
2514 m_pNavigationBar.SetButtonEnabled(BUTTON_MOVE, m_pSelectedSlotUI && m_pFocusedSlotUI && (transferringSupplies || isTargetingDifferentStorage));
2515
2516 m_pNavigationBar.SetButtonActionName(BUTTON_BACK, GAMEPAD_HINT_BACK);
2517 }
2518
2519 bool isWeaponQuickSlot = SCR_InventorySlotWeaponSlotsUI.Cast(m_pFocusedSlotUI);
2520 m_pNavigationBar.SetButtonEnabled(BUTTON_QUICK_ASSIGN, !isWeaponQuickSlot && (hoveringOverQuickSlots && m_pItemToAssign || isItemInCharacter && !hoveringOverQuickSlots && CanItemFitIntoQuickSlots(iic)));
2521 m_pNavigationBar.SetButtonEnabled(BUTTON_QUICK_UNASSIGN, hoveringOverQuickSlots && isItemInCharacter && !isWeaponQuickSlot && !m_pItemToAssign);
2522 }
2523 //---- REFACTOR NOTE END ----
2524
2525 //------------------------------------------------------------------------------------------------
2530 protected bool CanInspectItemInInventory(notnull IEntity item, notnull InventoryItemComponent iic)
2531 {
2532 return item.FindComponent(SCR_WeaponAttachmentsStorageComponent);
2533 }
2534
2535 //------------------------------------------------------------------------------------------------
2538 protected BaseInventoryStorageComponent GetOpenArsenalStorage()
2539 {
2541 return null;
2542
2543 BaseInventoryStorageComponent storage;
2546 {
2547 if (!SCR_InventoryOpenedStorageArsenalUI.Cast(storageUI))
2548 continue;
2549
2550 storage = storageUI.GetStorage();
2551 if (storage)
2552 return storage;
2553 }
2554
2555 return null;
2556 }
2557
2558 //------------------------------------------------------------------------------------------------
2560 {
2561 string sAction = GAMEPAD_HINT_SELECT;
2562 bool arsenalItem = IsStorageArsenal(m_pFocusedSlotUI.GetStorageUI().GetCurrentNavigationStorage()); // hotfix for disabling opening open action in arsenal storages
2563
2564 switch ( m_pFocusedSlotUI.GetSlotedItemFunction() )
2565 {
2566 case ESlotFunction.TYPE_GADGET:
2567 // m_pNavigationBar.SetButtonEnabled( BUTTON_EQUIP, true );
2568 break;
2569 case ESlotFunction.TYPE_WEAPON:
2570 //m_pNavigationBar.SetButtonEnabled( BUTTON_EQUIP, true );
2571
2572 InventoryItemComponent itemComp = m_pFocusedSlotUI.GetInventoryItemComponent();
2573
2574 if (!itemComp)
2575 return;
2576
2577 IEntity item = itemComp.GetOwner();
2578
2579 if (item)
2580 {
2582
2583 if (weaponComp &&
2584 weaponComp.GetWeaponType() != EWeaponType.WT_FRAGGRENADE &&
2585 weaponComp.GetWeaponType() != EWeaponType.WT_SMOKEGRENADE &&
2586 weaponComp.Type() != SCR_MineWeaponComponent)
2587 {
2588 m_pNavigationBar.SetButtonEnabled(BUTTON_OPEN_STORAGE, !arsenalItem && !ItemBelongsToThePlayer(item));
2589 m_pNavigationBar.SetButtonEnabled(BUTTON_OPEN_NEW_CONTAINER, !arsenalItem);
2590 }
2591 }
2592
2593 break;
2594 case ESlotFunction.TYPE_MAGAZINE:
2595 // TODO: show the Reload action
2596 //m_pNavigationBar.SetButtonEnabled( BUTTON_USE, true );
2597 break;
2598 case ESlotFunction.TYPE_CONSUMABLE:
2599 // TODO: show the Consume action
2600 m_pNavigationBar.SetButtonEnabled( BUTTON_USE, true );
2601
2602 break;
2603 case ESlotFunction.TYPE_STORAGE:
2604 if( m_EStateMenuItem == EStateMenuItem.STATE_MOVING_ITEM_STARTED && m_pFocusedSlotUI != m_pSelectedSlotUI )
2605 {
2606 sAction = "#AR-Inventory_Move";
2607 //m_pNavigationBar.SetButtonEnabled( BUTTON_SELECT, false );
2608 //m_pNavigationBar.SetButtonEnabled( BUTTON_MOVE, true );
2609 }
2610 // Enable in case the storage is not "togglable" - can be only shown and only opening another storage will close it
2611 /*else if ( m_EStateMenuStorage == EStateMenuStorage.STATE_OPENED && m_pFocusedSlotUI == m_pSelectedSlotUI && m_pFocusedSlotUI.Type() != SCR_InventorySlotStorageEmbeddedUI)
2612 {
2613 m_pNavigationBar.SetButtonEnabled( BUTTON_SELECT, false );
2614 }*/
2616 {
2617 m_pNavigationBar.SetButtonEnabled(BUTTON_OPEN_STORAGE, !arsenalItem);
2618 m_pNavigationBar.SetButtonEnabled(BUTTON_OPEN_NEW_CONTAINER, !arsenalItem);
2619 }
2620
2621 break;
2622
2623 case ESlotFunction.TYPE_HEALTH:
2624 // TODO: show the Heal action
2625 m_pNavigationBar.SetButtonEnabled( BUTTON_USE, true );
2626
2627 break;
2628 }
2629
2630 HandleSelectButtonState( sAction );
2631 }
2632
2633 //------------------------------------------------------------------------------------------------
2634 protected void CreateItemSplitDialog(int maxVal, IEntity entityTo, IEntity entityFrom)
2635 {
2636 SCR_ItemSplitDialog dialog = SCR_ItemSplitDialog.Create(maxVal, entityTo, entityFrom);
2637
2638 dialog.m_OnConfirm.Insert(OnItemSplitDialogConfirm);
2639 }
2640
2641 //------------------------------------------------------------------------------------------------
2643 {
2645 return;
2646
2648 return;
2649 }
2650
2651 //------------------------------------------------------------------------------------------------
2652 protected bool OnItemSplitDialogConfirm_Merge(inout notnull SCR_ItemSplitDialog dialog)
2653 {
2655
2656 if (!resourceInventoryComp)
2657 return false;
2658
2659 IEntity entityFrom = dialog.GetEntityFrom();
2660 IEntity entityTo = dialog.GetEntityTo();
2661
2662 SCR_ResourceComponent resourceComponentFrom = SCR_ResourceComponent.FindResourceComponent(entityFrom);
2663
2664 if (!resourceComponentFrom)
2665 return false;
2666
2667 if (!entityTo)
2668 return false;
2669
2670 SCR_ResourceComponent resourceComponentTo = SCR_ResourceComponent.FindResourceComponent(entityTo);
2671
2672 if (!resourceComponentTo)
2673 return false;
2674
2675 resourceInventoryComp.RpcAsk_MergeContainerWithContainerPartial(Replication.FindItemId(resourceComponentFrom), Replication.FindItemId(resourceComponentTo), EResourceType.SUPPLIES, dialog.GetSliderValue());
2676
2677 return true;
2678 }
2679
2680 //------------------------------------------------------------------------------------------------
2681 protected bool OnItemSplitDialogConfirm_Create(inout notnull SCR_ItemSplitDialog dialog)
2682 {
2684
2685 if (!resourceInventoryComp)
2686 return false;
2687
2688 IEntity entityFrom = dialog.GetEntityFrom();
2689 IEntity entityTo = dialog.GetEntityTo();
2690
2691 SCR_ResourceComponent resourceComponentFrom = SCR_ResourceComponent.FindResourceComponent(entityFrom);
2692
2693 if (!resourceComponentFrom)
2694 return false;
2695
2696 if (!entityTo)
2697 {
2698 resourceInventoryComp.RpcAsk_CreatePhysicalContainerWithContainer(Replication.FindItemId(resourceComponentFrom), Replication.FindItemId(null), Replication.FindItemId(null), EResourceType.SUPPLIES, dialog.GetSliderValue());
2699
2700 return true;
2701 }
2702
2703 SCR_ResourceComponent resourceComponentTo = SCR_ResourceComponent.FindResourceComponent(entityTo);
2704
2706 if (resourceComponentTo)
2707 return false;
2708
2709 SCR_InventoryStorageManagerComponent invManagerTo;
2710 IEntity entityParentTo = entityTo.GetParent();
2711
2712 if (entityParentTo)
2713 invManagerTo = SCR_InventoryStorageManagerComponent.Cast(entityParentTo.FindComponent(SCR_InventoryStorageManagerComponent));
2714
2715 if (!invManagerTo)
2716 return false;
2717
2718 BaseInventoryStorageComponent storageTo = BaseInventoryStorageComponent.Cast(entityTo.FindComponent(BaseInventoryStorageComponent));
2719
2720 if (!storageTo)
2721 return false;
2722
2723 resourceInventoryComp.RpcAsk_CreatePhysicalContainerWithContainer(Replication.FindItemId(resourceComponentFrom), Replication.FindItemId(invManagerTo), Replication.FindItemId(storageTo), EResourceType.SUPPLIES, dialog.GetSliderValue());
2724
2725 return true;
2726 }
2727
2728 //------------------------------------------------------------------------------------------------
2729 protected void HandleSelectButtonState(string sAction = GAMEPAD_HINT_SELECT)
2730 {
2731 //TODO: this can be done better
2732 if (sAction == GAMEPAD_HINT_MOVE)
2733 {
2734 m_pNavigationBar.SetButtonActionName(BUTTON_SELECT, sAction);
2735 }
2736 else
2737 {
2738 if (!m_pFocusedSlotUI.IsSelected())
2739 m_pNavigationBar.SetButtonActionName(BUTTON_SELECT, sAction);
2740 else
2742 }
2743 }
2744
2745 //------------------------------------------------------------------------------------------------
2751
2752 //------------------------------------------------------------------------------------------------
2755 {
2757 {
2758 m_pGearInspectionPointUI.ClearSlots();
2761 m_pInspectedSlot = null;
2762 }
2763
2764 if (!itemSlot)
2765 {
2769 m_PlayerRenderAttributes.RotateItemCamera(Vector(0, 0, 0), Vector(0, 0, 0), Vector(0, 0, 0)); // reset rotation
2771 return;
2772 }
2773
2775
2776 if (!itemComp)
2777 {
2782 return;
2783 }
2784
2785 //SCR_AnalyticsApplication.GetInstance().UseExaminationFromInventory();
2786
2787 IEntity item = itemComp.GetOwner();
2788
2789 SCR_WeaponAttachmentsStorageComponent weaponAttachmentStorage = SCR_WeaponAttachmentsStorageComponent.Cast(item.FindComponent(SCR_WeaponAttachmentsStorageComponent));
2790
2791 if (weaponAttachmentStorage)
2792 {
2793 m_PlayerRenderAttributes.RotateItemCamera(Vector(0, 90, 0), Vector(0, 90, 0), Vector(0, 90, 0)); // rotate inspected weapon to side view
2794 m_pInspectedSlot = itemSlot;
2795 InspectWeapon(weaponAttachmentStorage);
2797 return;
2798 }
2799
2800 /* Preparations for gear inspection
2801 ClothNodeStorageComponent clothNodeStorage = ClothNodeStorageComponent.Cast(item.FindComponent(ClothNodeStorageComponent));
2802
2803 if (clothNodeStorage)
2804 {
2805 m_pInspectedSlot = itemSlot;
2806 InspectGear(clothNodeStorage);
2807 UpdateGearInspectionPreview();
2808 return;
2809 }*/
2810 }
2811
2812 //------------------------------------------------------------------------------------------------
2813 void InspectWeapon(SCR_WeaponAttachmentsStorageComponent weaponAttachmentStorage)
2814 {
2819 Widget inspectionFrame = m_widget.FindAnyWidget("AttachmentPoints");
2820 m_wAttachmentContainer = GetGame().GetWorkspace().CreateWidgets(BACKPACK_STORAGE_LAYOUT, inspectionFrame);
2821 m_pGearInspectionPointUI = new SCR_InventoryGearInspectionPointUI(weaponAttachmentStorage, null, this, frameSlot: inspectionFrame);
2823 }
2824
2825 /* Preparations for gear inspection
2826 void InspectGear(ClothNodeStorageComponent clothNodeStorage)
2827 {
2828 Widget inspectionFrame = m_widget.FindAnyWidget("AttachmentPoints");
2829 m_wAttachmentContainer = GetGame().GetWorkspace().CreateWidgets(BACKPACK_STORAGE_LAYOUT, inspectionFrame);
2830 m_pGearInspectionPointUI = new SCR_InventoryGearInspectionPointUI(clothNodeStorage, null, this, frameSlot: inspectionFrame);
2831 m_wAttachmentContainer.AddHandler(m_pGearInspectionPointUI);
2832 }*/
2833
2838
2839 //------------------------------------------------------------------------------------------------
2841 protected void FilterOutStorages( bool bShow = true )
2842 {
2843 //Get all slots from the storage list UI
2844 array<SCR_InventorySlotUI> pSlotsInListUI = {};
2845 m_pStorageListUI.GetSlots( pSlotsInListUI );
2846 //foreach ( SCR_InventorySlotUI pSlotFromUI : pSlotsInListUI )
2847 // RegisterUIStorage( pSlotFromUI );
2848
2849 if ( m_pStorageLootUI )
2850 m_pStorageLootUI.GetSlots( pSlotsInListUI );
2853 if ( m_pQuickSlotStorage )
2854 m_pQuickSlotStorage.GetSlots( pSlotsInListUI );
2855 if ( m_pWeaponStorage )
2856 m_pWeaponStorage.GetSlots( pSlotsInListUI );
2857
2858 BaseInventoryStorageComponent pStorageTo;
2859 foreach ( SCR_InventorySlotUI pStorageSlotUI : pSlotsInListUI )
2860 {
2861 if ( !pStorageSlotUI )
2862 continue;
2863
2864 pStorageTo = pStorageSlotUI.GetAsStorage();
2865
2866 if ( bShow )
2867 {
2868 if ( !m_pSelectedSlotUI )
2869 continue;
2870 if ( pStorageSlotUI.GetAsStorage() == m_pSelectedSlotUI.GetStorageUI().GetCurrentNavigationStorage() ) //it's the same storage as the selected item comes from
2871 {
2872 pStorageSlotUI.SetEnabledForMove( 0 );
2873 continue;
2874 }
2875
2876 InventoryItemComponent pInventoryItem = m_pSelectedSlotUI.GetInventoryItemComponent();
2877 if ( !pInventoryItem )
2878 continue;
2879
2880 IEntity pItem = pInventoryItem.GetOwner();
2881
2882 if ( pStorageTo )
2883 {
2884 bool bCanStore = true;
2885
2886 if ( m_InventoryManager.CanInsertItemInActualStorage( pItem, pStorageTo ) )
2887 {
2888 if ( pStorageTo.Type() == SCR_InventoryStorageWeaponsUI )
2889 if ( !m_pWeaponStorageComp.Contains( pStorageTo.GetOwner() ) )
2890 bCanStore = false;
2891
2892 if ( bCanStore )
2893 pStorageSlotUI.SetEnabledForMove( 1 );
2894 else
2895 pStorageSlotUI.SetEnabledForMove( 0 );
2896 }
2897 else
2898 {
2899 pStorageSlotUI.SetEnabledForMove( 0 );
2900 }
2901 }
2902 else
2903 {
2904 pStorageSlotUI.SetEnabledForMove( 0 );
2905 }
2906
2907 }
2908 else
2909 {
2910 pStorageSlotUI.SetEnabledForMove( 2 );
2911 }
2912 }
2913 }
2914
2915 //------------------------------------------------------------------------------------------------
2916 protected void FilterOutItems( bool bFilterOut )
2917 {
2918 array<SCR_InventorySlotUI> aItemsUIInLoot = {};
2919
2920 //if ( m_pStorageLootUI )
2921 //aItemsUIInLoot.InsertAll( m_pStorageLootUI.GetUISlots() );
2922 if ( m_pStorageListUI )
2923 aItemsUIInLoot.InsertAll( m_pStorageListUI.GetUISlots() );
2924 //if ( m_pStorageBaseUI )
2925 //aItemsUIInLoot.InsertAll( m_pStorageBaseUI.GetUISlots() );
2926
2927 PrintFormat( "INV: Filtering out items %1", 1.5 );
2928
2929 foreach ( SCR_InventorySlotUI pSlot : aItemsUIInLoot )
2930 {
2931 if ( !pSlot.GetStorageComponent() )
2932 {
2933 if ( bFilterOut )
2934 {
2935 PrintFormat( "INV: Disabling slot %1", pSlot );
2936 pSlot.SetEnabledForMove( 0 );
2937 }
2938 else
2939 {
2940 PrintFormat( "INV: Reseting slot %1", pSlot );
2941 pSlot.SetEnabledForMove( 2 );
2942 }
2943 }
2944 }
2945 }
2946
2947 //------------------------------------------------------------------------------------------------
2949 {
2951 {
2952 m_bWasJustTraversing = false;
2953 return;
2954 }
2955
2957 {
2959 {
2961 return;
2962 }
2963
2964 if (!m_pSelectedSlotUI)
2965 {
2967 return;
2968 }
2969
2970 DeselectSlot();
2971 SetStorageSwitchMode(false);
2974 return;
2975 }
2976 else
2977 {
2978 DeselectSlot();
2979 }
2980
2982 }
2983
2984 //------------------------------------------------------------------------------------------------
2985 protected void Action_CloseInventory()
2986 {
2987 array<BaseInventoryStorageComponent> traverseStorage = {};
2988 if (m_wLootStorage)
2989 {
2991 storageUIHandler.GetTraverseStorage(traverseStorage);
2992 }
2993
2994 if (!traverseStorage.IsEmpty())
2995 {
2996 BaseInventoryStorageComponent storage = traverseStorage[0];
2997 if (storage)
2998 {
2999 IEntity entity = storage.GetOwner();
3000 m_InventoryManager.PlayItemSound(entity, SCR_SoundEvent.SOUND_CONTAINER_CLOSE);
3001 }
3002 }
3003 else
3004 {
3005 SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_INV_CLOSE);
3006 }
3007
3008 GetGame().GetInputManager().RemoveActionListener("Inventory_Drag", EActionTrigger.DOWN, Action_DragDown);
3009 GetGame().GetInputManager().RemoveActionListener("Inventory", EActionTrigger.DOWN, Action_CloseInventory);
3010
3011 if (m_pVicinity)
3012 {
3013 m_pVicinity.ManipulationComplete();
3015 }
3016
3017 MenuManager menuManager = GetGame().GetMenuManager();
3018 ChimeraMenuPreset menu = ChimeraMenuPreset.Inventory20Menu;
3019
3020 MenuBase inventoryMenu = menuManager.FindMenuByPreset(menu); // prototype inventory
3021 if (inventoryMenu)
3022 menuManager.CloseMenuByPreset(menu);
3023
3025 m_PlayerRenderAttributes.ResetDeltaRotation();
3026
3027 if (m_Player)
3028 {
3029 m_CharController = SCR_CharacterControllerComponent.Cast(m_Player.GetCharacterController());
3030 if (m_CharController)
3031 m_CharController.m_OnLifeStateChanged.Remove(LifeStateChanged);
3032 }
3033
3035 if (gameMode)
3037
3039 m_pCharacterWidgetHelper.Destroy();
3040
3042
3043 HideItemInfo();
3045
3046 if ( m_pItemInfo )
3047 m_pItemInfo.Destroy();
3048
3049 if ( m_pDamageInfo )
3050 m_pDamageInfo.Destroy();
3051
3052 m_pItemInfo = null;
3053 m_pDamageInfo = null;
3054
3056 m_InventoryManager.OnInventoryMenuClosed();
3057 }
3058
3059 //------------------------------------------------------------------------------------------------
3062 void LifeStateChanged(ECharacterLifeState previousLifeState, ECharacterLifeState newLifeState)
3063 {
3064 if (newLifeState != ECharacterLifeState.ALIVE)
3066 }
3067
3068 //------------------------------------------------------------------------------------------------
3069 //Only for cases when character is removed before dying
3070 protected void OnControllableDeleted(IEntity controllable)
3071 {
3072 if (m_Player && m_Player == controllable)
3074 }
3075
3076 //---- REFACTOR NOTE START: This code will need to be refactored as current implementation is not conforming to the standards ----
3077 //------------------------------------------------------------------------------------------------
3079 protected void SimpleFSM(EMenuAction EAction = EMenuAction.ACTION_SELECT)
3080 {
3081 //SCR_AnalyticsApplication.GetInstance().InteractWithItem(m_pFocusedSlotUI, m_pSelectedSlotUI, EAction, m_bIsUsingGamepad);
3082
3083 switch (EAction)
3084 {
3085 case EMenuAction.ACTION_MOVEINSIDE:
3086 {
3091 DeselectSlot();
3094 } break;
3095
3096 case EMenuAction.ACTION_SELECT:
3097 {
3098 if (!m_pFocusedSlotUI)
3099 return;
3100
3102 m_pSelectedSlotUI.SetSelected(false);
3103
3104 if (!m_pFocusedSlotUI.IsDraggable())
3105 return;
3106
3108 if (arsenalSlot && !arsenalSlot.IsAvailable())
3109 return;
3110
3112 {
3114 m_pSelectedSlotUI.SetSelected(true);
3116 }
3117
3121 } break;
3122
3123 case EMenuAction.ACTION_DESELECT:
3124 {
3126 {
3128 DeselectSlot()
3129 }
3130
3132 } break;
3133
3134 case EMenuAction.ACTION_DRAGGED:
3135 {
3136 m_EStateMenuItem = EStateMenuItem.STATE_MOVING_ITEM_STARTED;
3137 } break;
3138
3139 case EMenuAction.ACTION_DROPPED:
3140 {
3141 Action_Drop();
3143 m_pActiveHoveredStorageUI.ShowContainerBorder(false);
3144 m_EStateMenuItem = EStateMenuItem.STATE_IDLE;
3145 return;
3146 } break;
3147
3148 case EMenuAction.ACTION_MOVEBETWEEN:
3149 {
3151 {
3152 InspectItem(null);
3153 }
3154
3155 if (m_pFocusedSlotUI)
3156 {
3158 SCR_InventoryStorageBaseUI pStorage = m_pFocusedSlotUI.GetStorageUI();
3159
3160 if (SCR_InventoryOpenedStorageUI.Cast(pStorage) && m_aOpenedStoragesUI.Contains(SCR_InventoryOpenedStorageUI.Cast(pStorage)))
3161 {
3163 SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_INV_CONTAINER_DIFR_DROP);
3164 }
3165 else if (pStorage != m_pStorageLootUI)
3166 {
3168 SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_INV_VICINITY_DROP_CLICK);
3169 }
3170 else
3171 {
3173 SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_INV_PICKUP_CLICK);
3174 }
3175 m_pSelectedSlotUI = null;
3176 }
3178 } break;
3179
3180 case EMenuAction.ACTION_UNFOLD:
3181 {
3182 if ( m_pFocusedSlotUI.GetStorageUI() == m_pStorageListUI ) //if it is slot in the "storage list ui"
3183 {
3184 if (m_pFocusedSlotUI.GetAsStorage()) // and if it is a storage
3185 {
3186 //ShowStorage( m_pFocusedSlotUI.GetAsStorage() ); //show the content of the actualy selected
3189 }
3190 else
3191 {
3192 //CloseOpenedStorage(); // if it is not storage, show nothing
3193 //ToggleStorageContainerVisibility( m_pFocusedSlotUI.GetAsStorage() );
3195 }
3196
3197 }
3198 else
3199 {
3203 }
3204 } break;
3205
3206 case EMenuAction.ACTION_OPENCONTAINER:
3207 {
3209 } break;
3210 }
3211
3212 if (!m_bIsUsingGamepad)
3214 }
3215 //---- REFACTOR NOTE END ----
3216
3217 //------------------------------------------------------------------------------------------------
3218 protected void Action_OpenContainer()
3219 {
3220 SimpleFSM(EMenuAction.ACTION_OPENCONTAINER);
3221 }
3222
3223 //------------------------------------------------------------------------------------------------
3225 protected void Action_Drop()
3226 {
3227 bool onDrop = false;
3228 if (m_pFocusedSlotUI)
3229 onDrop = m_pFocusedSlotUI.OnDrop(m_pSelectedSlotUI);
3230
3231 Widget underCursor = WidgetManager.GetWidgetUnderCursor();
3232 if (underCursor && underCursor.GetName() == "HitZoneButton")
3233 {
3235 if (m_pSelectedSlotUI && hzContainer)
3236 {
3237 hzContainer.GetStorage().OnDrop(m_pSelectedSlotUI);
3238 }
3239 }
3240
3241 if ( !onDrop && IsFocusedItemInsideDropContainer() != EDropContainer.NOCONTAINER ) //dropped to a container
3242 {
3244 InspectItem(null);
3245
3246 if ( m_pFocusedSlotUI )
3247 {
3249 {
3250 if ( SCR_InventorySlotStorageUI.Cast( m_pFocusedSlotUI ) ) // storage
3251 {
3253 }
3254 else if ( SCR_InventorySlotWeaponSlotsUI.Cast( m_pFocusedSlotUI ) ) // weapon slot
3255 {
3257 }
3258 else if (m_pFocusedSlotUI) // simple slot
3259 {
3260 if ( SCR_InventoryStorageQuickSlotsUI.Cast( m_pFocusedSlotUI.GetStorageUI() ) ) //quick slot
3261 {
3263 }
3264 else
3265 {
3267 }
3268 }
3269 }
3270 else
3271 {
3272 DeselectSlot();
3274 SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_INV_DROP_ERROR);
3275 }
3276 }
3277 else
3278 {
3279 // just container
3282 if (!onDrop)
3283 MoveItem();
3284 }
3285 }
3286 else
3287 {
3288 if (WidgetManager.GetWidgetUnderCursor() == m_wPlayerRender)
3289 {
3290 EquipDraggedItem(true);
3291 }
3292 else
3293 {
3294 //dropped outside of a container
3296 }
3297 }
3298
3300 }
3301
3302 //------------------------------------------------------------------------------------------------
3304 {
3306 {
3307 int slotId = m_pQuickSlotStorage.GetSlotId(m_pFocusedSlotUI) + 1;
3310 m_pItemToAssign = null;
3311 }
3312 else
3313 {
3315 {
3318 }
3319 }
3320
3322 }
3323
3324 //------------------------------------------------------------------------------------------------
3326 {
3327 if (!m_pFocusedSlotUI)
3328 return;
3329
3330 InventoryItemComponent itemComp = m_pFocusedSlotUI.GetInventoryItemComponent();
3331 if (!itemComp)
3332 return;
3333
3334 IEntity item = itemComp.GetOwner();
3335 if (!item)
3336 return;
3337
3338 int slotId = m_pQuickSlotStorage.GetFocusedSlotId();
3339 slotId = Math.Clamp(slotId, 0, m_StorageManager.GetQuickSlotItems().Count());
3340 m_pItemToAssign = null;
3341 m_StorageManager.RemoveItemFromQuickSlot(item);
3345 HideItemInfo();
3346 }
3347
3348 //------------------------------------------------------------------------------------------------
3351 {
3352 bool operationFailed;
3353 if (MoveItemToStorageSlot_VirtualArsenal(operationFailed))
3354 {
3355 if (operationFailed)
3356 {
3357 DeselectSlot();
3359 SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_INV_DROP_ERROR);
3360 }
3361
3362 return;
3363 }
3364
3366 {
3367 DeselectSlot();
3368 return;
3369 }
3370
3371 if (!m_pSelectedSlotUI)
3372 return;
3373
3374 InventoryItemComponent pComp = m_pSelectedSlotUI.GetInventoryItemComponent();
3375 if (!pComp)
3376 return;
3377
3378 IEntity pItem = pComp.GetOwner();
3379 if (!m_InventoryManager.CanMoveItem(pItem) || !m_pFocusedSlotUI.IsCompatible())
3380 return;
3381
3382 m_pCallBack.m_pItem = pItem;
3383 m_pCallBack.m_pMenu = this;
3384 m_pCallBack.m_pStorageFrom = m_pSelectedSlotUI.GetStorageUI();
3385
3386 DeselectSlot();
3388 if (open)
3389 m_pCallBack.m_pStorageTo = open;
3390 else
3391 m_pCallBack.m_pStorageTo = m_pFocusedSlotUI.GetStorageUI();
3392
3393 m_pCallBack.m_pStorageToFocus = m_pCallBack.m_pStorageTo;
3394
3395 BaseInventoryStorageComponent pStorageFromComponent = m_pCallBack.m_pStorageFrom.GetCurrentNavigationStorage();
3396 BaseInventoryStorageComponent pStorageToComponent = m_pFocusedSlotUI.GetAsStorage();
3397
3398 if (!pStorageToComponent)
3399 pStorageToComponent = m_pCallBack.m_pStorageTo.GetStorage();
3400
3401 if (!pStorageToComponent || pStorageToComponent == pStorageFromComponent)
3402 return;
3403
3404 if (IsStorageArsenal(pStorageToComponent))
3405 {
3406 SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_INV_DROP_ERROR);
3407 return;
3408 }
3409
3410 bool shouldEquip = m_pCallBack.m_pStorageTo == m_pStorageListUI;
3411 bool equip = shouldEquip && m_InventoryManager.EquipAny(m_StorageManager , pItem, 0, m_pCallBack);
3412
3413 if (!equip)
3414 m_InventoryManager.InsertItem( pItem, pStorageToComponent, pStorageFromComponent, m_pCallBack );
3415 else
3416 m_InventoryManager.PlayItemSound(pItem, SCR_SoundEvent.SOUND_EQUIP);
3417 /*
3418 if ( pItem.FindComponent( SCR_GadgetComponent ) )
3419 m_InventoryManager.EquipGadget( pItem, m_pCallBack );
3420 else
3421 */
3422 }
3423
3424 //------------------------------------------------------------------------------------------------
3427 {
3429 return;
3430
3431 if (!m_pSelectedSlotUI)
3432 return;
3433
3434 InventoryItemComponent pComp = m_pSelectedSlotUI.GetInventoryItemComponent();
3435 if (!pComp)
3436 return;
3437
3439 if (!weaponSlot)
3440 return;
3441
3442 IEntity pItem = pComp.GetOwner();
3443 if (!m_InventoryManager.CanMoveItem(pItem) || !m_pFocusedSlotUI.IsCompatible())
3444 return;
3445
3446 m_pCallBack.m_pItem = pItem;
3447 m_pCallBack.m_pMenu = this;
3448 m_pCallBack.m_pStorageFrom = m_pSelectedSlotUI.GetStorageUI();
3449 m_pCallBack.m_pStorageTo = m_pFocusedSlotUI.GetStorageUI();
3450 m_pCallBack.m_pStorageToFocus = m_pCallBack.m_pStorageTo;
3451 m_pCallBack.m_iSlotToFocus = m_pCallBack.m_pStorageTo.GetSlotId(m_pFocusedSlotUI);
3452
3453 InventoryItemComponent pItemToReplaceComp = m_pFocusedSlotUI.GetInventoryItemComponent();
3454 IEntity pItemToReplace;
3455 if (pItemToReplaceComp)
3456 pItemToReplace = pItemToReplaceComp.GetOwner();
3457
3458 if (pItemToReplace)
3459 {
3460 ItemAttributeCollection itemAttributes = pComp.GetAttributes();
3461 if (!itemAttributes)
3462 return;
3463
3464 AttachmentAttributes itemAttribute = AttachmentAttributes.Cast(itemAttributes.FindAttribute(AttachmentAttributes));
3465
3466 // Check if inserted item is an attachment, if yes, try to add it into the weapon
3467 if (itemAttribute && itemAttribute.GetAttachmentType())
3468 {
3469 BaseInventoryStorageComponent pItemToReplaceStorage = BaseInventoryStorageComponent.Cast(pItemToReplace.FindComponent(BaseInventoryStorageComponent));
3470
3471 if (!pItemToReplaceStorage)
3472 return;
3473
3474 // Need to check for both since you can't insert from inside your own inventory
3475 if (m_InventoryManager.TryInsertItemInStorage(pItem, pItemToReplaceStorage, -1, m_pCallBack)
3476 || m_InventoryManager.TryMoveItemToStorage(pItem, pItemToReplaceStorage, -1, m_pCallBack))
3477 {
3478 m_InventoryManager.PlayItemSound(pItem, SCR_SoundEvent.SOUND_EQUIP);
3479 }
3480 else
3481 {
3482 SCR_UISoundEntity.SoundEvent("SOUND_INV_DROP_ERROR");
3483 }
3484
3485 return;
3486 }
3487
3488 BaseInventoryStorageComponent itemToReplaceStorage = BaseInventoryStorageComponent.Cast(pItemToReplace.FindComponent(BaseInventoryStorageComponent));
3489
3490 if (itemToReplaceStorage && m_InventoryManager.CanInsertItemInStorage(pItem, itemToReplaceStorage, -1))
3491 {
3492 if (m_InventoryManager.TryInsertItemInStorage(pItem, itemToReplaceStorage, -1, m_pCallBack))
3493 m_InventoryManager.PlayItemSound(pItem, SCR_SoundEvent.SOUND_EQUIP);
3494 else
3495 SCR_UISoundEntity.SoundEvent("SOUND_INV_DROP_ERROR");
3496
3497 return;
3498 }
3499 }
3500
3501 if (pItemToReplace && pItem && pItemToReplace != pItem)
3502 {
3503 if (m_pSelectedSlotUI.GetSlotedItemFunction() == ESlotFunction.TYPE_MAGAZINE)
3504 {
3505 m_CharController.ReloadWeaponWith(pItem);
3506 return;
3507 }
3508
3509 if (m_InventoryManager.TrySwapItemStorages(pItem, pItemToReplace, m_pCallBack))
3510 m_InventoryManager.PlayItemSound(pItem, SCR_SoundEvent.SOUND_EQUIP);
3511 else
3512 SCR_UISoundEntity.SoundEvent("SOUND_INV_DROP_ERROR");
3513
3514 return;
3515 }
3516
3517 DeselectSlot();
3518 BaseInventoryStorageComponent pStorageToComponent = m_pWeaponStorageComp;
3519
3520 if (!m_InventoryManager.TryMoveItemToStorage( pItem, m_pWeaponStorageComp, weaponSlot.GetWeaponSlotIndex(), m_pCallBack ))
3521 {
3522 if (!m_InventoryManager.TryInsertItemInStorage(pItem, m_pWeaponStorageComp, weaponSlot.GetWeaponSlotIndex(), m_pCallBack))
3523 SCR_UISoundEntity.SoundEvent("SOUND_INV_DROP_ERROR");
3524 return;
3525 }
3526
3527 m_InventoryManager.PlayItemSound(pItem, SCR_SoundEvent.SOUND_EQUIP);
3528 }
3529
3530 //---- REFACTOR NOTE START: This code will need to be refactored as current implementation is not conforming to the standards ----
3531 //------------------------------------------------------------------------------------------------
3533 void MoveItem( SCR_InventoryStorageBaseUI pStorageBaseUI = null )
3534 {
3535 bool operationFailed;
3536 if (MoveItem_VirtualArsenal(pStorageBaseUI, operationFailed))
3537 {
3538 DeselectSlot();
3540 if (operationFailed)
3541 SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_INV_DROP_ERROR);
3542
3543 return;
3544 }
3545
3546 if (MoveItem_ResourceContainer(pStorageBaseUI))
3547 {
3548 DeselectSlot();
3549 return;
3550 }
3551
3552 if ( !m_pSelectedSlotUI )
3553 return;
3554 InventoryItemComponent pComp = m_pSelectedSlotUI.GetInventoryItemComponent();
3555 if ( !pComp )
3556 return;
3557 IEntity pItem = pComp.GetOwner();
3558 if (!m_InventoryManager.CanMoveItem(pItem))
3559 return;
3560
3561 m_pCallBack.m_pItem = pItem;
3562 m_pCallBack.m_pMenu = this;
3563 m_pCallBack.m_pStorageFrom = m_pSelectedSlotUI.GetStorageUI();
3564 m_pCallBack.m_sItemToFocus = m_pSelectedSlotUI.GetItemResource();
3565
3566 if ( pStorageBaseUI )
3567 m_pCallBack.m_pStorageTo = pStorageBaseUI;
3568 else
3570
3571 m_pCallBack.m_pStorageToFocus = m_pCallBack.m_pStorageTo;
3572 if (m_pCallBack.m_pStorageTo)
3573 m_pCallBack.m_iSlotToFocus = m_pCallBack.m_pStorageTo.GetFocusedSlotId();
3574
3575 BaseInventoryStorageComponent pStorageTo = m_pActiveHoveredStorageUI.GetCurrentNavigationStorage();
3576 if (IsStorageArsenal(pStorageTo))
3577 {
3578 SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_INV_DROP_ERROR);
3579 return;
3580 }
3581
3582 if (pStorageTo && pStorageTo.IsInherited(SCR_WeaponAttachmentsStorageComponent))
3583 {
3584 m_pCallBack.m_pStorageMan = GetInventoryStorageManager();
3585 m_pCallBack.m_eAttachAction = EAttachAction.ATTACH;
3586 }
3587
3588 if (m_pCallBack.m_pStorageFrom)
3589 {
3590 BaseInventoryStorageComponent storageFrom = m_pCallBack.m_pStorageFrom.GetStorage();
3591 if (storageFrom && storageFrom.IsInherited(SCR_WeaponAttachmentsStorageComponent))
3592 {
3593 m_pCallBack.m_pStorageMan = GetInventoryStorageManager();
3594 m_pCallBack.m_eAttachAction = EAttachAction.DETACH;
3595 }
3596 }
3597
3598 if ( pStorageTo && EquipedWeaponStorageComponent.Cast( pStorageTo ) )
3599 {
3600 m_InventoryManager.EquipWeapon( pItem, m_pCallBack, m_pCallBack.m_pStorageFrom == m_pStorageLootUI );
3601 DeselectSlot();
3602 return;
3603 }
3604 else if ( pStorageTo && CharacterInventoryStorageComponent.Cast( pStorageTo ) )
3605 {
3606 m_InventoryManager.EquipAny( pStorageTo, pItem, 0, m_pCallBack );
3607 }
3608 else if ( m_pCallBack.m_pStorageTo == m_pStorageLootUI )
3609 {
3610 MoveToVicinity( pItem );
3611 SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_INV_VICINITY_DROP_CLICK);
3612 }
3613 else if ( m_pCallBack.m_pStorageFrom == m_pCallBack.m_pStorageTo)
3614 {
3615 SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_INV_CONTAINER_SAME_DROP);
3616 }
3617 else
3618 {
3619 if ( m_pCallBack.m_pStorageFrom == m_pStorageLootUI )
3621 else
3622 {
3623 // disallow reload for unequipped weapons
3625 {
3626 if (m_pActiveHoveredStorageUI.GetCurrentNavigationStorage().IsInherited(SCR_WeaponAttachmentsStorageComponent))
3627 {
3628 if (!IsWeaponEquipped(m_pActiveHoveredStorageUI.GetStorage().GetOwner()))
3629 return;
3630 }
3631 else if (m_pCallBack.m_pStorageFrom.GetStorage().IsInherited(SCR_WeaponAttachmentsStorageComponent))
3632 {
3633 if (!IsWeaponEquipped(m_pCallBack.m_pStorageFrom.GetStorage().GetOwner()))
3634 return;
3635 }
3636 }
3637
3638 m_InventoryManager.InsertItem( pItem, m_pActiveHoveredStorageUI.GetCurrentNavigationStorage(), m_pCallBack.m_pStorageFrom.GetStorage(), m_pCallBack );
3639 DeselectSlot();
3640 }
3641 }
3642 }
3643 //---- REFACTOR NOTE END ----
3644
3645 //------------------------------------------------------------------------------------------------
3647 protected void EquipWeapon()
3648 {
3649 if ( !m_pSelectedSlotUI )
3650 return;
3651 IEntity pItem = m_pSelectedSlotUI.GetInventoryItemComponent().GetOwner();
3652 if ( !pItem )
3653 return;
3654
3655 if ( m_InventoryManager )
3656 m_InventoryManager.EquipWeapon( pItem, m_pCallBack );
3657 }
3658
3659 //---- REFACTOR NOTE START: This code will need to be refactored as current implementation is not conforming to the standards ----
3660 //------------------------------------------------------------------------------------------------
3662 protected void MoveToVicinity( IEntity pItem )
3663 {
3664 BaseInventoryStorageComponent pStorageFrom = m_pSelectedSlotUI.GetStorageUI().GetStorage();
3665
3666 if (!m_InventoryManager.CanMoveItem(pItem))
3667 return;
3668
3669 if (pStorageFrom && pItem.FindComponent(BaseMagazineComponent) && pStorageFrom.IsInherited(SCR_WeaponAttachmentsStorageComponent))
3670 {
3671 if (!IsWeaponEquipped(pStorageFrom.GetOwner()))
3672 return;
3673 }
3674
3675 m_pCallBack.m_pStorageFrom = GetStorageUIByBaseStorageComponent(pStorageFrom);
3676 if (!m_pCallBack.m_pStorageFrom)
3677 m_pCallBack.m_pStorageFrom = m_pSelectedSlotUI.GetStorageUI();
3678
3679 BaseInventoryStorageComponent isStorage = BaseInventoryStorageComponent.Cast(pItem.FindComponent(BaseInventoryStorageComponent));
3680 if (isStorage)
3681 m_pCallBack.m_pStorageToDrop = isStorage;
3682
3683 m_pCallBack.m_pStorageTo = m_pStorageLootUI;
3684 auto storage = m_pStorageLootUI.GetCurrentNavigationStorage();
3685
3686 if ( storage && !IsStorageArsenal(storage) )
3687 m_InventoryManager.InsertItem( pItem, m_pStorageLootUI.GetCurrentNavigationStorage(), pStorageFrom, m_pCallBack ); // moving into the opened storage in the vicinity
3688 else
3689 {
3690 //droping it on the ground
3691 auto pSlot = m_pSelectedSlotUI.GetInventoryItemComponent().GetParentSlot();
3692 if ( pSlot )
3693 {
3694 if (pStorageFrom && pStorageFrom.IsInherited(SCR_WeaponAttachmentsStorageComponent))
3695 {
3696 m_pCallBack.m_pStorageMan = GetInventoryStorageManager();
3697 m_pCallBack.m_eAttachAction = EAttachAction.DETACH;
3698 }
3699 m_InventoryManager.TryRemoveItemFromInventory(pItem, pSlot.GetStorage(), m_pCallBack);
3700 m_InventoryManager.PlayItemSound(pItem, SCR_SoundEvent.SOUND_DROP);
3701 }
3702 else
3703 {
3704 SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_INV_DROP_ERROR);
3705 }
3706 }
3707 }
3708
3709 //------------------------------------------------------------------------------------------------
3711 protected void MoveFromVicinity()
3712 {
3713 IEntity pItem = m_pSelectedSlotUI.GetInventoryItemComponent().GetOwner();
3714 if (!m_InventoryManager.CanMoveItem(pItem))
3715 return;
3716
3717 m_pCallBack.m_pItem = pItem;
3718 m_pCallBack.m_pMenu = this;
3719
3720 m_pCallBack.m_pStorageFrom = m_pStorageLootUI;
3722
3723 if (ShouldSpawnItem())
3724 {
3725 m_pCallBack.m_bUpdateSlotOnly = true;
3726 BaseInventoryStorageComponent storageTo = m_InventoryManager.FindStorageForInsert(pItem, m_pActiveHoveredStorageUI.GetCurrentNavigationStorage(), EStoragePurpose.PURPOSE_ANY);
3727 m_InventoryManager.TrySpawnPrefabToStorage(pItem.GetPrefabData().GetPrefabName(), storageTo, -1, EStoragePurpose.PURPOSE_ANY, m_pCallBack);
3728 m_InventoryManager.PlayItemSound(pItem, SCR_SoundEvent.SOUND_PICK_UP);
3729 return;
3730 }
3731
3732 if (m_pActiveHoveredStorageUI.GetCurrentNavigationStorage() &&
3733 m_pActiveHoveredStorageUI.GetCurrentNavigationStorage().IsInherited(SCR_WeaponAttachmentsStorageComponent))
3734 {
3736 {
3737 if (!IsWeaponEquipped(m_pActiveHoveredStorageUI.GetCurrentNavigationStorage().GetOwner()))
3738 return;
3739 }
3740 m_pCallBack.m_pStorageMan = GetInventoryStorageManager();
3741 m_pCallBack.m_eAttachAction = EAttachAction.ATTACH;
3742 }
3743
3744 BaseInventoryStorageComponent storagefrom = m_pStorageLootUI.GetCurrentNavigationStorage();
3745 if (!storagefrom)
3746 {
3747 IEntity ent = m_pVicinity.GetItemOfInterest();
3748 if (ent)
3749 storagefrom = BaseInventoryStorageComponent.Cast(ent.FindComponent(BaseInventoryStorageComponent));
3750 }
3751
3752 m_InventoryManager.InsertItem(pItem, m_pActiveHoveredStorageUI.GetCurrentNavigationStorage(), storagefrom, m_pCallBack); //a storage is already opened, try to move it there
3753 m_InventoryManager.PlayItemSound(pItem, SCR_SoundEvent.SOUND_PICK_UP);
3754 }
3755
3756 //------------------------------------------------------------------------------------------------
3759 {
3761 return;
3762
3763 IEntity pItem = m_pSelectedSlotUI.GetInventoryItemComponent().GetOwner();
3764 if (!m_InventoryManager.CanMoveItem(pItem))
3765 return;
3766
3767 //~ Never send items to arsenal
3768 BaseInventoryStorageComponent storageTo = m_InventoryManager.FindStorageForItem(pItem, EStoragePurpose.PURPOSE_ANY);
3769 if (storageTo && storageTo.GetOwner().FindComponent(SCR_ArsenalComponent))
3770 return;
3771
3772 m_pCallBack.m_pItem = pItem;
3773 m_pCallBack.m_pMenu = this;
3774
3775 InventoryStorageSlot parentSlotFrom = m_pSelectedSlotUI.GetInventoryItemComponent().GetParentSlot();
3776 BaseInventoryStorageComponent storageFrom;
3777 if (parentSlotFrom)
3778 storageFrom = parentSlotFrom.GetStorage();
3779
3780 if (!storageFrom)
3781 storageFrom = m_pStorageLootUI.GetCurrentNavigationStorage();
3782
3783 m_pCallBack.m_pStorageFrom = GetStorageUIByBaseStorageComponent(storageFrom);
3784 m_pCallBack.m_pStorageTo = m_pStorageListUI;
3785 m_pCallBack.m_pStorageToFocus = m_pSelectedSlotUI.GetStorageUI();
3786 m_pCallBack.m_sItemToFocus = m_pSelectedSlotUI.GetItemResource();
3787 m_pCallBack.m_iSlotToFocus = m_pFocusedSlotUI.GetStorageUI().GetFocusedSlotId();
3788 m_pCallBack.m_bUpdateSlotOnly = m_pSelectedSlotUI.IsStacked();
3789
3790 BaseInventoryStorageComponent pStorageTo = m_StorageManager;
3791 if ( pItem.FindComponent( SCR_GadgetComponent ) )
3792 {
3793 BaseInventoryStorageComponent pStorageComp = m_InventoryManager.FindStorageForItem( pItem, EStoragePurpose.PURPOSE_EQUIPMENT_ATTACHMENT );
3794 if ( pStorageComp )
3795 pStorageTo = pStorageComp;
3796 else
3797 {
3798 pStorageComp = m_InventoryManager.FindStorageForItem( pItem, EStoragePurpose.PURPOSE_DEPOSIT );
3799 if ( pStorageComp )
3800 pStorageTo = pStorageComp;
3801 }
3802 }
3803
3804 if (ShouldSpawnItem())
3805 {
3806 m_pCallBack.m_bUpdateSlotOnly = true;
3807 m_InventoryManager.TrySpawnPrefabToStorage(pItem.GetPrefabData().GetPrefabName(), null, -1, EStoragePurpose.PURPOSE_ANY, m_pCallBack);
3808 m_InventoryManager.PlayItemSound(pItem, SCR_SoundEvent.SOUND_PICK_UP);
3809 return;
3810 }
3811
3812 BaseInventoryStorageComponent isStorage = BaseInventoryStorageComponent.Cast(pItem.FindComponent(BaseInventoryStorageComponent));
3813 if (isStorage)
3814 m_pCallBack.m_pStorageToPickUp = isStorage;
3815
3816 m_InventoryManager.InsertItem( pItem, null, m_pStorageLootUI.GetCurrentNavigationStorage(), m_pCallBack );
3817 }
3818 //---- REFACTOR NOTE END ----
3819
3820 //------------------------------------------------------------------------------------------------
3821 protected bool ShouldSpawnItem()
3822 {
3823 if (!m_pSelectedSlotUI)
3824 return false;
3825 if (!m_pSelectedSlotUI.GetStorageUI())
3826 return false;
3827
3828 BaseInventoryStorageComponent currStorage = m_pSelectedSlotUI.GetStorageUI().GetCurrentNavigationStorage();
3829 return IsStorageArsenal(currStorage);
3830 }
3831
3832 //------------------------------------------------------------------------------------------------
3833 protected bool IsStorageArsenal(BaseInventoryStorageComponent storage)
3834 {
3835 if (!storage)
3836 return false;
3837 return (storage.GetOwner().FindComponent(SCR_ArsenalComponent) != null);
3838 }
3839
3840 //---- REFACTOR NOTE START: This code will need to be refactored as current implementation is not conforming to the standards ----
3841 //------------------------------------------------------------------------------------------------
3842 protected void EquipDraggedItem(bool forceEquip = false)
3843 {
3844 if (EquipDraggedItem_VirtualArsenal(forceEquip))
3845 return;
3846
3847 if (!m_pSelectedSlotUI || !m_pSelectedSlotUI.GetInventoryItemComponent())
3848 return;
3849
3850 IEntity pItem = m_pSelectedSlotUI.GetInventoryItemComponent().GetOwner();
3851 if (!pItem)
3852 return;
3853
3854 m_pCallBack.m_pItem = pItem;
3855 m_pCallBack.m_pMenu = this;
3856 m_pCallBack.m_pStorageFrom = m_pSelectedSlotUI.GetStorageUI();
3857
3858 m_pCallBack.m_pStorageToFocus = m_pSelectedSlotUI.GetStorageUI();
3859 m_pCallBack.m_sItemToFocus = m_pSelectedSlotUI.GetItemResource();
3860 m_pCallBack.m_iSlotToFocus = m_pSelectedSlotUI.GetStorageUI().GetSlotId(m_pSelectedSlotUI);
3861 m_pCallBack.m_bShouldEquip = forceEquip;
3862
3863 BaseInventoryStorageComponent pStorageTo = m_StorageManager;
3864 if (m_pSelectedSlotUI.GetStorageUI().Type() == SCR_InventoryStorageWeaponsUI)
3865 {
3866 m_pCallBack.m_pStorageTo = m_pWeaponStorage;
3867 }
3868 else
3869 {
3870 m_pCallBack.m_pStorageTo = m_pStorageListUI;
3871 }
3872
3873 if (pItem.FindComponent(SCR_GadgetComponent))
3874 {
3875 BaseInventoryStorageComponent pStorageComp = m_InventoryManager.FindStorageForItem( pItem, EStoragePurpose.PURPOSE_EQUIPMENT_ATTACHMENT );
3876 if (pStorageComp)
3877 pStorageTo = pStorageComp;
3878 else
3879 {
3880 pStorageComp = m_InventoryManager.FindStorageForItem(pItem, EStoragePurpose.PURPOSE_DEPOSIT);
3881 if (pStorageComp)
3882 pStorageTo = pStorageComp;
3883 }
3884 }
3885
3886 if (pItem.FindComponent(WeaponComponent))
3887 {
3888 BaseInventoryStorageComponent pStorageComp = m_InventoryManager.FindStorageForItem(pItem, EStoragePurpose.PURPOSE_WEAPON_PROXY);
3889 if (pStorageComp)
3890 pStorageTo = pStorageComp;
3891 else
3892 {
3893 pStorageComp = m_InventoryManager.FindStorageForItem(pItem, EStoragePurpose.PURPOSE_DEPOSIT);
3894 if (pStorageComp)
3895 pStorageTo = pStorageComp;
3896 }
3897 }
3898
3899 bool equip = m_InventoryManager.EquipAny(pStorageTo , pItem, 0, m_pCallBack);
3900 if (!equip && m_pSelectedSlotUI)
3901 {
3902 m_InventoryManager.InsertItem(pItem, null, m_pSelectedSlotUI.GetStorageUI().GetCurrentNavigationStorage(), m_pCallBack);
3903 }
3904 else
3905 {
3906 m_InventoryManager.PlayItemSound(pItem, SCR_SoundEvent.SOUND_EQUIP);
3907 }
3908 }
3909
3910 //------------------------------------------------------------------------------------------------
3912 protected void MoveBetweenToVicinity()
3913 {
3914 InventoryItemComponent pInvComponent = m_pFocusedSlotUI.GetInventoryItemComponent();
3915 if(!pInvComponent)
3916 return;
3917
3918 IEntity pItem = pInvComponent.GetOwner();
3919 if (!m_InventoryManager.CanMoveItem(pItem))
3920 return;
3921
3922 m_pCallBack.m_pItem = pItem;
3923 m_pCallBack.m_pMenu = this;
3924
3925 m_pCallBack.m_pStorageToFocus = GetStorageUIByBaseStorageComponent(m_pSelectedSlotUI.GetStorageUI().GetCurrentNavigationStorage());
3926 m_pCallBack.m_sItemToFocus = m_pSelectedSlotUI.GetItemResource();
3927 m_pCallBack.m_iSlotToFocus = m_pFocusedSlotUI.GetStorageUI().GetFocusedSlotId();
3928 m_pCallBack.m_bUpdateSlotOnly = m_pSelectedSlotUI.IsStacked();
3929
3930 HideItemInfo();
3932 return;
3933
3934 MoveToVicinity( pItem );
3935 }
3936
3937 //------------------------------------------------------------------------------------------------
3942 protected bool DoesSlotContainNonRefundableItems(notnull SCR_InventorySlotUI slotToCheck, out bool nonrefundableItemInStorage = false)
3943 {
3944 // Check if the itemitself is nonrefundable
3945 InventoryItemComponent refundItemComponent = slotToCheck.GetInventoryItemComponent();
3946 if (!refundItemComponent)
3947 return false;
3948
3949 SCR_ItemAttributeCollection refundItemAttributes = SCR_ItemAttributeCollection.Cast(refundItemComponent.GetAttributes());
3950 if (refundItemAttributes && !refundItemAttributes.IsRefundable())
3951 return true;
3952
3953 BaseInventoryStorageComponent selectedSlotStorage = slotToCheck.GetAsStorage();
3954 SCR_UniversalInventoryStorageComponent selectedSlotUniversalStorage = SCR_UniversalInventoryStorageComponent.Cast(selectedSlotStorage);
3955
3956 // Check if stroage contains any nonrefundable items
3957 if (selectedSlotUniversalStorage && selectedSlotUniversalStorage.GetNonRefundableItemCount() > 0)
3958 {
3959 nonrefundableItemInStorage = true;
3960 return true;
3961 }
3962 else
3963 {
3964 // Check all substorages in a ClothNodeStorage
3965 ClothNodeStorageComponent selectedSlotClothStorage = ClothNodeStorageComponent.Cast(selectedSlotStorage);
3966 if (selectedSlotClothStorage)
3967 {
3968 array<BaseInventoryStorageComponent> storages = {};
3969 selectedSlotClothStorage.GetOwnedStorages(storages, 1, false);
3971
3972 foreach (BaseInventoryStorageComponent stor : storages)
3973 {
3974 if (!stor)
3975 continue;
3976 univStor = SCR_UniversalInventoryStorageComponent.Cast(stor);
3977 if (!univStor)
3978 continue;
3979 if (univStor.GetNonRefundableItemCount() > 0)
3980 {
3981 nonrefundableItemInStorage = true;
3982 return true;
3983 }
3984 }
3985 }
3986 }
3987
3988 return false;
3989 }
3990
3991 //------------------------------------------------------------------------------------------------
3993 {
3994 BaseInventoryStorageComponent storageComponent = m_pStorageLootUI.GetCurrentNavigationStorage();
3995
3996 if (!storageComponent && m_aOpenedStoragesUI)
3997 storageComponent = GetOpenArsenalStorage();
3998
3999 if (!storageComponent || !IsStorageArsenal(storageComponent))
4000 return false;
4001
4002 // Check if slot contains any nonrefundable items
4004 return false;
4005
4007 IEntity arsenalEntity = storageComponent.GetOwner();
4008 if (arsenalEntity)
4009 {
4011
4012 //~ Arsenal is disabled so cannot refund
4013 if (arsenalComp && !arsenalComp.IsArsenalEnabled())
4014 return true;
4015 }
4016
4017 InventoryItemComponent inventoryItemComponent = m_pSelectedSlotUI.GetInventoryItemComponent();
4018 SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.FindResourceComponent(arsenalEntity);
4020
4021 if (!resourceInventoryComponent)
4022 return false;
4023
4024 resourceInventoryComponent.RpcAsk_ArsenalRefundItem(Replication.FindItemId(resourceComponent), Replication.FindItemId(inventoryItemComponent), EResourceType.SUPPLIES);
4025
4026 return true;
4027 }
4028
4029 //------------------------------------------------------------------------------------------------
4030 protected bool MoveItem_VirtualArsenal(inout SCR_InventoryStorageBaseUI pStorageBaseUI = null, out bool operationFailed = false)
4031 {
4032 SCR_ArsenalInventorySlotUI arsenalInventorySlotUI;
4033
4035 arsenalInventorySlotUI = SCR_ArsenalInventorySlotUI.Cast(m_pSelectedSlotUI);
4036 else
4037 return false;
4038
4039 if (!arsenalInventorySlotUI)
4040 {
4041 if (m_pActiveHoveredStorageUI && !IsStorageArsenal(m_pActiveHoveredStorageUI.GetCurrentNavigationStorage()))
4042 return false;
4043
4044 // Check if slot contains any nonrefundable items
4046 return false;
4047
4049 BaseInventoryStorageComponent storageComponent = m_pStorageLootUI.GetCurrentNavigationStorage();
4050
4051 if (!storageComponent)
4052 storageComponent = m_pActiveHoveredStorageUI.GetStorage();
4053
4054 if (!storageComponent || !IsStorageArsenal(storageComponent) )
4055 return false;
4056
4057 IEntity arsenalEntity = storageComponent.GetOwner();
4058 if (arsenalEntity)
4059 {
4061
4062 //~ Arsenal is disabled so cannot refund
4063 if (arsenalComp && !arsenalComp.IsArsenalEnabled())
4064 {
4065 operationFailed = true;
4066 return true;
4067 }
4068 }
4069
4070 InventoryItemComponent inventoryItemComponent = m_pSelectedSlotUI.GetInventoryItemComponent();
4071 SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.FindResourceComponent(arsenalEntity);
4073
4074 resourceInventoryComponent.RpcAsk_ArsenalRefundItem(Replication.FindItemId(resourceComponent), Replication.FindItemId(inventoryItemComponent), EResourceType.SUPPLIES);
4075
4076 return true;
4077 }
4078
4079 BaseInventoryStorageComponent storageComponent = m_pActiveHoveredStorageUI.GetCurrentNavigationStorage();
4080 if (!storageComponent)
4081 return false;
4082 if (arsenalInventorySlotUI && storageComponent.GetOwner().FindComponent(SCR_ArsenalInventoryStorageManagerComponent))
4083 return true;
4084
4085 BaseInventoryStorageComponent storageTo = m_pActiveHoveredStorageUI.GetCurrentNavigationStorage();
4086 IEntity arsenalEntity = SCR_InventoryStorageBaseUI.ARSENAL_SLOT_STORAGES.Get(arsenalInventorySlotUI);
4087 SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.FindResourceComponent(arsenalEntity);
4088 ResourceName resourceName = arsenalInventorySlotUI.GetItemResource();
4090
4091 if (storageTo.IsInherited(ClothNodeStorageComponent))
4092 {
4093 storageTo = m_InventoryManager.FindActualStorageForItemResource(resourceName, storageTo);
4094 if (!storageTo)
4095 {
4096 operationFailed = true;
4097 return true;
4098 }
4099 }
4100
4101 if (m_InventoryManager.CanInsertItemInStorage(arsenalInventorySlotUI.GetInventoryItemComponent().GetOwner(), storageTo))
4102 resourceInventoryComponent.RpcAsk_ArsenalRequestItem(Replication.FindItemId(resourceComponent), Replication.FindItemId(storageTo), resourceName, EResourceType.SUPPLIES);
4103 else
4104 operationFailed = true;
4105
4106 return true;
4107 }
4108
4109 //------------------------------------------------------------------------------------------------
4111 {
4112 SCR_ArsenalInventorySlotUI arsenalInventorySlotUI;
4113
4115 arsenalInventorySlotUI = SCR_ArsenalInventorySlotUI.Cast(m_pSelectedSlotUI);
4116 else if (!m_pSelectedSlotUI || !arsenalInventorySlotUI)
4117 return false;
4118
4120
4121 if (!weaponSlot)
4122 return false;
4123
4124 BaseInventoryStorageComponent storageTo = weaponSlot.GetStorageUI().GetStorage();
4125 IEntity arsenalEntity = SCR_InventoryStorageBaseUI.ARSENAL_SLOT_STORAGES.Get(arsenalInventorySlotUI);
4126 if (!arsenalEntity)
4127 return false;
4128 SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.FindResourceComponent(arsenalEntity);
4129 ResourceName resourceName = arsenalInventorySlotUI.GetItemResource();
4131
4132 if (CanAddAttachment(arsenalInventorySlotUI, weaponSlot))
4133 {
4134 storageTo = weaponSlot.GetStorageComponent();
4135 }
4136
4137 if (m_InventoryManager.CanInsertItemInStorage(arsenalInventorySlotUI.GetInventoryItemComponent().GetOwner(), storageTo))
4138 resourceInventoryComponent.RpcAsk_ArsenalRequestItem(Replication.FindItemId(resourceComponent), Replication.FindItemId(storageTo), resourceName, EResourceType.SUPPLIES);
4139
4140 return true;
4141 }
4142
4143 //------------------------------------------------------------------------------------------------
4148 protected bool MoveItemToStorageSlot_VirtualArsenal(out bool operationFailed = false)
4149 {
4150 SCR_ArsenalInventorySlotUI arsenalInventorySlotUI;
4151
4153 arsenalInventorySlotUI = SCR_ArsenalInventorySlotUI.Cast(m_pSelectedSlotUI);
4154 else
4155 return false;
4156
4157 if (!arsenalInventorySlotUI)
4158 {
4159 // If the slot was dragged onto a non arsenal slot then do not process virtual arsenal.
4161 return false;
4162
4163 // Check if slot contains any nonrefundable items
4165 return false;
4166
4168 BaseInventoryStorageComponent storageComponent = m_pStorageLootUI.GetCurrentNavigationStorage();
4169
4170 if (!storageComponent)
4171 storageComponent = m_pActiveHoveredStorageUI.GetStorage();
4172
4173 if (!storageComponent || !IsStorageArsenal(storageComponent) )
4174 return false;
4175
4176 IEntity arsenalEntity = storageComponent.GetOwner();
4177 if (arsenalEntity)
4178 {
4180
4181 //~ Arsenal is disabled so cannot refund
4182 if (arsenalComp && !arsenalComp.IsArsenalEnabled())
4183 {
4184 operationFailed = true;
4185 return true;
4186 }
4187 }
4188
4189 InventoryItemComponent inventoryItemComponent = m_pSelectedSlotUI.GetInventoryItemComponent();
4190 SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.FindResourceComponent(arsenalEntity);
4192
4193 resourceInventoryComponent.RpcAsk_ArsenalRefundItem(Replication.FindItemId(resourceComponent), Replication.FindItemId(inventoryItemComponent), EResourceType.SUPPLIES);
4194
4195 return true;
4196 }
4197
4198 /*
4199 Do nothing but exit as successful because of dragging arsenal virtual item into another
4200 arsenal virtual item.
4201 */
4203 {
4204 operationFailed = true;
4205 return true;
4206 }
4207
4208 BaseInventoryStorageComponent storageTo = m_pFocusedSlotUI.GetAsStorage();
4209 if (!storageTo)
4210 storageTo = m_pFocusedSlotUI.GetStorageUI().GetStorage();
4211
4212 IEntity arsenalEntity = SCR_InventoryStorageBaseUI.ARSENAL_SLOT_STORAGES.Get(arsenalInventorySlotUI);
4213 SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.FindResourceComponent(arsenalEntity);
4214 ResourceName resourceName = arsenalInventorySlotUI.GetItemResource();
4216
4217 if (storageTo.IsInherited(ClothNodeStorageComponent))
4218 {
4219 storageTo = m_InventoryManager.FindActualStorageForItemResource(resourceName, storageTo);
4220 if (!storageTo)
4221 {
4222 operationFailed = true;
4223 return true;
4224 }
4225 }
4226
4227 if (m_InventoryManager.CanInsertItemInStorage(arsenalInventorySlotUI.GetInventoryItemComponent().GetOwner(), storageTo))
4228 resourceInventoryComponent.RpcAsk_ArsenalRequestItem(Replication.FindItemId(resourceComponent), Replication.FindItemId(storageTo), resourceName, EResourceType.SUPPLIES);
4229 else
4230 operationFailed = true;
4231
4232 return true;
4233 }
4234
4235 //------------------------------------------------------------------------------------------------
4236 protected bool EquipDraggedItem_VirtualArsenal(bool forceEquip = false)
4237 {
4238 SCR_ArsenalInventorySlotUI arsenalInventorySlotUI;
4239
4241 arsenalInventorySlotUI = SCR_ArsenalInventorySlotUI.Cast(m_pSelectedSlotUI);
4242
4243 if (!m_pSelectedSlotUI || !arsenalInventorySlotUI)
4244 return false;
4245
4246 if (!arsenalInventorySlotUI.IsAvailable())
4247 return true;
4248
4249 IEntity slotEntity = arsenalInventorySlotUI.GetInventoryItemComponent().GetOwner();
4250 BaseInventoryStorageComponent storageTo = m_InventoryManager.FindStorageForItem(slotEntity, EStoragePurpose.PURPOSE_ANY);
4251 IEntity arsenalEntity = SCR_InventoryStorageBaseUI.ARSENAL_SLOT_STORAGES.Get(arsenalInventorySlotUI);
4252 SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.FindResourceComponent(arsenalEntity);
4253 ResourceName resourceName = arsenalInventorySlotUI.GetItemResource();
4255
4256 if (m_InventoryManager.CanInsertItemInStorage(slotEntity, storageTo))
4257 resourceInventoryComponent.RpcAsk_ArsenalRequestItem(Replication.FindItemId(resourceComponent), Replication.FindItemId(storageTo), resourceName, EResourceType.SUPPLIES);
4258
4259 return true;
4260 }
4261
4262 //------------------------------------------------------------------------------------------------
4264 {
4265 SCR_ArsenalInventorySlotUI arsenalInventorySlotUI;
4266
4268 arsenalInventorySlotUI = SCR_ArsenalInventorySlotUI.Cast(m_pSelectedSlotUI);
4269
4270 if (!m_pSelectedSlotUI || !arsenalInventorySlotUI)
4271 return false;
4272
4273 if (!arsenalInventorySlotUI.IsAvailable())
4274 return true;
4275
4276 IEntity slotEntity = arsenalInventorySlotUI.GetInventoryItemComponent().GetOwner();
4277 BaseInventoryStorageComponent storageTo = m_InventoryManager.FindStorageForItem(slotEntity, EStoragePurpose.PURPOSE_ANY);
4278 IEntity arsenalEntity = SCR_InventoryStorageBaseUI.ARSENAL_SLOT_STORAGES.Get(arsenalInventorySlotUI);
4279 SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.FindResourceComponent(arsenalEntity);
4280 ResourceName resourceName = arsenalInventorySlotUI.GetItemResource();
4282
4283 if (m_InventoryManager.CanInsertItemInStorage(slotEntity, storageTo))
4284 resourceInventoryComponent.RpcAsk_ArsenalRequestItem(Replication.FindItemId(resourceComponent), Replication.FindItemId(storageTo), resourceName, EResourceType.SUPPLIES);
4285
4286 return true;
4287 }
4288
4289 //------------------------------------------------------------------------------------------------
4290 protected bool MoveItem_ResourceContainer(inout SCR_InventoryStorageBaseUI pStorageBaseUI = null)
4291 {
4292 if (!m_pSelectedSlotUI)
4293 return false;
4294
4295 IEntity draggedEntity = m_pSelectedSlotUI.GetInventoryItemComponent().GetOwner();
4296
4297 if (!draggedEntity)
4298 return false;
4299
4300 SCR_ResourceComponent resourceComponentFrom;
4302 if (supplySlot)
4303 resourceComponentFrom = supplySlot.GetResourceComponent();
4304 else // keep the old way for backwards compatibility
4305 resourceComponentFrom = SCR_ResourceComponent.FindResourceComponent(draggedEntity);
4306
4307 if (!resourceComponentFrom)
4308 return false;
4309
4310 //~ TODO: Hotfix until proper solution, block moving supplies if occupied by character
4311 SCR_BaseCompartmentManagerComponent compartmentManager = SCR_BaseCompartmentManagerComponent.Cast(resourceComponentFrom.GetOwner().FindComponent(SCR_BaseCompartmentManagerComponent));
4312 if (compartmentManager && compartmentManager.BlockSuppliesIfOccupied() && compartmentManager.GetOccupantCount() > 0)
4313 return false;
4314
4316 return false;
4317
4318 SCR_InventoryStorageManagerComponent invManagerTo = m_pActiveHoveredStorageUI.GetInventoryManager();
4319
4320 if (!invManagerTo)
4321 return false;
4322
4323 SCR_ResourceInteractor interactorFrom = resourceComponentFrom.GetConsumer(EResourceGeneratorID.DEFAULT_STORAGE, EResourceType.SUPPLIES);
4324
4325 if (!interactorFrom)
4326 interactorFrom = resourceComponentFrom.GetConsumer(EResourceGeneratorID.VEHICLE_UNLOAD, EResourceType.SUPPLIES);
4327
4328 if (!interactorFrom)
4329 return false;
4330
4331 BaseInventoryStorageComponent storageTo = m_pActiveHoveredStorageUI.GetStorage();
4332
4334 if (!storageTo)
4335 {
4336 SCR_EntityCatalog resourceContainerCatalog = SCR_EntityCatalogManagerComponent.GetInstance().GetEntityCatalogOfType(EEntityCatalogType.SUPPLY_CONTAINER_ITEM);
4337 array<SCR_EntityCatalogEntry> entries = {};
4338 array<SCR_BaseEntityCatalogData> data = {};
4339
4340 resourceContainerCatalog.GetEntityListWithData(SCR_ResourceContainerItemData, entries, data);
4341
4343 float maxStoredResources = Math.Min(interactorFrom.GetAggregatedResourceValue(), datum.GetMaxResourceValue());
4344
4345 if (maxStoredResources <= 0)
4346 return true;
4347
4348 CreateItemSplitDialog(maxStoredResources, null, draggedEntity);
4349
4350 return true;
4351 }
4352
4353 IEntity targetEntity = storageTo.GetOwner();
4354 if (!targetEntity)
4355 return false;
4356
4357 SCR_ResourceComponent targetResourceComponent = SCR_ResourceComponent.FindResourceComponent(targetEntity);
4358
4361 if (targetResourceComponent)
4363
4366 if (draggedEntity == targetEntity || resourceComponentFrom == targetResourceComponent)
4367 return true;
4368
4369 SCR_EntityCatalog resourceContainerCatalog = SCR_EntityCatalogManagerComponent.GetInstance().GetEntityCatalogOfType(EEntityCatalogType.SUPPLY_CONTAINER_ITEM);
4370 array<SCR_EntityCatalogEntry> entries = {};
4371 array<SCR_BaseEntityCatalogData> data = {};
4372 float maxResourceValueTo = 0.0;
4373
4374 resourceContainerCatalog.GetEntityListWithData(SCR_ResourceContainerItemData, entries, data);
4375
4376 foreach (int idx, SCR_EntityCatalogEntry entry: entries)
4377 {
4379
4380 if (invManagerTo.CanInsertResourceInStorage(entry.GetPrefab(), storageTo))
4381 {
4382 maxResourceValueTo = datum.GetMaxResourceValue();
4383 break;
4384 }
4385 }
4386
4387 float maxStoredResources = Math.Min(interactorFrom.GetAggregatedResourceValue(), maxResourceValueTo);
4388
4389 if (maxStoredResources <= 0)
4390 return true;
4391
4392 CreateItemSplitDialog(maxStoredResources, targetEntity, draggedEntity);
4393
4394 return true;
4395 }
4396
4397 //------------------------------------------------------------------------------------------------
4399 {
4400 if (!m_pSelectedSlotUI)
4401 return false;
4402
4405 draggedSlot = m_DraggedSlot;
4406
4408 if (!iic)
4409 return false;
4410
4411 IEntity draggedEntity = iic.GetOwner();
4412 if (!draggedEntity)
4413 return false;
4414
4415 SCR_ResourceComponent resourceComponentFrom = SCR_ResourceComponent.FindResourceComponent(draggedEntity);
4416
4417 if (!resourceComponentFrom)
4418 return false;
4419
4420 IEntity targetEntity;
4421
4422 if (m_pFocusedSlotUI && m_pFocusedSlotUI.GetInventoryItemComponent())
4423 targetEntity = m_pFocusedSlotUI.GetInventoryItemComponent().GetOwner();
4425 targetEntity = m_pActiveHoveredStorageUI.GetStorage().GetOwner();
4426
4427 if (!targetEntity)
4428 return false;
4429
4430 SCR_ResourceComponent resourceComponentTo = SCR_ResourceComponent.FindResourceComponent(targetEntity);
4431
4432 if (!resourceComponentTo)
4433 return false;
4434
4435 //~ TODO: Hotfix until proper solution, block moving supplies if occupied by character
4436 SCR_BaseCompartmentManagerComponent compartmentManager = SCR_BaseCompartmentManagerComponent.Cast(resourceComponentTo.GetOwner().FindComponent(SCR_BaseCompartmentManagerComponent));
4437 if (compartmentManager && compartmentManager.BlockSuppliesIfOccupied() && compartmentManager.GetOccupantCount() > 0)
4438 return false;
4439
4440 SCR_ResourceInteractor interactorFrom = resourceComponentFrom.GetConsumer(EResourceGeneratorID.DEFAULT_STORAGE, EResourceType.SUPPLIES);
4441
4442 if (!interactorFrom)
4443 interactorFrom = resourceComponentFrom.GetConsumer(EResourceGeneratorID.VEHICLE_UNLOAD, EResourceType.SUPPLIES);
4444
4445 if (!interactorFrom)
4446 return false;
4447
4448 SCR_ResourceInteractor interactorTo = resourceComponentTo.GetConsumer(EResourceGeneratorID.DEFAULT_STORAGE, EResourceType.SUPPLIES);
4449
4450 if (!interactorTo)
4451 interactorTo = resourceComponentTo.GetGenerator(EResourceGeneratorID.VEHICLE_LOAD, EResourceType.SUPPLIES);
4452
4453 if (!interactorTo)
4454 return false;
4455
4458 if (draggedSlot == m_pFocusedSlotUI)
4459 return true;
4460
4461 float maxStoredResources = Math.Min(interactorFrom.GetAggregatedResourceValue(), interactorTo.GetAggregatedMaxResourceValue() - interactorTo.GetAggregatedResourceValue());
4462
4463 if (maxStoredResources <= 0)
4464 return true;
4465
4466 CreateItemSplitDialog(maxStoredResources, targetEntity, draggedEntity);
4467
4468 return true;
4469 }
4470
4471 //---- REFACTOR NOTE END ----
4472 //------------------------------------------------------------------------------------------------
4474 {
4475 if (!m_pSelectedSlotUI)
4476 return;
4477
4478 m_pSelectedSlotUI.SetSelected(false);
4479 m_pSelectedSlotUI = null;
4480
4481 if (m_pNavigationBar)
4483 }
4484
4485 //------------------------------------------------------------------------------------------------
4487 {
4488 IEntity m_pStorageToOpen = GetInventoryStorageManager().GetStorageToOpen();
4489
4490 if (!m_pStorageToOpen)
4491 return false;
4492
4493 BaseInventoryStorageComponent comp = BaseInventoryStorageComponent.Cast(m_pStorageToOpen.FindComponent(BaseInventoryStorageComponent));
4494
4495 if (!comp)
4496 return false;
4497
4499
4500 if (!storageUI)
4501 return false;
4502
4503 if (storageUI.IsTraversalAllowed())
4504 storageUI.Traverse(comp);
4505
4506 SetStorageSwitchMode(false);
4507
4508 ButtonWidget lastCloseTraverseButton = storageUI.GetLastCloseTraverseButton();
4509
4510 if (m_bIsUsingGamepad && lastCloseTraverseButton && !CanFocusOnSlotInStorage(storageUI, 0))
4511 GetGame().GetCallqueue().Call(FocusWidget, lastCloseTraverseButton);
4512 else
4513 GetGame().GetCallqueue().Call(FocusOnSlotInStorage, storageUI, 0);
4514
4515 return true;
4516 }
4517
4518 protected void FocusWidget(Widget focusWidget)
4519 {
4520 GetGame().GetWorkspace().SetFocusedWidget(focusWidget);
4521 }
4522
4523 //------------------------------------------------------------------------------------------------
4525 protected void TraverseActualSlot()
4526 {
4528 auto storage = m_pFocusedSlotUI.GetAsStorage();
4529 if (storage)
4530 {
4531 SCR_InventoryStorageBaseUI parentUIContainer = m_pFocusedSlotUI.GetStorageUI();
4532
4533 if (parentUIContainer.IsTraversalAllowed() && ShouldAllowTraverseActualSlot())
4534 parentUIContainer.Traverse(storage);
4535
4536 ButtonWidget lastCloseTraverseButton = parentUIContainer.GetLastCloseTraverseButton();
4537
4538 if (m_bIsUsingGamepad && lastCloseTraverseButton && !CanFocusOnSlotInStorage(parentUIContainer, 0))
4539 GetGame().GetWorkspace().SetFocusedWidget(lastCloseTraverseButton);
4540 else
4541 FocusOnSlotInStorage(parentUIContainer);
4542 }
4543 }
4544
4545 //------------------------------------------------------------------------------------------------
4549 {
4550 InventoryItemComponent inventoryItemComponent = m_pSelectedSlotUI.GetInventoryItemComponent();
4551
4552 // Check if the selected slot is an arsenal, and if it's in some inventory item then disallow traverse.
4553 if (inventoryItemComponent && inventoryItemComponent.GetParentSlot() && inventoryItemComponent.GetOwner().FindComponent(SCR_ArsenalInventoryStorageManagerComponent))
4554 return false;
4555
4556 return true;
4557 }
4558
4559 //------------------------------------------------------------------------------------------------
4560 protected void OpenAsNewContainer()
4561 {
4563 auto storage = m_pFocusedSlotUI.GetAsStorage();
4564 if (storage)
4565 {
4566 OpenStorageAsContainer(storage);
4567 OpenLinkedStorages(storage);
4568 SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_INV_HOTKEY_OPEN);
4569 }
4570 }
4571
4572 //------------------------------------------------------------------------------------------------
4578 void OpenLinkedStorages(BaseInventoryStorageComponent parentStorage, bool showVicinity = true, bool hideCloseButton = true)
4579 {
4581 if (!scrStorage)
4582 return;
4583
4584 OpenLinkedStoragesDelayed(scrStorage, showVicinity, hideCloseButton);
4585
4586 //~ Call the actual open linked storages 1 frame later so it can check properly if the storages it should open are already open
4587 //GetGame().GetCallqueue().CallLater(OpenLinkedStoragesDelayed, param1: scrStorage, param2: showVicinity, param3: hideCloseButton);
4588 }
4589
4590 //------------------------------------------------------------------------------------------------
4591 //~ Don't call directly. Call OpenLinkedStorages() instead!
4592 protected void OpenLinkedStoragesDelayed(SCR_UniversalInventoryStorageComponent scrStorage, bool showVicinity = true, bool hideCloseButton = true)
4593 {
4594 array<BaseInventoryStorageComponent> linkedStorages = {};
4595 if (scrStorage.GetLinkedStorages(linkedStorages) <= 0)
4596 return;
4597
4598 bool alreadyOpen;
4599
4600 foreach (BaseInventoryStorageComponent linkedStorage : linkedStorages)
4601 {
4602 //~ Storage is already open by means of traversal
4603 if (m_pStorageLootUI && m_pStorageLootUI.GetCurrentNavigationStorage() == linkedStorage)
4604 continue;
4605
4606 alreadyOpen = false;
4607
4608 foreach (SCR_InventoryOpenedStorageUI openedStorage : m_aOpenedStoragesUI)
4609 {
4610 //~ Already open
4611 if (openedStorage.GetStorage() == linkedStorage)
4612 {
4613 alreadyOpen = true;
4614 break;
4615 }
4616 }
4617
4618 if (alreadyOpen)
4619 continue;
4620
4621 OpenStorageAsContainer(linkedStorage, showVicinity, hideCloseButton);
4622 }
4623 }
4624
4625 //---- REFACTOR NOTE START: As an call later function as it needs to check if the parent is still open ----
4626 //------------------------------------------------------------------------------------------------
4631 void CloseLinkedStorages(BaseInventoryStorageComponent parentStorage)
4632 {
4634 if (!scrStorage)
4635 return;
4636
4637 //~ Call the actual close linked storages 1 frame later so it can check if the parent storage is still open via container or traversal
4638 GetGame().GetCallqueue().CallLater(CloseLinkedStoragesDelayed, param1: scrStorage);
4639 }
4640 //---- REFACTOR NOTE END ----
4641
4642 //------------------------------------------------------------------------------------------------
4643 //~ Don't call directly. Call CloseLinkedStorages() instead!
4645 {
4646 if (!scrStorage)
4647 return;
4648
4649 array<BaseInventoryStorageComponent> linkedStorages = {};
4650 if (scrStorage.GetLinkedStorages(linkedStorages) <= 0)
4651 return;
4652
4653 //~ Trying to close linked storages but the parent storage is still open via traversal
4654 if (m_pStorageLootUI && m_pStorageLootUI.GetCurrentNavigationStorage() == scrStorage)
4655 return;
4656
4657 //~ Trying to close linked storages but the parent storage is still open as a container
4658 foreach (SCR_InventoryOpenedStorageUI openedStorage : m_aOpenedStoragesUI)
4659 {
4660 if (!openedStorage)
4661 continue;
4662
4663 if (openedStorage.GetStorage() == scrStorage)
4664 return;
4665 }
4666
4667 //~ Close each linked storage that is open
4668 foreach (BaseInventoryStorageComponent linkedStorage : linkedStorages)
4669 {
4670 foreach (SCR_InventoryOpenedStorageUI openedStorage : m_aOpenedStoragesUI)
4671 {
4672 if (!openedStorage)
4673 continue;
4674
4675 //~ Storage is open
4676 if (openedStorage.GetStorage() == linkedStorage)
4677 {
4678 RemoveOpenStorage(openedStorage);
4679 break;
4680 }
4681 }
4682 }
4683 }
4684
4685 //------------------------------------------------------------------------------------------------
4687 protected void Action_SelectItem()
4688 {
4689 // Ignore if we cannot interact
4690 if (!GetCanInteract())
4691 return;
4692 SimpleFSM( EMenuAction.ACTION_SELECT );
4693 }
4694
4695 //------------------------------------------------------------------------------------------------
4697 {
4698 SimpleFSM(EMenuAction.ACTION_DESELECT);
4700 }
4701
4702 //------------------------------------------------------------------------------------------------
4704 {
4705 SimpleFSM(EMenuAction.ACTION_MOVEINSIDE);
4707 }
4708
4709 //------------------------------------------------------------------------------------------------
4710 protected void Action_EquipItem()
4711 {
4712 if (m_pFocusedSlotUI)
4713 m_pFocusedSlotUI.UseItem(m_Player, SCR_EUseContext.FROM_INVENTORY);
4714
4716 }
4717
4718 //------------------------------------------------------------------------------------------------
4719 protected void Action_MoveBetween()
4720 {
4721 // Ignore if we cannot interact
4722 if (!GetCanInteract())
4723 return;
4724 SimpleFSM( EMenuAction.ACTION_MOVEBETWEEN );
4726 }
4727
4728 //------------------------------------------------------------------------------------------------
4730 {
4732 InspectItem(null);
4733 else
4735
4736 SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_INV_WEAPON_INSPECT);
4737 }
4738
4739 //------------------------------------------------------------------------------------------------
4741 protected void Action_UseItem()
4742 {
4743 if (m_pFocusedSlotUI)
4744 {
4745 // TODO: Currently won't work if there are no HitzonePointContainers. (Won't work for saline bag if the player is not injured in any way)
4747 if (hzContainer)
4748 {
4749 SCR_InventoryHitZoneUI hzStorage = hzContainer.GetStorage();
4750 if (!hzStorage)
4751 return;
4752
4753 IEntity item = m_pFocusedSlotUI.GetInventoryItemComponent().GetOwner();
4754 if (!item)
4755 return;
4756
4757 if (hzStorage.CanApplyItem(item))
4758 {
4759 hzStorage.OnDrop(m_pFocusedSlotUI);
4760 }
4761 else
4762 {
4763 hzContainer = null;
4764 hzStorage = null;
4765
4766 for (int i = 0, max = m_AttachmentSpinBox.GetNumItems(); i < max; i++)
4767 {
4768 hzContainer = SCR_InventoryHitZonePointContainerUI.Cast(m_AttachmentSpinBox.GetItemData(i));
4769 if (!hzContainer)
4770 continue;
4771
4772 hzStorage = hzContainer.GetStorage();
4773 if (hzStorage && hzStorage.CanApplyItem(item))
4774 hzStorage.OnDrop(m_pFocusedSlotUI)
4775 }
4776 }
4777 }
4778
4780 if (point)
4781 {
4782 m_pGearInspectionPointUI.SetSlotFocused(point);
4783 point.OnDrop(m_pFocusedSlotUI);
4784 }
4785
4786 if (m_pFocusedSlotUI && (!hzContainer || !point))
4787 {
4788 m_pFocusedSlotUI.UseItem(m_Player, SCR_EUseContext.FROM_INVENTORY);
4789 }
4790 }
4791 }
4792
4793 //------------------------------------------------------------------------------------------------
4795 protected void Action_UnfoldItem()
4796 {
4797 SimpleFSM( EMenuAction.ACTION_UNFOLD );
4798 }
4799
4800 //------------------------------------------------------------------------------------------------
4801 void Action_StepBack(SCR_InventoryStorageBaseUI pParentStorage = null, int traverseStorageIndex = -1)
4802 {
4803 //TODO: m_pActiveStorageUI must be set according the active SCR_InventoryStorageBaseUI
4804 if (pParentStorage && pParentStorage.IsTraversalAllowed())
4805 {
4806 pParentStorage.Back(traverseStorageIndex);
4807 FilterOutStorages(false);
4808 m_EStateMenuItem = EStateMenuItem.STATE_IDLE;
4809 SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_INV_CONTAINER_CLOSE);
4810 FocusOnSlotInStorage(pParentStorage);
4811 }
4813 }
4814 //---- REFACTOR NOTE START: This code will need to be refactored as current implementation is not conforming to the standards ----
4815 //------------------------------------------------------------------------------------------------
4817 {
4818 if ( m_bDraggingEnabled )
4819 return;
4820 if ( !m_pFocusedSlotUI )
4821 return;
4822 if (!m_pFocusedSlotUI.IsDraggable())
4823 return;
4824
4825 if ( m_pFocusedSlotUI && WidgetManager.GetWidgetUnderCursor() != m_pFocusedSlotUI.GetButtonWidget() )
4826 return;
4827
4828 if (m_pFocusedSlotUI.Type() != SCR_InventorySlotUI &&
4839 return;
4840
4841 m_bDraggingEnabled = false;
4842 WidgetManager.GetMousePos( m_iMouseX, m_iMouseY );
4843 GetGame().GetInputManager().AddActionListener( "Inventory_Drag", EActionTrigger.PRESSED, Action_OnDrag );
4844 }
4845
4846 //------------------------------------------------------------------------------------------------
4848 {
4849 int iMouseX, iMouseY;
4850 WidgetManager.GetMousePos( iMouseX, iMouseY );
4851 if ( !m_bDraggingEnabled )
4852 {
4853 int dX = Math.AbsInt( iMouseX - m_iMouseX );
4854 int dY = Math.AbsInt( iMouseY - m_iMouseY );
4855 if ( ( dX < DRAG_THRESHOLD ) && ( dY < DRAG_THRESHOLD ) )
4856 return;
4857 if (!m_pFocusedSlotUI)
4858 {
4859 m_bDraggingEnabled = true;
4860 GetGame().GetInputManager().AddActionListener("Inventory_Drag", EActionTrigger.UP, Action_DragUp);
4861 return;
4862 }
4863
4864 if (!m_pFocusedSlotUI.IsDraggable())
4865 return;
4866 InventoryItemComponent focusedItemComp = m_pFocusedSlotUI.GetInventoryItemComponent();
4867 if (!focusedItemComp)
4868 return;
4869
4871 InventoryStorageSlot slot = focusedItemComp.GetParentSlot();
4872 if (slot)
4873 {
4874 IEntity owner = slot.GetOwner();
4875 while (owner)
4876 {
4878 {
4879 SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_INV_CONTAINER_DRAG);
4880 break;
4881 }
4882
4883 owner = owner.GetParent();
4884 if (!owner)
4885 SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_INV_VICINITY_DRAG);
4886 }
4887 }
4888 else
4889 {
4890 SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_INV_VICINITY_DRAG);
4891 }
4892
4893 m_bDraggingEnabled = true;
4894 SimpleFSM( EMenuAction.ACTION_DRAGGED );
4895 m_wDragDropContainer.SetVisible( true );
4896
4898 {
4900 IEntity previewEntity = null;
4901 InventoryItemComponent pComp = m_pSelectedSlotUI.GetInventoryItemComponent();
4902 if ( pComp )
4903 {
4904 previewEntity = pComp.GetOwner();
4906 m_pPreviewManager.SetPreviewItem(m_pDragDropPreviewImage, previewEntity);
4907 }
4908 }
4909 ContainerSetPos( iMouseX, iMouseY );
4910 GetGame().GetInputManager().AddActionListener( "Inventory_Drag", EActionTrigger.UP, Action_DragUp );
4911 }
4912 else
4913 {
4914 ContainerSetPos( iMouseX, iMouseY );
4915 }
4916 }
4917
4918 //------------------------------------------------------------------------------------------------
4920 {
4921 GetGame().GetInputManager().RemoveActionListener( "Inventory_Drag", EActionTrigger.PRESSED, Action_OnDrag );
4922 GetGame().GetInputManager().RemoveActionListener( "Inventory_Drag", EActionTrigger.UP, Action_DragUp );
4924 m_pPreviewManager.SetPreviewItem(m_pDragDropPreviewImage, null);
4925 GetGame().GetCallqueue().CallLater(m_wDragDropContainer.SetVisible, 0, false, false);
4926 if (m_DraggedSlot)
4927 SimpleFSM( EMenuAction.ACTION_DROPPED );
4928 m_bDraggingEnabled = false;
4929 m_DraggedSlot = null;
4931 }
4932 //---- REFACTOR NOTE END ----
4933
4934 //------------------------------------------------------------------------------------------------
4935 void ContainerSetPos( int iMouseX, int iMouseY )
4936 {
4937 float fWidth, fHeight;
4938 WorkspaceWidget wWorkSpace = GetGame().GetWorkspace();
4939 m_wDragDropContainer.GetScreenSize( fWidth, fHeight );
4940 fWidth = wWorkSpace.DPIUnscale( fWidth ) / 2;
4941 fHeight = wWorkSpace.DPIUnscale( fHeight ) / 2;
4942
4943 m_pDragDropFrameSlotUI.SetPosX( wWorkSpace.DPIUnscale( iMouseX ) - fWidth );
4944 m_pDragDropFrameSlotUI.SetPosY( wWorkSpace.DPIUnscale( iMouseY ) - fHeight );
4945 }
4946
4947 //------------------------------------------------------------------------------------------------
4948 // !
4949 protected void Action_Move( SCR_InventoryStorageBaseUI pStorageBase )
4950 {
4951 IEntity pItem = m_pSelectedSlotUI.GetInventoryItemComponent().GetOwner();
4952 m_InventoryManager.InsertItem( pItem, pStorageBase.GetCurrentNavigationStorage(), m_pFocusedSlotUI.GetStorageUI().GetCurrentNavigationStorage() );
4954 }
4955
4956 //------------------------------------------------------------------------------------------------
4957 SCR_InventoryOpenedStorageUI GetOpenedStorage(BaseInventoryStorageComponent storage)
4958 {
4959 if (!storage)
4960 return null;
4961
4962 foreach (SCR_InventoryOpenedStorageUI openedStorage : m_aOpenedStoragesUI)
4963 {
4964 if (openedStorage.GetStorage() == storage)
4965 return openedStorage;
4966 }
4967 return null;
4968 }
4969
4970 //------------------------------------------------------------------------------------------------
4971 // !
4972 protected void Action_LootMove()
4973 {
4974 if ( !m_pFocusedSlotUI )
4975 return;
4976 IEntity pItem = m_pFocusedSlotUI.GetInventoryItemComponent().GetOwner();
4977 if (m_InventoryManager.CanMoveItem(pItem))
4978 return;
4979
4980 m_pCallBack.m_pItem = pItem;
4981 m_pCallBack.m_pMenu = this;
4982
4983 // Loot ===>>> Character
4984 if ( m_pFocusedSlotUI.GetStorageUI() == m_pStorageLootUI )
4985 {
4986 m_pCallBack.m_pStorageFrom = m_pStorageLootUI;
4987 m_pCallBack.m_pStorageTo = m_pFocusedSlotUI.GetStorageUI();
4988
4989 if ( m_pDisplayedStorage.Type() == EquipedWeaponStorageComponent ) //default view opened, put the item into the first suitable storage
4990 {
4991 m_InventoryManager.InsertItem( pItem, null, null, m_pCallBack );
4992 }
4993 else
4994 {
4995 m_InventoryManager.InsertItem( pItem, m_pStorageBaseUI.GetCurrentNavigationStorage(), m_pStorageLootUI.GetCurrentNavigationStorage(), m_pCallBack ); //a storage is already opened, try to move it there
4996 }
4997 }
4998 else
4999 // Character ===>>> Loot
5000 {
5001 m_pCallBack.m_pStorageFrom = m_pFocusedSlotUI.GetStorageUI();
5002 m_pCallBack.m_pStorageTo = m_pStorageLootUI;
5003 auto storage = m_pStorageLootUI.GetCurrentNavigationStorage();
5004 if ( storage )
5005 m_InventoryManager.InsertItem( pItem, m_pStorageLootUI.GetCurrentNavigationStorage(), m_pDisplayedStorage, m_pCallBack ); // moving into the opened storage in the vicinity
5006 else
5007 {
5008 //droping it on the ground
5009 auto pSlot = m_pFocusedSlotUI.GetInventoryItemComponent().GetParentSlot();
5010 if ( pSlot )
5011 m_InventoryManager.TryRemoveItemFromInventory(pItem, pSlot.GetStorage(), m_pCallBack);
5012 }
5013 }
5015 }
5016
5017 //------------------------------------------------------------------------------------------------
5018 // !
5019 protected bool IsStorageInsideLBS( BaseInventoryStorageComponent pStorage, ClothNodeStorageComponent pLBSStorage )
5020 {
5021 if ( !pLBSStorage )
5022 return false;
5023 array<BaseInventoryStorageComponent> aOutStorages = new array<BaseInventoryStorageComponent>();
5024 pLBSStorage.GetOwnedStorages( aOutStorages, 1, false );
5025 return aOutStorages.Find(pStorage) != -1;
5026 }
5027
5028 //------------------------------------------------------------------------------------------------
5029 protected void OnItemAddedListener( IEntity item, notnull BaseInventoryStorageComponent storage )
5030 {
5031 if ( storage == m_StorageManager.GetLootStorage() )
5032 return;
5033
5034 if (m_pCallBack.m_pStorageToPickUp)
5035 {
5036 if (item.FindComponent(BaseInventoryStorageComponent) != m_pCallBack.m_pStorageToPickUp)
5037 {
5038 int quickSlotIndex = m_StorageManager.GetDefaultQuickSlot(item);
5039 if (quickSlotIndex > -1)
5040 m_pQuickSlotStorage.RefreshSlot(quickSlotIndex);
5041 return;
5042 }
5043 }
5044
5045 if ( storage.Type() == EquipedWeaponStorageComponent ) //we are updating the weapon storage on character
5046 {
5047 if ( m_pWeaponStorage )
5048 m_pWeaponStorage.Refresh();
5049 }
5050 else if ( storage.Type() == WeaponAttachmentsStorageComponent ) // we are updating a weapon ( attachement / magazin inserted )
5051 {
5052 //if ( m_pWeaponStorage && m_pWeaponStorage.GetCurrentNavigationStorage() == storage )
5053 if ( m_pWeaponStorage )
5054 m_pWeaponStorage.Refresh();
5055 }
5056 else
5057 {
5059 if (storageUI)
5060 storageUI.Refresh();
5061 }
5062
5063 if (m_StorageManager.GetEntityIndexInQuickslots(item) > -1)
5065
5067
5069 {
5070 if (m_pWeaponStorageComp.Get(0) || m_pWeaponStorageComp.Get(1))
5071 {
5072 m_pWeaponStorage.Refresh();
5073 }
5074 }
5075 }
5076
5077 //------------------------------------------------------------------------------------------------
5078 protected void OnItemRemovedListener( IEntity item, notnull BaseInventoryStorageComponent storage )
5079 {
5080 if ( !storage )
5081 return;
5082
5083 if (m_pCallBack.m_pStorageToDrop)
5084 {
5085 if (item.FindComponent(BaseInventoryStorageComponent) != m_pCallBack.m_pStorageToDrop)
5086 {
5087 int quickSlotIndex = m_StorageManager.GetEntityIndexInQuickslots(item);
5088 if (quickSlotIndex > -1)
5089 m_pCallBack.m_bShouldUpdateQuickSlots = true;
5090 return;
5091 }
5092 }
5093
5094 SCR_ConsumableItemComponent consumable = SCR_ConsumableItemComponent.Cast(item.FindComponent(SCR_ConsumableItemComponent));
5095 if (consumable && consumable.GetConsumableEffect() && consumable.GetConsumableEffect().GetDeleteOnUse()) // consumables require different handling
5096 {
5098 m_pAttachmentStorageUI.Refresh();
5100 if (storageUI)
5101 storageUI.Refresh();
5103 }
5104
5105 if ( storage == m_StorageManager.GetLootStorage() )
5106 return;
5107
5108 if (m_StorageManager.GetLastQuickSlotId(item) > -1)
5110
5112 if (storageUI)
5113 storageUI.Refresh();
5114
5116
5118 {
5119 if (m_pWeaponStorageComp.Get(0) || m_pWeaponStorageComp.Get(1))
5120 {
5121 m_pWeaponStorage.Refresh();
5122 }
5123 }
5124 }
5125
5126 //------------------------------------------------------------------------------------------------
5128 {
5129 if ( m_bDraggingEnabled )
5130 pContainer.ShowContainerBorder( m_DraggedSlot != null );
5131 m_pActiveHoveredStorageUI = pContainer;
5132 pContainer.SetPagingActive(true);
5134
5135 m_bEnablePagingContext = pContainer.GetPageCount() > 1;
5136 }
5137
5138 //------------------------------------------------------------------------------------------------
5140 {
5141 if (!itemSlot)
5142 return;
5143
5145 return;
5146
5148 if (!itemComp)
5149 return;
5150
5151 IEntity itemEntity = itemComp.GetOwner();
5152 if (!itemEntity)
5153 return;
5154
5155 SCR_EntityCatalogManagerComponent entityCatalogManager = SCR_EntityCatalogManagerComponent.GetInstance();
5156 string smallestContainerPrefab = "";
5157
5158 if (entityCatalogManager)
5159 {
5160 SCR_EntityCatalog resourceContainerCatalog = entityCatalogManager.GetEntityCatalogOfType(EEntityCatalogType.SUPPLY_CONTAINER_ITEM);
5161 array<SCR_EntityCatalogEntry> entries = {};
5162 array<SCR_BaseEntityCatalogData> data = {};
5163
5164 resourceContainerCatalog.GetEntityListWithData(SCR_ResourceContainerItemData, entries, data);
5165
5166 if (!entries.IsEmpty())
5167 {
5168 int minResourceValue;
5169 int currentEntryValue;
5170
5172
5173 minResourceValue = datum.GetMaxResourceValue();
5174
5175 if (!minResourceValue)
5176 minResourceValue = 0;
5177
5178 foreach (int idx, SCR_EntityCatalogEntry entry: entries)
5179 {
5180 datum = SCR_ResourceContainerItemData.Cast(data[idx]);
5181 currentEntryValue = datum.GetMaxResourceValue();
5182
5183 if (currentEntryValue > minResourceValue)
5184 break;
5185
5186 minResourceValue = currentEntryValue;
5187
5188 if (!entry)
5189 continue;
5190
5191 smallestContainerPrefab = entry.GetPrefab();
5192 }
5193 }
5194 }
5195
5196 BaseInventoryStorageComponent contStorage;
5197 array<BaseInventoryStorageComponent> contStorageOwnedStorages = {};
5198 SCR_EquipmentStorageComponent equipmentStorage;
5199 IEntity smallestContainerEntity;
5200
5201 if (smallestContainerPrefab != "")
5202 smallestContainerEntity = GetGame().SpawnEntityPrefabLocal(Resource.Load(smallestContainerPrefab));
5203
5204 foreach (SCR_InventoryStorageBaseUI storageBaseUI: m_aStorages)
5205 {
5206 if (!storageBaseUI)
5207 continue;
5208 if (storageBaseUI.Type() == SCR_InventoryStorageLootUI)
5209 continue;
5210 if (storageBaseUI == m_pActiveHoveredStorageUI)
5211 continue;
5212
5213 contStorage = storageBaseUI.GetStorage();
5214 if (!contStorage)
5215 continue;
5216
5217 float itemWeight = itemComp.GetTotalWeight();
5218 float totalWeightWithInsertedItem;
5219
5220 totalWeightWithInsertedItem = storageBaseUI.GetTotalRoundedUpWeight(contStorage);
5221 totalWeightWithInsertedItem += Math.Round(itemWeight * 100) * 0.01;
5222
5223 storageBaseUI.UpdateTotalWeight(totalWeightWithInsertedItem);
5224
5225 float totalOccupiedVolumeWithInsertedItem;
5226 totalOccupiedVolumeWithInsertedItem = storageBaseUI.GetOccupiedVolume(contStorage);
5227 totalOccupiedVolumeWithInsertedItem += itemComp.GetTotalVolume();
5228
5229 contStorageOwnedStorages.Clear();
5230 contStorage.GetOwnedStorages(contStorageOwnedStorages, 1, false);
5231 contStorageOwnedStorages.Insert(contStorage);
5232
5233 bool shouldUpdateVolumePercentage = true;
5234
5235 // Check to see if the itemEntity can fit into any equipment Storages so that volume is not updated in those cases.
5236 BaseInventoryStorageComponent validStorage = m_InventoryManager.FindStorageForInsert(itemEntity, contStorage, EStoragePurpose.PURPOSE_EQUIPMENT_ATTACHMENT);
5237 if (validStorage)
5238 {
5239 shouldUpdateVolumePercentage = false;
5240 }
5241
5242 if (!m_InventoryManager.CanInsertItemInActualStorage(itemEntity, contStorage) && itemEntity.FindComponent(SCR_ResourceComponent))
5243 shouldUpdateVolumePercentage = false;
5244
5245 if (shouldUpdateVolumePercentage)
5246 storageBaseUI.UpdateVolumePercentage(storageBaseUI.GetOccupiedVolumePercentage(contStorage, totalOccupiedVolumeWithInsertedItem), true);
5247
5248 bool canInsert = m_InventoryManager.CanInsertItemInActualStorage(itemEntity, contStorage);
5249
5250 if (!canInsert && SCR_ResourceComponent.FindResourceComponent(itemEntity))
5251 canInsert = m_InventoryManager.CanInsertItemInActualStorage(smallestContainerEntity, contStorage);
5252
5253 if (!canInsert && validStorage)
5254 canInsert = m_InventoryManager.CanInsertItemInActualStorage(itemEntity, validStorage);
5255
5257 bool weightCheck = true;
5258 if (uniContStorage)
5259 weightCheck = uniContStorage.IsAdditionalWeightOk(itemComp.GetTotalWeight());
5260
5262 if (!contStorage.PerformDimensionValidation(itemEntity))
5264
5265 if (!weightCheck)
5266 reason |= EInvInsertFailReason.WEIGHT;
5267
5268 if (!contStorage.PerformVolumeValidation(itemEntity))
5269 reason |= EInvInsertFailReason.CAPACITY;
5270
5271 if (canInsert)
5272 storageBaseUI.SetStorageAsHighlighted(true);
5273 else
5274 storageBaseUI.SetStorageAsHighlighted(false, reason);
5275 }
5276
5277 delete smallestContainerEntity;
5278 }
5279
5280 //------------------------------------------------------------------------------------------------
5282 {
5283 foreach (SCR_InventoryStorageBaseUI storageBaseUI: m_aStorages)
5284 {
5285 if (!storageBaseUI)
5286 continue;
5287
5288 storageBaseUI.UpdateVolumePercentage(storageBaseUI.GetOccupiedVolumePercentage(storageBaseUI.GetStorage()));
5289 storageBaseUI.UpdateTotalWeight(storageBaseUI.GetTotalRoundedUpWeight(storageBaseUI.GetStorage()));
5290 storageBaseUI.SetStorageAsHighlighted(true);
5291 }
5292 }
5293
5294 //------------------------------------------------------------------------------------------------
5296 {
5297 pContainer.ShowContainerBorder( false );
5299 pContainer.SetPagingActive(false);
5301 }
5302
5303 //------------------------------------------------------------------------------------------------
5305 {
5306 pContainer.ShowContainerBorder(true);
5307 SetActiveStorage(pContainer);
5308 m_pActiveStorageUI = pContainer;
5310 }
5311
5312 //------------------------------------------------------------------------------------------------
5314 {
5315 pContainer.ShowContainerBorder(false);
5316 SetActiveStorage(pContainer);
5317 m_pActiveStorageUI = null;
5319 }
5320
5321 //------------------------------------------------------------------------------------------------
5326
5327 //------------------------------------------------------------------------------------------------
5329 protected void RefreshUISlotStorages()
5330 {
5331 foreach ( SCR_InventorySlotUI pStorage : m_aShownStorages )
5332 {
5333 if ( pStorage )
5334 pStorage.Refresh();
5335 }
5336 }
5337
5338 //------------------------------------------------------------------------------------------------
5339 protected void UpdateTotalWeightText()
5340 {
5341 if (!m_wTotalWeightText)
5342 return;
5343
5344 float weight = Math.Round(GetTotalWeight() * 100) * 0.01;
5345
5346 if (weight <= 0 )
5347 weight = 0;
5348
5349 m_wTotalWeightText.SetTextFormat("#AR-ValueUnit_Short_Kilograms", weight);
5350 }
5351
5352 protected void InitQuickSlots()
5353 {
5355
5356 int quickSlotCount = m_StorageManager.GetQuickSlotItems().Count();
5357 for (int slotId = 1; slotId <= quickSlotCount; ++slotId)
5358 {
5359 GetGame().GetInputManager().AddActionListener("InventoryQuickSlot" + slotId, EActionTrigger.PRESSED, Action_SelectQuickSlot);
5360 }
5361
5362 }
5363
5364 //------------------------------------------------------------------------------------------------
5366 {
5368 {
5369 m_wQuickSlotStorage.RemoveHandler( m_wQuickSlotStorage.FindHandler( SCR_InventoryStorageQuickSlotsUI ) ); //remove the handler from the widget
5370 m_wQuickSlotStorage.RemoveFromHierarchy();
5371 }
5372
5373 Widget parent = m_widget.FindAnyWidget( "QuickSlots" );
5374 m_wQuickSlotStorage = GetGame().GetWorkspace().CreateWidgets( "{A1E61EF091EAC47D}UI/layouts/Menus/Inventory/InventoryQuickSlotsGrid.layout", parent );
5375
5376 if( !m_wQuickSlotStorage )
5377 return;
5378
5379 OverlaySlot.SetVerticalAlign( m_wQuickSlotStorage, LayoutVerticalAlign.Bottom );
5380 OverlaySlot.SetHorizontalAlign(m_wQuickSlotStorage, LayoutHorizontalAlign.Left);
5381
5382 m_wQuickSlotStorage.AddHandler( new SCR_InventoryStorageQuickSlotsUI( null, null, this ) );
5384 }
5385
5386 //------------------------------------------------------------------------------------------------
5387 // !
5389 {
5390 if ( !GetGame().GetInputManager() )
5391 return;
5392 int iSlot = -1;
5393
5394 int quickSlotCount = m_StorageManager.GetQuickSlotItems().Count();
5395 for (int id = 1; id <= quickSlotCount; ++id)
5396 {
5397 if (GetGame().GetInputManager().GetActionTriggered("InventoryQuickSlot" + id))
5398 iSlot = id;
5399 }
5400
5401 if ( iSlot != -1 )
5402 SetItemToQuickSlot( iSlot );
5403 }
5404
5405 //------------------------------------------------------------------------------------------------
5406 // !
5408 {
5409 if ( !m_pSelectedSlotUI )
5410 return;
5411 InventoryItemComponent pInventoryComponent = m_pSelectedSlotUI.GetInventoryItemComponent();
5412 if ( !pInventoryComponent )
5413 return;
5414 m_StorageManager.StoreItemToQuickSlot( pInventoryComponent.GetOwner(), m_pSelectedSlotUI.GetSlotIndex() );
5416 }
5417
5418 //------------------------------------------------------------------------------------------------
5419 // !
5420 protected void SetItemToQuickSlot( int iSlotIndex, SCR_InventorySlotUI slot = null )
5421 {
5422 if (!slot)
5423 slot = m_pFocusedSlotUI;
5424
5425 if (!slot)
5426 return;
5427
5428 if (iSlotIndex < WEAPON_SLOTS_COUNT)
5429 return;
5430
5431 SCR_InventoryStorageBaseUI storageUI = slot.GetStorageUI();
5432 if (storageUI
5433 && (storageUI.IsInherited(SCR_InventoryStorageLootUI) || storageUI.IsInherited(SCR_InventoryOpenedStorageUI))
5434 || IsStorageArsenal(storageUI.GetCurrentNavigationStorage()))
5435 return; //we don't want to take anything from vicinity to the quickslot
5436
5437 if (slot.Type() == SCR_InventorySlotQuickSlotUI)
5438 return;
5439
5440 InventoryItemComponent pInventoryComponent = slot.GetInventoryItemComponent();
5441 if (!pInventoryComponent)
5442 return;
5443
5444 IEntity pItem = pInventoryComponent.GetOwner();
5445 if (!pItem)
5446 return;
5447
5448 if (m_pWeaponStorageComp.Contains(pItem))
5449 return;
5450
5451 if (!CanItemFitIntoQuickSlots(pInventoryComponent))
5452 return; //so far only items with one line are supported ( issue on the UI side )
5453
5454 m_StorageManager.StoreItemToQuickSlot( pItem, --iSlotIndex );
5456 }
5457
5458 //------------------------------------------------------------------------------------------------
5463 {
5464 SCR_ItemAttributeCollection itemAttributes = SCR_ItemAttributeCollection.Cast(iic.GetAttributes());
5465 if (!itemAttributes)
5466 return true;
5467
5468 ESlotSize size = itemAttributes.GetQuickSlotItemSize();
5469 return size == ESlotSize.SLOT_1x1 || size == ESlotSize.SLOT_2x1;
5470 }
5471
5472 //------------------------------------------------------------------------------------------------
5473 // !
5474 protected void SetItemToQuickSlotDrop()
5475 {
5476 if (!m_pFocusedSlotUI)
5477 return;
5478
5479 if (!m_pSelectedSlotUI)
5480 return;
5481
5482 if (!m_pFocusedSlotUI.IsCompatible())
5483 return;
5484
5485 SCR_InventoryStorageBaseUI selectedSlotStorage = m_pSelectedSlotUI.GetStorageUI();
5486 if (selectedSlotStorage &&
5487 (selectedSlotStorage.IsInherited(SCR_InventoryStorageLootUI) || selectedSlotStorage.IsInherited(SCR_InventoryOpenedStorageUI)) ||
5488 IsStorageArsenal(selectedSlotStorage.GetCurrentNavigationStorage()))
5489 {
5490 return; //we don't want to take anything from vicinity to the quickslot
5491 }
5492
5493 IEntity pOriginalEntity;
5495 {
5496 InventoryItemComponent pComp = m_pFocusedSlotUI.GetInventoryItemComponent();
5497 if ( pComp )
5498 {
5499 pOriginalEntity = pComp.GetOwner();
5500 }
5501 }
5502
5503 InventoryItemComponent inventoryComponent = m_pSelectedSlotUI.GetInventoryItemComponent();
5504 if (!inventoryComponent)
5505 return;
5506
5507 IEntity item = inventoryComponent.GetOwner();
5508 if (!item || item.IsDeleted())
5509 return;
5510
5511 if (!CanItemFitIntoQuickSlots(inventoryComponent))
5512 {
5513 SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_INV_DROP_ERROR);
5514 return;
5515 }
5516
5517 int iSlotIndex = m_pFocusedSlotUI.GetSlotIndex();
5518 if (iSlotIndex < WEAPON_SLOTS_COUNT || m_pWeaponStorageComp.Contains(item))
5519 {
5521 SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_INV_DROP_ERROR);
5522 if (m_pSelectedSlotUI.GetButtonWidget())
5523 FocusWidget(m_pSelectedSlotUI.GetButtonWidget());
5524 else
5525 FocusWidget(m_pFocusedSlotUI.GetButtonWidget());
5526
5527 DeselectSlot();
5529 return;
5530 }
5531
5532 m_StorageManager.StoreItemToQuickSlot(item, iSlotIndex);
5533 if (pOriginalEntity)
5534 m_StorageManager.StoreItemToQuickSlot(pOriginalEntity, m_pSelectedSlotUI.GetSlotIndex());
5535
5537
5538 SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_INV_HOTKEY_CONFIRM);
5539
5540 SetStorageSwitchMode(false);
5543 }
5544
5545 //------------------------------------------------------------------------------------------------
5547 {
5548 if (!item1 || !item2)
5549 return;
5550
5551 IEntity from = item1.GetInventoryItemComponent().GetOwner();
5552 IEntity to = item2.GetInventoryItemComponent().GetOwner();
5553
5554 if (!(m_InventoryManager.CanMoveItem(from) && m_InventoryManager.CanMoveItem(to)))
5555 return;
5556
5557 m_pCallBack.m_pStorageFrom = m_pSelectedSlotUI.GetStorageUI();
5558 m_pCallBack.m_pStorageTo = m_pFocusedSlotUI.GetStorageUI();
5559 m_pCallBack.m_pItem = from;
5560 m_pCallBack.m_pMenu = this;
5561 m_pCallBack.m_pStorageToFocus = m_pCallBack.m_pStorageFrom;
5562 m_pCallBack.m_sItemToFocus = m_pSelectedSlotUI.GetItemResource();
5563 m_pCallBack.m_iSlotToFocus = m_pSelectedSlotUI.GetStorageUI().GetSlotId(m_pSelectedSlotUI);
5564
5565 //if (m_InventoryManager.CanSwapItemStorages(from, to))
5566 m_InventoryManager.TrySwapItemStorages(from, to, m_pCallBack);
5567 }
5568
5569 //------------------------------------------------------------------------------------------------
5571 {
5572 if (!toStorage)
5573 toStorage = m_pFocusedSlotUI.GetStorageUI();
5574
5575 if (!toStorage || !m_pSelectedSlotUI)
5576 return;
5577
5578 MoveItem(toStorage);
5580 }
5581
5582 //------------------------------------------------------------------------------------------------
5584 {
5585 if (!weapon)
5586 return false;
5587
5588 BaseWeaponManagerComponent weaponMan = BaseWeaponManagerComponent.Cast(m_Player.FindComponent(BaseWeaponManagerComponent));
5589 if (!weaponMan)
5590 return false;
5591
5593 if (!weaponComp)
5594 return false;
5595
5596 return weaponComp == weaponMan.GetCurrentWeapon();
5597 }
5598
5599 //------------------------------------------------------------------------------------------------
5601 {
5603 if (!itemComp || !itemComp.GetOwner())
5604 return false;
5605
5606 InventoryItemComponent targetItemComp = targetSlot.GetInventoryItemComponent();
5607 if (!targetItemComp || !targetItemComp.GetOwner())
5608 return false;
5609
5610 ItemAttributeCollection itemAttributes = itemComp.GetAttributes();
5611 if (!itemAttributes)
5612 return false;
5613
5614 AttachmentAttributes itemAttribute = AttachmentAttributes.Cast(itemAttributes.FindAttribute(AttachmentAttributes));
5615
5616 if (itemAttribute && itemAttribute.GetAttachmentType())
5617 {
5618 BaseInventoryStorageComponent pItemToReplaceStorage = BaseInventoryStorageComponent.Cast(targetItemComp.GetOwner().FindComponent(BaseInventoryStorageComponent));
5619
5620 if (!pItemToReplaceStorage)
5621 return false;
5622
5623 return m_InventoryManager.CanInsertItemInStorage(itemComp.GetOwner(), pItemToReplaceStorage)
5624 || m_InventoryManager.CanMoveItemToStorage(itemComp.GetOwner(), pItemToReplaceStorage);
5625 }
5626
5627 return false;
5628 }
5629
5634
5635 //------------------------------------------------------------------------------------------------
5637 {
5638 return m_bIsUsingGamepad;
5639 }
5640
5641 //------------------------------------------------------------------------------------------------
5642 void OnInputDeviceIsGamepad(bool isGamepad)
5643 {
5644 bool oldState = m_bIsUsingGamepad;
5645 bool switchedToMnK = m_bIsUsingGamepad && m_bIsUsingGamepad != isGamepad;
5646 m_bIsUsingGamepad = isGamepad;
5648 SetAttachmentSpinBoxActive(isGamepad);
5649 if (oldState != isGamepad)
5650 {
5651 if (oldState)
5652 m_pNavigationBar.SetButtonActionName(BUTTON_BACK, GAMEPAD_HINT_CLOSE); // force reset the lable of this hint as for M&K there is only one mode for this button
5653 else if (m_pSelectedSlotUI)
5654 DeselectSlot() // as there is nothing that cleares the selected slot which was selected when using M&K
5655 }
5656
5658 }
5659
5660 //------------------------------------------------------------------------------------------------
5665
5666 //------------------------------------------------------------------------------------------------
5668 {
5669 return m_bDraggingEnabled;
5670 }
5671
5672 //------------------------------------------------------------------------------------------------
5674 {
5675 return SCR_InventoryMenuUI.Cast(GetGame().GetMenuManager().FindMenuByPreset(ChimeraMenuPreset.Inventory20Menu));
5676 }
5677
5678 //------------------------------------------------------------------------------------------------
5680 {
5687
5688 //~ Create generic hint info for items with factions
5689 FactionManager factionManager = GetGame().GetFactionManager();
5690 if (factionManager)
5691 {
5692 array<Faction> factions = {};
5693 factionManager.GetFactionsList(factions);
5694
5695 SCR_FactionOutfitItemHintUIInfo factionHintInfo;
5696 foreach (Faction faction : factions)
5697 {
5698 factionHintInfo = SCR_FactionOutfitItemHintUIInfo.Cast(SCR_BaseContainerTools.CreateInstanceFromPrefab(ITEM_FACTION_INFO_CONFIG));
5699 if (!factionHintInfo)
5700 break;
5701
5702 m_mItemFactionUIInfos.Insert(faction.GetFactionKey(), factionHintInfo);
5703 }
5704 }
5705 }
5706
5707 //------------------------------------------------------------------------------------------------
5709 {
5710 // reset view distance back to value defined in video settings
5711 BaseContainer vs = GetGame().GetGameUserSettings().GetModule("SCR_VideoSettings");
5712 if (vs)
5713 {
5714 int dist;
5715 vs.Get("m_iViewDistance", dist);
5716 GetGame().SetViewDistance(dist);
5717 }
5718 }
5719
5720 #else
5721 protected float GetTotalLoadWeight();
5722 SCR_InventoryStorageManagerComponent GetInventoryStorageManager();
5723 bool GetCanInteract();
5724 override void OnMenuOpen();
5725 protected void Init();
5726 void ShowStorage();
5727 void ShowStorage( BaseInventoryStorageComponent storage );
5728 protected void ShowStoragesList();
5729 protected void ShowEquipedWeaponStorage();
5730 void ShowItemInfo( string sName = "", string sDescr = "", float sWeight = 0.0 );
5731 void HideItemInfo();
5732 void SetSlotFocused( SCR_InventorySlotUI pFocusedSlot );
5734 void InspectItem(SCR_InventorySlotUI itemSlot);
5735 void FilterOutStorages();
5736 protected void Action_CloseInventory();
5737 protected void Action_SelectItem();
5738 protected void Action_EquipItem();
5739 protected void Action_Drop();
5740 protected void Action_Inspect();
5741 protected void OnItemAddedListener( IEntity item, BaseInventoryStorageComponent storage );
5742 protected void OnItemRemovedListener( IEntity item, BaseInventoryStorageComponent storage );
5743 override bool OnClick( Widget w, int x, int y, int button );
5744 void FilterOutStorages( false );
5745 void MoveItem();
5746 void SCR_InventoryMenuUI();
5747 #endif
5748}
AddonBuildInfoTool id
ChimeraMenuPreset
Menu presets.
EEntityCatalogType
ArmaReforgerScripted GetGame()
Definition game.c:1398
int size
ResourceName resourceName
Definition SCR_AIGroup.c:66
SCR_BaseGameMode GetGameMode()
InputManager GetInputManager()
ECharacterBloodState
void SCR_CharacterRankComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
SCR_EUseContext
Get all prefabs that have the spawner data
void SCR_InventoryAttachmentStorageUI(BaseInventoryStorageComponent storage, LoadoutAreaType slotID=null, SCR_InventoryMenuUI menuManager=null, int iPage=0, array< BaseInventoryStorageComponent > aTraverseStorage=null, InventorySearchPredicate searchPredicate=null)
EStateMenuStorage
@ STATE_OPENED
@ STATE_INIT
@ STATE_IDLE
@ STATE_MOVING_ITEM_STARTED
@ NOCONTAINER
@ ISNOTINSIDE
EInvInsertFailReason
@ ACTION_BACK
@ ACTION_UNFOLD
@ ACTION_MOVEINSIDE
@ ACTION_SELECT
@ ACTION_OPENCONTAINER
@ ACTION_DROPPED
@ ACTION_MOVEBETWEEN
@ ACTION_DRAGGED
@ ACTION_DESELECT
func InventorySlotHoverMethod
@ HIT_ZONES
@ QUICK_SLOTS
@ NAVIGATION_BAR
@ STORAGE_LIST
@ WEAPON_STORAGE
ScriptInvokerBase< InventorySlotHoverMethod > ScriptInvokerInventorySlotHover
void OnClick()
On click callback.
Widget GetRootWidget()
EResourceGeneratorID
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
SCR_RespawnComponentClass OK
Result code for request/assign response.
Definition EMoveError.c:14
void SCR_UniversalInventoryStorageComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Constant variables used in various menus.
proto external Managed FindComponent(typename typeName)
proto external EntityPrefabData GetPrefabData()
proto external IEntity GetParent()
proto external bool IsDeleted()
Input management system for user interactions.
Definition Math.c:13
proto external MenuBase FindMenuByPreset(ScriptMenuPresetEnum preset)
Finds first menu/dialog with given preset index, or nullptr when there is no such menu opened.
proto external bool CloseMenuByPreset(ScriptMenuPresetEnum preset)
Put menu with given iPresetId into queue for closing (which is processed during next MenuManeger upda...
Main replication API.
Definition Replication.c:14
Object holding reference to resource. In destructor release the resource.
Definition Resource.c:25
ScriptInvoker GetOnControllableDeleted()
Blood - does not receive damage directly, only via scripted events.
ref OnLifeStateChangedInvoker m_OnLifeStateChanged
void SetFaction(notnull Faction faction, notnull SCR_OutfitFactionData outfitFactionData)
override void OnFailed()
override void OnComplete()
void InitializeHitZoneUI(BaseInventoryStorageComponent storage, SCR_InventoryMenuUI menuManager, int hitZoneId, IEntity player, bool updateAttachmentStorage=true)
bool CanApplyItem(notnull IEntity item)
override bool OnDrop(SCR_InventorySlotUI slot)
const LocalizedString GAMEPAD_HINT_CLOSE
const string BACKPACK_STORAGE_LAYOUT
void CreateItemSplitDialog(int maxVal, IEntity entityTo, IEntity entityFrom)
bool EquipWeaponIntoWeaponSlot_VirtualArsenal()
bool OnItemSplitDialogConfirm_Create(inout notnull SCR_ItemSplitDialog dialog)
void ContainerSetPos(int iMouseX, int iMouseY)
static ScriptInvoker GetOnItemHoverEnd()
void AddItemToAttachmentSelection(string item, Managed data=null)
ref array< SCR_InventoryHitZonePointContainerUI > m_aHitZonePoints
void HighlightAvailableStorages(SCR_InventorySlotUI itemSlot)
SCR_InventoryHitZonePointUI m_fractureHandlerGlobal
SCR_InventoryStorageBaseUI m_pPrevActiveStorageUI
void HandleSelectButtonState(string sAction=GAMEPAD_HINT_SELECT)
SCR_InventoryGearInspectionPointUI GetGearInspectionUI()
SCR_CharacterDamageManagerComponent m_CharDamageManager
SCR_InventorySpinBoxComponent GetAttachmentSpinBoxComponent()
void OpenLinkedStorages(BaseInventoryStorageComponent parentStorage, bool showVicinity=true, bool hideCloseButton=true)
ref array< HitZone > m_aBleedingHitZones
BaseInventoryStorageComponent GetOpenArsenalStorage()
int CloseStorage(SCR_InventoryStorageBaseUI pStorageUI)
SCR_InventoryStorageBaseUI GetStorageUIByBaseStorageComponent(BaseInventoryStorageComponent pStorage)
void UpdateItemInfoPosition(bool postponed=false)
void OnControllableDeleted(IEntity controllable)
void FocusWidget(Widget focusWidget)
const LocalizedString GAMEPAD_HINT_DESELECT
SCR_InventorySlotUI GetDraggedSlot()
SCR_InventoryStorageBaseUI m_pActiveHoveredStorageUI
bool OnItemSplitDialogConfirm_Merge(inout notnull SCR_ItemSplitDialog dialog)
SCR_InventoryStorageManagerComponent m_InventoryManager
SCR_NavigationBarUI m_pNavigationBar
void ShowVicinity(bool compact=false)
bool MoveItem_ResourceContainer(inout SCR_InventoryStorageBaseUI pStorageBaseUI=null)
SCR_InventorySlotUI m_pSelectedSlotUI
void OnLootedCharacterLifeStateChanged(ECharacterLifeState previousLifeState, ECharacterLifeState newLifeState)
SCR_InventoryInspectionUI GetInspectionScreen()
Returns the inspection screen UI.
SCR_InventoryStorageBaseUI m_pActiveStorageUI
EDropContainer IsFocusedItemInsideDropContainer()
void EquipDraggedItem(bool forceEquip=false)
bool InitHitZones(bool batchProcessing=false)
void ShowItemInfo(string sName="", string sDescr="", float sWeight=0.0, SCR_InventoryUIInfo uiInfo=null)
SCR_InventorySpinBoxComponent m_AttachmentSpinBox
bool Init()
returns true if the init procedure was success
SCR_InventoryStorageBaseUI GetLootStorage()
SCR_InventorySlotStorageUI m_pStorageUITo
bool CanFocusOnSlotInStorage(SCR_InventoryStorageBaseUI storage, int slotIndex)
ItemPreviewManagerEntity GetItemPreviewManager()
SCR_InventorySlotUI m_DraggedSlot
bool MoveItemToStorageSlot_VirtualArsenal(out bool operationFailed=false)
void ShowAttachmentStorage(InventorySearchPredicate searchPredicate, bool closeOnly=false)
const string STORAGE_LAYOUT_CLOSE_WIDGET_NAME
ref array< SCR_InventoryOpenedStorageUI > m_aOpenedStoragesUI
void UnregisterUIStorage(SCR_InventorySlotUI pStorageUI)
bool CanAddAttachment(SCR_InventorySlotUI itemSlot, SCR_InventorySlotUI targetSlot)
const ResourceName ITEM_FACTION_INFO_CONFIG
SCR_InputButtonComponent m_CloseButton
ResourceName m_sSupplyRefundUIInfoPrefab
void NavigationBarUpdateGamepad()
Update the states of the navigation buttons used in the inventory while gamepad is used.
SCR_InventorySlotUI GetSelectedSlotUI()
BaseInventoryStorageComponent m_pStorageTo
SCR_InventoryStorageBaseUI GetActualStorageInCharacterStorageUI()
Actualy opened UI storage in character's storage.
void OnItemRemovedListener(IEntity item, notnull BaseInventoryStorageComponent storage)
SCR_InventoryStorageBaseUI GetActiveStorageUI()
void Action_Move(SCR_InventoryStorageBaseUI pStorageBase)
void OnAction(SCR_InputButtonComponent comp, string action, SCR_InventoryStorageBaseUI pParentStorage=null, int traverseStorageIndex=-1)
SCR_InventorySlotUI m_pFocusedSlotUI
bool IsWeaponEquipped(IEntity weapon)
void OnContainerHovered(SCR_InventoryStorageBaseUI pContainer)
SCR_CountingTimerUI m_salineTimerHandlerGlobal
ref SCR_PlayerSupplyAllocationItemHintUIInfo m_PlayerSupplyAllocationUIInfo
static ScriptInvokerInventorySlotHover GetOnItemHover()
bool CanInspectItemInInventory(notnull IEntity item, notnull InventoryItemComponent iic)
const string BUTTON_OPEN_NEW_CONTAINER
const string BUTTON_QUICK_UNASSIGN
SCR_InventoryStoragesListUI m_pStorageListUI
void ShowDamageInfo(string sName, SCR_InventoryDamageUIInfo damageInfo)
const ResourceName ITEM_RANK_PREFAB
PreviewRenderAttributes m_PlayerRenderAttributes
bool IsStorageInsideLBS(BaseInventoryStorageComponent pStorage, ClothNodeStorageComponent pLBSStorage)
void OnContainerLeft(SCR_InventoryStorageBaseUI pContainer)
void OnItemAddedListener(IEntity item, notnull BaseInventoryStorageComponent storage)
SCR_InventoryStorageQuickSlotsUI m_pQuickSlotStorage
SCR_CharacterInventoryStorageComponent m_StorageManager
const ResourceName PLAYER_SUPPLY_ALLOCATION_UIINFO_PREFAB
void NavigationBarUpdate()
Update the states of the navigation buttons used in the inventory.
ref SCR_NonrefundableItemHintUIInfo m_NonrefundableUIInfo
SCR_SlotUIComponent m_pDragDropFrameSlotUI
GridLayoutWidget m_wStoragesContainer
ItemPreviewWidget m_wPlayerRender
ref array< SCR_InventoryStorageBaseUI > m_aStorages
SCR_InventorySlotUI m_pItemToAssign
void Action_SelectItem()
when clicked on item / storage slot using controller or mouse
ref array< SCR_InventorySlotUI > m_aShownStorages
SCR_InventoryStorageBaseUI GetStorageList()
override void OnMenuUpdate(float tDelta)
ref SCR_SupplyCostItemHintUIInfo m_SupplyCostUIInfo
SCR_InventoryItemInfoUI m_pItemInfo
bool CanSwapItems(SCR_InventorySlotUI slot1, SCR_InventorySlotUI slot2)
void InspectWeapon(SCR_WeaponAttachmentsStorageComponent weaponAttachmentStorage)
SCR_CountingTimerUI m_morphineTimerHandlerGlobal
ref SCR_InvCallBack m_pCallBack
bool CanMoveItem(SCR_InventorySlotUI slot1, SCR_InventorySlotUI slot2)
bool FocusOnSlotInStorage(SCR_InventoryStorageBaseUI storageUi, int slotIndex=0)
void CloseLinkedStoragesDelayed(SCR_UniversalInventoryStorageComponent scrStorage)
void OpenStorageAsContainer(BaseInventoryStorageComponent storage, bool showVicinity=true, bool hideCloseButton=false)
ResourceName m_sNonrefundableUIInfoPrefab
void MoveToVicinity(IEntity pItem)
void FilterOutStorages(bool bShow=true)
shows only the storages the item can be stored into
SCR_InventoryStorageBaseUI GetStorageUIFromVicinity(BaseInventoryStorageComponent storage)
const string BUTTON_REMOVE_TOURNIQUET
ref SCR_ValuableIntelItemHintUIInfo m_ValuableIntelUIInfo
static ref ScriptInvoker m_OnItemHoverEnd
SCR_CharacterVicinityComponent m_pVicinity
const string BUTTON_ENTER_STORAGE
ref map< FactionKey, ref SCR_FactionOutfitItemHintUIInfo > m_mItemFactionUIInfos
ItemPreviewWidget m_pDragDropPreviewImage
SCR_InventoryStorageGadgetsUI m_pGadgetsBaseUI
void OnContainerFocused(SCR_InventoryStorageBaseUI pContainer)
bool CanMoveItem(SCR_InventorySlotUI slot1, SCR_InventoryStorageBaseUI slot2)
EStateMenuStorage m_EStateMenuStorage
SCR_InventoryOpenedStorageUI GetOpenedStorage(BaseInventoryStorageComponent storage)
void RegisterUIStorage(SCR_InventorySlotUI pStorageUI)
SCR_LoadingOverlay m_LoadingOverlay
void Action_SwapItems(SCR_InventorySlotUI item1, SCR_InventorySlotUI item2)
bool EquipDraggedItem_VirtualArsenal(bool forceEquip=false)
SCR_InventoryCharacterWidgetHelper m_pCharacterWidgetHelper
BaseInventoryStorageComponent m_pDisplayedStorage
ItemPreviewManagerEntity m_pPreviewManager
void InitializeAllHitZonesUI(bool startingTheProcess=true)
int CloseStorage(notnull Widget w)
SCR_InventoryWeaponSlotsUI m_pWeaponStorage
SCR_InventoryDamageInfoUI m_pDamageInfo
void OnContainerFocusLeft(SCR_InventoryStorageBaseUI pContainer)
SCR_InventorySlotStorageUI m_pFocusedSlotStorageUI
bool IsStorageArsenal(BaseInventoryStorageComponent storage)
void FilterOutItems(bool bFilterOut)
const string ARSENAL_STORAGE_LAYOUT
EStateMenuItem m_EStateMenuItem
ref SCR_InventoryGearInspectionPointUI m_pGearInspectionPointUI
SCR_InventoryStorageManagerComponent GetInventoryStorageManager()
static SCR_InventoryMenuUI GetInventoryMenu()
const LocalizedString GAMEPAD_HINT_SELECT
int m_iMouseY const int DRAG_THRESHOLD
void Action_MoveItemToStorage(SCR_InventoryStorageBaseUI toStorage=null)
SCR_InventorySlotUI FindFirstFocusableUiSlot(notnull array< SCR_InventorySlotUI > slots, out Widget button=null, int ignoredId=-1)
void SetItemToQuickSlot(int iSlotIndex, SCR_InventorySlotUI slot=null)
ItemPreviewWidget m_wPlayerRenderSmall
SCR_InventorySlotStorageUI GetSelectedSlotStorageUI()
void ToggleStorageContainerVisibility(notnull SCR_InventorySlotUI pSlot)
void RemoveOpenStorage(SCR_InventoryOpenedStorageUI openedStorage)
void RemoveAttachmentStorage(SCR_InventoryAttachmentStorageUI attStorage)
SCR_InventorySlotUI GetCurrentlyFocusedSlot()
void SortSlotsByLoadoutArea(out array< SCR_InventorySlotUI > aSlots)
void OpenLinkedStoragesDelayed(SCR_UniversalInventoryStorageComponent scrStorage, bool showVicinity=true, bool hideCloseButton=true)
SCR_CharacterControllerComponent GetCharacterController()
ref SCR_DamageStateConfig m_DamageStateConfig
ref SCR_SupplyRefundItemHintUIInfo m_SupplyRefundUIInfo
ChimeraCharacter m_Player
void CloseLinkedStorages(BaseInventoryStorageComponent parentStorage)
SCR_InventoryStorageBaseUI m_pStorageBaseUI
ResourceName m_sSupplyCostUIInfoPrefab
void LifeStateChanged(ECharacterLifeState previousLifeState, ECharacterLifeState newLifeState)
BaseInventoryStorageComponent m_pStorageFrom
SCR_InventoryAttachmentStorageUI m_pAttachmentStorageUI
const LocalizedString GAMEPAD_HINT_BACK
const ResourceName HITZONE_CONTAINER_LAYOUT
bool ItemBelongsToThePlayer(notnull IEntity item)
SCR_InventorySlotStorageUI m_pSelectedSlotStoragePrevUI
SCR_InventoryAttachmentStorageUI GetAttachmentStorageUI()
SCR_InventoryStorageBaseUI GetWeaponStorage()
void MoveItem(SCR_InventoryStorageBaseUI pStorageBaseUI=null)
EquipedWeaponStorageComponent m_pWeaponStorageComp
SCR_InventoryInspectionUI m_InspectionScreen
static ref ScriptInvokerInventorySlotHover m_OnItemHover
bool CanItemFitIntoQuickSlots(notnull InventoryItemComponent iic)
void OnItemSplitDialogConfirm(SCR_ItemSplitDialog dialog)
const LocalizedString GAMEPAD_HINT_MOVE
bool MoveItem_VirtualArsenal(inout SCR_InventoryStorageBaseUI pStorageBaseUI=null, out bool operationFailed=false)
void SetActiveStorage(SCR_InventoryStorageBaseUI storageUI)
void SetAttachmentSpinBoxActive(bool enable)
SCR_CharacterControllerComponent m_CharController
SCR_InventoryStorageBaseUI m_pStorageLootUI
void Action_StepBack(SCR_InventoryStorageBaseUI pParentStorage=null, int traverseStorageIndex=-1)
void GetGeneralItemHintsInfos(out notnull array< SCR_InventoryItemHintUIInfo > hintsInfo)
ref SCR_InventorySlotUI m_pInspectedSlot
void ShowStorage(BaseInventoryStorageComponent storage, LoadoutAreaType area=null)
SCR_InventoryHitZonePointUI m_bleedingHandlerGlobal
SCR_InventoryOpenedStorageUI CreateOpenedStorageUI(BaseInventoryStorageComponent storage)
ref SCR_ArsenalItemRankHintUIInfo m_ArsenalItemRankUIInfo
ResourceName m_ItemPreviewManagerPrefab
void SetStorageSwitchMode(bool enabled, bool updateNavBar=true)
BaseInventoryStorageComponent m_pLastCurrentNavStorage
const ResourceName VALUABLE_INTEL_UIINFO_PREFAB
void RemoveItemFromAttachmentSelection(string item)
const string STORAGES_LIST_LAYOUT
const string WEAPON_STORAGE_LAYOUT
void SimpleFSM(EMenuAction EAction=EMenuAction.ACTION_SELECT)
void InspectItem(SCR_InventorySlotUI itemSlot)
Opens the inspection screen for the item slot.
bool DoesSlotContainNonRefundableItems(notnull SCR_InventorySlotUI slotToCheck, out bool nonrefundableItemInStorage=false)
SCR_InventorySlotStorageUI m_pSelectedSlotStorageUI
void OnInputDeviceIsGamepad(bool isGamepad)
void SetSlotFocused(SCR_InventorySlotUI pFocusedSlot, SCR_InventoryStorageBaseUI pFromStorageUI, bool bFocused)
bool GetCanInteract()
Returns whether interaction with inventory items is possible.
override bool OnDrop(SCR_InventorySlotUI slot)
BaseInventoryStorageComponent GetStorageComponent()
returns the storage component associated with this UI component
InventoryItemComponent GetInventoryItemComponent()
void CheckCompatibility(SCR_InventorySlotUI slot)
void GetSlots(out notnull array< SCR_InventorySlotUI > outSlots)
string GetInventoryItemName(InventoryItemComponent item)
Function to override to get custom inventory name.
string GetInventoryItemDescription(InventoryItemComponent item)
Function to override to get custom inventory description.
static SCR_ItemSplitDialog Create(float max=1, IEntity entityTo=null, IEntity entityFrom=null)
static IEntity GetLocalControlledEntity()
Get max resource value of container Data obtained from if no max resource value found return max Resource value *int GetMaxResourceValue()
void RpcAsk_MergeContainerWithContainerPartial(RplId rplIdFrom, RplId rplIdTo, EResourceType resourceType, float requestedResources)
void RpcAsk_ArsenalRefundItem(RplId resourceComponentRplId, RplId inventoryItemRplId, EResourceType resourceType)
void RpcAsk_ArsenalRequestItem(RplId resourceComponentRplId, RplId storageComponentRplId, ResourceName resourceNameItem, EResourceType resourceType)
void RpcAsk_CreatePhysicalContainerWithContainer(RplId resourceComponentRplId, RplId inventoryManagerRplId, RplId storageComponentRplId, EResourceType resourceType, float requestedResources)
SCR_ResourceComponent GetResourceComponent()
UIInfo - allows to define UI elements.
Definition UIInfo.c:14
Definition Types.c:486
enum EPhysicsLayerPresets Vehicle
Definition gameLib.c:24
SCR_EditableEntityComponent GetControlledEntity()
EEquipItemType
ECharacterLifeState
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
proto void PrintFormat(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL, LogLevel level=LogLevel.NORMAL)
@ NONE
When Shape is created and not initialized yet.
Definition ShapeType.c:15
SCR_FieldOfViewSettings Attribute
int TNodeId
Node global id is a hash of name of the node.
Definition EnEntity.c:18
proto external PlayerController GetPlayerController()
EActionTrigger
EStoragePurpose
Tuple param1
proto native vector Vector(float x, float y, float z)
LayoutHorizontalAlign
LayoutVerticalAlign
@ SIZE
Float.
EWeaponType
Definition EWeaponType.c:13
ScriptInvokerBase< func > ScriptInvoker
Definition tools.c:134