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