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