DayZ 1.24
Loading...
Searching...
No Matches
ContainerWithCargoAndAttachments.c
Go to the documentation of this file.
1class ContainerWithCargoAndAttachments extends ClosableContainer
2{
4 protected ref CargoContainer m_CargoGrid;
5
10
12 {
13 WidgetEventHandler.GetInstance().RegisterOnDraggingOver(m_MainWidget, this, "DraggingOverHeader2");
14 }
15
17 {
18 if (m_Entity)
19 {
20 m_Entity.GetOnItemAttached().Remove(AttachmentAdded);
21 m_Entity.GetOnItemDetached().Remove(AttachmentRemoved);
22 }
23
24 if (m_Atts)
25 delete m_Atts;
26
27 foreach (EntityAI e, Attachments att : m_AttachmentAttachments)
28 delete att;
29
30 if (m_AttachmentAttachments)
31 m_AttachmentAttachments.Clear();
32
33 if (m_AttachmentAttachmentsContainers)
34 m_AttachmentAttachmentsContainers.Clear();
35
36 if (m_AttachmentCargos)
37 m_AttachmentCargos.Clear();
38 }
39
41 {
42 m_Body.Clear();
43
44 if (m_Atts)
45 m_Body.Insert(m_Atts.GetWrapper());
46
47 if (m_CargoGrid)
48 m_Body.Insert(m_CargoGrid);
49
50 GameInventory inv = m_Entity.GetInventory();
51 for (int i = 0; i < inv.AttachmentCount(); i++)
52 {
53 EntityAI ent = inv.GetAttachmentFromIndex(i);
54 if (ent)
55 {
56 AttachmentsWrapper att = m_AttachmentAttachmentsContainers.Get(ent);
57 if (att)
58 m_Body.Insert(att);
59
60 CargoContainer cargo = m_AttachmentCargos.Get(ent);
61 if (cargo)
62 m_Body.Insert(cargo);
63 }
64 }
65 }
66
67 void AttachmentAddedEx(EntityAI item, string slot, EntityAI parent, bool immedUpdate = true)
68 {
70 int sort = -1;
71 bool updateNeeded = false;
73 ref CargoContainer cont = null;
74
75 if (item.GetInventory().GetAttachmentSlotsCount() > 0 && item.CanDisplayAnyAttachmentSlot())
76 {
77 updateNeeded = true;
78
79 att_cont = new Attachments(this, item);
80 sort = (m_AttachmentSlotsSorted.Find(slot_id) * 2) + SORT_ATTACHMENTS_NEXT_OFFSET;
81 att_cont.InitAttachmentGrid(sort);
82
83 m_AttachmentAttachments.Insert(item, att_cont);
84 m_AttachmentAttachmentsContainers.Insert(item, att_cont.GetWrapper());
85
86 att_cont.UpdateInterval();
87 }
88
89 if (item.GetInventory().GetCargo())
90 {
91 updateNeeded = true;
92
93 cont = new CargoContainer(this, true);
94 sort = (m_AttachmentSlotsSorted.Find(slot_id) * 2) + SORT_CARGO_NEXT_OFFSET;
95 cont.GetRootWidget().SetSort(sort);
96 cont.SetEntity(item, false);
97 Insert(cont, m_Atts.GetAttachmentHeight() + m_AttachmentCargos.Count() + 1);
98
99 m_AttachmentCargos.Insert(item, cont);
100 }
101
102 if (updateNeeded)
103 {
104 if (att_cont)
105 {
106 att_cont.ShowFalseAttachmentsHeader(true);
107 if (cont)
108 {
109 cont.ShowFalseCargoHeader(false);
110 cont.UpdateSize();
111 cont.SetAlternateFalseTextHeaderWidget(att_cont.GetFalseHeaderTextWidget());
112 }
113 }
114 else if (cont)
115 {
116 cont.SetAlternateFalseTextHeaderWidget(null); //just to be safe..
117 }
118
119 RecomputeContainers();
120 RecomputeOpenedContainers();
121
122 Inventory.GetInstance().UpdateConsoleToolbar();
123
124 if (m_Parent && immedUpdate)
125 m_Parent.Refresh();
126 }
127 }
128
129 void AttachmentAdded(EntityAI item, string slot, EntityAI parent)
130 {
131 AttachmentAddedEx(item, slot, parent);
132 }
133
134 void AttachmentRemoved(EntityAI item, string slot, EntityAI parent)
135 {
137
138 CargoContainer old_cont = m_AttachmentCargos.Get(item);
139 if (old_cont)
140 {
141 m_AttachmentCargos.Remove(item);
142 delete old_cont;
143
144 if (m_Parent)
145 m_Parent.Refresh();
146 Inventory.GetInstance().UpdateConsoleToolbar();
147 }
148
149
150 AttachmentsWrapper old_att_cont = m_AttachmentAttachmentsContainers.Get(item);
151 if (old_att_cont)
152 {
153 m_AttachmentAttachmentsContainers.Remove(item);
154 m_AttachmentAttachments.Remove(item);
155 delete old_att_cont;
156
157 if (m_Parent)
158 m_Parent.Refresh();
159 Inventory.GetInstance().UpdateConsoleToolbar();
160 }
161
162 RecomputeContainers();
163 RecomputeOpenedContainers();
164 }
165
166 override void UpdateInterval()
167 {
168 if (m_Entity)
169 {
170 if (m_CargoGrid)
171 {
172 bool hideCargo = m_Entity.GetInventory().IsInventoryLockedForLockType(HIDE_INV_FROM_SCRIPT) || !m_Entity.CanDisplayCargo() || m_ForcedHide;
173 if (m_CargoGrid.IsVisible() && hideCargo)
174 HideCargo();
175 else if (!m_CargoGrid.IsVisible() && !hideCargo)
176 ShowCargo();
177
178 m_CargoGrid.UpdateInterval();
179 }
180
181 if (m_SlotIcon)
182 {
183 bool hide = m_LockCargo || ItemManager.GetInstance().GetDraggedItem() == m_Entity;
184 if (!hide)
185 SetOpenForSlotIcon(IsOpened());
186 m_SlotIcon.GetRadialIconPanel().Show(!hide);
187
188 }
189
190 super.UpdateInterval();
191 }
192 }
193
195 {
196 return m_Entity;
197 }
198
199 override void UnfocusAll()
200 {
201 if (m_Atts)
202 m_Atts.UnfocusAll();
203
204 if (m_CargoGrid)
205 m_CargoGrid.UnfocusAll();
206
207 foreach (EntityAI e1, CargoContainer cargo : m_AttachmentCargos)
208 cargo.UnfocusAll();
209
210
211 foreach (EntityAI e2, Attachments att : m_AttachmentAttachments)
212 att.UnfocusAll();
213 }
214
215 override bool IsLastIndex()
216 {
217 return m_ActiveIndex == (m_OpenedContainers.Count() - 1);
218 }
219
221 {
222 return IsFirstIndex();
223 }
224
226 {
227 return IsLastIndex();
228 }
229
230 override void MoveGridCursor(int direction)
231 {
232 Container c = GetFocusedContainer();
233 if (c)
234 {
235 c.MoveGridCursor(direction);
236 Inventory.GetInstance().UpdateConsoleToolbar();
237 }
238 }
239
241 {
243
244 m_Atts = new Attachments(this, m_Entity);
245 m_Atts.InitAttachmentGrid(SORT_ATTACHMENTS_OWN);
246 m_AttachmentSlotsSorted = m_Atts.GetSlotsSorted();
247
248 m_Entity.GetOnItemAttached().Insert(AttachmentAdded);
249 m_Entity.GetOnItemDetached().Insert(AttachmentRemoved);
250
251 m_ClosableHeader.SetItemPreview(m_Entity);
252 CheckHeaderDragability();
253
254 if (m_Entity.GetInventory().GetCargo())
255 {
256 m_CargoGrid = new CargoContainer(this, false);
257 m_CargoGrid.GetRootWidget().SetSort(SORT_CARGO_OWN);
258 m_CargoGrid.SetEntity(m_Entity, 0, immedUpdate);
259 m_CargoGrid.UpdateHeaderText(); // TODO: refresh?
260 Insert(m_CargoGrid);
261 }
262 else
263 {
264 string name = m_Entity.GetDisplayName();
265 name.ToUpper();
266 m_ClosableHeader.SetName(name);
267 }
268
269 m_AttachmentCargos = new map<EntityAI, ref CargoContainer>;
270 m_AttachmentAttachmentsContainers = new map<EntityAI, ref AttachmentsWrapper>;
271 m_AttachmentAttachments = new map<EntityAI, ref Attachments>;
272
273 (Container.Cast(m_Parent)).Insert(this);
274
275 foreach (int slot_id : m_AttachmentSlotsSorted)
276 {
277 EntityAI item = m_Entity.GetInventory().FindAttachment(slot_id);
278 if (item)
279 AttachmentAddedEx(item, InventorySlots.GetSlotName(slot_id), m_Entity, false);
280 }
281
282 RecomputeContainers();
283
284 if (m_CargoGrid)
285 {
286 bool hideCargo = m_Entity.GetInventory().IsInventoryLockedForLockType(HIDE_INV_FROM_SCRIPT) || !m_Entity.CanDisplayCargo() || m_ForcedHide;
287 if (m_CargoGrid.IsVisible() && hideCargo)
288 HideCargo();
289 else if (!m_CargoGrid.IsVisible() && !hideCargo)
290 ShowCargo();
291 }
292
293 if (IsDisplayable())
294 SetOpenState(true);
295 else
296 SetOpenState(false);
297
298 if (immedUpdate)
299 m_Parent.m_Parent.Refresh();
300
301 RecomputeOpenedContainers();
302 }
303
305 {
306 if (m_CargoGrid)
307 {
308 if (m_CargoGrid.IsVisible())
309 {
310 m_CargoGrid.OnHide();
311 RecomputeOpenedContainers();
312 }
313 }
314 }
315
317 {
318 if (m_CargoGrid)
319 {
320 if (!m_CargoGrid.IsVisible())
321 {
322 m_CargoGrid.OnShow();
323 RecomputeOpenedContainers();
324 }
325 }
326 }
327
329 {
330 return m_Entity;
331 }
332
334 {
335 string name = w.GetName();
336 name.Replace("PanelWidget", "Render");
337 return ItemPreviewWidget.Cast(w.FindAnyWidget(name));
338 }
339
341 {
342 ItemPreviewWidget ipw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
343 if (!ipw)
344 {
345 string name = w.GetName();
346 name.Replace("PanelWidget", "Render");
347 ipw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
348 }
349 if (!ipw)
350 ipw = ItemPreviewWidget.Cast(w);
351 if (!ipw || !ipw.IsInherited(ItemPreviewWidget))
352 return NULL;
353 return ipw.GetItem();
354 }
355
357 {
358 ItemPreviewWidget ipw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
359 if (!ipw)
360 {
361 string name = w.GetName();
362 name.Replace("PanelWidget", "Render");
363 ipw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
364 }
365 if (!ipw)
366 ipw = ItemPreviewWidget.Cast(w);
367 return ipw;
368 }
369
370 void MouseClick2(Widget w, int x, int y, int button)
371 {
373 w.GetUserData(icon);
374
376 if (icon)
377 selectedItem = ItemBase.Cast(icon.GetEntity());
378
379 if (selectedItem)
380 {
381 bool isReserved = icon.IsReserved();
382
383 switch (button)
384 {
385 case MouseState.RIGHT:
386#ifdef DIAG_DEVELOPER
387 if (GetDayZGame().IsLeftCtrlDown())
388 ShowActionMenu(selectedItem);
389#endif
390
391 if (isReserved)
392 {
393 EntityAI attachmentParent = icon.GetSlotParent();
394 GetGame().GetPlayer().GetHumanInventory().ClearUserReservedLocationSynced(selectedItem);
395 attachmentParent.GetOnAttachmentReleaseLock().Invoke(selectedItem, icon.GetSlotID());
396 }
397
398 break;
399
400 case MouseState.MIDDLE:
401 if (!isReserved)
402 InspectItem(selectedItem);
403
404 break;
405
406 case MouseState.LEFT:
407 if (!isReserved)
408 {
410 if (g_Game.IsLeftCtrlDown())
411 {
412 if (controlledPlayer.CanDropEntity(selectedItem))
413 {
414 if (selectedItem.GetTargetQuantityMax() < selectedItem.GetQuantity())
415 selectedItem.SplitIntoStackMaxClient(null, -1);
416 else
417 controlledPlayer.PhysicalPredictiveDropItem(selectedItem);
418 }
419 }
420 else
421 {
422 bool draggable = !controlledPlayer.GetInventory().HasInventoryReservation(selectedItem, null) && !controlledPlayer.GetInventory().IsInventoryLocked() && selectedItem.GetInventory().CanRemoveEntity() && !controlledPlayer.IsItemsToDelete();
423 ItemManager.GetInstance().SetWidgetDraggable(w, draggable);
424 }
425 }
426
427 break;
428 }
429 }
430 }
431
433 void DropReceived(Widget w, int x, int y, CargoContainer cargo)
434 {
435 EntityAI item = GetItemPreviewItem(w);
436 if (!item)
437 return;
438
439#ifndef PLATFORM_CONSOLE
440 int c_x, c_y;
441#endif
442
445
446 if (cargo != m_CargoGrid)
447 targetEntity = m_AttachmentCargos.GetKeyByValue(cargo);
448
449 if (targetEntity)
450 {
451 targetCargo = targetEntity.GetInventory().GetCargo();
452#ifdef PLATFORM_CONSOLE
453 if (m_CargoGrid && m_CargoGrid.HasItem(item))
454 return;
455#endif
456 }
457
458 if (!targetCargo || !targetEntity)
459 return;
460
462#ifdef PLATFORM_CONSOLE
463 x = 0;
464 y = targetCargo.GetItemCount();
465 targetEntity.GetInventory().FindFreeLocationFor(item, FindInventoryLocationType.CARGO, dst);
466#else
467 c_x = targetCargo.GetHeight();
468 c_y = targetCargo.GetWidth();
469
470 dst.SetCargoAuto(targetCargo, item, x, y, item.GetInventory().GetFlipCargo());
471#endif
472
474 item.GetInventory().GetCurrentInventoryLocation(src);
475 if (src.CompareLocationOnly(dst) && src.GetFlip() == dst.GetFlip())
476 return;
477
478#ifdef PLATFORM_CONSOLE
479 if (dst.IsValid() && targetEntity.GetInventory().LocationCanAddEntity(dst))
480#else
481 if (c_x > x && c_y > y && targetEntity.GetInventory().LocationCanAddEntity(dst))
482#endif
483 {
485
487
488 Icon icon = cargo.GetIcon(item);
489 if (icon)
490 {
491 if (w && w.FindAnyWidget("Cursor"))
492 w.FindAnyWidget("Cursor").SetColor(ColorManager.BASE_COLOR);
493
494 icon.Refresh();
495 Refresh();
496 }
497 }
498
499 ItemManager.GetInstance().HideDropzones();
500 ItemManager.GetInstance().SetIsDragging(false);
501 }
502
504 {
505 ItemManager.GetInstance().HideDropzones();
506 ItemManager.GetInstance().SetIsDragging(false);
509 int slot_id = -1;
510 bool is_reserved = false;
512 receiver.GetUserData(slots_icon);
513 //string name = receiver.GetName();
514 //name.Replace("PanelWidget", "Render");
515
516 //ItemPreviewWidget receiver_iw = ItemPreviewWidget.Cast( receiver.FindAnyWidget(name) );
517 if (slots_icon)
518 {
519 receiver_item = slots_icon.GetEntity();
520 slot_id = slots_icon.GetSlotID();
521 attached_entity = slots_icon.GetSlotParent();
522 is_reserved = slots_icon.IsReserved();
523 }
524
525 EntityAI item = GetItemPreviewItem(w);
526 if (!item)
527 return;
530 float stackable;
531
533 if (!item.GetInventory().CanRemoveEntity() || !player.CanManipulateInventory())
534 return;
535
540 {
541 if (player.GetWeaponManager().CanAttachMagazine(wpn, mag))
542 player.GetWeaponManager().AttachMagazine(mag);
543 }
544 else if (receiver_item && !is_reserved)
545 {
546 if ((ItemBase.Cast(receiver_item)).CanBeCombined(ItemBase.Cast(item)))
549 {
550 if (!receiver_item.GetInventory().CanRemoveEntity())
551 return;
552 GetGame().GetPlayer().PredictiveSwapEntities(receiver_item, item);
553 }
554 else if (receiver_item.GetInventory().CanAddAttachment(item))
555 player.PredictiveTakeEntityToTargetAttachment(receiver_item, item);
556 }
557 else if (attached_entity && attached_entity.GetInventory().CanAddAttachmentEx(item, slot_id))
558 {
559 stackable = item_base.GetTargetQuantityMax(slot_id);
560 if (stackable == 0 || stackable >= item_base.GetQuantity())
561 player.PredictiveTakeEntityToTargetAttachmentEx(attached_entity, item, slot_id);
562 else if (stackable != 0 && stackable < item_base.GetQuantity())
563 item_base.SplitIntoStackMaxClient(attached_entity, slot_id);
564 }
565 else if (attached_entity && attached_entity.GetInventory().CanAddAttachment(item))
566 {
567 attached_entity.GetInventory().FindFreeLocationFor(item, FindInventoryLocationType.ATTACHMENT, il);
568 stackable = item_base.GetTargetQuantityMax(il.GetSlot());
569 if (stackable == 0 || stackable >= item_base.GetQuantity())
570 player.PredictiveTakeEntityToTargetAttachmentEx(attached_entity, item, il.GetSlot());
571 else if (stackable != 0 && stackable < item_base.GetQuantity())
572 item_base.SplitIntoStackMaxClient(attached_entity, il.GetSlot());
573 }
574 else if (m_Entity.GetInventory().CanAddAttachment(item))
575 {
576 m_Entity.GetInventory().FindFreeLocationFor(item, FindInventoryLocationType.ATTACHMENT, il);
577 stackable = item_base.GetTargetQuantityMax(il.GetSlot());
578 if (stackable == 0 || stackable >= item_base.GetQuantity())
579 player.PredictiveTakeEntityToTargetAttachmentEx(m_Entity, item, il.GetSlot());
580 else if (stackable != 0 && stackable < item_base.GetQuantity())
581 item_base.SplitIntoStackMaxClient(m_Entity, il.GetSlot());
582 }
583 else if (m_Entity.GetInventory().CanAddEntityInCargo(item, item.GetInventory().GetFlipCargo()) && !m_Entity.GetInventory().HasEntityInCargo(item))
585 /*else if( !player.GetInventory().HasEntityInInventory( item ) || !m_Entity.GetInventory().HasEntityInCargo( item ) )
586 {
587 SplitItemUtils.TakeOrSplitToInventory( PlayerBase.Cast( GetGame().GetPlayer() ), m_Entity, item );
588 }*/
589 }
590
592 {
593 TakeAsAttachment(w, receiver);
594 }
595
597 {
598 TakeAsAttachment(w, receiver);
599 }
600
601 void DoubleClick(Widget w, int x, int y, int button)
602 {
603 if (button == MouseState.LEFT && !g_Game.IsLeftCtrlDown())
604 {
606 if (w == NULL || player.GetInventory().IsInventoryLocked())
607 return;
608 ItemPreviewWidget iw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
609 if (!iw)
610 {
611 string name = w.GetName();
612 name.Replace("PanelWidget", "Render");
613 iw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
614 }
615
616 if (!iw)
617 iw = ItemPreviewWidget.Cast(w);
618
619 EntityAI item = iw.GetItem();
620
621 if (!item)
622 return;
623
625 iw.GetUserData(icon);
626
627 if (icon && icon.IsReserved())
628 return;
629
630 if (!item.GetInventory().CanRemoveEntity() || !player.CanManipulateInventory())
631 return;
632
633 if (player.GetInventory().HasEntityInInventory(item) && player.GetHumanInventory().CanAddEntityInHands(item))
634 player.PredictiveTakeEntityToHands(item);
635 else
636 {
637 if (player.GetInventory().CanAddEntityToInventory(item) && item.GetInventory().CanRemoveEntity())
638 player.PredictiveTakeEntityToInventory(FindInventoryLocationType.ANY, InventoryItem.Cast(item));
639 else
640 {
641 if (player.GetHumanInventory().CanAddEntityInHands(item))
642 player.PredictiveTakeEntityToHands(item);
643 }
644 }
645
646 HideOwnedTooltip();
647
648 name = w.GetName();
649 name.Replace("PanelWidget", "Temperature");
650 w.FindAnyWidget(name).Show(false);
651 }
652 }
653
654 bool DraggingOverGrid(Widget w, int x, int y, Widget reciever, CargoContainer cargo)
655 {
656 if (w == NULL)
657 return false;
658
659 EntityAI item = GetItemPreviewItem(w);
660
661 if (!item)
662 return false;
663
664 int color;
665 int idx = 0;
666 int c_x, c_y;
667
670
671 if (cargo == m_CargoGrid)
672 {
674 target_cargo = m_Entity.GetInventory().GetCargo();
675 }
676 else
677 {
678 target_entity = m_AttachmentCargos.GetKeyByValue(cargo);
679 if (target_entity)
680 target_cargo = target_entity.GetInventory().GetCargo();
681 else
682 return false;
683 }
684
686 {
687 c_x = target_cargo.GetHeight();
688 c_y = target_cargo.GetWidth();
689 }
690 else
691 return false;
692
693 if (c_x > x && c_y > y && target_entity.GetInventory().CanAddEntityInCargoEx(item, idx, x, y, item.GetInventory().GetFlipCargo()))
694 {
696 if (target_entity.GetHierarchyRootPlayer() == GetGame().GetPlayer())
697 ItemManager.GetInstance().GetRightDropzone().SetAlpha(1);
698 else
699 ItemManager.GetInstance().GetLeftDropzone().SetAlpha(1);
700 }
701 else
703
704 if (w.FindAnyWidget("Cursor"))
705 w.FindAnyWidget("Cursor").SetColor(color);
706 else
707 {
708 string name = w.GetName();
709 name.Replace("PanelWidget", "Cursor");
710 if (w.FindAnyWidget(name))
711 w.FindAnyWidget(name).SetColor(color);
712 }
713
714 return true;
715 }
716
717 override void DraggingOver(Widget w, int x, int y, Widget receiver)
718 {
719 DraggingOverHeader(w, x, y, receiver);
720 }
721
722 override void DraggingOverHeader(Widget w, int x, int y, Widget receiver)
723 {
724 if (w == NULL)
725 return;
726 EntityAI item = GetItemPreviewItem(w);
727 if (!item)
728 return;
729
731 receiver.GetUserData(slots_icon);
732
735 bool is_reserved = false;
736 int slot_id = -1;
737
738 if (slots_icon)
739 {
740 attached_entity = slots_icon.GetSlotParent();
741 slot_id = slots_icon.GetSlotID();
742 receiver_item = slots_icon.GetEntity();
743 is_reserved = slots_icon.IsReserved();
744 }
745
746
750 if (m_Entity)
751 {
753 {
754 if (player.GetWeaponManager().CanAttachMagazine(wpn, mag))
755 {
756 ItemManager.GetInstance().HideDropzones();
757 if (m_Entity.GetHierarchyRootPlayer() == GetGame().GetPlayer())
758 ItemManager.GetInstance().GetRightDropzone().SetAlpha(1);
759 else
760 ItemManager.GetInstance().GetLeftDropzone().SetAlpha(1);
762 }
763 }
764 else if (receiver_item && !is_reserved)
765 {
768 if (receiver_itemIB && itemIB && receiver_itemIB.CanBeCombined(itemIB))
769 {
770 ItemManager.GetInstance().HideDropzones();
771 if (m_Entity.GetHierarchyRootPlayer() == GetGame().GetPlayer())
772 ItemManager.GetInstance().GetRightDropzone().SetAlpha(1);
773 else
774 ItemManager.GetInstance().GetLeftDropzone().SetAlpha(1);
776 }
778 {
779 ItemManager.GetInstance().HideDropzones();
780 if (m_Entity.GetHierarchyRootPlayer() == GetGame().GetPlayer())
781 ItemManager.GetInstance().GetRightDropzone().SetAlpha(1);
782 else
783 ItemManager.GetInstance().GetLeftDropzone().SetAlpha(1);
785 }
786 else if (receiver_itemIB.GetInventory().CanAddAttachment(item))
787 {
788 ItemManager.GetInstance().HideDropzones();
789 if (receiver_itemIB.GetHierarchyRootPlayer() == GetGame().GetPlayer())
790 ItemManager.GetInstance().GetRightDropzone().SetAlpha(1);
791 else
792 ItemManager.GetInstance().GetLeftDropzone().SetAlpha(1);
794 }
795 }
796 else if (attached_entity && attached_entity.GetInventory().CanAddAttachmentEx(item, slot_id))
797 {
798 ItemManager.GetInstance().HideDropzones();
799 if (attached_entity.GetHierarchyRootPlayer() == GetGame().GetPlayer())
800 ItemManager.GetInstance().GetRightDropzone().SetAlpha(1);
801 else
802 ItemManager.GetInstance().GetLeftDropzone().SetAlpha(1);
804 }
805 else if (m_Entity.GetInventory().CanAddAttachment(item))
806 {
807 ItemManager.GetInstance().HideDropzones();
808 if (m_Entity.GetHierarchyRootPlayer() == GetGame().GetPlayer())
809 ItemManager.GetInstance().GetRightDropzone().SetAlpha(1);
810 else
811 ItemManager.GetInstance().GetLeftDropzone().SetAlpha(1);
813 }
814 else if ((m_Entity.GetInventory().CanAddEntityInCargo(item, item.GetInventory().GetFlipCargo()) && !m_Entity.GetInventory().HasEntityInCargo(item)) /*|| player.GetHumanInventory().HasEntityInHands( item )*/)
815 {
816 ItemManager.GetInstance().HideDropzones();
817 if (m_Entity.GetHierarchyRootPlayer() == GetGame().GetPlayer())
818 ItemManager.GetInstance().GetRightDropzone().SetAlpha(1);
819 else
820 ItemManager.GetInstance().GetLeftDropzone().SetAlpha(1);
822 }
823 else
824 {
825 ItemManager.GetInstance().ShowSourceDropzone(item);
827 }
828 }
829 }
830}
void Inventory(LayoutHolder parent)
Definition Inventory.c:76
EntityAI m_Entity
Definition ActionDebug.c:11
bool IsOpened()
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
DayZGame g_Game
Definition DayZGame.c:3528
DayZGame GetDayZGame()
Definition DayZGame.c:3530
Icon x
Icon y
FindInventoryLocationType
flags for searching locations in inventory
override void CombineItemsClient(EntityAI entity2, bool use_stack_max=true)
Definition ItemBase.c:5528
PlayerBase GetPlayer()
Widget m_Parent
Definition SizeToChild.c:86
void Refresh()
represents base for cargo storage for entities
Definition Cargo.c:7
Super root of all classes in Enforce script.
Definition EnScript.c:11
ref map< EntityAI, ref CargoContainer > m_AttachmentCargos
void TakeAsAttachment(Widget w, Widget receiver)
void AttachmentAddedEx(EntityAI item, string slot, EntityAI parent, bool immedUpdate=true)
void DoubleClick(Widget w, int x, int y, int button)
override void DraggingOverHeader(Widget w, int x, int y, Widget receiver)
void AttachmentRemoved(EntityAI item, string slot, EntityAI parent)
void OnDropReceivedFromHeader2(Widget w, int x, int y, Widget receiver)
override void DraggingOver(Widget w, int x, int y, Widget receiver)
ref map< EntityAI, ref Attachments > m_AttachmentAttachments
ref map< EntityAI, ref AttachmentsWrapper > m_AttachmentAttachmentsContainers
void AttachmentAdded(EntityAI item, string slot, EntityAI parent)
void ContainerWithCargoAndAttachments(LayoutHolder parent, int sort=-1)
override void MoveGridCursor(int direction)
void MouseClick2(Widget w, int x, int y, int button)
bool DraggingOverGrid(Widget w, int x, int y, Widget reciever, CargoContainer cargo)
ItemPreviewWidget GetItemPreviewWidgetDragOrDrop(Widget w)
override EntityAI GetFocusedContainerEntity()
override void OnDropReceivedFromHeader(Widget w, int x, int y, Widget receiver)
void SetEntity(EntityAI entity, bool immedUpdate=true)
void DropReceived(Widget w, int x, int y, CargoContainer cargo)
NOTE Used for mouse only.
static int BASE_COLOR
static int COMBINE_COLOR
static int SWAP_COLOR
static int GREEN_COLOR
static int RED_COLOR
static ColorManager GetInstance()
script counterpart to engine's class Inventory
Definition Inventory.c:79
static bool CanSwapEntitiesEx(notnull EntityAI item1, notnull EntityAI item2)
Definition Inventory.c:610
Definition Icon.c:2
InventoryLocation.
provides access to slot configuration
static proto native owned string GetSlotName(int id)
converts slot_id to string
static proto native int GetSlotIdFromString(string slot_name)
converts string to slot_id
static ItemManager GetInstance()
static void TakeOrSplitToInventoryLocation(notnull PlayerBase player, notnull InventoryLocation dst)
static void TakeOrSplitToInventory(notnull PlayerBase player, notnull EntityAI target, notnull EntityAI item)
static WidgetEventHandler GetInstance()
proto native CGame GetGame()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
MouseState
Definition EnSystem.c:311