Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_InventoryMenuUI.c
Go to the documentation of this file.
2 {
12 };
13 
15 {
19 };
20 
22 {
23  STATE_INIT,
24  STATE_IDLE,
26 };
27 
29 {
33 };
34 
36 {
40 };
41 
43 {
44  BEGIN = 0,
52 
53 };
54 
55 //------------------------------------------------------------------------------------------------
57 {
58  SCR_InventoryStorageBaseUI m_pStorageFrom;
59  SCR_InventoryStorageBaseUI m_pStorageTo;
60  SCR_InventoryStorageBaseUI m_pStorageToFocus;
61  SCR_InventoryStorageManagerComponent m_pStorageMan;
62 
63  BaseInventoryStorageComponent m_pStorageToDrop;
64  BaseInventoryStorageComponent m_pStorageToPickUp;
65 
66  EAttachAction m_eAttachAction = EAttachAction.NONE;
67  IEntity m_pItem;
68  SCR_InventoryMenuUI m_pMenu;
69  ResourceName m_sItemToFocus;
70  int m_iSlotToFocus;
71  bool m_bShouldEquip;
72  bool m_bUpdateSlotOnly;
73  bool m_bShouldUpdateQuickSlots;
74 
75  void InternalComplete()
76  {
77  OnComplete();
78  }
79  //------------------------------------------------------------------------------------------------
80  protected override void OnFailed()
81  {
82  if (m_pMenu && m_pItem && m_bShouldEquip)
83  {
84  m_pMenu.GetCharacterController().TryEquipRightHandItem(m_pItem, EEquipItemType.EEquipTypeWeapon, false);
85  m_bShouldEquip = false;
86  }
87 
88  if (m_pMenu)
89  m_pMenu.Action_DeselectItem();
90  }
91 
92  //------------------------------------------------------------------------------------------------
93  protected override void OnComplete()
94  {
95  if (m_pMenu && m_pItem && m_bShouldEquip)
96  {
97  m_pMenu.GetCharacterController().TryEquipRightHandItem(m_pItem, EEquipItemType.EEquipTypeWeapon, false);
98  m_bShouldEquip = false;
99  }
100 
101  if (m_eAttachAction == EAttachAction.ATTACH)
102  {
103  if (m_pStorageMan)
104  m_pStorageMan.PlayItemSound(m_pItem, SCR_SoundEvent.SOUND_EQUIP);
105  }
106  else if (m_eAttachAction == EAttachAction.DETACH)
107  {
108  if (m_pStorageMan)
109  m_pStorageMan.PlayItemSound(m_pItem, SCR_SoundEvent.SOUND_UNEQUIP);
110  }
111 
112  m_eAttachAction = EAttachAction.NONE;
113 
114  bool shouldUpdateStorageList;
115  if ( m_pStorageFrom )
116  {
117  if ( m_pMenu )
118  {
119  if ( m_pStorageFrom == m_pMenu.GetStorageList() )
120  {
121  shouldUpdateStorageList = true;
122  }
123  else
124  {
125  if (m_bUpdateSlotOnly)
126  {
127  m_pStorageFrom.UpdateSlotUI(m_sItemToFocus);
128  m_bUpdateSlotOnly = false;
129  }
130  else
131  {
132  BaseInventoryStorageComponent storage = m_pStorageFrom.GetCurrentNavigationStorage();
133  auto open = m_pMenu.GetOpenedStorage(storage);
134  if (open)
135  open.Refresh();
136 
137  if (m_pItem)
138  {
139  auto itemStorage = BaseInventoryStorageComponent.Cast(m_pItem.FindComponent(BaseInventoryStorageComponent));
140  open = m_pMenu.GetOpenedStorage(itemStorage);
141  if (open)
142  open.CloseStorage();
143  }
144 
145  if (m_pStorageFrom)
146  m_pStorageFrom.Refresh();
147  }
148  }
149  }
150  }
151  else
152  {
153  if ( m_pMenu )
154  {
155  shouldUpdateStorageList = true;
156  }
157  }
158 
159  if ( m_pStorageTo )
160  {
161  if ( m_pMenu )
162  {
163  if ( m_pStorageTo == m_pMenu.GetStorageList() )
164  {
165  shouldUpdateStorageList = true;
166 
167  auto itemStorage = BaseInventoryStorageComponent.Cast(m_pItem.FindComponent(BaseInventoryStorageComponent));
168  SCR_InventoryOpenedStorageUI open = m_pMenu.GetOpenedStorage(itemStorage);
169  if (open)
170  open.CloseStorage();
171  }
172  else
173  {
174  m_pStorageTo.Refresh();
175  BaseInventoryStorageComponent storage = m_pStorageTo.GetCurrentNavigationStorage();
176  auto open = m_pMenu.GetOpenedStorage(storage);
177  if (open)
178  open.Refresh();
179  }
180  }
181  }
182 
183  if (shouldUpdateStorageList)
184  {
185  m_pMenu.ShowStoragesList();
186  m_pMenu.ShowAllStoragesInList();
187  }
188 
189  if ( m_pMenu )
190  {
191  if ( m_pStorageFrom != m_pMenu.GetLootStorage() && m_pStorageTo != m_pMenu.GetLootStorage() )
192  m_pMenu.RefreshLootUIListener();
193 
194  SCR_InventoryStorageBaseUI pStorage = m_pMenu.GetActualStorageInCharacterStorageUI();
195  if ( pStorage )
196  {
197  if ( pStorage.Type() == SCR_InventoryStorageWeaponsUI )
198  pStorage = m_pMenu.GetStorageList();
199  //pStorage.Refresh();
200  }
201 
202  m_pMenu.NavigationBarUpdate();
203  m_pMenu.RefreshPlayerWidget();
204  }
205 
206  if (m_pStorageToFocus)
207  {
208  m_pMenu.FocusOnSlotInStorage(m_pStorageToFocus, m_iSlotToFocus);
209  m_iSlotToFocus = -1;
210  }
211 
212  if (!m_bShouldEquip && m_pStorageTo && m_pStorageTo.IsInherited(SCR_InventoryStorageLootUI))
213  SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_INV_CONTAINER_DIFR_DROP);
214 
215  if (m_pStorageToDrop)
216  {
217  if (m_pMenu && m_bShouldUpdateQuickSlots)
218  m_pMenu.ShowQuickSlotStorage();
219  m_pStorageToDrop = null;
220  }
221 
222  if (m_pStorageToPickUp)
223  {
224  if (m_pMenu && m_bShouldUpdateQuickSlots)
225  m_pMenu.ShowQuickSlotStorage();
226  m_pStorageToPickUp = null;
227  }
228 
229  m_bShouldUpdateQuickSlots = false;
230 
231  ResetVariables();
232  }
233 
234  //------------------------------------------------------------------------------------------------
235  protected void ResetVariables()
236  {
237  m_pStorageToFocus = null;
238  m_pStorageTo = null;
239  m_pStorageFrom = null;
240  }
241 
242 };
243 
244 //------------------------------------------------------------------------------------------------
248 {
249 
250  #ifndef DISABLE_INVENTORY
251  static protected ResourceName m_ItemPreviewManagerPrefab = "{9F18C476AB860F3B}Prefabs/World/Game/ItemPreviewManager.et";
252  protected SCR_InventoryStorageManagerComponent m_InventoryManager = null;
253  protected SCR_CharacterInventoryStorageComponent m_StorageManager = null;
254  protected ChimeraCharacter m_Player;
255  protected Widget m_wContainer;
256  protected Widget m_wStorageList, m_wGadgetStorage, m_wLootStorage, m_wOpenedStorage, m_wWeaponSlots;
257  protected Widget m_wAttachmentStorage;
258  protected Widget m_widget;
259 
260  protected SCR_InventoryInspectionUI m_InspectionScreen = null;
261 
262  protected SCR_InventorySlotUI m_pFocusedSlotUI = null;
263  protected SCR_InventorySlotUI m_pSelectedSlotUI = null;
264  protected SCR_InventorySlotUI m_pPrevSelectedSlotUI = null;
265 
266  protected SCR_InventorySlotStorageUI m_pFocusedSlotStorageUI = null;
267  protected SCR_InventorySlotStorageUI m_pSelectedSlotStorageUI = null;
268  protected SCR_InventorySlotStorageUI m_pSelectedSlotStoragePrevUI = null;
269 
270  protected SCR_InventoryStorageBaseUI m_pStorageBaseUI = null;
271  protected SCR_InventoryStoragesListUI m_pStorageListUI = null;
272  protected SCR_InventoryStorageGadgetsUI m_pGadgetsBaseUI = null;
273  protected SCR_InventoryStorageBaseUI m_pStorageLootUI = null;
274  protected SCR_InventoryWeaponSlotsUI m_pWeaponStorage = null;
275  protected EquipedWeaponStorageComponent m_pWeaponStorageComp = null;
276  protected ref array<SCR_InventoryOpenedStorageUI> m_aOpenedStoragesUI = {};
277  protected SCR_InventoryAttachmentStorageUI m_pAttachmentStorageUI = null;
278 
279  protected SCR_InventoryItemInfoUI m_pItemInfo = null;
280  protected SCR_InventoryDamageInfoUI m_pDamageInfo = null;
281  protected SCR_InventoryStorageBaseUI m_pActiveStorageUI = null;
282  protected SCR_InventoryStorageBaseUI m_pActiveHoveredStorageUI = null;
283  protected SCR_InventoryStorageBaseUI m_pPrevActiveStorageUI = null;
284  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 )
285  protected GridLayoutWidget m_wStoragesContainer;
286  protected const int STORAGE_AREA_COLUMNS = 2;
287  protected int m_iStorageListCounter = 0;
288  protected int m_iVicinityDiscoveryRadius = 0;
289  //protected static bool m_bColdStart = true; // uncomment to enable the expand / collapse feature of storages
290 
291  protected ref SCR_InventorySlotUI m_pInspectedSlot = null;
292  protected ref SCR_InventoryGearInspectionPointUI m_pGearInspectionPointUI = null;
293  protected Widget m_wAttachmentContainer = null;
294 
295  protected ProgressBarWidget m_wProgressBarWeight;
296  protected ProgressBarWidget m_wProgressBarWeightItem;
297 
298  const string ARSENAL_STORAGE_LAYOUT = "{1DA3820E61D50EA1}UI/layouts/Menus/Inventory/ArsenalInventoryContainerGrid.layout";
299  const string BACKPACK_STORAGE_LAYOUT = "{06E9285D68D190EF}UI/layouts/Menus/Inventory/InventoryContainerGrid.layout";
300  const string WEAPON_STORAGE_LAYOUT = "{7B28D87B8A1ADD41}UI/layouts/Menus/Inventory/InventoryWeaponSlots.layout";
301  const string GADGETS_STORAGE_LAYOUT = "{265189B87ED5CD10}UI/layouts/Menus/Inventory/InventoryGadgetsPanel.layout";
302  const string STORAGES_LIST_LAYOUT = "{FC579324F5E4B3A3}UI/layouts/Menus/Inventory/InventoryCharacterGrid.layout";
303  const string ITEM_INFO = "{AE8B7B0A97BB0BA8}UI/layouts/Menus/Inventory/InventoryItemInfo.layout";
304  const string DAMAGE_INFO = "{55AFA256E1C20FB2}UI/layouts/Menus/Inventory/InventoryDamageInfo.layout";
305  const string ACTION_LAYOUT = "{81BB7785A3987196}UI/layouts/Menus/Inventory/InventoryActionNew.layout";
306 
307  const string STORAGE_LAYOUT_CLOSE_WIDGET_NAME = "CloseStorageBtn";
308 
309  const ResourceName HITZONE_CONTAINER_LAYOUT= "{36DB099B4CDF8FC2}UI/layouts/Menus/Inventory/Medical/HitZonePointContainer.layout";
310 
311  [Attribute("{01E150D909447632}Configs/Damage/DamageStateConfig.conf", desc: "Config to get visual data from", params: "conf class=SCR_DamageStateConfig")]
312  protected ref SCR_DamageStateConfig m_DamageStateConfig;
313 
314 
315  protected EStateMenuStorage m_EStateMenuStorage = EStateMenuStorage.STATE_IDLE; // is this useful for anything?
316  protected EStateMenuItem m_EStateMenuItem = EStateMenuItem.STATE_IDLE;
317  protected string m_sFSMStatesNames[10]={"init", "idle", "item selected", "storage selected", "STATE_STORAGE_OPENED", "storage unfolded", "move started", "move finished", "closing", "STATE_UNKNOWN" };
318  protected SCR_NavigationBarUI m_pNavigationBar = null;
319  protected SCR_InputButtonComponent m_CloseButton;
320 
321  protected ResourceName m_sSupplyCostUIInfoPrefab = "{4D8296CB3CB3B8BF}Configs/Inventory/SupplyCost_ItemUIInfo.conf";
322  protected ref SCR_SupplyCostItemHintUIInfo m_SupplyCostUIInfo;
323 
324  //variables dedicated to move an item from storage to storage
325  protected IEntity m_pItem;
326  protected BaseInventoryStorageComponent m_pDisplayedStorage, m_pLastCurrentNavStorage;
327  protected BaseInventoryStorageComponent m_pStorageFrom, m_pStorageTo; //last known storages from the last move operation
328 // protected SCR_InventorySlotUI m_pStorageUIFrom;
329  protected SCR_InventorySlotStorageUI m_pStorageUITo; //last known storagesUI from the last move operation
330  protected SCR_CharacterVicinityComponent m_pVicinity;
331  ItemPreviewWidget m_wPlayerRender, m_wPlayerRenderSmall;
332  PreviewRenderAttributes m_PlayerRenderAttributes;
333  protected ButtonWidget m_wButtonShowAll;
334  protected SCR_InventoryCharacterWidgetHelper m_pCharacterWidgetHelper;
335  protected ItemPreviewManagerEntity m_pPreviewManager;
336  protected bool m_bDraggingEnabled;
337  protected FrameWidget m_wDragDropContainer;
338  protected SCR_SlotUIComponent m_pDragDropFrameSlotUI;
339  protected ItemPreviewWidget m_pDragDropPreviewImage;
340  protected ref array<SCR_InventoryStorageBaseUI> m_aStorages = {};
341  protected TextWidget m_wTotalWeightText;
342  protected bool m_bLocked = false; //helper variable
343 
344  //Item/Weapon Switching
345  protected SCR_InventoryStorageQuickSlotsUI m_pQuickSlotStorage;
346  protected Widget m_wQuickSlotStorage;
347  protected ref SCR_InvCallBack m_pCallBack = new SCR_InvCallBack();
348  const int WEAPON_SLOTS_COUNT = 4;
349 
350  protected bool m_bIsUsingGamepad;
351  protected float m_fX, m_fY; //debug;
352  protected bool m_bShowIt = true;
353  protected int m_iMouseX, m_iMouseY
354  const int DRAG_THRESHOLD = 5;
355 
356  //other character's information
357  protected SCR_CharacterControllerComponent m_CharController;
358  protected Widget m_wCharFeatureBleeding;
359  protected Widget m_wCharFeatureWounded;
360  //protected ProgressBarWidget m_wInfoStamina; // Preparation for showing the stamina level in inventory
361  protected ref array<HitZone> m_aBleedingHitZones = {};
362 
363  protected bool m_bWasJustTraversing;
364  protected bool m_bStorageSwitchMode;
365  protected SCR_InventorySlotUI m_pItemToAssign;
366 
367  protected Widget m_wAttachmentPointsContainer;
368  protected ref array<SCR_InventoryHitZonePointContainerUI> m_aHitZonePoints = {};
369 
370  protected SCR_InventoryHitZonePointUI m_bleedingHandlerGlobal;
371  protected SCR_InventoryHitZonePointUI m_fractureHandlerGlobal;
372  protected SCR_CountingTimerUI m_morphineTimerHandlerGlobal;
373  protected SCR_CountingTimerUI m_salineTimerHandlerGlobal;
374 
375  protected SCR_CharacterDamageManagerComponent m_CharDamageManager;
376  protected const int CHARACTER_HITZONES_COUNT = 7;
377 
378  protected SCR_InventorySpinBoxComponent m_AttachmentSpinBox;
379 
380  protected bool m_bProcessInitQueue = false;
381  protected EInvInitStage m_eInitStage = EInvInitStage.BEGIN;
382  protected SCR_LoadingOverlay m_LoadingOverlay;
383 
384  //------------------------------------------------------------------------------------------------
385  ItemPreviewManagerEntity GetItemPreviewManager()
386  {
387  return m_pPreviewManager;
388  }
389 
390  //------------------------------------------------------------------------------------------------
391  protected void InitializeCharacterHitZones()
392  {
393  if (m_AttachmentSpinBox)
394  m_AttachmentSpinBox.ClearAll();
395 
396  Widget bleeding = m_widget.FindAnyWidget("BleedingGlobal");
397  Widget fracture = m_widget.FindAnyWidget("FractureGlobal");
398  Widget morphineTimer = m_widget.FindAnyWidget("MorphineTimer");
399  Widget salineTimer = m_widget.FindAnyWidget("SalineTimer");
400 
401  m_CharController = SCR_CharacterControllerComponent.Cast(m_Player.GetCharacterController());
402  m_CharDamageManager = SCR_CharacterDamageManagerComponent.Cast(m_Player.GetDamageManager());
403  if (bleeding)
404  m_bleedingHandlerGlobal = SCR_InventoryHitZonePointUI.Cast(bleeding.FindHandler(SCR_InventoryHitZonePointUI));
405 
406  if (fracture)
407  m_fractureHandlerGlobal = SCR_InventoryHitZonePointUI.Cast(fracture.FindHandler(SCR_InventoryHitZonePointUI));
408 
409  if (morphineTimer)
410  m_morphineTimerHandlerGlobal = SCR_CountingTimerUI.Cast(morphineTimer.FindHandler(SCR_CountingTimerUI));
411 
412  if (salineTimer)
413  m_salineTimerHandlerGlobal = SCR_CountingTimerUI.Cast(salineTimer.FindHandler(SCR_CountingTimerUI));
414  }
415 
416  protected bool InitHitZones()
417  {
418  int hzToInit = m_aHitZonePoints.Count();
419  if (hzToInit == CHARACTER_HITZONES_COUNT)
420  return true;
421 
422  Widget w = GetGame().GetWorkspace().CreateWidgets(HITZONE_CONTAINER_LAYOUT, m_wAttachmentPointsContainer);
424  point.InitializeHitZoneUI(m_pStorageListUI.GetStorage(), this, hzToInit + 1, m_Player);
425  m_aHitZonePoints.Insert(point);
426 
427  return false;
428  }
429 
430  //------------------------------------------------------------------------------------------------
431  protected void HideCharacterHitZones()
432  {
433  if (m_AttachmentSpinBox)
434  m_AttachmentSpinBox.ClearAll();
435  if (m_bleedingHandlerGlobal)
436  m_bleedingHandlerGlobal.GetRootWidget().SetVisible(false);
437 
438  if (m_fractureHandlerGlobal)
439  m_fractureHandlerGlobal.GetRootWidget().SetVisible(false);
440 
441  if (m_morphineTimerHandlerGlobal)
442  m_morphineTimerHandlerGlobal.GetRootWidget().SetVisible(false);
443 
444  if (m_salineTimerHandlerGlobal)
445  m_salineTimerHandlerGlobal.GetRootWidget().SetVisible(false);
446 
447  foreach (SCR_InventoryHitZonePointContainerUI point : m_aHitZonePoints)
448  {
449  point.GetRootWidget().RemoveFromHierarchy();
450  }
451 
452  m_aHitZonePoints.Clear();
453  }
454 
455  //------------------------------------------------------------------------------------------------
456  // !
457  protected void InitializeCharacterInformation()
458  {
459  SCR_CharacterBloodHitZone charBloodHZ = SCR_CharacterBloodHitZone.Cast(m_CharDamageManager.GetBloodHitZone());
460  charBloodHZ.GetOnDamageStateChanged().Insert(OnDamageStateChanged);
461 
462  m_CharDamageManager.GetOnDamageOverTimeRemoved().Insert(OnDamageStateChanged);
463  m_CharDamageManager.GetOnDamageOverTimeAdded().Insert(OnDamageStateChanged);
464  m_CharDamageManager.GetOnDamageStateChanged().Insert(OnDamageStateChanged);
465  OnDamageStateChanged();
466  }
467 
468  //------------------------------------------------------------------------------------------------
469  void AddItemToAttachmentSelection(string item, Managed data = null)
470  {
471  if (item.IsEmpty())
472  return;
473  if (m_AttachmentSpinBox.FindItem(item) < 0)
474  m_AttachmentSpinBox.AddItem(item, false, data);
475 
476  SetAttachmentSpinBoxActive(m_bIsUsingGamepad);
477  }
478 
479  //------------------------------------------------------------------------------------------------
480  void RemoveItemFromAttachmentSelection(string item)
481  {
482  int index = m_AttachmentSpinBox.FindItem(item);
483  if (index > -1)
484  m_AttachmentSpinBox.RemoveItem(index, false);
485 
486  if (m_pDamageInfo && m_pDamageInfo.GetName() == item)
487  m_pDamageInfo.Destroy();
488 
489  SetAttachmentSpinBoxActive(m_bIsUsingGamepad);
490  }
491 
492  //------------------------------------------------------------------------------------------------
493  SCR_InventorySpinBoxComponent GetAttachmentSpinBoxComponent()
494  {
495  return m_AttachmentSpinBox;
496  }
497 
498  //------------------------------------------------------------------------------------------------
499  // !
500  void OnDamageStateChanged()
501  {
502  SCR_CharacterBloodHitZone charBloodHZ = SCR_CharacterBloodHitZone.Cast(m_CharDamageManager.GetBloodHitZone());
503 
504  //TODO@FAC change this strong treshold and make better condition when effects work
505  bool bleedingVisible = (charBloodHZ.GetHealthScaled() <= charBloodHZ.GetDamageStateThreshold(ECharacterBloodState.STRONG));
506  float bleedingAmount = Math.InverseLerp(
507  charBloodHZ.GetDamageStateThreshold(ECharacterBloodState.UNCONSCIOUS),
508  charBloodHZ.GetDamageStateThreshold(ECharacterBloodState.UNDAMAGED),
509  charBloodHZ.GetHealthScaled());
510 
511  if (m_bleedingHandlerGlobal)
512  {
513  m_bleedingHandlerGlobal.GetRootWidget().SetVisible(bleedingVisible);
514  m_bleedingHandlerGlobal.SetBloodLevelProgress(bleedingAmount);
515  }
516 
517  if (m_fractureHandlerGlobal)
518  m_fractureHandlerGlobal.GetRootWidget().SetVisible(m_CharDamageManager.GetMovementDamage() > 0);
519 
520  if (m_morphineTimerHandlerGlobal)
521  {
522  SCR_HitZone headHZ = SCR_HitZone.Cast(m_CharDamageManager.GetHeadHitZone());
523  if (headHZ)
524  m_morphineTimerHandlerGlobal.GetRootWidget().SetVisible(headHZ.GetDamageOverTime(EDamageType.HEALING) < 0);
525  }
526 
527  if (m_salineTimerHandlerGlobal)
528  m_salineTimerHandlerGlobal.GetRootWidget().SetVisible(charBloodHZ.GetDamageOverTime(EDamageType.HEALING) < 0);
529  }
530 
531  //------------------------------------------------------------------------------------------------
532  // !
533  void RegisterUIStorage( SCR_InventorySlotUI pStorageUI )
534  {
535  if ( m_aShownStorages.Find( pStorageUI ) > -1 )
536  return;
537 
538  if ( SCR_InventorySlotStorageUI.Cast( pStorageUI ) || SCR_InventorySlotWeaponUI.Cast( pStorageUI ) )
539  m_aShownStorages.Insert( pStorageUI );
540  }
541 
542  //------------------------------------------------------------------------------------------------
543  // !
544  void UnregisterUIStorage( SCR_InventorySlotUI pStorageUI )
545  {
546  if ( pStorageUI )
547  m_aShownStorages.RemoveItem( pStorageUI );
548  }
549 
550  //------------------------------------------------------------------------------------------------
551  void SetActiveStorage( SCR_InventoryStorageBaseUI storageUI )
552  {
553  m_pPrevActiveStorageUI = m_pActiveStorageUI;
554  m_pActiveStorageUI = storageUI;
555  if( m_pActiveStorageUI )
556  {
557  m_pFocusedSlotUI = m_pActiveStorageUI.GetFocusedSlot();
558  }
559  }
560 
561  //------------------------------------------------------------------------------------------------
562  //---Get total weight from all storages (weapon, gadget, deposit)
563  protected float GetTotalWeight()
564  {
565  if (!m_InventoryManager)
566  return 0;
567 
568  return m_InventoryManager.GetTotalWeightOfAllStorages();
569  }
570 
571  //------------------------------------------------------------------------------------------------
572  SCR_InventoryStorageManagerComponent GetInventoryStorageManager()
573  {
574  return m_InventoryManager;
575  }
576 
577  //------------------------------------------------------------------------------------------------
579  SCR_InventoryStorageBaseUI GetActualStorageInCharacterStorageUI() { return m_pStorageBaseUI; }
580  SCR_InventoryStorageBaseUI GetStorageList() { return m_pStorageListUI; }
581  SCR_InventoryStorageBaseUI GetLootStorage() { return m_pStorageLootUI; }
582 
583  //------------------------------------------------------------------------------------------------
585  bool GetCanInteract()
586  {
587  if (GetInspectionScreen())
588  return false;
589 
590  return true;
591  }
592 
593  //------------------------------------------------------------------------------------------------
594  void RefreshPlayerWidget()
595  {
596  if (!m_pPreviewManager || m_pInspectedSlot)
597  return;
598  if (m_wPlayerRender)
599  m_pPreviewManager.SetPreviewItem(m_wPlayerRender, m_Player, m_PlayerRenderAttributes, true);
600  if (m_wPlayerRenderSmall)
601  m_pPreviewManager.SetPreviewItem(m_wPlayerRenderSmall, m_Player, m_PlayerRenderAttributes);
602  }
603 
604  protected bool ProcessInitQueue()
605  {
606  switch (m_eInitStage)
607  {
608  case EInvInitStage.BEGIN:
609  {
610  m_eInitStage = EInvInitStage.NAVIGATION_BAR;
611  } break;
612 
613  case EInvInitStage.NAVIGATION_BAR:
614  {
615  m_pNavigationBar.SetAllButtonEnabled(false);
616  m_pNavigationBar.FillFromConfig();
617  NavigationBarUpdate();
618  m_eInitStage = EInvInitStage.QUICK_SLOTS;
619  } break;
620 
621  case EInvInitStage.QUICK_SLOTS:
622  {
623  InitQuickSlots();
624  m_eInitStage = EInvInitStage.WEAPON_STORAGE;
625  } break;
626 
627  case EInvInitStage.WEAPON_STORAGE:
628  {
629  ShowEquipedWeaponStorage();
630  m_eInitStage = EInvInitStage.STORAGE_LIST;
631  } break;
632 
633  case EInvInitStage.STORAGE_LIST:
634  {
635  ShowStoragesList();
636  m_eInitStage = EInvInitStage.STORAGES;
637  } break;
638 
639  case EInvInitStage.STORAGES:
640  {
641  ShowAllStoragesInList();
642  m_eInitStage = EInvInitStage.HIT_ZONES;
643  } break;
644 
645  case EInvInitStage.HIT_ZONES:
646  {
647  if (InitHitZones())
648  {
649  m_wPlayerRender.SetVisible(true);
650 
651  m_eInitStage = EInvInitStage.DONE;
652  }
653  } break;
654 
655  case EInvInitStage.DONE:
656  {
657  OnQueueProcessed();
658  return true;
659  }
660  }
661 
662  return false;
663  }
664 
665  protected void OnQueueProcessed()
666  {
667  m_bProcessInitQueue = false;
668  m_wAttachmentPointsContainer.SetVisible(true);
669  UpdateCharacterPreview();
670  SetStorageSwitchMode(m_bIsUsingGamepad);
671  if (m_LoadingOverlay)
672  m_LoadingOverlay.GetRootWidget().RemoveFromHierarchy();
673  }
674 
675  //------------------------------------------------------------------------------------------------
676  override void OnMenuUpdate(float tDelta)
677  {
678  super.OnMenuUpdate(tDelta);
679 
680  if (m_bProcessInitQueue)
681  {
682  if (!ProcessInitQueue())
683  return;
684  }
685 
686  if (m_InspectionScreen)
687  {
688  m_InspectionScreen.UpdateView(tDelta);
689  return;
690  }
691 
692  if (m_pCharacterWidgetHelper && m_pPreviewManager && m_PlayerRenderAttributes && m_pCharacterWidgetHelper.Update(tDelta, m_PlayerRenderAttributes))
693  {
694  UpdatePreview();
695  }
696  }
697 
698  //------------------------------------------------------------------------------------------------
699  void UpdatePreview()
700  {
701  if (m_pInspectedSlot)
702  UpdateGearInspectionPreview();
703  else
704  UpdateCharacterPreview();
705  }
706 
707  //------------------------------------------------------------------------------------------------
708  protected void UpdateCharacterPreview()
709  {
710  if (!m_wPlayerRender)
711  return;
712 
713  m_pPreviewManager.SetPreviewItem(m_wPlayerRender, m_Player, m_PlayerRenderAttributes);
714 
715  for (int i, count = m_aHitZonePoints.Count(); i < count; i++)
716  {
717  SCR_InventoryHitZonePointContainerUI hp = m_aHitZonePoints[i];
718  if (!hp)
719  continue;
720  TNodeId id = hp.GetBoneIndex();
721 
722  vector transform[4];
723  Math3D.MatrixIdentity4(transform);
724  float xOffset = 0;
725  if (hp.GetHitZoneGroup() == ECharacterHitZoneGroup.HEAD)
726  xOffset = -40;
727 
728  vector screenPos;
729  if (m_wPlayerRender.TryGetItemNodePositionInWidgetSpace(id, transform, screenPos))
730  {
731  FrameSlot.SetPos(hp.GetRootWidget(), screenPos[0] + xOffset, screenPos[1]);
732  }
733  }
734  }
735 
736  //------------------------------------------------------------------------------------------------
737  void UpdateGearInspectionPreview()
738  {
739  if (!m_pInspectedSlot)
740  {
741  InspectItem(null);
742  return;
743  }
744 
745  InventoryItemComponent itemComp = m_pInspectedSlot.GetInventoryItemComponent();
746 
747  if (!itemComp)
748  {
749  InspectItem(null);
750  return;
751  }
752 
753  m_pPreviewManager.SetPreviewItem(m_wPlayerRender, itemComp.GetOwner(), m_PlayerRenderAttributes, true);
754 
755  if (m_wPlayerRender && m_pGearInspectionPointUI)
756  m_pGearInspectionPointUI.UpdatePreviewSlotWidgets(m_wPlayerRender);
757  }
758 
759  //------------------------------------------------------------------------------------------------
760  override void OnMenuOpen()
761  {
762  if( !Init() )
763  {
764  Action_CloseInventory();
765  return;
766  }
767 
768  GetGame().SetViewDistance(GetGame().GetMinimumViewDistance());
769 
770  ShowVicinity();
771 
772  m_bProcessInitQueue = true;
773 
774  if (m_pPreviewManager)
775  {
776  m_wPlayerRender = ItemPreviewWidget.Cast( m_widget.FindAnyWidget( "playerRender" ) );
777  auto collection = m_StorageManager.GetAttributes();
778  if (collection)
779  m_PlayerRenderAttributes = PreviewRenderAttributes.Cast(collection.FindAttribute(SCR_CharacterInventoryPreviewAttributes));
780  SizeLayoutWidget wPlayerRenderSmallRoot = SizeLayoutWidget.Cast( m_widget.FindAnyWidget( "playerRenderSmallRoot" ) );
781  if ( wPlayerRenderSmallRoot )
782  m_wPlayerRenderSmall = ItemPreviewWidget.Cast( wPlayerRenderSmallRoot.FindAnyWidget( "item" ) );
783 
784  m_pCharacterWidgetHelper = SCR_InventoryCharacterWidgetHelper(m_wPlayerRender, GetGame().GetWorkspace() );
785  }
786 
787  Widget wrap = m_widget.FindAnyWidget( "WrapLayoutShow" );
788  m_wButtonShowAll = ButtonWidget.Cast( wrap.FindAnyWidget( "ItemButton" ) );
789  if( m_wButtonShowAll )
790  {
791  m_wButtonShowAll.AddHandler( new SCR_InventoryButton( EInventoryButton.BUTTON_SHOW_DEFAULT, this ) );
792  }
793 
794  if( m_pNavigationBar )
795  m_pNavigationBar.m_OnAction.Insert(OnAction);
796 
797  GetGame().GetInputManager().AddActionListener("Inventory_Drag", EActionTrigger.DOWN, Action_DragDown);
798  GetGame().GetInputManager().AddActionListener("Inventory", EActionTrigger.DOWN, Action_CloseInventory);
799  InitAttachmentSpinBox();
800  OnInputDeviceIsGamepad(!GetGame().GetInputManager().IsUsingMouseAndKeyboard());
801  GetGame().OnInputDeviceIsGamepadInvoker().Insert(OnInputDeviceIsGamepad);
802 
803  SetAttachmentSpinBoxActive(m_bIsUsingGamepad);
804 
805  ResetHighlightsOnAvailableStorages();
806  SetOpenStorage();
807  UpdateTotalWeightText();
808 
809  InitializeCharacterHitZones();
810  InitializeCharacterInformation();
811  UpdateCharacterPreview();
812  }
813 
814  void InitAttachmentSpinBox()
815  {
816  if (m_AttachmentSpinBox)
817  {
818  m_AttachmentSpinBox.ClearAll();
819  return;
820  }
821 
822  Widget w = m_widget.FindAnyWidget("AttachmentSpinBox");
823  if (!w)
824  {
825  Print("Cannot find AttachmentSpinBox widget in hierarchy!", LogLevel.ERROR);
826  return;
827  }
828 
829  m_AttachmentSpinBox = SCR_InventorySpinBoxComponent.Cast(w.FindHandler(SCR_InventorySpinBoxComponent));
830  m_AttachmentSpinBox.m_OnChanged.Insert(NavigationBarUpdateGamepad);
831  }
832 
833 
834  //------------------------------------------------------------------------------------------------
835  protected void SetStorageSwitchMode(bool enabled)
836  {
837  m_bStorageSwitchMode = enabled;
838  foreach (SCR_InventoryStorageBaseUI storage : m_aStorages)
839  {
840  if (storage)
841  storage.ActivateStorageButton(m_bStorageSwitchMode);
842  }
843 
844  m_pStorageLootUI.ActivateStorageButton(m_bStorageSwitchMode);
845  if (m_pStorageListUI)
846  m_pStorageListUI.ActivateStorageButton(m_bStorageSwitchMode);
847 
848  foreach (SCR_InventoryOpenedStorageUI storage : m_aOpenedStoragesUI)
849  {
850  storage.ActivateStorageButton(m_bStorageSwitchMode);
851  }
852 
853  if (m_bStorageSwitchMode)
854  {
855  HideItemInfo();
856  Widget btnToFocus = m_pStorageLootUI.GetButtonWidget();
857  if (m_pActiveStorageUI)
858  btnToFocus = m_pActiveStorageUI.GetButtonWidget();
859  GetGame().GetWorkspace().SetFocusedWidget(btnToFocus);
860  }
861  else
862  {
863  if (m_pActiveStorageUI)
864  {
865  m_pActiveStorageUI.ShowContainerBorder(false);
866  FocusOnSlotInStorage(m_pActiveStorageUI);
867  }
868  }
869 
870  NavigationBarUpdate();
871  }
872 
873  //------------------------------------------------------------------------------------------------
874  protected void ToggleStorageSwitchMode()
875  {
876  SetStorageSwitchMode(!m_bStorageSwitchMode);
877  }
878 
879  protected void SetAttachmentSpinBoxActive(bool enable)
880  {
881  if (!m_AttachmentSpinBox)
882  return;
883 
884  int itemCount = m_AttachmentSpinBox.GetNumItems();
885  bool shouldBeActive = (enable && (itemCount > 0));
886  m_AttachmentSpinBox.SetEnabled(shouldBeActive);
887  m_AttachmentSpinBox.GetRootWidget().SetVisible(shouldBeActive);
888 
889  Widget leftArea = m_widget.FindAnyWidget("LeftArea");
890  Widget rightArea = m_widget.FindAnyWidget("StoragesListSlot");
891 
892  // Switches navigation targets based on the presence of the spinbox in the center
893  if (shouldBeActive)
894  {
895  leftArea.SetNavigation(WidgetNavigationDirection.RIGHT, WidgetNavigationRuleType.EXPLICIT, "AttachmentSpinBox");
896  rightArea.SetNavigation(WidgetNavigationDirection.LEFT, WidgetNavigationRuleType.EXPLICIT, "AttachmentSpinBox");
897  m_AttachmentSpinBox.GetRootWidget().SetNavigation(WidgetNavigationDirection.RIGHT, WidgetNavigationRuleType.EXPLICIT, "StoragesListSlot");
898  m_AttachmentSpinBox.GetRootWidget().SetNavigation(WidgetNavigationDirection.LEFT, WidgetNavigationRuleType.EXPLICIT, "StorageLootSlot");
899  }
900  else
901  {
902  leftArea.SetNavigation(WidgetNavigationDirection.RIGHT, WidgetNavigationRuleType.EXPLICIT, "StoragesListSlot");
903  rightArea.SetNavigation(WidgetNavigationDirection.LEFT, WidgetNavigationRuleType.EXPLICIT, "StorageLootSlot");
904  }
905  }
906 
907  //------------------------------------------------------------------------------------------------
908  bool CanFocusOnSlotInStorage(SCR_InventoryStorageBaseUI storage, int slotIndex)
909  {
910  if (!storage)
911  return false;
912 
913  array<SCR_InventorySlotUI> slots = {};
914  storage.GetSlots(slots);
915  return slots.IsIndexValid(slotIndex);
916  }
917 
918  //------------------------------------------------------------------------------------------------
919  void FocusOnSlotInStorage(SCR_InventoryStorageBaseUI storage, int slotIndex = 0)
920  {
921  if (!storage)
922  return;
923 
924  array<SCR_InventorySlotUI> slots = {};
925  storage.GetSlots(slots);
926 
927  if (slots.IsIndexValid(slotIndex) && slots[slotIndex])
928  {
929  Widget slotToFocus = slots[slotIndex].GetButtonWidget();
930  if (!slotToFocus)
931  {
932  while (slots.IsIndexValid(++slotIndex) && !slotToFocus)
933  {
934  slotToFocus = slots[slotIndex].GetButtonWidget();
935  }
936  }
937 
938  GetGame().GetWorkspace().SetFocusedWidget(slotToFocus);
939  }
940  else
941  {
942  int slotToFocus = (slots.Count()-1);
943  if (slots.IsIndexValid(slotToFocus) && slots[slotToFocus])
944  GetGame().GetWorkspace().SetFocusedWidget(slots[slotToFocus].GetButtonWidget());
945  else
946  GetGame().GetWorkspace().SetFocusedWidget(null);
947  }
948  }
949 
950  //------------------------------------------------------------------------------------------------
952  protected bool Init()
953  {
954  m_widget = GetRootWidget();
955 
956  if ( m_widget == null )
957  return false;
958 
959  Widget loading = m_widget.FindAnyWidget("LoadingOverlay");
960  if (loading)
961  {
962  loading.SetVisible(true);
963  m_LoadingOverlay = SCR_LoadingOverlay.Cast(loading.FindHandler(SCR_LoadingOverlay));
964  }
965 
966  //Get player
967  PlayerController playerController = GetGame().GetPlayerController();
968  if ( playerController != null )
969  {
970  m_Player = ChimeraCharacter.Cast(playerController.GetControlledEntity());
971  if ( m_Player != null )
972  {
973  ChimeraWorld world = ChimeraWorld.CastFrom(m_Player.GetWorld());
974  if (!world)
975  return false;
976 
977  m_pPreviewManager = world.GetItemPreviewManager();
978  if (!m_pPreviewManager)
979  {
980  Resource rsc = Resource.Load(m_ItemPreviewManagerPrefab);
981  if (rsc.IsValid())
982  GetGame().SpawnEntityPrefabLocal(rsc, world);
983 
984  m_pPreviewManager = world.GetItemPreviewManager();
985  }
986 
987  m_CharController = SCR_CharacterControllerComponent.Cast(m_Player.GetCharacterController());
988  if (m_CharController)
989  {
990  m_CharController.m_OnLifeStateChanged.Insert(LifeStateChanged);
991  if (m_CharController.GetLifeState() != ECharacterLifeState.ALIVE)
992  return false;
993  }
994 
996  if (gameMode)
997  gameMode.GetOnControllableDeleted().Insert(OnControllableDeleted);
998 
999  //Inventory Manager
1000  m_InventoryManager = SCR_InventoryStorageManagerComponent.Cast( m_Player.FindComponent( SCR_InventoryStorageManagerComponent ) );
1001  m_StorageManager = SCR_CharacterInventoryStorageComponent.Cast( m_Player.FindComponent( SCR_CharacterInventoryStorageComponent ) );
1002  if( !m_StorageManager )
1003  return false;
1004  m_pWeaponStorageComp = EquipedWeaponStorageComponent.Cast(m_StorageManager.GetWeaponStorage());
1005  if( !m_pWeaponStorageComp )
1006  return false;
1007  if ( m_InventoryManager )
1008  {
1009  m_InventoryManager.m_OnItemAddedInvoker.Insert(OnItemAddedListener);
1010  m_InventoryManager.m_OnItemRemovedInvoker.Insert(OnItemRemovedListener);
1011  }
1012 
1013  m_wProgressBarWeight = ProgressBarWidget.Cast( m_widget.FindAnyWidget( "ProgressBarWeight" ) );
1014  if( m_wProgressBarWeight )
1015  {
1016  m_wProgressBarWeight.SetMin( 0.0 );
1017  m_wProgressBarWeight.SetMax( m_StorageManager.GetMaxLoad() );
1018  m_wProgressBarWeight.SetCurrent( m_InventoryManager.GetTotalWeightOfAllStorages() );
1019  };
1020 
1021  m_wProgressBarWeightItem = ProgressBarWidget.Cast( m_widget.FindAnyWidget( "ProgressBarWeightItem" ) );
1022  if( m_wProgressBarWeightItem )
1023  {
1024  m_wProgressBarWeightItem.SetMin( 0.0 );
1025  m_wProgressBarWeightItem.SetMax( m_StorageManager.GetMaxLoad() );
1026  m_wProgressBarWeightItem.SetCurrent( 0.0 );
1027  };
1028 
1029  Widget wNaviBar = m_widget.FindAnyWidget( "Footer" );
1030  if( wNaviBar )
1031  m_pNavigationBar = SCR_NavigationBarUI.Cast( wNaviBar.FindHandler( SCR_NavigationBarUI ) );
1032  m_pVicinity = SCR_CharacterVicinityComponent.Cast(m_Player.FindComponent(SCR_CharacterVicinityComponent));
1033  if (m_pVicinity)
1034  {
1035  m_pVicinity.OnVicinityUpdateInvoker.Insert(RefreshLootUIListener);
1036  m_iVicinityDiscoveryRadius = m_pVicinity.GetDiscoveryRadius();
1037  IEntity itemOfInterest = m_pVicinity.GetItemOfInterest();
1038  if (itemOfInterest && itemOfInterest.IsInherited(SCR_ChimeraCharacter))
1039  {
1040  SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(itemOfInterest);
1041  SCR_CharacterControllerComponent charCtrl = SCR_CharacterControllerComponent.Cast(character.GetCharacterController());
1042  if (charCtrl)
1043  charCtrl.m_OnLifeStateChanged.Insert(OnLootedCharacterLifeStateChanged);
1044  }
1045  }
1046 
1047  m_wStoragesContainer = GridLayoutWidget.Cast( m_widget.FindAnyWidget( "StorageGrid" ) );
1048  m_wTotalWeightText = TextWidget.Cast( m_widget.FindAnyWidget("TotalWeightText") );
1049  }
1050  else
1051  {
1052  return false;
1053  }
1054 
1055  }
1056  else
1057  {
1058  return false;
1059  }
1060 
1061  m_wDragDropContainer = FrameWidget.Cast( m_widget.FindAnyWidget( "DragDropContainer" ) );
1062  if ( m_wDragDropContainer )
1063  {
1064  m_pDragDropFrameSlotUI = SCR_SlotUIComponent.Cast( m_wDragDropContainer.FindHandler( SCR_SlotUIComponent ) );
1065  m_pDragDropPreviewImage = ItemPreviewWidget.Cast( m_wDragDropContainer.FindAnyWidget( "item" ) );
1066  }
1067 
1068  m_wAttachmentPointsContainer = m_widget.FindAnyWidget("AttachmentPoints");
1069 
1070  return true;
1071  }
1072 
1073  protected void OnLootedCharacterLifeStateChanged(ECharacterLifeState previousLifeState, ECharacterLifeState newLifeState)
1074  {
1075  if (newLifeState == ECharacterLifeState.ALIVE)
1076  {
1077  IEntity itemOfInterest = m_pVicinity.GetItemOfInterest();
1078  if (itemOfInterest && itemOfInterest.IsInherited(SCR_ChimeraCharacter))
1079  {
1080  SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(itemOfInterest);
1081  SCR_CharacterControllerComponent charCtrl = SCR_CharacterControllerComponent.Cast(character.GetCharacterController());
1082  if (charCtrl)
1083  charCtrl.m_OnLifeStateChanged.Remove(OnLootedCharacterLifeStateChanged);
1084  }
1085 
1086  m_pVicinity.SetItemOfInterest(null);
1087  RefreshLootUIListener();
1088  }
1089  }
1090 
1091  //------------------------------------------------------------------------------------------------
1092  void OnAction( SCR_InputButtonComponent comp, string action, SCR_InventoryStorageBaseUI pParentStorage = null, int traverseStorageIndex = -1 )
1093  {
1094  switch (action)
1095  {
1096  case "Inventory":
1097  {
1098  Action_CloseInventory();
1099  }
1100  break;
1101 
1102  case "Inventory_UnassignFromQuickSlot":
1103  {
1104  Action_QuickSlotUnassign();
1105  } break;
1106 
1107  case "Inventory_EnterStorage":
1108  {
1109  SetStorageSwitchMode(false);
1110  } break;
1111 
1112  case "Inventory_AssignToQuickSlot":
1113  {
1114  Action_QuickSlotAssign();
1115  } break;
1116 
1117  case "Inventory_Drop":
1118  {
1119  Action_MoveBetween();
1120  } break;
1121 
1122  case "Inventory_Equip":
1123  {
1124  Action_EquipItem();
1125  } break;
1126 
1127  case "Inventory_Select":
1128  {
1129  if (m_pAttachmentStorageUI && m_AttachmentSpinBox.IsFocused())
1130  {
1131  FocusOnSlotInStorage(m_pAttachmentStorageUI);
1132  return;
1133  }
1134 
1135  if (m_bStorageSwitchMode && m_bIsUsingGamepad)
1136  {
1137  SetStorageSwitchMode(false);
1138  return;
1139  }
1140  if (m_pFocusedSlotUI && !m_pFocusedSlotUI.IsSlotSelected())
1141  Action_SelectItem();
1142  else
1143  Action_DeselectItem();
1144  } break;
1145 
1146  case "Inventory_Deselect":
1147  {
1148  Action_DeselectItem();
1149  } break;
1150 
1151  case "Inventory_OpenStorage":
1152  {
1153  Action_UnfoldItem();
1154  } break;
1155 
1156  case "Inventory_OpenNewStorage":
1157  {
1158  Action_OpenContainer();
1159  } break;
1160 
1161  case "Inventory_StepBack":
1162  {
1163  Action_StepBack( pParentStorage, traverseStorageIndex );
1164  } break;
1165 
1166  case "Inventory_Inspect":
1167  {
1168  Action_Inspect();
1169  } break;
1170 
1171  case "Inventory_Use":
1172  {
1173  Action_UseItem();
1174  } break;
1175 
1176  case "Inventory_Move":
1177  {
1178  if (m_bStorageSwitchMode)
1179  {
1180  Action_Drop();
1181  return;
1182  }
1183  else if (m_pSelectedSlotUI)
1184  {
1185  Action_Drop();
1186  return;
1187  }
1188 
1189  Action_MoveItemToStorage();
1190  } break;
1191 
1192  case "Inventory_Swap":
1193  {
1194  if (m_bStorageSwitchMode)
1195  {
1196  ToggleStorageSwitchMode();
1197  FocusOnSlotInStorage(m_pActiveStorageUI);
1198  return;
1199  }
1200  Action_SwapItems(m_pSelectedSlotUI, m_pFocusedSlotUI);
1201  } break;
1202 
1203  case "Inventory_DetachItem":
1204  {
1205  SCR_InventoryHitZonePointContainerUI hzContainer = SCR_InventoryHitZonePointContainerUI.Cast(m_AttachmentSpinBox.GetCurrentItemData());
1206  if (hzContainer)
1207  hzContainer.RemoveTourniquetFromSlot();
1208  } break;
1209 
1210  case "InventoryEscape":
1211  {
1212  Action_TryCloseInventory();
1213  } break;
1214  }
1215  }
1216 
1217  //------------------------------------------------------------------------------------------------
1218  // ! Default view of the character's inventory
1219  void ShowDefault()
1220  {
1221  ShowEquipedWeaponStorage();
1222  if ( !m_pSelectedSlotStorageUI )
1223  {
1224  SimpleFSM( EMenuAction.ACTION_BACK );
1225  return;
1226  }
1227  m_pSelectedSlotStorageUI.SetSelected( false );
1228 
1229  if ( m_pSelectedSlotUI )
1230  {
1231  m_pSelectedSlotUI.SetSelected( false );
1232  m_pSelectedSlotUI = null;
1233  }
1234  if ( m_pSelectedSlotStorageUI )
1235  m_pSelectedSlotStorageUI = null;
1236 
1237  FilterOutStorages( false );
1238  }
1239 
1240  //------------------------------------------------------------------------------------------------
1241  protected int CloseOpenedStorage()
1242  {
1243  if ( !m_wContainer ) // what?
1244  return -1; //any storage opened
1245  return CloseStorage( m_wContainer );
1246  }
1247 
1248  //------------------------------------------------------------------------------------------------
1249  protected int CloseStorage( SCR_InventoryStorageBaseUI pStorageUI )
1250  {
1251  //if (!pStorageUI)
1252  //return -1;
1253  Widget w = pStorageUI.GetRootWidget();
1254  if ( !w )
1255  return -1;
1256 
1257  //~ Close linked storages one frame later to make sure the the current storage is closed
1258  CloseLinkedStorages(pStorageUI.GetStorage());
1259 
1260  return CloseStorage( w );
1261  }
1262 
1263  //------------------------------------------------------------------------------------------------
1264  protected int CloseStorage( notnull Widget w )
1265  {
1266  auto storageUIHandler = SCR_InventoryStorageBaseUI.Cast( w.FindHandler( SCR_InventoryStorageBaseUI ) );
1267  if ( !storageUIHandler )
1268  return -1; //some storage opened, but it does not have any handler ( wrong )
1269 
1270  int iLastShownPage = storageUIHandler.GetLastShownPage();
1271  m_pLastCurrentNavStorage = storageUIHandler.GetCurrentNavigationStorage();
1272  w.RemoveHandler( storageUIHandler ); //remove the handler from the widget
1273  w.RemoveFromHierarchy();
1274 
1275  return iLastShownPage;
1276  }
1277 
1278  //------------------------------------------------------------------------------------------------
1279  // ! Hides/Unhides ( not closes ) the storage
1280  protected void ToggleStorageContainerVisibility( notnull SCR_InventorySlotUI pSlot )
1281  {
1282  BaseInventoryStorageComponent pStorage = pSlot.GetAsStorage();
1283  if ( !pStorage )
1284  return;
1285  SCR_InventoryStorageBaseUI pStorageUI = GetStorageUIByBaseStorageComponent( pStorage );
1286  if ( !pStorageUI )
1287  return;
1288  pStorageUI.ToggleShow();
1289  }
1290 
1291  //------------------------------------------------------------------------------------------------
1292  // ! Shows the content of the 1st available storage
1293  void ShowStorage()
1294  {
1295  if( !m_StorageManager )
1296  return;
1297 
1298  array<SCR_UniversalInventoryStorageComponent> pStorages = new array<SCR_UniversalInventoryStorageComponent>();
1299  m_StorageManager.GetStorages( pStorages );
1300 
1301  if( pStorages.Count() == 0 )
1302  return;
1303  SCR_UniversalInventoryStorageComponent pStorage = pStorages.Get( 0 );
1304  ShowStorage( pStorage );
1305  }
1306 
1307  //------------------------------------------------------------------------------------------------
1309  void ShowStorage( BaseInventoryStorageComponent storage, LoadoutAreaType area = null )
1310  {
1311  if ( !m_wStoragesContainer )
1312  return;
1313  m_wContainer = GetGame().GetWorkspace().CreateWidgets( BACKPACK_STORAGE_LAYOUT, m_wStoragesContainer );
1314  int iRow = Math.Floor( m_iStorageListCounter / STORAGE_AREA_COLUMNS );
1315  int iCol = m_iStorageListCounter % STORAGE_AREA_COLUMNS;
1316  m_iStorageListCounter++;
1317 
1318  m_wStoragesContainer.SetRowFillWeight( iRow, 0 );
1319  m_wStoragesContainer.SetColumnFillWeight( iCol, 0 );
1320 
1321  GridSlot.SetColumn( m_wContainer, iCol );
1322  GridSlot.SetRow( m_wContainer, iRow );
1323  GridSlot.SetColumnSpan( m_wContainer, 1 );
1324  GridSlot.SetRowSpan( m_wContainer, 1 );
1325 
1326  if ( !m_wContainer )
1327  return;
1328  if ( storage.Type() == ClothNodeStorageComponent )
1329  {
1330  m_wContainer.AddHandler( new SCR_InventoryStorageLBSUI( storage, area, this, 0, null) );
1331  m_pStorageBaseUI = SCR_InventoryStorageBaseUI.Cast( m_wContainer.FindHandler( SCR_InventoryStorageLBSUI ) );
1332  }
1333  else if ( storage.Type() == EquipedWeaponStorageComponent )
1334  {
1335  m_wContainer.AddHandler( new SCR_InventoryStorageWeaponsUI( m_StorageManager.GetWeaponStorage(), area, this ) );
1336  m_pStorageBaseUI = SCR_InventoryStorageWeaponsUI.Cast( m_wContainer.FindHandler( SCR_InventoryStorageWeaponsUI ) );
1337  }
1338  else
1339  {
1340  m_wContainer.AddHandler( new SCR_InventoryStorageBackpackUI( storage, area, this, 0, null ) );
1341  m_pStorageBaseUI = SCR_InventoryStorageBaseUI.Cast( m_wContainer.FindHandler( SCR_InventoryStorageBaseUI ) );
1342  }
1343 
1344  m_aStorages.Insert( m_pStorageBaseUI );
1345  }
1346 
1347  //------------------------------------------------------------------------------------------------
1348  void ShowVicinity(bool compact = false) // if true, vicinity will have only 4 rows instead of 6
1349  {
1350  if (!m_pVicinity)
1351  {
1352  Print("No vicnity component on character!", LogLevel.DEBUG);
1353  return;
1354  }
1355 
1356  if ( m_wLootStorage )
1357  {
1358  m_wLootStorage.RemoveHandler( m_wLootStorage.FindHandler( SCR_InventoryStorageLootUI ) ); //remove the handler from the widget
1359  m_wLootStorage.RemoveFromHierarchy();
1360  }
1361 
1362  Widget parent = m_widget.FindAnyWidget( "StorageLootSlot" );
1363  m_wLootStorage = GetGame().GetWorkspace().CreateWidgets( BACKPACK_STORAGE_LAYOUT, parent );
1364  if ( !m_wLootStorage )
1365  return;
1366 
1367  if (compact)
1368  m_wLootStorage.AddHandler( new SCR_InventoryStorageLootUI( null, null, this, 0, null, m_Player, 4, 6 ) );
1369  else
1370  m_wLootStorage.AddHandler( new SCR_InventoryStorageLootUI( null, null, this, 0, null, m_Player ) );
1371  m_pStorageLootUI = SCR_InventoryStorageBaseUI.Cast( m_wLootStorage.FindHandler( SCR_InventoryStorageLootUI ) );
1372  }
1373 
1374  //------------------------------------------------------------------------------------------------
1375  void ShowAttachmentStorage(InventorySearchPredicate searchPredicate, bool closeOnly = false)
1376  {
1377  if (m_wAttachmentStorage)
1378  {
1379  m_wAttachmentStorage.RemoveHandler(m_wAttachmentStorage.FindHandler(SCR_InventoryAttachmentStorageUI));
1380  m_wAttachmentStorage.RemoveFromHierarchy();
1381  if (closeOnly)
1382  return;
1383  }
1384 
1385  Widget parent = m_widget.FindAnyWidget("AttachmentStorage");
1386  if (!parent)
1387  return;
1388 
1389  m_wAttachmentStorage = GetGame().GetWorkspace().CreateWidgets(BACKPACK_STORAGE_LAYOUT, parent);
1390  if (!m_wAttachmentStorage)
1391  return;
1392 
1393  SCR_InventoryAttachmentStorageUI handler = new SCR_InventoryAttachmentStorageUI(m_pStorageListUI.GetStorage(), null, this, 0, null, searchPredicate);
1394  m_wAttachmentStorage.AddHandler(handler);
1395  m_pAttachmentStorageUI = handler;
1396  }
1397 
1398  //------------------------------------------------------------------------------------------------
1399  void CloseAttachmentStorage()
1400  {
1401  if (m_wAttachmentStorage)
1402  {
1403  m_wAttachmentStorage.RemoveHandler(m_wAttachmentStorage.FindHandler(SCR_InventoryAttachmentStorageUI));
1404  m_wAttachmentStorage.RemoveFromHierarchy();
1405  }
1406  }
1407 
1408  //------------------------------------------------------------------------------------------------
1409  SCR_InventoryAttachmentStorageUI GetAttachmentStorageUI()
1410  {
1411  return m_pAttachmentStorageUI;
1412  }
1413 
1414  //------------------------------------------------------------------------------------------------
1415  void RemoveAttachmentStorage(SCR_InventoryAttachmentStorageUI attStorage)
1416  {
1417  CloseStorage(attStorage);
1418  }
1419 
1420  //------------------------------------------------------------------------------------------------
1421  // shows opened storage in a new container
1422  void OpenStorageAsContainer(BaseInventoryStorageComponent storage, bool showVicinity = true, bool hideCloseButton = false)
1423  {
1424  foreach (SCR_InventoryOpenedStorageUI openedStorage : m_aOpenedStoragesUI)
1425  {
1426  if (openedStorage.GetStorage() == storage)
1427  {
1428  // if storage is already open, close it instead
1429  RemoveOpenStorage(openedStorage);
1430  return;
1431  }
1432  }
1433 
1434  SCR_InventoryOpenedStorageUI handler = CreateOpenedStorageUI(storage);
1435 
1436  Widget parent = m_widget.FindAnyWidget("OpenedStorages");
1437  Widget newStorage;
1438 
1439  //if (SCR_InventoryStorageContainerUI.Cast(handler) || SCR_InventoryOpenedStorageArsenalUI.Cast(handler))
1440  if (SCR_InventoryOpenedStorageArsenalUI.Cast(handler))
1441  newStorage = GetGame().GetWorkspace().CreateWidgets(ARSENAL_STORAGE_LAYOUT, parent);
1442  else
1443  newStorage = GetGame().GetWorkspace().CreateWidgets(BACKPACK_STORAGE_LAYOUT, parent);
1444 
1445  newStorage.AddHandler(handler);
1446 
1447  ButtonWidget closeBtn = handler.ActivateCloseStorageButton();
1448 
1449  ScrollLayoutWidget scroll = ScrollLayoutWidget.Cast(m_widget.FindAnyWidget("LeftAreaScroll"));
1450 
1451  if (scroll)
1452  scroll.SetSliderPos(0, 0);
1453 
1454  m_aOpenedStoragesUI.Insert(handler);
1455 
1456  if (showVicinity)
1457  ShowVicinity(true);
1458 
1459  if (hideCloseButton)
1460  {
1461  Widget closeButton = newStorage.FindAnyWidget(STORAGE_LAYOUT_CLOSE_WIDGET_NAME);
1462  if (closeButton)
1463  closeButton.SetVisible(false);
1464  }
1465 
1466  OpenLinkedStorages(storage, showVicinity, true);
1467  FocusOnSlotInStorage(handler);
1468  }
1469 
1470  //------------------------------------------------------------------------------------------------
1471  void RemoveOpenStorage(SCR_InventoryOpenedStorageUI openedStorage)
1472  {
1473  CloseStorage(openedStorage);
1474  m_aOpenedStoragesUI.RemoveItem(openedStorage);
1475  if (m_aOpenedStoragesUI.IsEmpty())
1476  {
1477  ShowVicinity();
1478  }
1479  }
1480 
1481  //------------------------------------------------------------------------------------------------
1482  void RefreshLootUIListener()
1483  {
1484  if (!m_pVicinity || !m_pStorageLootUI)
1485  return;
1486 
1487  m_pStorageLootUI.Refresh();
1488  if (m_aOpenedStoragesUI.IsEmpty())
1489  return;
1490 
1491  vector playerOrigin = m_Player.GetOrigin();
1492  vector entityBoundsMaxs, entityBoundsMins;
1494  for (int index = m_aOpenedStoragesUI.Count() - 1; index >= 0; index--)
1495  {
1496  storageUI = m_aOpenedStoragesUI.Get(index);
1497  if (!storageUI)
1498  continue;
1499 
1500  //~ 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
1501  Vehicle vehicleRoot = Vehicle.Cast(storageUI.GetStorage().GetOwner().GetRootParent());
1502  if (vehicleRoot)
1503  vehicleRoot.GetWorldBounds(entityBoundsMins, entityBoundsMaxs);
1504  //~ Root parent is not a vehicle so take bounds of self
1505  else
1506  storageUI.GetStorage().GetOwner().GetWorldBounds(entityBoundsMins, entityBoundsMaxs);
1507 
1508  //~ No bounds on storage and rootparent is not avehicle than try to get bounds of parent instead
1509  if (entityBoundsMins - entityBoundsMaxs == vector.Zero && !vehicleRoot)
1510  {
1511  //~ Get the bounds from parents instead if root is not a vehicle
1512  if (storageUI.GetStorage().GetOwner().GetParent())
1513  storageUI.GetStorage().GetOwner().GetParent().GetWorldBounds(entityBoundsMins, entityBoundsMaxs);
1514 
1515  //~ Check if bounds were found
1516  if (entityBoundsMins - entityBoundsMaxs == vector.Zero)
1517  {
1518  Print("SCR_InventoryMenuUI: RefreshLootUIListener storage owner has no bounds and it could not find a valid parent with bounds!", LogLevel.ERROR);
1519  RemoveOpenStorage(storageUI);
1520  return;
1521  }
1522  }
1523 
1524  if (!Math3D.IntersectionSphereAABB(playerOrigin, m_iVicinityDiscoveryRadius, entityBoundsMins, entityBoundsMaxs))
1525  RemoveOpenStorage(storageUI);
1526  }
1527  }
1528 
1529  //------------------------------------------------------------------------------------------------
1530  void ShowStoragesList()
1531  {
1532  if( m_wStorageList )
1533  {
1534  m_wStorageList.RemoveHandler( m_wStorageList.FindHandler( SCR_InventoryStoragesListUI ) ); //remove the handler from the widget
1535  m_wStorageList.RemoveFromHierarchy();
1536  }
1537 
1538  Widget parent = m_widget.FindAnyWidget( "StoragesListSlot" );
1539  m_wStorageList = GetGame().GetWorkspace().CreateWidgets( STORAGES_LIST_LAYOUT, parent );
1540 
1541  if( !m_wStorageList )
1542  return;
1543 
1544  m_wStorageList.AddHandler( new SCR_InventoryStoragesListUI( m_StorageManager, null, this ) );
1545  m_pStorageListUI = SCR_InventoryStoragesListUI.Cast( m_wStorageList.FindHandler( SCR_InventoryStoragesListUI ) );
1546  }
1547 
1548  //------------------------------------------------------------------------------------------------
1549  void ShowAllStoragesInList()
1550  {
1551  m_iStorageListCounter = 0;
1552  array<SCR_InventorySlotUI> aSlotsUI = {};
1553  m_pStorageListUI.GetSlots( aSlotsUI );
1554  if ( !m_aStorages.IsEmpty() )
1555  {
1556  foreach ( SCR_InventoryStorageBaseUI pStorage : m_aStorages )
1557  {
1558  if ( !pStorage )
1559  continue;
1560  CloseStorage( pStorage );
1561  }
1562  }
1563  SortSlotsByLoadoutArea( aSlotsUI );
1564  m_aStorages.Resize( aSlotsUI.Count() );
1565 
1566  foreach ( SCR_InventorySlotUI pSlot : aSlotsUI )
1567  {
1568  if ( !pSlot )
1569  continue;
1570 
1571  BaseInventoryStorageComponent pStorage = pSlot.GetAsStorage();
1572  if ( pStorage )
1573  {
1574  ShowStorage( pStorage, pSlot.GetLoadoutArea() );
1575 
1576  /* Enable to have the expand / collapse feature
1577  if ( m_StorageManager.GetIsStorageShown( pStorage ) )
1578  m_pStorageBaseUI.Show( true );
1579  else
1580  m_pStorageBaseUI.Show( false );
1581  */
1582  }
1583  }
1584  }
1585 
1586  //------------------------------------------------------------------------------------------------
1587  protected SCR_InventoryStorageBaseUI GetStorageUIFromVicinity(BaseInventoryStorageComponent storage)
1588  {
1589  if (!storage)
1590  return null;
1591  array<SCR_InventorySlotUI> slots = {};
1592  m_pStorageLootUI.GetSlots(slots);
1593  foreach (SCR_InventorySlotUI slot : slots)
1594  {
1595  if (slot && slot.GetStorageComponent() == storage)
1596  return slot.GetStorageUI();
1597  }
1598 
1599  return null;
1600  }
1601 
1602  //------------------------------------------------------------------------------------------------
1603  protected SCR_InventoryOpenedStorageUI CreateOpenedStorageUI(BaseInventoryStorageComponent storage)
1604  {
1605  IEntity storageOwner = storage.GetOwner();
1606 
1607  SCR_ArsenalInventoryStorageManagerComponent arsenalManagerComponent
1608  = SCR_ArsenalInventoryStorageManagerComponent.Cast(storageOwner.FindComponent(SCR_ArsenalInventoryStorageManagerComponent));
1609 
1610  if (arsenalManagerComponent)
1611  return new SCR_InventoryOpenedStorageArsenalUI(storage, null, this, 0, {storage});
1612 
1613  SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.FindResourceComponent(storageOwner);
1614 
1615  if (resourceComponent)
1616  {
1617  //% Remove the hard coded type for the resources type.
1618  SCR_ResourceContainer container = resourceComponent.GetContainer(EResourceType.SUPPLIES);
1619 
1620  if (container)
1621  return new SCR_InventoryStorageContainerUI(storage, null, this, 0, {storage});
1622  }
1623 
1624  return new SCR_InventoryOpenedStorageUI(storage, null, this, 0, {storage});
1625  }
1626 
1627  //------------------------------------------------------------------------------------------------
1628  SCR_InventoryStorageBaseUI GetStorageUIByBaseStorageComponent( BaseInventoryStorageComponent pStorage )
1629  {
1630  if (!pStorage)
1631  return m_pStorageLootUI;
1632 
1633  if (pStorage == m_pWeaponStorageComp)
1634  return m_pWeaponStorage;
1635 
1636  BaseInventoryStorageComponent parentStorage;
1637 
1638  if (pStorage && pStorage.GetParentSlot())
1639  parentStorage = pStorage.GetParentSlot().GetStorage();
1640 
1641  if (ClothNodeStorageComponent.Cast(parentStorage))
1642  {
1643  foreach (SCR_InventoryStorageBaseUI pStorageUI : m_aStorages)
1644  {
1645  if (pStorageUI && pStorageUI.GetStorage() == parentStorage)
1646  return pStorageUI;
1647  }
1648  }
1649 
1650  foreach (SCR_InventoryStorageBaseUI pStorageUI : m_aStorages)
1651  {
1652  if (pStorageUI && pStorageUI.GetStorage() == pStorage)
1653  return pStorageUI;
1654  }
1655 
1656  foreach (SCR_InventoryStorageBaseUI pStorageUI : m_aOpenedStoragesUI)
1657  {
1658  if (pStorageUI && pStorageUI.GetStorage() == pStorage)
1659  return pStorageUI;
1660  }
1661 
1662  return null;
1663  }
1664 
1665  //------------------------------------------------------------------------------------------------
1666  protected void SortSlotsByLoadoutArea( out array<SCR_InventorySlotUI> aSlots )
1667  {
1668  array<SCR_InventorySlotUI> tmpSlots = {};
1669  tmpSlots.Copy( aSlots );
1670  aSlots.Clear();
1671 
1672  foreach ( SCR_InventorySlotUI pSlotUI : tmpSlots )
1673  {
1674  if ( !SCR_InventorySlotStorageUI.Cast( pSlotUI ) || pSlotUI.GetLoadoutArea() == null )
1675  continue;
1676  aSlots.Insert(pSlotUI);
1677  }
1678  }
1679 
1680  //------------------------------------------------------------------------------------------------
1681  protected void ShowGadgetStorage()
1682  {
1683  if( m_wGadgetStorage && m_wContainer )
1684  {
1685  m_wContainer.RemoveHandler( m_wGadgetStorage.FindHandler( SCR_InventoryStorageGadgetsUI ) ); //remove the handler from the widget
1686  m_wGadgetStorage.RemoveFromHierarchy();
1687  }
1688 
1689  Widget parent = m_widget.FindAnyWidget( "GadgetsGridSlot" );
1690  m_wGadgetStorage = GetGame().GetWorkspace().CreateWidgets( GADGETS_STORAGE_LAYOUT, parent );
1691 
1692  if( !m_wGadgetStorage )
1693  return;
1694 
1695  //m_wGadgetStorage.AddHandler( new SCR_InventoryStorageGadgetsUI( m_StorageManager.GetGadgetsStorage(), ELoadoutArea.ELA_None, this ) );
1696  m_pGadgetsBaseUI = SCR_InventoryStorageGadgetsUI.Cast( m_wGadgetStorage.FindHandler( SCR_InventoryStorageGadgetsUI ) );
1697  }
1698 
1699  //------------------------------------------------------------------------------------------------
1700  protected void ShowEquipedWeaponStorage()
1701  {
1702 
1703  if ( m_wWeaponSlots )
1704  {
1705  m_wWeaponSlots.RemoveHandler( m_wWeaponSlots.FindHandler( SCR_InventoryWeaponSlotsUI ) ); //remove the handler from the widget
1706  m_wWeaponSlots.RemoveFromHierarchy();
1707  }
1708 
1709  Widget parent = m_widget.FindAnyWidget( "WeaponSlots" );
1710  m_wWeaponSlots = GetGame().GetWorkspace().CreateWidgets( WEAPON_STORAGE_LAYOUT, parent );
1711 
1712  if ( !m_wWeaponSlots )
1713  return;
1714 
1715  m_wWeaponSlots.AddHandler( new SCR_InventoryWeaponSlotsUI( m_StorageManager.GetWeaponStorage(), null, this ) );
1716  m_pStorageBaseUI = SCR_InventoryWeaponSlotsUI.Cast( m_wWeaponSlots.FindHandler( SCR_InventoryWeaponSlotsUI ) );
1717  m_pWeaponStorage = SCR_InventoryWeaponSlotsUI.Cast( m_pStorageBaseUI );
1718  m_pWeaponStorageComp = EquipedWeaponStorageComponent.Cast( m_pWeaponStorage.GetStorage() );
1719  }
1720 
1721  //------------------------------------------------------------------------------------------------
1722  void ShowItemInfo( string sName = "", string sDescr = "", float sWeight = 0.0, SCR_InventoryUIInfo uiInfo = null )
1723  {
1724  if ( !m_pItemInfo )
1725  {
1726  //Widget parent = m_widget.FindAnyWidget( "SoldierInfo" );
1727  Widget infoWidget = GetGame().GetWorkspace().CreateWidgets(ITEM_INFO, m_widget);
1728  if ( !infoWidget )
1729  return;
1730 
1731  infoWidget.AddHandler( new SCR_InventoryItemInfoUI() );
1732  m_pItemInfo = SCR_InventoryItemInfoUI.Cast( infoWidget.FindHandler( SCR_InventoryItemInfoUI ) );
1733  }
1734 
1735  if( !m_pItemInfo )
1736  return;
1737 
1738  Widget w = WidgetManager.GetWidgetUnderCursor();
1739  if (!w)
1740  {
1741  w = m_pFocusedSlotUI.GetButtonWidget();
1742  }
1743 
1744  m_pItemInfo.Show( 0.6, w, m_bIsUsingGamepad );
1745  m_pItemInfo.SetName( sName );
1746  m_pItemInfo.SetDescription( sDescr );
1747 
1748  m_pItemInfo.SetWeight( sWeight );
1749  if (uiInfo && uiInfo.IsIconVisible())
1750  m_pItemInfo.SetIcon(uiInfo.GetIconPath(), uiInfo.GetIconColor());
1751  else
1752  m_pItemInfo.ShowIcon(false);
1753 
1754  array<SCR_InventoryItemHintUIInfo> hintsInfo = {};
1755 
1756  //~ Add hints
1757  if (uiInfo)
1758  uiInfo.GetItemHintArray(hintsInfo);
1759 
1760  //~ Arsenal supply cost hint if item is in an arsenal storage
1761  if (m_SupplyCostUIInfo)
1762  {
1763  SCR_ArsenalInventorySlotUI arsenalSlot = SCR_ArsenalInventorySlotUI.Cast(m_pFocusedSlotUI);
1764  if (arsenalSlot)
1765  {
1766  m_SupplyCostUIInfo.SetSupplyCost(arsenalSlot.GetItemSupplyCost());
1767  hintsInfo.InsertAt(m_SupplyCostUIInfo, 0);
1768  }
1769  }
1770 
1771  //~ If has hints show them
1772  if (!hintsInfo.IsEmpty())
1773  m_pItemInfo.SetItemHints(m_pFocusedSlotUI.GetInventoryItemComponent(), hintsInfo, m_pFocusedSlotUI);
1774 
1775  int targetPosX, targetPosY;
1776 
1777  float x, y;
1778  w.GetScreenPos(x, y);
1779 
1780  float width, height;
1781  w.GetScreenSize(width, height);
1782 
1783  // Needed to update the widget to the correct size before requesting its size here.
1784  m_pItemInfo.GetInfoWidget().Update();
1785 
1786  float screenSizeX, screenSizeY;
1787  GetGame().GetWorkspace().GetScreenSize(screenSizeX, screenSizeY);
1788 
1789  float infoWidth, infoHeight;
1790  m_pItemInfo.GetInfoWidget().GetScreenSize(infoWidth, infoHeight);
1791 
1792  targetPosX = x;
1793  targetPosY = y + height;
1794 
1795  float offsetX = (screenSizeX - infoWidth - targetPosX);
1796  if (offsetX < 0)
1797  targetPosX += offsetX;
1798  float offsetY = (screenSizeY - infoHeight - targetPosY);
1799  if (offsetY < 0)
1800  targetPosY += offsetY;
1801 
1802  m_pItemInfo.Move(
1803  GetGame().GetWorkspace().DPIUnscale(targetPosX),
1804  GetGame().GetWorkspace().DPIUnscale(targetPosY));
1805  }
1806 
1807  //------------------------------------------------------------------------------------------------
1808  void ShowDamageInfo(string sName, SCR_InventoryDamageUIInfo damageInfo)
1809  {
1810  Widget w = WidgetManager.GetWidgetUnderCursor();
1811  if (!w && m_AttachmentSpinBox)
1812  {
1813  SCR_InventoryHitZonePointContainerUI currentHZContainer = SCR_InventoryHitZonePointContainerUI.Cast(m_AttachmentSpinBox.GetCurrentItemData());
1814  if (currentHZContainer)
1815  w = currentHZContainer.GetRootWidget().FindAnyWidget("HitZoneButton");
1816  }
1817 
1818  if (!w)
1819  return;
1820 
1821  if (!m_pDamageInfo)
1822  {
1823  Widget infoWidget = GetGame().GetWorkspace().CreateWidgets(DAMAGE_INFO, m_widget);
1824  if ( !infoWidget )
1825  return;
1826 
1827  infoWidget.AddHandler( new SCR_InventoryDamageInfoUI() );
1828  m_pDamageInfo = SCR_InventoryDamageInfoUI.Cast( infoWidget.FindHandler( SCR_InventoryDamageInfoUI ) );
1829  }
1830 
1831  if (!m_pDamageInfo)
1832  return;
1833 
1834  m_pDamageInfo.Show( 0.6, w, m_bIsUsingGamepad );
1835  m_pDamageInfo.SetName( sName );
1836 
1837  if (damageInfo)
1838  {
1839  m_pDamageInfo.SetDamageStateVisible(damageInfo.m_bDamageIconVisible, damageInfo.m_bDamageRegenerating, damageInfo.m_sDamageIntensity, damageInfo.m_sDamageText);
1840  m_pDamageInfo.SetBleedingStateVisible(damageInfo.m_bBleedingIconVisible, damageInfo.m_sBleedingText);
1841  m_pDamageInfo.SetTourniquetStateVisible(damageInfo.m_bTourniquetIconVisible);
1842  m_pDamageInfo.SetSalineBagStateVisible(damageInfo.m_bSalineBagIconVisible);
1843  m_pDamageInfo.SetFractureStateVisible(damageInfo.m_bFractureIconVisible, damageInfo.m_bFractureIcon2Visible);
1844  }
1845 
1846  int iMouseX, iMouseY;
1847 
1848  float x, y;
1849  w.GetScreenPos(x, y);
1850 
1851  float width, height;
1852  w.GetScreenSize(width, height);
1853 
1854  float screenSizeX, screenSizeY;
1855  GetGame().GetWorkspace().GetScreenSize(screenSizeX, screenSizeY);
1856 
1857  float infoWidth, infoHeight;
1858  m_pDamageInfo.GetInfoWidget().GetScreenSize(infoWidth, infoHeight);
1859 
1860  iMouseX = x;
1861  iMouseY = y + height;
1862  if (x + infoWidth > screenSizeX)
1863  iMouseX = screenSizeX - infoWidth - width * 0.5; // offset info if it would go outside of the screen
1864 
1865  m_pDamageInfo.Move( GetGame().GetWorkspace().DPIUnscale( iMouseX ), GetGame().GetWorkspace().DPIUnscale( iMouseY ) );
1866  }
1867 
1868  //------------------------------------------------------------------------------------------------
1869  protected bool GetDamageInfo()
1870  {
1871  Widget infoWidget = GetGame().GetWorkspace().CreateWidgets(DAMAGE_INFO, m_widget);
1872  if ( !infoWidget )
1873  return false;
1874 
1875  infoWidget.AddHandler( new SCR_InventoryDamageInfoUI() );
1876  m_pDamageInfo = SCR_InventoryDamageInfoUI.Cast( infoWidget.FindHandler( SCR_InventoryDamageInfoUI ) );
1877 
1878  return m_pDamageInfo;
1879  }
1880 
1881  void DestroyDamageInfo()
1882  {
1883  if (m_pItemInfo)
1884  m_pItemInfo.Destroy();
1885  }
1886 
1887  //------------------------------------------------------------------------------------------------
1888  void HideItemInfo()
1889  {
1890  if ( !m_pItemInfo )
1891  return;
1892  m_pItemInfo.Hide();
1893  }
1894 
1895  //------------------------------------------------------------------------------------------------
1896  void HideDamageInfo()
1897  {
1898  if ( !m_pDamageInfo )
1899  return;
1900  m_pDamageInfo.Hide();
1901  }
1902 
1903  //------------------------------------------------------------------------------------------------
1904  void SetSlotFocused( SCR_InventorySlotUI pFocusedSlot, SCR_InventoryStorageBaseUI pFromStorageUI, bool bFocused )
1905  {
1906  if( bFocused )
1907  {
1908  InputManager pInputManager = GetGame().GetInputManager();
1909  if ( !( pInputManager && pInputManager.IsUsingMouseAndKeyboard() ) )
1910  {
1911  if ( m_pActiveStorageUI != pFromStorageUI )
1912  {
1913  if ( m_pActiveStorageUI )
1914  {
1915  SCR_InventorySlotUI pLastFocusedSlot = pFromStorageUI.GetLastFocusedSlot();
1916  pFromStorageUI.SetSlotFocused( pLastFocusedSlot );
1917  if ( pLastFocusedSlot )
1918  {
1919  m_bLocked = true;
1920  GetGame().GetWorkspace().SetFocusedWidget( pLastFocusedSlot.GetButtonWidget(), true );
1921  m_bLocked = false;
1922  }
1923  }
1924 
1925  m_pActiveStorageUI = pFromStorageUI;
1926  }
1927  }
1928 
1929  m_pFocusedSlotUI = pFocusedSlot;
1930  SetFocusedSlotEffects();
1931  }
1932  else
1933  {
1934  if ( !m_bLocked )
1935  {
1936  if ( m_pActiveStorageUI )
1937  m_pActiveStorageUI.SetLastFocusedSlot( pFocusedSlot );
1938 
1939  HideItemInfo();
1940  m_pFocusedSlotUI = null;
1941  NavigationBarUpdate();
1942  }
1943  }
1944  }
1945 
1946  //------------------------------------------------------------------------------------------------
1947  protected void SetFocusedSlotEffects()
1948  {
1949  if( !m_pFocusedSlotUI )
1950  {
1951  if( m_wProgressBarWeightItem )
1952  m_wProgressBarWeightItem.SetCurrent( 0.0 );
1953  return;
1954  }
1955 
1956  //show info about the item
1957  InventoryItemComponent invItemComp = m_pFocusedSlotUI.GetInventoryItemComponent();
1958  if ( !invItemComp )
1959  return;
1960  auto attribs = SCR_ItemAttributeCollection.Cast( invItemComp.GetAttributes() );
1961 
1962  if ( !attribs )
1963  return;
1964  UIInfo itemInfo = attribs.GetUIInfo();
1965  if ( !itemInfo )
1966  HideItemInfo();
1967  else
1968  {
1969  SCR_InventoryUIInfo inventoryInfo = SCR_InventoryUIInfo.Cast(itemInfo);
1970 
1971  if (inventoryInfo)
1972  ShowItemInfo( inventoryInfo.GetInventoryItemName(invItemComp), inventoryInfo.GetInventoryItemDescription(invItemComp), invItemComp.GetTotalWeight(), inventoryInfo);
1973  else
1974  ShowItemInfo( itemInfo.GetName(), itemInfo.GetDescription(), invItemComp.GetTotalWeight(), null);
1975  }
1976 
1977  //show the weight on the progressbar
1978  //TODO: overlap or add on the end, depending on if the item is already in the storage or is going to be added
1979  if( m_wProgressBarWeightItem )
1980  {
1981  float weight = invItemComp.GetTotalWeight();
1982  m_wProgressBarWeightItem.SetCurrent( weight );
1983  };
1984 
1985  NavigationBarUpdate();
1986  }
1987 
1988  //------------------------------------------------------------------------------------------------
1990  protected EDropContainer IsFocusedItemInsideDropContainer()
1991  {
1992  if ( !m_pActiveHoveredStorageUI )
1993  return EDropContainer.NOCONTAINER;
1994  if ( m_pActiveHoveredStorageUI.GetFocusedSlot() == m_pFocusedSlotUI )
1995  return EDropContainer.ISINSIDE;
1996 
1997  return EDropContainer.ISNOTINSIDE;
1998  }
1999 
2000  //------------------------------------------------------------------------------------------------
2001  protected bool CanSwapItems(SCR_InventorySlotUI slot1, SCR_InventorySlotUI slot2)
2002  {
2003  if (!slot1 || !slot2)
2004  return false;
2005 
2006  return m_InventoryManager.CanSwapItemStorages(
2007  slot1.GetInventoryItemComponent().GetOwner(),
2008  slot2.GetInventoryItemComponent().GetOwner()
2009  );
2010  }
2011 
2012  //------------------------------------------------------------------------------------------------
2013  protected bool CanMoveItem(SCR_InventorySlotUI slot1, SCR_InventorySlotUI slot2)
2014  {
2015  if (!slot1 || !slot2)
2016  return false;
2017 
2018  return m_InventoryManager.CanMoveItemToStorage(
2019  slot1.GetInventoryItemComponent().GetOwner(),
2020  slot2.GetStorageComponent()
2021  );
2022  }
2023 
2024  //------------------------------------------------------------------------------------------------
2025  protected bool CanMoveItem(SCR_InventorySlotUI slot1, SCR_InventoryStorageBaseUI slot2)
2026  {
2027  if (!slot1 || !slot2)
2028  return false;
2029 
2030  return m_InventoryManager.CanMoveItemToStorage(
2031  slot1.GetInventoryItemComponent().GetOwner(),
2032  slot2.GetStorage()
2033  );
2034  }
2035 
2036  //------------------------------------------------------------------------------------------------
2037  void NavigationBarUpdate()
2038  {
2039  if (!m_pNavigationBar)
2040  return;
2041 
2042  if (m_bIsUsingGamepad)
2043  {
2044  NavigationBarUpdateGamepad();
2045  return;
2046  }
2047 
2048  m_pNavigationBar.SetAllButtonEnabled( false );
2049  m_pNavigationBar.SetButtonEnabled( "ButtonBack", true );
2050 
2051  SCR_InventoryHitZoneUI hzSlot = SCR_InventoryHitZoneUI.Cast(m_pActiveHoveredStorageUI);
2052  m_pNavigationBar.SetButtonEnabled("ButtonRemoveTourniquet", (hzSlot && hzSlot.IsTourniquetted()));
2053 
2054  if ( !m_pFocusedSlotUI )
2055  return;
2056 
2057  InventoryItemComponent itemComp = m_pFocusedSlotUI.GetInventoryItemComponent();
2058  if (itemComp && itemComp.GetOwner()
2059  && m_pActiveHoveredStorageUI != m_pStorageListUI
2060  && m_pActiveHoveredStorageUI != m_pStorageLootUI)
2061  {
2062  bool canUse = m_StorageManager.CanUseItem_Inventory(itemComp.GetOwner());
2063  bool canEquip = m_StorageManager.CanEquipItem_Inventory(itemComp.GetOwner());
2064 
2065  m_pNavigationBar.SetButtonEnabled("ButtonUse", canUse);
2066  m_pNavigationBar.SetButtonEnabled("ButtonEquip", canEquip);
2067  }
2068 
2069  if ( m_pFocusedSlotUI.GetStorageUI() == m_pQuickSlotStorage )
2070  {
2071  if (m_pFocusedSlotUI.GetInventoryItemComponent())
2072  m_pNavigationBar.SetButtonEnabled("ButtonQuickSlotUnassign", true);
2073  return;
2074  }
2075 
2076  bool arsenalItem = IsStorageArsenal(m_pFocusedSlotUI.GetStorageUI().GetCurrentNavigationStorage());
2077  if (itemComp && itemComp.GetOwner() && !arsenalItem)
2078  m_pNavigationBar.SetButtonEnabled("ButtonInspect", (itemComp.GetOwner().FindComponent(SCR_WeaponAttachmentsStorageComponent) != null));
2079 
2080  m_pNavigationBar.SetButtonEnabled( "ButtonSelect", true );
2081  m_pNavigationBar.SetButtonEnabled( "ButtonDrop", m_pFocusedSlotUI.IsDraggable() );
2082 
2083  bool flag = m_pFocusedSlotUI.GetStorageUI() == m_pStorageLootUI;
2084  bool isArsenal = IsStorageArsenal(m_pStorageLootUI.GetCurrentNavigationStorage());
2085 
2086  if (m_aOpenedStoragesUI.Contains(SCR_InventoryOpenedStorageUI.Cast(m_pFocusedSlotUI.GetStorageUI())))
2087  {
2088  isArsenal = false;
2089  flag = false;
2090  }
2091 
2092  if (isArsenal)
2093  {
2094  m_pNavigationBar.SetButtonEnabled("ButtonBuy", flag);
2095  m_pNavigationBar.SetButtonEnabled("ButtonSell", !flag);
2096  m_pNavigationBar.SetButtonEnabled("ButtonPickup", false);
2097  m_pNavigationBar.SetButtonEnabled("ButtonDrop", false);
2098  }
2099  else
2100  {
2101  m_pNavigationBar.SetButtonEnabled("ButtonBuy", false);
2102  m_pNavigationBar.SetButtonEnabled("ButtonSell", false);
2103  m_pNavigationBar.SetButtonEnabled("ButtonPickup", flag);
2104  m_pNavigationBar.SetButtonEnabled("ButtonDrop", !flag);
2105  }
2106 
2107  m_pNavigationBar.SetButtonEnabled( "ButtonStepBack", true );
2108 
2109  HandleSlottedItemFunction();
2110  }
2111 
2112  //------------------------------------------------------------------------------------------------
2113  void HandleSlottedItemFunction()
2114  {
2115  string sAction = "#AR-Inventory_Select";
2116  bool arsenalItem = IsStorageArsenal(m_pFocusedSlotUI.GetStorageUI().GetCurrentNavigationStorage()); // hotfix for disabling opening open action in arsenal storages
2117 
2118  switch ( m_pFocusedSlotUI.GetSlotedItemFunction() )
2119  {
2120  case ESlotFunction.TYPE_GADGET:
2121  // m_pNavigationBar.SetButtonEnabled( "ButtonEquip", true );
2122  break;
2123  case ESlotFunction.TYPE_WEAPON:
2124  //m_pNavigationBar.SetButtonEnabled( "ButtonEquip", true );
2125 
2126  InventoryItemComponent itemComp = m_pFocusedSlotUI.GetInventoryItemComponent();
2127 
2128  if (!itemComp)
2129  return;
2130 
2131  IEntity item = itemComp.GetOwner();
2132 
2133  if (item)
2134  {
2135  WeaponComponent weaponComp = WeaponComponent.Cast(item.FindComponent(WeaponComponent));
2136 
2137  if (weaponComp &&
2138  weaponComp.GetWeaponType() != EWeaponType.WT_FRAGGRENADE &&
2139  weaponComp.GetWeaponType() != EWeaponType.WT_SMOKEGRENADE &&
2140  weaponComp.Type() != SCR_MineWeaponComponent)
2141  {
2142  m_pNavigationBar.SetButtonEnabled( "ButtonOpenStorage", !arsenalItem );
2143  m_pNavigationBar.SetButtonEnabled( "ButtonOpenAsContainer", !arsenalItem );
2144  }
2145  }
2146 
2147  break;
2148  case ESlotFunction.TYPE_MAGAZINE:
2149  // TODO: show the Reload action
2150  //m_pNavigationBar.SetButtonEnabled( "ButtonUse", true );
2151  break;
2152  case ESlotFunction.TYPE_CONSUMABLE:
2153  // TODO: show the Consume action
2154  m_pNavigationBar.SetButtonEnabled( "ButtonUse", true );
2155 
2156  break;
2157  case ESlotFunction.TYPE_STORAGE:
2158  if( m_EStateMenuItem == EStateMenuItem.STATE_MOVING_ITEM_STARTED && m_pFocusedSlotUI != m_pSelectedSlotUI )
2159  {
2160  sAction = "#AR-Inventory_Move";
2161  //m_pNavigationBar.SetButtonEnabled( "ButtonSelect", false );
2162  //m_pNavigationBar.SetButtonEnabled( "ButtonMove", true );
2163  }
2164  // Enable in case the storage is not "togglable" - can be only shown and only opening another storage will close it
2165  /*else if ( m_EStateMenuStorage == EStateMenuStorage.STATE_OPENED && m_pFocusedSlotUI == m_pSelectedSlotUI && m_pFocusedSlotUI.Type() != SCR_InventorySlotStorageEmbeddedUI)
2166  {
2167  m_pNavigationBar.SetButtonEnabled( "ButtonSelect", false );
2168  }*/
2169  else if ( m_pFocusedSlotUI.Type() == SCR_InventorySlotStorageEmbeddedUI || m_pFocusedSlotUI.Type() == SCR_SupplyInventorySlotUI)
2170  {
2171  m_pNavigationBar.SetButtonEnabled( "ButtonOpenStorage", !arsenalItem );
2172  m_pNavigationBar.SetButtonEnabled( "ButtonOpenAsContainer", !arsenalItem );
2173  }
2174 
2175  break;
2176 
2177  case ESlotFunction.TYPE_HEALTH:
2178  // TODO: show the Heal action
2179  m_pNavigationBar.SetButtonEnabled( "ButtonUse", true );
2180 
2181  break;
2182  }
2183 
2184  HandleSelectButtonState( sAction );
2185  }
2186 
2187  //------------------------------------------------------------------------------------------------
2188  protected void CreateItemSplitDialog(int maxVal, IEntity entityTo, IEntity entityFrom)
2189  {
2190  SCR_ItemSplitDialog dialog = SCR_ItemSplitDialog.Create(maxVal, entityTo, entityFrom);
2191 
2192  dialog.m_OnConfirm.Insert(OnItemSplitDialogConfirm);
2193  }
2194 
2195  //------------------------------------------------------------------------------------------------
2196  protected void OnItemSplitDialogConfirm(SCR_ItemSplitDialog dialog)
2197  {
2198  if (OnItemSplitDialogConfirm_Merge(dialog))
2199  return;
2200 
2201  if (OnItemSplitDialogConfirm_Create(dialog))
2202  return;
2203  }
2204 
2205  //------------------------------------------------------------------------------------------------
2206  protected bool OnItemSplitDialogConfirm_Merge(inout notnull SCR_ItemSplitDialog dialog)
2207  {
2209 
2210  if (!resourceInventoryComp)
2211  return false;
2212 
2213  IEntity entityFrom = dialog.GetEntityFrom();
2214  IEntity entityTo = dialog.GetEntityTo();
2215 
2216  SCR_ResourceComponent resourceComponentFrom = SCR_ResourceComponent.FindResourceComponent(entityFrom);
2217 
2218  if (!resourceComponentFrom)
2219  return false;
2220 
2221  if (!entityTo)
2222  return false;
2223 
2224  SCR_ResourceComponent resourceComponentTo = SCR_ResourceComponent.FindResourceComponent(entityTo);
2225 
2226  if (!resourceComponentTo)
2227  return false;
2228 
2229  resourceInventoryComp.Rpc(resourceInventoryComp.RpcAsk_MergeContainerWithContainerPartial, Replication.FindId(resourceComponentFrom), Replication.FindId(resourceComponentTo), EResourceType.SUPPLIES, dialog.GetSliderValue());
2230 
2231  return true;
2232  }
2233 
2234  //------------------------------------------------------------------------------------------------
2235  protected bool OnItemSplitDialogConfirm_Create(inout notnull SCR_ItemSplitDialog dialog)
2236  {
2238 
2239  if (!resourceInventoryComp)
2240  return false;
2241 
2242  IEntity entityFrom = dialog.GetEntityFrom();
2243  IEntity entityTo = dialog.GetEntityTo();
2244 
2245  SCR_ResourceComponent resourceComponentFrom = SCR_ResourceComponent.FindResourceComponent(entityFrom);
2246 
2247  if (!resourceComponentFrom)
2248  return false;
2249 
2250  if (!entityTo)
2251  {
2252  resourceInventoryComp.Rpc(resourceInventoryComp.RpcAsk_CreatePhysicalContainerWithContainer, Replication.FindId(resourceComponentFrom), Replication.FindId(null), Replication.FindId(null), EResourceType.SUPPLIES, dialog.GetSliderValue());
2253 
2254  return true;
2255  }
2256 
2257  SCR_ResourceComponent resourceComponentTo = SCR_ResourceComponent.FindResourceComponent(entityTo);
2258 
2260  if (resourceComponentTo)
2261  return false;
2262 
2263  SCR_InventoryStorageManagerComponent invManagerTo;
2264  IEntity entityParentTo = entityTo.GetParent();
2265 
2266  if (entityParentTo)
2267  invManagerTo = SCR_InventoryStorageManagerComponent.Cast(entityParentTo.FindComponent(SCR_InventoryStorageManagerComponent));
2268 
2269  if (!invManagerTo)
2270  return false;
2271 
2272  BaseInventoryStorageComponent storageTo = BaseInventoryStorageComponent.Cast(entityTo.FindComponent(BaseInventoryStorageComponent));
2273 
2274  if (!storageTo)
2275  return false;
2276 
2277  resourceInventoryComp.Rpc(resourceInventoryComp.RpcAsk_CreatePhysicalContainerWithContainer, Replication.FindId(resourceComponentFrom), Replication.FindId(invManagerTo), Replication.FindId(storageTo), EResourceType.SUPPLIES, dialog.GetSliderValue());
2278 
2279  return true;
2280  }
2281 
2282 
2283 
2284  //------------------------------------------------------------------------------------------------
2285  void NavigationBarUpdateGamepad()
2286  {
2287  m_pNavigationBar.SetAllButtonEnabled(false);
2288  m_pNavigationBar.SetButtonEnabled("ButtonBack", true);
2289  m_pNavigationBar.SetButtonEnabled("ButtonSelect", true);
2290 
2291  SCR_InventoryHitZoneUI hzSlot = m_AttachmentSpinBox.GetFocusedHZPoint();
2292 
2293  m_pNavigationBar.SetButtonEnabled("ButtonRemoveTourniquet",
2294  (hzSlot && hzSlot.IsTourniquetted()) &&
2295  m_AttachmentSpinBox.IsFocused()
2296  );
2297 
2298  if (m_pActiveStorageUI == m_pAttachmentStorageUI)
2299  {
2300  m_pNavigationBar.SetButtonEnabled("ButtonUse", true);
2301  return;
2302  }
2303 
2304  if (m_bStorageSwitchMode)
2305  {
2306  m_pNavigationBar.SetButtonActionName("ButtonBack", "#AR-Inventory_Close");
2307  bool shouldShowMove = (m_pSelectedSlotUI != null) && m_pSelectedSlotUI.IsDraggable();
2308  if (m_pSelectedSlotUI)
2309  m_pNavigationBar.SetButtonActionName("ButtonBack", "#AR-Inventory_Deselect");
2310  if (m_pActiveStorageUI)
2311  shouldShowMove &= m_pActiveStorageUI.IsStorageHighlighted();
2312  m_pNavigationBar.SetButtonEnabled("ButtonMove", shouldShowMove);
2313  m_pNavigationBar.SetButtonEnabled("ButtonSelect", !m_pSelectedSlotUI);
2314  m_pNavigationBar.SetButtonEnabled("ButtonEnterStorage", m_pSelectedSlotUI != null)
2315  }
2316  else
2317  {
2318  m_pNavigationBar.SetButtonEnabled("ButtonMove", m_pSelectedSlotUI != null);
2319  m_pNavigationBar.SetButtonEnabled("ButtonSwap", m_pSelectedSlotUI != null);
2320  }
2321 
2322  if (!m_bStorageSwitchMode &&
2323  m_pActiveStorageUI != m_pStorageLootUI &&
2324  m_pActiveStorageUI != m_pStorageListUI &&
2325  m_pActiveStorageUI && !m_pActiveStorageUI.IsInherited(SCR_InventoryOpenedStorageUI))
2326  {
2327  m_pNavigationBar.SetButtonEnabled("ButtonQuickSlotAssign", true);
2328  }
2329 
2330  bool isQuickSlotStorage = (m_pActiveStorageUI == m_pQuickSlotStorage);
2331  if (isQuickSlotStorage)
2332  {
2333  bool itmToAssign = m_pItemToAssign != null;
2334  m_pNavigationBar.SetAllButtonEnabled(false);
2335  m_pNavigationBar.SetButtonEnabled("ButtonMove", m_pSelectedSlotUI != null);
2336  m_pNavigationBar.SetButtonEnabled("ButtonClose", true);
2337  if (m_bStorageSwitchMode)
2338  m_pNavigationBar.SetButtonEnabled("ButtonSelect", true);
2339 
2340  m_pNavigationBar.SetButtonEnabled("ButtonQuickSlotAssign", itmToAssign);
2341  m_pNavigationBar.SetButtonEnabled("ButtonQuickSlotUnassign",
2342  !itmToAssign &&
2343  m_pFocusedSlotUI != null
2344  );
2345  }
2346 
2347  if (!m_pFocusedSlotUI)
2348  return;
2349 
2350  InventoryItemComponent itemComp = m_pFocusedSlotUI.GetInventoryItemComponent();
2351  bool arsenalItem = IsStorageArsenal(m_pFocusedSlotUI.GetStorageUI().GetCurrentNavigationStorage());
2352  if (itemComp && itemComp.GetOwner() && !arsenalItem)
2353  m_pNavigationBar.SetButtonEnabled("ButtonInspect", (itemComp.GetOwner().FindComponent(SCR_WeaponAttachmentsStorageComponent) != null));
2354 
2355  if (itemComp
2356  && m_pActiveStorageUI != m_pStorageListUI
2357  && m_pActiveStorageUI != m_pStorageLootUI)
2358  {
2359  bool canUse = m_StorageManager.CanUseItem_Inventory(itemComp.GetOwner());
2360  bool canEquip = m_StorageManager.CanEquipItem_Inventory(itemComp.GetOwner());
2361 
2362  m_pNavigationBar.SetButtonEnabled("ButtonUse", canUse);
2363  m_pNavigationBar.SetButtonEnabled("ButtonEquip", canEquip);
2364  }
2365 
2366  if (!m_pSelectedSlotUI)
2367  m_pNavigationBar.SetButtonActionName("ButtonBack", "#AR-Menu_Back");
2368 
2369  m_pNavigationBar.SetButtonEnabled("ButtonDrop",
2370  (m_pFocusedSlotUI != null) &&
2371  !isQuickSlotStorage &&
2372  m_pFocusedSlotUI.IsDraggable() &&
2373  !m_AttachmentSpinBox.IsFocused()
2374  );
2375 
2376  bool flag = m_pFocusedSlotUI.GetStorageUI() == m_pStorageLootUI;
2377  m_pNavigationBar.SetButtonEnabled("ButtonPickup", flag);
2378 
2379  if (!isQuickSlotStorage)
2380  {
2381  m_pNavigationBar.SetButtonEnabled("ButtonDrop", !flag);
2382  HandleSlottedItemFunction();
2383  }
2384  }
2385 
2386  //------------------------------------------------------------------------------------------------
2387  protected void HandleSelectButtonState( string sAction = "#AR-Inventory_Select" )
2388  {
2389  //TODO: this can be done better
2390  if ( sAction == "#AR-Inventory_Move" )
2391  m_pNavigationBar.SetButtonActionName( "ButtonSelect", sAction );
2392  else
2393  {
2394  if ( !m_pFocusedSlotUI.IsSlotSelected() )
2395  m_pNavigationBar.SetButtonActionName( "ButtonSelect", sAction );
2396  else
2397  m_pNavigationBar.SetButtonActionName( "ButtonSelect", "#AR-Inventory_Deselect" );
2398  }
2399  }
2400 
2401  //------------------------------------------------------------------------------------------------
2403  SCR_InventoryInspectionUI GetInspectionScreen()
2404  {
2405  return m_InspectionScreen;
2406  }
2407 
2408  //------------------------------------------------------------------------------------------------
2410  void InspectItem(SCR_InventorySlotUI itemSlot)
2411  {
2412  if (m_pGearInspectionPointUI)
2413  {
2414  m_pGearInspectionPointUI.ClearSlots();
2415  m_wAttachmentContainer.RemoveHandler(m_pGearInspectionPointUI);
2416  m_pGearInspectionPointUI = null;
2417  m_pInspectedSlot = null;
2418  }
2419 
2420  if (!itemSlot)
2421  {
2422  CloseAttachmentStorage();
2423  SetAttachmentSpinBoxActive(m_bIsUsingGamepad);
2424  m_PlayerRenderAttributes.RotateItemCamera(Vector(0, 0, 0), Vector(0, 0, 0), Vector(0, 0, 0)); // reset rotation
2425  InitializeCharacterHitZones();
2426  UpdateCharacterPreview();
2427  return;
2428  }
2429 
2430  InventoryItemComponent itemComp = itemSlot.GetInventoryItemComponent();
2431 
2432  if (!itemComp)
2433  {
2434  InitializeCharacterHitZones();
2435  CloseAttachmentStorage();
2436  SetAttachmentSpinBoxActive(m_bIsUsingGamepad);
2437  UpdateCharacterPreview();
2438  return;
2439  }
2440 
2441  IEntity item = itemComp.GetOwner();
2442 
2443  SCR_WeaponAttachmentsStorageComponent weaponAttachmentStorage = SCR_WeaponAttachmentsStorageComponent.Cast(item.FindComponent(SCR_WeaponAttachmentsStorageComponent));
2444 
2445  if (weaponAttachmentStorage)
2446  {
2447  m_PlayerRenderAttributes.RotateItemCamera(Vector(0, 90, 0), Vector(0, 90, 0), Vector(0, 90, 0)); // rotate inspected weapon to side view
2448  m_pInspectedSlot = itemSlot;
2449  InspectWeapon(weaponAttachmentStorage);
2450  UpdateGearInspectionPreview();
2451  return;
2452  }
2453 
2454  /* Preparations for gear inspection
2455  ClothNodeStorageComponent clothNodeStorage = ClothNodeStorageComponent.Cast(item.FindComponent(ClothNodeStorageComponent));
2456 
2457  if (clothNodeStorage)
2458  {
2459  m_pInspectedSlot = itemSlot;
2460  InspectGear(clothNodeStorage);
2461  UpdateGearInspectionPreview();
2462  return;
2463  }*/
2464  }
2465 
2466  //------------------------------------------------------------------------------------------------
2467  void InspectWeapon(SCR_WeaponAttachmentsStorageComponent weaponAttachmentStorage)
2468  {
2469  CloseAttachmentStorage();
2470  HideCharacterHitZones();
2471  SetAttachmentSpinBoxActive(m_bIsUsingGamepad);
2472  Widget inspectionFrame = m_widget.FindAnyWidget("AttachmentPoints");
2473  m_wAttachmentContainer = GetGame().GetWorkspace().CreateWidgets(BACKPACK_STORAGE_LAYOUT, inspectionFrame);
2474  m_pGearInspectionPointUI = new SCR_InventoryGearInspectionPointUI(weaponAttachmentStorage, null, this, frameSlot: inspectionFrame);
2475  m_wAttachmentContainer.AddHandler(m_pGearInspectionPointUI);
2476  }
2477 
2478  /* Preparations for gear inspection
2479  void InspectGear(ClothNodeStorageComponent clothNodeStorage)
2480  {
2481  Widget inspectionFrame = m_widget.FindAnyWidget("AttachmentPoints");
2482  m_wAttachmentContainer = GetGame().GetWorkspace().CreateWidgets(BACKPACK_STORAGE_LAYOUT, inspectionFrame);
2483  m_pGearInspectionPointUI = new SCR_InventoryGearInspectionPointUI(clothNodeStorage, null, this, frameSlot: inspectionFrame);
2484  m_wAttachmentContainer.AddHandler(m_pGearInspectionPointUI);
2485  }*/
2486 
2487  SCR_InventoryGearInspectionPointUI GetGearInspectionUI()
2488  {
2489  return m_pGearInspectionPointUI;
2490  }
2491 
2492  //------------------------------------------------------------------------------------------------
2494  protected void FilterOutStorages( bool bShow = true )
2495  {
2496  //Get all slots from the storage list UI
2497  array<SCR_InventorySlotUI> pSlotsInListUI = new array<SCR_InventorySlotUI>();
2498  m_pStorageListUI.GetSlots( pSlotsInListUI );
2499  //foreach ( SCR_InventorySlotUI pSlotFromUI : pSlotsInListUI )
2500  // RegisterUIStorage( pSlotFromUI );
2501 
2502  if ( m_pStorageLootUI )
2503  m_pStorageLootUI.GetSlots( pSlotsInListUI );
2504  if ( GetActualStorageInCharacterStorageUI() )
2505  GetActualStorageInCharacterStorageUI().GetSlots( pSlotsInListUI );
2506  if ( m_pQuickSlotStorage )
2507  m_pQuickSlotStorage.GetSlots( pSlotsInListUI );
2508  if ( m_pWeaponStorage )
2509  m_pWeaponStorage.GetSlots( pSlotsInListUI );
2510 
2511  BaseInventoryStorageComponent pStorageTo;
2512  foreach ( SCR_InventorySlotUI pStorageSlotUI : pSlotsInListUI )
2513  {
2514  if ( !pStorageSlotUI )
2515  continue;
2516 
2517  pStorageTo = pStorageSlotUI.GetAsStorage();
2518 
2519  if ( bShow )
2520  {
2521  if ( !m_pSelectedSlotUI )
2522  continue;
2523  if ( pStorageSlotUI.GetAsStorage() == m_pSelectedSlotUI.GetStorageUI().GetCurrentNavigationStorage() ) //it's the same storage as the selected item comes from
2524  {
2525  pStorageSlotUI.SetEnabledForMove( 0 );
2526  continue;
2527  }
2528 
2529  InventoryItemComponent pInventoryItem = m_pSelectedSlotUI.GetInventoryItemComponent();
2530  if ( !pInventoryItem )
2531  continue;
2532 
2533  IEntity pItem = pInventoryItem.GetOwner();
2534 
2535  if ( pStorageTo )
2536  {
2537  bool bCanStore = true;
2538 
2539  if ( m_InventoryManager.CanInsertItemInActualStorage( pItem, pStorageTo ) )
2540  {
2541  if ( pStorageTo.Type() == SCR_InventoryStorageWeaponsUI )
2542  if ( !m_pWeaponStorageComp.Contains( pStorageTo.GetOwner() ) )
2543  bCanStore = false;
2544 
2545  if ( bCanStore )
2546  pStorageSlotUI.SetEnabledForMove( 1 );
2547  else
2548  pStorageSlotUI.SetEnabledForMove( 0 );
2549  }
2550  else
2551  {
2552  pStorageSlotUI.SetEnabledForMove( 0 );
2553  }
2554  }
2555  else
2556  {
2557  pStorageSlotUI.SetEnabledForMove( 0 );
2558  }
2559 
2560  }
2561  else
2562  {
2563  pStorageSlotUI.SetEnabledForMove( 2 );
2564  }
2565  }
2566  }
2567 
2568  //------------------------------------------------------------------------------------------------
2569  protected void FilterOutItems( bool bFilterOut )
2570  {
2571  array<SCR_InventorySlotUI> aItemsUIInLoot = {};
2572 
2573  //if ( m_pStorageLootUI )
2574  //aItemsUIInLoot.InsertAll( m_pStorageLootUI.GetUISlots() );
2575  if ( m_pStorageListUI )
2576  aItemsUIInLoot.InsertAll( m_pStorageListUI.GetUISlots() );
2577  //if ( m_pStorageBaseUI )
2578  //aItemsUIInLoot.InsertAll( m_pStorageBaseUI.GetUISlots() );
2579 
2580  PrintFormat( "INV: Filtering out items %1", 1.5 );
2581 
2582  foreach ( SCR_InventorySlotUI pSlot : aItemsUIInLoot )
2583  {
2584  if ( !pSlot.GetStorageComponent() )
2585  {
2586  if ( bFilterOut )
2587  {
2588  PrintFormat( "INV: Disabling slot %1", pSlot );
2589  pSlot.SetEnabledForMove( 0 );
2590  }
2591  else
2592  {
2593  PrintFormat( "INV: Reseting slot %1", pSlot );
2594  pSlot.SetEnabledForMove( 2 );
2595  }
2596  }
2597  }
2598  }
2599 
2600  //------------------------------------------------------------------------------------------------
2601  protected void Action_TryCloseInventory()
2602  {
2603  if (m_bWasJustTraversing)
2604  {
2605  m_bWasJustTraversing = false;
2606  return;
2607  }
2608 
2609  if (m_bIsUsingGamepad)
2610  {
2611  if (!m_bStorageSwitchMode)
2612  {
2613  SetStorageSwitchMode(true);
2614  return;
2615  }
2616  else
2617  {
2618  if (m_pSelectedSlotUI)
2619  {
2620  DeselectSlot();
2621  }
2622  else
2623  {
2624  Action_CloseInventory();
2625  return;
2626  }
2627 
2628  SetStorageSwitchMode(false);
2629  ResetHighlightsOnAvailableStorages();
2630  FocusOnSlotInStorage(m_pActiveStorageUI);
2631  return;
2632  }
2633  }
2634  else
2635  {
2636  DeselectSlot();
2637  }
2638 
2639  Action_CloseInventory();
2640  }
2641 
2642  //------------------------------------------------------------------------------------------------
2643  protected void Action_CloseInventory()
2644  {
2645  array<BaseInventoryStorageComponent> traverseStorage = {};
2646  if (m_wLootStorage)
2647  {
2648  SCR_InventoryStorageBaseUI storageUIHandler = SCR_InventoryStorageBaseUI.Cast( m_wLootStorage.FindHandler( SCR_InventoryStorageBaseUI ) );
2649  storageUIHandler.GetTraverseStorage(traverseStorage);
2650  }
2651 
2652  if (!traverseStorage.IsEmpty())
2653  {
2654  BaseInventoryStorageComponent storage = traverseStorage[0];
2655  if (storage)
2656  {
2657  IEntity entity = storage.GetOwner();
2658  m_InventoryManager.PlayItemSound(entity, SCR_SoundEvent.SOUND_CONTAINER_CLOSE);
2659  }
2660  }
2661  else
2662  {
2663  SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_INV_CLOSE);
2664  }
2665 
2666  GetGame().GetInputManager().RemoveActionListener("Inventory_Drag", EActionTrigger.DOWN, Action_DragDown);
2667  GetGame().GetInputManager().RemoveActionListener("Inventory", EActionTrigger.DOWN, Action_CloseInventory);
2668  //m_bColdStart = false;
2669  if (m_pVicinity)
2670  {
2671  m_pVicinity.ManipulationComplete();
2672  m_iVicinityDiscoveryRadius = 0;
2673  }
2674 
2675  auto menuManager = GetGame().GetMenuManager();
2676  auto menu = ChimeraMenuPreset.Inventory20Menu;
2677 
2678  auto inventoryMenu = menuManager.FindMenuByPreset( menu ); // prototype inventory
2679  if (inventoryMenu)
2680  menuManager.CloseMenuByPreset( menu );
2681 
2682  if (m_PlayerRenderAttributes)
2683  m_PlayerRenderAttributes.ResetDeltaRotation();
2684 
2685  if (m_Player)
2686  {
2687  m_CharController = SCR_CharacterControllerComponent.Cast(m_Player.GetCharacterController());
2688  if (m_CharController)
2689  m_CharController.m_OnLifeStateChanged.Remove(LifeStateChanged);
2690  }
2691 
2693  if (gameMode)
2694  gameMode.GetOnControllableDeleted().Remove(OnControllableDeleted);
2695 
2696  if (m_pCharacterWidgetHelper)
2697  m_pCharacterWidgetHelper.Destroy();
2698 
2699  m_pCharacterWidgetHelper = null;
2700 
2701  HideItemInfo();
2702  HideDamageInfo();
2703 
2704  if ( m_pItemInfo )
2705  m_pItemInfo.Destroy();
2706 
2707  if ( m_pDamageInfo )
2708  m_pDamageInfo.Destroy();
2709 
2710  m_pItemInfo = null;
2711  m_pDamageInfo = null;
2712 
2713  if (m_InventoryManager)
2714  m_InventoryManager.OnInventoryMenuClosed();
2715  }
2716 
2717  //------------------------------------------------------------------------------------------------
2720  void LifeStateChanged(ECharacterLifeState previousLifeState, ECharacterLifeState newLifeState)
2721  {
2722  if (newLifeState != ECharacterLifeState.ALIVE)
2723  Action_CloseInventory();
2724  }
2725 
2726  //------------------------------------------------------------------------------------------------
2727  //Only for cases when character is removed before dying
2728  protected void OnControllableDeleted(IEntity controllable)
2729  {
2730  if (m_Player && m_Player == controllable)
2731  Action_CloseInventory();
2732  }
2733 
2734  //------------------------------------------------------------------------------------------------
2736  protected void SimpleFSM( EMenuAction EAction = EMenuAction.ACTION_SELECT )
2737  {
2738  switch (EAction)
2739  {
2740  case EMenuAction.ACTION_MOVEINSIDE:
2741  {
2742  Action_MoveItemToStorage(m_pActiveStorageUI);
2743  if (m_bIsUsingGamepad)
2744  SetStorageSwitchMode(true);
2745  NavigationBarUpdate();
2746  if (m_pSelectedSlotUI)
2747  {
2748  m_pSelectedSlotUI.SetSelected(false);
2749  m_pSelectedSlotUI = null;
2750  }
2751  FocusOnSlotInStorage(m_pActiveStorageUI);
2752  ResetHighlightsOnAvailableStorages();
2753  } break;
2754 
2755  case EMenuAction.ACTION_SELECT:
2756  {
2757  if (!m_pFocusedSlotUI)
2758  return;
2759 
2760  if (m_pSelectedSlotUI)
2761  m_pSelectedSlotUI.SetSelected(false);
2762 
2763  if (m_bIsUsingGamepad)
2764  {
2765  m_pSelectedSlotUI = m_pFocusedSlotUI;
2766  m_pSelectedSlotUI.SetSelected(true);
2767  HighlightAvailableStorages(m_pSelectedSlotUI);
2768  }
2769 
2770  NavigationBarUpdate();
2771  if (m_bIsUsingGamepad)
2772  SetStorageSwitchMode(true);
2773  } break;
2774 
2775  case EMenuAction.ACTION_DESELECT:
2776  {
2777  if (m_pSelectedSlotUI)
2778  {
2779  ResetHighlightsOnAvailableStorages();
2780  m_pSelectedSlotUI.SetSelected(false);
2781  m_pSelectedSlotUI = null;
2782  }
2783 
2784  NavigationBarUpdate();
2785  } break;
2786 
2787  case EMenuAction.ACTION_DRAGGED:
2788  {
2789  m_EStateMenuItem = EStateMenuItem.STATE_MOVING_ITEM_STARTED;
2790  } break;
2791 
2792  case EMenuAction.ACTION_DROPPED:
2793  {
2794  Action_Drop();
2795  if (m_pActiveHoveredStorageUI)
2796  m_pActiveHoveredStorageUI.ShowContainerBorder(false);
2797  m_EStateMenuItem = EStateMenuItem.STATE_IDLE;
2798  return;
2799  } break;
2800 
2801  case EMenuAction.ACTION_MOVEBETWEEN:
2802  {
2803  if (m_pFocusedSlotUI == m_pInspectedSlot)
2804  {
2805  InspectItem(null);
2806  }
2807 
2808  if (m_pFocusedSlotUI)
2809  {
2810  m_pSelectedSlotUI = m_pFocusedSlotUI;
2811  SCR_InventoryStorageBaseUI pStorage = m_pFocusedSlotUI.GetStorageUI();
2812 
2813  if (SCR_InventoryOpenedStorageUI.Cast(pStorage) && m_aOpenedStoragesUI.Contains(SCR_InventoryOpenedStorageUI.Cast(pStorage)))
2814  {
2815  MoveBetweenFromVicinity();
2816  SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_INV_CONTAINER_DIFR_DROP);
2817  }
2818  else if (pStorage != m_pStorageLootUI)
2819  {
2820  MoveBetweenToVicinity();
2821  SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_INV_VICINITY_DROP_CLICK);
2822  }
2823  else
2824  {
2825  MoveBetweenFromVicinity();
2826  SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_INV_PICKUP_CLICK);
2827  }
2828  m_pSelectedSlotUI = null;
2829  }
2830  ResetHighlightsOnAvailableStorages();
2831  } break;
2832 
2833  case EMenuAction.ACTION_UNFOLD:
2834  {
2835  if ( m_pFocusedSlotUI.GetStorageUI() == m_pStorageListUI ) //if it is slot in the "storage list ui"
2836  {
2837  if ( BaseInventoryStorageComponent.Cast( m_pFocusedSlotUI.GetAsStorage() ) ) // and if it is a storage
2838  {
2839  //ShowStorage( m_pFocusedSlotUI.GetAsStorage() ); //show the content of the actualy selected
2840  ToggleStorageContainerVisibility( m_pFocusedSlotUI );
2841  m_EStateMenuStorage = EStateMenuStorage.STATE_OPENED;
2842  }
2843  else
2844  {
2845  //CloseOpenedStorage(); // if it is not storage, show nothing
2846  //ToggleStorageContainerVisibility( m_pFocusedSlotUI.GetAsStorage() );
2847  m_EStateMenuStorage = EStateMenuStorage.STATE_IDLE;
2848  }
2849 
2850  }
2851  else
2852  {
2853  TraverseActualSlot();
2854  NavigationBarUpdate();
2855  m_EStateMenuStorage = EStateMenuStorage.STATE_OPENED;
2856  }
2857  } break;
2858 
2859  case EMenuAction.ACTION_OPENCONTAINER:
2860  {
2861  OpenAsNewContainer();
2862  } break;
2863  }
2864 
2865  if (!m_bIsUsingGamepad)
2866  m_pSelectedSlotUI = m_pFocusedSlotUI;
2867 
2868  HideItemInfo();
2869  }
2870 
2871  //------------------------------------------------------------------------------------------------
2872  protected void Action_OpenContainer()
2873  {
2874  SimpleFSM(EMenuAction.ACTION_OPENCONTAINER);
2875  }
2876 
2877  //------------------------------------------------------------------------------------------------
2879  protected void Action_Drop()
2880  {
2881  bool onDrop = false;
2882  if (m_pFocusedSlotUI)
2883  onDrop = m_pFocusedSlotUI.OnDrop(m_pSelectedSlotUI);
2884 
2885  Widget underCursor = WidgetManager.GetWidgetUnderCursor();
2886  if (underCursor && underCursor.GetName() == "HitZoneButton")
2887  {
2888  SCR_InventoryHitZonePointContainerUI hzContainer = SCR_InventoryHitZonePointContainerUI.Cast(m_AttachmentSpinBox.GetCurrentItemData());
2889  if (m_pSelectedSlotUI && hzContainer)
2890  {
2891  hzContainer.GetStorage().OnDrop(m_pSelectedSlotUI);
2892  }
2893  }
2894 
2895  if ( !onDrop && IsFocusedItemInsideDropContainer() != EDropContainer.NOCONTAINER ) //dropped to a container
2896  {
2897  if (m_pSelectedSlotUI == m_pInspectedSlot)
2898  InspectItem(null);
2899 
2900  if ( m_pFocusedSlotUI )
2901  {
2902  if ( IsFocusedItemInsideDropContainer() == EDropContainer.ISINSIDE )
2903  {
2904  if ( SCR_InventorySlotStorageUI.Cast( m_pFocusedSlotUI ) ) // storage
2905  {
2906  MoveItemToStorageSlot();
2907  }
2908  else if ( SCR_InventorySlotWeaponSlotsUI.Cast( m_pFocusedSlotUI ) ) // weapon slot
2909  {
2910  EquipWeaponIntoWeaponSlot();
2911  }
2912  else if ( SCR_InventorySlotUI.Cast( m_pFocusedSlotUI ) ) // simple slot
2913  {
2914  if ( SCR_InventoryStorageQuickSlotsUI.Cast( m_pFocusedSlotUI.GetStorageUI() ) ) //quick slot
2915  {
2916  //m_pFocusedSlotUI.m_iQuickSlotIndex
2917  SetItemToQuickSlotDrop();
2918  }
2919  else
2920  {
2921  MoveItemToStorageSlot();
2922  /*
2923  if ( m_pFocusedSlotUI.GetInventoryItemComponent() )
2924  {
2925  MoveItemToStorageSlot();
2926  }
2927  else
2928  {
2929  //we are inserting into empy slot
2930  m_InventoryManager.EquipGadget( m_pSelectedSlotUI.GetInventoryItemComponent().GetOwner() );
2931  }
2932  */
2933  }
2934 
2935  }
2936  }
2937  }
2938  else
2939  {
2940  // just container
2941  if (m_pActiveHoveredStorageUI)
2942  m_pActiveHoveredStorageUI.OnDrop(m_pSelectedSlotUI);
2943  if (!onDrop)
2944  MoveItem();
2945  }
2946  }
2947  else
2948  {
2949  if (WidgetManager.GetWidgetUnderCursor() == m_wPlayerRender)
2950  {
2951  EquipDraggedItem(true);
2952  }
2953  else
2954  {
2955  //dropped outside of a container
2956  RemoveItemFromQuickSlotDrop();
2957  }
2958  }
2959 
2960  ResetHighlightsOnAvailableStorages();
2961  }
2962 
2963  //------------------------------------------------------------------------------------------------
2964  void Action_QuickSlotAssign()
2965  {
2966  if (m_pItemToAssign && m_pActiveStorageUI == m_pQuickSlotStorage)
2967  {
2968  int slotId = m_pQuickSlotStorage.GetFocusedSlotId() + 1;
2969  SetItemToQuickSlot(slotId, m_pItemToAssign);
2970  FocusOnSlotInStorage(m_pQuickSlotStorage, slotId - 1);
2971  m_pItemToAssign = null;
2972  }
2973  else
2974  {
2975  if (m_pActiveStorageUI != m_pStorageLootUI && m_pActiveStorageUI != m_pQuickSlotStorage)
2976  {
2977  m_pItemToAssign = m_pFocusedSlotUI;
2978  FocusOnSlotInStorage(m_pQuickSlotStorage, 4);
2979  }
2980  }
2981 
2982  NavigationBarUpdate();
2983  }
2984 
2985  //------------------------------------------------------------------------------------------------
2986  void Action_QuickSlotUnassign()
2987  {
2988  if (!m_pFocusedSlotUI)
2989  return;
2990 
2991  InventoryItemComponent itemComp = m_pFocusedSlotUI.GetInventoryItemComponent();
2992  if (!itemComp)
2993  return;
2994 
2995  IEntity item = itemComp.GetOwner();
2996  if (!item)
2997  return;
2998 
2999  int slotId = m_pQuickSlotStorage.GetFocusedSlotId();
3000  slotId = Math.Clamp(slotId, 0, m_StorageManager.GetQuickSlotItems().Count());
3001  m_pItemToAssign = null;
3002  m_StorageManager.RemoveItemFromQuickSlot(item);
3003  ShowQuickSlotStorage();
3004  FocusOnSlotInStorage(m_pQuickSlotStorage, slotId);
3005  NavigationBarUpdate();
3006  }
3007 
3008  //------------------------------------------------------------------------------------------------
3010  void MoveItemToStorageSlot()
3011  {
3012  if (MoveItemToStorageSlot_VirtualArsenal())
3013  return;
3014 
3015  if (MoveItemToStorageSlot_ResourceContainer())
3016  {
3017  if (m_pSelectedSlotUI)
3018  {
3019  m_pSelectedSlotUI.SetSelected(false);
3020  m_pSelectedSlotUI = null;
3021  }
3022 
3023  return;
3024  }
3025 
3026  if (!m_pSelectedSlotUI)
3027  return;
3028 
3029  InventoryItemComponent pComp = m_pSelectedSlotUI.GetInventoryItemComponent();
3030  if (!pComp)
3031  return;
3032 
3033  IEntity pItem = pComp.GetOwner();
3034  if (!m_InventoryManager.CanMoveItem(pItem))
3035  return;
3036 
3037  m_pCallBack.m_pItem = pItem;
3038  m_pCallBack.m_pMenu = this;
3039  m_pCallBack.m_pStorageFrom = m_pSelectedSlotUI.GetStorageUI();
3040  m_pCallBack.m_pStorageTo = m_pFocusedSlotUI.GetStorageUI();
3041 
3042  BaseInventoryStorageComponent pStorageFromComponent = m_pCallBack.m_pStorageFrom.GetCurrentNavigationStorage();
3043  BaseInventoryStorageComponent pStorageToComponent = m_pFocusedSlotUI.GetAsStorage();
3044 
3045  if (!pStorageToComponent)
3046  pStorageToComponent = m_pCallBack.m_pStorageTo.GetStorage();
3047 
3048  if (IsStorageArsenal(pStorageToComponent))
3049  {
3050  SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_INV_DROP_ERROR);
3051  return;
3052  }
3053 
3054  bool shouldEquip = m_pCallBack.m_pStorageTo == m_pStorageListUI;
3055  bool equip = shouldEquip && m_InventoryManager.EquipAny(m_StorageManager , pItem, 0, m_pCallBack);
3056 
3057  if (!equip)
3058  m_InventoryManager.InsertItem( pItem, pStorageToComponent, pStorageFromComponent, m_pCallBack );
3059  else
3060  m_InventoryManager.PlayItemSound(pItem, SCR_SoundEvent.SOUND_EQUIP);
3061  /*
3062  if ( pItem.FindComponent( SCR_GadgetComponent ) )
3063  m_InventoryManager.EquipGadget( pItem, m_pCallBack );
3064  else
3065  */
3066  }
3067 
3068  //------------------------------------------------------------------------------------------------
3070  void EquipWeaponIntoWeaponSlot()
3071  {
3072  if (EquipWeaponIntoWeaponSlot_VirtualArsenal())
3073  return;
3074 
3075  if (!m_pSelectedSlotUI)
3076  return;
3077 
3078  InventoryItemComponent pComp = m_pSelectedSlotUI.GetInventoryItemComponent();
3079  if (!pComp)
3080  return;
3081 
3082  SCR_InventorySlotWeaponSlotsUI weaponSlot = SCR_InventorySlotWeaponSlotsUI.Cast(m_pFocusedSlotUI);
3083  if (!weaponSlot)
3084  return;
3085 
3086  IEntity pItem = pComp.GetOwner();
3087  if (!m_InventoryManager.CanMoveItem(pItem))
3088  return;
3089 
3090  m_pCallBack.m_pItem = pItem;
3091  m_pCallBack.m_pMenu = this;
3092  m_pCallBack.m_pStorageFrom = m_pSelectedSlotUI.GetStorageUI();
3093  m_pCallBack.m_pStorageTo = m_pFocusedSlotUI.GetStorageUI();
3094 
3095  InventoryItemComponent pItemToReplaceComp = m_pFocusedSlotUI.GetInventoryItemComponent();
3096  IEntity pItemToReplace;
3097  if (pItemToReplaceComp)
3098  pItemToReplace = pItemToReplaceComp.GetOwner();
3099 
3100  if (pItemToReplace)
3101  {
3102  BaseInventoryStorageComponent itemToReplaceStorage = BaseInventoryStorageComponent.Cast(pItemToReplace.FindComponent(BaseInventoryStorageComponent));
3103 
3104  if (itemToReplaceStorage && m_InventoryManager.CanInsertItemInStorage(pItem, itemToReplaceStorage, -1))
3105  {
3106  m_InventoryManager.TryInsertItemInStorage(pItem, itemToReplaceStorage, -1, m_pCallBack);
3107  return;
3108  }
3109  }
3110 
3111  InventoryStorageSlot itemParentSlot = pComp.GetParentSlot();
3112 
3113  if (pItemToReplace && pItem)
3114  {
3115  if (itemParentSlot && IsStorageArsenal(itemParentSlot.GetStorage()))
3116  {
3117  m_InventoryManager.TryReplaceAndDropItemAtSlot(m_pWeaponStorageComp, pItem, weaponSlot.GetWeaponSlotIndex(), m_pCallBack, true, true);
3118  return;
3119  }
3120  else if (pItemToReplace != pItem)
3121  {
3122  if (m_InventoryManager.TrySwapItemStorages(pItem, pItemToReplace, m_pCallBack))
3123  m_InventoryManager.PlayItemSound(pItem, SCR_SoundEvent.SOUND_EQUIP);
3124  else
3125  SCR_UISoundEntity.SoundEvent("SOUND_INV_DROP_ERROR");
3126 
3127  return;
3128  }
3129  }
3130 
3131  BaseInventoryStorageComponent pStorageToComponent = m_pWeaponStorageComp;
3132 
3133  if (!m_InventoryManager.TryMoveItemToStorage( pItem, m_pWeaponStorageComp, weaponSlot.GetWeaponSlotIndex(), m_pCallBack ))
3134  {
3135  if (!m_InventoryManager.TryInsertItemInStorage(pItem, m_pWeaponStorageComp, weaponSlot.GetWeaponSlotIndex(), m_pCallBack))
3136  SCR_UISoundEntity.SoundEvent("SOUND_INV_DROP_ERROR");
3137  return;
3138  }
3139 
3140  m_InventoryManager.PlayItemSound(pItem, SCR_SoundEvent.SOUND_EQUIP);
3141  }
3142 
3143  //------------------------------------------------------------------------------------------------
3145  void MoveItem( SCR_InventoryStorageBaseUI pStorageBaseUI = null )
3146  {
3147  if (MoveItem_VirtualArsenal(pStorageBaseUI))
3148  return;
3149 
3150  if (MoveItem_ResourceContainer(pStorageBaseUI))
3151  {
3152  if (m_pSelectedSlotUI)
3153  {
3154  m_pSelectedSlotUI.SetSelected(false);
3155  m_pSelectedSlotUI = null;
3156  }
3157 
3158  return;
3159  }
3160 
3161  if ( !m_pSelectedSlotUI )
3162  return;
3163  InventoryItemComponent pComp = m_pSelectedSlotUI.GetInventoryItemComponent();
3164  if ( !pComp )
3165  return;
3166  IEntity pItem = pComp.GetOwner();
3167  if (!m_InventoryManager.CanMoveItem(pItem))
3168  return;
3169 
3170  m_pCallBack.m_pItem = pItem;
3171  m_pCallBack.m_pMenu = this;
3172  m_pCallBack.m_pStorageToFocus = m_pSelectedSlotUI.GetStorageUI();
3173  m_pCallBack.m_pStorageFrom = m_pSelectedSlotUI.GetStorageUI();
3174 
3175  if ( pStorageBaseUI )
3176  m_pCallBack.m_pStorageTo = pStorageBaseUI;
3177  else
3178  m_pCallBack.m_pStorageTo = m_pActiveHoveredStorageUI;
3179 
3180  BaseInventoryStorageComponent pStorageTo = m_pActiveHoveredStorageUI.GetCurrentNavigationStorage();
3181  if (IsStorageArsenal(pStorageTo))
3182  {
3183  SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_INV_DROP_ERROR);
3184  return;
3185  }
3186 
3187  if (pStorageTo && pStorageTo.IsInherited(SCR_WeaponAttachmentsStorageComponent))
3188  {
3189  m_pCallBack.m_pStorageMan = GetInventoryStorageManager();
3190  m_pCallBack.m_eAttachAction = EAttachAction.ATTACH;
3191  }
3192 
3193  if (m_pCallBack.m_pStorageFrom)
3194  {
3195  BaseInventoryStorageComponent storageFrom = m_pCallBack.m_pStorageFrom.GetStorage();
3196  if (storageFrom && storageFrom.IsInherited(SCR_WeaponAttachmentsStorageComponent))
3197  {
3198  m_pCallBack.m_pStorageMan = GetInventoryStorageManager();
3199  m_pCallBack.m_eAttachAction = EAttachAction.DETACH;
3200  }
3201  }
3202 
3203  if ( pStorageTo && EquipedWeaponStorageComponent.Cast( pStorageTo ) )
3204  {
3205  m_InventoryManager.EquipWeapon( pItem, m_pCallBack, m_pCallBack.m_pStorageFrom == m_pStorageLootUI );
3206  return;
3207  }
3208  else if ( pStorageTo && CharacterInventoryStorageComponent.Cast( pStorageTo ) )
3209  {
3210  m_InventoryManager.EquipAny( pStorageTo, pItem, 0, m_pCallBack );
3211  }
3212  else if ( m_pCallBack.m_pStorageTo == m_pStorageLootUI )
3213  {
3214  MoveToVicinity( pItem );
3215  SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_INV_VICINITY_DROP_CLICK);
3216  }
3217  else if ( m_pCallBack.m_pStorageFrom == m_pCallBack.m_pStorageTo)
3218  {
3219  SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_INV_CONTAINER_SAME_DROP);
3220  }
3221  else
3222  {
3223  if ( m_pCallBack.m_pStorageFrom == m_pStorageLootUI )
3224  MoveFromVicinity();
3225  else
3226  m_InventoryManager.InsertItem( pItem, m_pActiveHoveredStorageUI.GetCurrentNavigationStorage(), m_pCallBack.m_pStorageFrom.GetStorage(), m_pCallBack );
3227  }
3228  }
3229 
3230  //------------------------------------------------------------------------------------------------
3232  protected void EquipWeapon()
3233  {
3234  if ( !m_pSelectedSlotUI )
3235  return;
3236  IEntity pItem = m_pSelectedSlotUI.GetInventoryItemComponent().GetOwner();
3237  if ( !pItem )
3238  return;
3239 
3240  if ( m_InventoryManager )
3241  m_InventoryManager.EquipWeapon( pItem, m_pCallBack );
3242  }
3243 
3244  //------------------------------------------------------------------------------------------------
3246  protected void MoveToVicinity( IEntity pItem )
3247  {
3248  BaseInventoryStorageComponent pStorageFrom = m_pSelectedSlotUI.GetStorageUI().GetStorage();
3249 
3250  if (!m_InventoryManager.CanMoveItem(pItem))
3251  return;
3252 
3253  m_pCallBack.m_pStorageFrom = GetStorageUIByBaseStorageComponent(pStorageFrom);
3254  if (!m_pCallBack.m_pStorageFrom)
3255  m_pCallBack.m_pStorageFrom = m_pSelectedSlotUI.GetStorageUI();
3256 
3257  BaseInventoryStorageComponent isStorage = BaseInventoryStorageComponent.Cast(pItem.FindComponent(BaseInventoryStorageComponent));
3258  if (isStorage)
3259  m_pCallBack.m_pStorageToDrop = isStorage;
3260 
3261  m_pCallBack.m_pStorageTo = m_pStorageLootUI;
3262  auto storage = m_pStorageLootUI.GetCurrentNavigationStorage();
3263 
3264  if ( storage && !IsStorageArsenal(storage) )
3265  m_InventoryManager.InsertItem( pItem, m_pStorageLootUI.GetCurrentNavigationStorage(), pStorageFrom, m_pCallBack ); // moving into the opened storage in the vicinity
3266  else
3267  {
3268  //droping it on the ground
3269  auto pSlot = m_pSelectedSlotUI.GetInventoryItemComponent().GetParentSlot();
3270  if ( pSlot )
3271  {
3272  if (pStorageFrom && pStorageFrom.IsInherited(SCR_WeaponAttachmentsStorageComponent))
3273  {
3274  m_pCallBack.m_pStorageMan = GetInventoryStorageManager();
3275  m_pCallBack.m_eAttachAction = EAttachAction.DETACH;
3276  }
3277  m_InventoryManager.TryRemoveItemFromInventory(pItem, pSlot.GetStorage(), m_pCallBack);
3278  m_InventoryManager.PlayItemSound(pItem, SCR_SoundEvent.SOUND_DROP);
3279  }
3280  else
3281  {
3282  SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_INV_DROP_ERROR);
3283  }
3284  }
3285  }
3286 
3287  //------------------------------------------------------------------------------------------------
3289  protected void MoveFromVicinity()
3290  {
3291  IEntity pItem = m_pSelectedSlotUI.GetInventoryItemComponent().GetOwner();
3292  if (!m_InventoryManager.CanMoveItem(pItem))
3293  return;
3294 
3295  m_pCallBack.m_pItem = pItem;
3296  m_pCallBack.m_pMenu = this;
3297 
3298  m_pCallBack.m_pStorageFrom = m_pStorageLootUI;
3299  m_pCallBack.m_pStorageTo = m_pActiveHoveredStorageUI;
3300 
3301  if (ShouldSpawnItem())
3302  {
3303  m_pCallBack.m_bUpdateSlotOnly = true;
3304  BaseInventoryStorageComponent storageTo = m_InventoryManager.FindStorageForInsert(pItem, m_pActiveHoveredStorageUI.GetCurrentNavigationStorage(), EStoragePurpose.PURPOSE_ANY);
3305  m_InventoryManager.TrySpawnPrefabToStorage(pItem.GetPrefabData().GetPrefabName(), storageTo, -1, EStoragePurpose.PURPOSE_ANY, m_pCallBack);
3306  m_InventoryManager.PlayItemSound(pItem, SCR_SoundEvent.SOUND_PICK_UP);
3307  return;
3308  }
3309 
3310  if (m_pActiveHoveredStorageUI.GetCurrentNavigationStorage() &&
3311  m_pActiveHoveredStorageUI.GetCurrentNavigationStorage().IsInherited(SCR_WeaponAttachmentsStorageComponent))
3312  {
3313  m_pCallBack.m_pStorageMan = GetInventoryStorageManager();
3314  m_pCallBack.m_eAttachAction = EAttachAction.ATTACH;
3315  }
3316 
3317  BaseInventoryStorageComponent storagefrom = m_pStorageLootUI.GetCurrentNavigationStorage();
3318  if (!storagefrom)
3319  {
3320  IEntity ent = m_pVicinity.GetItemOfInterest();
3321  if (ent)
3322  storagefrom = BaseInventoryStorageComponent.Cast(ent.FindComponent(BaseInventoryStorageComponent));
3323  }
3324 
3325  m_InventoryManager.InsertItem(pItem, m_pActiveHoveredStorageUI.GetCurrentNavigationStorage(), storagefrom, m_pCallBack); //a storage is already opened, try to move it there
3326  m_InventoryManager.PlayItemSound(pItem, SCR_SoundEvent.SOUND_PICK_UP);
3327  }
3328 
3329  //------------------------------------------------------------------------------------------------
3331  protected void MoveBetweenFromVicinity()
3332  {
3333  if (MoveBetweenFromVicinity_VirtualArsenal())
3334  return;
3335 
3336  IEntity pItem = m_pSelectedSlotUI.GetInventoryItemComponent().GetOwner();
3337  if (!m_InventoryManager.CanMoveItem(pItem))
3338  return;
3339 
3340  //~ Never send items to arsenal
3341  BaseInventoryStorageComponent storageTo = m_InventoryManager.FindStorageForItem(pItem, EStoragePurpose.PURPOSE_ANY);
3342  if (storageTo && storageTo.GetOwner().FindComponent(SCR_ArsenalComponent))
3343  return;
3344 
3345  m_pCallBack.m_pItem = pItem;
3346  m_pCallBack.m_pMenu = this;
3347 
3348  InventoryStorageSlot parentSlotFrom = m_pSelectedSlotUI.GetInventoryItemComponent().GetParentSlot();
3349  BaseInventoryStorageComponent storageFrom;
3350  if (parentSlotFrom)
3351  storageFrom = parentSlotFrom.GetStorage();
3352 
3353  if (!storageFrom)
3354  storageFrom = m_pStorageLootUI.GetCurrentNavigationStorage();
3355 
3356  m_pCallBack.m_pStorageFrom = GetStorageUIByBaseStorageComponent(storageFrom);
3357  m_pCallBack.m_pStorageTo = m_pStorageListUI;
3358  m_pCallBack.m_pStorageToFocus = m_pSelectedSlotUI.GetStorageUI();
3359  m_pCallBack.m_sItemToFocus = m_pSelectedSlotUI.GetItemResource();
3360  m_pCallBack.m_iSlotToFocus = m_pFocusedSlotUI.GetStorageUI().GetFocusedSlotId();
3361  m_pCallBack.m_bUpdateSlotOnly = m_pSelectedSlotUI.IsStacked();
3362 
3363  BaseInventoryStorageComponent pStorageTo = m_StorageManager;
3364  if ( pItem.FindComponent( SCR_GadgetComponent ) )
3365  {
3366  BaseInventoryStorageComponent pStorageComp = m_InventoryManager.FindStorageForItem( pItem, EStoragePurpose.PURPOSE_EQUIPMENT_ATTACHMENT );
3367  if ( pStorageComp )
3368  pStorageTo = pStorageComp;
3369  else
3370  {
3371  pStorageComp = m_InventoryManager.FindStorageForItem( pItem, EStoragePurpose.PURPOSE_DEPOSIT );
3372  if ( pStorageComp )
3373  pStorageTo = pStorageComp;
3374  }
3375  }
3376 
3377  if (ShouldSpawnItem())
3378  {
3379  m_pCallBack.m_bUpdateSlotOnly = true;
3380  m_InventoryManager.TrySpawnPrefabToStorage(pItem.GetPrefabData().GetPrefabName(), null, -1, EStoragePurpose.PURPOSE_ANY, m_pCallBack);
3381  m_InventoryManager.PlayItemSound(pItem, SCR_SoundEvent.SOUND_PICK_UP);
3382  return;
3383  }
3384 
3385  BaseInventoryStorageComponent isStorage = BaseInventoryStorageComponent.Cast(pItem.FindComponent(BaseInventoryStorageComponent));
3386  if (isStorage)
3387  m_pCallBack.m_pStorageToPickUp = isStorage;
3388 
3389  m_InventoryManager.InsertItem( pItem, null, m_pStorageLootUI.GetCurrentNavigationStorage(), m_pCallBack );
3390  }
3391 
3392  //------------------------------------------------------------------------------------------------
3393  protected bool ShouldSpawnItem()
3394  {
3395  if (!m_pSelectedSlotUI)
3396  return false;
3397  if (!m_pSelectedSlotUI.GetStorageUI())
3398  return false;
3399 
3400  BaseInventoryStorageComponent currStorage = m_pSelectedSlotUI.GetStorageUI().GetCurrentNavigationStorage();
3401  return IsStorageArsenal(currStorage);
3402  }
3403 
3404  //------------------------------------------------------------------------------------------------
3405  protected bool IsStorageArsenal(BaseInventoryStorageComponent storage)
3406  {
3407  if (!storage)
3408  return false;
3409  return (storage.GetOwner().FindComponent(SCR_ArsenalComponent) != null);
3410  }
3411 
3412  //------------------------------------------------------------------------------------------------
3413  protected void EquipDraggedItem(bool forceEquip = false)
3414  {
3415  if (EquipDraggedItem_VirtualArsenal(forceEquip))
3416  return;
3417 
3418  if (!m_pSelectedSlotUI || !m_pSelectedSlotUI.GetInventoryItemComponent())
3419  return;
3420 
3421  IEntity pItem = m_pSelectedSlotUI.GetInventoryItemComponent().GetOwner();
3422  if (!pItem)
3423  return;
3424 
3425  m_pCallBack.m_pItem = pItem;
3426  m_pCallBack.m_pMenu = this;
3427  m_pCallBack.m_pStorageFrom = m_pSelectedSlotUI.GetStorageUI();
3428 
3429  m_pCallBack.m_pStorageToFocus = m_pSelectedSlotUI.GetStorageUI();
3430  m_pCallBack.m_sItemToFocus = m_pSelectedSlotUI.GetItemResource();
3431  m_pCallBack.m_bShouldEquip = forceEquip;
3432 
3433  BaseInventoryStorageComponent pStorageTo = m_StorageManager;
3434  if (m_pSelectedSlotUI.GetStorageUI().Type() == SCR_InventoryStorageWeaponsUI)
3435  {
3436  m_pCallBack.m_pStorageTo = m_pWeaponStorage;
3437  }
3438  else
3439  {
3440  m_pCallBack.m_pStorageTo = m_pStorageListUI;
3441  }
3442 
3443  if (pItem.FindComponent(SCR_GadgetComponent))
3444  {
3445  BaseInventoryStorageComponent pStorageComp = m_InventoryManager.FindStorageForItem( pItem, EStoragePurpose.PURPOSE_EQUIPMENT_ATTACHMENT );
3446  if (pStorageComp)
3447  pStorageTo = pStorageComp;
3448  else
3449  {
3450  pStorageComp = m_InventoryManager.FindStorageForItem(pItem, EStoragePurpose.PURPOSE_DEPOSIT);
3451  if (pStorageComp)
3452  pStorageTo = pStorageComp;
3453  }
3454  }
3455 
3456  if (pItem.FindComponent(WeaponComponent))
3457  {
3458  BaseInventoryStorageComponent pStorageComp = m_InventoryManager.FindStorageForItem(pItem, EStoragePurpose.PURPOSE_WEAPON_PROXY);
3459  if (pStorageComp)
3460  pStorageTo = pStorageComp;
3461  else
3462  {
3463  pStorageComp = m_InventoryManager.FindStorageForItem(pItem, EStoragePurpose.PURPOSE_DEPOSIT);;
3464  if (pStorageComp)
3465  pStorageTo = pStorageComp;
3466  }
3467  }
3468 
3469  bool equip = m_InventoryManager.EquipAny(pStorageTo , pItem, 0, m_pCallBack);
3470  if (!equip && m_pSelectedSlotUI)
3471  {
3472  m_InventoryManager.InsertItem(pItem, null, m_pSelectedSlotUI.GetStorageUI().GetCurrentNavigationStorage(), m_pCallBack);
3473  }
3474  else
3475  {
3476  m_InventoryManager.PlayItemSound(pItem, SCR_SoundEvent.SOUND_EQUIP);
3477  }
3478  }
3479 
3480  //------------------------------------------------------------------------------------------------
3482  protected void MoveBetweenToVicinity()
3483  {
3484  InventoryItemComponent pInvComponent = m_pFocusedSlotUI.GetInventoryItemComponent();
3485  if(!pInvComponent)
3486  return;
3487 
3488  IEntity pItem = pInvComponent.GetOwner();
3489  if (!m_InventoryManager.CanMoveItem(pItem))
3490  return;
3491 
3492  m_pCallBack.m_pItem = pItem;
3493  m_pCallBack.m_pMenu = this;
3494 
3495  m_pCallBack.m_pStorageToFocus = GetStorageUIByBaseStorageComponent(m_pSelectedSlotUI.GetStorageUI().GetCurrentNavigationStorage());
3496  m_pCallBack.m_sItemToFocus = m_pSelectedSlotUI.GetItemResource();
3497  m_pCallBack.m_iSlotToFocus = m_pFocusedSlotUI.GetStorageUI().GetFocusedSlotId();
3498  m_pCallBack.m_bUpdateSlotOnly = m_pSelectedSlotUI.IsStacked();
3499 
3500  if (MoveBetweenToVicinity_VirtualArsenal())
3501  return;
3502 
3503  MoveToVicinity( pItem );
3504  }
3505 
3506  //------------------------------------------------------------------------------------------------
3507  protected bool MoveBetweenToVicinity_VirtualArsenal()
3508  {
3509  BaseInventoryStorageComponent storageComponent = m_pStorageLootUI.GetCurrentNavigationStorage();
3510 
3511  if (!storageComponent && m_aOpenedStoragesUI)
3512  {
3514  foreach (SCR_InventoryOpenedStorageUI storageUI: m_aOpenedStoragesUI)
3515  {
3516  if (!SCR_InventoryOpenedStorageArsenalUI.Cast(storageUI))
3517  continue;
3518 
3519  storageComponent = storageUI.GetStorage();
3520 
3521  if (storageComponent)
3522  break;
3523  }
3524  }
3525 
3526  if (!storageComponent || !IsStorageArsenal(storageComponent))
3527  return false;
3528 
3530  IEntity arsenalEntity = storageComponent.GetOwner();
3531  InventoryItemComponent inventoryItemComponent = m_pSelectedSlotUI.GetInventoryItemComponent();
3532  SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.FindResourceComponent(arsenalEntity);
3534 
3535  if (!resourceInventoryComponent)
3536  return false;
3537 
3538  resourceInventoryComponent.Rpc(resourceInventoryComponent.RpcAsk_ArsenalRefundItem, Replication.FindId(resourceComponent), Replication.FindId(inventoryItemComponent), EResourceType.SUPPLIES);
3539 
3540  return true;
3541  }
3542 
3543  //------------------------------------------------------------------------------------------------
3544  protected bool MoveItem_VirtualArsenal(inout SCR_InventoryStorageBaseUI pStorageBaseUI = null)
3545  {
3546  SCR_ArsenalInventorySlotUI arsenalInventorySlotUI;
3547 
3548  if (m_pSelectedSlotUI)
3549  arsenalInventorySlotUI = SCR_ArsenalInventorySlotUI.Cast(m_pSelectedSlotUI);
3550  else
3551  return false;
3552 
3553  if (!arsenalInventorySlotUI)
3554  {
3555  if (m_pActiveHoveredStorageUI)
3556  return false;
3557 
3559  BaseInventoryStorageComponent storageComponent = m_pStorageLootUI.GetCurrentNavigationStorage();
3560 
3561  if (!storageComponent)
3562  storageComponent = m_pActiveHoveredStorageUI.GetStorage();
3563 
3564  if (!storageComponent || !IsStorageArsenal(storageComponent) )
3565  return false;
3566 
3567  IEntity arsenalEntity = storageComponent.GetOwner();
3568  InventoryItemComponent inventoryItemComponent = m_pSelectedSlotUI.GetInventoryItemComponent();
3569  SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.FindResourceComponent(arsenalEntity);
3571  //BaseInventoryStorageComponent physicalItemStorage = inventoryItemComponent.GetParentSlot().GetStorage();
3572 
3573  resourceInventoryComponent.Rpc(resourceInventoryComponent.RpcAsk_ArsenalRefundItem, Replication.FindId(resourceComponent), Replication.FindId(inventoryItemComponent), EResourceType.SUPPLIES);
3574 
3575  /*
3576  if (!physicalItemStorage)
3577  return true;
3578 
3579  SCR_InventoryStorageBaseUI storageUI = GetStorageUIByBaseStorageComponent(physicalItemStorage);
3580 
3581  if (!storageUI)
3582  return true;
3583 
3584  storageUI.Refresh();
3585  */
3586 
3587  return true;
3588  }
3589 
3590  BaseInventoryStorageComponent storageComponent = m_pActiveHoveredStorageUI.GetCurrentNavigationStorage();
3591 
3592  if (arsenalInventorySlotUI && storageComponent.GetOwner().FindComponent(SCR_ArsenalInventoryStorageManagerComponent))
3593  return true;
3594 
3595  SCR_InventoryStorageManagerComponent invManagerTo = m_pActiveHoveredStorageUI.GetInventoryManager();
3596  BaseInventoryStorageComponent storageTo = m_pActiveHoveredStorageUI.GetStorage();
3597  IEntity arsenalEntity = SCR_InventoryStorageBaseUI.ARSENAL_SLOT_STORAGES.Get(arsenalInventorySlotUI);
3598  SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.FindResourceComponent(arsenalEntity);
3599  ResourceName resourceName = arsenalInventorySlotUI.GetItemResource();
3601 
3602  if (invManagerTo.CanInsertItemInStorage(arsenalInventorySlotUI.GetInventoryItemComponent().GetOwner(), storageTo))
3603  resourceInventoryComponent.Rpc(resourceInventoryComponent.RpcAsk_ArsenalRequestItem, Replication.FindId(resourceComponent), Replication.FindId(invManagerTo), Replication.FindId(storageTo), resourceName, EResourceType.SUPPLIES);
3604 
3605  return true;
3606  }
3607 
3608  //------------------------------------------------------------------------------------------------
3609  protected bool EquipWeaponIntoWeaponSlot_VirtualArsenal()
3610  {
3611  SCR_ArsenalInventorySlotUI arsenalInventorySlotUI;
3612 
3613  if (m_pSelectedSlotUI)
3614  arsenalInventorySlotUI = SCR_ArsenalInventorySlotUI.Cast(m_pSelectedSlotUI);
3615  else if (!m_pSelectedSlotUI || !arsenalInventorySlotUI)
3616  return false;
3617 
3618  SCR_InventorySlotWeaponSlotsUI weaponSlot = SCR_InventorySlotWeaponSlotsUI.Cast(m_pFocusedSlotUI);
3619 
3620  if (!weaponSlot)
3621  return false;
3622 
3623  SCR_InventoryStorageManagerComponent invManagerTo = weaponSlot.GetStorageUI().GetInventoryManager();
3624  BaseInventoryStorageComponent storageTo = weaponSlot.GetStorageUI().GetStorage();
3625  IEntity arsenalEntity = SCR_InventoryStorageBaseUI.ARSENAL_SLOT_STORAGES.Get(arsenalInventorySlotUI);
3626  if (!arsenalEntity)
3627  return false;
3628  SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.FindResourceComponent(arsenalEntity);
3629  ResourceName resourceName = arsenalInventorySlotUI.GetItemResource();
3631 
3632  if (invManagerTo.CanInsertItemInStorage(arsenalInventorySlotUI.GetInventoryItemComponent().GetOwner(), storageTo))
3633  resourceInventoryComponent.Rpc(resourceInventoryComponent.RpcAsk_ArsenalRequestItem, Replication.FindId(resourceComponent), Replication.FindId(invManagerTo), Replication.FindId(storageTo), resourceName, EResourceType.SUPPLIES);
3634 
3635  return true;
3636  }
3637 
3638  //------------------------------------------------------------------------------------------------
3643  protected bool MoveItemToStorageSlot_VirtualArsenal()
3644  {
3645  SCR_ArsenalInventorySlotUI arsenalInventorySlotUI;
3646 
3647  if (m_pSelectedSlotUI)
3648  arsenalInventorySlotUI = SCR_ArsenalInventorySlotUI.Cast(m_pSelectedSlotUI);
3649  else
3650  return false;
3651 
3652  if (!arsenalInventorySlotUI)
3653  {
3654  // If the slot was dragged onto a non arsenal slot then do not process virtual arsenal.
3655  if (!SCR_ArsenalInventorySlotUI.Cast(m_pFocusedSlotUI))
3656  return false;
3657 
3659  BaseInventoryStorageComponent storageComponent = m_pStorageLootUI.GetCurrentNavigationStorage();
3660 
3661  if (!storageComponent)
3662  storageComponent = m_pActiveHoveredStorageUI.GetStorage();
3663 
3664  if (!storageComponent || !IsStorageArsenal(storageComponent) )
3665  return false;
3666 
3667  IEntity arsenalEntity = storageComponent.GetOwner();
3668  InventoryItemComponent inventoryItemComponent = m_pSelectedSlotUI.GetInventoryItemComponent();
3669  SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.FindResourceComponent(arsenalEntity);
3671 
3672  resourceInventoryComponent.Rpc(resourceInventoryComponent.RpcAsk_ArsenalRefundItem, Replication.FindId(resourceComponent), Replication.FindId(inventoryItemComponent), EResourceType.SUPPLIES);
3673 
3674  return true;
3675  }
3676 
3677  /*
3678  Do nothing but exit as successful because of dragging arsenal virtual item into another
3679  arsenal virtual item.
3680  */
3681  if (SCR_ArsenalInventorySlotUI.Cast(m_pFocusedSlotUI))
3682  return true;
3683 
3684  SCR_InventoryStorageManagerComponent invManagerTo = m_pFocusedSlotUI.GetStorageUI().GetInventoryManager();
3685  BaseInventoryStorageComponent storageTo = m_pFocusedSlotUI.GetStorageUI().GetStorage();
3686  IEntity arsenalEntity = SCR_InventoryStorageBaseUI.ARSENAL_SLOT_STORAGES.Get(arsenalInventorySlotUI);
3687  SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.FindResourceComponent(arsenalEntity);
3688  ResourceName resourceName = arsenalInventorySlotUI.GetItemResource();
3690 
3691  if (invManagerTo.CanInsertItemInStorage(arsenalInventorySlotUI.GetInventoryItemComponent().GetOwner(), storageTo))
3692  resourceInventoryComponent.Rpc(resourceInventoryComponent.RpcAsk_ArsenalRequestItem, Replication.FindId(resourceComponent), Replication.FindId(invManagerTo), Replication.FindId(storageTo), resourceName, EResourceType.SUPPLIES);
3693 
3694  return true;
3695  }
3696 
3697  //------------------------------------------------------------------------------------------------
3698  protected bool EquipDraggedItem_VirtualArsenal(bool forceEquip = false)
3699  {
3700  SCR_ArsenalInventorySlotUI arsenalInventorySlotUI;
3701 
3702  if (m_pSelectedSlotUI)
3703  arsenalInventorySlotUI = SCR_ArsenalInventorySlotUI.Cast(m_pSelectedSlotUI);
3704 
3705  if (!m_pSelectedSlotUI || !arsenalInventorySlotUI)
3706  return false;
3707 
3708  SCR_InventoryStorageManagerComponent invManagerTo = m_InventoryManager;
3709  IEntity slotEntity = arsenalInventorySlotUI.GetInventoryItemComponent().GetOwner();
3710  BaseInventoryStorageComponent storageTo = m_InventoryManager.FindStorageForItem(slotEntity, EStoragePurpose.PURPOSE_ANY);
3711  IEntity arsenalEntity = SCR_InventoryStorageBaseUI.ARSENAL_SLOT_STORAGES.Get(arsenalInventorySlotUI);
3712  SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.FindResourceComponent(arsenalEntity);
3713  ResourceName resourceName = arsenalInventorySlotUI.GetItemResource();
3715 
3716  if (invManagerTo.CanInsertItemInStorage(slotEntity, storageTo))
3717  resourceInventoryComponent.Rpc(resourceInventoryComponent.RpcAsk_ArsenalRequestItem, Replication.FindId(resourceComponent), Replication.FindId(invManagerTo), Replication.FindId(storageTo), resourceName, EResourceType.SUPPLIES);
3718 
3719  return true;;
3720  }
3721 
3722  //------------------------------------------------------------------------------------------------
3723  protected bool MoveBetweenFromVicinity_VirtualArsenal()
3724  {
3725  SCR_ArsenalInventorySlotUI arsenalInventorySlotUI;
3726 
3727  if (m_pSelectedSlotUI)
3728  arsenalInventorySlotUI = SCR_ArsenalInventorySlotUI.Cast(m_pSelectedSlotUI);
3729 
3730  if (!m_pSelectedSlotUI || !arsenalInventorySlotUI)
3731  return false;
3732 
3733  SCR_InventoryStorageManagerComponent invManagerTo = m_InventoryManager;
3734  IEntity slotEntity = arsenalInventorySlotUI.GetInventoryItemComponent().GetOwner();
3735  BaseInventoryStorageComponent storageTo = m_InventoryManager.FindStorageForItem(slotEntity, EStoragePurpose.PURPOSE_ANY);
3736  IEntity arsenalEntity = SCR_InventoryStorageBaseUI.ARSENAL_SLOT_STORAGES.Get(arsenalInventorySlotUI);
3737  SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.FindResourceComponent(arsenalEntity);
3738  ResourceName resourceName = arsenalInventorySlotUI.GetItemResource();
3740 
3741  if (invManagerTo.CanInsertItemInStorage(slotEntity, storageTo))
3742  resourceInventoryComponent.Rpc(resourceInventoryComponent.RpcAsk_ArsenalRequestItem, Replication.FindId(resourceComponent), Replication.FindId(invManagerTo), Replication.FindId(storageTo), resourceName, EResourceType.SUPPLIES);
3743 
3744  return true;;
3745  }
3746 
3747  //------------------------------------------------------------------------------------------------
3748  protected bool MoveItem_ResourceContainer(inout SCR_InventoryStorageBaseUI pStorageBaseUI = null)
3749  {
3750  if (!m_pSelectedSlotUI)
3751  return false;
3752 
3753  IEntity draggedEntity = m_pSelectedSlotUI.GetInventoryItemComponent().GetOwner();
3754 
3755  if (!draggedEntity)
3756  return false;
3757 
3758  SCR_ResourceComponent resourceComponentFrom = SCR_ResourceComponent.FindResourceComponent(draggedEntity);
3759 
3760  if (!resourceComponentFrom)
3761  return false;
3762 
3763  //~ TODO: Hotfix until proper solution, block moving supplies if occupied by character
3764  SCR_BaseCompartmentManagerComponent compartmentManager = SCR_BaseCompartmentManagerComponent.Cast(resourceComponentFrom.GetOwner().FindComponent(SCR_BaseCompartmentManagerComponent));
3765  if (compartmentManager && compartmentManager.BlockSuppliesIfOccupied() && compartmentManager.GetOccupantCount() > 0)
3766  return false;
3767 
3768  if (!m_pActiveHoveredStorageUI)
3769  return false;
3770 
3771  SCR_InventoryStorageManagerComponent invManagerTo = m_pActiveHoveredStorageUI.GetInventoryManager();
3772 
3773  if (!invManagerTo)
3774  return false;
3775 
3776  SCR_ResourceInteractor interactorFrom = resourceComponentFrom.GetConsumer(EResourceGeneratorID.DEFAULT_STORAGE, EResourceType.SUPPLIES);
3777 
3778  if (!interactorFrom)
3779  interactorFrom = resourceComponentFrom.GetConsumer(EResourceGeneratorID.VEHICLE_UNLOAD, EResourceType.SUPPLIES);
3780 
3781  if (!interactorFrom)
3782  return false;
3783 
3784  BaseInventoryStorageComponent storageTo = m_pActiveHoveredStorageUI.GetStorage();
3785 
3787  if (!storageTo)
3788  {
3789  SCR_EntityCatalog resourceContainerCatalog = SCR_EntityCatalogManagerComponent.GetInstance().GetEntityCatalogOfType(EEntityCatalogType.SUPPLY_CONTAINER_ITEM);
3790  array<SCR_EntityCatalogEntry> entries = {};
3791  array<SCR_BaseEntityCatalogData> data = {};
3792 
3793  resourceContainerCatalog.GetEntityListWithData(SCR_ResourceContainerItemData, entries, data);
3794 
3796  float maxStoredResources = Math.Min(interactorFrom.GetAggregatedResourceValue(), datum.GetMaxResourceValue());
3797 
3798  if (maxStoredResources <= 0)
3799  return true;
3800 
3801  CreateItemSplitDialog(maxStoredResources, null, draggedEntity);
3802 
3803  return true;
3804  }
3805 
3806  IEntity targetEntity = storageTo.GetOwner();
3807  if (!targetEntity)
3808  return false;
3809 
3810  SCR_ResourceComponent targetResourceComponent = SCR_ResourceComponent.FindResourceComponent(targetEntity);
3811 
3814  if (targetResourceComponent)
3815  return MoveItemToStorageSlot_ResourceContainer();
3816 
3819  if (draggedEntity == targetEntity || resourceComponentFrom == targetResourceComponent)
3820  return true;
3821 
3822  SCR_EntityCatalog resourceContainerCatalog = SCR_EntityCatalogManagerComponent.GetInstance().GetEntityCatalogOfType(EEntityCatalogType.SUPPLY_CONTAINER_ITEM);
3823  array<SCR_EntityCatalogEntry> entries = {};
3824  array<SCR_BaseEntityCatalogData> data = {};
3825  float maxResourceValueTo = 0.0;
3826 
3827  resourceContainerCatalog.GetEntityListWithData(SCR_ResourceContainerItemData, entries, data);
3828 
3829  foreach (int idx, SCR_EntityCatalogEntry entry: entries)
3830  {
3832 
3833  if (invManagerTo.CanInsertResourceInStorage(entry.GetPrefab(), storageTo))
3834  {
3835  maxResourceValueTo = datum.GetMaxResourceValue();
3836  break;
3837  }
3838  }
3839 
3840  float maxStoredResources = Math.Min(interactorFrom.GetAggregatedResourceValue(), maxResourceValueTo);
3841 
3842  if (maxStoredResources <= 0)
3843  return true;
3844 
3845  CreateItemSplitDialog(maxStoredResources, targetEntity, draggedEntity);
3846 
3847  return true;
3848  }
3849 
3850  //------------------------------------------------------------------------------------------------
3851  protected bool MoveItemToStorageSlot_ResourceContainer()
3852  {
3853  if (!m_pSelectedSlotUI)
3854  return false;
3855 
3856  IEntity draggedEntity = m_pSelectedSlotUI.GetInventoryItemComponent().GetOwner();
3857 
3858  if (!draggedEntity)
3859  return false;
3860 
3861  SCR_ResourceComponent resourceComponentFrom = SCR_ResourceComponent.FindResourceComponent(draggedEntity);
3862 
3863  if (!resourceComponentFrom)
3864  return false;
3865 
3866  IEntity targetEntity;
3867 
3868  if (m_pFocusedSlotUI && m_pFocusedSlotUI.GetInventoryItemComponent())
3869  targetEntity = m_pFocusedSlotUI.GetInventoryItemComponent().GetOwner();
3870  else if (m_pActiveHoveredStorageUI && m_pActiveHoveredStorageUI.GetStorage())
3871  targetEntity = m_pActiveHoveredStorageUI.GetStorage().GetOwner();
3872 
3873  if (!targetEntity)
3874  return false;
3875 
3876  SCR_ResourceComponent resourceComponentTo = SCR_ResourceComponent.FindResourceComponent(targetEntity);
3877 
3878  if (!resourceComponentTo)
3879  return false;
3880 
3881  //~ TODO: Hotfix until proper solution, block moving supplies if occupied by character
3882  SCR_BaseCompartmentManagerComponent compartmentManager = SCR_BaseCompartmentManagerComponent.Cast(resourceComponentTo.GetOwner().FindComponent(SCR_BaseCompartmentManagerComponent));
3883  if (compartmentManager && compartmentManager.BlockSuppliesIfOccupied() && compartmentManager.GetOccupantCount() > 0)
3884  return false;
3885 
3886  SCR_ResourceInteractor interactorFrom = resourceComponentFrom.GetConsumer(EResourceGeneratorID.DEFAULT_STORAGE, EResourceType.SUPPLIES);
3887 
3888  if (!interactorFrom)
3889  interactorFrom = resourceComponentFrom.GetConsumer(EResourceGeneratorID.VEHICLE_UNLOAD, EResourceType.SUPPLIES);
3890 
3891  if (!interactorFrom)
3892  return false;
3893 
3894  SCR_ResourceInteractor interactorTo = resourceComponentTo.GetConsumer(EResourceGeneratorID.DEFAULT_STORAGE, EResourceType.SUPPLIES);
3895 
3896  if (!interactorTo)
3897  interactorTo = resourceComponentTo.GetGenerator(EResourceGeneratorID.VEHICLE_LOAD, EResourceType.SUPPLIES);
3898 
3899  if (!interactorTo)
3900  return false;
3901 
3904  if (m_pSelectedSlotUI == m_pFocusedSlotUI)
3905  return true;
3906 
3907  float maxStoredResources = Math.Min(interactorFrom.GetAggregatedResourceValue(), interactorTo.GetAggregatedMaxResourceValue() - interactorTo.GetAggregatedResourceValue());
3908 
3909  if (maxStoredResources <= 0)
3910  return true;
3911 
3912  CreateItemSplitDialog(maxStoredResources, targetEntity, draggedEntity);
3913 
3914  return true;
3915  }
3916 
3917  //------------------------------------------------------------------------------------------------
3918  void DeselectSlot()
3919  {
3920  if (m_pSelectedSlotUI)
3921  {
3922  m_pSelectedSlotUI.SetSelected(false);
3923  m_pSelectedSlotUI = null;
3924  }
3925  }
3926 
3927  //------------------------------------------------------------------------------------------------
3929  protected void HandleItemSelection()
3930  {
3931  if ( m_pFocusedSlotUI && m_pSelectedSlotUI && m_pFocusedSlotUI != m_pSelectedSlotUI )
3932  {
3933  if ( m_bDraggingEnabled )
3934  {
3935  m_pFocusedSlotUI.SetSelected( true ); //select new one
3936  m_pSelectedSlotUI.SetSelected( false ); //deselect the previous one
3937  m_pSelectedSlotUI = m_pFocusedSlotUI; //and register the newly selected
3938  FilterOutStorages( true );
3939  m_EStateMenuItem = EStateMenuItem.STATE_MOVING_ITEM_STARTED;
3940  }
3941  }
3942  else
3943  {
3944  if ( m_bDraggingEnabled )
3945  {
3946  if ( m_pSelectedSlotUI )
3947  m_pSelectedSlotUI.SetSelected( false ); //deselect it
3948  m_pSelectedSlotUI = null; //and deregister it
3949  FilterOutStorages( false );
3950  m_EStateMenuItem = EStateMenuItem.STATE_IDLE;
3951  }
3952  }
3953  }
3954 
3955  //------------------------------------------------------------------------------------------------
3956  void SetOpenStorage()
3957  {
3958  IEntity m_pStorageToOpen = GetInventoryStorageManager().GetStorageToOpen();
3959 
3960  if (!m_pStorageToOpen)
3961  {
3962  SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_INV_OPEN);
3963  return;
3964  }
3965 
3966  BaseInventoryStorageComponent comp = BaseInventoryStorageComponent.Cast(m_pStorageToOpen.FindComponent(BaseInventoryStorageComponent));
3967 
3968  if (!comp)
3969  return;
3970 
3971  SCR_InventoryStorageBaseUI storageUI = GetStorageUIFromVicinity(comp);
3972 
3973  if (!storageUI)
3974  return;
3975 
3976  if (storageUI.IsTraversalAllowed())
3977  storageUI.Traverse(comp);
3978 
3979  SetStorageSwitchMode(false);
3980 
3981  ButtonWidget lastCloseTraverseButton = storageUI.GetLastCloseTraverseButton();
3982 
3983  if (m_bIsUsingGamepad && lastCloseTraverseButton && !CanFocusOnSlotInStorage(storageUI, 0))
3984  GetGame().GetWorkspace().SetFocusedWidget(lastCloseTraverseButton);
3985  else
3986  FocusOnSlotInStorage(storageUI);
3987  }
3988 
3989  //------------------------------------------------------------------------------------------------
3991  protected void TraverseActualSlot()
3992  {
3993  m_pSelectedSlotUI = m_pFocusedSlotUI;
3994  auto storage = m_pFocusedSlotUI.GetAsStorage();
3995  if (storage)
3996  {
3997  SCR_InventoryStorageBaseUI parentUIContainer = m_pFocusedSlotUI.GetStorageUI();
3998 
3999  if (parentUIContainer.IsTraversalAllowed() && ShouldAllowTraverseActualSlot())
4000  parentUIContainer.Traverse(storage);
4001 
4002  ButtonWidget lastCloseTraverseButton = parentUIContainer.GetLastCloseTraverseButton();
4003 
4004  if (m_bIsUsingGamepad && lastCloseTraverseButton && !CanFocusOnSlotInStorage(parentUIContainer, 0))
4005  GetGame().GetWorkspace().SetFocusedWidget(lastCloseTraverseButton);
4006  else
4007  FocusOnSlotInStorage(parentUIContainer);
4008  }
4009  }
4010 
4011  //------------------------------------------------------------------------------------------------
4014  protected bool ShouldAllowTraverseActualSlot()
4015  {
4016  InventoryItemComponent inventoryItemComponent = m_pSelectedSlotUI.GetInventoryItemComponent();
4017 
4018  // Check if the selected slot is an arsenal, and if it's in some inventory item then disallow traverse.
4019  if (inventoryItemComponent && inventoryItemComponent.GetParentSlot() && inventoryItemComponent.GetOwner().FindComponent(SCR_ArsenalInventoryStorageManagerComponent))
4020  return false;
4021 
4022  return true;
4023  }
4024 
4025  //------------------------------------------------------------------------------------------------
4026  protected void OpenAsNewContainer()
4027  {
4028  m_pSelectedSlotUI = m_pFocusedSlotUI;
4029  auto storage = m_pFocusedSlotUI.GetAsStorage();
4030  if (storage)
4031  {
4032  OpenStorageAsContainer(storage);
4033  OpenLinkedStorages(storage);
4034  }
4035  }
4036 
4037  //------------------------------------------------------------------------------------------------
4043  void OpenLinkedStorages(BaseInventoryStorageComponent parentStorage, bool showVicinity = true, bool hideCloseButton = true)
4044  {
4046  if (!scrStorage)
4047  return;
4048 
4049  OpenLinkedStoragesDelayed(scrStorage, showVicinity, hideCloseButton);
4050 
4051  //~ Call the actual open linked storages 1 frame later so it can check properly if the storages it should open are already open
4052  //GetGame().GetCallqueue().CallLater(OpenLinkedStoragesDelayed, param1: scrStorage, param2: showVicinity, param3: hideCloseButton);
4053  }
4054 
4055  //------------------------------------------------------------------------------------------------
4056  //~ Don't call directly. Call OpenLinkedStorages() instead!
4057  protected void OpenLinkedStoragesDelayed(SCR_UniversalInventoryStorageComponent scrStorage, bool showVicinity = true, bool hideCloseButton = true)
4058  {
4059  array<BaseInventoryStorageComponent> linkedStorages = {};
4060  if (scrStorage.GetLinkedStorages(linkedStorages) <= 0)
4061  return;
4062 
4063  bool alreadyOpen;
4064 
4065  foreach (BaseInventoryStorageComponent linkedStorage : linkedStorages)
4066  {
4067  //~ Storage is already open by means of traversal
4068  if (m_pStorageLootUI && m_pStorageLootUI.GetCurrentNavigationStorage() == linkedStorage)
4069  continue;
4070 
4071  alreadyOpen = false;
4072 
4073  foreach (SCR_InventoryOpenedStorageUI openedStorage : m_aOpenedStoragesUI)
4074  {
4075  //~ Already open
4076  if (openedStorage.GetStorage() == linkedStorage)
4077  {
4078  alreadyOpen = true;
4079  break;
4080  }
4081  }
4082 
4083  if (alreadyOpen)
4084  continue;
4085 
4086  OpenStorageAsContainer(linkedStorage, showVicinity, hideCloseButton);
4087  }
4088  }
4089 
4090  //------------------------------------------------------------------------------------------------
4095  void CloseLinkedStorages(BaseInventoryStorageComponent parentStorage)
4096  {
4098  if (!scrStorage)
4099  return;
4100 
4101  //~ Call the actual close linked storages 1 frame later so it can check if the parent storage is still open via container or traversal
4102  GetGame().GetCallqueue().CallLater(CloseLinkedStoragesDelayed, param1: scrStorage);
4103  }
4104 
4105  //------------------------------------------------------------------------------------------------
4106  //~ Don't call directly. Call CloseLinkedStorages() instead!
4107  protected void CloseLinkedStoragesDelayed(SCR_UniversalInventoryStorageComponent scrStorage)
4108  {
4109  array<BaseInventoryStorageComponent> linkedStorages = {};
4110  if (scrStorage.GetLinkedStorages(linkedStorages) <= 0)
4111  return;
4112 
4113  //~ Trying to close linked storages but the parent storage is still open via traversal
4114  if (m_pStorageLootUI && m_pStorageLootUI.GetCurrentNavigationStorage() == scrStorage)
4115  return;
4116 
4117  //~ Trying to close linked storages but the parent storage is still open as a container
4118  foreach (SCR_InventoryOpenedStorageUI openedStorage : m_aOpenedStoragesUI)
4119  {
4120  if (openedStorage.GetStorage() == scrStorage)
4121  return;
4122  }
4123 
4124  //~ Close each linked storage that is open
4125  foreach (BaseInventoryStorageComponent linkedStorage : linkedStorages)
4126  {
4127  foreach (SCR_InventoryOpenedStorageUI openedStorage : m_aOpenedStoragesUI)
4128  {
4129  //~ Storage is open
4130  if (openedStorage.GetStorage() == linkedStorage)
4131  {
4132  RemoveOpenStorage(openedStorage);
4133  break;
4134  }
4135  }
4136  }
4137  }
4138 
4139  //------------------------------------------------------------------------------------------------
4141  protected void Action_SelectItem()
4142  {
4143  // Ignore if we cannot interact
4144  if (!GetCanInteract())
4145  return;
4146  SimpleFSM( EMenuAction.ACTION_SELECT );
4147  }
4148 
4149  //------------------------------------------------------------------------------------------------
4150  void Action_DeselectItem()
4151  {
4152  SimpleFSM(EMenuAction.ACTION_DESELECT);
4153  ResetHighlightsOnAvailableStorages();
4154  }
4155 
4156  //------------------------------------------------------------------------------------------------
4157  protected void Action_MoveInsideStorage()
4158  {
4159  SimpleFSM(EMenuAction.ACTION_MOVEINSIDE);
4160  ResetHighlightsOnAvailableStorages();
4161  }
4162 
4163  //------------------------------------------------------------------------------------------------
4164  protected void Action_EquipItem()
4165  {
4166  if (m_pFocusedSlotUI)
4167  m_pFocusedSlotUI.UseItem(m_Player);
4168  }
4169 
4170  //------------------------------------------------------------------------------------------------
4171  protected void Action_MoveBetween()
4172  {
4173  // Ignore if we cannot interact
4174  if (!GetCanInteract())
4175  return;
4176  SimpleFSM( EMenuAction.ACTION_MOVEBETWEEN );
4177  ResetHighlightsOnAvailableStorages();
4178  }
4179 
4180  //------------------------------------------------------------------------------------------------
4181  void Action_Inspect()
4182  {
4183  if (m_pFocusedSlotUI == m_pInspectedSlot)
4184  InspectItem(null);
4185  else
4186  InspectItem(m_pFocusedSlotUI);
4187  }
4188 
4189  //------------------------------------------------------------------------------------------------
4191  protected void Action_UseItem()
4192  {
4193  if (m_pFocusedSlotUI)
4194  {
4195  // 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)
4196  SCR_InventoryHitZonePointContainerUI hzContainer = SCR_InventoryHitZonePointContainerUI.Cast(m_AttachmentSpinBox.GetCurrentItemData());
4197  if (hzContainer)
4198  {
4199  SCR_InventoryHitZoneUI hzStorage = hzContainer.GetStorage();
4200  if (!hzStorage)
4201  return;
4202 
4203  IEntity item = m_pFocusedSlotUI.GetInventoryItemComponent().GetOwner();
4204  if (!item)
4205  return;
4206 
4207  if (hzStorage.CanApplyItem(item))
4208  {
4209  hzStorage.OnDrop(m_pFocusedSlotUI);
4210  }
4211  else
4212  {
4213  hzContainer = null;
4214  hzStorage = null;
4215 
4216  for (int i = 0, max = m_AttachmentSpinBox.GetNumItems(); i < max; i++)
4217  {
4218  hzContainer = SCR_InventoryHitZonePointContainerUI.Cast(m_AttachmentSpinBox.GetItemData(i));
4219  if (!hzContainer)
4220  continue;
4221 
4222  hzStorage = hzContainer.GetStorage();
4223  if (hzStorage && hzStorage.CanApplyItem(item))
4224  hzStorage.OnDrop(m_pFocusedSlotUI)
4225  }
4226  }
4227  }
4228 
4229  SCR_InventorySlotGearInspectionUI point = SCR_InventorySlotGearInspectionUI.Cast(m_AttachmentSpinBox.GetCurrentItemData());
4230  if (point)
4231  {
4232  m_pGearInspectionPointUI.SetSlotFocused(point);
4233  point.OnDrop(m_pFocusedSlotUI);
4234  }
4235 
4236  if (!hzContainer || !point)
4237  {
4238  m_pFocusedSlotUI.UseItem(m_Player);
4239  }
4240  }
4241  }
4242 
4243  //------------------------------------------------------------------------------------------------
4245  protected void Action_UnfoldItem()
4246  {
4247  SimpleFSM( EMenuAction.ACTION_UNFOLD );
4248  }
4249 
4250  //------------------------------------------------------------------------------------------------
4251  void Action_StepBack(SCR_InventoryStorageBaseUI pParentStorage = null, int traverseStorageIndex = -1)
4252  {
4253  //TODO: m_pActiveStorageUI must be set according the active SCR_InventoryStorageBaseUI
4254  if (pParentStorage && pParentStorage.IsTraversalAllowed())
4255  {
4256  pParentStorage.Back(traverseStorageIndex);
4257  FilterOutStorages(false);
4258  m_EStateMenuItem = EStateMenuItem.STATE_IDLE;
4259  SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_INV_CONTAINER_CLOSE);
4260  FocusOnSlotInStorage(pParentStorage);
4261  m_bWasJustTraversing = true;
4262  }
4263  ResetHighlightsOnAvailableStorages();
4264  }
4265 
4266  //------------------------------------------------------------------------------------------------
4267  void Action_DragDown()
4268  {
4269  if ( m_bDraggingEnabled )
4270  return;
4271  if ( !m_pFocusedSlotUI )
4272  return;
4273  if (!m_pFocusedSlotUI.IsDraggable())
4274  return;
4275 
4276  if ( m_pFocusedSlotUI && WidgetManager.GetWidgetUnderCursor() != m_pFocusedSlotUI.GetButtonWidget() )
4277  return;
4278 
4279  if (m_pFocusedSlotUI.Type() != SCR_InventorySlotUI &&
4280  m_pFocusedSlotUI.Type() != SCR_InventorySlotLBSUI &&
4281  m_pFocusedSlotUI.Type() != SCR_InventorySlotStorageUI &&
4282  m_pFocusedSlotUI.Type() != SCR_InventorySlotStorageEmbeddedUI &&
4283  m_pFocusedSlotUI.Type() != SCR_InventoryStorageWeaponsUI &&
4284  m_pFocusedSlotUI.Type() != SCR_InventorySlotWeaponUI &&
4285  m_pFocusedSlotUI.Type() != SCR_InventorySlotQuickSlotUI &&
4286  m_pFocusedSlotUI.Type() != SCR_InventorySlotWeaponSlotsUI &&
4287  m_pFocusedSlotUI.Type() != SCR_InventorySlotGearInspectionUI &&
4288  m_pFocusedSlotUI.Type() != SCR_ArsenalInventorySlotUI &&
4289  m_pFocusedSlotUI.Type() != SCR_SupplyInventorySlotUI)
4290  return;
4291 
4292  m_bDraggingEnabled = false;
4293  WidgetManager.GetMousePos( m_iMouseX, m_iMouseY );
4294  GetGame().GetInputManager().AddActionListener( "Inventory_Drag", EActionTrigger.PRESSED, Action_OnDrag );
4295  }
4296 
4297  //------------------------------------------------------------------------------------------------
4298  void Action_OnDrag()
4299  {
4300  int iMouseX, iMouseY;
4301  WidgetManager.GetMousePos( iMouseX, iMouseY );
4302  if ( !m_bDraggingEnabled )
4303  {
4304  int dX = Math.AbsInt( iMouseX - m_iMouseX );
4305  int dY = Math.AbsInt( iMouseY - m_iMouseY );
4306  if ( ( dX < DRAG_THRESHOLD ) && ( dY < DRAG_THRESHOLD ) )
4307  return;
4308  if ( !m_pFocusedSlotUI )
4309  return;
4310  if (!m_pFocusedSlotUI.IsDraggable())
4311  return;
4312  InventoryItemComponent focusedItemComp = m_pFocusedSlotUI.GetInventoryItemComponent();
4313  if (!focusedItemComp)
4314  return;
4315 
4316  InventoryStorageSlot slot = focusedItemComp.GetParentSlot();
4317  if (slot)
4318  {
4319  IEntity owner = slot.GetOwner();
4320  while (owner)
4321  {
4322  if (GetGame().GetPlayerController().GetControlledEntity() == owner)
4323  {
4324  SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_INV_CONTAINER_DRAG);
4325  break;
4326  }
4327 
4328  owner = owner.GetParent();
4329  if (!owner)
4330  SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_INV_VICINITY_DRAG);
4331  }
4332  }
4333  else
4334  {
4335  SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_INV_VICINITY_DRAG);
4336  }
4337 
4338  m_bDraggingEnabled = true;
4339  SimpleFSM( EMenuAction.ACTION_DRAGGED );
4340  m_wDragDropContainer.SetVisible( true );
4341 
4342  if ( m_pPreviewManager && m_pSelectedSlotUI )
4343  {
4344  HighlightAvailableStorages(m_pSelectedSlotUI);
4345  IEntity previewEntity = null;
4346  InventoryItemComponent pComp = m_pSelectedSlotUI.GetInventoryItemComponent();
4347  if ( pComp )
4348  {
4349  previewEntity = pComp.GetOwner();
4350  if (m_pDragDropPreviewImage)
4351  m_pPreviewManager.SetPreviewItem(m_pDragDropPreviewImage, previewEntity);
4352  }
4353  }
4354  ContainerSetPos( iMouseX, iMouseY );
4355  GetGame().GetInputManager().AddActionListener( "Inventory_Drag", EActionTrigger.UP, Action_DragUp );
4356  }
4357  else
4358  {
4359  ContainerSetPos( iMouseX, iMouseY );
4360  }
4361  }
4362 
4363  //------------------------------------------------------------------------------------------------
4364  void Action_DragUp()
4365  {
4366  GetGame().GetInputManager().RemoveActionListener( "Inventory_Drag", EActionTrigger.PRESSED, Action_OnDrag );
4367  GetGame().GetInputManager().RemoveActionListener( "Inventory_Drag", EActionTrigger.UP, Action_DragUp );
4368  if (m_pPreviewManager)
4369  m_pPreviewManager.SetPreviewItem(m_pDragDropPreviewImage, null);
4370  GetGame().GetCallqueue().CallLater(m_wDragDropContainer.SetVisible, 0, false, false);
4371  SimpleFSM( EMenuAction.ACTION_DROPPED );
4372  m_bDraggingEnabled = false;
4373  ResetHighlightsOnAvailableStorages();
4374  }
4375 
4376  //------------------------------------------------------------------------------------------------
4377  void ContainerSetPos( int iMouseX, int iMouseY )
4378  {
4379  float fWidth, fHeight;
4380  WorkspaceWidget wWorkSpace = GetGame().GetWorkspace();
4381  m_wDragDropContainer.GetScreenSize( fWidth, fHeight );
4382  fWidth = wWorkSpace.DPIUnscale( fWidth ) / 2;
4383  fHeight = wWorkSpace.DPIUnscale( fHeight ) / 2;
4384 
4385  m_pDragDropFrameSlotUI.SetPosX( wWorkSpace.DPIUnscale( iMouseX ) - fWidth );
4386  m_pDragDropFrameSlotUI.SetPosY( wWorkSpace.DPIUnscale( iMouseY ) - fHeight );
4387  }
4388 
4389  //------------------------------------------------------------------------------------------------
4390  // !
4391  protected void Action_Move( SCR_InventoryStorageBaseUI pStorageBase )
4392  {
4393  IEntity pItem = m_pSelectedSlotUI.GetInventoryItemComponent().GetOwner();
4394  m_InventoryManager.InsertItem( pItem, pStorageBase.GetCurrentNavigationStorage(), m_pFocusedSlotUI.GetStorageUI().GetCurrentNavigationStorage() );
4395  ResetHighlightsOnAvailableStorages();
4396  }
4397 
4398  //------------------------------------------------------------------------------------------------
4399  SCR_InventoryOpenedStorageUI GetOpenedStorage(BaseInventoryStorageComponent storage)
4400  {
4401  if (!storage)
4402  return null;
4403 
4404  foreach (SCR_InventoryOpenedStorageUI openedStorage : m_aOpenedStoragesUI)
4405  {
4406  if (openedStorage.GetStorage() == storage)
4407  return openedStorage;
4408  }
4409  return null;
4410  }
4411 
4412  //------------------------------------------------------------------------------------------------
4413  // !
4414  protected void Action_LootMove()
4415  {
4416  if ( !m_pFocusedSlotUI )
4417  return;
4418  IEntity pItem = m_pFocusedSlotUI.GetInventoryItemComponent().GetOwner();
4419  if (m_InventoryManager.CanMoveItem(pItem))
4420  return;
4421 
4422  m_pCallBack.m_pItem = pItem;
4423  m_pCallBack.m_pMenu = this;
4424 
4425  // Loot ===>>> Character
4426  if ( m_pFocusedSlotUI.GetStorageUI() == m_pStorageLootUI )
4427  {
4428  m_pCallBack.m_pStorageFrom = m_pStorageLootUI;
4429  m_pCallBack.m_pStorageTo = m_pFocusedSlotUI.GetStorageUI();
4430 
4431  if ( m_pDisplayedStorage.Type() == EquipedWeaponStorageComponent ) //default view opened, put the item into the first suitable storage
4432  {
4433  m_InventoryManager.InsertItem( pItem, null, null, m_pCallBack );
4434  }
4435  else
4436  {
4437  m_InventoryManager.InsertItem( pItem, m_pStorageBaseUI.GetCurrentNavigationStorage(), m_pStorageLootUI.GetCurrentNavigationStorage(), m_pCallBack ); //a storage is already opened, try to move it there
4438  }
4439  }
4440  else
4441  // Character ===>>> Loot
4442  {
4443  m_pCallBack.m_pStorageFrom = m_pFocusedSlotUI.GetStorageUI();
4444  m_pCallBack.m_pStorageTo = m_pStorageLootUI;
4445  auto storage = m_pStorageLootUI.GetCurrentNavigationStorage();
4446  if ( storage )
4447  m_InventoryManager.InsertItem( pItem, m_pStorageLootUI.GetCurrentNavigationStorage(), m_pDisplayedStorage, m_pCallBack ); // moving into the opened storage in the vicinity
4448  else
4449  {
4450  //droping it on the ground
4451  auto pSlot = m_pFocusedSlotUI.GetInventoryItemComponent().GetParentSlot();
4452  if ( pSlot )
4453  m_InventoryManager.TryRemoveItemFromInventory(pItem, pSlot.GetStorage(), m_pCallBack);
4454  }
4455  }
4456  ResetHighlightsOnAvailableStorages();
4457  }
4458 
4459  //------------------------------------------------------------------------------------------------
4460  // !
4461  protected bool IsStorageInsideLBS( BaseInventoryStorageComponent pStorage, ClothNodeStorageComponent pLBSStorage )
4462  {
4463  if ( !pLBSStorage )
4464  return false;
4465  array<BaseInventoryStorageComponent> aOutStorages = new array<BaseInventoryStorageComponent>();
4466  pLBSStorage.GetOwnedStorages( aOutStorages, 1, false );
4467  return aOutStorages.Find(pStorage) != -1;
4468  }
4469 
4470  //------------------------------------------------------------------------------------------------
4471  protected void OnItemAddedListener( IEntity item, notnull BaseInventoryStorageComponent storage )
4472  {
4473  if ( storage == m_StorageManager.GetLootStorage() )
4474  return;
4475 
4476  if (m_pCallBack.m_pStorageToPickUp)
4477  {
4478  if (item.FindComponent(BaseInventoryStorageComponent) != m_pCallBack.m_pStorageToPickUp)
4479  {
4480  int quickSlotIndex = m_StorageManager.GetEntityQuickSlot(item);
4481  if (quickSlotIndex > -1)
4482  m_pQuickSlotStorage.RefreshSlot(quickSlotIndex);
4483  return;
4484  }
4485  }
4486 
4487  if ( storage.Type() == EquipedWeaponStorageComponent ) //we are updating the weapon storage on character
4488  {
4489  if ( m_pWeaponStorage )
4490  m_pWeaponStorage.Refresh();
4491  }
4492  else if ( storage.Type() == WeaponAttachmentsStorageComponent ) // we are updating a weapon ( attachement / magazin inserted )
4493  {
4494  //if ( m_pWeaponStorage && m_pWeaponStorage.GetCurrentNavigationStorage() == storage )
4495  if ( m_pWeaponStorage )
4496  m_pWeaponStorage.Refresh();
4497  }
4498  else
4499  {
4500  SCR_InventoryStorageBaseUI storageUI = GetStorageUIByBaseStorageComponent(storage);
4501  if (storageUI)
4502  storageUI.Refresh();
4503  }
4504 
4505  if (m_StorageManager.IsItemAlreadyInQuickSlot(item))
4506  ShowQuickSlotStorage();
4507 
4508  UpdateTotalWeightText();
4509  }
4510 
4511  //------------------------------------------------------------------------------------------------
4512  protected void OnItemRemovedListener( IEntity item, notnull BaseInventoryStorageComponent storage )
4513  {
4514  if ( !storage )
4515  return;
4516 
4517  if (m_pCallBack.m_pStorageToDrop)
4518  {
4519  if (item.FindComponent(BaseInventoryStorageComponent) != m_pCallBack.m_pStorageToDrop)
4520  {
4521  int quickSlotIndex = m_StorageManager.GetEntityQuickSlot(item);
4522  if (quickSlotIndex > -1)
4523  m_pCallBack.m_bShouldUpdateQuickSlots = true;
4524  return;
4525  }
4526  }
4527 
4528  SCR_ConsumableItemComponent consumable = SCR_ConsumableItemComponent.Cast(item.FindComponent(SCR_ConsumableItemComponent));
4529  if (consumable && consumable.GetConsumableEffect() && consumable.GetConsumableEffect().GetDeleteOnUse()) // consumables require different handling
4530  {
4531  if (m_wAttachmentStorage && m_pAttachmentStorageUI)
4532  m_pAttachmentStorageUI.Refresh();
4533  SCR_InventoryStorageBaseUI storageUI = GetStorageUIByBaseStorageComponent(storage);
4534  if (storageUI)
4535  storageUI.Refresh();
4536  ShowQuickSlotStorage();
4537  }
4538 
4539  if ( storage == m_StorageManager.GetLootStorage() )
4540  return;
4541 
4542  if (m_StorageManager.GetLastQuickSlotId(item) > -1)
4543  ShowQuickSlotStorage();
4544 
4545  SCR_InventoryStorageBaseUI storageUI = GetStorageUIByBaseStorageComponent(storage);
4546  if (storageUI)
4547  storageUI.Refresh();
4548 
4549  UpdateTotalWeightText();
4550  }
4551 
4552  //------------------------------------------------------------------------------------------------
4553  void OnContainerHovered( SCR_InventoryStorageBaseUI pContainer )
4554  {
4555  if ( m_bDraggingEnabled )
4556  pContainer.ShowContainerBorder( true );
4557  m_pActiveHoveredStorageUI = pContainer;
4558  pContainer.SetPagingActive(true);
4559  NavigationBarUpdate();
4560  }
4561 
4562  //------------------------------------------------------------------------------------------------
4563  void HighlightAvailableStorages(SCR_InventorySlotUI itemSlot)
4564  {
4565  if (!itemSlot)
4566  return;
4567 
4568  if (!m_pActiveHoveredStorageUI)
4569  return;
4570 
4571  InventoryItemComponent itemComp = itemSlot.GetInventoryItemComponent();
4572  if (!itemComp)
4573  return;
4574 
4575  IEntity itemEntity = itemComp.GetOwner();
4576  if (!itemEntity)
4577  return;
4578 
4579  InventoryStorageSlot itemParentSlot = itemComp.GetParentSlot();
4580  BaseInventoryStorageComponent originStorage;
4581  if (itemParentSlot)
4582  originStorage = itemParentSlot.GetStorage();
4583 
4584 
4585  SCR_InventoryStorageManagerComponent invManagerTo = m_pActiveHoveredStorageUI.GetInventoryManager();
4586 
4587  if (!invManagerTo)
4588  return;
4589 
4590  SCR_EntityCatalogManagerComponent entityCatalogManager = SCR_EntityCatalogManagerComponent.GetInstance();
4591  string smallestContainerPrefab = "";
4592 
4593  if (entityCatalogManager)
4594  {
4595  SCR_EntityCatalog resourceContainerCatalog = entityCatalogManager.GetEntityCatalogOfType(EEntityCatalogType.SUPPLY_CONTAINER_ITEM);
4596  array<SCR_EntityCatalogEntry> entries = {};
4597  array<SCR_BaseEntityCatalogData> data = {};
4598 
4599  resourceContainerCatalog.GetEntityListWithData(SCR_ResourceContainerItemData, entries, data);
4600 
4601  if (!entries.IsEmpty())
4602  {
4603  int minResourceValue;
4604  int currentEntryValue;
4605 
4607 
4608  minResourceValue = datum.GetMaxResourceValue();
4609 
4610  if (!minResourceValue)
4611  minResourceValue = 0;
4612 
4613  foreach (int idx, SCR_EntityCatalogEntry entry: entries)
4614  {
4615  datum = SCR_ResourceContainerItemData.Cast(data[idx]);
4616  currentEntryValue = datum.GetMaxResourceValue();
4617 
4618  if (currentEntryValue > minResourceValue)
4619  break;
4620 
4621  minResourceValue = currentEntryValue;
4622 
4623  if (!entry)
4624  continue;
4625 
4626  smallestContainerPrefab = entry.GetPrefab();
4627  }
4628  }
4629  }
4630 
4631  BaseInventoryStorageComponent contStorage;
4632  array<BaseInventoryStorageComponent> contStorageOwnedStorages = {};
4633  SCR_EquipmentStorageComponent equipmentStorage;
4634  IEntity smallestContainerEntity;
4635 
4636  if (smallestContainerPrefab != "")
4637  smallestContainerEntity = GetGame().SpawnEntityPrefabLocal(Resource.Load(smallestContainerPrefab));
4638 
4639  foreach (SCR_InventoryStorageBaseUI storageBaseUI: m_aStorages)
4640  {
4641  if (!storageBaseUI)
4642  continue;
4643  if (storageBaseUI.Type() == SCR_InventoryStorageLootUI)
4644  continue;
4645  contStorage = storageBaseUI.GetStorage();
4646  if (!contStorage)
4647  continue;
4648  if (originStorage && contStorage == originStorage)
4649  continue;
4650  if (IsStorageInsideLBS(originStorage, ClothNodeStorageComponent.Cast(contStorage)))
4651  continue;
4652 
4653  float itemWeight = itemComp.GetTotalWeight();
4654  float totalWeightWithInsertedItem;
4655 
4656  totalWeightWithInsertedItem = storageBaseUI.GetTotalRoundedUpWeight(contStorage);
4657  totalWeightWithInsertedItem += Math.Round(itemWeight * 100) * 0.01;
4658 
4659  storageBaseUI.UpdateTotalWeight(totalWeightWithInsertedItem);
4660 
4661  float totalOccupiedVolumeWithInsertedItem;
4662  totalOccupiedVolumeWithInsertedItem = storageBaseUI.GetOccupiedVolume(contStorage);
4663  totalOccupiedVolumeWithInsertedItem += itemComp.GetTotalVolume();
4664 
4665  contStorageOwnedStorages.Clear();
4666  contStorage.GetOwnedStorages(contStorageOwnedStorages, 1, false);
4667  contStorageOwnedStorages.Insert(contStorage);
4668 
4669  bool shouldUpdateVolumePercentage = true;
4670 
4671  // Check to see if the itemEntity can fit into any equipment Storages so that volume is not updated in those cases.
4672  for (int i = 0, count = contStorageOwnedStorages.Count(); i < count; i++)
4673  {
4674  equipmentStorage = SCR_EquipmentStorageComponent.Cast(contStorageOwnedStorages.Get(i));
4675  if (!equipmentStorage)
4676  continue;
4677 
4678  bool canInsert = m_InventoryManager.CanInsertItemInStorage(itemEntity, equipmentStorage, -1); //split because of debug purposes
4679  bool canMove = m_InventoryManager.CanMoveItemToStorage(itemEntity, equipmentStorage, -1);
4680 
4681  if (canInsert || canMove)
4682  {
4683  shouldUpdateVolumePercentage = false;
4684  break;
4685  }
4686  }
4687 
4688  if (!m_InventoryManager.CanInsertItemInActualStorage(itemEntity, contStorage) && itemEntity.FindComponent(SCR_ResourceComponent))
4689  shouldUpdateVolumePercentage = false;
4690 
4691  if (shouldUpdateVolumePercentage)
4692  storageBaseUI.UpdateVolumePercentage(storageBaseUI.GetOccupiedVolumePercentage(contStorage, totalOccupiedVolumeWithInsertedItem));
4693 
4694  bool canInsert = m_InventoryManager.CanInsertItemInActualStorage(itemEntity, contStorage);
4695 
4696  if (!canInsert && SCR_ResourceComponent.FindResourceComponent(itemEntity))
4697  canInsert = m_InventoryManager.CanInsertItemInActualStorage(smallestContainerEntity, contStorage);
4698 
4699  if (canInsert)
4700  storageBaseUI.SetStorageAsHighlighted(true);
4701  else
4702  storageBaseUI.SetStorageAsHighlighted(false);
4703  }
4704 
4705  delete smallestContainerEntity;
4706  }
4707 
4708  //------------------------------------------------------------------------------------------------
4709  void ResetHighlightsOnAvailableStorages()
4710  {
4711  foreach (SCR_InventoryStorageBaseUI storageBaseUI: m_aStorages)
4712  {
4713  if (!storageBaseUI)
4714  continue;
4715 
4716  storageBaseUI.UpdateVolumePercentage(storageBaseUI.GetOccupiedVolumePercentage(storageBaseUI.GetStorage()));
4717  storageBaseUI.UpdateTotalWeight(storageBaseUI.GetTotalRoundedUpWeight(storageBaseUI.GetStorage()));
4718  storageBaseUI.SetStorageAsHighlighted(true);
4719  }
4720  }
4721 
4722  //------------------------------------------------------------------------------------------------
4723  void OnContainerLeft( SCR_InventoryStorageBaseUI pContainer )
4724  {
4725  pContainer.ShowContainerBorder( false );
4726  m_pActiveHoveredStorageUI = null;
4727  pContainer.SetPagingActive(false);
4728  NavigationBarUpdate();
4729  }
4730 
4731  //------------------------------------------------------------------------------------------------
4732  void OnContainerFocused(SCR_InventoryStorageBaseUI pContainer)
4733  {
4734  pContainer.ShowContainerBorder(true);
4735  SetActiveStorage(pContainer);
4736  m_pActiveStorageUI = pContainer;
4737  NavigationBarUpdate();
4738  }
4739 
4740  //------------------------------------------------------------------------------------------------
4741  void OnContainerFocusLeft(SCR_InventoryStorageBaseUI pContainer)
4742  {
4743  pContainer.ShowContainerBorder(false);
4744  SetActiveStorage(pContainer);
4745  m_pActiveStorageUI = null;
4746  NavigationBarUpdate();
4747  }
4748 
4749  //------------------------------------------------------------------------------------------------
4750  SCR_CharacterControllerComponent GetCharacterController()
4751  {
4752  return m_CharController;
4753  }
4754 
4755  //------------------------------------------------------------------------------------------------
4757  protected bool MoveOperation( InventoryItemComponent pItemComponent, BaseInventoryStorageComponent pStorageTo )
4758  {
4759  if ( !pItemComponent || !pStorageTo )
4760  {
4761  Print( "INV: Cannot perform move operation. Either item or storage doesn't exist", LogLevel.DEBUG );
4762  return false;
4763  }
4764 
4765  m_InventoryManager.EquipAny( pStorageTo, pItemComponent.GetOwner() );
4766  return true;
4767  }
4768 
4769  //------------------------------------------------------------------------------------------------
4771  void MoveWeapon()
4772  {
4773  if (!m_pFocusedSlotUI)
4774  return;
4775 
4776  m_pCallBack.m_pStorageFrom = m_pFocusedSlotUI.GetStorageUI();
4777 
4778  m_InventoryManager.EquipWeapon( m_pFocusedSlotUI.GetInventoryItemComponent().GetOwner(), m_pCallBack );
4779  }
4780 
4781  //------------------------------------------------------------------------------------------------
4783  protected void RefreshUISlotStorages()
4784  {
4785  foreach ( SCR_InventorySlotUI pStorage : m_aShownStorages )
4786  {
4787  if ( pStorage )
4788  pStorage.Refresh();
4789  }
4790  }
4791 
4792  //------------------------------------------------------------------------------------------------
4793  protected void UpdateTotalWeightText()
4794  {
4795  if (!m_wTotalWeightText)
4796  return;
4797 
4798  float weight = Math.Round(GetTotalWeight() * 100) * 0.01;
4799 
4800  if (weight <= 0 )
4801  weight = 0;
4802 
4803  m_wTotalWeightText.SetTextFormat("#AR-ValueUnit_Short_Kilograms", weight);
4804  }
4805 
4806  protected void InitQuickSlots()
4807  {
4808  ShowQuickSlotStorage();
4809 
4810  int quickSlotCount = m_StorageManager.GetQuickSlotItems().Count();
4811  for (int slotId = 1; slotId <= quickSlotCount; ++slotId)
4812  {
4813  GetGame().GetInputManager().AddActionListener("InventoryQuickSlot" + slotId, EActionTrigger.PRESSED, Action_SelectQuickSlot);
4814  }
4815 
4816  }
4817 
4818  //------------------------------------------------------------------------------------------------
4819  void ShowQuickSlotStorage()
4820  {
4821  if( m_wQuickSlotStorage )
4822  {
4823  m_wQuickSlotStorage.RemoveHandler( m_wQuickSlotStorage.FindHandler( SCR_InventoryStorageQuickSlotsUI ) ); //remove the handler from the widget
4824  m_wQuickSlotStorage.RemoveFromHierarchy();
4825  }
4826 
4827  Widget parent = m_widget.FindAnyWidget( "QuickSlots" );
4828  m_wQuickSlotStorage = GetGame().GetWorkspace().CreateWidgets( "{A1E61EF091EAC47C}UI/layouts/Menus/Inventory/InventoryQuickSlotsGrid.layout", parent );
4829 
4830  if( !m_wQuickSlotStorage )
4831  return;
4832 
4833  OverlaySlot.SetVerticalAlign( m_wQuickSlotStorage, LayoutVerticalAlign.Bottom );
4834  OverlaySlot.SetHorizontalAlign(m_wQuickSlotStorage, LayoutHorizontalAlign.Left);
4835 
4836  m_wQuickSlotStorage.AddHandler( new SCR_InventoryStorageQuickSlotsUI( null, null, this ) );
4837  m_pQuickSlotStorage = SCR_InventoryStorageQuickSlotsUI.Cast( m_wQuickSlotStorage.FindHandler( SCR_InventoryStorageQuickSlotsUI ) );
4838  }
4839 
4840  //------------------------------------------------------------------------------------------------
4841  // !
4842  void Action_SelectQuickSlot()
4843  {
4844  if ( !GetGame().GetInputManager() )
4845  return;
4846  int iSlot = -1;
4847 
4848  int quickSlotCount = m_StorageManager.GetQuickSlotItems().Count();
4849  for (int id = 1; id <= quickSlotCount; ++id)
4850  {
4851  if (GetGame().GetInputManager().GetActionTriggered("InventoryQuickSlot" + id))
4852  iSlot = id;
4853  }
4854 
4855  if ( iSlot != -1 )
4856  SetItemToQuickSlot( iSlot );
4857  }
4858 
4859  //------------------------------------------------------------------------------------------------
4860  // !
4861  protected void RemoveItemFromQuickSlotDrop()
4862  {
4863  if ( !m_pSelectedSlotUI )
4864  return;
4865  InventoryItemComponent pInventoryComponent = m_pSelectedSlotUI.GetInventoryItemComponent();
4866  if ( !pInventoryComponent )
4867  return;
4868  m_StorageManager.StoreItemToQuickSlot( pInventoryComponent.GetOwner(), m_pSelectedSlotUI.GetSlotIndex() );
4869  ShowQuickSlotStorage();
4870  }
4871 
4872  //------------------------------------------------------------------------------------------------
4873  // !
4874  protected void SetItemToQuickSlot( int iSlotIndex, SCR_InventorySlotUI slot = null )
4875  {
4876  if (!slot)
4877  slot = m_pFocusedSlotUI;
4878  if ( !slot )
4879  return;
4880  if (iSlotIndex < WEAPON_SLOTS_COUNT)
4881  return;
4882 
4883  SCR_InventoryStorageBaseUI storageUI = slot.GetStorageUI();
4884  if (storageUI
4885  && (storageUI.IsInherited(SCR_InventoryStorageLootUI) || storageUI.IsInherited(SCR_InventoryOpenedStorageUI))
4886  || IsStorageArsenal(storageUI.GetCurrentNavigationStorage()))
4887  return; //we don't want to take anything from vicinity to the quickslot
4888 
4889  if ( slot.Type() == SCR_InventorySlotQuickSlotUI )
4890  return;
4891  InventoryItemComponent pInventoryComponent = slot.GetInventoryItemComponent();
4892  if ( !pInventoryComponent )
4893  return;
4894  IEntity pItem = pInventoryComponent.GetOwner();
4895  if (!pItem)
4896  return;
4897  if (m_pWeaponStorageComp.Contains(pItem))
4898  return;
4899  SCR_ItemAttributeCollection pItemAttributes = SCR_ItemAttributeCollection.Cast( pInventoryComponent.GetAttributes() );
4900  if ( pItemAttributes && ( pItemAttributes.GetQuickSlotItemSize() != ESlotSize.SLOT_1x1 && pItemAttributes.GetQuickSlotItemSize() != ESlotSize.SLOT_2x1 ) )
4901  return; //so far only items with one line are supported ( issue on the UI side )
4902 
4903  m_StorageManager.StoreItemToQuickSlot( pItem, --iSlotIndex );
4904  ShowQuickSlotStorage();
4905  }
4906 
4907  //------------------------------------------------------------------------------------------------
4908  // !
4909  protected void SetItemToQuickSlotDrop()
4910  {
4911  if ( !m_pFocusedSlotUI )
4912  return;
4913  if ( !m_pSelectedSlotUI )
4914  return;
4915 
4916  SCR_InventoryStorageBaseUI selectedSlotStorage = m_pSelectedSlotUI.GetStorageUI();
4917  if (selectedSlotStorage &&
4918  (selectedSlotStorage.IsInherited(SCR_InventoryStorageLootUI) || selectedSlotStorage.IsInherited(SCR_InventoryOpenedStorageUI)) ||
4919  IsStorageArsenal(selectedSlotStorage.GetCurrentNavigationStorage()))
4920  {
4921  return; //we don't want to take anything from vicinity to the quickslot
4922  }
4923 
4924  IEntity pOriginalEntity;
4925  if ( ( SCR_InventorySlotQuickSlotUI.Cast( m_pSelectedSlotUI ) ) && ( SCR_InventorySlotQuickSlotUI.Cast( m_pFocusedSlotUI ) ) ) // swapping
4926  {
4927  InventoryItemComponent pComp = m_pFocusedSlotUI.GetInventoryItemComponent();
4928  if ( pComp )
4929  {
4930  pOriginalEntity = pComp.GetOwner();
4931  }
4932  }
4933 
4934  InventoryItemComponent pInventoryComponent = m_pSelectedSlotUI.GetInventoryItemComponent();
4935  if ( !pInventoryComponent )
4936  return;
4937  SCR_ItemAttributeCollection pItemAttributes = SCR_ItemAttributeCollection.Cast( pInventoryComponent.GetAttributes() );
4938  if ( pItemAttributes && ( pItemAttributes.GetQuickSlotItemSize() != ESlotSize.SLOT_1x1 && pItemAttributes.GetQuickSlotItemSize() != ESlotSize.SLOT_2x1 ) )
4939  {
4940  SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_INV_DROP_ERROR);
4941  return;
4942  }
4943  int iSlotIndex = m_pFocusedSlotUI.GetSlotIndex();
4944 
4945  if (iSlotIndex < WEAPON_SLOTS_COUNT || m_pWeaponStorageComp.Contains(pInventoryComponent.GetOwner()))
4946  {
4947  ShowQuickSlotStorage();
4948  SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_INV_DROP_ERROR);
4949  return;
4950  }
4951 
4952  m_StorageManager.StoreItemToQuickSlot( pInventoryComponent.GetOwner(), iSlotIndex );
4953  if ( pOriginalEntity )
4954  m_StorageManager.StoreItemToQuickSlot( pOriginalEntity, m_pSelectedSlotUI.GetSlotIndex() );
4955  ShowQuickSlotStorage();
4956 
4957  SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_INV_HOTKEY_CONFIRM);
4958 
4959  SetStorageSwitchMode(false);
4960  Action_DeselectItem();
4961  FocusOnSlotInStorage(m_pQuickSlotStorage, iSlotIndex);
4962  }
4963 
4964  //------------------------------------------------------------------------------------------------
4965  protected void Action_SwapItems(SCR_InventorySlotUI item1, SCR_InventorySlotUI item2)
4966  {
4967  if (!item1 || !item2)
4968  return;
4969 
4970  IEntity from = item1.GetInventoryItemComponent().GetOwner();
4971  IEntity to = item2.GetInventoryItemComponent().GetOwner();
4972 
4973  if (!(m_InventoryManager.CanMoveItem(from) && m_InventoryManager.CanMoveItem(to)))
4974  return;
4975 
4976  m_pCallBack.m_pStorageFrom = m_pSelectedSlotUI.GetStorageUI();
4977  m_pCallBack.m_pStorageTo = m_pFocusedSlotUI.GetStorageUI();
4978  m_pCallBack.m_pItem = from;
4979  m_pCallBack.m_pMenu = this;
4980  m_pCallBack.m_pStorageToFocus = m_pCallBack.m_pStorageFrom;
4981 
4982  //if (m_InventoryManager.CanSwapItemStorages(from, to))
4983  m_InventoryManager.TrySwapItemStorages(from, to, m_pCallBack);
4984  }
4985 
4986  //------------------------------------------------------------------------------------------------
4987  protected void Action_MoveItemToStorage(SCR_InventoryStorageBaseUI toStorage = null)
4988  {
4989  if (!toStorage)
4990  toStorage = m_pFocusedSlotUI.GetStorageUI();
4991 
4992  if (!toStorage || !m_pSelectedSlotUI)
4993  return;
4994 
4995  MoveItem(toStorage);
4996  ResetHighlightsOnAvailableStorages();
4997  }
4998 
4999  void OnAttachmentSpinboxFocused()
5000  {
5001  NavigationBarUpdate();
5002  }
5003 
5004  //------------------------------------------------------------------------------------------------
5005  bool IsUsingGamepad()
5006  {
5007  return m_bIsUsingGamepad;
5008  }
5009 
5010  //------------------------------------------------------------------------------------------------
5011  void OnInputDeviceIsGamepad(bool isGamepad)
5012  {
5013  m_bIsUsingGamepad = isGamepad;
5014  SetStorageSwitchMode(m_bIsUsingGamepad);
5015  SetAttachmentSpinBoxActive(isGamepad);
5016  NavigationBarUpdate();
5017  }
5018 
5019  static SCR_InventoryMenuUI GetInventoryMenu()
5020  {
5021  return SCR_InventoryMenuUI.Cast(GetGame().GetMenuManager().FindMenuByPreset(ChimeraMenuPreset.Inventory20Menu));
5022  }
5023 
5024  //------------------------------------------------------------------------------------------------
5025  void SCR_InventoryMenuUI()
5026  {
5027  m_SupplyCostUIInfo = SCR_SupplyCostItemHintUIInfo.Cast(SCR_BaseContainerTools.CreateInstanceFromPrefab(m_sSupplyCostUIInfoPrefab));
5028  }
5029 
5030  //------------------------------------------------------------------------------------------------
5031  void ~SCR_InventoryMenuUI()
5032  {
5033  // reset view distance back to value defined in video settings
5034  BaseContainer vs = GetGame().GetGameUserSettings().GetModule("SCR_VideoSettings");
5035  if (vs)
5036  {
5037  int dist;
5038  vs.Get("m_iViewDistance", dist);
5039  GetGame().SetViewDistance(dist);
5040  }
5041  }
5042 
5043  #else
5044  protected float GetTotalLoadWeight();
5045  SCR_InventoryStorageManagerComponent GetInventoryStorageManager();
5046  bool GetCanInteract();
5047  override void OnMenuOpen();
5048  protected void Init();
5049  void ShowStorage();
5050  void ShowStorage( BaseInventoryStorageComponent storage );
5051  protected void ShowStoragesList();
5052  //protected void ShowGadgetStorage();
5053  protected void ShowEquipedWeaponStorage();
5054  void ShowItemInfo( string sName = "", string sDescr = "", float sWeight = 0.0 );
5055  void HideItemInfo();
5056  void SetSlotFocused( SCR_InventorySlotUI pFocusedSlot );
5057  SCR_InventoryInspectionUI GetInspectionScreen();
5058  void InspectItem(SCR_InventorySlotUI itemSlot);
5059  void FilterOutStorages();
5060  protected void Action_CloseInventory();
5061  protected void Action_SelectItem();
5062  protected void Action_EquipItem();
5063  protected void Action_Drop();
5064  protected void Action_Inspect();
5065  protected void OnItemAddedListener( IEntity item, BaseInventoryStorageComponent storage );
5066  protected void OnItemRemovedListener( IEntity item, BaseInventoryStorageComponent storage );
5067  override bool OnClick( Widget w, int x, int y, int button );
5068  void FilterOutStorages( false );
5069  void MoveItem();
5070  void MoveWeapon();
5071  void SCR_InventoryMenuUI();
5072  #endif
5073 }
SCR_InventoryDamageInfoUI
Definition: SCR_InventoryDamageInfoUI.c:5
SCR_SupplyInventorySlotUI
Definition: SCR_SupplyInventorySlotUI.c:2
STORAGES
@ STORAGES
Definition: SCR_InventoryMenuUI.c:49
DONE
@ DONE
Definition: SCR_InventoryMenuUI.c:51
ChimeraMenuBase
Constant variables used in various menus.
Definition: ChimeraMenuBase.c:70
ECharacterHitZoneGroup
ECharacterHitZoneGroup
Definition: SCR_CharacterDamageManagerComponent.c:1
ChimeraWorld
Definition: ChimeraWorld.c:12
SCR_BaseGameMode
Definition: SCR_BaseGameMode.c:137
m_CharController
protected SCR_CharacterControllerComponent m_CharController
Definition: SCR_ConsumableItemComponent.c:18
EDropContainer
EDropContainer
Definition: SCR_InventoryMenuUI.c:28
SCR_InventoryStorageWeaponsUI
Definition: SCR_InventoryStorageWeaponsUI.c:4
EStateMenuItem
EStateMenuItem
Definition: SCR_InventoryMenuUI.c:21
ACTION_DESELECT
@ ACTION_DESELECT
Definition: SCR_InventoryMenuUI.c:4
m_bIsUsingGamepad
protected bool m_bIsUsingGamepad
Definition: SCR_CampaignTutorialComponentArland.c:58
SCR_InvCallBack
Definition: SCR_InventoryMenuUI.c:56
SCR_InventoryStorageLootUI
Definition: SCR_InventoryStorageLootUI.c:4
ECharacterLifeState
ECharacterLifeState
Definition: ECharacterLifeState.c:12
ACTION_UNFOLD
@ ACTION_UNFOLD
Definition: SCR_InventoryMenuUI.c:5
InventoryStorageSlot
Definition: InventoryStorageSlot.c:12
STATE_INIT
@ STATE_INIT
Definition: SCR_InventoryMenuUI.c:16
EAttachAction
EAttachAction
Definition: SCR_InventoryMenuUI.c:35
BEGIN
@ BEGIN
Definition: SCR_InventoryMenuUI.c:44
SCR_UISoundEntity
Definition: SCR_UISoundEntity.c:7
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
UIInfo
UIInfo - declare object, allows to define UI elements.
Definition: UIInfo.c:13
PreviewRenderAttributes
Definition: PreviewRenderAttributes.c:12
EEntityCatalogType
EEntityCatalogType
Definition: EEntityCatalogType.c:4
SCR_SoundEvent
Definition: SCR_SoundEvent.c:1
SCR_InventoryAttachmentStorageUI
void SCR_InventoryAttachmentStorageUI(BaseInventoryStorageComponent storage, LoadoutAreaType slotID=null, SCR_InventoryMenuUI menuManager=null, int iPage=0, array< BaseInventoryStorageComponent > aTraverseStorage=null, InventorySearchPredicate searchPredicate=null)
Definition: SCR_InventoryAttachmentStorageUI.c:100
SCR_InventorySlotWeaponSlotsUI
Definition: SCR_InventorySlotWeaponSlotsUI.c:4
EEquipItemType
EEquipItemType
Definition: EEquipItemType.c:12
SCR_UniversalInventoryStorageComponent
void SCR_UniversalInventoryStorageComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_UniversalInventoryStorageComponent.c:259
SCR_InventoryStorageBackpackUI
Definition: SCR_InventoryStorageBackpackUI.c:5
SCR_ArsenalInventorySlotUI
Definition: SCR_ArsenalInventorySlotUI.c:2
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
SCR_InventorySlotWeaponUI
Definition: SCR_InventorySlotWeaponUI.c:6
SCR_InventoryDamageUIInfo
Definition: SCR_InventoryDamageUIInfo.c:2
SCR_InventoryInspectionUI
Definition: SCR_InventoryInspectionUI.c:6
SCR_InventoryStorageGadgetsUI
Definition: SCR_InventoryStorageGadgetsUI.c:4
m_InventoryManager
SCR_InventoryStorageManagerComponent m_InventoryManager
Definition: SCR_AttachementAction.c:15
ISNOTINSIDE
@ ISNOTINSIDE
Definition: SCR_InventoryMenuUI.c:31
EInvInitStage
EInvInitStage
Definition: SCR_InventoryMenuUI.c:42
SCR_InventorySpinBoxComponent
Definition: SCR_InventorySpinBoxComponent.c:1
SCR_CharacterControllerComponent
Definition: SCR_CharacterControllerComponent.c:35
GetPlayerController
proto external PlayerController GetPlayerController()
Definition: SCR_PlayerDeployMenuHandlerComponent.c:307
SCR_CountingTimerUI
Definition: SCR_CountingTimerUI.c:1
SCR_CharacterBloodHitZone
Blood - does not receive damage directly, only via scripted events.
Definition: SCR_CharacterHitZone.c:480
SCR_LoadingOverlay
Definition: SCR_LoadingOverlay.c:49
EStateMenuStorage
EStateMenuStorage
Definition: SCR_InventoryMenuUI.c:14
SCR_DamageStateConfig
Definition: SCR_DamageStateConfig.c:2
DAMAGE_INFO
const protected string DAMAGE_INFO
Definition: SCR_InventoryHitZonePointUI.c:421
GetRootWidget
Widget GetRootWidget()
Definition: SCR_UITaskManagerComponent.c:160
SCR_InventorySlotGearInspectionUI
Definition: SCR_InventoryGearInspectionSlotUI.c:258
ACTION_MOVEBETWEEN
@ ACTION_MOVEBETWEEN
Definition: SCR_InventoryMenuUI.c:7
SCR_InventoryStorageBaseUI
Definition: SCR_InventoryStorageBaseUI.c:6
SCR_InventoryOpenedStorageArsenalUI
Definition: SCR_InventoryOpenedStorageArsenalUI.c:1
GetGameMode
SCR_BaseGameMode GetGameMode()
Definition: SCR_BaseGameModeComponent.c:15
SCR_NavigationBarUI
Definition: SCR_NavigationBarUI.c:31
SCR_InventoryGearInspectionPointUI
Definition: SCR_InventoryGearInspectionSlotUI.c:1
DETACH
@ DETACH
Definition: SCR_InventoryMenuUI.c:39
SCR_InventoryButton
Definition: SCR_InventoryButtonPageUI.c:13
SCR_InventoryUIInfo
Definition: SCR_InventoryUIInfo.c:2
ScriptedInventoryOperationCallback
Definition: ScriptedInventoryOperationCallback.c:12
SCR_SupplyCostItemHintUIInfo
Definition: SCR_SupplyCostItemHintUIInfo.c:2
SCR_InventoryStorageContainerUI
Definition: SCR_InventoryStorageContainerUI.c:1
m_LoadingOverlay
protected SCR_LoadingOverlay m_LoadingOverlay
Definition: SCR_BackendImageComponent.c:250
Attribute
typedef Attribute
Post-process effect of scripted camera.
m_Player
protected ChimeraCharacter m_Player
Definition: SCR_CampaignTutorialComponentArland.c:40
SCR_InventoryStorageLBSUI
Definition: SCR_InventoryStorageLBSUI.c:5
NAVIGATION_BAR
@ NAVIGATION_BAR
Definition: SCR_InventoryMenuUI.c:45
SCR_ItemSplitDialog
Definition: SCR_ItemSplitDialog.c:1
SCR_InventoryItemInfoUI
Definition: SCR_InventoryItemInfoUI.c:6
SCR_CharacterDamageManagerComponent
Definition: SCR_CharacterDamageManagerComponent.c:18
OnClick
override bool OnClick(Widget w, int x, int y, int button)
Definition: SCR_HighlightedEditorUIComponent.c:129
ACTION_DRAGGED
@ ACTION_DRAGGED
Definition: SCR_InventoryMenuUI.c:8
ACTION_MOVEINSIDE
@ ACTION_MOVEINSIDE
Definition: SCR_InventoryMenuUI.c:10
ACTION_SELECT
@ ACTION_SELECT
Definition: SCR_InventoryMenuUI.c:3
ESlotSize
ESlotSize
Definition: InventoryConstants.c:1
SCR_InventoryOpenedStorageUI
Definition: SCR_InventoryOpenedStorageUI.c:1
ISINSIDE
@ ISINSIDE
Definition: SCR_InventoryMenuUI.c:30
SCR_InventorySlotQuickSlotUI
Definition: SCR_InventorySlotQuickSlotUI.c:4
SCR_InventorySlotStorageEmbeddedUI
Definition: SCR_InventorySlotStorageEmbeddedUI.c:5
ACTION_BACK
@ ACTION_BACK
Definition: SCR_InventoryMenuUI.c:6
EResourceType
EResourceType
Definition: SCR_ResourceContainer.c:1
WEAPON_STORAGE
@ WEAPON_STORAGE
Definition: SCR_InventoryMenuUI.c:47
SCR_InventoryHitZoneUI
Definition: SCR_InventoryHitZoneSlotUI.c:1
ACTION_DROPPED
@ ACTION_DROPPED
Definition: SCR_InventoryMenuUI.c:9
STATE_OPENED
@ STATE_OPENED
Definition: SCR_InventoryMenuUI.c:18
SCR_InventoryMenuUI
Definition: SCR_InventoryMenuUI.c:247
SCR_ResourceContainerItemData
Definition: SCR_ResourceContainerItemData.c:2
GetControlledEntity
SCR_EditableEntityComponent GetControlledEntity()
Returns the controlled entity or null if none.
Definition: SCR_EditablePlayerDelegateComponent.c:86
SCR_InventoryWeaponSlotsUI
Definition: SCR_InventoryWeaponSlotsUI.c:6
EInventoryButton
EInventoryButton
Definition: SCR_InventoryButtonPageUI.c:1
SCR_SlotUIComponent
Definition: SCR_SlotUIComponent.c:6
InventoryItemComponent
Definition: InventoryItemComponent.c:12
NONE
@ NONE
Definition: SCR_InventoryMenuUI.c:37
SCR_BaseContainerTools
Definition: SCR_BaseContainerTools.c:3
EMenuAction
EMenuAction
Definition: SCR_InventoryMenuUI.c:1
SCR_ItemAttributeCollection
Definition: SCR_ItemAttributeCollection.c:2
HIT_ZONES
@ HIT_ZONES
Definition: SCR_InventoryMenuUI.c:50
SCR_InventorySlotStorageUI
Definition: SCR_InventorySlotStorageUI.c:5
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition: SCR_DestructionSynchronizationComponent.c:17
SCR_HitZone
Definition: SCR_HitZone.c:1
SCR_EntityCatalog
Definition: SCR_EntityCatalog.c:181
GetInputManager
protected InputManager GetInputManager()
Definition: SCR_BaseManualCameraComponent.c:65
STATE_MOVING_ITEM_STARTED
@ STATE_MOVING_ITEM_STARTED
Definition: SCR_InventoryMenuUI.c:25
SCR_ResourceContainer
Definition: SCR_ResourceContainer.c:34
ChimeraMenuPreset
ChimeraMenuPreset
Menu presets.
Definition: ChimeraMenuBase.c:3
EStoragePurpose
EStoragePurpose
Definition: EStoragePurpose.c:12
SCR_InventorySlotLBSUI
Definition: SCR_InventorySlotLBSUI.c:6
ItemPreviewWidget
Definition: ItemPreviewWidget.c:12
SCR_InventoryStorageQuickSlotsUI
Definition: SCR_InventoryStorageQuickSlotsUI.c:6
EDamageType
EDamageType
Definition: EDamageType.c:12
EWeaponType
EWeaponType
Definition: EWeaponType.c:12
SCR_ResourcePlayerControllerInventoryComponent
Definition: SCR_ResourcePlayerControllerInventoryComponent.c:20
ESlotFunction
ESlotFunction
Definition: SCR_InventorySlotUI.c:12
data
Get all prefabs that have the spawner data
Definition: SCR_EntityCatalogManagerComponent.c:305
LoadoutAreaType
Definition: LoadoutAreaType.c:12
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
NOCONTAINER
@ NOCONTAINER
Definition: SCR_InventoryMenuUI.c:32
SCR_InventoryStoragesListUI
Definition: SCR_InventoryStoragesListUI.c:6
SCR_InventoryCharacterWidgetHelper
Definition: SCR_InventoryCharacterWidgetHelper.c:2
ECharacterBloodState
ECharacterBloodState
Definition: SCR_CharacterHitZone.c:13
SCR_InventoryAttachmentStorageUI
Definition: SCR_InventoryAttachmentStorageUI.c:1
ATTACH
@ ATTACH
Definition: SCR_InventoryMenuUI.c:38
SCR_ArsenalComponent
Definition: SCR_ArsenalComponent.c:9
SCR_InventorySlotUI
Definition: SCR_InventorySlotUI.c:27
QUICK_SLOTS
@ QUICK_SLOTS
Definition: SCR_InventoryMenuUI.c:46
ACTION_OPENCONTAINER
@ ACTION_OPENCONTAINER
Definition: SCR_InventoryMenuUI.c:11
SCR_EntityCatalogEntry
Definition: SCR_EntityCatalogEntry.c:5
STATE_IDLE
@ STATE_IDLE
Definition: SCR_InventoryMenuUI.c:17
STORAGE_LIST
@ STORAGE_LIST
Definition: SCR_InventoryMenuUI.c:48
SCR_InputButtonComponent
Definition: SCR_InputButtonComponent.c:1
SCR_InventoryHitZonePointContainerUI
Definition: SCR_InventoryHitZonePointUI.c:1
SCR_CharacterInventoryPreviewAttributes
Definition: SCR_CharacterInventoryPreviewAttributes.c:1
EResourceGeneratorID
EResourceGeneratorID
Definition: SCR_ResourceGenerator.c:1