DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
Icon.c
См. документацию.
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
33 protected ProgressBarWidget m_QuantityProgress;
35
38
40 protected ImageWidget m_AmmoTypeIcon;
41
42 void Icon( LayoutHolder parent, bool hands_icon = false )
43 {
44 m_HandsIcon = hands_icon;
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 {
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 else
113 {
114 HideOwnedTooltip();
115 }
116
117 m_SelectedPanel.Show(active);
118 }
119
120 override void SetParentWidget()
121 {
122 #ifndef PLATFORM_CONSOLE
123 if (m_Parent.IsInherited(HandsPreview))
124 {
125 super.SetParentWidget();
126 }
127 else
128 {
129 if (m_Parent != null)
130 {
131 CargoContainer gridContainer = CargoContainer.Cast(m_Parent);
132 if (gridContainer)
133 {
134 m_ParentWidget = gridContainer.GetMainWidget();
135 }
136 }
137 }
138 #else
139 super.SetParentWidget();
140 #endif
141 }
142
143 int GetRelevantInventoryAction(int relevantActions)
144 {
145 return 0;
146
147 }
148
150 {
151 InventoryMenu menu = InventoryMenu.Cast(GetGame().GetUIManager().FindMenu(MENU_INVENTORY));
152 HideOwnedTooltip();
153 if (menu)
154 {
155 menu.RefreshQuickbar();
156 }
157 }
158
159 void DoubleClick(Widget w, int x, int y, int button)
160 {
161 if (button == MouseState.LEFT && !g_Game.IsLeftCtrlDown())
162 {
163 PlayerBase controlledPlayer = PlayerBase.Cast(GetGame().GetPlayer());
164 if (controlledPlayer.GetInventory().HasInventoryReservation(m_Obj, null) || controlledPlayer.GetInventory().IsInventoryLocked() || controlledPlayer.IsItemsToDelete())
165 return;
166
167 ItemPreviewWidget targetIpw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
168 if (!targetIpw)
169 {
170 string name = w.GetName();
171 name.Replace("PanelWidget", "Render");
172 targetIpw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
173 }
174
175 if (!targetIpw)
176 targetIpw = ItemPreviewWidget.Cast(w);
177
178 EntityAI targetEntity = targetIpw.GetItem();
179 if (targetIpw)
180 {
181 if (!targetEntity.GetInventory().CanRemoveEntity())
182 return;
183
184 if (m_HandsIcon)
185 {
186 if (controlledPlayer.GetHumanInventory().CanRemoveEntityInHands())
187 controlledPlayer.PredictiveMoveItemFromHandsToInventory();
188
190
191 return;
192 }
193
194 EntityAI entityInHands = controlledPlayer.GetHumanInventory().GetEntityInHands();
195 EntityAI entityRootParent = targetEntity.GetHierarchyRoot();
196
197 if (controlledPlayer.GetInventory().HasEntityInInventory(targetEntity) && controlledPlayer.GetHumanInventory().CanAddEntityInHands(targetEntity))
198 {
199 controlledPlayer.PredictiveTakeEntityToHands(targetEntity);
200 }
201 else if (entityInHands && entityRootParent == controlledPlayer)
202 {
203 InventoryLocation targetItemLocation = new InventoryLocation();
204 InventoryLocation handsItemLocation = new InventoryLocation();
205 entityInHands.GetInventory().GetCurrentInventoryLocation(handsItemLocation);
206 int index = controlledPlayer.GetHumanInventory().FindUserReservedLocationIndex(entityInHands);
207 if (index >= 0)
208 controlledPlayer.GetHumanInventory().GetUserReservedLocation(index, targetItemLocation);
209
210 if (controlledPlayer.GetInventory().CanForceSwapEntitiesEx(targetEntity, targetItemLocation, entityInHands, handsItemLocation))
211 {
212 controlledPlayer.PredictiveForceSwapEntities(targetEntity, entityInHands, targetItemLocation);
213 }
214 else if (controlledPlayer.GetInventory().CanSwapEntitiesEx(targetEntity, entityInHands ))
215 {
216 controlledPlayer.PredictiveSwapEntities(targetEntity, entityInHands);
217 }
218 else
219 {
220 controlledPlayer.GetInventory().FindFreeLocationFor(targetEntity, FindInventoryLocationType.ANY, targetItemLocation);
221 if (targetItemLocation.IsValid() && controlledPlayer.GetInventory().LocationCanAddEntity(targetItemLocation))
222 SplitItemUtils.TakeOrSplitToInventoryLocation(controlledPlayer, targetItemLocation);
223 }
224 }
225 else
226 {
227 bool found = false;
228 if (targetEntity.GetInventory().CanRemoveEntity())
229 {
231 found = controlledPlayer.GetInventory().FindFreeLocationFor(targetEntity, FindInventoryLocationType.ANY, i2);
232 if (found)
233 {
234 if (i2.GetType() == FindInventoryLocationType.ATTACHMENT)
235 {
236 if (i2.GetParent() != controlledPlayer)
237 found = false;
238 }
239 }
240 }
241
242 if (found)
243 {
244 if (controlledPlayer.GetHumanInventory().CanAddEntityToInventory(targetEntity))
245 controlledPlayer.PredictiveTakeEntityToInventory(FindInventoryLocationType.ANY, targetEntity);
246 }
247 else
248 {
249 if (controlledPlayer.GetHumanInventory().CanAddEntityInHands(targetEntity))
250 controlledPlayer.PredictiveTakeEntityToHands(targetEntity);
251 }
252 }
253
255 }
256 }
257 }
258
259 void DraggingOverSwap( Widget w, int x, int y, Widget receiver )
260 {
261 if (w == null)
262 {
263 return;
264 }
265
266 string name = w.GetName();
267 name.Replace("PanelWidget", "Render");
268
269 ItemPreviewWidget targetIpw = ItemPreviewWidget.Cast(receiver.FindAnyWidget( "Render" ));
270 if (m_HandsIcon)
271 {
272 targetIpw = ItemPreviewWidget.Cast(receiver.GetParent().FindAnyWidget( "Render" ));
273 }
274
275 ItemPreviewWidget selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
276 if (selectedIpw == null)
277 {
278 selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
279 }
280
281 if (selectedIpw == null)
282 {
283 return;
284 }
285
286 InventoryItem targetEntity = InventoryItem.Cast(targetIpw.GetItem());
287 InventoryItem selectedEntity = InventoryItem.Cast(selectedIpw.GetItem());
288 if (!selectedEntity || !targetEntity)
289 {
290 return;
291 }
292
294 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
295 int index = player.GetHumanInventory().FindUserReservedLocationIndex(m_Item);
296
297 if (index >= 0)
298 {
299 player.GetHumanInventory().GetUserReservedLocation(index, il);
300
301 if (GameInventory.CanForceSwapEntitiesEx(selectedEntity, null, targetEntity, il))
302 {
306 return;
307 }
308 }
310
311 int chosenInventoryAction = ItemManager.GetChosenCombinationFlag(selectedEntity, targetEntity, testedFlags, il);
312 UpdateFrameColor(selectedEntity, targetEntity, chosenInventoryAction, w, il);
313 }
314
315 void DraggingOverCombine(Widget w, int x, int y, Widget receiver)
316 {
317 if (w == null)
318 {
319 return;
320 }
321
322 ItemPreviewWidget selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
323 if (!selectedIpw)
324 {
325 string name = w.GetName();
326 name.Replace("PanelWidget", "Render");
327 selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
328 }
329
330 if (!selectedIpw)
331 {
332 selectedIpw = ItemPreviewWidget.Cast(w);
333 }
334
335 if (!selectedIpw.GetItem())
336 {
337 return;
338 }
339 EntityAI selectedEntity = selectedIpw.GetItem();
340 EntityAI targetEntity = GetGame().GetPlayer().GetHumanInventory().GetEntityInHands();
341
343
344 int chosenInventoryAction = ItemManager.GetChosenCombinationFlag(selectedEntity, targetEntity, testedFlags);
345 UpdateFrameColor(selectedEntity, targetEntity, chosenInventoryAction, w);
346 }
347
348 bool MouseEnter(Widget w, int x, int y)
349 {
350 if (!m_IsDragged)
351 {
352 PrepareOwnedTooltip(m_Obj, x, y);
353 m_CursorWidget.Show(true);
354 }
355
356 return true;
357 }
358
359 bool MouseLeave( Widget w, Widget s, int x, int y)
360 {
361 HideOwnedTooltip();
362 if (!m_IsDragged)
363 {
364 m_CursorWidget.Show(false);
365 }
366 return true;
367 }
368
369 void DraggingOver( Widget w, int x, int y, Widget receiver )
370 {
372
373 if (w == null)
374 {
375 return;
376 }
377 string name = w.GetName();
378 name.Replace("PanelWidget", "Render");
379
380 ItemPreviewWidget targetIpw = ItemPreviewWidget.Cast(receiver.FindAnyWidget( "Render" ));
381 if (m_HandsIcon)
382 {
383 targetIpw = ItemPreviewWidget.Cast(receiver.GetParent().FindAnyWidget( "Render" ));
384 }
385
386 ItemPreviewWidget selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget( name ));
387 if (selectedIpw == null)
388 {
389 selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget( "Render" ));
390 }
391 if (selectedIpw == null)
392 {
393 return;
394 }
395
396 PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
397 InventoryItem targetEntity = InventoryItem.Cast(targetIpw.GetItem());
398 InventoryItem selectedEntity = InventoryItem.Cast(selectedIpw.GetItem());
399 InventoryLocation ilDst;
400 if (!targetEntity || !selectedEntity)
401 {
402 return;
403 }
404
405 if (m_Lock)
406 {
407 if (targetEntity == selectedEntity)
408 {
410 ItemManager.GetInstance().GetRightDropzone().SetAlpha( 1 );
411 }
412 else
413 {
414 CargoContainer parentContainer = CargoContainer.Cast(m_Parent);
415
416 float parentX;
417 float parentY;
418
419 parentContainer.GetRootWidget().GetScreenPos(parentX, parentY);
420
421 float iconSize = parentContainer.GetIconSize();
422 float spaceSize = parentContainer.GetSpaceSize();
423
424 int PosX = (x - parentX) / (iconSize + spaceSize);
425 int PosY = (y - parentY) / (iconSize + spaceSize);
426
427 EntityAI parent = m_Lock;
428 CargoBase targetCargo = parent.GetInventory().GetCargo();
429
430 ilDst = new InventoryLocation();
431 ilDst.SetCargoAuto(targetCargo, selectedEntity, PosY, PosX, selectedEntity.GetInventory().GetFlipCargo());
432
433 if (parent.GetInventory().LocationCanAddEntity(ilDst))
434 {
437 }
438 else
439 {
442 }
443 }
444 }
445 else
446 {
448
449 int chosenInventoryAction = ItemManager.GetChosenCombinationFlag(selectedEntity, targetEntity, testedFlags, ilDst);
450 UpdateFrameColor(selectedEntity, targetEntity, chosenInventoryAction, w, ilDst);
451 }
452 }
453
454 void OnPerformCombination( int combinationFlags )
455 {
456 PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
457 if (m_am_entity1 == null || m_am_entity2 == null) return;
458
459 if (combinationFlags == InventoryCombinationFlags.NONE) return;
460
461 Weapon_Base wpn;
462 Magazine mag;
463
464 if (combinationFlags & InventoryCombinationFlags.PERFORM_ACTION)
465 {
467 Class.CastTo(amc, player.GetActionManager());
468
469 if (m_am_entity1 == player.GetHumanInventory().GetEntityInHands())
470 {
471 amc.PerformActionFromInventory(ItemBase.Cast( m_am_entity1 ),ItemBase.Cast( m_am_entity2 ));
472 }
473 else
474 {
475 amc.PerformActionFromInventory(ItemBase.Cast( m_am_entity2 ),ItemBase.Cast( m_am_entity1 ));
476 }
477 }
478 else if (combinationFlags & InventoryCombinationFlags.SET_ACTION)
479 {
481 Class.CastTo(amc2, player.GetActionManager());
482
483 if (m_am_entity1 == player.GetHumanInventory().GetEntityInHands())
484 {
485 amc2.SetActionFromInventory(ItemBase.Cast( m_am_entity1 ), ItemBase.Cast( m_am_entity2 ));
486 }
487 else
488 {
489 amc2.SetActionFromInventory(ItemBase.Cast( m_am_entity2 ), ItemBase.Cast( m_am_entity1 ));
490 }
491 }
492 else if (combinationFlags & InventoryCombinationFlags.COMBINE_QUANTITY2)
493 {
494 ItemBase entity = ItemBase.Cast(m_am_entity1);
495 entity.CombineItemsClient(ItemBase.Cast( m_am_entity2 ));
496 }
497 else if (combinationFlags & InventoryCombinationFlags.ADD_AS_ATTACHMENT)
498 {
499 float stackable = m_am_entity2.GetTargetQuantityMax(-1);
500
501 if (stackable == 0 || stackable >= m_am_entity2.GetQuantity())
502 {
503 player.PredictiveTakeEntityToTargetAttachment(m_am_entity1, m_am_entity2);
504 }
505 else
506 {
508 m_am_entity1.GetInventory().FindFreeLocationFor(m_am_entity2, FindInventoryLocationType.ATTACHMENT, il);
509 ItemBase.Cast(m_am_entity2).SplitIntoStackMaxToInventoryLocationClient(il);
510 }
511 }
512 else if (combinationFlags & InventoryCombinationFlags.ADD_AS_CARGO)
513 {
514 SplitItemUtils.TakeOrSplitToInventory(player, m_am_entity1, m_am_entity2);
515 }
516 }
517
518 bool PerformCombination(EntityAI selectedEntity, EntityAI targetEntity, int combinationFlag, InventoryLocation ilSwapDst = null)
519 {
520 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
522
523 switch (combinationFlag)
524 {
526 return player.PredictiveTakeEntityToTargetAttachment(targetEntity, selectedEntity);
528 SplitItemUtils.TakeOrSplitToInventory(player, targetEntity, selectedEntity);
529 return true;
531 targetEntity.CombineItemsClient(selectedEntity);
532 return true;
534 Class.CastTo(amc, player.GetActionManager());
535 if (targetEntity == player.GetHumanInventory().GetEntityInHands())
536 {
537 amc.SetActionFromInventory(ItemBase.Cast(targetEntity), ItemBase.Cast(selectedEntity));
538 }
539 else
540 {
541 amc.SetActionFromInventory(ItemBase.Cast(selectedEntity), ItemBase.Cast(targetEntity));
542 }
543 return true;
545 Class.CastTo(amc, player.GetActionManager());
546 if (targetEntity == player.GetHumanInventory().GetEntityInHands())
547 {
548 amc.PerformActionFromInventory(ItemBase.Cast(targetEntity), ItemBase.Cast(selectedEntity));
549 }
550 else
551 {
552 amc.PerformActionFromInventory(ItemBase.Cast(selectedEntity), ItemBase.Cast(targetEntity));
553 }
554 return true;
556 return player.GetWeaponManager().SwapMagazine(Magazine.Cast(selectedEntity));
558 return player.PredictiveSwapEntities(targetEntity, selectedEntity);
560 return player.PredictiveForceSwapEntities(selectedEntity, targetEntity, ilSwapDst);
561 default:
562 return false;
563 }
564
565 return false;
566 }
567
568 void UpdateFrameColor(EntityAI selectedEntity, EntityAI targetEntity, int combinationFlag, Widget w, InventoryLocation il = null)
569 {
570 int color;
571 Widget targetDropzone;
572
574 switch (combinationFlag)
575 {
580 break;
586 break;
588 color = ColorManager.SWAP_COLOR;
590 break;
592 color = ColorManager.SWAP_COLOR;
594 break;
597 if (il)
598 {
600 }
601 else
602 {
604 }
605 break;
606 default:
607 color = ColorManager.RED_COLOR;
609 }
610
611 ColorManager.GetInstance().SetColor( w, color );
612 }
613
614
615
616 void ShowActionMenuCombine( EntityAI entity1, EntityAI entity2, int combinationFlags, Widget w , bool color_test )
617 {
618 int lastFlag = 0;
619 ContextMenu cmenu = ContextMenu.Cast(GetGame().GetUIManager().GetMenu().GetContextMenu());
620 m_am_entity1 = entity1;
621 m_am_entity2 = entity2;
622 cmenu.Hide();
623 cmenu.Clear();
624 int id = -1;
625
626 if ( entity1 == null || entity2 == null ) return;
627
628 if ( combinationFlags == InventoryCombinationFlags.NONE )
629 {
630 if ( color_test )
631 {
634 }
635 return;
636 }
637
638 if (combinationFlags & InventoryCombinationFlags.ADD_AS_CARGO)
639 {
641 cmenu.Add( "#inv_context_add_as_cargo", this, "OnPerformCombination", new Param1<int>( lastFlag ) );
642 }
643 if (combinationFlags & InventoryCombinationFlags.ADD_AS_ATTACHMENT)
644 {
646 cmenu.Add( "#inv_context_add_as_attachment", this, "OnPerformCombination", new Param1<int>( lastFlag ));
647 }
648
649 if (combinationFlags & InventoryCombinationFlags.COMBINE_QUANTITY2)
650 {
652 cmenu.Add("#inv_context_combine_quantity", this, "OnPerformCombination", new Param1<int>( lastFlag ));
653 }
654
655 if (combinationFlags & InventoryCombinationFlags.SET_ACTION)
656 {
658 cmenu.Add("#inv_context_attach_magazine", this, "OnPerformCombination", new Param1<int>( lastFlag ));
659 }
660
661 if (combinationFlags & InventoryCombinationFlags.PERFORM_ACTION)
662 {
664 cmenu.Add("Perform action", this, "OnPerformCombination", new Param1<int>( lastFlag ));
665 }
666
667 if (color_test)
668 {
669 if (lastFlag == 0)
670 {
672 ItemManager.GetInstance().GetCenterDropzone().SetAlpha( 1 );
674 }
676 {
678 ItemManager.GetInstance().GetCenterDropzone().SetAlpha( 1 );
680 }
681 else
682 {
684 ItemManager.GetInstance().GetCenterDropzone().SetAlpha( 1 );
686 }
687 }
688 else if (cmenu.Count() >= 1)
689 {
690 OnPerformCombination(combinationFlags);
691 return;
692 }
693 }
694
695 void OnPerformRecipe(int id)
696 {
697 if ( m_am_entity1 == null || m_am_entity2 == null ) return;
698
699 Debug.Log("OnPerformRecipe called for id:"+id.ToString(),"recipes");
700 PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
701 player.GetCraftingManager().SetInventoryCraft( id, ItemBase.Cast(m_am_entity1), ItemBase.Cast(m_am_entity2));
702 }
703
704 void Combine( Widget w, int x, int y, Widget receiver )
705 {
708 ItemPreviewWidget selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
709 if (!selectedIpw)
710 {
711 string name = w.GetName();
712 name.Replace("PanelWidget", "Render");
713 selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget( name ));
714 }
715 if (!selectedIpw)
716 {
717 selectedIpw = ItemPreviewWidget.Cast(w);
718 }
719 if (!selectedIpw.GetItem())
720 {
721 return;
722 }
723 EntityAI selectedEntity = selectedIpw.GetItem();
724 EntityAI targetEntity = GetGame().GetPlayer().GetHumanInventory().GetEntityInHands();
726
727 int chosenInventoryAction = ItemManager.GetChosenCombinationFlag(selectedEntity, targetEntity, testedFlags);
728 PerformCombination(selectedEntity, targetEntity, chosenInventoryAction);
729 }
730
731 bool CombineItems( EntityAI entity1, EntityAI entity2 )
732 {
733 int flags = ItemManager.GetCombinationFlags( entity1, entity2 );
734 return FlagAction( entity1, entity2, flags );
735 }
736
737 bool FlagAction( EntityAI entity1, EntityAI entity2, int combinationFlags )
738 {
739 int current_flag;
740 ContextMenu cmenu = ContextMenu.Cast(GetGame().GetUIManager().GetMenu().GetContextMenu());
741 m_am_entity1 = entity1;
742 m_am_entity2 = entity2;
743 cmenu.Hide();
744 cmenu.Clear();
745 int id = -1;
746
747 if (combinationFlags & InventoryCombinationFlags.COMBINE_QUANTITY2 )
748 {
749 ItemBase entity = ItemBase.Cast( entity1 );
750 entity.CombineItemsClient( ItemBase.Cast( entity2 ) );
751 return false;
752 }
753
754 if (entity1 == null || entity2 == null || combinationFlags == InventoryCombinationFlags.NONE )
755 return true;
756
757 if (combinationFlags & InventoryCombinationFlags.ADD_AS_ATTACHMENT )
758 {
760 cmenu.Add( "#inv_context_add_as_attachment", this, "OnPerformCombination", new Param1<int>( current_flag ) );
761 }
762 /*if (combinationFlags & InventoryCombinationFlags.LOAD_CHAMBER )
763 {
764 current_flag = InventoryCombinationFlags.LOAD_CHAMBER;
765 cmenu.Add( "#inv_context_load_chamber", this, "OnPerformCombination", new Param1<int>( current_flag ) );
766 }*/
767 if(combinationFlags & InventoryCombinationFlags.ATTACH_MAGAZINE)
768 {
770 cmenu.Add("#inv_context_attach_magazine", this, "OnPerformCombination", new Param1<int>( current_flag ) );
771 }
772
773 if (combinationFlags & InventoryCombinationFlags.ADD_AS_CARGO )
774 {
776 cmenu.Add( "#inv_context_add_as_cargo", this, "OnPerformCombination", new Param1<int>( current_flag ) );
777 }
778
779 if (combinationFlags & InventoryCombinationFlags.SWAP )
780 {
781 current_flag = InventoryCombinationFlags.SWAP;
782 cmenu.Add( "#inv_context_swap", this, "OnPerformCombination", new Param1<int>( current_flag ) );
783 }
784
785 if (combinationFlags & InventoryCombinationFlags.COMBINE_QUANTITY2 )
786 {
788 cmenu.Add( "#inv_context_combine", this, "OnPerformCombination", new Param1<int>( current_flag ) );
789 }
790
791 if(combinationFlags & InventoryCombinationFlags.SET_ACTION)
792 {
794 cmenu.Add("#inv_context_attach_magazine", this, "OnPerformCombination", new Param1<int>( current_flag ) );
795 }
796
797 if(combinationFlags & InventoryCombinationFlags.PERFORM_ACTION)
798 {
800 cmenu.Add("Perform Action2", this, "OnPerformCombination", new Param1<int>( current_flag ) );
801 }
802
803 int m_am_Pos_x, m_am_Pos_y;
804 GetMousePos( m_am_Pos_x, m_am_Pos_y );
805 m_am_Pos_x -= 5;
806 m_am_Pos_y -= 5;
807
808 MissionGameplay mission = MissionGameplay.Cast( GetGame().GetMission() );
809 /*if (combinationFlags & InventoryCombinationFlags.RECIPE_HANDS || combinationFlags & InventoryCombinationFlags.RECIPE_ANYWHERE )
810 {
811 OnPerformRecipe( id );
812 return true;
813 }
814 else /*if (cmenu.Count() == 1 )*/
815 //{
816 OnPerformCombination( current_flag );
817 return true;
818 //}
819 /*else
820 {
821 cmenu.Show( m_am_Pos_x, m_am_Pos_y );
822 return true;
823 }*/
824 }
825
826 void MouseClick(Widget w, int x, int y, int button)
827 {
828 if (button == MouseState.RIGHT)
829 {
830 if (m_Lock)
831 {
832 GetGame().GetPlayer().GetHumanInventory().ClearUserReservedLocationSynced(m_Item);
833 }
834 else if (m_Item)
835 {
836 #ifdef DIAG_DEVELOPER
837 if (GetDayZGame().IsLeftCtrlDown())
838 ShowActionMenu(m_Item);
839 else
840 #endif
841 {
842 m_Item.OnRightClick();
843
844 if (m_HasQuantity)
845 SetQuantity();
846 }
847 }
848
849 }
850 else if (!m_Lock)
851 {
852 switch (button)
853 {
854 case MouseState.MIDDLE:
856 break;
857
858 case MouseState.LEFT:
859 PlayerBase controlledPlayer = PlayerBase.Cast(GetGame().GetPlayer());
860 if (g_Game.IsLeftCtrlDown())
861 {
862 if (controlledPlayer.CanDropEntity(m_Item))
863 {
864 if (m_Item.GetTargetQuantityMax() < m_Item.GetQuantity())
865 m_Item.SplitIntoStackMaxClient(null, -1);
866 else
867 controlledPlayer.PhysicalPredictiveDropItem(m_Item);
868
870 }
871 }
872 else
873 {
875 m_Obj.GetInventory().GetCurrentInventoryLocation(il);
876
877 bool draggable = !controlledPlayer.GetInventory().HasInventoryReservation(m_Obj, null) && !controlledPlayer.GetInventory().IsInventoryLocked() && !controlledPlayer.IsItemsToDelete();
878 draggable = draggable && (m_Obj.GetHierarchyRoot() && m_Obj.GetInventory().CanRemoveEntity() || !m_Obj.GetHierarchyRoot() && AttachmentsOutOfReach.IsAttachmentReachable(m_Obj, "", il.GetSlot()));
879
881 }
882 break;
883 }
884 }
885 }
886
887 void DropReceivedFromMain( Widget w, int x, int y, Widget receiver )
888 {
891 string name = w.GetName();
892 name.Replace("PanelWidget", "Render");
893 PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
894
895 ItemPreviewWidget targetIpw = ItemPreviewWidget.Cast(receiver.FindAnyWidget( "Render" ));
896 if (m_HandsIcon)
897 {
898 targetIpw = ItemPreviewWidget.Cast(receiver.GetParent().FindAnyWidget( "Render" ));
899 }
900
901 ItemPreviewWidget selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget( name ));
902 if (selectedIpw == null)
903 {
904 selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget( "Render" ));
905 }
906 if (selectedIpw == null)
907 {
908 return;
909 }
910
911 InventoryItem targetEntity = InventoryItem.Cast(targetIpw.GetItem());
912 InventoryItem selectedEntity = InventoryItem.Cast(selectedIpw.GetItem());
913 if (!selectedEntity)
914 {
915 return;
916 }
917 int index;
918 InventoryLocation ilSrc;
919 InventoryLocation ilDst;
920 if (m_Lock && targetEntity == selectedEntity)
921 {
922 index = player.GetHumanInventory().FindUserReservedLocationIndex(m_Item);
923 ilSrc = new InventoryLocation();
924 ilDst = new InventoryLocation();
925
926 m_Item.GetInventory().GetCurrentInventoryLocation(ilSrc);
927 player.GetHumanInventory().GetUserReservedLocation(index, ilDst);
928
929 if (ilDst.GetParent().GetInventory().LocationCanAddEntity(ilDst))
930 {
931
932 player.GetHumanInventory().ClearUserReservedLocation(m_Item);
933 player.PredictiveTakeToDst(ilSrc, ilDst);
934 m_Item.GetOnReleaseLock().Invoke(m_Item);
935 }
936 }
937 else if (m_Lock)
938 {
939 CargoContainer parentCargo = CargoContainer.Cast(m_Parent);
940
941 float parentX;
942 float parentY;
943
944 parentCargo.GetRootWidget().GetScreenPos(parentX, parentY);
945
946 float iconSize = parentCargo.GetIconSize();
947 float spaceSize = parentCargo.GetSpaceSize();
948
949 int PosX = (x-parentX) / (iconSize + spaceSize);
950 int PosY = (y-parentY) / (iconSize + spaceSize);
951
952 EntityAI parent = m_Lock;
953 CargoBase targetCargo = parent.GetInventory().GetCargo();
954
955 ilDst = new InventoryLocation();
956 ilDst.SetCargoAuto(targetCargo, selectedEntity, PosY, PosX, selectedEntity.GetInventory().GetFlipCargo());
957
958 if (parent.GetInventory().LocationCanAddEntity(ilDst))
959 {
960 player.GetHumanInventory().ClearUserReservedLocation(m_Item);
961 m_Item.GetOnReleaseLock().Invoke(m_Item);
962
964 }
965 }
966 else
967 {
968 ilDst = new InventoryLocation();
970
971 int chosenInventoryAction = ItemManager.GetChosenCombinationFlag(selectedEntity, targetEntity, testedFlags, ilDst);
972 PerformCombination(selectedEntity, targetEntity, chosenInventoryAction, ilDst);
973 }
974 }
975
976 void Swap( Widget w, int x, int y, Widget receiver )
977 {
980 string name = w.GetName();
981 name.Replace("PanelWidget", "Render");
982
983 ItemPreviewWidget targetIpw = ItemPreviewWidget.Cast(receiver.FindAnyWidget( "Render" ));
984 if (m_HandsIcon)
985 {
986 targetIpw = ItemPreviewWidget.Cast(receiver.GetParent().FindAnyWidget( "Render" ));
987 }
988
989 ItemPreviewWidget selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget( name ));
990 if (selectedIpw == null)
991 {
992 selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget( "Render" ));
993 }
994 if (selectedIpw == null)
995 {
996 return;
997 }
998
999 InventoryItem targetEntity = InventoryItem.Cast(targetIpw.GetItem());
1000 InventoryItem selectedEntity = InventoryItem.Cast(selectedIpw.GetItem());
1001 if (!selectedEntity || !targetEntity)
1002 {
1003 return;
1004 }
1005
1006 PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
1007 EntityAI itemInHands = player.GetHumanInventory().GetEntityInHands();
1008
1011 targetEntity.GetInventory().GetCurrentInventoryLocation(ilSrc);
1013
1014 int index = player.GetHumanInventory().FindUserReservedLocationIndex(targetEntity);
1015 if (index>=0)
1016 {
1017 player.GetHumanInventory().GetUserReservedLocation(index, ilDst);
1018
1019 if (GameInventory.CanForceSwapEntitiesEx( selectedEntity, ilSrc, targetEntity, ilDst ))
1020 {
1021 if (m_HandsIcon && !player.GetInventory().HasInventoryReservation(itemInHands, null) && !player.IsItemsToDelete())
1022 {
1023 GetGame().GetPlayer().PredictiveForceSwapEntities(selectedEntity, targetEntity, ilDst);
1024 return;
1025 }
1026 }
1027 }
1029
1030 int chosenInventoryAction = ItemManager.GetChosenCombinationFlag(selectedEntity, targetEntity, testedFlags, ilDst);
1031 PerformCombination(selectedEntity, targetEntity, chosenInventoryAction, ilDst);
1032 }
1033
1034 void ToRefresh( Icon icon, Icon icon2 )
1035 {
1036 ( IconsContainer.Cast( m_Parent ) ).RemoveItem( icon );
1037 ( IconsContainer.Cast( m_Parent ) ).RemoveItem( icon2 );
1038 }
1039
1040 override void SetLayoutName()
1041 {
1042 #ifdef PLATFORM_CONSOLE
1043 m_LayoutName = WidgetLayoutName.IconXbox;
1044 #else
1045 switch (InventoryMenu.GetWidthType())
1046 {
1047 case ScreenWidthType.NARROW:
1048 {
1049 m_LayoutName = WidgetLayoutName.IconNarrow;
1050 break;
1051 }
1052 case ScreenWidthType.MEDIUM:
1053 {
1054 m_LayoutName = WidgetLayoutName.IconMedium;
1055 break;
1056 }
1057 case ScreenWidthType.WIDE:
1058 {
1059 m_LayoutName = WidgetLayoutName.IconWide;
1060 break;
1061 }
1062 }
1063 #endif
1064
1065 }
1066
1067 void SetSize( int x, int y )
1068 {
1069 m_SizeX = x;
1070 m_SizeY = y;
1071 }
1072
1073 void SetPos( int x, int y )
1074 {
1075 m_PosX = x;
1076 m_PosY = y;
1077 }
1078
1080 {
1081 return m_CargoPos;
1082 }
1083
1084 void SetCargoPos(int x)
1085 {
1086 GetMainWidget().SetSort( x );
1087 m_CargoPos = x;
1088 }
1089
1091 {
1094 m_IsDragged = false;
1095
1097
1098 if (m_HandsIcon)
1099 {
1100 m_ItemPreview.SetForceFlipEnable(true);
1101 m_ItemPreview.SetForceFlip(false);
1102 Refresh();
1103 FullScreen();
1104 }
1105
1106 m_ColorWidget.Show(false);
1107
1108 m_CursorWidget.SetColor( ARGBF( 1, 1, 1, 1 ) );
1109 m_CursorWidget.Show( false );
1110
1111 InventoryMenu menu = InventoryMenu.Cast(GetGame().GetUIManager().FindMenu( MENU_INVENTORY ));
1112
1113 if (menu)
1114 menu.RefreshQuickbar();
1115 }
1116
1118 {
1119 m_PreviousFlipOrientation = m_Item.GetInventory().GetFlipCargo();
1122 m_IsDragged = true;
1124 int ww, hh;
1126 if (m_Item.GetInventory().GetFlipCargo())
1127 SetSize(hh, ww);
1128 else
1129 SetSize(ww, hh);
1130
1131 SetSize();
1132
1133 if (!m_HandsIcon)
1134 {
1135 Refresh();
1136 }
1137 else
1138 {
1139 m_ItemPreview.SetForceFlipEnable(false);
1141 }
1143
1144 m_CursorWidget.Show(true);
1145 }
1146
1147 void OnDraggingOverBackground( Widget w, int x, int y, Widget reciever )
1148 {
1150 EntityAI entity = EntityAI.Cast( m_Obj );
1151 EntityAI parent = entity.GetHierarchyParent();
1152 if (parent && parent.GetHierarchyRootPlayer() == GetGame().GetPlayer())
1153 {
1155 }
1156 else if (!m_HandsIcon)
1157 {
1158 ItemManager.GetInstance().GetLeftDropzone().SetAlpha(1);
1159 }
1160
1161 if (w == null || reciever == null)
1162 {
1163 return;
1164 }
1165 Pos pa;
1166 reciever.GetUserData(pa);
1167 if (m_Parent)
1168 {
1169 ContainerWithCargo item = ContainerWithCargo.Cast(m_Parent.m_Parent);
1170 if (item)
1171 {
1172 item.DraggingOverGrid(w, m_PosY + pa.y, m_PosX + pa.x, reciever);
1173 }
1174 HandsContainer hands_item = HandsContainer.Cast(m_Parent.m_Parent);
1175 if (hands_item)
1176 {
1177 hands_item.DraggingOverGrid(w, m_PosY + pa.y, m_PosX + pa.x, reciever, null);
1178 }
1179 }
1180 }
1181
1182 void DropReceivedFromBackground( Widget w, int x, int y, Widget reciever )
1183 {
1184 Pos pa;
1185 if (reciever)
1186 {
1187 reciever.GetUserData(pa);
1188 if (m_Parent)
1189 {
1190 ContainerWithCargo item = ContainerWithCargo.Cast(m_Parent.m_Parent);
1191 if (item)
1192 {
1193 item.DropReceived(w, m_PosY + pa.y, m_PosX + pa.x);
1194 }
1195 }
1196 }
1197 }
1198
1200 {
1201 if (m_Item)
1202 {
1203 m_Item.GetInventory().SetFlipCargo(m_PreviousFlipOrientation);
1204 int ww, hh;
1206
1208 SetSize(hh, ww);
1209 else
1210 SetSize(ww, hh);
1211
1212 SetSize();
1213 }
1214 }
1215
1216 override void Refresh()
1217 {
1218 super.Refresh();
1219
1220 if (!m_HandsIcon)
1221 SetPos();
1222
1223 if (m_HasTemperature)
1225
1226 if (m_IsWeapon)
1228
1229 if (m_HasQuantity)
1230 SetQuantity();
1231 }
1232
1237
1239 {
1240 Refresh();
1241 GetMainWidget().Update();
1242 }
1243
1245 {
1246 if (m_IsDragged)
1247 {
1248 return;
1249 }
1250 GetRootWidget().ClearFlags(WidgetFlags.HEXACTSIZE + WidgetFlags.VEXACTSIZE);
1251 GetRootWidget().SetSize(1, 1);
1252 m_ColorWidget.SetColor(ARGB( 0, 0, 0, 0 ));
1253 }
1254
1255 void RefreshPos( int row, int column )
1256 {
1257 if (row != m_PosY || column != m_PosX)
1258 {
1259 m_PosX = column;
1260 m_PosY = row;
1261 SetPos();
1263 }
1264 }
1265
1267 {
1268 return m_Obj;
1269 }
1270
1272 {
1273 Weapon_Base wpn = Weapon_Base.Cast(GetObject());
1274 if (wpn)
1275 {
1276 int i;
1277 ImageWidget ammoIcon;
1278 if (!wpn.IsShowingChamberedBullet())
1279 {
1280 for (i = 0; i < m_AmmoIcons.Count(); i++)
1281 {
1282 ammoIcon = m_AmmoIcons.Get(i);
1283 ammoIcon.Show(false);
1284 }
1285 }
1286 else
1287 {
1288 for (i = 0; i < wpn.GetMuzzleCount(); i++)
1289 {
1290 if (i > m_AmmoIcons.Count())
1291 break;
1292
1293 ammoIcon = m_AmmoIcons.Get(i);
1294
1295 if (wpn.IsChamberFull(i))
1296 {
1297 if (wpn.IsJammed())
1298 {
1299 ammoIcon.Show(true);
1300 ammoIcon.SetImage(2);
1301 }
1302 else if (wpn.IsChamberFiredOut(i))
1303 {
1304 ammoIcon.Show(true);
1305 ammoIcon.SetImage(1);
1306 }
1307 else
1308 {
1309 ammoIcon.Show(true);
1310 ammoIcon.SetImage(0);
1311 }
1312 }
1313 else
1314 {
1315 ammoIcon.Show(false);
1316 }
1317 }
1318 }
1319 }
1320 }
1321
1323 {
1324 if (m_Item)
1325 {
1326 int quantityType = QuantityConversions.HasItemQuantity(m_Item);
1328 {
1330
1331 if (quantityType == QUANTITY_COUNT)
1332 {
1333 string quantityText = QuantityConversions.GetItemQuantityText(m_Item);
1334
1335 if (QuantityConversions.GetItemQuantityMax(m_Item) == 1 || quantityText == "")
1336 {
1337 m_QuantityStack.Show(false);
1338 }
1339 else
1340 {
1341 m_QuantityItem.SetText(quantityText);
1342 m_QuantityStack.Show(true);
1343 }
1344
1345 m_QuantityProgress.Show(false);
1346 }
1347 else if (quantityType == QUANTITY_PROGRESS)
1348 {
1349 int max = m_Item.GetQuantityMax();
1350 int count = m_Item.ConfigGetInt("count");
1351 float quantity = m_CurrQuantity;
1352
1353 if (count > 0)
1354 {
1355 max = count;
1356 }
1357
1358 if (max > 0)
1359 {
1360 float value = Math.Round((quantity / max) * 100);
1361 m_QuantityProgress.SetCurrent(value);
1362 }
1363
1364 m_QuantityStack.Show(false);
1365 m_QuantityProgress.Show(true);
1366 }
1367 }
1368 }
1369 }
1370
1371 void SetSort(int index)
1372 {
1373 GetMainWidget().SetSort(index);
1374 GetMainWidget().Update();
1375 }
1376
1378 {
1379 return GetMainWidget().GetSort();
1380 }
1381
1382 void SetItemPreviewEx(bool refresh = true)
1383 {
1384 m_ItemPreview.Show(true, refresh);
1385 m_ItemPreview.SetItem(EntityAI.Cast(m_Obj));
1386 m_ItemPreview.SetModelOrientation("0 0 0");
1387 m_ItemPreview.SetView(m_Obj.GetViewIndex());
1388 }
1389
1391 {
1393 }
1394
1395 void SetItemSizeEx(bool refresh = true)
1396 {
1397 #ifdef PLATFORM_CONSOLE
1398 m_ItemSizePanel.Show(true, refresh);
1399 m_ItemSizeWidget.Show(true, refresh);
1400
1401 int sizeX, sizeY;
1402 GetGame().GetInventoryItemSize(m_Item, sizeX, sizeY);
1403 int capacity = sizeX * sizeY;
1404 m_ItemSizeWidget.SetText(capacity.ToString());
1405 #endif
1406 }
1407
1409 {
1410 SetItemSizeEx();
1411 }
1412
1413 void UpdateFlip(bool flipped)
1414 {
1415 int sizeX, sizeY;
1416 GetGame().GetInventoryItemSize(m_Item, sizeX, sizeY);
1417
1418 if (flipped)
1419 SetSize(sizeY, sizeX);
1420 else
1421 SetSize(sizeX, sizeY);
1422
1423 SetSize();
1424 }
1425
1426 void InitLock( EntityAI parent, EntityAI obj, int x_pos, int y_pos, bool flip)
1427 {
1428 m_Lock = parent;
1429 m_Obj = obj;
1430 m_Item = ItemBase.Cast(m_Obj);
1431
1432 SetPos(x_pos, y_pos);
1433 UpdateFlip( flip );
1434
1435 ItemManager.GetInstance().SetWidgetDraggable( GetMainWidget(), false );
1436 WidgetEventHandler.GetInstance().RegisterOnMouseButtonDown( GetMainWidget(), this, "MouseClick" );
1437 WidgetEventHandler.GetInstance().RegisterOnDropReceived( GetMainWidget(), this, "DropReceivedFromMain" );
1438 WidgetEventHandler.GetInstance().RegisterOnDraggingOver( GetMainWidget(), this, "DraggingOver" );
1439
1440 m_RootWidget.FindAnyWidget( "Reserved" ).Show( true );
1441 m_ItemPreview.SetForceFlipEnable(true);
1442 m_ItemPreview.SetForceFlip(flip);
1444 Refresh();
1445 }
1446
1447 void InitEx( EntityAI obj, bool refresh = true )
1448 {
1449 if (obj != m_Obj)
1450 {
1451 if (m_Obj)
1452 {
1453 m_Obj.GetOnItemFlipped().Remove(UpdateFlip );
1454 m_Obj.GetOnViewIndexChanged().Remove(SetItemPreview);
1455 }
1456 if (obj)
1457 {
1458 obj.GetOnItemFlipped().Insert(UpdateFlip);
1459 obj.GetOnViewIndexChanged().Insert(SetItemPreview);
1460 }
1461 }
1462
1463 if (m_HandsIcon)
1464 {
1465 m_ItemPreview.SetForceFlipEnable(true);
1466 m_ItemPreview.SetForceFlip(false);
1467 }
1468
1469 m_Obj = obj;
1470 m_Item = ItemBase.Cast(m_Obj);
1471 m_Lock = null;
1472
1473 SetItemPreviewEx(refresh);
1474
1475 WidgetEventHandler.GetInstance().RegisterOnDrag( GetMainWidget(), this, "CreateWhiteBackground" );
1476 WidgetEventHandler.GetInstance().RegisterOnDrop( GetMainWidget(), this, "DestroyWhiteBackground" );
1477 WidgetEventHandler.GetInstance().RegisterOnDropReceived( GetMainWidget(), this, "DropReceivedFromMain" );
1478 WidgetEventHandler.GetInstance().RegisterOnMouseButtonDown( GetMainWidget(), this, "MouseClick" );
1479 WidgetEventHandler.GetInstance().RegisterOnDropReceived( GetMainWidget().FindAnyWidget( "Swap" ), this, "Swap" );
1480 WidgetEventHandler.GetInstance().RegisterOnDraggingOver( GetMainWidget().FindAnyWidget( "Swap" ), this, "DraggingOverSwap" );
1481 WidgetEventHandler.GetInstance().RegisterOnDropReceived( GetMainWidget().FindAnyWidget( "Combine" ), this, "Combine" );
1482 WidgetEventHandler.GetInstance().RegisterOnDraggingOver( GetMainWidget().FindAnyWidget( "Combine" ), this, "DraggingOverCombine" );
1483 WidgetEventHandler.GetInstance().RegisterOnDraggingOver( GetMainWidget(), this, "DraggingOver" );
1484 WidgetEventHandler.GetInstance().RegisterOnMouseEnter( GetMainWidget(), this, "MouseEnter" );
1485 WidgetEventHandler.GetInstance().RegisterOnMouseLeave( GetMainWidget(), this, "MouseLeave" );
1486 WidgetEventHandler.GetInstance().RegisterOnDoubleClick( GetMainWidget(), this, "DoubleClick" );
1487
1488 SetItemSizeEx(refresh);
1489 CheckIsWeapon();
1490 CheckIsMagazineEx(refresh);
1492 CheckHasQuantityEx(refresh);
1493 m_RootWidget.FindAnyWidget("Reserved").Show(false, refresh);
1494
1495 m_ColorWidget.Show(false);
1496 if (refresh)
1497 Refresh();
1498 }
1499
1500 void Init(EntityAI obj)
1501 {
1502 InitEx(obj);
1503 }
1504
1506 {
1507 Weapon_Base wpn = Weapon_Base.Cast(m_Obj);
1508 if (wpn)
1509 {
1511 m_IsWeapon = true;
1512 float posX = 0.0;
1513 float width = 0.0, height = 0.0;
1514 for (int i = 0; i < wpn.GetMuzzleCount(); i++)
1515 {
1516 if (i == 1)
1517 {
1518 m_AmmoIcons[0].GetSize(width, height);
1519 }
1520 posX += width;
1521
1522 Widget ammoIcon = Widget.Cast(GetGame().GetWorkspace().CreateWidgets("gui/layouts/inventory_new/ammo_icon.layout", GetMainWidget()));
1523 ammoIcon.SetPos(posX, 0.0, false);
1524
1525 ImageWidget ammoIconImg = ImageWidget.Cast(ammoIcon.GetChildren());
1526
1527 AmmoData data = Magazine.GetAmmoData(wpn.GetChamberAmmoTypeName(i));
1528 if (data)
1529 {
1530 CartridgeType cartridgeType = data.m_CartridgeType;
1531 switch (cartridgeType)
1532 {
1533 case CartridgeType.Pistol:
1534 {
1535 ammoIconImg.LoadImageFile(0, "set:dayz_gui image:cartridge_pistol");
1536 ammoIconImg.LoadImageFile(1, "set:dayz_gui image:shell_pistol");
1537 ammoIconImg.LoadImageFile(2, "set:dayz_gui image:jam_pistol");
1538 break;
1539 }
1540 case CartridgeType.Intermediate:
1541 {
1542 ammoIconImg.LoadImageFile(0, "set:dayz_gui image:cartridge_int");
1543 ammoIconImg.LoadImageFile(1, "set:dayz_gui image:shell_int");
1544 ammoIconImg.LoadImageFile(2, "set:dayz_gui image:jam_int");
1545 break;
1546 }
1547 case CartridgeType.FullPower:
1548 {
1549 ammoIconImg.LoadImageFile(0, "set:dayz_gui image:cartridge_fp");
1550 ammoIconImg.LoadImageFile(1, "set:dayz_gui image:shell_fp");
1551 ammoIconImg.LoadImageFile(2, "set:dayz_gui image:jam_fp");
1552 break;
1553 }
1554 case CartridgeType.Shell:
1555 {
1556 ammoIconImg.LoadImageFile(0, "set:dayz_gui image:cartridge_shell");
1557 ammoIconImg.LoadImageFile(1, "set:dayz_gui image:shell_shell");
1558 ammoIconImg.LoadImageFile(2, "set:dayz_gui image:jam_shell");
1559 break;
1560 }
1561 //@note: Crossbows cant jam so we dont add a icon for the jam state
1562 case CartridgeType.Arrow:
1563 {
1564 ammoIconImg.LoadImageFile(0, "set:dayz_gui image:arrow_int");
1565 ammoIconImg.LoadImageFile(1, "set:dayz_gui image:arrow_int");
1566 break;
1567 }
1568 }
1569 }
1570 m_AmmoIcons.Insert(ammoIconImg);
1571 }
1572 }
1573 else
1574 {
1575 m_IsWeapon = false;
1576 }
1577 }
1578
1579 void CheckIsMagazineEx( bool refresh = true )
1580 {
1581 Magazine mag = Magazine.Cast(m_Obj);
1582 if (mag)
1583 {
1584 m_IsMagazine = true;
1585 AmmoData data = Magazine.GetAmmoData(mag.ClassName());
1586 if (data)
1587 {
1588 ProjectileType p_type = data.m_ProjectileType;
1589 switch (p_type)
1590 {
1591 case ProjectileType.None:
1592 {
1593 m_AmmoTypeIcon.Show(false, refresh);
1594 break;
1595 }
1596 case ProjectileType.Tracer:
1597 {
1598 m_AmmoTypeIcon.LoadImageFile(0, "set:dayz_gui image:tracer");
1599 m_AmmoTypeIcon.Show(true, refresh);
1600 break;
1601 }
1602 case ProjectileType.AP:
1603 {
1604 m_AmmoTypeIcon.LoadImageFile(0, "set:dayz_gui image:armor_piercing");
1605 m_AmmoTypeIcon.Show(true, refresh);
1606 break;
1607 }
1608 }
1609 }
1610 }
1611 else
1612 {
1613 m_IsMagazine = false;
1614 }
1615 }
1616
1618 {
1620 }
1621
1623 {
1624 if (m_Item)
1625 {
1626 m_HasTemperature = m_Item.CanHaveTemperature();
1627 }
1628 }
1629
1630 void CheckHasQuantityEx(bool refresh = true)
1631 {
1632 if (m_Item)
1633 {
1635
1636 if (m_HasQuantity)
1637 m_QuantityPanel.Show(true, refresh);
1638 }
1639 }
1640
1642 {
1644 }
1645
1646 void SetPosX(int x)
1647 {
1648 m_PosX = x;
1649 }
1650
1651 void SetPosY(int y)
1652 {
1653 m_PosY = y;
1654 }
1655
1656 void SetSizeX(int x)
1657 {
1658 m_SizeX = x;
1659 }
1660
1661 void SetSizeY(int y)
1662 {
1663 m_SizeY = y;
1664 }
1665
1667 {
1668 return m_PosX;
1669 }
1670
1672 {
1673 return m_PosY;
1674 }
1675
1677 {
1678 return m_SizeX;
1679 }
1680
1682 {
1683 return m_SizeY;
1684 }
1685
1686 void SetPosEx(bool refresh = true)
1687 {
1688 CargoContainer parentContainer = CargoContainer.Cast(m_Parent);
1689 HandsPreview parentHPrevContainer = HandsPreview.Cast(m_Parent);
1690 Widget rootWidget = GetRootWidget();
1691 float iconSize, spaceSize;
1692 if (parentContainer)
1693 {
1694 iconSize = parentContainer.GetIconSize();
1695 spaceSize = parentContainer.GetSpaceSize();
1696 }
1697 else if (parentHPrevContainer)
1698 {
1699 iconSize = parentHPrevContainer.GetIconSize();
1700 if (rootWidget)
1701 {
1702 rootWidget.SetFlags(WidgetFlags.EXACTSIZE, refresh);
1703 }
1704 }
1705
1706 if (rootWidget)
1707 {
1708 #ifndef PLATFORM_CONSOLE
1709 rootWidget.SetPos(iconSize * GetPosX() + ( GetPosX() + 1 ) * spaceSize, iconSize * GetPosY() + ( GetPosY() + 1 ) * spaceSize, refresh);
1710 rootWidget.SetSize(iconSize * m_SizeX + ( m_SizeX ) * spaceSize, iconSize * m_SizeY + ( m_SizeY ) * spaceSize, refresh);
1711 #else
1712 int row = m_CargoPos / 5;
1713 int column = m_CargoPos % 5;
1714 rootWidget.SetPos(iconSize * column, iconSize * row, refresh);
1715 rootWidget.SetSize(iconSize, iconSize, refresh);
1716 #endif
1717 }
1718 }
1719
1720 void SetPos()
1721 {
1722 SetPosEx();
1723 }
1724
1725 void SetSize()
1726 {
1727 CargoContainer parentContainer = CargoContainer.Cast(m_Parent);
1728 HandsPreview parentHPrevContainer = HandsPreview.Cast(m_Parent);
1729 float iconSize, spaceSize;
1730 Widget rootWidget = GetRootWidget();
1731 if (parentContainer)
1732 {
1733 iconSize = parentContainer.GetIconSize();
1734 spaceSize = parentContainer.GetSpaceSize();
1735 }
1736 else if (parentHPrevContainer)
1737 {
1738 iconSize = parentHPrevContainer.GetIconSize();
1739 if (rootWidget)
1740 {
1741 GetRootWidget().SetFlags(WidgetFlags.EXACTSIZE);
1742 }
1743 }
1744
1745 if (rootWidget)
1746 {
1747 #ifndef PLATFORM_CONSOLE
1748 GetRootWidget().SetSize(iconSize * m_SizeX + ( m_SizeX ) * spaceSize, iconSize * m_SizeY + ( m_SizeY ) * spaceSize);
1749 #else
1750 GetRootWidget().SetSize(iconSize, iconSize);
1751 #endif
1752 }
1753 }
1754
1755 override void UpdateInterval()
1756 {
1757 if (m_Item)
1758 {
1759 if (m_HasTemperature)
1761
1762 if (m_IsWeapon)
1764
1765 if (m_HasQuantity)
1766 SetQuantity();
1767 }
1768 }
1769}
1770
1771class Pos
1772{
1773 int x, y;
1774
1775 void Pos(int _x, int _y)
1776 {
1777 x = _x;
1778 y = _y;
1779 }
1780}
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
DayZGame g_Game
Определения DayZGame.c:3868
DayZGame GetDayZGame()
Определения DayZGame.c:3870
Mission mission
Определения DisplayStatus.c:28
proto string ToString()
Icon x
void Pos(int _x, int _y)
Определения Icon.c:1775
Icon y
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:17
override ContextMenu GetContextMenu()
Определения InventoryMenu.c:80
ScreenWidthType
Определения InventoryMenu.c:2
void InventoryMenu()
Определения InventoryMenu.c:20
CartridgeType
Определения Magazine.c:4
PlayerBase GetPlayer()
Определения ModifierBase.c:51
ref Widget m_RootWidget[MAX_SIMULTANIOUS_PLAYERS]
Определения PluginRemotePlayerDebugClient.c:14
Widget m_Parent
Определения SizeToChild.c:92
void SetActive()
Определения TrapBase.c:414
Widget m_ParentWidget
Определения UiHintPanel.c:318
void SetActionFromInventory(ItemBase mainItem, ItemBase targetItem)
Определения ActionManagerClient.c:1224
void PerformActionFromInventory(ItemBase mainItem, ItemBase targetItem)
Определения ActionManagerClient.c:1087
static bool IsAttachmentReachable(EntityAI e, string att_slot_name="", int slot_id=-1, float range=1.5)
Определения AttachmentsOutOfReach.c:5
proto void GetInventoryItemSize(InventoryItem item, out int width, out int height)
proto native DayZPlayer GetPlayer()
represents base for cargo storage for entities
Определения Cargo.c:7
Super root of all classes in Enforce script.
Определения EnScript.c:11
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 FSWAP_COLOR
Определения ColorManager.c:19
static int GREEN_COLOR
Определения ColorManager.c:17
static int RED_COLOR
Определения ColorManager.c:16
static ColorManager GetInstance()
Определения ColorManager.c:27
Определения ColorManager.c:2
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.
Определения Debug.c:122
Определения Debug.c:2
Определения Building.c:6
static bool CanForceSwapEntitiesEx(notnull EntityAI item1, InventoryLocation item1_dst, notnull EntityAI item2, out InventoryLocation item2_dst)
Определения Inventory.c:664
script counterpart to engine's class Inventory
Определения Inventory.c:79
bool DraggingOverGrid(Widget w, int x, int y, Widget reciever, CargoContainer cargo)
Определения HandsContainer.c:1065
Определения HandsContainer.c:2
float GetIconSize()
Определения HandsPreview.c:61
Определения HandsPreview.c:2
void ShowActionMenuCombine(EntityAI entity1, EntityAI entity2, int combinationFlags, Widget w, bool color_test)
Определения Icon.c:616
Widget m_MicromanagedPanel
Определения Icon.c:28
void SetPosX(int x)
Определения Icon.c:1646
void RevertToOriginalFlip()
Определения Icon.c:1199
Widget m_QuantityPanel
Определения Icon.c:31
void UpdateFrameColor(EntityAI selectedEntity, EntityAI targetEntity, int combinationFlag, Widget w, InventoryLocation il=null)
Определения Icon.c:568
Widget GetCursorWidget()
Определения Icon.c:88
Widget m_ColorWidget
Определения Icon.c:26
void DoubleClick(Widget w, int x, int y, int button)
Определения Icon.c:159
void DraggingOverCombine(Widget w, int x, int y, Widget receiver)
Определения Icon.c:315
bool m_PreviousFlipOrientation
Определения Icon.c:20
override void SetParentWidget()
Определения Icon.c:120
void FullScreen()
Определения Icon.c:1244
int m_PosX
Определения Icon.c:5
void SetCargoPos(int x)
Определения Icon.c:1084
int GetRelevantInventoryAction(int relevantActions)
Определения Icon.c:143
void ToRefresh(Icon icon, Icon icon2)
Определения Icon.c:1034
int GetPosY()
Определения Icon.c:1671
Widget m_SelectedPanel
Определения Icon.c:27
Widget m_ItemSizePanel
Определения Icon.c:36
void DraggingOverSwap(Widget w, int x, int y, Widget receiver)
Определения Icon.c:259
bool MouseEnter(Widget w, int x, int y)
Определения Icon.c:348
void OnDraggingOverBackground(Widget w, int x, int y, Widget reciever)
Определения Icon.c:1147
override void SetLayoutName()
Определения Icon.c:1040
bool m_HasTemperature
Определения Icon.c:11
void SetSize()
Определения Icon.c:1725
override void Refresh()
Определения Icon.c:1216
void OnPerformRecipe(int id)
Определения Icon.c:695
void SetItemSize()
Определения Icon.c:1408
void SetPosEx(bool refresh=true)
Определения Icon.c:1686
void SetTemperature()
Определения Icon.c:1233
void SetItemSizeEx(bool refresh=true)
Определения Icon.c:1395
void MouseClick(Widget w, int x, int y, int button)
Определения Icon.c:826
bool IsDragged()
Определения Icon.c:98
Widget GetSelectedWidget()
Определения Icon.c:83
int GetCargoPos()
Определения Icon.c:1079
Widget m_QuantityStack
Определения Icon.c:34
void DraggingOver(Widget w, int x, int y, Widget receiver)
Определения Icon.c:369
void UpdateFlip(bool flipped)
Определения Icon.c:1413
void SetSizeY(int y)
Определения Icon.c:1661
bool CombineItems(EntityAI entity1, EntityAI entity2)
Определения Icon.c:731
TextWidget m_QuantityItem
Определения Icon.c:32
ItemBase m_Item
Определения Icon.c:16
void RefreshIconPos()
Определения Icon.c:1238
void SetPosY(int y)
Определения Icon.c:1651
override void SetActive(bool active)
Определения Icon.c:103
void CheckHasQuantityEx(bool refresh=true)
Определения Icon.c:1630
bool m_IsMagazine
Определения Icon.c:10
void CheckHasTemperature()
Определения Icon.c:1622
bool m_HasQuantity
Определения Icon.c:12
int GetSizeY()
Определения Icon.c:1681
bool m_HandsIcon
Определения Icon.c:17
EntityAI m_Obj
Определения Icon.c:15
void SetSize(int x, int y)
Определения Icon.c:1067
void CheckIsMagazine()
Определения Icon.c:1617
void RefreshPos(int row, int column)
Определения Icon.c:1255
int m_SizeX
Определения Icon.c:3
void OnPerformCombination(int combinationFlags)
Определения Icon.c:454
void SetPos(int x, int y)
Определения Icon.c:1073
const int NUMBER_OF_TIMERS
Определения Icon.c:22
Object GetObject()
Определения Icon.c:1266
void CheckIsWeapon()
Определения Icon.c:1505
void ~Icon()
Определения Icon.c:66
void DestroyWhiteBackground()
Определения Icon.c:1090
Widget GetMicromanagedPanel()
Определения Icon.c:93
void Icon(LayoutHolder parent, bool hands_icon=false)
Определения Icon.c:42
void SetSort(int index)
Определения Icon.c:1371
Widget m_CursorWidget
Определения Icon.c:29
void SetQuantity()
Определения Icon.c:1322
void SetItemPreviewEx(bool refresh=true)
Определения Icon.c:1382
void Swap(Widget w, int x, int y, Widget receiver)
Определения Icon.c:976
void SetItemPreview()
Определения Icon.c:1390
void DropReceivedFromMain(Widget w, int x, int y, Widget receiver)
Определения Icon.c:887
ProgressBarWidget m_QuantityProgress
Определения Icon.c:33
int m_CargoPos
Определения Icon.c:18
int GetSort()
Определения Icon.c:1377
bool MouseLeave(Widget w, Widget s, int x, int y)
Определения Icon.c:359
float m_CurrQuantity
Определения Icon.c:13
TextWidget m_ItemSizeWidget
Определения Icon.c:37
EntityAI m_Lock
Определения Icon.c:8
ref array< ImageWidget > m_AmmoIcons
Определения Icon.c:39
void SetPos()
Определения Icon.c:1720
void CreateWhiteBackground()
Определения Icon.c:1117
ItemPreviewWidget m_ItemPreview
Определения Icon.c:24
int GetPosX()
Определения Icon.c:1666
int GetSizeX()
Определения Icon.c:1676
void SetSizeX(int x)
Определения Icon.c:1656
void InitLock(EntityAI parent, EntityAI obj, int x_pos, int y_pos, bool flip)
Определения Icon.c:1426
override void UpdateInterval()
Определения Icon.c:1755
void RefreshMuzzleIcon()
Определения Icon.c:1271
bool FlagAction(EntityAI entity1, EntityAI entity2, int combinationFlags)
Определения Icon.c:737
void Combine(Widget w, int x, int y, Widget receiver)
Определения Icon.c:704
void InitEx(EntityAI obj, bool refresh=true)
Определения Icon.c:1447
bool PerformCombination(EntityAI selectedEntity, EntityAI targetEntity, int combinationFlag, InventoryLocation ilSwapDst=null)
Определения Icon.c:518
void CheckHasQuantity()
Определения Icon.c:1641
bool m_IsDragged
Определения Icon.c:19
void Init(EntityAI obj)
Определения Icon.c:1500
void RefreshQuickbar()
Определения Icon.c:149
ImageWidget m_AmmoTypeIcon
Определения Icon.c:40
int m_SizeY
Определения Icon.c:4
void DropReceivedFromBackground(Widget w, int x, int y, Widget reciever)
Определения Icon.c:1182
int m_PosY
Определения Icon.c:6
bool m_IsWeapon
Определения Icon.c:9
void CheckIsMagazineEx(bool refresh=true)
Определения Icon.c:1579
Определения IconsContainer.c:2
static const int FSWAP
Определения InventoryCombinationFlags.c:7
static const int PERFORM_ACTION
Определения InventoryCombinationFlags.c:15
static const int ADD_AS_CARGO
Определения InventoryCombinationFlags.c:5
static const int ATTACH_MAGAZINE
Определения InventoryCombinationFlags.c:18
static const int NONE
Определения InventoryCombinationFlags.c:3
static const int SWAP_MAGAZINE
Определения InventoryCombinationFlags.c:10
static const int SET_ACTION
Определения InventoryCombinationFlags.c:19
static const int ADD_AS_ATTACHMENT
Определения InventoryCombinationFlags.c:4
static const int COMBINE_QUANTITY2
Определения InventoryCombinationFlags.c:13
static const int SWAP
Определения InventoryCombinationFlags.c:6
Определения ItemBase.c:15
proto native bool IsValid()
verify current set inventory location
proto native EntityAI GetParent()
returns parent of current inventory location
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
proto native int GetType()
returns type of InventoryLocation
InventoryLocation.
Определения InventoryLocation.c:29
Определения InventoryItem.c:731
static int GetCombinationFlags(EntityAI entity1, EntityAI entity2)
Определения ItemManager.c:800
void SetSelectedItemEx(EntityAI selected_item, Container selected_container, LayoutHolder selected_icon)
Определения ItemManager.c:113
Widget GetCenterDropzone()
Определения ItemManager.c:351
Icon GetDraggedIcon()
Определения ItemManager.c:378
void ShowSourceDropzone(EntityAI item)
Определения ItemManager.c:302
Widget GetLeftDropzone()
Определения ItemManager.c:336
void SetIconTemperature(EntityAI item, Widget item_w)
Определения ItemManager.c:501
void SetDraggedItem(EntityAI dragged_item)
Определения ItemManager.c:363
Widget GetRightDropzone()
Определения ItemManager.c:344
void HideDropzones()
Определения ItemManager.c:287
void SetWidgetDraggable(Widget w, bool draggable)
Определения ItemManager.c:693
void SetDraggedIcon(Icon dragged_icon)
Определения ItemManager.c:373
void SetIsDragging(bool is_dragging)
Определения ItemManager.c:383
static int GetChosenCombinationFlag(EntityAI selectedEntity, EntityAI targetEntity, int relevantFlags, out InventoryLocation dst=null)
Определения ItemManager.c:719
static ItemManager GetInstance()
Определения ItemManager.c:282
Определения ItemManager.c:2
proto native EntityAI GetItem()
Определения gameplay.c:277
bool InspectItem()
Определения Container.c:387
Определения Container.c:2
Определения EnMath.c:7
Определения ObjectTyped.c:2
Определения PlayerBaseClient.c:2
static float GetItemQuantity(InventoryItem item)
Определения QuantityConversions.c:72
static int HasItemQuantity(notnull EntityAI item)
Определения QuantityConversions.c:143
static float GetItemQuantityMax(InventoryItem item)
Определения QuantityConversions.c:96
static string GetItemQuantityText(EntityAI item, bool showMax=false)
Определения QuantityConversions.c:3
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
Определения EnWidgets.c:220
override bool IsShowingChamberedBullet()
Определения Magnum.c:285
shorthand
Определения BoltActionRifle_Base.c:6
void RegisterOnDropReceived(Widget w, Managed eventHandler, string functionName)
Определения WidgetEventHandler.c:91
void RegisterOnMouseLeave(Widget w, Managed eventHandler, string functionName)
Определения WidgetEventHandler.c:126
void RegisterOnDraggingOver(Widget w, Managed eventHandler, string functionName)
Определения WidgetEventHandler.c:112
void RegisterOnDrag(Widget w, Managed eventHandler, string functionName)
Определения WidgetEventHandler.c:98
void RegisterOnDrop(Widget w, Managed eventHandler, string functionName)
Определения WidgetEventHandler.c:105
static WidgetEventHandler GetInstance()
Определения WidgetEventHandler.c:22
void RegisterOnMouseEnter(Widget w, Managed eventHandler, string functionName)
Определения WidgetEventHandler.c:119
void RegisterOnMouseButtonDown(Widget w, Managed eventHandler, string functionName)
Определения WidgetEventHandler.c:70
void RegisterOnDoubleClick(Widget w, Managed eventHandler, string functionName)
Определения WidgetEventHandler.c:140
Определения EnWidgets.c:190
const string IconWide
Определения WidgetLayoutName.c:30
const string IconMedium
Определения WidgetLayoutName.c:29
const string IconXbox
Определения WidgetLayoutName.c:31
const string IconNarrow
Определения WidgetLayoutName.c:28
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
const int QUANTITY_PROGRESS
Определения constants.c:516
const int QUANTITY_COUNT
Определения constants.c:515
const int QUANTITY_HIDDEN
Определения constants.c:514
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
Определения constants.c:180
MouseState
Определения EnSystem.c:311
proto void GetMousePos(out int x, out int y)
WidgetFlags
Определения EnWidgets.c:58
proto native Widget FindAnyWidget(string pathname)
int ARGB(int a, int r, int g, int b)
Определения proto.c:322
int ARGBF(float fa, float fr, float fg, float fb)
Converts <0.0, 1.0> ARGB into color.
Определения proto.c:332