DayZ 1.24
Loading...
Searching...
No Matches
Icon.c
Go to the documentation of this file.
2{
3 protected int m_SizeX;
4 protected int m_SizeY;
5 protected int m_PosX;
6 protected int m_PosY;
7
8 protected EntityAI m_Lock;
9 protected bool m_IsWeapon = false;
10 protected bool m_IsMagazine = false;
11 protected bool m_HasTemperature = false;
12 protected bool m_HasQuantity = false;
13 protected float m_CurrQuantity = -1;
14
15 protected EntityAI m_Obj;
16 protected ItemBase m_Item;
17 protected bool m_HandsIcon;
18 protected int m_CargoPos;
19 protected bool m_IsDragged;
21
22 const int NUMBER_OF_TIMERS = 2;
23
25
30
35
38
41
42 void Icon(LayoutHolder parent, bool hands_icon = false)
43 {
45 ItemManager.GetInstance().SetSelectedItemEx(null, null, null);
46
47 m_ItemPreview = ItemPreviewWidget.Cast(GetMainWidget().FindAnyWidget("Render"));
48
49 m_ColorWidget = GetMainWidget().FindAnyWidget("Color");
50 m_SelectedPanel = GetMainWidget().FindAnyWidget("Selected");
51 m_MicromanagedPanel = GetMainWidget().FindAnyWidget("Micromanaged");
52 m_CursorWidget = GetMainWidget().FindAnyWidget("Cursor");
53
54 m_QuantityPanel = GetMainWidget().FindAnyWidget("QuantityPanel");
55 m_QuantityItem = TextWidget.Cast(GetMainWidget().FindAnyWidget("Quantity"));
56 m_QuantityProgress = ProgressBarWidget.Cast(GetMainWidget().FindAnyWidget("QuantityBar"));
57 m_QuantityStack = GetMainWidget().FindAnyWidget("QuantityStackPanel");
58
59 m_ItemSizePanel = GetMainWidget().FindAnyWidget("ItemSizePanel");
60 m_ItemSizeWidget = TextWidget.Cast(GetMainWidget().FindAnyWidget("ItemSize"));
61
62 m_AmmoTypeIcon = ImageWidget.Cast(GetMainWidget().FindAnyWidget("AmmoTypeIcon"));
63 SetActive(false);
64 }
65
66 void ~Icon()
67 {
68 if (m_Obj)
69 {
70 m_Obj.GetOnItemFlipped().Remove(UpdateFlip);
71 m_Obj.GetOnViewIndexChanged().Remove(SetItemPreview);
72 }
73
74 if (m_IsDragged)
75 {
77 ItemManager.GetInstance().HideDropzones();
78 ItemManager.GetInstance().SetIsDragging(false);
79 m_IsDragged = false;
80 }
81 }
82
87
89 {
90 return m_CursorWidget;
91 }
92
97
98 bool IsDragged()
99 {
100 return m_IsDragged;
101 }
102
103 override void SetActive(bool active)
104 {
105 super.SetActive(active);
106 if (active && GetObject())
107 {
108 float x, y;
109 GetMainWidget().GetScreenPos(x, y);
110 PrepareOwnedTooltip(EntityAI.Cast(GetObject()), -1, y);
111 }
112
114 }
115
116 override void SetParentWidget()
117 {
118#ifndef PLATFORM_CONSOLE
119 if (m_Parent.IsInherited(HandsPreview))
120 super.SetParentWidget();
121 else
122 {
123 if (m_Parent != null)
124 {
125 CargoContainer gridContainer = CargoContainer.Cast(m_Parent);
126 if (gridContainer)
127 m_ParentWidget = gridContainer.GetMainWidget();
128 }
129 }
130#else
131 super.SetParentWidget();
132#endif
133 }
134
136 {
137 return 0;
138
139 }
140
142 {
143 InventoryMenu menu = InventoryMenu.Cast(GetGame().GetUIManager().FindMenu(MENU_INVENTORY));
144 HideOwnedTooltip();
145 if (menu)
146 menu.RefreshQuickbar();
147 }
148
149 void DoubleClick(Widget w, int x, int y, int button)
150 {
151 if (button == MouseState.LEFT && !g_Game.IsLeftCtrlDown())
152 {
154 if (controlledPlayer.GetInventory().HasInventoryReservation(m_Obj, null) || controlledPlayer.GetInventory().IsInventoryLocked() || controlledPlayer.IsItemsToDelete())
155 return;
156
157 ItemPreviewWidget targetIpw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
158 if (!targetIpw)
159 {
160 string name = w.GetName();
161 name.Replace("PanelWidget", "Render");
162 targetIpw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
163 }
164
165 if (!targetIpw)
167
168 EntityAI targetEntity = targetIpw.GetItem();
169 if (targetIpw)
170 {
171 if (!targetEntity.GetInventory().CanRemoveEntity())
172 return;
173
174 if (m_HandsIcon)
175 {
176 if (controlledPlayer.GetHumanInventory().CanRemoveEntityInHands())
177 controlledPlayer.PredictiveMoveItemFromHandsToInventory();
178
180
181 return;
182 }
183
184 EntityAI entityInHands = controlledPlayer.GetHumanInventory().GetEntityInHands();
185 EntityAI entityRootParent = targetEntity.GetHierarchyRoot();
186
187 if (controlledPlayer.GetInventory().HasEntityInInventory(targetEntity) && controlledPlayer.GetHumanInventory().CanAddEntityInHands(targetEntity))
188 controlledPlayer.PredictiveTakeEntityToHands(targetEntity);
190 {
192 int index = controlledPlayer.GetHumanInventory().FindUserReservedLocationIndex(entityInHands);
193 if (index >= 0)
194 controlledPlayer.GetHumanInventory().GetUserReservedLocation(index, inventoryLocation);
195
196 if (controlledPlayer.GetInventory().CanForceSwapEntitiesEx(targetEntity, null, entityInHands, inventoryLocation))
197 controlledPlayer.PredictiveForceSwapEntities(targetEntity, entityInHands, inventoryLocation);
198 else if (controlledPlayer.GetInventory().CanSwapEntitiesEx(targetEntity, entityInHands))
199 controlledPlayer.PredictiveSwapEntities(targetEntity, entityInHands);
200 else
201 {
202 controlledPlayer.GetInventory().FindFreeLocationFor(targetEntity, FindInventoryLocationType.ANY, inventoryLocation);
203 if (inventoryLocation.IsValid() && controlledPlayer.GetInventory().LocationCanAddEntity(inventoryLocation))
205 }
206 }
207 else
208 {
209 bool found = false;
210 if (targetEntity.GetInventory().CanRemoveEntity())
211 {
213 found = controlledPlayer.GetInventory().FindFreeLocationFor(targetEntity, FindInventoryLocationType.ANY, i2);
214 if (found)
215 {
216 if (i2.GetType() == FindInventoryLocationType.ATTACHMENT)
217 {
218 if (i2.GetParent() != controlledPlayer)
219 found = false;
220 }
221 }
222 }
223
224 if (found)
225 {
226 if (controlledPlayer.GetHumanInventory().CanAddEntityToInventory(targetEntity))
227 controlledPlayer.PredictiveTakeEntityToInventory(FindInventoryLocationType.ANY, targetEntity);
228 }
229 else
230 {
231 if (controlledPlayer.GetHumanInventory().CanAddEntityInHands(targetEntity))
232 controlledPlayer.PredictiveTakeEntityToHands(targetEntity);
233 }
234 }
235
237 }
238 }
239 }
240
242 {
243 if (w == null)
244 return;
245
246 string name = w.GetName();
247 name.Replace("PanelWidget", "Render");
248
249 ItemPreviewWidget targetIpw = ItemPreviewWidget.Cast(receiver.FindAnyWidget("Render"));
250 if (m_HandsIcon)
251 targetIpw = ItemPreviewWidget.Cast(receiver.GetParent().FindAnyWidget("Render"));
252
254 if (selectedIpw == null)
255 selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
256
257 if (selectedIpw == null)
258 return;
259
263 return;
264
267 int index = player.GetHumanInventory().FindUserReservedLocationIndex(m_Item);
268
269 if (index >= 0)
270 {
271 player.GetHumanInventory().GetUserReservedLocation(index, il);
272
274 {
276 ItemManager.GetInstance().HideDropzones();
277 ItemManager.GetInstance().ShowSourceDropzone(il.GetParent());
278 return;
279 }
280 }
282
285 }
286
288 {
289 if (w == null)
290 return;
291
292 ItemPreviewWidget selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
293 if (!selectedIpw)
294 {
295 string name = w.GetName();
296 name.Replace("PanelWidget", "Render");
297 selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
298 }
299
300 if (!selectedIpw)
302
303 if (!selectedIpw.GetItem())
304 return;
306 EntityAI targetEntity = GetGame().GetPlayer().GetHumanInventory().GetEntityInHands();
307
309
312 }
313
314 bool MouseEnter(Widget w, int x, int y)
315 {
316 if (!m_IsDragged)
317 {
318 PrepareOwnedTooltip(m_Obj, x, y);
319 m_CursorWidget.Show(true);
320 }
321
322 return true;
323 }
324
325 bool MouseLeave(Widget w, Widget s, int x, int y)
326 {
327 HideOwnedTooltip();
328 if (!m_IsDragged)
329 m_CursorWidget.Show(false);
330 return true;
331 }
332
334 {
335 ItemManager.GetInstance().HideDropzones();
336
337 if (w == null)
338 return;
339 string name = w.GetName();
340 name.Replace("PanelWidget", "Render");
341
342 ItemPreviewWidget targetIpw = ItemPreviewWidget.Cast(receiver.FindAnyWidget("Render"));
343 if (m_HandsIcon)
344 targetIpw = ItemPreviewWidget.Cast(receiver.GetParent().FindAnyWidget("Render"));
345
347 if (selectedIpw == null)
348 selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
349 if (selectedIpw == null)
350 return;
351
357 return;
358
359 if (m_Lock)
360 {
362 {
364 ItemManager.GetInstance().GetRightDropzone().SetAlpha(1);
365 }
366 else
367 {
368 CargoContainer parentContainer = CargoContainer.Cast(m_Parent);
369
370 float parentX;
371 float parentY;
372
373 parentContainer.GetRootWidget().GetScreenPos(parentX, parentY);
374
375 float iconSize = parentContainer.GetIconSize();
376 float spaceSize = parentContainer.GetSpaceSize();
377
378 int PosX = (x - parentX) / (iconSize + spaceSize);
379 int PosY = (y - parentY) / (iconSize + spaceSize);
380
381 EntityAI parent = m_Lock;
382 CargoBase targetCargo = parent.GetInventory().GetCargo();
383
384 ilDst = new InventoryLocation();
385 ilDst.SetCargoAuto(targetCargo, selectedEntity, PosY, PosX, selectedEntity.GetInventory().GetFlipCargo());
386
387 if (parent.GetInventory().LocationCanAddEntity(ilDst))
388 {
390 ItemManager.GetInstance().GetRightDropzone().SetAlpha(1);
391 }
392 else
393 {
395 ItemManager.GetInstance().ShowSourceDropzone(selectedEntity);
396 }
397 }
398 }
399 else
400 {
402
405 }
406 }
407
409 {
411 if (m_am_entity1 == null || m_am_entity2 == null) return;
412
414
417
419 {
421 Class.CastTo(amc, player.GetActionManager());
422
423 if (m_am_entity1 == player.GetHumanInventory().GetEntityInHands())
424 amc.PerformActionFromInventory(ItemBase.Cast(m_am_entity1), ItemBase.Cast(m_am_entity2));
425 else
426 amc.PerformActionFromInventory(ItemBase.Cast(m_am_entity2), ItemBase.Cast(m_am_entity1));
427 }
429 {
431 Class.CastTo(amc2, player.GetActionManager());
432
433 if (m_am_entity1 == player.GetHumanInventory().GetEntityInHands())
434 amc2.SetActionFromInventory(ItemBase.Cast(m_am_entity1), ItemBase.Cast(m_am_entity2));
435 else
436 amc2.SetActionFromInventory(ItemBase.Cast(m_am_entity2), ItemBase.Cast(m_am_entity1));
437 }
439 {
440 ItemBase entity = ItemBase.Cast(m_am_entity1);
441 entity.CombineItemsClient(ItemBase.Cast(m_am_entity2));
442 }
444 {
445 float stackable = m_am_entity2.GetTargetQuantityMax(-1);
446
447 if (stackable == 0 || stackable >= m_am_entity2.GetQuantity())
448 player.PredictiveTakeEntityToTargetAttachment(m_am_entity1, m_am_entity2);
449 else
450 {
452 m_am_entity1.GetInventory().FindFreeLocationFor(m_am_entity2, FindInventoryLocationType.ATTACHMENT, il);
453 ItemBase.Cast(m_am_entity2).SplitIntoStackMaxToInventoryLocationClient(il);
454 }
455 }
457 SplitItemUtils.TakeOrSplitToInventory(player, m_am_entity1, m_am_entity2);
458 }
459
461 {
464
465 switch (combinationFlag)
466 {
468 float stackable = targetEntity.GetTargetQuantityMax(-1);
469
470 if (stackable == 0 || stackable >= targetEntity.GetQuantity())
471 return player.PredictiveTakeEntityToTargetAttachment(targetEntity, selectedEntity);
472 else
473 {
475 targetEntity.GetInventory().FindFreeLocationFor(selectedEntity, FindInventoryLocationType.ATTACHMENT, il);
476 ItemBase.Cast(selectedEntity).SplitIntoStackMaxToInventoryLocationClient(il);
477 return true;
478 }
479 break;
482 return true;
484 targetEntity.CombineItemsClient(selectedEntity);
485 return true;
487 Class.CastTo(amc, player.GetActionManager());
488 if (targetEntity == player.GetHumanInventory().GetEntityInHands())
489 amc.SetActionFromInventory(ItemBase.Cast(targetEntity), ItemBase.Cast(selectedEntity));
490 else
491 amc.SetActionFromInventory(ItemBase.Cast(selectedEntity), ItemBase.Cast(targetEntity));
492 return true;
494 Class.CastTo(amc, player.GetActionManager());
495 if (targetEntity == player.GetHumanInventory().GetEntityInHands())
496 amc.PerformActionFromInventory(ItemBase.Cast(targetEntity), ItemBase.Cast(selectedEntity));
497 else
498 amc.PerformActionFromInventory(ItemBase.Cast(selectedEntity), ItemBase.Cast(targetEntity));
499 return true;
501 return player.GetWeaponManager().SwapMagazine(Magazine.Cast(selectedEntity));
503 return player.PredictiveSwapEntities(targetEntity, selectedEntity);
505 return player.PredictiveForceSwapEntities(selectedEntity, targetEntity, ilSwapDst);
506 default:
507 return false;
508 }
509
510 return false;
511 }
512
514 {
515 int color;
517
518 ItemManager.GetInstance().HideDropzones();
519 switch (combinationFlag)
520 {
524 ItemManager.GetInstance().ShowSourceDropzone(targetEntity);
525 break;
530 ItemManager.GetInstance().ShowSourceDropzone(targetEntity);
531 break;
534 ItemManager.GetInstance().ShowSourceDropzone(selectedEntity);
535 break;
538 ItemManager.GetInstance().ShowSourceDropzone(selectedEntity);
539 break;
542 if (il)
543 ItemManager.GetInstance().ShowSourceDropzone(il.GetParent());
544 else
545 ItemManager.GetInstance().ShowSourceDropzone(selectedEntity);
546 break;
547 default:
549 ItemManager.GetInstance().ShowSourceDropzone(selectedEntity);
550 }
551
552 ColorManager.GetInstance().SetColor(w, color);
553 }
554
555
557 {
558 int lastFlag = 0;
559 ContextMenu cmenu = ContextMenu.Cast(GetGame().GetUIManager().GetMenu().GetContextMenu());
560 m_am_entity1 = entity1;
561 m_am_entity2 = entity2;
562 cmenu.Hide();
563 cmenu.Clear();
564 int id = -1;
565
566 if (entity1 == null || entity2 == null) return;
567
569 {
570 if (color_test)
571 {
573 ItemManager.GetInstance().ShowSourceDropzone(entity2);
574 }
575 return;
576 }
577
579 {
581 cmenu.Add("#inv_context_add_as_cargo", this, "OnPerformCombination", new Param1<int>(lastFlag));
582 }
584 {
586 cmenu.Add("#inv_context_add_as_attachment", this, "OnPerformCombination", new Param1<int>(lastFlag));
587 }
588
590 {
592 cmenu.Add("#inv_context_combine_quantity", this, "OnPerformCombination", new Param1<int>(lastFlag));
593 }
594
596 {
598 cmenu.Add("#inv_context_attach_magazine", this, "OnPerformCombination", new Param1<int>(lastFlag));
599 }
600
602 {
604 cmenu.Add("Perform action", this, "OnPerformCombination", new Param1<int>(lastFlag));
605 }
606
607 if (color_test)
608 {
609 if (lastFlag == 0)
610 {
611 ItemManager.GetInstance().HideDropzones();
612 ItemManager.GetInstance().GetCenterDropzone().SetAlpha(1);
614 }
616 {
617 ItemManager.GetInstance().HideDropzones();
618 ItemManager.GetInstance().GetCenterDropzone().SetAlpha(1);
620 }
621 else
622 {
623 ItemManager.GetInstance().HideDropzones();
624 ItemManager.GetInstance().GetCenterDropzone().SetAlpha(1);
626 }
627 }
628 else if (cmenu.Count() >= 1)
629 {
631 return;
632 }
633 }
634
635 void OnPerformRecipe(int id)
636 {
637 if (m_am_entity1 == null || m_am_entity2 == null) return;
638
639 Debug.Log("OnPerformRecipe called for id:" + id.ToString(), "recipes");
641 player.GetCraftingManager().SetInventoryCraft(id, ItemBase.Cast(m_am_entity1), ItemBase.Cast(m_am_entity2));
642 }
643
644 void Combine(Widget w, int x, int y, Widget receiver)
645 {
646 ItemManager.GetInstance().HideDropzones();
647 ItemManager.GetInstance().SetIsDragging(false);
648 ItemPreviewWidget selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
649 if (!selectedIpw)
650 {
651 string name = w.GetName();
652 name.Replace("PanelWidget", "Render");
653 selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
654 }
655 if (!selectedIpw)
657 if (!selectedIpw.GetItem())
658 return;
660 EntityAI targetEntity = GetGame().GetPlayer().GetHumanInventory().GetEntityInHands();
662
665 }
666
672
674 {
675 int current_flag;
676 ContextMenu cmenu = ContextMenu.Cast(GetGame().GetUIManager().GetMenu().GetContextMenu());
677 m_am_entity1 = entity1;
678 m_am_entity2 = entity2;
679 cmenu.Hide();
680 cmenu.Clear();
681 int id = -1;
682
684 {
686 entity.CombineItemsClient(ItemBase.Cast(entity2));
687 return false;
688 }
689
691 return true;
692
694 {
696 cmenu.Add("#inv_context_add_as_attachment", this, "OnPerformCombination", new Param1<int>(current_flag));
697 }
698 /*if (combinationFlags & InventoryCombinationFlags.LOAD_CHAMBER )
699 {
700 current_flag = InventoryCombinationFlags.LOAD_CHAMBER;
701 cmenu.Add( "#inv_context_load_chamber", this, "OnPerformCombination", new Param1<int>( current_flag ) );
702 }*/
704 {
706 cmenu.Add("#inv_context_attach_magazine", this, "OnPerformCombination", new Param1<int>(current_flag));
707 }
708
710 {
712 cmenu.Add("#inv_context_add_as_cargo", this, "OnPerformCombination", new Param1<int>(current_flag));
713 }
714
716 {
718 cmenu.Add("#inv_context_swap", this, "OnPerformCombination", new Param1<int>(current_flag));
719 }
720
722 {
724 cmenu.Add("#inv_context_combine", this, "OnPerformCombination", new Param1<int>(current_flag));
725 }
726
728 {
730 cmenu.Add("#inv_context_attach_magazine", this, "OnPerformCombination", new Param1<int>(current_flag));
731 }
732
734 {
736 cmenu.Add("Perform Action2", this, "OnPerformCombination", new Param1<int>(current_flag));
737 }
738
741 m_am_Pos_x -= 5;
742 m_am_Pos_y -= 5;
743
744 MissionGameplay mission = MissionGameplay.Cast(GetGame().GetMission());
745 /*if (combinationFlags & InventoryCombinationFlags.RECIPE_HANDS || combinationFlags & InventoryCombinationFlags.RECIPE_ANYWHERE )
746 {
747 OnPerformRecipe( id );
748 return true;
749 }
750 else /*if (cmenu.Count() == 1 )*/
751 //{
753 return true;
754 //}
755 /*else
756 {
757 cmenu.Show( m_am_Pos_x, m_am_Pos_y );
758 return true;
759 }*/
760 }
761
762 void MouseClick(Widget w, int x, int y, int button)
763 {
764 if (button == MouseState.RIGHT)
765 {
766 if (m_Lock)
767 GetGame().GetPlayer().GetHumanInventory().ClearUserReservedLocationSynced(m_Item);
768 else
769 {
770 if (m_Item && m_Item.IsItemBase())
771 {
772 m_Item.OnRightClick();
773
774 if (m_HasQuantity)
775 SetQuantity();
776#ifdef DIAG_DEVELOPER
777 if (GetDayZGame().IsLeftCtrlDown())
778 ShowActionMenu(m_Item);
779#endif
780 }
781 }
782
783 }
784 else if (!m_Lock)
785 {
786 switch (button)
787 {
788 case MouseState.MIDDLE:
790 break;
791
792 case MouseState.LEFT:
794 if (g_Game.IsLeftCtrlDown())
795 {
796 if (controlledPlayer.CanDropEntity(m_Item))
797 {
798 if (m_Item.GetTargetQuantityMax() < m_Item.GetQuantity())
799 m_Item.SplitIntoStackMaxClient(null, -1);
800 else
801 controlledPlayer.PhysicalPredictiveDropItem(m_Item);
802
803 ItemManager.GetInstance().SetWidgetDraggable(w, false);
804 }
805 }
806 else
807 {
809 m_Obj.GetInventory().GetCurrentInventoryLocation(il);
810
811 bool draggable = !controlledPlayer.GetInventory().HasInventoryReservation(m_Obj, null) && !controlledPlayer.GetInventory().IsInventoryLocked() && !controlledPlayer.IsItemsToDelete();
812 draggable = draggable && (m_Obj.GetHierarchyRoot() && m_Obj.GetInventory().CanRemoveEntity() || !m_Obj.GetHierarchyRoot() && AttachmentsOutOfReach.IsAttachmentReachable(m_Obj, "", il.GetSlot()));
813
814 ItemManager.GetInstance().SetWidgetDraggable(w, draggable);
815 }
816 break;
817 }
818 }
819 }
820
822 {
823 ItemManager.GetInstance().HideDropzones();
824 ItemManager.GetInstance().SetIsDragging(false);
825 string name = w.GetName();
826 name.Replace("PanelWidget", "Render");
828
829 ItemPreviewWidget targetIpw = ItemPreviewWidget.Cast(receiver.FindAnyWidget("Render"));
830 if (m_HandsIcon)
831 targetIpw = ItemPreviewWidget.Cast(receiver.GetParent().FindAnyWidget("Render"));
832
834 if (selectedIpw == null)
835 selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
836 if (selectedIpw == null)
837 return;
838
841 if (!selectedEntity)
842 return;
843 int index;
847 {
848 index = player.GetHumanInventory().FindUserReservedLocationIndex(m_Item);
849 ilSrc = new InventoryLocation();
850 ilDst = new InventoryLocation();
851
852 m_Item.GetInventory().GetCurrentInventoryLocation(ilSrc);
853 player.GetHumanInventory().GetUserReservedLocation(index, ilDst);
854
855 if (ilDst.GetParent().GetInventory().LocationCanAddEntity(ilDst))
856 {
857
858 player.GetHumanInventory().ClearUserReservedLocation(m_Item);
859 player.PredictiveTakeToDst(ilSrc, ilDst);
860 m_Item.GetOnReleaseLock().Invoke(m_Item);
861 }
862 }
863 else if (m_Lock)
864 {
865 CargoContainer parentCargo = CargoContainer.Cast(m_Parent);
866
867 float parentX;
868 float parentY;
869
870 parentCargo.GetRootWidget().GetScreenPos(parentX, parentY);
871
872 float iconSize = parentCargo.GetIconSize();
873 float spaceSize = parentCargo.GetSpaceSize();
874
875 int PosX = (x - parentX) / (iconSize + spaceSize);
876 int PosY = (y - parentY) / (iconSize + spaceSize);
877
878 EntityAI parent = m_Lock;
879 CargoBase targetCargo = parent.GetInventory().GetCargo();
880
881 ilDst = new InventoryLocation();
882 ilDst.SetCargoAuto(targetCargo, selectedEntity, PosY, PosX, selectedEntity.GetInventory().GetFlipCargo());
883
884 if (parent.GetInventory().LocationCanAddEntity(ilDst))
885 {
886 player.GetHumanInventory().ClearUserReservedLocation(m_Item);
887 m_Item.GetOnReleaseLock().Invoke(m_Item);
888
890 }
891 }
892 else
893 {
894 ilDst = new InventoryLocation();
896
899 }
900 }
901
902 void Swap(Widget w, int x, int y, Widget receiver)
903 {
904 ItemManager.GetInstance().HideDropzones();
905 ItemManager.GetInstance().SetIsDragging(false);
906 string name = w.GetName();
907 name.Replace("PanelWidget", "Render");
908
909 ItemPreviewWidget targetIpw = ItemPreviewWidget.Cast(receiver.FindAnyWidget("Render"));
910 if (m_HandsIcon)
911 targetIpw = ItemPreviewWidget.Cast(receiver.GetParent().FindAnyWidget("Render"));
912
914 if (selectedIpw == null)
915 selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
916 if (selectedIpw == null)
917 return;
918
922 return;
923
925 EntityAI itemInHands = player.GetHumanInventory().GetEntityInHands();
926
929 targetEntity.GetInventory().GetCurrentInventoryLocation(ilSrc);
930 Icon icon = ItemManager.GetInstance().GetDraggedIcon();
931
932 int index = player.GetHumanInventory().FindUserReservedLocationIndex(targetEntity);
933 if (index >= 0)
934 {
935 player.GetHumanInventory().GetUserReservedLocation(index, ilDst);
936
938 {
939 if (m_HandsIcon && !player.GetInventory().HasInventoryReservation(itemInHands, null) && !player.IsItemsToDelete())
940 {
941 GetGame().GetPlayer().PredictiveForceSwapEntities(selectedEntity, targetEntity, ilDst);
942 return;
943 }
944 }
945 }
947
950 }
951
953 {
954 (IconsContainer.Cast(m_Parent)).RemoveItem(icon);
955 (IconsContainer.Cast(m_Parent)).RemoveItem(icon2);
956 }
957
958 override void SetLayoutName()
959 {
960#ifdef PLATFORM_CONSOLE
961 m_LayoutName = WidgetLayoutName.IconXbox;
962#else
963 switch (InventoryMenu.GetWidthType())
964 {
965 case ScreenWidthType.NARROW:
966 {
967 m_LayoutName = WidgetLayoutName.IconNarrow;
968 break;
969 }
970 case ScreenWidthType.MEDIUM:
971 {
972 m_LayoutName = WidgetLayoutName.IconMedium;
973 break;
974 }
975 case ScreenWidthType.WIDE:
976 {
977 m_LayoutName = WidgetLayoutName.IconWide;
978 break;
979 }
980 }
981#endif
982
983 }
984
985 void SetSize(int x, int y)
986 {
987 m_SizeX = x;
988 m_SizeY = y;
989 }
990
991 void SetPos(int x, int y)
992 {
993 m_PosX = x;
994 m_PosY = y;
995 }
996
998 {
999 return m_CargoPos;
1000 }
1001
1002 void SetCargoPos(int x)
1003 {
1004 GetMainWidget().SetSort(x);
1005 m_CargoPos = x;
1006 }
1007
1009 {
1010 ItemManager.GetInstance().HideDropzones();
1011 ItemManager.GetInstance().SetIsDragging(false);
1012 m_IsDragged = false;
1013
1015
1016 if (m_HandsIcon)
1017 {
1020 Refresh();
1021 FullScreen();
1022 }
1023
1024 m_CursorWidget.SetColor(ARGBF(1, 1, 1, 1));
1025 m_CursorWidget.Show(false);
1026
1027 InventoryMenu menu = InventoryMenu.Cast(GetGame().GetUIManager().FindMenu(MENU_INVENTORY));
1028
1029 if (menu)
1030 menu.RefreshQuickbar();
1031 }
1032
1034 {
1035 m_PreviousFlipOrientation = m_Item.GetInventory().GetFlipCargo();
1036 ItemManager.GetInstance().SetDraggedIcon(this);
1037 ItemManager.GetInstance().SetDraggedItem(m_Item);
1038 m_IsDragged = true;
1039 ItemManager.GetInstance().SetIsDragging(true);
1040 int ww, hh;
1041 GetGame().GetInventoryItemSize(m_Item, ww, hh);
1042 if (m_Item.GetInventory().GetFlipCargo())
1043 SetSize(hh, ww);
1044 else
1045 SetSize(ww, hh);
1046
1047 SetSize();
1048
1049 if (!m_HandsIcon)
1050 Refresh();
1051 else
1052 {
1055 m_ColorWidget.SetAlpha(0.1);
1056 }
1057
1058 m_CursorWidget.Show(true);
1059 }
1060
1062 {
1063 ItemManager.GetInstance().HideDropzones();
1064 EntityAI entity = EntityAI.Cast(m_Obj);
1065 EntityAI parent = entity.GetHierarchyParent();
1066 if (parent && parent.GetHierarchyRootPlayer() == GetGame().GetPlayer())
1067 ItemManager.GetInstance().GetRightDropzone().SetAlpha(1);
1068 else if (!m_HandsIcon)
1069 ItemManager.GetInstance().GetLeftDropzone().SetAlpha(1);
1070
1071 if (w == null || reciever == null)
1072 return;
1073 Pos pa;
1074 reciever.GetUserData(pa);
1075 if (m_Parent)
1076 {
1077 ContainerWithCargo item = ContainerWithCargo.Cast(m_Parent.m_Parent);
1078 if (item)
1079 item.DraggingOverGrid(w, m_PosY + pa.y, m_PosX + pa.x, reciever);
1081 if (hands_item)
1082 hands_item.DraggingOverGrid(w, m_PosY + pa.y, m_PosX + pa.x, reciever, null);
1083 }
1084 }
1085
1087 {
1088 Pos pa;
1089 if (reciever)
1090 {
1091 reciever.GetUserData(pa);
1092 if (m_Parent)
1093 {
1094 ContainerWithCargo item = ContainerWithCargo.Cast(m_Parent.m_Parent);
1095 if (item)
1096 item.DropReceived(w, m_PosY + pa.y, m_PosX + pa.x);
1097 }
1098 }
1099 }
1100
1102 {
1103 if (m_Item)
1104 {
1105 m_Item.GetInventory().SetFlipCargo(m_PreviousFlipOrientation);
1106 int ww, hh;
1107 GetGame().GetInventoryItemSize(m_Item, ww, hh);
1108
1110 SetSize(hh, ww);
1111 else
1112 SetSize(ww, hh);
1113
1114 SetSize();
1115 }
1116 }
1117
1118 override void Refresh()
1119 {
1120 super.Refresh();
1121
1122 if (!m_HandsIcon)
1123 SetPos();
1124
1125 if (m_HasTemperature)
1127
1128 if (m_IsWeapon)
1130
1131 if (m_HasQuantity)
1132 SetQuantity();
1133 }
1134
1136 {
1137 ItemManager.GetInstance().SetIconTemperature(EntityAI.Cast(m_Obj), m_RootWidget);
1138 }
1139
1141 {
1142 Refresh();
1143 GetMainWidget().Update();
1144 }
1145
1147 {
1148 if (m_IsDragged)
1149 return;
1150 GetRootWidget().ClearFlags(WidgetFlags.HEXACTSIZE + WidgetFlags.VEXACTSIZE);
1151 GetRootWidget().SetSize(1, 1);
1152 m_ColorWidget.SetColor(ARGB(0, 0, 0, 0));
1153 }
1154
1155 void RefreshPos(int row, int column)
1156 {
1157 if (row != m_PosY || column != m_PosX)
1158 {
1159 m_PosX = column;
1160 m_PosY = row;
1161 SetPos();
1163 }
1164 }
1165
1167 {
1168 return m_Obj;
1169 }
1170
1172 {
1174 if (wpn)
1175 {
1176 int i;
1178 if (!wpn.IsShowingChamberedBullet())
1179 {
1180 for (i = 0; i < m_AmmoIcons.Count(); i++)
1181 {
1182 ammoIcon = m_AmmoIcons.Get(i);
1183 ammoIcon.Show(false);
1184 }
1185 /* int bullet_count = 0;
1186 int fireout_count = 0;
1187
1188 for ( i = 0; i < wpn.GetMuzzleCount(); i++ )
1189 {
1190 if (wpn.IsChamberFull(i))
1191 {
1192 if (wpn.IsChamberFiredOut(i))
1193 {
1194 fireout_count++;
1195 }
1196 else
1197 {
1198 bullet_count++;
1199 }
1200 }
1201 }
1202
1203 int j;
1204 i = 0;
1205 for ( j= 0; j < bullet_count; j++ )
1206 {
1207 if ( i > m_AmmoIcons.Count() )
1208 {
1209 //add plus ammo
1210 break;
1211 }
1212
1213 ammoIcon = m_AmmoIcons.Get(i);
1214 ammoIcon.Show( true );
1215 ammoIcon.SetImage( 0 );
1216 i++;
1217 }
1218
1219 for ( j= 0; j < fireout_count; j++ )
1220 {
1221 if ( i > m_AmmoIcons.Count() )
1222 {
1223 //add plus ammo
1224 break;
1225 }
1226
1227 ammoIcon = m_AmmoIcons.Get(i);
1228 ammoIcon.Show( true );
1229 ammoIcon.SetImage( 1 );
1230 i++;
1231 }
1232
1233 for (j = i; j < m_AmmoIcons.Count(); j++)
1234 {
1235 ammoIcon = m_AmmoIcons.Get(j);
1236 ammoIcon.Show(false);
1237 }*/
1238 }
1239 else
1240 {
1241 //TODO MW - add more conplex logic
1242 for (i = 0; i < wpn.GetMuzzleCount(); i++)
1243 {
1244 if (i > m_AmmoIcons.Count())
1245 {
1246 //add plus ammo
1247 break;
1248 }
1249
1250 ammoIcon = m_AmmoIcons.Get(i);
1251
1252 if (wpn.IsChamberFull(i))
1253 {
1254 if (wpn.IsJammed())
1255 {
1256 ammoIcon.Show(true);
1257 ammoIcon.SetImage(2);
1258 }
1259 else if (wpn.IsChamberFiredOut(i))
1260 {
1261 ammoIcon.Show(true);
1262 ammoIcon.SetImage(1);
1263 }
1264 else
1265 {
1266 ammoIcon.Show(true);
1267 ammoIcon.SetImage(0);
1268 }
1269 }
1270 else
1271 ammoIcon.Show(false);
1272 }
1273 }
1274 }
1275 }
1276
1278 {
1279 if (m_Item)
1280 {
1283 {
1285
1287 {
1289
1291 m_QuantityStack.Show(false);
1292 else
1293 {
1295 m_QuantityStack.Show(true);
1296 }
1297
1298 m_QuantityProgress.Show(false);
1299 }
1300 else if (quantityType == QUANTITY_PROGRESS)
1301 {
1302 int max = m_Item.GetQuantityMax();
1303 int count = m_Item.ConfigGetInt("count");
1304 float quantity = m_CurrQuantity;
1305
1306 if (count > 0)
1307 max = count;
1308
1309 if (max > 0)
1310 {
1311 float value = Math.Round((quantity / max) * 100);
1312 m_QuantityProgress.SetCurrent(value);
1313 }
1314
1315 m_QuantityStack.Show(false);
1316 m_QuantityProgress.Show(true);
1317 }
1318 }
1319 }
1320 }
1321
1322 void SetSort(int index)
1323 {
1324 GetMainWidget().SetSort(index);
1325 GetMainWidget().Update();
1326 }
1327
1329 {
1330 return GetMainWidget().GetSort();
1331 }
1332
1333 void SetItemPreviewEx(bool refresh = true)
1334 {
1335 m_ItemPreview.Show(true, refresh);
1338 m_ItemPreview.SetView(m_Obj.GetViewIndex());
1339 }
1340
1342 {
1344 }
1345
1346 void SetItemSizeEx(bool refresh = true)
1347 {
1348#ifdef PLATFORM_CONSOLE
1349 m_ItemSizePanel.Show(true, refresh);
1350 m_ItemSizeWidget.Show(true, refresh);
1351
1352 int sizeX, sizeY;
1353 GetGame().GetInventoryItemSize(m_Item, sizeX, sizeY);
1354 int capacity = sizeX * sizeY;
1355 m_ItemSizeWidget.SetText(capacity.ToString());
1356#endif
1357 }
1358
1360 {
1361 SetItemSizeEx();
1362 }
1363
1365 {
1366 int sizeX, sizeY;
1367 GetGame().GetInventoryItemSize(m_Item, sizeX, sizeY);
1368
1369 if (flipped)
1371 else
1373
1374 SetSize();
1375 }
1376
1377 void InitLock(EntityAI parent, EntityAI obj, int x_pos, int y_pos, bool flip)
1378 {
1379 m_Lock = parent;
1380 m_Obj = obj;
1381 m_Item = ItemBase.Cast(m_Obj);
1382
1383 SetPos(x_pos, y_pos);
1385
1386 ItemManager.GetInstance().SetWidgetDraggable(GetMainWidget(), false);
1387 WidgetEventHandler.GetInstance().RegisterOnMouseButtonDown(GetMainWidget(), this, "MouseClick");
1388 WidgetEventHandler.GetInstance().RegisterOnDropReceived(GetMainWidget(), this, "DropReceivedFromMain");
1389 WidgetEventHandler.GetInstance().RegisterOnDraggingOver(GetMainWidget(), this, "DraggingOver");
1390
1391 m_RootWidget.FindAnyWidget("Reserved").Show(true);
1395 Refresh();
1396 }
1397
1398 void InitEx(EntityAI obj, bool refresh = true)
1399 {
1400 if (obj != m_Obj)
1401 {
1402 if (m_Obj)
1403 {
1404 m_Obj.GetOnItemFlipped().Remove(UpdateFlip);
1405 m_Obj.GetOnViewIndexChanged().Remove(SetItemPreview);
1406 }
1407 if (obj)
1408 {
1409 obj.GetOnItemFlipped().Insert(UpdateFlip);
1410 obj.GetOnViewIndexChanged().Insert(SetItemPreview);
1411 }
1412 }
1413
1414 if (m_HandsIcon)
1415 {
1418 }
1419
1420 m_Obj = obj;
1421 m_Item = ItemBase.Cast(m_Obj);
1422 m_Lock = null;
1423
1425
1426 WidgetEventHandler.GetInstance().RegisterOnDrag(GetMainWidget(), this, "CreateWhiteBackground");
1427 WidgetEventHandler.GetInstance().RegisterOnDrop(GetMainWidget(), this, "DestroyWhiteBackground");
1428 WidgetEventHandler.GetInstance().RegisterOnDropReceived(GetMainWidget(), this, "DropReceivedFromMain");
1429 WidgetEventHandler.GetInstance().RegisterOnMouseButtonDown(GetMainWidget(), this, "MouseClick");
1430 WidgetEventHandler.GetInstance().RegisterOnDropReceived(GetMainWidget().FindAnyWidget("Swap"), this, "Swap");
1431 WidgetEventHandler.GetInstance().RegisterOnDraggingOver(GetMainWidget().FindAnyWidget("Swap"), this, "DraggingOverSwap");
1432 WidgetEventHandler.GetInstance().RegisterOnDropReceived(GetMainWidget().FindAnyWidget("Combine"), this, "Combine");
1433 WidgetEventHandler.GetInstance().RegisterOnDraggingOver(GetMainWidget().FindAnyWidget("Combine"), this, "DraggingOverCombine");
1434 WidgetEventHandler.GetInstance().RegisterOnDraggingOver(GetMainWidget(), this, "DraggingOver");
1435 WidgetEventHandler.GetInstance().RegisterOnMouseEnter(GetMainWidget(), this, "MouseEnter");
1436 WidgetEventHandler.GetInstance().RegisterOnMouseLeave(GetMainWidget(), this, "MouseLeave");
1437 WidgetEventHandler.GetInstance().RegisterOnDoubleClick(GetMainWidget(), this, "DoubleClick");
1438
1440 CheckIsWeapon();
1444 m_RootWidget.FindAnyWidget("Reserved").Show(false, refresh);
1445
1446 if (refresh)
1447 Refresh();
1448 }
1449
1450 void Init(EntityAI obj)
1451 {
1452 InitEx(obj);
1453 }
1454
1456 {
1458 if (wpn)
1459 {
1461 m_IsWeapon = true;
1462 float posX = 0.0;
1463 float widht = 0.0, height = 0.0;
1464 for (int i = 0; i < wpn.GetMuzzleCount(); i++)
1465 {
1466 if (i == 1)
1467 m_AmmoIcons[0].GetSize(widht, height);
1468 posX += widht;
1469
1470 Widget ammoIcon = Widget.Cast(GetGame().GetWorkspace().CreateWidgets("gui/layouts/inventory_new/ammo_icon.layout", GetMainWidget()));
1471 ammoIcon.SetPos(posX, 0.0, false);
1472
1473 ImageWidget ammoIconImg = ImageWidget.Cast(ammoIcon.GetChildren());
1474
1475 AmmoData data = Magazine.GetAmmoData(wpn.GetChamberAmmoTypeName(i));
1476 if (data)
1477 {
1478 CartridgeType c_type = data.m_CartridgeType;
1479 switch (c_type)
1480 {
1481 case CartridgeType.Pistol:
1482 {
1483 ammoIconImg.LoadImageFile(0, "set:dayz_gui image:cartridge_pistol");
1484 ammoIconImg.LoadImageFile(1, "set:dayz_gui image:shell_pistol");
1485 ammoIconImg.LoadImageFile(2, "set:dayz_gui image:jam_pistol");
1486 break;
1487 }
1488 case CartridgeType.Intermediate:
1489 {
1490 ammoIconImg.LoadImageFile(0, "set:dayz_gui image:cartridge_int");
1491 ammoIconImg.LoadImageFile(1, "set:dayz_gui image:shell_int");
1492 ammoIconImg.LoadImageFile(2, "set:dayz_gui image:jam_int");
1493 break;
1494 }
1495 case CartridgeType.FullPower:
1496 {
1497 ammoIconImg.LoadImageFile(0, "set:dayz_gui image:cartridge_fp");
1498 ammoIconImg.LoadImageFile(1, "set:dayz_gui image:shell_fp");
1499 ammoIconImg.LoadImageFile(2, "set:dayz_gui image:jam_fp");
1500 break;
1501 }
1502 case CartridgeType.Shell:
1503 {
1504 ammoIconImg.LoadImageFile(0, "set:dayz_gui image:cartridge_shell");
1505 ammoIconImg.LoadImageFile(1, "set:dayz_gui image:shell_shell");
1506 ammoIconImg.LoadImageFile(2, "set:dayz_gui image:jam_shell");
1507 break;
1508 }
1509 }
1510 }
1511 m_AmmoIcons.Insert(ammoIconImg);
1512 }
1513 }
1514 else
1515 m_IsWeapon = false;
1516 }
1517
1518 void CheckIsMagazineEx(bool refresh = true)
1519 {
1520 Magazine mag = Magazine.Cast(m_Obj);
1521 if (mag)
1522 {
1523 m_IsMagazine = true;
1524 AmmoData data = Magazine.GetAmmoData(mag.ClassName());
1525 if (data)
1526 {
1527 ProjectileType p_type = data.m_ProjectileType;
1528 switch (p_type)
1529 {
1530 case ProjectileType.None:
1531 {
1532 m_AmmoTypeIcon.Show(false, refresh);
1533 break;
1534 }
1535 case ProjectileType.Tracer:
1536 {
1537 m_AmmoTypeIcon.LoadImageFile(0, "set:dayz_gui image:tracer");
1538 m_AmmoTypeIcon.Show(true, refresh);
1539 break;
1540 }
1541 case ProjectileType.AP:
1542 {
1543 m_AmmoTypeIcon.LoadImageFile(0, "set:dayz_gui image:armor_piercing");
1544 m_AmmoTypeIcon.Show(true, refresh);
1545 break;
1546 }
1547 }
1548 }
1549 }
1550 else
1551 m_IsMagazine = false;
1552 }
1553
1555 {
1557 }
1558
1560 {
1561 if (m_Item)
1562 m_HasTemperature = (m_Item.GetTemperatureMax() != 0 && m_Item.GetTemperatureMin() != 0);
1563 }
1564
1565 void CheckHasQuantityEx(bool refresh = true)
1566 {
1567 if (m_Item)
1568 {
1570
1571 if (m_HasQuantity)
1572 m_QuantityPanel.Show(true, refresh);
1573 }
1574 }
1575
1577 {
1579 }
1580
1581 void SetPosX(int x)
1582 {
1583 m_PosX = x;
1584 }
1585
1586 void SetPosY(int y)
1587 {
1588 m_PosY = y;
1589 }
1590
1591 void SetSizeX(int x)
1592 {
1593 m_SizeX = x;
1594 }
1595
1596 void SetSizeY(int y)
1597 {
1598 m_SizeY = y;
1599 }
1600
1602 {
1603 return m_PosX;
1604 }
1605
1607 {
1608 return m_PosY;
1609 }
1610
1612 {
1613 return m_SizeX;
1614 }
1615
1617 {
1618 return m_SizeY;
1619 }
1620
1621 void SetPosEx(bool refresh = true)
1622 {
1623 CargoContainer parentContainer = CargoContainer.Cast(m_Parent);
1625 Widget rootWidget = GetRootWidget();
1626 float iconSize, spaceSize;
1627 if (parentContainer)
1628 {
1629 iconSize = parentContainer.GetIconSize();
1630 spaceSize = parentContainer.GetSpaceSize();
1631 }
1632 else if (parentHPrevContainer)
1633 {
1634 iconSize = parentHPrevContainer.GetIconSize();
1635 if (rootWidget)
1636 rootWidget.SetFlags(WidgetFlags.EXACTSIZE, refresh);
1637 }
1638
1639 if (rootWidget)
1640 {
1641#ifndef PLATFORM_CONSOLE
1642 rootWidget.SetPos(iconSize * GetPosX() + (GetPosX() + 1) * spaceSize, iconSize * GetPosY() + (GetPosY() + 1) * spaceSize, refresh);
1644#else
1645 int row = m_CargoPos / 5;
1646 int column = m_CargoPos % 5;
1649#endif
1650 }
1651 }
1652
1653 void SetPos()
1654 {
1655 SetPosEx();
1656 }
1657
1658 void SetSize()
1659 {
1660 CargoContainer parentContainer = CargoContainer.Cast(m_Parent);
1662 float iconSize, spaceSize;
1663 Widget rootWidget = GetRootWidget();
1664 if (parentContainer)
1665 {
1666 iconSize = parentContainer.GetIconSize();
1667 spaceSize = parentContainer.GetSpaceSize();
1668 }
1669 else if (parentHPrevContainer)
1670 {
1671 iconSize = parentHPrevContainer.GetIconSize();
1672 if (rootWidget)
1673 GetRootWidget().SetFlags(WidgetFlags.EXACTSIZE);
1674 }
1675
1676 if (rootWidget)
1677 {
1678#ifndef PLATFORM_CONSOLE
1679 GetRootWidget().SetSize(iconSize * m_SizeX + (m_SizeX) * spaceSize, iconSize * m_SizeY + (m_SizeY) * spaceSize);
1680#else
1681 GetRootWidget().SetSize(iconSize, iconSize);
1682#endif
1683 }
1684 }
1685
1686 override void UpdateInterval()
1687 {
1688 if (m_Item)
1689 {
1690 if (m_HasTemperature)
1692
1693 if (m_IsWeapon)
1695
1696 if (m_HasQuantity)
1697 SetQuantity();
1698 }
1699 }
1700}
1701
1702class Pos
1703{
1704 int x, y;
1705
1706 void Pos(int _x, int _y)
1707 {
1708 x = _x;
1709 y = _y;
1710 }
1711}
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
DayZGame g_Game
Definition DayZGame.c:3528
DayZGame GetDayZGame()
Definition DayZGame.c:3530
Mission mission
proto string ToString()
Icon x
void Pos(int _x, int _y)
Definition Icon.c:1706
Icon y
FindInventoryLocationType
flags for searching locations in inventory
override ContextMenu GetContextMenu()
ScreenWidthType
void InventoryMenu()
CartridgeType
Definition Magazine.c:4
PlayerBase GetPlayer()
ref Widget m_RootWidget[MAX_SIMULTANIOUS_PLAYERS]
Widget m_Parent
Definition SizeToChild.c:86
void SetActive()
Definition TrapBase.c:409
Widget m_ParentWidget
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
static int BASE_COLOR
static int COMBINE_COLOR
static int SWAP_COLOR
static int FSWAP_COLOR
static int GREEN_COLOR
static int RED_COLOR
static ColorManager GetInstance()
Definition Debug.c:14
static void Log(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message with normal prio.
Definition Debug.c:133
script counterpart to engine's class Inventory
Definition Inventory.c:79
static bool CanForceSwapEntitiesEx(notnull EntityAI item1, InventoryLocation item1_dst, notnull EntityAI item2, out InventoryLocation item2_dst)
Definition Inventory.c:645
Definition Icon.c:2
void ShowActionMenuCombine(EntityAI entity1, EntityAI entity2, int combinationFlags, Widget w, bool color_test)
Definition Icon.c:556
Widget m_MicromanagedPanel
Definition Icon.c:28
void SetPosX(int x)
Definition Icon.c:1581
void RevertToOriginalFlip()
Definition Icon.c:1101
Widget m_QuantityPanel
Definition Icon.c:31
void UpdateFrameColor(EntityAI selectedEntity, EntityAI targetEntity, int combinationFlag, Widget w, InventoryLocation il=null)
Definition Icon.c:513
Widget GetCursorWidget()
Definition Icon.c:88
Widget m_ColorWidget
Definition Icon.c:26
void DoubleClick(Widget w, int x, int y, int button)
Definition Icon.c:149
void DraggingOverCombine(Widget w, int x, int y, Widget receiver)
Definition Icon.c:287
bool m_PreviousFlipOrientation
Definition Icon.c:20
override void SetParentWidget()
Definition Icon.c:116
void FullScreen()
Definition Icon.c:1146
int m_PosX
Definition Icon.c:5
void SetCargoPos(int x)
Definition Icon.c:1002
int GetRelevantInventoryAction(int relevantActions)
Definition Icon.c:135
void ToRefresh(Icon icon, Icon icon2)
Definition Icon.c:952
int GetPosY()
Definition Icon.c:1606
Widget m_SelectedPanel
Definition Icon.c:27
Widget m_ItemSizePanel
Definition Icon.c:36
void DraggingOverSwap(Widget w, int x, int y, Widget receiver)
Definition Icon.c:241
bool MouseEnter(Widget w, int x, int y)
Definition Icon.c:314
void OnDraggingOverBackground(Widget w, int x, int y, Widget reciever)
Definition Icon.c:1061
override void SetLayoutName()
Definition Icon.c:958
bool m_HasTemperature
Definition Icon.c:11
void SetSize()
Definition Icon.c:1658
override void Refresh()
Definition Icon.c:1118
void OnPerformRecipe(int id)
Definition Icon.c:635
void SetItemSize()
Definition Icon.c:1359
void SetPosEx(bool refresh=true)
Definition Icon.c:1621
void SetTemperature()
Definition Icon.c:1135
void SetItemSizeEx(bool refresh=true)
Definition Icon.c:1346
void MouseClick(Widget w, int x, int y, int button)
Definition Icon.c:762
bool IsDragged()
Definition Icon.c:98
Widget GetSelectedWidget()
Definition Icon.c:83
int GetCargoPos()
Definition Icon.c:997
Widget m_QuantityStack
Definition Icon.c:34
void DraggingOver(Widget w, int x, int y, Widget receiver)
Definition Icon.c:333
void UpdateFlip(bool flipped)
Definition Icon.c:1364
void SetSizeY(int y)
Definition Icon.c:1596
bool CombineItems(EntityAI entity1, EntityAI entity2)
Definition Icon.c:667
TextWidget m_QuantityItem
Definition Icon.c:32
ItemBase m_Item
Definition Icon.c:16
void RefreshIconPos()
Definition Icon.c:1140
void SetPosY(int y)
Definition Icon.c:1586
override void SetActive(bool active)
Definition Icon.c:103
void CheckHasQuantityEx(bool refresh=true)
Definition Icon.c:1565
bool m_IsMagazine
Definition Icon.c:10
void CheckHasTemperature()
Definition Icon.c:1559
bool m_HasQuantity
Definition Icon.c:12
int GetSizeY()
Definition Icon.c:1616
bool m_HandsIcon
Definition Icon.c:17
EntityAI m_Obj
Definition Icon.c:15
void SetSize(int x, int y)
Definition Icon.c:985
void CheckIsMagazine()
Definition Icon.c:1554
void RefreshPos(int row, int column)
Definition Icon.c:1155
int m_SizeX
Definition Icon.c:3
void OnPerformCombination(int combinationFlags)
Definition Icon.c:408
void SetPos(int x, int y)
Definition Icon.c:991
const int NUMBER_OF_TIMERS
Definition Icon.c:22
Object GetObject()
Definition Icon.c:1166
void CheckIsWeapon()
Definition Icon.c:1455
void ~Icon()
Definition Icon.c:66
void DestroyWhiteBackground()
Definition Icon.c:1008
Widget GetMicromanagedPanel()
Definition Icon.c:93
void Icon(LayoutHolder parent, bool hands_icon=false)
Definition Icon.c:42
void SetSort(int index)
Definition Icon.c:1322
Widget m_CursorWidget
Definition Icon.c:29
void SetQuantity()
Definition Icon.c:1277
void SetItemPreviewEx(bool refresh=true)
Definition Icon.c:1333
void Swap(Widget w, int x, int y, Widget receiver)
Definition Icon.c:902
void SetItemPreview()
Definition Icon.c:1341
void DropReceivedFromMain(Widget w, int x, int y, Widget receiver)
Definition Icon.c:821
ProgressBarWidget m_QuantityProgress
Definition Icon.c:33
int m_CargoPos
Definition Icon.c:18
int GetSort()
Definition Icon.c:1328
bool MouseLeave(Widget w, Widget s, int x, int y)
Definition Icon.c:325
float m_CurrQuantity
Definition Icon.c:13
TextWidget m_ItemSizeWidget
Definition Icon.c:37
EntityAI m_Lock
Definition Icon.c:8
ref array< ImageWidget > m_AmmoIcons
Definition Icon.c:39
void SetPos()
Definition Icon.c:1653
void CreateWhiteBackground()
Definition Icon.c:1033
ItemPreviewWidget m_ItemPreview
Definition Icon.c:24
int GetPosX()
Definition Icon.c:1601
int GetSizeX()
Definition Icon.c:1611
void SetSizeX(int x)
Definition Icon.c:1591
void InitLock(EntityAI parent, EntityAI obj, int x_pos, int y_pos, bool flip)
Definition Icon.c:1377
override void UpdateInterval()
Definition Icon.c:1686
void RefreshMuzzleIcon()
Definition Icon.c:1171
bool FlagAction(EntityAI entity1, EntityAI entity2, int combinationFlags)
Definition Icon.c:673
void Combine(Widget w, int x, int y, Widget receiver)
Definition Icon.c:644
void InitEx(EntityAI obj, bool refresh=true)
Definition Icon.c:1398
bool PerformCombination(EntityAI selectedEntity, EntityAI targetEntity, int combinationFlag, InventoryLocation ilSwapDst=null)
Definition Icon.c:460
void CheckHasQuantity()
Definition Icon.c:1576
bool m_IsDragged
Definition Icon.c:19
void Init(EntityAI obj)
Definition Icon.c:1450
void RefreshQuickbar()
Definition Icon.c:141
ImageWidget m_AmmoTypeIcon
Definition Icon.c:40
int m_SizeY
Definition Icon.c:4
void DropReceivedFromBackground(Widget w, int x, int y, Widget reciever)
Definition Icon.c:1086
int m_PosY
Definition Icon.c:6
bool m_IsWeapon
Definition Icon.c:9
void CheckIsMagazineEx(bool refresh=true)
Definition Icon.c:1518
InventoryLocation.
static int GetCombinationFlags(EntityAI entity1, EntityAI entity2)
static int GetChosenCombinationFlag(EntityAI selectedEntity, EntityAI targetEntity, int relevantFlags, out InventoryLocation dst=null)
static ItemManager GetInstance()
proto native void SetView(int viewIndex)
proto native void SetForceFlipEnable(bool enable)
proto native void SetItem(EntityAI object)
proto native void SetForceFlip(bool value)
proto native void SetModelOrientation(vector vOrientation)
bool InspectItem()
Definition Container.c:321
Definition EnMath.c:7
static float GetItemQuantity(InventoryItem item)
static int HasItemQuantity(notnull EntityAI item)
static float GetItemQuantityMax(InventoryItem item)
static string GetItemQuantityText(EntityAI item, bool showMax=false)
static void TakeOrSplitToInventoryLocation(notnull PlayerBase player, notnull InventoryLocation dst)
static void TakeOrSplitToInventory(notnull PlayerBase player, notnull EntityAI target, notnull EntityAI item)
static WidgetEventHandler GetInstance()
const string IconWide
const string IconMedium
const string IconXbox
const string IconNarrow
proto native CGame GetGame()
const int QUANTITY_PROGRESS
Definition constants.c:484
const int QUANTITY_COUNT
Definition constants.c:483
const int QUANTITY_HIDDEN
Definition constants.c:482
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
static proto float Round(float f)
Returns mathematical round of value.
const int MENU_INVENTORY
Definition constants.c:170
MouseState
Definition EnSystem.c:311
proto void GetMousePos(out int x, out int y)
WidgetFlags
Definition EnWidgets.c:58
proto native Widget FindAnyWidget(string pathname)
int ARGB(int a, int r, int g, int b)
Definition proto.c:322
int ARGBF(float fa, float fr, float fg, float fb)
Converts <0.0, 1.0> ARGB into color.
Definition proto.c:332