DayZ 1.24
Loading...
Searching...
No Matches
ClosableContainer Class Reference
Inheritance diagram for ClosableContainer:
[legend]
Collaboration diagram for ClosableContainer:
[legend]

Protected Member Functions

void ContainerWithCargo (Container parent, int sort=-1)
 
override bool IsDisplayable ()
 
override bool IsEmpty ()
 
override bool IsItemActive ()
 
override bool CanCombine ()
 
override bool CanCombineAmmo ()
 
override bool IsItemWithQuantityActive ()
 
void LockCargo (bool value)
 
override void Open ()
 
override void Close ()
 
override bool IsOpened ()
 
override void UpdateInterval ()
 
override bool IsFirstContainerFocused ()
 
override bool IsLastContainerFocused ()
 
override void SetDefaultFocus (bool while_micromanagment_mode=false)
 
override void UnfocusAll ()
 
override bool SplitItem ()
 
override bool EquipItem ()
 
override bool TransferItem ()
 
override bool TransferItemToVicinity ()
 
override bool InspectItem ()
 
void SetEntity (EntityAI entity, int cargo_index=0, bool immedUpdate=true)
 
EntityAI GetEntity ()
 
override EntityAI GetFocusedContainerEntity ()
 
EntityAI GetItemPreviewItem (Widget w)
 
bool DraggingOverGrid (Widget w, int x, int y, Widget reciever)
 
void DropReceived (Widget w, int x, int y)
 
void TakeIntoHands (notnull PlayerBase player, notnull EntityAI item)
 
override void DraggingOverHeader (Widget w, int x, int y, Widget receiver)
 
override void DraggingOver (Widget w, int x, int y, Widget receiver)
 
override void OnDropReceivedFromHeader (Widget w, int x, int y, Widget receiver)
 
void ContainerWithCargoAndAttachments (LayoutHolder parent, int sort=-1)
 
void ~ContainerWithCargoAndAttachments ()
 
void RecomputeContainers ()
 
void AttachmentAddedEx (EntityAI item, string slot, EntityAI parent, bool immedUpdate=true)
 
void AttachmentAdded (EntityAI item, string slot, EntityAI parent)
 
void AttachmentRemoved (EntityAI item, string slot, EntityAI parent)
 
override void UpdateInterval ()
 
override EntityAI GetFocusedContainerEntity ()
 
override void UnfocusAll ()
 
override bool IsLastIndex ()
 
override bool IsFirstContainerFocused ()
 
override bool IsLastContainerFocused ()
 
override void MoveGridCursor (int direction)
 
void SetEntity (EntityAI entity, bool immedUpdate=true)
 
void HideCargo ()
 
void ShowCargo ()
 
EntityAI GetEntity ()
 
ItemPreviewWidget GetItemPreviewWidgetDragOrDrop (Widget w)
 
EntityAI GetItemPreviewItem (Widget w)
 
Widget GetItemPreviewWidget (Widget w)
 
void MouseClick2 (Widget w, int x, int y, int button)
 
void DropReceived (Widget w, int x, int y, CargoContainer cargo)
 NOTE Used for mouse only.
 
void TakeAsAttachment (Widget w, Widget receiver)
 
override void OnDropReceivedFromHeader (Widget w, int x, int y, Widget receiver)
 
void OnDropReceivedFromHeader2 (Widget w, int x, int y, Widget receiver)
 
void DoubleClick (Widget w, int x, int y, int button)
 
bool DraggingOverGrid (Widget w, int x, int y, Widget reciever, CargoContainer cargo)
 
override void DraggingOver (Widget w, int x, int y, Widget receiver)
 
override void DraggingOverHeader (Widget w, int x, int y, Widget receiver)
 

Protected Attributes

ref CargoContainer m_CargoGrid
 
int m_CargoIndex = -1
 
ref Attachments m_Atts
 
ref map< EntityAI, ref CargoContainer > m_AttachmentCargos
 
ref map< EntityAI, ref AttachmentsWrapperm_AttachmentAttachmentsContainers
 
ref map< EntityAI, ref Attachmentsm_AttachmentAttachments
 
ref array< intm_AttachmentSlotsSorted
 

Detailed Description

Definition at line 1 of file ContainerWithCargo.c.

Constructor & Destructor Documentation

◆ ~ContainerWithCargoAndAttachments()

void ClosableContainer::~ContainerWithCargoAndAttachments ( )
inlineprotected

Definition at line 16 of file ContainerWithCargoAndAttachments.c.

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
28 delete att;
29
32
35
37 m_AttachmentCargos.Clear();
38 }
EntityAI m_Entity
Definition ActionDebug.c:11
ref map< EntityAI, ref CargoContainer > m_AttachmentCargos
void AttachmentRemoved(EntityAI item, string slot, EntityAI parent)
ref map< EntityAI, ref Attachments > m_AttachmentAttachments
ref map< EntityAI, ref AttachmentsWrapper > m_AttachmentAttachmentsContainers
void AttachmentAdded(EntityAI item, string slot, EntityAI parent)

References m_Entity.

Member Function Documentation

◆ AttachmentAdded()

void ClosableContainer::AttachmentAdded ( EntityAI item,
string slot,
EntityAI parent )
inlineprotected

Definition at line 129 of file ContainerWithCargoAndAttachments.c.

130 {
131 AttachmentAddedEx(item, slot, parent);
132 }
void AttachmentAddedEx(EntityAI item, string slot, EntityAI parent, bool immedUpdate=true)

◆ AttachmentAddedEx()

void ClosableContainer::AttachmentAddedEx ( EntityAI item,
string slot,
EntityAI parent,
bool immedUpdate = true )
inlineprotected

Definition at line 67 of file ContainerWithCargoAndAttachments.c.

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
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
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
120 RecomputeOpenedContainers();
121
122 Inventory.GetInstance().UpdateConsoleToolbar();
123
124 if (m_Parent && immedUpdate)
125 m_Parent.Refresh();
126 }
127 }
void Inventory(LayoutHolder parent)
Definition Inventory.c:76
Widget m_Parent
Definition SizeToChild.c:86
provides access to slot configuration
static proto native int GetSlotIdFromString(string slot_name)
converts string to slot_id

References InventorySlots::GetSlotIdFromString(), Inventory(), and m_Parent.

◆ AttachmentRemoved()

void ClosableContainer::AttachmentRemoved ( EntityAI item,
string slot,
EntityAI parent )
inlineprotected

Definition at line 134 of file ContainerWithCargoAndAttachments.c.

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
151 if (old_att_cont)
152 {
155 delete old_att_cont;
156
157 if (m_Parent)
158 m_Parent.Refresh();
159 Inventory.GetInstance().UpdateConsoleToolbar();
160 }
161
163 RecomputeOpenedContainers();
164 }

References InventorySlots::GetSlotIdFromString(), Inventory(), and m_Parent.

◆ CanCombine()

override bool ClosableContainer::CanCombine ( )
inlineprotected

Definition at line 37 of file ContainerWithCargo.c.

38 {
39 return m_CargoGrid.CanCombine();
40 }
ref CargoContainer m_CargoGrid

◆ CanCombineAmmo()

override bool ClosableContainer::CanCombineAmmo ( )
inlineprotected

Definition at line 42 of file ContainerWithCargo.c.

43 {
44 return m_CargoGrid.CanCombineAmmo();
45 }

◆ Close()

override void ClosableContainer::Close ( )
inlineprotected

Definition at line 84 of file ContainerWithCargo.c.

85 {
86 if (!m_LockCargo)
87 {
88 ItemManager.GetInstance().SetDefaultOpenState(m_Entity.GetType(), false);
89 m_Closed = true;
90 SetOpenForSlotIcon(false);
91 OnHide();
92 m_Parent.m_Parent.Refresh();
93 }
94
95 if (m_SlotIcon)
96 m_SlotIcon.GetRadialIconPanel().Show(!m_LockCargo);
97 }
override void OnHide()
static ItemManager GetInstance()

References ItemManager::GetInstance(), m_Entity, m_Parent, and OnHide().

Referenced by Container::CloseButtonOnMouseButtonDown().

◆ ContainerWithCargo()

void ClosableContainer::ContainerWithCargo ( Container parent,
int sort = -1 )
inlineprotected

Definition at line 6 of file ContainerWithCargo.c.

7 {
8 m_LockCargo = false;
9 m_Parent = parent;
10
11 m_CargoGrid = new CargoContainer(this);
12 Insert(m_CargoGrid);
13
14 m_CargoGrid.GetRootWidget().SetSort(1);
15
16 WidgetEventHandler.GetInstance().RegisterOnDraggingOver(m_MainWidget, this, "DraggingOverGrid");
17 RecomputeOpenedContainers();
18 }
static WidgetEventHandler GetInstance()

References WidgetEventHandler::GetInstance(), and m_Parent.

Referenced by AttachmentCategoriesRow::RefreshSlot().

◆ ContainerWithCargoAndAttachments()

void ClosableContainer::ContainerWithCargoAndAttachments ( LayoutHolder parent,
int sort = -1 )
inlineprotected

Definition at line 11 of file ContainerWithCargoAndAttachments.c.

12 {
13 WidgetEventHandler.GetInstance().RegisterOnDraggingOver(m_MainWidget, this, "DraggingOverHeader2");
14 }

References WidgetEventHandler::GetInstance().

◆ DoubleClick()

void ClosableContainer::DoubleClick ( Widget w,
int x,
int y,
int button )
inlineprotected

Definition at line 601 of file ContainerWithCargoAndAttachments.c.

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 }
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
DayZGame g_Game
Definition DayZGame.c:3528
FindInventoryLocationType
flags for searching locations in inventory
PlayerBase GetPlayer()
proto native CGame GetGame()
MouseState
Definition EnSystem.c:311

References g_Game, GetGame(), GetPlayer(), and name.

◆ DraggingOver() [1/2]

override void ClosableContainer::DraggingOver ( Widget w,
int x,
int y,
Widget receiver )
inlineprotected

Definition at line 395 of file ContainerWithCargo.c.

396 {
397 if (!w)
398 return;
400 if (!item)
401 return;
402
404 if (item.GetInventory().CanRemoveEntity() && player.CanManipulateInventory() && m_Entity.GetInventory().CanAddEntityInCargo(item, item.GetInventory().GetFlipCargo()) && !m_Entity.GetInventory().HasEntityInCargo(item))
405 {
407 ItemManager.GetInstance().HideDropzones();
408 if (m_Entity.GetHierarchyRootPlayer() == GetGame().GetPlayer())
409 ItemManager.GetInstance().GetRightDropzone().SetAlpha(1);
410 else
411 ItemManager.GetInstance().GetLeftDropzone().SetAlpha(1);
412 }
413 else
414 {
416 ItemManager.GetInstance().ShowSourceDropzone(item);
417 }
418 }
EntityAI GetItemPreviewItem(Widget w)
static int GREEN_COLOR
static int RED_COLOR
static ColorManager GetInstance()

References GetGame(), ColorManager::GetInstance(), ItemManager::GetInstance(), GetItemPreviewItem(), GetPlayer(), ColorManager::GREEN_COLOR, m_Entity, and ColorManager::RED_COLOR.

Referenced by DraggingOverHeader().

◆ DraggingOver() [2/2]

override void ClosableContainer::DraggingOver ( Widget w,
int x,
int y,
Widget receiver )
inlineprotected

Definition at line 717 of file ContainerWithCargoAndAttachments.c.

718 {
720 }
Icon x
Icon y
override void DraggingOverHeader(Widget w, int x, int y, Widget receiver)

References x, and y.

◆ DraggingOverGrid() [1/2]

bool ClosableContainer::DraggingOverGrid ( Widget w,
int x,
int y,
Widget reciever )
inlineprotected

Definition at line 229 of file ContainerWithCargo.c.

230 {
231 if (w == null)
232 return false;
233
235 if (!player.CanManipulateInventory())
236 return false;
237
239
240 if (!item)
241 return false;
242
243 if (!item.GetInventory().CanRemoveEntity())
244 return false;
245
246 int color, c_x, c_y;
247
248#ifdef PLATFORM_CONSOLE
249 int idx = -1;
250#else
251 int idx = 0;
252#endif
253
254 CargoBase cargo = m_Entity.GetInventory().GetCargoFromIndex(m_CargoIndex);
255 if (cargo)
256 {
257 c_x = cargo.GetHeight();
258 c_y = cargo.GetWidth();
259 }
260
262#ifdef PLATFORM_CONSOLE
263 x = 0;
264 y = cargo.GetItemCount();
265 m_Entity.GetInventory().FindFreeLocationFor(item, FindInventoryLocationType.CARGO, dst);
266#else
267 dst.SetCargoAuto(cargo, item, x, y, item.GetInventory().GetFlipCargo());
268#endif
269
270#ifdef PLATFORM_CONSOLE
271 if (dst.IsValid() && m_Entity.GetInventory().LocationCanAddEntityEx(dst))
272#else
273 if (m_Entity && c_x > x && c_y > y && m_Entity.GetInventory().LocationCanAddEntityEx(dst))
274#endif
275 {
276 ItemManager.GetInstance().HideDropzones();
277 if (m_Entity.GetHierarchyRootPlayer() == GetGame().GetPlayer())
278 ItemManager.GetInstance().GetRightDropzone().SetAlpha(1);
279 else
280 ItemManager.GetInstance().GetLeftDropzone().SetAlpha(1);
282 }
283 else
284 {
286 ItemManager.GetInstance().ShowSourceDropzone(item);
287 }
288
289 if (w.FindAnyWidget("Cursor"))
290 w.FindAnyWidget("Cursor").SetColor(color);
291 else
292 {
293 string name = w.GetName();
294 name.Replace("PanelWidget", "Cursor");
295 if (w.FindAnyWidget(name))
296 w.FindAnyWidget(name).SetColor(color);
297 }
298
299 return true;
300 }
represents base for cargo storage for entities
Definition Cargo.c:7
InventoryLocation.

References GetGame(), ItemManager::GetInstance(), GetItemPreviewItem(), GetPlayer(), ColorManager::GREEN_COLOR, m_Entity, name, ColorManager::RED_COLOR, x, and y.

◆ DraggingOverGrid() [2/2]

bool ClosableContainer::DraggingOverGrid ( Widget w,
int x,
int y,
Widget reciever,
CargoContainer cargo )
inlineprotected

Definition at line 654 of file ContainerWithCargoAndAttachments.c.

655 {
656 if (w == NULL)
657 return false;
658
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 }

References GetGame(), ItemManager::GetInstance(), GetPlayer(), ColorManager::GREEN_COLOR, m_Entity, name, ColorManager::RED_COLOR, x, and y.

◆ DraggingOverHeader() [1/2]

override void ClosableContainer::DraggingOverHeader ( Widget w,
int x,
int y,
Widget receiver )
inlineprotected

Definition at line 390 of file ContainerWithCargo.c.

391 {
393 }
override void DraggingOver(Widget w, int x, int y, Widget receiver)

References DraggingOver(), x, and y.

◆ DraggingOverHeader() [2/2]

override void ClosableContainer::DraggingOverHeader ( Widget w,
int x,
int y,
Widget receiver )
inlineprotected

Definition at line 722 of file ContainerWithCargoAndAttachments.c.

723 {
724 if (w == NULL)
725 return;
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 }
Super root of all classes in Enforce script.
Definition EnScript.c:11
static int COMBINE_COLOR
static int SWAP_COLOR
script counterpart to engine's class Inventory
Definition Inventory.c:79
static bool CanSwapEntitiesEx(notnull EntityAI item1, notnull EntityAI item2)
Definition Inventory.c:610
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.

References GameInventory::CanSwapEntitiesEx(), Class::CastTo(), ColorManager::COMBINE_COLOR, GetGame(), ColorManager::GetInstance(), ItemManager::GetInstance(), GetPlayer(), ColorManager::GREEN_COLOR, m_Entity, ColorManager::RED_COLOR, and ColorManager::SWAP_COLOR.

◆ DropReceived() [1/2]

void ClosableContainer::DropReceived ( Widget w,
int x,
int y )
inlineprotected

Definition at line 302 of file ContainerWithCargo.c.

303 {
304 float xx, yy;
305 GetMainWidget().Update();
306 GetMainWidget().GetScreenSize(xx, yy);
307 if (GetMainWidget().FindAnyWidget("Background"))
308 {
309 GetMainWidget().FindAnyWidget("Background").Show(true);
310 GetMainWidget().FindAnyWidget("Background").SetSize(xx, yy);
311 }
313 if (!item)
314 return;
315
316#ifdef PLATFORM_CONSOLE
317 if (m_CargoGrid.HasItem(item))
318 return;
319#endif
320
321#ifdef PLATFORM_CONSOLE
322 int idx = -1;
323#else
324 int idx = 0;
325#endif
326 int c_x, c_y;
327
328 CargoBase cargo = m_Entity.GetInventory().GetCargoFromIndex(m_CargoIndex);
329
330 if (cargo)
331 {
332 c_x = cargo.GetHeight();
333 c_y = cargo.GetWidth();
334 }
335
337#ifdef PLATFORM_CONSOLE
338 x = 0;
339 y = cargo.GetItemCount();
340 m_Entity.GetInventory().FindFreeLocationFor(item, FindInventoryLocationType.CARGO, dst);
341#else
342 dst.SetCargoAuto(cargo, item, x, y, item.GetInventory().GetFlipCargo());
343#endif
344
346 item.GetInventory().GetCurrentInventoryLocation(src);
347
348 if (src.CompareLocationOnly(dst) && src.GetFlip() == dst.GetFlip())
349 return;
350
351#ifdef PLATFORM_CONSOLE
352 if (dst.IsValid() && m_Entity.GetInventory().LocationCanAddEntityEx(dst))
353#else
354 if (c_x > x && c_y > y && m_Entity.GetInventory().LocationCanAddEntityEx(dst))
355#endif
356 {
358
360
361 Icon icon = m_CargoGrid.GetIcon(item);
362
363 if (icon && w && w.FindAnyWidget("Cursor"))
364 {
365 w.FindAnyWidget("Cursor").SetColor(ColorManager.BASE_COLOR);
366 icon.Refresh();
367 Refresh();
368 }
369 }
370
371 ItemManager.GetInstance().HideDropzones();
372 ItemManager.GetInstance().SetIsDragging(false);
373 }
void Refresh()
static int BASE_COLOR
Definition Icon.c:2
static void TakeOrSplitToInventoryLocation(notnull PlayerBase player, notnull InventoryLocation dst)
proto native Widget FindAnyWidget(string pathname)

References ColorManager::BASE_COLOR, FindAnyWidget(), GetGame(), ItemManager::GetInstance(), GetItemPreviewItem(), GetPlayer(), m_Entity, Refresh(), SplitItemUtils::TakeOrSplitToInventoryLocation(), x, and y.

◆ DropReceived() [2/2]

void ClosableContainer::DropReceived ( Widget w,
int x,
int y,
CargoContainer cargo )
inlineprotected

NOTE Used for mouse only.

Definition at line 433 of file ContainerWithCargoAndAttachments.c.

434 {
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 }

References ColorManager::BASE_COLOR, GetGame(), ItemManager::GetInstance(), GetPlayer(), m_Entity, Refresh(), SplitItemUtils::TakeOrSplitToInventoryLocation(), x, and y.

◆ EquipItem()

override bool ClosableContainer::EquipItem ( )
inlineprotected

Definition at line 158 of file ContainerWithCargo.c.

159 {
160 return m_CargoGrid.EquipItem();
161 }

◆ GetEntity() [1/2]

EntityAI ClosableContainer::GetEntity ( )
inlineprotected

Definition at line 203 of file ContainerWithCargo.c.

204 {
205 return m_Entity;
206 }

References m_Entity.

Referenced by OnDropReceivedFromHeader().

◆ GetEntity() [2/2]

EntityAI ClosableContainer::GetEntity ( )
inlineprotected

Definition at line 328 of file ContainerWithCargoAndAttachments.c.

329 {
330 return m_Entity;
331 }

References m_Entity.

◆ GetFocusedContainerEntity() [1/2]

override EntityAI ClosableContainer::GetFocusedContainerEntity ( )
inlineprotected

Definition at line 208 of file ContainerWithCargo.c.

209 {
210 return m_Entity;
211 }

References m_Entity.

◆ GetFocusedContainerEntity() [2/2]

override EntityAI ClosableContainer::GetFocusedContainerEntity ( )
inlineprotected

Definition at line 194 of file ContainerWithCargoAndAttachments.c.

195 {
196 return m_Entity;
197 }

References m_Entity.

◆ GetItemPreviewItem() [1/2]

EntityAI ClosableContainer::GetItemPreviewItem ( Widget w)
inlineprotected

Definition at line 213 of file ContainerWithCargo.c.

214 {
215 ItemPreviewWidget ipw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
216 if (!ipw)
217 {
218 string name = w.GetName();
219 name.Replace("PanelWidget", "Render");
220 ipw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
221 }
222 if (!ipw)
223 ipw = ItemPreviewWidget.Cast(w);
224 if (!ipw || !ipw.IsInherited(ItemPreviewWidget))
225 return null;
226 return ipw.GetItem();
227 }

References name.

Referenced by DraggingOver(), DraggingOverGrid(), DropReceived(), and OnDropReceivedFromHeader().

◆ GetItemPreviewItem() [2/2]

EntityAI ClosableContainer::GetItemPreviewItem ( Widget w)
inlineprotected

Definition at line 340 of file ContainerWithCargoAndAttachments.c.

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 }

References name.

◆ GetItemPreviewWidget()

Widget ClosableContainer::GetItemPreviewWidget ( Widget w)
inlineprotected

Definition at line 356 of file ContainerWithCargoAndAttachments.c.

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 }

References name.

◆ GetItemPreviewWidgetDragOrDrop()

ItemPreviewWidget ClosableContainer::GetItemPreviewWidgetDragOrDrop ( Widget w)
inlineprotected

Definition at line 333 of file ContainerWithCargoAndAttachments.c.

334 {
335 string name = w.GetName();
336 name.Replace("PanelWidget", "Render");
337 return ItemPreviewWidget.Cast(w.FindAnyWidget(name));
338 }

References name.

◆ HideCargo()

void ClosableContainer::HideCargo ( )
inlineprotected

Definition at line 304 of file ContainerWithCargoAndAttachments.c.

305 {
306 if (m_CargoGrid)
307 {
308 if (m_CargoGrid.IsVisible())
309 {
310 m_CargoGrid.OnHide();
311 RecomputeOpenedContainers();
312 }
313 }
314 }

◆ InspectItem()

override bool ClosableContainer::InspectItem ( )
inlineprotected

Definition at line 173 of file ContainerWithCargo.c.

174 {
175 return m_CargoGrid.InspectItem();
176 }

Referenced by AttachmentCategoriesRow::MouseClick().

◆ IsDisplayable()

override bool ClosableContainer::IsDisplayable ( )
inlineprotected

Definition at line 20 of file ContainerWithCargo.c.

21 {
22 if (m_Entity)
23 return m_Entity.CanDisplayCargo();
24 return false;
25 }

References m_Entity.

Referenced by Container::Open(), and Container::UpdateRadialIcon().

◆ IsEmpty()

override bool ClosableContainer::IsEmpty ( )
inlineprotected

Definition at line 27 of file ContainerWithCargo.c.

28 {
29 return m_CargoGrid.IsEmpty();
30 }

◆ IsFirstContainerFocused() [1/2]

override bool ClosableContainer::IsFirstContainerFocused ( )
inlineprotected

Definition at line 133 of file ContainerWithCargo.c.

134 {
135 return m_CargoGrid.IsFirstContainerFocused();
136 }

◆ IsFirstContainerFocused() [2/2]

override bool ClosableContainer::IsFirstContainerFocused ( )
inlineprotected

Definition at line 220 of file ContainerWithCargoAndAttachments.c.

221 {
222 return IsFirstIndex();
223 }

◆ IsItemActive()

override bool ClosableContainer::IsItemActive ( )
inlineprotected

Definition at line 32 of file ContainerWithCargo.c.

33 {
34 return m_CargoGrid.IsItemActive();
35 }

◆ IsItemWithQuantityActive()

override bool ClosableContainer::IsItemWithQuantityActive ( )
inlineprotected

Definition at line 47 of file ContainerWithCargo.c.

48 {
49 return m_CargoGrid.IsItemWithQuantityActive();
50 }

◆ IsLastContainerFocused() [1/2]

override bool ClosableContainer::IsLastContainerFocused ( )
inlineprotected

Definition at line 138 of file ContainerWithCargo.c.

139 {
140 return m_CargoGrid.IsLastContainerFocused();
141 }

◆ IsLastContainerFocused() [2/2]

override bool ClosableContainer::IsLastContainerFocused ( )
inlineprotected

Definition at line 225 of file ContainerWithCargoAndAttachments.c.

226 {
227 return IsLastIndex();
228 }

◆ IsLastIndex()

override bool ClosableContainer::IsLastIndex ( )
inlineprotected

Definition at line 215 of file ContainerWithCargoAndAttachments.c.

216 {
217 return m_ActiveIndex == (m_OpenedContainers.Count() - 1);
218 }

◆ IsOpened()

override bool ClosableContainer::IsOpened ( )
inlineprotected

Definition at line 99 of file ContainerWithCargo.c.

100 {
101 return !m_Closed && !m_LockCargo;
102 }

Referenced by Container::OnShow(), UpdateInterval(), and Container::UpdateRadialIcon().

◆ LockCargo()

void ClosableContainer::LockCargo ( bool value)
inlineprotected

Definition at line 52 of file ContainerWithCargo.c.

53 {
54 if (value != m_LockCargo)
55 {
56 if (value)
57 {
58 m_LockCargo = true;
59 OnHide();
60 }
61 else
62 {
63 m_LockCargo = false;
64 SetOpenState(!m_Closed);
65 }
66 }
67 }

References OnHide().

Referenced by SetEntity(), and UpdateInterval().

◆ MouseClick2()

void ClosableContainer::MouseClick2 ( Widget w,
int x,
int y,
int button )
inlineprotected

Definition at line 370 of file ContainerWithCargoAndAttachments.c.

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)
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 }
DayZGame GetDayZGame()
Definition DayZGame.c:3530
override bool InspectItem()

References g_Game, GetDayZGame(), GetGame(), ItemManager::GetInstance(), and GetPlayer().

◆ MoveGridCursor()

override void ClosableContainer::MoveGridCursor ( int direction)
inlineprotected

Definition at line 230 of file ContainerWithCargoAndAttachments.c.

231 {
232 Container c = GetFocusedContainer();
233 if (c)
234 {
235 c.MoveGridCursor(direction);
236 Inventory.GetInstance().UpdateConsoleToolbar();
237 }
238 }

References Inventory().

◆ OnDropReceivedFromHeader() [1/2]

override void ClosableContainer::OnDropReceivedFromHeader ( Widget w,
int x,
int y,
Widget receiver )
inlineprotected

Definition at line 420 of file ContainerWithCargo.c.

421 {
423 if (!item)
424 return;
425
428 if (GetEntity() && item.GetInventory().GetCurrentInventoryLocation(src))
429 {
431 if (m_Entity.GetInventory().FindFreeLocationFor(item, FindInventoryLocationType.ATTACHMENT, dst))
432 player.PredictiveTakeToDst(src, dst);
433
434 bool can_add = m_Entity.GetInventory().CanAddEntityInCargo(item, item.GetInventory().GetFlipCargo());
435 bool in_cargo = !player.GetInventory().HasEntityInInventory(item) || !m_Entity.GetInventory().HasEntityInCargo(item);
436 if (can_add && in_cargo)
438 }
439 }
static void TakeOrSplitToInventory(notnull PlayerBase player, notnull EntityAI target, notnull EntityAI item)

References GetEntity(), GetGame(), GetItemPreviewItem(), GetPlayer(), m_Entity, and SplitItemUtils::TakeOrSplitToInventory().

◆ OnDropReceivedFromHeader() [2/2]

override void ClosableContainer::OnDropReceivedFromHeader ( Widget w,
int x,
int y,
Widget receiver )
inlineprotected

Definition at line 591 of file ContainerWithCargoAndAttachments.c.

592 {
594 }
void TakeAsAttachment(Widget w, Widget receiver)

◆ OnDropReceivedFromHeader2()

void ClosableContainer::OnDropReceivedFromHeader2 ( Widget w,
int x,
int y,
Widget receiver )
inlineprotected

Definition at line 596 of file ContainerWithCargoAndAttachments.c.

597 {
599 }

◆ Open()

override void ClosableContainer::Open ( )
inlineprotected

Definition at line 69 of file ContainerWithCargo.c.

70 {
71 if (!m_LockCargo)
72 {
73 ItemManager.GetInstance().SetDefaultOpenState(m_Entity.GetType(), true);
74 m_Closed = false;
75 SetOpenForSlotIcon(true);
76 OnShow();
77 m_Parent.m_Parent.Refresh();
78 }
79
80 if (m_SlotIcon)
81 m_SlotIcon.GetRadialIconPanel().Show(!m_LockCargo);
82 }
override void OnShow()

References ItemManager::GetInstance(), m_Entity, m_Parent, and OnShow().

◆ RecomputeContainers()

void ClosableContainer::RecomputeContainers ( )
inlineprotected

Definition at line 40 of file ContainerWithCargoAndAttachments.c.

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 {
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 }

References m_Entity.

◆ SetDefaultFocus()

override void ClosableContainer::SetDefaultFocus ( bool while_micromanagment_mode = false)
inlineprotected

Definition at line 143 of file ContainerWithCargo.c.

144 {
145 m_CargoGrid.SetDefaultFocus(while_micromanagment_mode);
146 }

◆ SetEntity() [1/2]

void ClosableContainer::SetEntity ( EntityAI entity,
bool immedUpdate = true )
inlineprotected

Definition at line 240 of file ContainerWithCargoAndAttachments.c.

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
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)
280 }
281
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 }
override bool IsDisplayable()
static proto native owned string GetSlotName(int id)
converts slot_id to string

References InventorySlots::GetSlotName(), m_Entity, m_Parent, and name.

◆ SetEntity() [2/2]

void ClosableContainer::SetEntity ( EntityAI entity,
int cargo_index = 0,
bool immedUpdate = true )
inlineprotected

Definition at line 178 of file ContainerWithCargo.c.

179 {
182
183 SetOpenState(true);
184
185 m_CargoGrid.SetEntity(entity, immedUpdate);
186 m_CargoGrid.UpdateHeaderText();
187 m_ClosableHeader.SetItemPreview(entity);
188 CheckHeaderDragability();
189 (Container.Cast(m_Parent)).Insert(this, -1, false);
190
191 if (m_Entity.GetInventory().IsInventoryLockedForLockType(HIDE_INV_FROM_SCRIPT) || !m_Entity.CanDisplayCargo())
192 LockCargo(true);
193 else
194 LockCargo(false);
195
196 if (immedUpdate)
197 {
198 Refresh();
199 GetMainWidget().Update();
200 }
201 }
void LockCargo(bool value)

References LockCargo(), m_Entity, m_Parent, and Refresh().

◆ ShowCargo()

void ClosableContainer::ShowCargo ( )
inlineprotected

Definition at line 316 of file ContainerWithCargoAndAttachments.c.

317 {
318 if (m_CargoGrid)
319 {
320 if (!m_CargoGrid.IsVisible())
321 {
322 m_CargoGrid.OnShow();
323 RecomputeOpenedContainers();
324 }
325 }
326 }

◆ SplitItem()

override bool ClosableContainer::SplitItem ( )
inlineprotected

Definition at line 153 of file ContainerWithCargo.c.

154 {
155 return m_CargoGrid.SplitItem();
156 }

◆ TakeAsAttachment()

void ClosableContainer::TakeAsAttachment ( Widget w,
Widget receiver )
inlineprotected

Definition at line 503 of file ContainerWithCargoAndAttachments.c.

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
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 }
override void CombineItemsClient(EntityAI entity2, bool use_stack_max=true)
Definition ItemBase.c:5528

References GameInventory::CanSwapEntitiesEx(), Class::CastTo(), CombineItemsClient(), GetGame(), ItemManager::GetInstance(), GetPlayer(), m_Entity, and SplitItemUtils::TakeOrSplitToInventory().

◆ TakeIntoHands()

void ClosableContainer::TakeIntoHands ( notnull PlayerBase player,
notnull EntityAI item )
inlineprotected

Definition at line 375 of file ContainerWithCargo.c.

376 {
378
379 if (!item.GetInventory().CanRemoveEntity() || !player.CanManipulateInventory())
380 return;
381
382 float stackable = item_base.GetTargetQuantityMax();
383
384 if (stackable == 0 || stackable >= item_base.GetQuantity())
385 player.PredictiveTakeEntityToHands(item);
386 else if (stackable != 0 && stackable < item_base.GetQuantity())
387 item_base.SplitIntoStackMaxHandsClient(player);
388 }

◆ TransferItem()

override bool ClosableContainer::TransferItem ( )
inlineprotected

Definition at line 163 of file ContainerWithCargo.c.

164 {
165 return m_CargoGrid.TransferItem();
166 }

◆ TransferItemToVicinity()

override bool ClosableContainer::TransferItemToVicinity ( )
inlineprotected

Definition at line 168 of file ContainerWithCargo.c.

169 {
170 return m_CargoGrid.TransferItemToVicinity();
171 }

◆ UnfocusAll() [1/2]

override void ClosableContainer::UnfocusAll ( )
inlineprotected

Definition at line 148 of file ContainerWithCargo.c.

149 {
150 m_CargoGrid.Unfocus();
151 }

◆ UnfocusAll() [2/2]

override void ClosableContainer::UnfocusAll ( )
inlineprotected

Definition at line 199 of file ContainerWithCargoAndAttachments.c.

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)
209
210
212 att.UnfocusAll();
213 }
override void UnfocusAll()

◆ UpdateInterval() [1/2]

override void ClosableContainer::UpdateInterval ( )
inlineprotected

Definition at line 104 of file ContainerWithCargo.c.

105 {
106 if (m_Entity)
107 {
108 if (m_Entity.GetInventory().IsInventoryLockedForLockType(HIDE_INV_FROM_SCRIPT) || !m_Entity.CanDisplayCargo())
109 {
110 LockCargo(true);
111 if (m_CargoGrid.IsVisible())
112 RecomputeOpenedContainers();
113 }
114 else
115 {
116 LockCargo(false);
117 if (!m_CargoGrid.IsVisible())
118 RecomputeOpenedContainers();
119 }
120
121 super.UpdateInterval();
122 m_CargoGrid.UpdateInterval();
123
124 bool hide = m_LockCargo || ItemManager.GetInstance().GetDraggedItem() == m_Entity;
125 if (!hide)
126 SetOpenForSlotIcon(IsOpened());
127
128 if (m_SlotIcon)
129 m_SlotIcon.GetRadialIconPanel().Show(!hide);
130 }
131 }
override bool IsOpened()

References ItemManager::GetInstance(), IsOpened(), LockCargo(), and m_Entity.

◆ UpdateInterval() [2/2]

override void ClosableContainer::UpdateInterval ( )
inlineprotected

Definition at line 166 of file ContainerWithCargoAndAttachments.c.

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 }

References ItemManager::GetInstance(), IsOpened(), and m_Entity.

Member Data Documentation

◆ m_AttachmentAttachments

ref map<EntityAI, ref Attachments> ClosableContainer::m_AttachmentAttachments
protected

Definition at line 8 of file ContainerWithCargoAndAttachments.c.

◆ m_AttachmentAttachmentsContainers

ref map<EntityAI, ref AttachmentsWrapper> ClosableContainer::m_AttachmentAttachmentsContainers
protected

Definition at line 7 of file ContainerWithCargoAndAttachments.c.

◆ m_AttachmentCargos

ref map<EntityAI, ref CargoContainer> ClosableContainer::m_AttachmentCargos
protected

Definition at line 6 of file ContainerWithCargoAndAttachments.c.

◆ m_AttachmentSlotsSorted

ref array<int> ClosableContainer::m_AttachmentSlotsSorted
protected

Definition at line 9 of file ContainerWithCargoAndAttachments.c.

◆ m_Atts

ref Attachments ClosableContainer::m_Atts
protected

Definition at line 3 of file ContainerWithCargoAndAttachments.c.

◆ m_CargoGrid

ref CargoContainer ClosableContainer::m_CargoGrid
protected

Definition at line 3 of file ContainerWithCargo.c.

◆ m_CargoIndex

int ClosableContainer::m_CargoIndex = -1
protected

Definition at line 4 of file ContainerWithCargo.c.


The documentation for this class was generated from the following files: