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