Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
inventory.c
Go to the documentation of this file.
1 #ifdef PLATFORM_CONSOLE
2 enum ConsoleActionToolbarMask
3 {
4  EMPTY = 0,
5  TO_HANDS_SWAP_VICINITY = 1,
6  TO_HANDS_SWAP_INVENTORY = 2,
7  DROP = 4,
8  EQUIP = 8,
9  SPLIT = 16,
10  TO_INVENTORY = 32,
11  OPEN_CLOSE_CONTAINER = 64,
12  MICROMANAGMENT = 128,
13  QUICKSLOT = 256,
14  COMBINE = 512,
15 }
16 #endif
17 
19 {
22  UP,
24 }
25 
27 {
28  protected ref LeftArea m_LeftArea;
29  protected ref RightArea m_RightArea;
30  protected ref HandsArea m_HandsArea;
32  protected ref InventoryQuickbar m_Quickbar;
33 
42 
43  protected ref ContextMenu m_ContextMenu;
44  protected static ref map<string, int> m_PlayerAttachmentsIndexes;
45 
46  protected bool m_HadFastTransferred;
47  protected bool m_HadInspected;
49 
50  protected static Inventory m_Instance;
51 
52  protected int m_ControllerAngle;
53  protected int m_ControllerTilt;
54  protected bool m_ControllerRightStickTimerEnd = true;
56 
57  protected bool m_HoldingQB;
59 
61  const float BT_REPEAT_DELAY = 0.35; //delay from first press to begin tick repeat state
62  const float BT_REPEAT_TIME = 0.09; //tick repeat frequency time
63  const float BT_THRESHOLD_VALUE = 0.8; //threshold values for analog inputs
64  const int INV_MOV_LEFT = 0;
65  const int INV_MOV_RIGHT = 1;
66  const int INV_MOV_UP = 2;
67  const int INV_MOV_DOWN = 3;
68  protected ref array<string> m_InvInputNames = {"UAUILeftInventory","UAUIRightInventory","UAUIUpInventory","UAUIDownInventory"};
71  protected int m_InvInputWrappersCount;
72  protected float m_SensitivityThreshold = 0.0;
75 
76  void Inventory(LayoutHolder parent)
77  {
78  m_Instance = this;
80 
82  new ItemManager(GetMainWidget());
83  new ColorManager();
84 
85  m_LeftArea = new LeftArea(this);
86  m_RightArea = new RightArea(this);
87  m_HandsArea = new HandsArea(this);
88  m_PlayerPreview = new PlayerPreview(this);
89 
90  m_QuickbarWidget = GetMainWidget().FindAnyWidget("QuickbarGrid");
91  m_Quickbar = new InventoryQuickbar(m_QuickbarWidget);
92  m_Quickbar.UpdateItems(m_QuickbarWidget);
93 
94  m_SpecializationPanel = GetMainWidget().FindAnyWidget("SpecializationPanelPanel");
95  m_SpecializationIcon = GetMainWidget().FindAnyWidget("SpecializationIcon");
96 
97  WidgetEventHandler.GetInstance().RegisterOnDropReceived(GetMainWidget().FindAnyWidget("LeftBackground"), this, "OnLeftPanelDropReceived");
98  WidgetEventHandler.GetInstance().RegisterOnDraggingOver(GetMainWidget().FindAnyWidget("LeftBackground"), this, "DraggingOverLeftPanel");
99  WidgetEventHandler.GetInstance().RegisterOnDropReceived(GetMainWidget().FindAnyWidget("LeftPanel").FindAnyWidget("Scroller"), this, "OnLeftPanelDropReceived");
100  WidgetEventHandler.GetInstance().RegisterOnDraggingOver(GetMainWidget().FindAnyWidget("LeftPanel").FindAnyWidget("Scroller"), this, "DraggingOverLeftPanel");
101 
102  WidgetEventHandler.GetInstance().RegisterOnDropReceived(GetMainWidget().FindAnyWidget("RightBackground"), this, "OnRightPanelDropReceived");
103  WidgetEventHandler.GetInstance().RegisterOnDraggingOver(GetMainWidget().FindAnyWidget("RightBackground"), this, "DraggingOverRightPanel");
104  WidgetEventHandler.GetInstance().RegisterOnDropReceived(GetMainWidget().FindAnyWidget("RightPanel").FindAnyWidget("Scroller"), this, "OnRightPanelDropReceived");
105  WidgetEventHandler.GetInstance().RegisterOnDraggingOver(GetMainWidget().FindAnyWidget("RightPanel").FindAnyWidget("Scroller"), this, "DraggingOverRightPanel");
106 
107  WidgetEventHandler.GetInstance().RegisterOnDropReceived(GetMainWidget().FindAnyWidget("CharacterPanel"), this, "OnCenterPanelDropReceived");
108  WidgetEventHandler.GetInstance().RegisterOnDraggingOver(GetMainWidget().FindAnyWidget("CharacterPanel"), this, "DraggingOverCenterPanel");
109 
110  WidgetEventHandler.GetInstance().RegisterOnDropReceived(GetMainWidget().FindAnyWidget("HandsPanel"), this, "OnHandsPanelDropReceived");
111  WidgetEventHandler.GetInstance().RegisterOnDraggingOver(GetMainWidget().FindAnyWidget("HandsPanel"), this, "DraggingOverHandsPanel");
112 
113  #ifdef PLATFORM_CONSOLE
114  PluginDiagMenu plugin_diag_menu = PluginDiagMenu.Cast(GetPlugin(PluginDiagMenu));
115  GetGame().GetUIManager().ShowUICursor(false);
117  GetMainWidget().FindAnyWidget("CursorCharacter").Show(false);
118 
119  //console inventory toolbar
120  m_TopConsoleToolbarVicinity = GetRootWidget().FindAnyWidget("LBRB_Vicinity");
121  m_TopConsoleToolbarHands = GetRootWidget().FindAnyWidget("LBRB_Hands");
122  m_TopConsoleToolbarEquipment = GetRootWidget().FindAnyWidget("LBRB_Equipment");
123 
124  RichTextWidget.Cast(m_TopConsoleToolbarVicinity.FindAnyWidget("LBRB_Vicinity_LBIcon")).SetText(InputUtils.GetRichtextButtonIconFromInputAction("UAUIInventoryTabLeft", "", EUAINPUT_DEVICE_CONTROLLER));
125  RichTextWidget.Cast(m_TopConsoleToolbarVicinity.FindAnyWidget("LBRB_Vicinity_RBIcon")).SetText(InputUtils.GetRichtextButtonIconFromInputAction("UAUIInventoryTabRight", "", EUAINPUT_DEVICE_CONTROLLER));
126  RichTextWidget.Cast(m_TopConsoleToolbarHands.FindAnyWidget("LBRB_Hands_LBIcon")).SetText(InputUtils.GetRichtextButtonIconFromInputAction("UAUIInventoryTabLeft", "", EUAINPUT_DEVICE_CONTROLLER));
127  RichTextWidget.Cast(m_TopConsoleToolbarHands.FindAnyWidget("LBRB_Hands_RBIcon")).SetText(InputUtils.GetRichtextButtonIconFromInputAction("UAUIInventoryTabRight", "", EUAINPUT_DEVICE_CONTROLLER));
128  RichTextWidget.Cast(m_TopConsoleToolbarEquipment.FindAnyWidget("LBRB_Equipment_LBIcon")).SetText(InputUtils.GetRichtextButtonIconFromInputAction("UAUIInventoryTabLeft", "", EUAINPUT_DEVICE_CONTROLLER));
129  RichTextWidget.Cast(m_TopConsoleToolbarEquipment.FindAnyWidget("LBRB_Equipment_RBIcon")).SetText(InputUtils.GetRichtextButtonIconFromInputAction("UAUIInventoryTabRight", "", EUAINPUT_DEVICE_CONTROLLER));
130 
131  m_BottomConsoleToolbar = GetRootWidget().FindAnyWidget("BottomConsoleToolbar");
132  m_BottomConsoleToolbarRichText = RichTextWidget.Cast(GetRootWidget().FindAnyWidget("ContextToolbarText"));
133 
135 
136  GetGame().GetMission().GetOnInputPresetChanged().Insert(OnInputPresetChanged);
137  GetGame().GetMission().GetOnInputDeviceChanged().Insert(OnInputDeviceChanged);
138 
139  m_SpecializationPanel.Show(false);
142  #endif
143  }
144 
146  {
147  int namesCount = m_InvInputNames.Count();
150 
151  for (int i = 0; i < namesCount; i++)
152  {
153  m_InvInputWrappers.Insert(GetUApi().GetInputByName(m_InvInputNames[i]).GetPersistentWrapper());
154  m_InvInputTimes.Insert(0);
155  }
156 
158  }
159 
160  protected void OnInputPresetChanged()
161  {
162  #ifdef PLATFORM_CONSOLE
164  #endif
165  }
166 
167  protected void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
168  {
169  switch (pInputDeviceType)
170  {
171  case EInputDeviceType.CONTROLLER:
172  m_BottomConsoleToolbar.Show(true);
174  break;
175 
176  default:
177  if (GetGame().GetInput().IsEnabledMouseAndKeyboardEvenOnServer())
178  {
179  m_BottomConsoleToolbar.Show(false);
180  m_TopConsoleToolbarVicinity.Show(false);
181  m_TopConsoleToolbarHands.Show(false);
182  m_TopConsoleToolbarEquipment.Show(false);
183  }
184  break;
185  }
186  }
187 
188  static Inventory GetInstance()
189  {
190  return m_Instance;
191  }
192 
193  void Serialize()
194  {
195  ItemManager.GetInstance().SerializeDefaultOpenStates();
196  ItemManager.GetInstance().SerializeDefaultHeaderOpenStates();
197  }
198 
199  void Deserialize()
200  {
201  ItemManager.GetInstance().DeserializeDefaultOpenStates();
202  ItemManager.GetInstance().DeserializeDefaultHeaderOpenStates();
203  }
204 
205  static int GetPlayerAttachmentIndex(string slot_name)
206  {
207  return m_PlayerAttachmentsIndexes[slot_name];
208  }
209 
210  static int GetPlayerAttachmentIndex(int slot_id)
211  {
212  return GetPlayerAttachmentIndex(InventorySlots.GetSlotName(slot_id));
213  }
214 
216  {
217  int i;
218  string data, errorMessage;
219 
220  m_PlayerAttachmentsIndexes = new map<string, int>();
221 
222  if (GetGame().GetProfileString("INV_AttIndexes", data))
223  {
224  if (!JsonFileLoader<map<string, int>>.LoadData(data, m_PlayerAttachmentsIndexes, errorMessage))
225  ErrorEx(errorMessage);
226  }
227 
228  string configPathGhostSlots = "CfgVehicles SurvivorBase InventoryEquipment playerSlots";
229  array<string> playerGhostSlots = new array<string>();
230  GetGame().ConfigGetTextArray(configPathGhostSlots, playerGhostSlots);
231 
232  foreach (string slotName : playerGhostSlots)
233  {
234  slotName.Replace("Slot_", "");
235  if (!m_PlayerAttachmentsIndexes.Contains(slotName) && InventorySlots.GetSlotIdFromString(slotName) != -1)
236  {
237  m_PlayerAttachmentsIndexes.Insert(slotName, m_PlayerAttachmentsIndexes.Count());
238  }
239  }
240 
241  if (!JsonFileLoader<map<string, int>>.MakeData(m_PlayerAttachmentsIndexes, data, errorMessage))
242  ErrorEx(errorMessage);
243 
244  GetGame().SetProfileString("INV_AttIndexes", data);
245  }
246 
247  static void MoveAttachmentUp(int slot_id)
248  {
249  int curr = GetPlayerAttachmentIndex(slot_id);
250 
251  int next_offset = 0;
252  string next_item = "init";
253  int next_id;
254  EntityAI next_ent;
255 
256  while(!next_ent && next_item != "")
257  {
258  next_item = m_PlayerAttachmentsIndexes.GetKeyByValue(curr + --next_offset);
259  next_id = InventorySlots.GetSlotIdFromString(next_item);
260  next_ent = GetGame().GetPlayer().GetInventory().FindAttachment(next_id);
261  if (next_ent && !m_Instance.m_RightArea.HasEntityContainerVisible(next_ent))
262  next_ent = null;
263  }
264 
265  if (next_item != "" && next_ent)
266  {
267  int next = GetPlayerAttachmentIndex(next_item);
268  m_PlayerAttachmentsIndexes.Set(InventorySlots.GetSlotName(slot_id), next);
269  m_PlayerAttachmentsIndexes.Set(next_item, curr);
270  if (m_Instance)
271  m_Instance.m_RightArea.SwapItemsInOrder(next_id, slot_id);
272  }
273  }
274 
275  static void MoveAttachmentDown(int slot_id)
276  {
277  int curr = GetPlayerAttachmentIndex(slot_id);
278 
279  int next_offset = 0;
280  string next_item = "init";
281  int next_id;
282  EntityAI next_ent;
283 
284  while(!next_ent && next_item != "")
285  {
286  next_item = m_PlayerAttachmentsIndexes.GetKeyByValue(curr + ++next_offset);
287  next_id = InventorySlots.GetSlotIdFromString(next_item);
288  next_ent = GetGame().GetPlayer().GetInventory().FindAttachment(next_id);
289  if (next_ent && !m_Instance.m_RightArea.HasEntityContainerVisible(next_ent))
290  next_ent = null;
291  }
292 
293  if (next_item != "" && next_ent)
294  {
295  int next = GetPlayerAttachmentIndex(next_item);
296  m_PlayerAttachmentsIndexes.Set(InventorySlots.GetSlotName(slot_id), next);
297  m_PlayerAttachmentsIndexes.Set(next_item, curr);
298  if (m_Instance)
299  m_Instance.m_RightArea.SwapItemsInOrder(next_id, slot_id);
300  }
301  }
302 
303  protected int GetProperControllerStickAngle(int angle)
304  {
305  int proper_angle = (360 - angle) % 360;
306  return proper_angle;
307  }
308 
309  protected int AngleToDirection(int angle)
310  {
311  if (angle < 45 || angle > 315)
312  {
313  return Direction.RIGHT;
314  }
315  else if (angle < 135 && angle > 45)
316  {
317  return Direction.DOWN;
318  }
319  else if (angle < 225 && angle > 135)
320  {
321  return Direction.LEFT;
322  }
323  else if (angle < 315 && angle > 225)
324  {
325  return Direction.UP;
326  }
327  return -1;
328  }
329 
330  void TimerEnd()
331  {
334  }
335 
336  bool Controller(Widget w, int control, int value)
337  {
338  #ifdef PLATFORM_CONSOLE
339 
340  //Right stick
341  if (control == ControlID.CID_RADIALMENU)
342  {
343  m_ControllerAngle = value >> 4; // <0,360>
344  m_ControllerTilt = value & 0xF; // <0,10>
345 
347 
349 
350  if (m_ControllerTilt>5)
351  {
353  {
355  m_ControllerRightStickTimer.Run(0.1, this, "TimerEnd");
356  }
357  }
358  return true;
359  }
360 
362  #endif
363  return false;
364  }
365 
366  void DraggingOverHandsPanel(Widget w, int x, int y, Widget receiver)
367  {
368  ItemManager.GetInstance().HideDropzones();
369  m_HandsArea.DraggingOverHandsPanel(w, x, y, receiver);
370  }
371 
372  void OnHandsPanelDropReceived(Widget w, int x, int y, Widget receiver)
373  {
374  m_HandsArea.OnHandsPanelDropReceived(w, x, y, receiver);
375  }
376 
377  void OnLeftPanelDropReceived(Widget w, int x, int y, Widget receiver)
378  {
379  m_LeftArea.OnLeftPanelDropReceived(w, x, y, receiver);
380  }
381 
382  void OnRightPanelDropReceived(Widget w, int x, int y, Widget receiver)
383  {
384  if (w)
385  {
386  ItemPreviewWidget ipw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
387  if (!ipw)
388  {
389  string name = w.GetName();
390  name.Replace("PanelWidget", "Render");
391  ipw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
392  if (!ipw)
393  {
394  ipw = ItemPreviewWidget.Cast(w);
395  if (!ipw)
396  {
397  return;
398  }
399  }
400  }
401 
402  EntityAI item = ipw.GetItem();
403  if (item)
404  {
405  PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
407  if (player && player.GetInventory().FindFreeLocationFor(item, FindInventoryLocationType.CARGO | FindInventoryLocationType.ATTACHMENT, il))
408  {
409  SplitItemUtils.TakeOrSplitToInventory(player, player, item);
410  }
411  }
412  }
413  }
414 
415  void OnCenterPanelDropReceived(Widget w, int x, int y, Widget receiver)
416  {
417  if (w)
418  {
419  ItemPreviewWidget ipw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
420  if (!ipw)
421  {
422  string name = w.GetName();
423  name.Replace("PanelWidget", "Render");
424  ipw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
425  if (!ipw)
426  {
427  ipw = ItemPreviewWidget.Cast(w);
428  if (!ipw)
429  {
430  return;
431  }
432  }
433  }
434 
435  EntityAI item = ipw.GetItem();
436  if (item)
437  {
438  if (!item.GetInventory().CanRemoveEntity())
439  return;
440  PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
441 
442  bool found = false;
443 
444  InventoryLocation inv_loc = new InventoryLocation;
445 
446  if (player)
447  {
448  int index = player.GetHumanInventory().FindUserReservedLocationIndex(item);
449  if (index>=0)
450  {
451  player.GetHumanInventory().GetUserReservedLocation(index, inv_loc);
452  if (player.GetInventory().LocationCanAddEntity(inv_loc))
453  {
454  SplitItemUtils.TakeOrSplitToInventoryLocation(player, inv_loc);
455  }
456  return;
457  }
458 
459  }
460 
461  if (player && (player.GetInventory().CanAddAttachment(item)))
462  {
463  float stackable = item.GetTargetQuantityMax(-1);
464 
465  if (stackable == 0 || stackable >= item.GetQuantity())
466  {
467  player.PredictiveTakeEntityAsAttachment(item);
468  }
469  else
470  {
472  player.GetInventory().FindFreeLocationFor(item, FindInventoryLocationType.ATTACHMENT, il);
473  ItemBase.Cast(item).SplitIntoStackMaxToInventoryLocationClient(il);
474  }
475  }
476  else
477  {
478  int slot_id = item.GetInventory().GetSlotId(0);
479  EntityAI slot_item = player.GetInventory().FindAttachment(slot_id);
480  if (slot_item && player.GetInventory().CanSwapEntitiesEx(item, slot_item))
481  {
482  player.PredictiveSwapEntities(item, slot_item);
483  }
484  else if (player.CanReceiveItemIntoCargo(item))
485  {
487  player.GetInventory().FindFreeLocationFor(item, FindInventoryLocationType.ANY, dst);
488  if (dst.IsValid())
489  {
490  if (dst.GetType() == InventoryLocationType.HANDS && item.IsHeavyBehaviour())
491  {
492  ActionManagerClient mngr_client;
493  CastTo(mngr_client, player.GetActionManager());
494 
495  ActionTarget atrg = new ActionTarget(item, null, -1, vector.Zero, -1.0);
496  if (mngr_client.GetAction(ActionTakeItemToHands).Can(player, atrg, null))
497  mngr_client.PerformActionStart(mngr_client.GetAction(ActionTakeItemToHands), atrg, null);
498 
499  return;
500  }
501 
502  SplitItemUtils.TakeOrSplitToInventoryLocation(player, dst);
503  }
504  }
505  }
506  }
507  }
508  }
509 
510  void DraggingOverLeftPanel(Widget w, int x, int y, Widget receiver)
511  {
512  m_LeftArea.DraggingOverHeader(w, x, y, receiver);
513  }
514 
515  void DraggingOverRightPanel(Widget w, int x, int y, Widget receiver)
516  {
517  m_RightArea.DraggingOverHeader(w, x, y, receiver);
518  }
519 
520  void DraggingOverCenterPanel(Widget w, int x, int y, Widget receiver)
521  {
522  if (w)
523  {
524  ItemPreviewWidget ipw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
525  if (!ipw)
526  {
527  string name = w.GetName();
528  name.Replace("PanelWidget", "Render");
529  ipw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
530  if (!ipw)
531  {
532  ipw = ItemPreviewWidget.Cast(w);
533  if (!ipw)
534  {
535  return;
536  }
537  }
538  }
539 
540  EntityAI item = ipw.GetItem();
541  PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
542 
543  if (player && item)
544  {
545  int slot_id = item.GetInventory().GetSlotId(0);
546  EntityAI slot_item = player.GetInventory().FindAttachment(slot_id);
547  bool found = false;
548 
549  InventoryLocation inv_loc = new InventoryLocation;
550 
551  int index = player.GetHumanInventory().FindUserReservedLocationIndex(item);
552  if (index>=0)
553  {
554  player.GetHumanInventory().GetUserReservedLocation(index, inv_loc);
555  if (player.GetInventory().LocationCanAddEntity(inv_loc))
556  found = true;
557  }
558 
559  if (!found)
560  {
561  player.GetInventory().FindFreeLocationFor(item, FindInventoryLocationType.ANY, inv_loc);
562  }
563 
564 
565  if (inv_loc.IsValid())
566  {
567  ItemManager.GetInstance().HideDropzones();
568  GetMainWidget().FindAnyWidget("RightPanel").FindAnyWidget("DropzoneX").SetAlpha(1);
569  if (inv_loc.GetType() == 4)
570  {
571  ItemManager.GetInstance().HideDropzones();
572  GetMainWidget().FindAnyWidget("HandsPanel").FindAnyWidget("DropzoneX").SetAlpha(1);
573  }
574 
575  ColorManager.GetInstance().SetColor(w, ColorManager.GREEN_COLOR);
576  }
577  else
578  {
579  ItemManager.GetInstance().ShowSourceDropzone(item);
580  ColorManager.GetInstance().SetColor(w, ColorManager.RED_COLOR);
581  }
582  }
583  else
584  {
585  ColorManager.GetInstance().SetColor(w, ColorManager.RED_COLOR);
586  }
587  }
588  }
589 
590  void Update(float timeslice)
591  {
592  #ifdef PLATFORM_CONSOLE
593  //inventory grid movement
595 
596  if (m_InvInputActive & (1 << INV_MOV_RIGHT))
597  {
598  if (GetUApi().GetInputByID(UAUIDragNDrop).LocalValue())
599  {
601  }
602 
603  if (!GetUApi().GetInputByID(UAUIInventoryTabRight).LocalValue())
604  {
605  if (m_RightArea.IsActive())
606  m_RightArea.MoveGridCursor(Direction.RIGHT);
607  if (m_LeftArea.IsActive())
608  m_LeftArea.MoveGridCursor(Direction.RIGHT);
609  if (m_HandsArea.IsActive())
610  m_HandsArea.MoveGridCursor(Direction.RIGHT);
611  }
612  }
613  else if (m_InvInputActive & (1 << INV_MOV_LEFT))
614  {
615  if (GetUApi().GetInputByID(UAUIDragNDrop).LocalValue())
616  {
618  }
619 
620  if (!GetUApi().GetInputByID(UAUIInventoryTabLeft).LocalValue())
621  {
622  if (m_RightArea.IsActive())
623  m_RightArea.MoveGridCursor(Direction.LEFT);
624  if (m_LeftArea.IsActive())
625  m_LeftArea.MoveGridCursor(Direction.LEFT);
626  if (m_HandsArea.IsActive())
627  m_HandsArea.MoveGridCursor(Direction.LEFT);
628  }
629  }
630  else if (m_InvInputActive & (1 << INV_MOV_UP))
631  {
632  if (GetUApi().GetInputByID(UAUIDragNDrop).LocalValue())
633  {
635  }
636 
637  if (!GetUApi().GetInputByID(UAUIInventoryContainerUp).LocalValue())
638  {
639  if (m_RightArea.IsActive())
640  m_RightArea.MoveGridCursor(Direction.UP);
641  if (m_LeftArea.IsActive())
642  m_LeftArea.MoveGridCursor(Direction.UP);
643  if (m_HandsArea.IsActive())
644  m_HandsArea.MoveGridCursor(Direction.UP);
645  }
646  }
647  else if (m_InvInputActive & (1 << INV_MOV_DOWN))
648  {
649  if (GetUApi().GetInputByID(UAUIDragNDrop).LocalValue())
650  {
652  }
653 
654  if (!GetUApi().GetInputByID(UAUIInventoryContainerDown).LocalValue())
655  {
656  if (m_RightArea.IsActive())
657  m_RightArea.MoveGridCursor(Direction.DOWN);
658  if (m_LeftArea.IsActive())
659  m_LeftArea.MoveGridCursor(Direction.DOWN);
660  if (m_HandsArea.IsActive())
661  m_HandsArea.MoveGridCursor(Direction.DOWN);
662  }
663  }
664 
665  m_InvInputActive = 0;
666  #endif
667 
668  UpdateInterval();
669  }
670 
672  override void UpdateInterval()
673  {
674  PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
675  InventoryItem item;
676  if (GetUApi().GetInputByID(UAUIRotateInventory).LocalPress())
677  {
678  item = InventoryItem.Cast(ItemManager.GetInstance().GetDraggedItem());
679  if (item)
680  {
681  int size_x, size_y;
682  GetGame().GetInventoryItemSize(item, size_x, size_y);
683  if (size_x != size_y)
684  {
685  item.GetInventory().FlipCargo();
686  item.GetOnItemFlipped().Invoke(item.GetInventory().GetFlipCargo());
687  }
688  }
689  }
690 
691  #ifdef PLATFORM_CONSOLE
693  if (player)
694  dpi = player.GetDayZPlayerInventory();
695 
696  // There's a second one a bit below
697  if (dpi && !dpi.IsProcessing())
698  {
699  if (GetUApi().GetInputByID(UAUIExpandCollapseContainer).LocalPress())
700  {
701  if (m_RightArea.IsActive())
702  {
703  m_RightArea.ExpandCollapseContainer();
704  }
705  else if (m_LeftArea.IsActive())
706  {
707  m_LeftArea.ExpandCollapseContainer();
708  }
709  }
710 
711  if (GetUApi().GetInputByID(UAUIDragNDrop).LocalHoldBegin())
712  {
714  }
715 
716  if (GetUApi().GetInputByID(UAUISplit).LocalPress())
717  {
718  if (m_HandsArea.IsActive())
719  {
720  if (m_HandsArea.SplitItem())
721  {
722  m_HandsArea.SetActive(false);
723  m_HandsArea.UnfocusGrid();
724  m_RightArea.SetActive(true);
725  }
726  }
727  else if (m_RightArea.IsActive())
728  {
729  m_RightArea.SplitItem();
730  }
731  else if (m_LeftArea.IsActive())
732  {
733  m_LeftArea.SplitItem();
734  }
735 
736  HideOwnedTooltip();
737  }
738 
739  if (GetUApi().GetInputByID(UAUIFastEquip).LocalPress())
740  {
741  if (m_HandsArea.IsActive())
742  {
743  if (m_HandsArea.EquipItem())
744  {
745  m_HandsArea.SetActive(false);
746  m_HandsArea.UnfocusGrid();
747  m_RightArea.SetActive(true);
748  }
749  }
750  else if (m_RightArea.IsActive())
751  {
752  m_RightArea.EquipItem();
753  }
754  else if (m_LeftArea.IsActive())
755  {
756  m_LeftArea.EquipItem();
757  }
758 
760  HideOwnedTooltip();
761  }
762 
763  if (ItemManager.GetInstance().IsMicromanagmentMode() && GetUApi().GetInputByID(UAUIDragNDrop).LocalRelease())
764  {
765  if (m_RightArea.IsActive())
766  {
767  m_RightArea.Select();
768  }
769  else if (m_LeftArea.IsActive())
770  {
771  m_LeftArea.Select();
772  }
773  else if (m_HandsArea.IsActive())
774  {
775  m_HandsArea.Select();
776  }
777 
780  }
781  if (GetUApi().GetInputByID(UAUIPutInHandsFromVicinity).LocalPress())
782  {
783  if (m_LeftArea.IsActive())
784  {
785  if (m_LeftArea.Select())
786  {
787  m_LeftArea.SetActive(false);
788  m_LeftArea.UnfocusGrid();
789  m_HandsArea.SetActive(true);
790 
792  }
793  }
794  }
795  if (GetUApi().GetInputByID(UAUIPutInHandsFromInventory).LocalPress())
796  {
797  if (m_RightArea.IsActive())
798  {
799  if (m_RightArea.Select())
800  {
801  m_RightArea.SetActive(false);
802  m_RightArea.UnfocusGrid();
803  m_HandsArea.SetActive(true);
804 
806  }
807  }
808  }
809 
810  if (GetUApi().GetInputByID(UAUIFastTransferToVicinity).LocalPress()) //item drop
811  {
812  if (m_HandsArea.IsActive())
813  {
814  item = InventoryItem.Cast(m_HandsArea.GetFocusedItem());
815  if (item && item.GetInventory().CanRemoveEntity())
816  {
817  if (m_HandsArea.TransferItemToVicinity())
818  {
819  m_HandsArea.SetActive(false);
820  m_HandsArea.UnfocusGrid();
821  m_LeftArea.SetActive(true);
822  m_HadFastTransferred = true;
823  }
824  }
825  }
826  else if (m_RightArea.IsActive())
827  {
828  item = InventoryItem.Cast(m_RightArea.GetFocusedItem());
829  if (item && item.GetInventory().CanRemoveEntity())
830  {
831  if (m_RightArea.TransferItemToVicinity())
832  m_HadFastTransferred = true;
833  }
834  }
835 
837  HideOwnedTooltip();
838  }
839  }
840 
841  if (GetUApi().GetInputByID(UAUIInspectItem).LocalPress())
842  {
843  if (m_HandsArea.IsActive())
844  {
845  if (m_HandsArea.InspectItem())
846  {
847  m_HadInspected = true;
848  }
849  }
850  else if (m_RightArea.IsActive())
851  {
852  if (m_RightArea.InspectItem())
853  {
854  m_HadInspected = true;
855  }
856  }
857  else if (m_LeftArea.IsActive())
858  {
859  if (m_LeftArea.InspectItem())
860  {
861  m_HadInspected = true;
862  }
863  }
864 
866  }
867 
868  if (GetUApi().GetInputByID(UAUIFastTransferItem).LocalPress())
869  m_HadFastTransferred = false;
870 
871  if (GetUApi().GetInputByID(UAUIInspectItem).LocalPress())
872  m_HadInspected = false;
873 
874  if (dpi && !dpi.IsProcessing())
875  {
876  if (!m_HadFastTransferred && GetUApi().GetInputByID(UAUIFastTransferItem).LocalPress()) //transfers item to inventory (not hands, or hands last?)
877  {
878  if (m_LeftArea.IsActive())
879  {
880  item = InventoryItem.Cast(m_LeftArea.GetFocusedItem());
881  if (item && item.GetInventory().CanRemoveEntity())
882  {
883  m_LeftArea.TransferItem();
884  }
885  }
886  else if (m_HandsArea.IsActive())
887  {
888  item = InventoryItem.Cast(m_HandsArea.GetFocusedItem());
889  if (item && item.GetInventory().CanRemoveEntity())
890  {
891  if (m_HandsArea.TransferItem())
892  {
893  m_HandsArea.SetActive(false);
894  m_HandsArea.UnfocusGrid();
895  m_RightArea.SetActive(true);
896  }
897  }
898  }
899 
901  HideOwnedTooltip();
902  }
903  }
904 
905  if (GetUApi().GetInputByID(UAUIInventoryContainerUp).LocalPress())
906  {
907  if (GetUApi().GetInputByID(UAUIDragNDrop).LocalValue())
908  {
910  }
911 
913  }
914 
915  if (GetUApi().GetInputByID(UAUIInventoryContainerDown).LocalPress())
916  {
917  if (GetUApi().GetInputByID(UAUIDragNDrop).LocalValue())
918  {
920  }
921 
923  }
924 
925  if (GetUApi().GetInputByID(UAUIInventoryTabLeft).LocalPress())
926  {
927  if (GetUApi().GetInputByID(UAUIDragNDrop).LocalValue())
928  {
930  }
931 
933  }
934 
935  if (GetUApi().GetInputByID(UAUIInventoryTabRight).LocalPress())
936  {
937  if (GetUApi().GetInputByID(UAUIDragNDrop).LocalValue())
938  {
940  }
941 
942  MoveFocusByArea(Direction.RIGHT);
943  }
944 
945  //Open Quickbar radial menu
946  if (GetUApi().GetInputByID(UAUIQuickbarRadialInventoryOpen).LocalPress())
947  {
948  //assign item
949  EntityAI item_to_assign;
950 
951  if (m_HandsArea.IsActive())
952  {
953  player = PlayerBase.Cast(GetGame().GetPlayer());
954  item_to_assign = player.GetItemInHands();
955  m_HandsArea.AddItemToQuickbarRadial(item_to_assign);
956  }
957  else if (m_RightArea.IsActive())
958  {
959  item_to_assign = m_RightArea.GetFocusedItem();
960  m_RightArea.AddItemToQuickbarRadial(item_to_assign);
961  }
962  }
963  #endif
964 
965  MissionGameplay mission = MissionGameplay.Cast(GetGame().GetMission());
966  if (!m_HadInspected && GetUApi().GetInputByID(UAUICombine).LocalPress())
967  {
968  if (GetMainWidget().IsVisible())
969  {
970  #ifdef PLATFORM_CONSOLE
971  //DisableMicromanagement();
972  if (m_RightArea.IsActive())
973  {
974  if (m_RightArea.CanCombine())
975  {
976  if (m_RightArea.Combine())
977  {
978  mission.HideInventory();
979  }
980  }
981  }
982  else if (m_LeftArea.IsActive())
983  {
984  if (m_LeftArea.CanCombine())
985  {
986  if (m_LeftArea.Combine())
987  {
988  mission.HideInventory();
989  }
990  }
991  }
992  #endif
993  }
994  }
995 
996  if (!m_HadInspected && GetUApi().GetInputByID(UAUIBack).LocalPress())
997  {
998  mission.HideInventory();
999  }
1000 
1001  for (int i = 0; i < 10; i++)
1002  {
1003  if (!m_HoldingQB && GetUApi().GetInputByName("UAItem" + i).LocalPress())
1004  {
1005  m_QBHoveredItems = InventoryItem.Cast(ItemManager.GetInstance().GetHoveredItem());
1006  m_HoldingQB = true;
1007  }
1008 
1009  if (m_HoldingQB && GetUApi().GetInputByName("UAItem" + i).LocalHold())
1010  {
1011 
1013  m_QBHoveredItems = null;
1014  m_HoldingQB = false;
1015  }
1016  }
1017 
1018  m_LeftArea.UpdateInterval();
1019  m_RightArea.UpdateInterval();
1020  m_HandsArea.UpdateInterval();
1021  m_PlayerPreview.UpdateInterval();
1022 
1023  #ifdef PLATFORM_CONSOLE
1024  UpdateConsoleToolbarCheck();
1025  #endif
1026  }
1027 
1028  void AddQuickbarItem(InventoryItem item, int index)
1029  {
1030  PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
1031 
1032  if (item && item.GetInventory().CanRemoveEntity())
1033  {
1034  player.SetQuickBarEntityShortcut(item, index) ;
1035  }
1036 
1037  InventoryMenu menu = InventoryMenu.Cast(GetGame().GetUIManager().FindMenu(MENU_INVENTORY));
1038  if (menu)
1039  {
1040  menu.RefreshQuickbar();
1041  }
1042  }
1043 
1045  {
1046  if (!ItemManager.GetInstance().IsMicromanagmentMode())
1047  {
1048  ItemManager.GetInstance().SetItemMicromanagmentMode(true);
1049  if (m_RightArea.IsActive())
1050  {
1051  m_RightArea.SelectItem();
1052  }
1053  else if (m_LeftArea.IsActive())
1054  {
1055  m_LeftArea.SelectItem();
1056  }
1057  else if (m_HandsArea.IsActive())
1058  {
1059  m_HandsArea.SelectItem();
1060  }
1061 
1063  HideOwnedTooltip();
1064  }
1065  }
1066 
1068  {
1069  if (ItemManager.GetInstance().IsMicromanagmentMode())
1070  {
1071  ItemManager.GetInstance().SetItemMicromanagmentMode(false);
1072  ItemManager.GetInstance().SetSelectedItemEx(null, null, null);
1074  HideOwnedTooltip();
1075  }
1076  }
1077 
1078  override void SetLayoutName()
1079  {
1080  #ifdef PLATFORM_CONSOLE
1081  m_LayoutName = WidgetLayoutName.InventoryXbox;
1082  #else
1083  switch (InventoryMenu.GetWidthType())
1084  {
1085  case ScreenWidthType.NARROW:
1086  {
1087  m_LayoutName = WidgetLayoutName.InventoryNarrow;
1088  break;
1089  }
1090  case ScreenWidthType.MEDIUM:
1091  {
1092  m_LayoutName = WidgetLayoutName.InventoryMedium;
1093  break;
1094  }
1095  case ScreenWidthType.WIDE:
1096  {
1097  m_LayoutName = WidgetLayoutName.InventoryWide;
1098  break;
1099  }
1100  }
1101  #endif
1102  }
1103 
1104  void Init() {}
1105 
1106  void Reset()
1107  {
1108  m_LeftArea.Refresh();
1109  m_RightArea.Refresh();
1110  m_HandsArea.Refresh();
1111  }
1112 
1114  {
1115  #ifdef PLATFORM_CONSOLE
1116  m_RightArea.UnfocusGrid();
1117  m_LeftArea.UnfocusGrid();
1118  m_HandsArea.UnfocusGrid();
1119 
1120  m_LeftArea.SetActive(false);
1121  m_HandsArea.SetActive(false);
1122  m_RightArea.SetActive(false);
1123 
1124  m_RightArea.ResetFocusedContainer();
1125  m_LeftArea.ResetFocusedContainer();
1126 
1127  m_RightArea.SetActive(true);
1128  #endif
1129  }
1130 
1131  override void OnShow()
1132  {
1133  SetFocus(GetMainWidget());
1134  Deserialize();
1135 
1136  PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
1137  if (player && player.IsPlacingLocal())
1138  {
1139  GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Call(player.TogglePlacingLocal);
1140  }
1141 
1142  Mission mission = GetGame().GetMission();
1143  if (mission)
1144  {
1145  IngameHud hud = IngameHud.Cast(mission.GetHud());
1146  if (hud)
1147  {
1148  hud.ShowQuickbarUI(false);
1149  hud.ShowHudInventory(true);
1150  }
1151  }
1152 
1154 
1155  #ifdef PLATFORM_CONSOLE
1157  #endif
1158 
1159  RefreshQuickbar();
1160  UpdateInterval();
1162 
1163  m_HadFastTransferred = false;
1164  m_HadInspected = false;
1165 
1166  m_PlayerPreview.RefreshPlayerPreview();
1167  }
1168 
1169  override void OnHide()
1170  {
1171  Serialize();
1172  HideOwnedTooltip();
1173  Mission mission = GetGame().GetMission();
1174  if (mission)
1175  {
1176  IngameHud hud = IngameHud.Cast(mission.GetHud());
1177  if (hud)
1178  {
1179  hud.ShowQuickbarUI(true);
1180  hud.ShowHudInventory(false);
1181  }
1182  }
1183  ItemManager.GetInstance().SetSelectedItemEx(null, null, null);
1184  }
1185 
1187  {
1188  PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
1189  if (player && player.GetSoftSkillsManager())
1190  {
1191  float x = player.GetSoftSkillsManager().GetSpecialtyLevel() / 2;
1192  float y = -0.75;
1193  #ifndef PLATFORM_CONSOLE
1194  m_SpecializationIcon.SetPos(x, y, true);
1195  #else
1196  Mission mission = GetGame().GetMission();
1197  IngameHud hud = IngameHud.Cast(mission.GetHud());
1198  if (hud)
1199  {
1200  hud.UpdateSpecialtyMeter(x,y);
1201  }
1202  #endif
1203  }
1204  }
1205 
1206  override void Refresh()
1207  {
1208  m_LeftArea.Refresh();
1209  m_HandsArea.Refresh();
1210  m_RightArea.Refresh();
1211 
1212  RefreshQuickbar();
1214  }
1215 
1217  {
1218  #ifndef PLATFORM_CONSOLE
1219  m_QuickbarWidget.Show(true);
1220  #else
1221  m_QuickbarWidget.Show(GetGame().GetInput().IsEnabledMouseAndKeyboardEvenOnServer());
1222  #endif
1223 
1224  #ifndef PLATFORM_CONSOLE
1225  if (m_Quickbar)
1226  #else
1227  if (m_Quickbar && GetGame().GetInput().IsEnabledMouseAndKeyboardEvenOnServer())
1228  #endif
1229  {
1230  m_Quickbar.UpdateItems(m_QuickbarWidget);
1231  }
1232  }
1233 
1234 
1235  #ifdef PLATFORM_CONSOLE
1236  protected string GetConsoleToolbarText(int mask)
1237  {
1238  string result = "";
1239 
1240  string toHandsSwapVicinity = string.Format(" %1", InputUtils.GetRichtextButtonIconFromInputAction("UAUIPutInHandsFromVicinity", GetStringVariant("UAUIPutInHandsFromVicinity",{"#STR_Controls_TakeInHandsSwap","#STR_USRACT_HoldToHandSwap",""}), EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
1241  string toHandsSwapInv = string.Format(" %1", InputUtils.GetRichtextButtonIconFromInputAction("UAUIPutInHandsFromInventory", GetStringVariant("UAUIPutInHandsFromInventory",{"#STR_Controls_TakeInHandsSwap","#STR_USRACT_HoldToHandSwap",""}), EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
1242  string drop = string.Format(" %1", InputUtils.GetRichtextButtonIconFromInputAction("UAUIFastTransferToVicinity", "#dayz_context_menu_drop", EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
1243  string equip = string.Format(" %1", InputUtils.GetRichtextButtonIconFromInputAction("UAUIFastEquip", "#dayz_context_menu_equip", EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
1244  string split = string.Format(" %1", InputUtils.GetRichtextButtonIconFromInputAction("UAUISplit", GetStringVariant("UAUISplit",{"#dayz_context_menu_split","#STR_Controls_HoldSplit",""}), EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
1245  string toInventory = string.Format(" %1", InputUtils.GetRichtextButtonIconFromInputAction("UAUIFastTransferItem", "#dayz_context_menu_to_inventory", EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
1246  string openCloseContainer = string.Format(" %1", InputUtils.GetRichtextButtonIconFromInputAction("UAUIExpandCollapseContainer", "#dayz_context_menu_open_close", EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
1247  string micromanagment = string.Format(" %1", InputUtils.GetRichtextButtonIconFromInputAction("UAUIDragNDrop", "#dayz_context_menu_micro", EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
1248  string quickslot = string.Format(" %1", InputUtils.GetRichtextButtonIconFromInputAction("UAUIQuickbarRadialInventoryOpen", "#ps4_dayz_context_menu_quickslot", EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
1249  string combine = string.Format(" %1", InputUtils.GetRichtextButtonIconFromInputAction("UAUICombine", GetStringVariant("UAUICombine",{"#dayz_context_menu_combine","#dayz_context_menu_combine_hold",""}), EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
1250 
1251  if (mask & ConsoleActionToolbarMask.OPEN_CLOSE_CONTAINER)
1252  {
1253  result += openCloseContainer;
1254  }
1255  if (mask & ConsoleActionToolbarMask.TO_HANDS_SWAP_VICINITY)
1256  {
1257  result += toHandsSwapVicinity;
1258  }
1259  if (mask & ConsoleActionToolbarMask.TO_HANDS_SWAP_INVENTORY)
1260  {
1261  result += toHandsSwapInv;
1262  }
1263  if (mask & ConsoleActionToolbarMask.TO_INVENTORY)
1264  {
1265  result += toInventory;
1266  }
1267  if (mask & ConsoleActionToolbarMask.DROP)
1268  {
1269  result += drop;
1270  }
1271  if (mask & ConsoleActionToolbarMask.SPLIT)
1272  {
1273  result += split;
1274  }
1275  if (mask & ConsoleActionToolbarMask.EQUIP)
1276  {
1277  result += equip;
1278  }
1279  if (mask & ConsoleActionToolbarMask.COMBINE)
1280  {
1281  result += combine;
1282  }
1283  if (mask & ConsoleActionToolbarMask.MICROMANAGMENT)
1284  {
1285  result += micromanagment;
1286  }
1287  if (mask & ConsoleActionToolbarMask.QUICKSLOT)
1288  {
1289  result += quickslot;
1290  }
1291 
1292  return result;
1293  }
1294  #endif
1295 
1297  {
1298  if (m_LeftArea && m_LeftArea.IsActive())
1299  {
1300  return m_LeftArea;
1301  }
1302  else if (m_RightArea && m_RightArea.IsActive())
1303  {
1304  return m_RightArea;
1305  }
1306  else if (m_HandsArea && m_HandsArea.IsActive())
1307  {
1308  return m_HandsArea;
1309  }
1310  return null;
1311  }
1312 
1313  #ifdef PLATFORM_CONSOLE
1314  void UpdateConsoleToolbarCheck()
1315  {
1317  {
1318  PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
1319  if (player.GetInventory().GetAnyInventoryReservationCount() == 0)
1320  {
1323  }
1324  }
1325  }
1326  #endif
1327 
1328  //Console toolbar
1330  {
1331  #ifdef PLATFORM_CONSOLE
1332  int combinationFlag = 0;
1333  string contextualText;
1334  InventoryLocation il;
1335 
1336  Container focusedArea = GetFocusedArea();
1337  if (focusedArea)
1338  {
1339  Container focusedContainer = GetFocusedArea().GetFocusedContainer();
1340  EntityAI focusedItem = GetFocusedArea().GetFocusedItem();
1341 
1342  if (!(focusedItem && focusedItem.IsSetForDeletion()))
1343  {
1344  if (focusedContainer)
1345  {
1346  if (focusedItem)
1347  {
1348  il = new InventoryLocation;
1349  focusedItem.GetInventory().GetCurrentInventoryLocation( il );
1350  }
1351 
1352  bool canBeManipulated = false;
1353  PlayerBase player;
1354  PlayerBase itemPlayerOwner;
1355 
1356  player = PlayerBase.Cast(GetGame().GetPlayer());
1357 
1358  m_NeedUpdateConsoleToolbar = player.GetInventory().GetAnyInventoryReservationCount() > 0;
1359 
1360  if (focusedItem)
1361  {
1362  itemPlayerOwner = PlayerBase.Cast(focusedItem.GetHierarchyRootPlayer());
1363  il = new InventoryLocation;
1364  focusedItem.GetInventory().GetCurrentInventoryLocation( il );
1365 
1366  canBeManipulated = !player.GetInventory().HasInventoryReservation( focusedItem, null ) && !player.GetInventory().IsInventoryLocked() && !player.IsItemsToDelete();
1367  m_NeedUpdateConsoleToolbar |= !canBeManipulated;
1368  canBeManipulated = canBeManipulated && focusedItem.CanPutIntoHands(null);
1369  canBeManipulated = canBeManipulated && focusedItem.GetInventory().CanRemoveEntity();
1370 
1371  EntityAI parent = il.GetParent();
1372  if ( parent && il.GetType() == InventoryLocationType.ATTACHMENT )
1373  {
1374  canBeManipulated = canBeManipulated && AttachmentsOutOfReach.IsAttachmentReachable( parent, "", il.GetSlot() );
1375  canBeManipulated = canBeManipulated && !parent.GetInventory().GetSlotLock( il.GetSlot() );
1376  }
1377 
1378  if (canBeManipulated)
1379  {
1380  if (!ItemManager.GetInstance().IsMicromanagmentMode())
1381  {
1382  combinationFlag |= ConsoleActionToolbarMask.MICROMANAGMENT;
1383  }
1384 
1385  if (focusedContainer.CanEquipEx(focusedItem))
1386  {
1387  combinationFlag |= ConsoleActionToolbarMask.EQUIP;
1388  }
1389 
1390  if (player!= null && player == itemPlayerOwner)
1391  {
1392  if (focusedContainer.CanSwapOrTakeToHandsEx(focusedItem))
1393  {
1394  combinationFlag |= ConsoleActionToolbarMask.TO_HANDS_SWAP_INVENTORY;
1395  }
1396 
1397  if (focusedContainer.CanDropEx(focusedItem))
1398  {
1399  combinationFlag |= ConsoleActionToolbarMask.DROP;
1400  }
1401  }
1402  else
1403  {
1404  if (focusedContainer.CanSwapOrTakeToHandsEx(focusedItem))
1405  {
1406  combinationFlag |= ConsoleActionToolbarMask.TO_HANDS_SWAP_VICINITY;
1407  }
1408  }
1409 
1410  if (focusedContainer.CanCombineEx(focusedItem))
1411  {
1412  combinationFlag |= ConsoleActionToolbarMask.COMBINE;
1413  }
1414 
1415  if (focusedContainer.CanSplitEx(focusedItem))
1416  {
1417  combinationFlag |= ConsoleActionToolbarMask.SPLIT;
1418  }
1419 
1420  if (focusedArea.CanTakeToInventoryEx(focusedItem))
1421  {
1422  combinationFlag |= ConsoleActionToolbarMask.TO_INVENTORY;
1423  }
1424  }
1425  }
1426 
1427  if (focusedContainer.CanOpenCloseContainerEx(focusedItem))
1428  {
1429  combinationFlag |= ConsoleActionToolbarMask.OPEN_CLOSE_CONTAINER;
1430  }
1431 
1432  if (player!= null && focusedContainer.CanAddToQuickbarEx(focusedItem))
1433  {
1434  combinationFlag |= ConsoleActionToolbarMask.QUICKSLOT;
1435  }
1436  }
1437  }
1438  contextualText = GetConsoleToolbarText(combinationFlag);
1440  m_TopConsoleToolbarVicinity.Show(m_LeftArea.IsActive());
1442  m_TopConsoleToolbarHands.Show(m_HandsArea.IsActive());
1444  m_TopConsoleToolbarEquipment.Show(m_RightArea.IsActive());
1446  m_BottomConsoleToolbarRichText.SetText(contextualText + " ");
1447  }
1448  #endif
1449  }
1450 
1452  string GetStringVariant(string pInputAction, notnull array<string> variants)
1453  {
1454  if (variants.Count() != 3)
1455  {
1456  ErrorEx("wrong array count!");
1457  return "";
1458  }
1459 
1460  UAInput inp = GetUApi().GetInputByName(pInputAction);
1461  if (!inp.IsLimited() || inp.IsClickLimit()) //returns 'click' (no extension) variant as default
1462  {
1463  return variants[0];
1464  }
1465  if (inp.IsHoldLimit() || inp.IsHoldBeginLimit())
1466  {
1467  return variants[1];
1468  }
1469  if (inp.IsDoubleClickLimit())
1470  {
1471  return variants[2];
1472  }
1473  ErrorEx("Unhandled limiter exception!");
1474  return "";
1475  }
1476 
1478  void MoveFocusByContainer(int direction)
1479  {
1480  HideOwnedTooltip();
1481 
1482  if (direction == Direction.UP)
1483  {
1484  if ( m_LeftArea.IsActive() )
1485  {
1486  m_LeftArea.SetSameLevelPreviousActive();
1487  }
1488  else if ( m_RightArea.IsActive() )
1489  {
1490  m_RightArea.SetSameLevelPreviousActive();
1491  }
1492  else if ( m_HandsArea.IsActive() )
1493  {
1494  m_HandsArea.SetSameLevelPreviousActive();
1495  }
1496 
1498  }
1499  else if (direction == Direction.DOWN)
1500  {
1501  if ( m_LeftArea.IsActive() )
1502  {
1503  m_LeftArea.SetSameLevelNextActive();
1504  }
1505  else if ( m_RightArea.IsActive() )
1506  {
1507  m_RightArea.SetSameLevelNextActive();
1508  }
1509  else if ( m_HandsArea.IsActive() )
1510  {
1511  m_HandsArea.SetSameLevelNextActive();
1512  }
1513 
1515  }
1516  }
1517 
1519  void MoveFocusByArea(int direction)
1520  {
1521  HideOwnedTooltip();
1522  PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
1523 
1524  if (direction == Direction.LEFT)
1525  {
1526  if (m_LeftArea.IsActive())
1527  {
1528  if (!ItemManager.GetInstance().IsMicromanagmentMode())
1529  {
1530  m_LeftArea.UnfocusGrid();
1531  }
1532  m_LeftArea.SetActive(false);
1533  m_RightArea.SetActive(true);
1534 
1536  }
1537  else if (m_RightArea.IsActive())
1538  {
1539  if (!ItemManager.GetInstance().IsMicromanagmentMode())
1540  {
1541  m_RightArea.UnfocusGrid();
1542  }
1543  m_RightArea.SetActive(false);
1544  player = PlayerBase.Cast(GetGame().GetPlayer());
1545  EntityAI item_in_hands = player.GetItemInHands();
1546  m_HandsArea.SetActive(true);
1547 
1549  }
1550  else if (m_HandsArea.IsActive())
1551  {
1552  m_HandsArea.UnfocusGrid();
1553  m_HandsArea.SetActive(false);
1554  m_LeftArea.SetActive(true);
1555 
1557  }
1558  }
1559  else if (direction == Direction.RIGHT)
1560  {
1561  if (m_LeftArea.IsActive())
1562  {
1563  if (!ItemManager.GetInstance().IsMicromanagmentMode())
1564  {
1565  m_LeftArea.UnfocusGrid();
1566  }
1567  m_LeftArea.SetActive(false);
1568  player = PlayerBase.Cast(GetGame().GetPlayer());
1569  item_in_hands = player.GetItemInHands();
1570  m_HandsArea.SetActive(true);
1571 
1573  }
1574  else if (m_RightArea.IsActive())
1575  {
1576  if (!ItemManager.GetInstance().IsMicromanagmentMode())
1577  {
1578  m_RightArea.UnfocusGrid();
1579  }
1580  m_RightArea.SetActive(false);
1581  m_LeftArea.SetActive(true);
1582 
1584  }
1585  else if (m_HandsArea.IsActive())
1586  {
1587  m_HandsArea.UnfocusGrid();
1588  m_HandsArea.SetActive(false);
1589  m_RightArea.SetActive(true);
1590 
1592  }
1593  }
1594  }
1595 
1597  {
1598  float tickvalue = 0;
1599 
1600  if (m_SensitivityThreshold > 0.0)
1601  {
1602  if (m_SensitivityThreshold < BT_REPEAT_TIME) //sensitivity solution...
1603  {
1604  m_SensitivityThreshold += timeslice;
1605  return;
1606  }
1607  else
1608  {
1609  m_SensitivityThreshold = 0.0;
1610  }
1611  }
1612 
1613  for (int i = 0; i < m_InvInputWrappersCount; i++)
1614  {
1615  m_InvUAInput = m_InvInputWrappers[i].InputP();
1616 
1617  if (m_InvUAInput.LocalValue() > BT_THRESHOLD_VALUE)
1618  {
1619  tickvalue = m_InvInputTimes[i];
1620  tickvalue += timeslice;
1621  }
1622  else
1623  {
1624  tickvalue = 0.0;
1625  }
1626 
1627  if (tickvalue < BT_REPEAT_DELAY && m_InvUAInput.LocalPress())
1628  {
1629  m_InvInputActive |= (1 << i);
1630  m_SensitivityThreshold += timeslice;
1631  }
1632  else if (tickvalue > (BT_REPEAT_DELAY + BT_REPEAT_TIME))
1633  {
1634  while (tickvalue > (BT_REPEAT_DELAY + BT_REPEAT_TIME))
1635  {
1636  tickvalue -= BT_REPEAT_TIME;
1637  }
1638 
1639  m_InvInputActive |= (1 << i);
1640  m_SensitivityThreshold += timeslice;
1641  }
1642  else
1643  {
1644  m_InvInputActive &= ~(1 << i);
1645  }
1646 
1647  m_InvInputTimes[i] = tickvalue;
1648  }
1649  }
1650 }
ItemBase
Definition: inventoryitem.c:730
AngleToDirection
protected int AngleToDirection(int angle)
Definition: inventory.c:309
GetGame
proto native CGame GetGame()
PlayerPreview
Definition: playerpreview.c:1
BT_REPEAT_DELAY
const float BT_REPEAT_DELAY
Definition: inventory.c:61
LayoutHolder
Definition: container.c:1
CALL_CATEGORY_SYSTEM
const int CALL_CATEGORY_SYSTEM
Definition: tools.c:8
ActionTakeItemToHands
Definition: actiontakeitemtohands.c:1
m_BottomConsoleToolbar
protected Widget m_BottomConsoleToolbar
Definition: inventory.c:40
m_InvInputTimes
protected ref array< float > m_InvInputTimes
Definition: inventory.c:70
mission
Mission mission
Definition: displaystatus.c:28
m_SensitivityThreshold
protected float m_SensitivityThreshold
Definition: inventory.c:72
LoadPlayerAttachmentIndexes
protected void LoadPlayerAttachmentIndexes()
Definition: inventory.c:215
m_LeftArea
enum Direction m_LeftArea
m_ControllerTilt
protected int m_ControllerTilt
Definition: inventory.c:53
InputUtils
Definition: inpututils.c:1
Mission
Mission class.
Definition: gameplay.c:670
DROP
@ DROP
Definition: eanimsoundeventid.c:3
InventorySlots
provides access to slot configuration
Definition: inventoryslots.c:5
m_QuickbarWidget
protected Widget m_QuickbarWidget
Definition: inventory.c:34
m_InvInputActive
int m_InvInputActive
Definition: inventory.c:74
UAInput
Definition: uainput.c:23
RefreshQuickbar
void RefreshQuickbar()
Definition: inventory.c:1216
m_ControllerRightStickTimerEnd
protected bool m_ControllerRightStickTimerEnd
Definition: inventory.c:54
BT_REPEAT_TIME
const float BT_REPEAT_TIME
Definition: inventory.c:62
DayZPlayerInventory
Definition: dayzplayerinventory.c:111
EMPTY
const string EMPTY
Lists loot spawns that are not abandoned but have no loot.
Definition: centraleconomy.c:181
MoveFocusByContainer
void MoveFocusByContainer(int direction)
Shifts between containers vertically.
Definition: inventory.c:1478
MoveFocusByArea
void MoveFocusByArea(int direction)
Shifts between vicinity-hands-player.
Definition: inventory.c:1519
BT_THRESHOLD_VALUE
const float BT_THRESHOLD_VALUE
Definition: inventory.c:63
m_InvUAInput
UAInput m_InvUAInput
Definition: inventory.c:73
InventoryMovementButtonTickHandler
void InventoryMovementButtonTickHandler(float timeslice)
Definition: inventory.c:1596
UP
@ UP
Definition: inventory.c:22
DraggingOverRightPanel
void DraggingOverRightPanel(Widget w, int x, int y, Widget receiver)
Definition: inventory.c:515
y
Icon y
AttachmentsOutOfReach
Definition: attachmentsoutofreach.c:1
INV_MOV_RIGHT
const int INV_MOV_RIGHT
Definition: inventory.c:65
InventoryLocation
InventoryLocation.
Definition: inventorylocation.c:27
OnHandsPanelDropReceived
void OnHandsPanelDropReceived(Widget w, int x, int y, Widget receiver)
Definition: inventory.c:372
DraggingOverHandsPanel
void DraggingOverHandsPanel(Widget w, int x, int y, Widget receiver)
Definition: inventory.c:366
WidgetLayoutName
Definition: widgetlayoutname.c:1
AddQuickbarItem
void AddQuickbarItem(InventoryItem item, int index)
Definition: inventory.c:1028
m_HoldingQB
protected bool m_HoldingQB
Definition: inventory.c:57
m_SpecializationIcon
protected Widget m_SpecializationIcon
Definition: inventory.c:36
INV_MOV_UP
const int INV_MOV_UP
Definition: inventory.c:66
Update
void Update(float timeslice)
Definition: inventory.c:590
SplitItemUtils
Definition: splititemutils.c:1
InventoryItem
Definition: itembase.c:13
LEFT
@ LEFT
Definition: inventory.c:21
FindAnyWidget
proto native Widget FindAnyWidget(string pathname)
OnHide
override void OnHide()
Definition: inventory.c:1169
OnInputDeviceChanged
protected void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
Definition: inventory.c:167
m_PlayerPreview
protected ref PlayerPreview m_PlayerPreview
Definition: inventory.c:31
TimerEnd
void TimerEnd()
Definition: inventory.c:330
ErrorEx
enum ShapeType ErrorEx
m_SpecializationPanel
protected Widget m_SpecializationPanel
Definition: inventory.c:35
MENU_INVENTORY
const int MENU_INVENTORY
Definition: constants.c:170
InitInputWrapperData
void InitInputWrapperData()
Definition: inventory.c:145
m_ContextMenu
protected ref ContextMenu m_ContextMenu
Definition: inventory.c:43
GetPlugin
PluginBase GetPlugin(typename plugin_type)
Definition: pluginmanager.c:316
EInputDeviceType
EInputDeviceType
Definition: input.c:2
RightArea
Definition: rightarea.c:1
m_HadInspected
protected bool m_HadInspected
Definition: inventory.c:47
RichTextWidget
Definition: gameplay.c:315
m_InpInp
UAInput m_InpInp
Definition: inventory.c:671
PlayerBase
Definition: playerbaseclient.c:1
map
map
Definition: controlsxboxnew.c:3
vector
Definition: enconvert.c:105
ControlID
ControlID
Definition: enwidgets.c:633
m_HandsArea
protected ref HandsArea m_HandsArea
Definition: inventory.c:30
RIGHT
@ RIGHT
Definition: inventory.c:20
ActionTarget
class ActionTargets ActionTarget
OnLeftPanelDropReceived
void OnLeftPanelDropReceived(Widget w, int x, int y, Widget receiver)
Definition: inventory.c:377
SetLayoutName
override void SetLayoutName()
Definition: inventory.c:1078
GetStringVariant
string GetStringVariant(string pInputAction, notnull array< string > variants)
Picks from the strings by active input limiter variant in order: {click,hold,doubleclick}....
Definition: inventory.c:1452
m_HadFastTransferred
protected bool m_HadFastTransferred
Definition: inventory.c:46
OnCenterPanelDropReceived
void OnCenterPanelDropReceived(Widget w, int x, int y, Widget receiver)
Definition: inventory.c:415
ColorManager
Definition: colormanager.c:1
InventoryLocationType
InventoryLocationType
types of Inventory Location
Definition: inventorylocation.c:3
IsVisible
proto native bool IsVisible()
Container
Definition: cargocontainer.c:2
UpdateConsoleToolbar
void UpdateConsoleToolbar()
Definition: inventory.c:1329
Serialize
void Serialize()
Definition: inventory.c:193
slotName
PlayerSpawnPreset slotName
Init
void Init()
Launched from 'DayZGame.DeferredInit' to make earlier access, use, and updates impossible (downside o...
Definition: inventory.c:1104
m_Quickbar
protected ref InventoryQuickbar m_Quickbar
Definition: inventory.c:32
EnableMicromanagement
void EnableMicromanagement()
Definition: inventory.c:1044
Refresh
override void Refresh()
Definition: inventory.c:1206
m_NeedUpdateConsoleToolbar
protected bool m_NeedUpdateConsoleToolbar
Definition: inventory.c:48
m_ControllerRightStickTimer
protected ref Timer m_ControllerRightStickTimer
Definition: inventory.c:55
DOWN
@ DOWN
Definition: inventory.c:23
ItemManager
Definition: itemmanager.c:1
DraggingOverCenterPanel
void DraggingOverCenterPanel(Widget w, int x, int y, Widget receiver)
Definition: inventory.c:520
FindInventoryLocationType
FindInventoryLocationType
flags for searching locations in inventory
Definition: inventorylocation.c:15
OnRightPanelDropReceived
void OnRightPanelDropReceived(Widget w, int x, int y, Widget receiver)
Definition: inventory.c:382
ActionManagerClient
Definition: actionmanagerclient.c:4
Controller
bool Controller(Widget w, int control, int value)
Definition: inventory.c:336
ScreenWidthType
ScreenWidthType
Definition: inventorymenu.c:1
array< string >
m_TopConsoleToolbarHands
protected Widget m_TopConsoleToolbarHands
Definition: inventory.c:38
ResetFocusedContainers
void ResetFocusedContainers()
Definition: inventory.c:1113
m_InvInputNames
protected ref array< string > m_InvInputNames
Definition: inventory.c:68
SetFocus
proto native void SetFocus(Widget w)
HandsArea
Definition: handsarea.c:1
name
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
x
Icon x
GetFocusedArea
Container GetFocusedArea()
Definition: inventory.c:1296
GetProperControllerStickAngle
protected int GetProperControllerStickAngle(int angle)
Definition: inventory.c:303
DraggingOverLeftPanel
void DraggingOverLeftPanel(Widget w, int x, int y, Widget receiver)
Definition: inventory.c:510
GetPlayer
protected void GetPlayer()
Definition: crosshairselector.c:127
Reset
void Reset()
Definition: inventory.c:1106
ItemPreviewWidget
Definition: gameplay.c:275
m_TopConsoleToolbarVicinity
protected Widget m_TopConsoleToolbarVicinity
Definition: inventory.c:37
InventoryMenu
void InventoryMenu()
Definition: inventorymenu.c:20
UpdateInterval
override void UpdateInterval()
Definition: inventory.c:672
OnInputPresetChanged
protected void OnInputPresetChanged()
Definition: inventory.c:160
Inventory
void Inventory(LayoutHolder parent)
Definition: inventory.c:76
INV_MOV_LEFT
const int INV_MOV_LEFT
Definition: inventory.c:64
Timer
Definition: dayzplayerimplement.c:62
m_TopConsoleToolbarEquipment
protected Widget m_TopConsoleToolbarEquipment
Definition: inventory.c:39
m_RightArea
protected ref RightArea m_RightArea
Definition: inventory.c:29
DisableMicromanagement
void DisableMicromanagement()
Definition: inventory.c:1067
INV_MOV_DOWN
const int INV_MOV_DOWN
Definition: inventory.c:67
Widget
Definition: enwidgets.c:189
OnShow
override void OnShow()
Definition: inventory.c:1131
GetUApi
proto native UAInputAPI GetUApi()
m_InvInputWrappers
protected ref array< UAIDWrapper > m_InvInputWrappers
Definition: inventory.c:69
GetInput
ActionInput GetInput()
Definition: actionbase.c:1066
LeftArea
Definition: leftarea.c:1
SPLIT
SPLIT
Definition: miscgameplayfunctions.c:197
UpdateSpecialtyMeter
void UpdateSpecialtyMeter()
Definition: inventory.c:1186
PluginDiagMenu
Definition: plugindiagmenu.c:29
EntityAI
Definition: building.c:5
Deserialize
void Deserialize()
Definition: inventory.c:199
m_BottomConsoleToolbarRichText
protected RichTextWidget m_BottomConsoleToolbarRichText
Definition: inventory.c:41
m_ControllerAngle
protected int m_ControllerAngle
Definition: inventory.c:52
Direction
Direction
Definition: inventory.c:18
m_QBHoveredItems
protected InventoryItem m_QBHoveredItems
Definition: inventory.c:58
WidgetEventHandler
Definition: widgeteventhandler.c:1
m_InvInputWrappersCount
protected int m_InvInputWrappersCount
Definition: inventory.c:71