DayZ 1.24
Loading...
Searching...
No Matches
AttachmentCategoriesRow.c
Go to the documentation of this file.
2{
3 protected string m_CategoryIdentifier;
4 protected string m_RowConfigPath;
5 protected bool m_Refreshing;
6
9
11 {
12 m_Refreshing = false;
15
16 m_Body.Insert(m_AttachmentsContainer);
17
18 m_ClosableHeader.GetMainWidget().ClearFlags(WidgetFlags.DRAGGABLE);
19
20 RecomputeOpenedContainers();
21 }
22
24 {
26 }
27
29 {
30 SlotsIcon icon = GetFocusedSlotsIcon();
31 if (icon)
32 return icon.GetSlotID();
33 return -1;
34 }
35
36 override bool Select()
37 {
38 Man player = GetGame().GetPlayer();
39 SlotsIcon focused_icon = GetFocusedSlotsIcon();
40 EntityAI focused_item = GetFocusedItem();
41 Container focused_cont = GetFocusedContainer();
42 ItemBase selected_item = ItemBase.Cast(ItemManager.GetInstance().GetSelectedItem()); // == dragged item
43
44 if (selected_item && focused_item != selected_item)//dropping from micromanagement
45 {
46 if (selected_item.GetInventory().CanRemoveEntity())
47 {
48 int stack_max;
49
50 if (!focused_icon)
51 {
52 if (focused_cont)
53 focused_cont.Select();
54 }
55 else if (!focused_item && m_Entity && m_Entity.GetInventory().CanAddAttachmentEx(selected_item, focused_icon.GetSlotID()))
56 {
58 float quantity = selected_item.GetQuantity();
59 if (stack_max == 0 || stack_max >= quantity || !selected_item.CanBeSplit())
60 {
61 player.PredictiveTakeEntityToTargetAttachmentEx(m_Entity, selected_item, focused_icon.GetSlotID());
62 return true;
63 }
64 else
65 {
66 selected_item.SplitIntoStackMaxClient(m_Entity, focused_icon.GetSlotID());
67 return true;
68 }
69 }
70 else if (focused_icon.GetSlotID() != -1)
71 {
72 if (focused_item && focused_item.GetHierarchyParent() && focused_item.GetHierarchyParent().GetInventory().CanAddAttachment(selected_item))
73 {
75 focused_item.GetInventory().GetCurrentInventoryLocation(inv_loc);
77 quantity = focused_item.GetQuantity();
78 if (focused_item.CanBeCombined(ItemBase.Cast(selected_item)))
79 {
80 focused_item.CombineItemsClient(selected_item, true);
81 return true;
82 }
84 {
85 player.PredictiveSwapEntities(selected_item, focused_item);
86 return true;
87 }
88 else if (m_AttachmentCargos.Contains(inv_loc.GetSlot()))
89 {
90 if (focused_item.GetInventory().CanAddEntityInCargo(selected_item, selected_item.GetInventory().GetFlipCargo()))
91 {
93 return true;
94 }
95 }
96 }
97 }
98 }
99 }
100 else //clicking
101 {
102 if (focused_item && focused_item.GetInventory().CanRemoveEntity() && (!focused_icon || !focused_icon.IsOutOfReach()))
103 {
104 EntityAI item_in_hands = GetGame().GetPlayer().GetHumanInventory().GetEntityInHands();
105 if (item_in_hands && item_in_hands.GetInventory().CanRemoveEntity())
106 {
108 {
109 player.PredictiveSwapEntities(item_in_hands, focused_item);
110 return true;
111 }
112 }
113 else
114 {
115 if (player.GetHumanInventory().CanAddEntityInHands(focused_item))
116 {
117 player.PredictiveTakeEntityToHands(focused_item);
118 return true;
119 }
120 }
121 }
122 }
123
124 return false;
125 }
126
127 override bool TransferItem()
128 {
129 if (CanTakeToInventory())
130 {
131 EntityAI entity = GetFocusedItem();
132 SlotsIcon focused_icon = GetFocusedSlotsIcon();
133 if (entity && !entity.IsLockedInSlot() && (!focused_icon || !focused_icon.IsOutOfReach()))
134 {
136 GetGame().GetPlayer().PredictiveTakeEntityToInventory(FindInventoryLocationType.CARGO, entity);
137 return true;
138 }
139 }
140 return false;
141 }
142
144 {
145 if (CanDrop())
146 {
147 ItemBase item = ItemBase.Cast(GetFocusedItem());
149 SlotsIcon focused_icon = GetFocusedSlotsIcon();
150
151 if (item && !item.IsLockedInSlot() && (focused_icon && !focused_icon.IsOutOfReach()))
152 {
153 if (item.GetTargetQuantityMax() < item.GetQuantity())
154 item.SplitIntoStackMaxClient(null, -1);
155 else
156 player.PhysicalPredictiveDropItem(item);
157 return true;
158 }
159 }
160 return false;
161 }
162
163 override bool Combine()
164 {
165 if (CanCombine())
166 {
167 Man player = GetGame().GetPlayer();
168 ItemBase prev_item = ItemBase.Cast(GetFocusedItem());
169 ItemBase selected_item = ItemBase.Cast(player.GetHumanInventory().GetEntityInHands());
170 SlotsIcon focused_icon = GetFocusedSlotsIcon();
171
172 if (selected_item)
173 {
175 int stack_max;
176 if (selected_item && selected_item.GetInventory().CanRemoveEntity() && (focused_icon && !focused_icon.IsOutOfReach()))
177 {
178 if (!prev_item && m_Entity.GetInventory().CanAddAttachmentEx(selected_item, selected_slot))
179 {
181 float quantity = selected_item.GetQuantity();
182 if (stack_max == 0 || stack_max >= quantity || !selected_item.CanBeSplit())
183 {
184 player.PredictiveTakeEntityToTargetAttachmentEx(m_Entity, selected_item, selected_slot);
185 return true;
186 }
187 else
188 {
189 selected_item.SplitIntoStackMaxClient(m_Entity, selected_slot);
190 return true;
191 }
192 }
193 else if (selected_slot != -1)
194 {
195 if (prev_item)
196 {
198 prev_item.GetInventory().GetCurrentInventoryLocation(inv_loc);
200 quantity = prev_item.GetQuantity();
201 if (prev_item.CanBeCombined(ItemBase.Cast(selected_item)))
202 {
203 prev_item.CombineItemsClient(selected_item, true);
204 return true;
205 }
207 {
208 player.PredictiveSwapEntities(selected_item, prev_item);
209 return true;
210 }
211 else if (m_AttachmentCargos.Contains(inv_loc.GetSlot()))
212 {
213 if (prev_item.GetInventory().CanAddEntityInCargo(selected_item, selected_item.GetInventory().GetFlipCargo()))
214 {
216 return true;
217 }
218 }
219 }
220 }
221 }
222 }
223 }
224 return false;
225 }
226
228 {
229 return false;
230 }
231
232 override bool SplitItem()
233 {
234 return false;
235 }
236
237 override bool EquipItem() //TODO: may be possible, but the hint doesn't reflect it anyway
238 {
239 return false;
240 }
241
242 override bool CanCombine()
243 {
244 Man player = GetGame().GetPlayer();
245 ItemBase prev_item = ItemBase.Cast(GetFocusedItem());
246 ItemBase selected_item = ItemBase.Cast(player.GetHumanInventory().GetEntityInHands());
247 SlotsIcon focused_icon = GetFocusedSlotsIcon();
248
249 if (selected_item)
250 {
252 int stack_max;
253 if (selected_item && selected_item.GetInventory().CanRemoveEntity() && (focused_icon && !focused_icon.IsOutOfReach()))
254 {
255 if (m_Entity.GetInventory().CanAddAttachmentEx(selected_item, selected_slot))
256 {
258 float quantity = selected_item.GetQuantity();
259 if (stack_max == 0 || stack_max >= quantity || !selected_item.CanBeSplit())
260 return true;
261 else
262 return true;
263 }
264 else if (selected_slot != -1)
265 {
266 if (prev_item)
267 {
269 prev_item.GetInventory().GetCurrentInventoryLocation(inv_loc);
271 quantity = prev_item.GetQuantity();
272 if (prev_item.CanBeCombined(ItemBase.Cast(selected_item)))
273 return true;
274 }
275 }
276 }
277 }
278 return false;
279 }
280
281 override bool CanCombineAmmo()
282 {
283 return false;
284 }
285
286 override bool IsItemActive()
287 {
288 SlotsIcon icon = GetFocusedSlotsIcon();
289 return GetFocusedItem() != null && (!icon || !icon.IsOutOfReach());
290 }
291
293 {
294 ItemBase item = ItemBase.Cast(GetFocusedItem());
295 SlotsIcon icon = GetFocusedSlotsIcon();
296 return item && (!icon || !icon.IsOutOfReach()) && item.CanBeSplit();
297 }
298
300 {
301 ItemManager.GetInstance().HideDropzones();
302 ItemManager.GetInstance().SetIsDragging(false);
305 int slot_id = -1;
306 bool is_reserved = false;
308 receiver.GetUserData(slots_icon);
309 float stackable = 0.0;
311
312 if (slots_icon)
313 {
314 receiver_item = slots_icon.GetEntity();
315 slot_id = slots_icon.GetSlotID();
316 attached_entity = slots_icon.GetSlotParent();
317 is_reserved = slots_icon.IsReserved();
318 }
319
321 if (!item)
322 return;
324
326 if (!item.GetInventory().CanRemoveEntity() || !player.CanManipulateInventory())
327 return;
328
333 {
334 if (player.GetWeaponManager().CanAttachMagazine(wpn, mag))
335 player.GetWeaponManager().AttachMagazine(mag);
336 }
337 else if (receiver_item && !is_reserved)
338 {
339 if ((ItemBase.Cast(receiver_item)).CanBeCombined(ItemBase.Cast(item)))
342 {
343 if (!receiver_item.GetInventory().CanRemoveEntity())
344 return;
345 GetGame().GetPlayer().PredictiveSwapEntities(receiver_item, item);
346 }
347 else if (receiver_item.GetInventory().CanAddAttachment(item))
348 player.PredictiveTakeEntityToTargetAttachment(receiver_item, item);
349 }
350 else if (attached_entity && slot_id != -1 && attached_entity.GetInventory().CanAddAttachmentEx(item, slot_id))
351 {
352 item_base = ItemBase.Cast(item);
353 stackable = item_base.GetTargetQuantityMax(slot_id);
354
355 if (stackable == 0 || stackable >= item_base.GetQuantity())
356 player.PredictiveTakeEntityToTargetAttachmentEx(attached_entity, item, slot_id);
357 else if (stackable != 0 && stackable < item_base.GetQuantity())
358 item_base.SplitIntoStackMaxClient(m_Entity, slot_id);
359 }
360 else if (attached_entity && slot_id == -1 && attached_entity.GetInventory().FindFreeLocationFor(item, FindInventoryLocationType.ATTACHMENT, il))
361 {
362 item_base = ItemBase.Cast(item);
363 stackable = item_base.GetTargetQuantityMax(il.GetSlot());
364
365 if (stackable == 0 || stackable >= item_base.GetQuantity())
366 player.PredictiveTakeEntityToTargetAttachmentEx(attached_entity, item, il.GetSlot());
367 else if (stackable != 0 && stackable < item_base.GetQuantity())
368 item_base.SplitIntoStackMaxClient(m_Entity, il.GetSlot());
369 }
370 /*else if( ( m_Entity.GetInventory().CanAddEntityInCargo( item, item.GetInventory().GetFlipCargo() ) && ( !player.GetInventory().HasEntityInInventory( item ) || !m_Entity.GetInventory().HasEntityInCargo( item )) ) )
371 {
372 SplitItemUtils.TakeOrSplitToInventory( PlayerBase.Cast( GetGame().GetPlayer() ), m_Entity, item );
373 }*/
374 }
375
376 override void UnfocusAll()
377 {
378 int i;
379 for (i = 1; i < Count(); i++)
380 {
381 for (int j = 0; j < ITEMS_IN_ROW; j++)
382 {
383 Widget w = Get(i).GetMainWidget().FindAnyWidget("Cursor" + j);
384 if (w)
385 w.Show(false);
386 }
387 }
388 for (i = 0; i < m_AttachmentCargos.Count(); i++)
389 {
390 m_AttachmentCargos.GetElement(i).Unfocus();
391 m_AttachmentCargos.GetElement(i).SetActive(false);
392 }
393 }
394
395 override void DraggingOverHeader(Widget w, int x, int y, Widget receiver)
396 {
397 if (w == null)
398 return;
399 ItemPreviewWidget iw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
400 if (!iw)
401 {
402 string name = w.GetName();
403 name.Replace("PanelWidget", "Render");
404 iw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
405 }
406 if (!iw)
407 iw = ItemPreviewWidget.Cast(w);
408
409 if (!iw || !iw.GetItem() || (iw.GetItem() == m_Entity))
410 return;
411
414 name = receiver.GetName();
415 name.Replace("PanelWidget", "Render");
417 if (receiver_iw)
418 receiver_item = ItemBase.Cast(receiver_iw.GetItem());
419
421 receiver.GetUserData(slots_icon);
422
423 if (receiver_item)
424 {
425 int stack_max = InventorySlots.GetStackMaxForSlotId(receiver_item.GetInventory().GetSlotId(0));
426 //int quantity = receiver_item.GetQuantity();
427 //bool combinable = ( quantity < stack_max ) && ( ItemBase.Cast( receiver_item ).CanBeCombined( ItemBase.Cast( iw.GetItem() ) ) );
428 if (receiver_item.CanBeCombined(ItemBase.Cast(iw.GetItem())))
429 {
430 ItemManager.GetInstance().HideDropzones();
431 ItemManager.GetInstance().GetLeftDropzone().SetAlpha(1);
433 }
434 else if (stack_max == 0 && GameInventory.CanSwapEntitiesEx(receiver_item, iw.GetItem()))
435 {
436 ItemManager.GetInstance().HideDropzones();
437 ItemManager.GetInstance().GetLeftDropzone().SetAlpha(1);
439 }
440 else
441 {
442 ItemManager.GetInstance().ShowSourceDropzone(iw.GetItem());
444 }
445 }
446 else if (slots_icon && slots_icon.GetSlotID() != -1)
447 {
448 item = ItemBase.Cast(iw.GetItem());
449
450 if (item && m_Entity.GetInventory().CanAddAttachmentEx(item, slots_icon.GetSlotID()))
451 {
452 ItemManager.GetInstance().HideDropzones();
453 ItemManager.GetInstance().GetLeftDropzone().SetAlpha(1);
455 }
456 else
457 {
458 ItemManager.GetInstance().ShowSourceDropzone(iw.GetItem());
460 }
461 }
462 else
463 {
464 ItemManager.GetInstance().ShowSourceDropzone(iw.GetItem());
466 }
467 }
468
469 bool DraggingOverGrid(Widget w, int x, int y, Widget reciever, CargoContainer cargo)
470 {
471 if (w == null)
472 return false;
473
475
476 if (!item)
477 return false;
478
479 int color;
480 int idx = 0;
481 int c_x, c_y;
482
485
486 target_entity = cargo.GetEntity() ;
487 if (target_entity)
488 target_cargo = target_entity.GetInventory().GetCargo();
489 else
490 return false;
491
493 {
494 c_x = target_cargo.GetHeight();
495 c_y = target_cargo.GetWidth();
496 }
497 else
498 return false;
499
500 if (c_x > x && c_y > y && target_entity.GetInventory().CanAddEntityInCargoEx(item, idx, x, y, item.GetInventory().GetFlipCargo()))
502 else
504
505 if (w.FindAnyWidget("Cursor"))
506 w.FindAnyWidget("Cursor").SetColor(color);
507 else
508 {
509 string name = w.GetName();
510 name.Replace("PanelWidget", "Cursor");
511 if (w.FindAnyWidget(name))
512 w.FindAnyWidget(name).SetColor(color);
513 }
514
515 return true;
516 }
517
518 void DropReceived(Widget w, int x, int y, CargoContainer cargo)
519 {
521 if (!item)
522 return;
523
524 int idx = 0;
525 int c_x, c_y;
526
529
530 target_entity = cargo.GetEntity();
531 if (target_entity)
532 target_cargo = target_entity.GetInventory().GetCargo();
533 else
534 return;
535
537 {
538 c_x = target_cargo.GetHeight();
539 c_y = target_cargo.GetWidth();
540 }
541 else
542 return;
543
545 dst.SetCargoAuto(target_cargo, item, x, y, item.GetInventory().GetFlipCargo());
546
547 if (c_x > x && c_y > y && target_entity.GetInventory().LocationCanAddEntity(dst))
548 {
550
552
553 Icon icon = cargo.GetIcon(item);
554
555 if (icon)
556 {
557 icon.GetCursorWidget().SetColor(ColorManager.BASE_COLOR);
558 icon.RefreshPos(x, y);
559 icon.Refresh();
560 Refresh();
561 }
562 }
563 }
564
566 {
567 ItemPreviewWidget ipw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
568 if (!ipw)
569 {
570 string name = w.GetName();
571 name.Replace("PanelWidget", "Render");
572 ipw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
573 }
574 if (!ipw)
575 ipw = ItemPreviewWidget.Cast(w);
576 if (!ipw || !ipw.IsInherited(ItemPreviewWidget))
577 return null;
578 return ipw.GetItem();
579 }
580
581 override void Refresh()
582 {
583 if (!m_Refreshing)
584 {
585 if (!m_Closed)
586 {
587 super.Refresh();
589 }
590 }
591 }
592
594 {
595 m_Refreshing = true;
596 int row_count = m_AttachmentsContainer.GetRowCount();
597 int row;
598 for (row = 0; row < row_count; row++)
599 {
600 int col_count = m_AttachmentsContainer.GetColumnCountForRow(row);
601 int col;
602 for (col = 0; col < col_count; col++)
603 RefreshSlot(row, col, -1, "");
604 }
605 m_Refreshing = false;
606 }
607
608 //slot_id and slot_name parametr is not used
609 void RefreshSlot(int row, int column, int slot_id, string slot_name)
610 {
612 int slot_id_ = icon.GetSlotID();
613 EntityAI item = m_Entity.GetInventory().FindAttachment(slot_id_);
615
616 if (!m_Entity.CanDisplayAttachmentSlot(slot_id_))
617 {
618 icon.Clear();
619 icon.GetMainWidget().Show(false);
620 }
621 else if (!item)
622 {
623 if (icon.GetEntity())
624 {
625 icon.ClearRemainSelected();
626
628 if (cont)
629 {
631 this.Remove(cont);
632 (Container.Cast(cont.m_Parent)).Remove(cont);
633 }
634 }
635 icon.GetMainWidget().Show(true);
636 }
637 else
638 {
639 icon.GetMainWidget().Show(true);
640 if (icon.GetEntity() != item)
641 icon.Init(item);
642 else
643 icon.Refresh();
644
646 if (cont && cont.GetEntity() != item)
647 {
649 (Container.Cast(cont.m_Parent)).Remove(cont);
650 this.Remove(cont);
651 cont = null;
652 }
653
654 if (!cont)
655 {
656 if (item.GetInventory().GetCargo() && m_AttachmentCargos)
657 {
658 cont = new ContainerWithCargo(this, true);
659 cont.GetRootWidget().SetSort(m_AttachmentCargos.Count() + 10);
660 cont.SetEntity(item);
661 cont.SetSlotIcon(icon);
662
664 icon.SetContainer(cont);
665
666 SetOpenForSlotIcon(cont.IsOpened(), icon);
667 }
668 }
669
670 if (cont)
671 icon.GetRadialIconPanel().Show(cont.IsDisplayable());
672
674 bool draggable = true;
675 bool can_be_removed = item.GetInventory().CanRemoveEntity();
676 bool in_hands_condition = m_Entity.GetHierarchyRoot() == GetGame().GetPlayer();
678 if (m_Entity.GetInventory().GetSlotLock(slot_id_) && ItemManager.GetInstance().GetDraggedItem() != item)
679 {
680 icon.GetMountedWidget().Show(true);
681 draggable = false;
682 }
683 else
684 icon.GetMountedWidget().Show(false);
685
686 if (!m_Entity.CanReleaseAttachment(item))
687 draggable = false;
688
690 icon.GetOutOfReachWidget().Show(false);
691 else
692 {
693 icon.GetOutOfReachWidget().Show(true);
694 draggable = false;
695 }
696
697 if (draggable)
698 icon.GetRender().GetParent().SetFlags(WidgetFlags.DRAGGABLE);
699 else
700 icon.GetRender().GetParent().ClearFlags(WidgetFlags.DRAGGABLE);
701 }
702 }
703
704 void DoubleClick(Widget w, int x, int y, int button)
705 {
706 if (button == MouseState.LEFT && !g_Game.IsLeftCtrlDown())
707 {
708 ItemPreviewWidget iw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
709 if (!iw)
710 {
711 string name = w.GetName();
712 name.Replace("PanelWidget", "Render");
713 iw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
714 }
715
716 if (!iw)
717 iw = ItemPreviewWidget.Cast(w);
718
720 w.GetUserData(icon);
721
722 if (icon && m_Entity.GetInventory().GetSlotLock(iw.GetUserID()))
723 return;
724
725 if (icon.IsOutOfReach())
726 return;
727
728 ItemBase item = ItemBase.Cast(iw.GetItem());
729 if (item)
730 {
731 if (!item.GetInventory().CanRemoveEntity())
732 return;
733
735 if (controlledPlayer.GetInventory().HasEntityInInventory(item) && controlledPlayer.GetHumanInventory().CanAddEntityInHands(item))
736 controlledPlayer.PredictiveTakeEntityToHands(item);
737 else
738 {
739 if (controlledPlayer.GetInventory().CanAddEntityToInventory(item) && item.GetInventory().CanRemoveEntity())
740 {
741 if (item.GetTargetQuantityMax() < item.GetQuantity())
742 item.SplitIntoStackMaxClient(controlledPlayer, -1);
743 else
744 controlledPlayer.PredictiveTakeEntityToInventory(FindInventoryLocationType.ANY, item);
745 }
746 else
747 {
748 if (controlledPlayer.GetHumanInventory().CanAddEntityInHands(item))
749 {
750 if (item.GetTargetQuantityMax() < item.GetQuantity())
751 item.SplitIntoStackMaxHandsClient(controlledPlayer);
752 else
753 controlledPlayer.PredictiveTakeEntityToHands(item);
754 }
755 }
756 }
757
758 HideOwnedTooltip();
759
760 name = w.GetName();
761 name.Replace("PanelWidget", "Temperature");
762 w.FindAnyWidget(name).Show(false);
763 }
764 }
765 }
766
767 void MouseClick(Widget w, int x, int y, int button)
768 {
771 w.GetUserData(icon);
772 if (icon)
773 selectedItem = ItemBase.Cast(icon.GetEntity());
774
775 if (selectedItem)
776 {
777 switch (button)
778 {
779 case MouseState.RIGHT:
780#ifdef DIAG_DEVELOPER
781 if (g_Game.IsLeftCtrlDown())
782 ShowActionMenu(selectedItem);
783#endif
784
785 break;
786
787 case MouseState.MIDDLE:
789 break;
790
791 case MouseState.LEFT:
793 if (g_Game.IsLeftCtrlDown())
794 {
795 if (icon.IsOutOfReach())
796 return;
797
798 if (controlledPlayer.CanDropEntity(selectedItem))
799 {
800 if (selectedItem.GetTargetQuantityMax() < selectedItem.GetQuantity())
801 selectedItem.SplitIntoStackMaxClient(null, -1);
802 else
803 controlledPlayer.PhysicalPredictiveDropItem(selectedItem);
804 }
805 else
806 {
807 bool draggable = !controlledPlayer.GetInventory().HasInventoryReservation(selectedItem, null) && !controlledPlayer.GetInventory().IsInventoryLocked() && selectedItem.GetInventory().CanRemoveEntity() && !controlledPlayer.IsItemsToDelete();
808 ItemManager.GetInstance().SetWidgetDraggable(w, draggable);
809 }
810 }
811 else
812 {
813 ClosableContainer c = ClosableContainer.Cast(icon.GetContainer());
814 if (c)
815 c.Toggle();
816 }
817
818 break;
819 }
820 }
821 }
822
824 {
827
829
831 string categoryName;
832
835 GetGame().ConfigGetTextArray(m_RowConfigPath, player_ghosts_slots2);
837 header.SetName(categoryName);
838
840 SetHeader(null);
841
842 int count = player_ghosts_slots2.Count();
843 int lastRow = count / ITEMS_IN_ROW;
845
846 for (int j = 0; j < count; j++)
847 {
848 string slotName = player_ghosts_slots2.Get(j);
849 string iconName; //must be in format "set:<setname> image:<imagename>"
850 string path = "CfgSlots" + " Slot_" + slotName;
851
853
854 GetGame().ConfigGetText(path + " ghostIcon", iconName);
855 GetGame().ConfigGetText(path + " name", slotName);
856
857 int row = j / ITEMS_IN_ROW;
858 int column = j % ITEMS_IN_ROW;
859 if (column == 0)
860 {
862 slotsContainer.GetRootWidget().SetAlpha(0.7);
863 if (row == lastRow)
864 slotsContainer.SetColumnCount(count % ITEMS_IN_ROW);
865 else
866 slotsContainer.SetColumnCount(ITEMS_IN_ROW);
867
869 slotsContainer.GetRootWidget().SetSort(row);
870 }
871
872 SlotsIcon icon = slotsContainer.GetSlotIcon(column);
873 WidgetEventHandler.GetInstance().RegisterOnDropReceived(icon.GetMainWidget(), this, "OnDropReceivedFromHeader");
874 WidgetEventHandler.GetInstance().RegisterOnDropReceived(icon.GetGhostSlot(), this, "OnDropReceivedFromHeader");
875 WidgetEventHandler.GetInstance().RegisterOnDropReceived(icon.GetPanelWidget(), this, "OnDropReceivedFromHeader");
876
877 WidgetEventHandler.GetInstance().RegisterOnDraggingOver(icon.GetMainWidget(), this, "DraggingOverHeader");
878 WidgetEventHandler.GetInstance().RegisterOnDraggingOver(icon.GetGhostSlot(), this, "DraggingOverHeader");
879 WidgetEventHandler.GetInstance().RegisterOnDraggingOver(icon.GetPanelWidget(), this, "DraggingOverHeader");
880
881 WidgetEventHandler.GetInstance().RegisterOnDrop(icon.GetMainWidget(), this, "OnIconDrop");
882 WidgetEventHandler.GetInstance().RegisterOnDrop(icon.GetPanelWidget(), this, "OnIconDrop");
883
884 WidgetEventHandler.GetInstance().RegisterOnDoubleClick(icon.GetPanelWidget(), this, "DoubleClick");
885 WidgetEventHandler.GetInstance().RegisterOnMouseButtonUp(icon.GetPanelWidget(), this, "MouseClick");
886
888 icon.SetSlotID(slotId);
889 icon.SetSlotDisplayName(InventorySlots.GetSlotDisplayName(slotId));
890
891 icon.Clear();
892 }
894 }
895
896 override void UpdateInterval()
897 {
898 super.UpdateInterval();
900 }
901}
const int ITEMS_IN_ROW
Definition Attachments.c:1
EntityAI m_Entity
Definition ActionDebug.c:11
void Remove(Object object)
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
PlayerSpawnPreset slotName
DayZGame g_Game
Definition DayZGame.c:3528
string GetHeader()
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()
array< ref PlayerStatBase > Get()
void MouseClick(Widget w, int x, int y, int button)
override bool CanSplitEx(EntityAI focusedItem)
override void OnDropReceivedFromHeader(Widget w, int x, int y, Widget receiver)
ref AttachmentsGroupContainer m_AttachmentsContainer
void Init(int attachments_categories_count, int i, string attachment_category, string config_path_attachment_categories, EntityAI entity, int parent_m_Body_count)
void DoubleClick(Widget w, int x, int y, int button)
ref map< int, ref ContainerWithCargo > m_AttachmentCargos
void AttachmentCategoriesRow(LayoutHolder parent, int sort=-1)
void RefreshSlot(int row, int column, int slot_id, string slot_name)
void DropReceived(Widget w, int x, int y, CargoContainer cargo)
override void DraggingOverHeader(Widget w, int x, int y, Widget receiver)
bool DraggingOverGrid(Widget w, int x, int y, Widget reciever, CargoContainer cargo)
EntityAI GetItemPreviewItem(Widget w)
static bool IsAttachmentReachable(EntityAI e, string att_slot_name="", int slot_id=-1, float range=1.5)
represents base for cargo storage for entities
Definition Cargo.c:7
Super root of all classes in Enforce script.
Definition EnScript.c:11
override bool InspectItem()
void ContainerWithCargo(Container parent, int sort=-1)
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 Header.c:2
Definition Icon.c:2
InventoryLocation.
provides access to slot configuration
static proto native int GetStackMaxForSlotId(int slot_Id)
static proto native owned string GetSlotName(int id)
converts slot_id to string
static proto native owned string GetSlotDisplayName(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 const int IMAGESETGROUP_INVENTORY
static string VerifyIconImageString(int imageset_group=IMAGESETGROUP_INVENTORY, string icon_name="")
Checks for improperly formated, legacy image names and corrects them to default format.
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
WidgetFlags
Definition EnWidgets.c:58