DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
AttachmentCategoriesRow.c
См. документацию.
2{
3 protected string m_CategoryIdentifier;
4 protected string m_RowConfigPath;
5 protected bool m_Refreshing;
6
9
10 void AttachmentCategoriesRow(LayoutHolder parent, int sort = -1)
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 {
33 return icon.GetSlotID();
34 }
35 return -1;
36 }
37
38 override bool Select()
39 {
40 Man player = g_Game.GetPlayer();
41 SlotsIcon focused_icon = GetFocusedSlotsIcon();
42 EntityAI focused_item = GetFocusedItem();
43 Container focused_cont = GetFocusedContainer();
44 ItemBase selected_item = ItemBase.Cast(ItemManager.GetInstance().GetSelectedItem()); // == dragged item
45
46 if (selected_item && focused_item != selected_item)//dropping from micromanagement
47 {
48 if (selected_item.GetInventory().CanRemoveEntity())
49 {
50 int stack_max;
51
52 if (!focused_icon)
53 {
54 if (focused_cont)
55 {
56 focused_cont.Select();
57 }
58 }
59 else if (!focused_item && m_Entity && m_Entity.GetInventory().CanAddAttachmentEx(selected_item, focused_icon.GetSlotID()))
60 {
61 stack_max = InventorySlots.GetStackMaxForSlotId(focused_icon.GetSlotID());
62 float quantity = selected_item.GetQuantity();
63 if (stack_max == 0 || stack_max >= quantity || !selected_item.CanBeSplit())
64 {
65 player.PredictiveTakeEntityToTargetAttachmentEx(m_Entity, selected_item, focused_icon.GetSlotID());
66 return true;
67 }
68 else
69 {
70 selected_item.SplitIntoStackMaxClient(m_Entity, focused_icon.GetSlotID());
71 return true;
72 }
73 }
74 else if (focused_icon.GetSlotID() != -1)
75 {
76 if (focused_item && focused_item.GetHierarchyParent() && focused_item.GetHierarchyParent().GetInventory().CanAddAttachment(selected_item))
77 {
79 focused_item.GetInventory().GetCurrentInventoryLocation(inv_loc);
80 stack_max = InventorySlots.GetStackMaxForSlotId(inv_loc.GetSlot());
81 quantity = focused_item.GetQuantity();
82 if (focused_item.CanBeCombined(ItemBase.Cast(selected_item)))
83 {
84 focused_item.CombineItemsClient(selected_item, true);
85 return true;
86 }
87 else if (stack_max == 0 && GameInventory.CanSwapEntitiesEx(focused_item, selected_item))
88 {
89 player.PredictiveSwapEntities(selected_item, focused_item);
90 return true;
91 }
92 else if (m_AttachmentCargos.Contains(inv_loc.GetSlot()))
93 {
94 if (focused_item.GetInventory().CanAddEntityInCargo(selected_item, selected_item.GetInventory().GetFlipCargo()))
95 {
96 SplitItemUtils.TakeOrSplitToInventory(PlayerBase.Cast(player), focused_item, selected_item);
97 return true;
98 }
99 }
100 }
101 }
102 }
103 }
104 else //clicking
105 {
106 if (focused_item && focused_item.GetInventory().CanRemoveEntity() && (!focused_icon || !focused_icon.IsOutOfReach()))
107 {
108 EntityAI item_in_hands = g_Game.GetPlayer().GetEntityInHands();
109 if (item_in_hands && item_in_hands.GetInventory().CanRemoveEntity())
110 {
111 if (GameInventory.CanSwapEntitiesEx(item_in_hands, focused_item))
112 {
113 player.PredictiveSwapEntities(item_in_hands, focused_item);
114 return true;
115 }
116 }
117 else
118 {
119 if (player.GetHumanInventory().CanAddEntityInHands(focused_item))
120 {
121 player.PredictiveTakeEntityToHands(focused_item);
122 return true;
123 }
124 }
125 }
126 }
127
128 return false;
129 }
130
131 override bool TransferItem()
132 {
133 if (CanTakeToInventory())
134 {
135 EntityAI entity = GetFocusedItem();
136 SlotsIcon focused_icon = GetFocusedSlotsIcon();
137 if (entity && !entity.IsLockedInSlot() && (!focused_icon || !focused_icon.IsOutOfReach()))
138 {
139 PlayerBase player = PlayerBase.Cast( g_Game.GetPlayer() );
140 g_Game.GetPlayer().PredictiveTakeEntityToInventory( FindInventoryLocationType.CARGO, entity );
141 return true;
142 }
143 }
144 return false;
145 }
146
148 {
149 if (CanDrop())
150 {
151 ItemBase item = ItemBase.Cast(GetFocusedItem());
152 PlayerBase player = PlayerBase.Cast( g_Game.GetPlayer() );
153 SlotsIcon focused_icon = GetFocusedSlotsIcon();
154
155 if (item && !item.IsLockedInSlot() && (focused_icon && !focused_icon.IsOutOfReach()))
156 {
157 if (item.GetTargetQuantityMax() < item.GetQuantity())
158 item.SplitIntoStackMaxClient(null, -1);
159 else
160 player.PhysicalPredictiveDropItem(item);
161 return true;
162 }
163 }
164 return false;
165 }
166
167 override bool Combine()
168 {
169 if (CanCombine())
170 {
171 Man player = g_Game.GetPlayer();
172 ItemBase prev_item = ItemBase.Cast(GetFocusedItem());
173 ItemBase selected_item = ItemBase.Cast( player.GetEntityInHands() );
174 SlotsIcon focused_icon = GetFocusedSlotsIcon();
175
176 if (selected_item)
177 {
178 int selected_slot = GetFocusedSlot();
179 int stack_max;
180 if (selected_item && selected_item.GetInventory().CanRemoveEntity() && (focused_icon && !focused_icon.IsOutOfReach()))
181 {
182 if (!prev_item && m_Entity.GetInventory().CanAddAttachmentEx(selected_item, selected_slot))
183 {
184 stack_max = InventorySlots.GetStackMaxForSlotId(selected_slot);
185 float quantity = selected_item.GetQuantity();
186 if (stack_max == 0 || stack_max >= quantity || !selected_item.CanBeSplit())
187 {
188 player.PredictiveTakeEntityToTargetAttachmentEx(m_Entity, selected_item, selected_slot);
189 return true;
190 }
191 else
192 {
193 selected_item.SplitIntoStackMaxClient(m_Entity, selected_slot);
194 return true;
195 }
196 }
197 else if (selected_slot != -1)
198 {
199 if (prev_item)
200 {
202 prev_item.GetInventory().GetCurrentInventoryLocation(inv_loc);
203 stack_max = InventorySlots.GetStackMaxForSlotId(inv_loc.GetSlot());
204 quantity = prev_item.GetQuantity();
205 if (prev_item.CanBeCombined(ItemBase.Cast(selected_item)))
206 {
207 prev_item.CombineItemsClient(selected_item, true);
208 return true;
209 }
210 else if (stack_max == 0 && GameInventory.CanSwapEntitiesEx(prev_item, selected_item))
211 {
212 player.PredictiveSwapEntities(selected_item, prev_item);
213 return true;
214 }
215 else if (m_AttachmentCargos.Contains(inv_loc.GetSlot()))
216 {
217 if (prev_item.GetInventory().CanAddEntityInCargo(selected_item, selected_item.GetInventory().GetFlipCargo()))
218 {
219 SplitItemUtils.TakeOrSplitToInventory(PlayerBase.Cast(player), prev_item, selected_item);
220 return true;
221 }
222 }
223 }
224 }
225 }
226 }
227 }
228 return false;
229 }
230
231 override bool EquipItem() //TODO: may be possible, but the hint doesn't reflect it anyway
232 {
233 return false;
234 }
235
236 override bool CanCombine()
237 {
238 Man player = g_Game.GetPlayer();
239 ItemBase prev_item = ItemBase.Cast(GetFocusedItem());
240 ItemBase selected_item = ItemBase.Cast( player.GetEntityInHands() );
241 SlotsIcon focused_icon = GetFocusedSlotsIcon();
242
243 if (selected_item)
244 {
245 int selected_slot = GetFocusedSlot();
246 int stack_max;
247 if (selected_item && selected_item.GetInventory().CanRemoveEntity() && (focused_icon && !focused_icon.IsOutOfReach()))
248 {
249 if (m_Entity.GetInventory().CanAddAttachmentEx(selected_item, selected_slot))
250 {
251 stack_max = InventorySlots.GetStackMaxForSlotId(selected_slot);
252 float quantity = selected_item.GetQuantity();
253 if (stack_max == 0 || stack_max >= quantity || !selected_item.CanBeSplit())
254 {
255 return true;
256 }
257 else
258 {
259 return true;
260 }
261 }
262 else if (selected_slot != -1)
263 {
264 if (prev_item)
265 {
267 prev_item.GetInventory().GetCurrentInventoryLocation(inv_loc);
268 stack_max = InventorySlots.GetStackMaxForSlotId(inv_loc.GetSlot());
269 quantity = prev_item.GetQuantity();
270 if (prev_item.CanBeCombined(ItemBase.Cast(selected_item)))
271 {
272 return true;
273 }
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
299 override void OnDropReceivedFromHeader(Widget w, int x, int y, Widget receiver)
300 {
303 SlotsIcon slots_icon;
304 EntityAI receiver_item;
305 int slot_id = -1;
306 bool is_reserved = false;
307 EntityAI attached_entity;
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 {
323 return;
324 }
325 ItemBase item_base = ItemBase.Cast(item);
326
327 PlayerBase player = PlayerBase.Cast( g_Game.GetPlayer() );
328 if (!item.GetInventory().CanRemoveEntity() || !player.CanManipulateInventory())
329 return;
330
331 EntityAI target_att_entity = m_Entity;
332 Weapon_Base wpn;
333 Magazine mag;
334 if (Class.CastTo(wpn, m_Entity) && Class.CastTo(mag, item))
335 {
336 if (player.GetWeaponManager().CanAttachMagazine(wpn, mag))
337 {
338 player.GetWeaponManager().AttachMagazine(mag);
339 }
340 }
341 else if (receiver_item && !is_reserved)
342 {
343 if ((ItemBase.Cast(receiver_item)).CanBeCombined(ItemBase.Cast(item)))
344 {
345 (ItemBase.Cast(receiver_item)).CombineItemsClient(ItemBase.Cast(item));
346 }
347 else if (GameInventory.CanSwapEntitiesEx(receiver_item, item))
348 {
349 if (!receiver_item.GetInventory().CanRemoveEntity())
350 return;
351 g_Game.GetPlayer().PredictiveSwapEntities( receiver_item, item );
352 }
353 else if (receiver_item.GetInventory().CanAddAttachment(item))
354 {
355 player.PredictiveTakeEntityToTargetAttachment(receiver_item, item);
356 }
357 }
358 else if (attached_entity && slot_id != -1 && attached_entity.GetInventory().CanAddAttachmentEx(item, slot_id))
359 {
360 item_base = ItemBase.Cast(item);
361 stackable = item_base.GetTargetQuantityMax(slot_id);
362
363 if (stackable == 0 || stackable >= item_base.GetQuantity())
364 {
365 player.PredictiveTakeEntityToTargetAttachmentEx(attached_entity, item, slot_id);
366 }
367 else if (stackable != 0 && stackable < item_base.GetQuantity())
368 {
369 item_base.SplitIntoStackMaxClient(m_Entity, slot_id);
370 }
371 }
372 else if (attached_entity && slot_id == -1 && attached_entity.GetInventory().FindFreeLocationFor(item,FindInventoryLocationType.ATTACHMENT,il))
373 {
374 item_base = ItemBase.Cast(item);
375 stackable = item_base.GetTargetQuantityMax(il.GetSlot());
376
377 if (stackable == 0 || stackable >= item_base.GetQuantity())
378 {
379 player.PredictiveTakeEntityToTargetAttachmentEx(attached_entity, item, il.GetSlot());
380 }
381 else if (stackable != 0 && stackable < item_base.GetQuantity())
382 {
383 item_base.SplitIntoStackMaxClient(m_Entity, il.GetSlot());
384 }
385 }
386 /*else if ((m_Entity.GetInventory().CanAddEntityInCargo(item, item.GetInventory().GetFlipCargo()) && (!player.GetInventory().HasEntityInInventory(item) || !m_Entity.GetInventory().HasEntityInCargo(item))))
387 {
388 SplitItemUtils.TakeOrSplitToInventory( PlayerBase.Cast( g_Game.GetPlayer() ), m_Entity, item );
389 }*/
390 }
391
392 override void UnfocusAll()
393 {
394 int i;
395 for (i = 1; i < Count(); ++i)
396 {
397 for (int j = 0; j < ITEMS_IN_ROW; j++)
398 {
399 Widget w = Get(i).GetMainWidget().FindAnyWidget("Cursor" + j);
400 if (w)
401 w.Show(false);
402 }
403 }
404
405 for (i = 0; i < m_AttachmentCargos.Count(); ++i)
406 {
407 m_AttachmentCargos.GetElement(i).Unfocus();
408 m_AttachmentCargos.GetElement(i).SetActive(false);
409 }
410 }
411
412 override void DraggingOverHeader(Widget w, int x, int y, Widget receiver)
413 {
414 if (w == null)
415 {
416 return;
417 }
418 ItemPreviewWidget iw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
419 if (!iw)
420 {
421 string name = w.GetName();
422 name.Replace("PanelWidget", "Render");
423 iw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
424 }
425 if (!iw)
426 {
427 iw = ItemPreviewWidget.Cast(w);
428 }
429
430 if (!iw || !iw.GetItem() || (iw.GetItem() == m_Entity))
431 {
432 return;
433 }
434
435 ItemBase item;
436 ItemBase receiver_item;
437 name = receiver.GetName();
438 name.Replace("PanelWidget", "Render");
439 ItemPreviewWidget receiver_iw = ItemPreviewWidget.Cast(receiver.FindAnyWidget(name));
440 if (receiver_iw)
441 receiver_item = ItemBase.Cast(receiver_iw.GetItem());
442
443 SlotsIcon slots_icon;
444 receiver.GetUserData(slots_icon);
445
446 if (receiver_item)
447 {
448 int stack_max = InventorySlots.GetStackMaxForSlotId(receiver_item.GetInventory().GetSlotId(0));
449 //int quantity = receiver_item.GetQuantity();
450 //bool combinable = (quantity < stack_max) && (ItemBase.Cast(receiver_item).CanBeCombined(ItemBase.Cast(iw.GetItem())));
451 if (receiver_item.CanBeCombined(ItemBase.Cast(iw.GetItem())))
452 {
456 }
457 else if (stack_max == 0 && GameInventory.CanSwapEntitiesEx(receiver_item, iw.GetItem()))
458 {
462 }
463 else
464 {
467 }
468 }
469 else if (slots_icon && slots_icon.GetSlotID() != -1)
470 {
471 item = ItemBase.Cast(iw.GetItem());
472
473 if (item && m_Entity.GetInventory().CanAddAttachmentEx(item, slots_icon.GetSlotID()))
474 {
478 }
479 else
480 {
483 }
484 }
485 else
486 {
489 }
490 }
491
492 bool DraggingOverGrid(Widget w, int x, int y, Widget reciever, CargoContainer cargo)
493 {
494 if (w == null)
495 {
496 return false;
497 }
498
500
501 if (!item)
502 {
503 return false;
504 }
505
506 int color;
507 int idx = 0;
508 int c_x, c_y;
509
510 EntityAI target_entity;
511 CargoBase target_cargo;
512
513 target_entity = cargo.GetEntity() ;
514 if (target_entity)
515 {
516 target_cargo = target_entity.GetInventory().GetCargo();
517 }
518 else
519 return false;
520
521 if (target_cargo && target_entity)
522 {
523 c_x = target_cargo.GetHeight();
524 c_y = target_cargo.GetWidth();
525 }
526 else
527 return false;
528
529 if (c_x > x && c_y > y && target_entity.GetInventory().CanAddEntityInCargoEx(item, idx, x, y, item.GetInventory().GetFlipCargo()))
530 {
532 }
533 else
534 {
535 color = ColorManager.RED_COLOR;
536 }
537
538 if (w.FindAnyWidget("Cursor"))
539 {
540 w.FindAnyWidget("Cursor").SetColor(color);
541 }
542 else
543 {
544 string name = w.GetName();
545 name.Replace("PanelWidget", "Cursor");
546 if (w.FindAnyWidget(name))
547 {
548 w.FindAnyWidget(name).SetColor(color);
549 }
550 }
551
552 return true;
553 }
554
555 void DropReceived(Widget w, int x, int y, CargoContainer cargo)
556 {
558 if (!item)
559 {
560 return;
561 }
562
563 int idx = 0;
564 int c_x, c_y;
565
566 EntityAI target_entity;
567 CargoBase target_cargo;
568
569 target_entity = cargo.GetEntity();
570 if (target_entity)
571 {
572 target_cargo = target_entity.GetInventory().GetCargo();
573 }
574 else
575 return;
576
577 if (target_cargo && target_entity)
578 {
579 c_x = target_cargo.GetHeight();
580 c_y = target_cargo.GetWidth();
581 }
582 else
583 return;
584
586 dst.SetCargoAuto(target_cargo, item, x, y, item.GetInventory().GetFlipCargo());
587
588 if (c_x > x && c_y > y && target_entity.GetInventory().LocationCanAddEntity(dst))
589 {
590 PlayerBase player = PlayerBase.Cast( g_Game.GetPlayer() );
591
593
594 Icon icon = cargo.GetIcon(item);
595
596 if (icon)
597 {
598 icon.GetCursorWidget().SetColor(ColorManager.BASE_COLOR);
599 icon.RefreshPos(x, y);
600 icon.Refresh();
601 Refresh();
602 }
603 }
604 }
605
607 {
608 ItemPreviewWidget ipw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
609 if (!ipw)
610 {
611 string name = w.GetName();
612 name.Replace("PanelWidget", "Render");
613 ipw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
614 }
615 if (!ipw)
616 {
617 ipw = ItemPreviewWidget.Cast(w);
618 }
619 if (!ipw || !ipw.IsInherited(ItemPreviewWidget))
620 {
621 return null;
622 }
623 return ipw.GetItem();
624 }
625
626 override void Refresh()
627 {
628 if (!m_Refreshing)
629 {
630 if (!m_Closed)
631 {
632 super.Refresh();
634 }
635 }
636 }
637
639 {
640 m_Refreshing = true;
641 int row_count = m_AttachmentsContainer.GetRowCount();
642 int row;
643 for (row = 0; row < row_count; ++row)
644 {
645 int col_count = m_AttachmentsContainer.GetColumnCountForRow(row);
646 int col;
647 for (col = 0; col < col_count; ++col)
648 {
649 RefreshSlot(row, col, -1, "");
650 }
651 }
652 m_Refreshing = false;
653 }
654
655 //slot_id and slot_name parametr is not used
656 void RefreshSlot(int row, int column, int slot_id, string slot_name)
657 {
658 SlotsIcon icon = m_AttachmentsContainer.GetSlotsIcon(row, column);
659 int slot_id_ = icon.GetSlotID();
660 EntityAI item = m_Entity.GetInventory().FindAttachment(slot_id_);
662
663 if (!m_Entity.CanDisplayAttachmentSlot(slot_id_))
664 {
665 icon.Clear();
666 icon.GetMainWidget().Show(false);
667 }
668 else if (!item)
669 {
670 icon.ClearRemainSelected();
671
672 cont = m_AttachmentCargos.Get(slot_id_);
673 if (cont)
674 {
675 m_AttachmentCargos.Remove(slot_id_);
676 this.Remove(cont);
677 (Container.Cast(cont.m_Parent)).Remove(cont);
678 }
679 icon.GetMainWidget().Show(true);
680 }
681 else
682 {
683 icon.GetMainWidget().Show(true);
684 if (icon.GetEntity() != item)
685 {
686 icon.Init(item);
687 }
688 else
689 {
690 icon.Refresh();
691 }
692
693 cont = m_AttachmentCargos.Get(slot_id_);
694 if (cont && cont.GetEntity() != item)
695 {
696 m_AttachmentCargos.Remove(slot_id_);
697 (Container.Cast(cont.m_Parent)).Remove(cont);
698 this.Remove(cont);
699 cont = null;
700 }
701
702 if (!cont)
703 {
704 if (item.GetInventory().GetCargo() && m_AttachmentCargos)
705 {
706 cont = new ContainerWithCargo(this, true);
707 cont.GetRootWidget().SetSort(m_AttachmentCargos.Count() + 10);
708 cont.SetEntity(item);
709 cont.SetSlotIcon(icon);
710
711 m_AttachmentCargos.Insert(slot_id_, cont);
712 icon.SetContainer(cont);
713
714 SetOpenForSlotIcon(cont.IsOpened(),icon);
715 }
716 }
717
718 if (cont)
719 {
720 icon.GetRadialIconPanel().Show(cont.IsDisplayable());
721 }
722
723 string slotName = InventorySlots.GetSlotName(slot_id_);
724 bool draggable = true;
725 bool can_be_removed = item.GetInventory().CanRemoveEntity();
726 bool in_hands_condition = m_Entity.GetHierarchyRoot() == g_Game.GetPlayer();
728 if (m_Entity.GetInventory().GetSlotLock(slot_id_) && ItemManager.GetInstance().GetDraggedItem() != item)
729 {
730 icon.GetMountedWidget().Show(true);
731 draggable = false;
732 }
733 else
734 {
735 icon.GetMountedWidget().Show(false);
736 }
737
738 if (!m_Entity.CanReleaseAttachment(item))
739 {
740 draggable = false;
741 }
742
743 if ((in_hands_condition || in_vicinity_condition) && can_be_removed)
744 {
745 icon.GetOutOfReachWidget().Show(false);
746 }
747 else
748 {
749 icon.GetOutOfReachWidget().Show(true);
750 draggable = false;
751 }
752
753 if (draggable)
754 {
755 icon.GetRender().GetParent().SetFlags(WidgetFlags.DRAGGABLE);
756 }
757 else
758 {
759 icon.GetRender().GetParent().ClearFlags(WidgetFlags.DRAGGABLE);
760 }
761 }
762 }
763
764 protected bool IsCategoryReachable(EntityAI ent, string categoryName, float range = 1.5)
765 {
766 TypeAttachmentGroupsDataHolder holder = ent.GetTypeAttachmentGroupInfoHolder();
767 TypeAttachmentGroupData dataObj = holder.GetAttGroupDataByClassName(categoryName);
768 if (!dataObj)
769 return false;
770
771 string selectionName = dataObj.m_SelectionName;
772 if (ent.MemoryPointExists(selectionName))
773 {
774 vector position = ent.GetMemoryPointPos(selectionName);
775 position = ent.ModelToWorld(position);
776 vector posPlayer = g_Game.GetPlayer().GetPosition();
777 float heightDiff = posPlayer[1] - position[1];
778 float negativeTolerance = -range / 5;
779 posPlayer[1] = 0;
780 position[1] = 0;
781 //sort of 'dome' shaped detection with some negative leeway
782 return heightDiff >= negativeTolerance && (Math.AbsFloat(heightDiff) <= range) && vector.Distance(posPlayer, position) <= range;
783 }
784
785 return true;
786 }
787
788 void DoubleClick(Widget w, int x, int y, int button)
789 {
790 if (button == MouseState.LEFT && !g_Game.IsLeftCtrlDown())
791 {
792 ItemPreviewWidget iw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
793 if (!iw)
794 {
795 string name = w.GetName();
796 name.Replace("PanelWidget", "Render");
797 iw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
798 }
799
800 if (!iw)
801 iw = ItemPreviewWidget.Cast(w);
802
803 SlotsIcon icon;
804 w.GetUserData(icon);
805
806 if (icon && m_Entity.GetInventory().GetSlotLock(iw.GetUserID()))
807 return;
808
809 if (icon.IsOutOfReach())
810 return;
811
812 ItemBase item = ItemBase.Cast(iw.GetItem());
813 if (item)
814 {
815 if (!item.GetInventory().CanRemoveEntity())
816 return;
817
818 PlayerBase controlledPlayer = PlayerBase.Cast(g_Game.GetPlayer());
819 if (controlledPlayer.GetInventory().HasEntityInInventory(item) && controlledPlayer.GetHumanInventory().CanAddEntityInHands(item))
820 {
821 controlledPlayer.PredictiveTakeEntityToHands(item);
822 }
823 else
824 {
825 if (controlledPlayer.GetInventory().CanAddEntityToInventory(item) && item.GetInventory().CanRemoveEntity())
826 {
827 if (item.GetTargetQuantityMax() < item.GetQuantity())
828 item.SplitIntoStackMaxClient(controlledPlayer, -1);
829 else
830 controlledPlayer.PredictiveTakeEntityToInventory(FindInventoryLocationType.ANY, item);
831 }
832 else
833 {
834 if (controlledPlayer.GetHumanInventory().CanAddEntityInHands(item))
835 {
836 if (item.GetTargetQuantityMax() < item.GetQuantity())
837 item.SplitIntoStackMaxHandsClient(controlledPlayer);
838 else
839 controlledPlayer.PredictiveTakeEntityToHands(item);
840 }
841 }
842 }
843
844 HideOwnedTooltip();
845
846 name = w.GetName();
847 name.Replace("PanelWidget", "Temperature");
848 w.FindAnyWidget(name).Show(false);
849 }
850 }
851 }
852
853 void MouseClick(Widget w, int x, int y, int button)
854 {
855 ItemBase selectedItem;
856 SlotsIcon icon;
857 w.GetUserData(icon);
858 if (icon)
859 selectedItem = ItemBase.Cast(icon.GetEntity());
860
861 if (selectedItem)
862 {
863 switch (button)
864 {
865 case MouseState.RIGHT:
866 #ifdef DIAG_DEVELOPER
867 if (g_Game.IsLeftCtrlDown())
868 ShowActionMenu(selectedItem);
869 #endif
870
871 if (CanSplitEx(selectedItem))
872 {
873 selectedItem.OnRightClick();
874 }
875
876 break;
877
878 case MouseState.MIDDLE:
879 InspectItem(selectedItem);
880 break;
881
882 case MouseState.LEFT:
883 PlayerBase controlledPlayer = PlayerBase.Cast(g_Game.GetPlayer());
884 if (g_Game.IsLeftCtrlDown())
885 {
886 if (icon.IsOutOfReach())
887 return;
888
889 if (controlledPlayer.CanDropEntity(selectedItem))
890 {
891 if (selectedItem.GetTargetQuantityMax() < selectedItem.GetQuantity())
892 selectedItem.SplitIntoStackMaxClient(null, -1);
893 else
894 controlledPlayer.PhysicalPredictiveDropItem(selectedItem);
895 }
896 else
897 {
898 bool draggable = !controlledPlayer.GetInventory().HasInventoryReservation(selectedItem, null) && !controlledPlayer.GetInventory().IsInventoryLocked() && selectedItem.GetInventory().CanRemoveEntity() && !controlledPlayer.IsItemsToDelete();
900 }
901 }
902 else
903 {
905 if (c)
906 c.Toggle();
907 }
908
909 break;
910 }
911 }
912 }
913
914 void Init(int attachments_categories_count, int i, string attachment_category, string config_path_attachment_categories, EntityAI entity, int parent_m_Body_count)
915 {
916 m_Entity = entity;
917 Header header = GetHeader();
918
919 m_CategoryIdentifier = attachment_category;
920
921 array<string> player_ghosts_slots2 = new array<string>();
922 string categoryName;
923
924 m_RowConfigPath = config_path_attachment_categories + " " + attachment_category + " attachmentSlots";
925 string config_path_category_name = config_path_attachment_categories + " " + attachment_category + " name";
926 g_Game.ConfigGetTextArray(m_RowConfigPath, player_ghosts_slots2);
927 g_Game.ConfigGetText(config_path_category_name, categoryName);
928 header.SetName(categoryName);
929
930 m_AttachmentsContainer.SetHeader(header);
931 SetHeader(null);
932
933 int count = player_ghosts_slots2.Count();
934 int lastRow = count / ITEMS_IN_ROW;
935 SlotsContainer slotsContainer;
936
937 for (int j = 0; j < count; ++j)
938 {
939 string slotName = player_ghosts_slots2.Get(j);
940 string iconName; //must be in format "set:<setname> image:<imagename>"
941 string path = "CfgSlots" + " Slot_" + slotName;
942
944
945 g_Game.ConfigGetText(path + " ghostIcon", iconName);
946 g_Game.ConfigGetText(path + " name", slotName);
947
948 int row = j / ITEMS_IN_ROW;
949 int column = j % ITEMS_IN_ROW;
950 if (column == 0)
951 {
952 slotsContainer = new SlotsContainer(m_AttachmentsContainer, m_Entity);
953 slotsContainer.GetRootWidget().SetAlpha(0.7);
954 if (row == lastRow)
955 slotsContainer.SetColumnCount(count % ITEMS_IN_ROW);
956 else
957 slotsContainer.SetColumnCount(ITEMS_IN_ROW);
958
959 m_AttachmentsContainer.Insert(slotsContainer);
960 slotsContainer.GetRootWidget().SetSort(row);
961 }
962
963 SlotsIcon icon = slotsContainer.GetSlotIcon(column);
964 WidgetEventHandler.GetInstance().RegisterOnDropReceived(icon.GetMainWidget(), this, "OnDropReceivedFromHeader");
965 WidgetEventHandler.GetInstance().RegisterOnDropReceived(icon.GetGhostSlot(), this, "OnDropReceivedFromHeader");
966 WidgetEventHandler.GetInstance().RegisterOnDropReceived(icon.GetPanelWidget(), this, "OnDropReceivedFromHeader");
967
968 WidgetEventHandler.GetInstance().RegisterOnDraggingOver(icon.GetMainWidget(), this, "DraggingOverHeader");
969 WidgetEventHandler.GetInstance().RegisterOnDraggingOver(icon.GetGhostSlot(), this, "DraggingOverHeader");
970 WidgetEventHandler.GetInstance().RegisterOnDraggingOver(icon.GetPanelWidget(), this, "DraggingOverHeader");
971
972 WidgetEventHandler.GetInstance().RegisterOnDrop(icon.GetMainWidget(), this, "OnIconDrop");
973 WidgetEventHandler.GetInstance().RegisterOnDrop(icon.GetPanelWidget(), this, "OnIconDrop");
974
977
979 icon.SetSlotID(slotId);
981
982 icon.Clear();
983 }
985 }
986
987 override void UpdateInterval()
988 {
989 super.UpdateInterval();
991 }
992}
const int ITEMS_IN_ROW
Entity m_Entity
Определения CachedEquipmentStorageBase.c:16
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
PlayerSpawnPreset slotName
DayZGame g_Game
Определения DayZGame.c:4074
vector position
Определения DustKickupEffects.c:20
string GetHeader()
Определения ErrorProperties.c:76
Icon x
Icon y
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:18
string path
Определения OptionSelectorMultistate.c:142
override float Get()
Определения PlayerStatBase.c:134
@ Count
Определения RandomGeneratorSyncManager.c:8
void MouseClick(Widget w, int x, int y, int button)
Определения AttachmentCategoriesRow.c:853
string m_RowConfigPath
Определения AttachmentCategoriesRow.c:4
override void UpdateInterval()
Определения AttachmentCategoriesRow.c:987
override void Refresh()
Определения AttachmentCategoriesRow.c:626
override bool Select()
Определения AttachmentCategoriesRow.c:38
bool IsCategoryReachable(EntityAI ent, string categoryName, float range=1.5)
Определения AttachmentCategoriesRow.c:764
override bool TransferItemToVicinity()
Определения AttachmentCategoriesRow.c:147
override void OnDropReceivedFromHeader(Widget w, int x, int y, Widget receiver)
Определения AttachmentCategoriesRow.c:299
override bool IsItemWithQuantityActive()
Определения AttachmentCategoriesRow.c:292
override bool IsItemActive()
Определения AttachmentCategoriesRow.c:286
override bool CanCombineAmmo()
Определения AttachmentCategoriesRow.c:281
ref AttachmentsGroupContainer m_AttachmentsContainer
Определения AttachmentCategoriesRow.c:7
override bool Combine()
Определения AttachmentCategoriesRow.c:167
void Init(int attachments_categories_count, int i, string attachment_category, string config_path_attachment_categories, EntityAI entity, int parent_m_Body_count)
Определения AttachmentCategoriesRow.c:914
override void UnfocusAll()
Определения AttachmentCategoriesRow.c:392
void DoubleClick(Widget w, int x, int y, int button)
Определения AttachmentCategoriesRow.c:788
override bool TransferItem()
Определения AttachmentCategoriesRow.c:131
ref map< int, ref ContainerWithCargo > m_AttachmentCargos
Определения AttachmentCategoriesRow.c:8
string m_CategoryIdentifier
Определения AttachmentCategoriesRow.c:3
void AttachmentCategoriesRow(LayoutHolder parent, int sort=-1)
Определения AttachmentCategoriesRow.c:10
void RefreshSlot(int row, int column, int slot_id, string slot_name)
Определения AttachmentCategoriesRow.c:656
void DropReceived(Widget w, int x, int y, CargoContainer cargo)
Определения AttachmentCategoriesRow.c:555
override void DraggingOverHeader(Widget w, int x, int y, Widget receiver)
Определения AttachmentCategoriesRow.c:412
bool DraggingOverGrid(Widget w, int x, int y, Widget reciever, CargoContainer cargo)
Определения AttachmentCategoriesRow.c:492
string GetCategoryIdentifier()
Определения AttachmentCategoriesRow.c:23
override bool CanCombine()
Определения AttachmentCategoriesRow.c:236
override bool EquipItem()
Определения AttachmentCategoriesRow.c:231
EntityAI GetItemPreviewItem(Widget w)
Определения AttachmentCategoriesRow.c:606
static bool IsAttachmentReachable(EntityAI e, string att_slot_name="", int slot_id=-1, float range=1.5)
Определения AttachmentsOutOfReach.c:5
proto native int GetWidth()
proto native int GetHeight()
represents base for cargo storage for entities
Определения Cargo.c:7
Super root of all classes in Enforce script.
Определения EnScript.c:11
override bool InspectItem()
Определения ContainerWithCargo.c:184
void ContainerWithCargo(LayoutHolder parent, int sort=-1)
Определения ContainerWithCargo.c:6
void SetColor(Widget w, int color)
Определения ColorManager.c:32
static int BASE_COLOR
Определения ColorManager.c:15
static int COMBINE_COLOR
Определения ColorManager.c:20
static int SWAP_COLOR
Определения ColorManager.c:18
static int GREEN_COLOR
Определения ColorManager.c:17
static int RED_COLOR
Определения ColorManager.c:16
static ColorManager GetInstance()
Определения ColorManager.c:27
Определения ColorManager.c:2
override bool Select()
Определения CargoContainer.c:852
Определения CargoContainer.c:3
static bool CanSwapEntitiesEx(notnull EntityAI item1, notnull EntityAI item2)
script counterpart to engine's class Inventory
void SetName(string name)
Определения Header.c:33
Определения Header.c:2
Widget GetCursorWidget()
Определения Icon.c:88
override void Refresh()
Определения Icon.c:1215
void RefreshPos(int row, int column)
Определения Icon.c:1254
Определения Icon.c:2
proto native int GetSlot()
returns slot id if current type is Attachment
proto native void SetCargoAuto(notnull CargoBase cargo, EntityAI e, int row, int col, bool flip)
based on Cargo.IsProxyCargo uses SetProxyCargo or SetCargo respectively
InventoryLocation.
Определения InventoryLocation.c:30
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 proto native int GetStackMaxForSlotId(int slot_Id)
static proto native owned string GetSlotName(int id)
converts slot_id to string
provides access to slot configuration
Определения InventorySlots.c:6
override bool CanBeCombined(EntityAI other_item, bool reservation_check=true, bool stack_max_limit=false)
Определения Rag.c:61
override bool CanBeSplit()
Определения Rag.c:34
EntityAI GetDraggedItem()
Определения ItemManager.c:368
void ShowSourceDropzone(EntityAI item)
Определения ItemManager.c:302
Widget GetLeftDropzone()
Определения ItemManager.c:336
EntityAI GetSelectedItem()
Определения ItemManager.c:85
void HideDropzones()
Определения ItemManager.c:287
void SetWidgetDraggable(Widget w, bool draggable)
Определения ItemManager.c:693
void SetIsDragging(bool is_dragging)
Определения ItemManager.c:383
static ItemManager GetInstance()
Определения ItemManager.c:282
Определения ItemManager.c:2
proto native EntityAI GetItem()
Определения gameplay.c:287
Определения Container.c:2
Определения EnMath.c:7
Определения PlayerBaseClient.c:2
SlotsIcon GetSlotIcon(int index)
Определения SlotsContainer.c:207
Определения SlotsContainer.c:2
override void Clear()
Определения SlotsIcon.c:65
override void ClearRemainSelected()
Определения SlotsIcon.c:57
void SetContainer(Container container)
Определения SlotsIconBase.c:109
Container GetContainer()
Определения SlotsIconBase.c:119
Widget GetRadialIconPanel()
Определения SlotsIconBase.c:270
override void Refresh()
Определения SlotsIconBase.c:315
EntityAI GetSlotParent()
Определения SlotsIconBase.c:155
Widget GetOutOfReachWidget()
Определения SlotsIconBase.c:235
void SetSlotID(int slot_ID)
Определения SlotsIconBase.c:165
bool IsReserved()
Определения SlotsIconBase.c:170
int GetSlotID()
Определения SlotsIconBase.c:160
ImageWidget GetGhostSlot()
Определения SlotsIconBase.c:205
Widget GetPanelWidget()
Определения SlotsIconBase.c:175
ItemPreviewWidget GetRender()
Определения SlotsIconBase.c:200
void SetSlotDisplayName(string text)
Определения SlotsIconBase.c:114
EntityAI GetEntity()
Определения SlotsIconBase.c:335
Widget GetMountedWidget()
Определения SlotsIconBase.c:195
void Init(EntityAI obj, bool reservation=false)
Определения SlotsIconBase.c:472
bool IsOutOfReach()
Определения SlotsIconBase.c:700
Определения SlotsIcon.c:2
static void TakeOrSplitToInventoryLocation(notnull PlayerBase player, notnull InventoryLocation dst)
Определения SplitItemUtils.c:34
static void TakeOrSplitToInventory(notnull PlayerBase player, notnull EntityAI target, notnull EntityAI item)
Определения SplitItemUtils.c:3
Определения SplitItemUtils.c:2
static const int IMAGESETGROUP_INVENTORY
Определения StaticGUIUtils.c:3
static string VerifyIconImageString(int imageset_group=IMAGESETGROUP_INVENTORY, string icon_name="")
Checks for improperly formated, legacy image names and corrects them to default format.
Определения StaticGUIUtils.c:7
Определения StaticGUIUtils.c:2
string m_SelectionName
in imageset format
Определения TypeAttachmentGroupData.c:12
Data for one attachment group.
Определения TypeAttachmentGroupData.c:4
TypeAttachmentGroupData GetAttGroupDataByClassName(string groupName)
Returns single 'GUIInventoryAttachmentsProps' subclass data based on class name.
Data holder for attachment group classes.
Определения TypeAttachmentGroupDataHolders.c:5
const float DEFAULT
Определения ActionConstants.c:114
shorthand
Определения BoltActionRifle_Base.c:6
void RegisterOnDropReceived(Widget w, Managed eventHandler, string functionName)
Определения WidgetEventHandler.c:91
void RegisterOnDraggingOver(Widget w, Managed eventHandler, string functionName)
Определения WidgetEventHandler.c:112
void RegisterOnDrop(Widget w, Managed eventHandler, string functionName)
Определения WidgetEventHandler.c:105
static WidgetEventHandler GetInstance()
Определения WidgetEventHandler.c:22
void RegisterOnMouseButtonUp(Widget w, Managed eventHandler, string functionName)
Определения WidgetEventHandler.c:77
void RegisterOnDoubleClick(Widget w, Managed eventHandler, string functionName)
Определения WidgetEventHandler.c:140
Определения EnWidgets.c:190
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Определения Transport.c:70
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
Определения EnConvert.c:119
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
static proto float AbsFloat(float f)
Returns absolute value.
MouseState
Определения EnSystem.c:311
WidgetFlags
Определения EnWidgets.c:58