DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
Icon.c
Go to the documentation of this file.
2{
3 protected int m_SizeX;
4 protected int m_SizeY;
5 protected int m_PosX;
6 protected int m_PosY;
7
8 protected EntityAI m_Lock;
9 protected bool m_IsWeapon = false;
10 protected bool m_IsMagazine = false;
11 protected bool m_HasTemperature = false;
12 protected bool m_HasQuantity = false;
13 protected float m_CurrQuantity = -1;
14
15 protected EntityAI m_Obj;
16 protected ItemBase m_Item;
17 protected bool m_HandsIcon;
18 protected int m_CargoPos;
19 protected bool m_IsDragged;
21
22 const int NUMBER_OF_TIMERS = 2;
23
25
28
31 protected ProgressBarWidget m_QuantityProgress;
33
36
38 protected ImageWidget m_AmmoTypeIcon;
39
40 void Icon( LayoutHolder parent, bool hands_icon = false )
41 {
42 m_HandsIcon = hands_icon;
43 ItemManager.GetInstance().SetSelectedItem( null, null, null, null );
44
45 m_ItemPreview = ItemPreviewWidget.Cast( GetMainWidget().FindAnyWidget( "Render" ) );
46
47 m_ColorWidget = GetMainWidget().FindAnyWidget( "Color" );
48 m_SelectedPanel = GetMainWidget().FindAnyWidget( "Selected" );
49
50 m_QuantityPanel = GetMainWidget().FindAnyWidget( "QuantityPanel" );
51 m_QuantityItem = TextWidget.Cast( GetMainWidget().FindAnyWidget( "Quantity" ) );
52 m_QuantityProgress = ProgressBarWidget.Cast( GetMainWidget().FindAnyWidget( "QuantityBar" ) );
53 m_QuantityStack = GetMainWidget().FindAnyWidget( "QuantityStackPanel" );
54
55 m_ItemSizePanel = GetMainWidget().FindAnyWidget( "ItemSizePanel" );
56 m_ItemSizeWidget = TextWidget.Cast( GetMainWidget().FindAnyWidget( "ItemSize" ) );
57
58 m_AmmoTypeIcon = ImageWidget.Cast( GetMainWidget().FindAnyWidget( "AmmoTypeIcon" ) );
59 SetActive( false );
60 }
61
62 void ~Icon()
63 {
64 if( m_Obj )
65 {
66 m_Obj.GetOnItemFlipped().Remove( UpdateFlip );
67 m_Obj.GetOnViewIndexChanged().Remove( SetItemPreview );
68 }
69
70 if( m_IsDragged)
71 {
75 m_IsDragged = false;
76 }
77 }
78
80 {
81 return m_SelectedPanel;
82 }
83
84 bool IsDragged()
85 {
86 return m_IsDragged;
87 }
88
89 override void SetActive( bool active )
90 {
91 super.SetActive( active );
92 if( active && GetObject() )
93 {
94 float x, y;
95 GetMainWidget().GetScreenPos( x, y );
96 PrepareOwnedTooltip( EntityAI.Cast( GetObject() ), -1, y );
97 }
98
99 m_SelectedPanel.Show( active );
100 }
101
102 override void SetParentWidget()
103 {
104 #ifndef PLATFORM_CONSOLE
105 if( m_Parent.IsInherited( HandsPreview ) )
106 {
107 super.SetParentWidget();
108 }
109 else
110 {
111 if( m_Parent != null )
112 {
113 CargoContainer grid_container = CargoContainer.Cast( m_Parent );
114 if( grid_container )
115 {
116 m_ParentWidget = grid_container.GetMainWidget();
117 }
118 }
119 }
120 #else
121 super.SetParentWidget();
122 #endif
123 }
124
126 {
127 InventoryMenu menu = InventoryMenu.Cast( GetGame().GetUIManager().FindMenu( MENU_INVENTORY ) );
128 HideOwnedTooltip();
129 if( menu )
130 {
131 menu.RefreshQuickbar();
132 }
133 }
134
135 void DoubleClick(Widget w, int x, int y, int button)
136 {
137 if( button == MouseState.LEFT && !g_Game.IsLeftCtrlDown())
138 {
139 PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
140 if( player.GetInventory().HasInventoryReservation( m_Obj, null ) || player.GetInventory().IsInventoryLocked() || player.IsItemsToDelete() )
141 {
142 return;
143 }
144
145 InventoryMenu menu = InventoryMenu.Cast( GetGame().GetUIManager().FindMenu( MENU_INVENTORY ) );
146 if( w == null )
147 {
148 return;
149 }
150 ItemPreviewWidget iw = ItemPreviewWidget.Cast( w.FindAnyWidget( "Render" ) );
151 if( !iw )
152 {
153 string name = w.GetName();
154 name.Replace( "PanelWidget", "Render" );
155 iw = ItemPreviewWidget.Cast( w.FindAnyWidget( name ) );
156 }
157
158 if( !iw )
159 {
160 iw = ItemPreviewWidget.Cast( w );
161 }
162
163 if( !iw.GetItem() )
164 {
165 return;
166 }
167
168 EntityAI item = iw.GetItem();
169
170 if( !item.GetInventory().CanRemoveEntity() )
171 return;
172
173 if( m_HandsIcon )
174 {
175 if( player.GetHumanInventory().CanRemoveEntityInHands() )
176 {
177 player.PredictiveMoveItemFromHandsToInventory();
178 }
179 HideOwnedTooltip();
180 if( menu )
181 {
182 menu.RefreshQuickbar();
183 }
184 return;
185 }
186
188 EntityAI hands_item = player.GetHumanInventory().GetEntityInHands();
189 EntityAI item_root_owner = item.GetHierarchyRoot();
190
191
192 if ( player.GetInventory().HasEntityInInventory( item ) && player.GetHumanInventory().CanAddEntityInHands( item ) )
193 {
194 player.PredictiveTakeEntityToHands( item );
195 }
196 else if ( hands_item && item_root_owner == GetGame().GetPlayer() )
197 {
199 hands_item.GetInventory().GetCurrentInventoryLocation(i1_hand);
200 int index = player.GetHumanInventory().FindUserReservedLocationIndex(hands_item);
201 if(index>=0)
202 {
203 player.GetHumanInventory().GetUserReservedLocation( index, i1);
204 }
205
206 if( player.GetInventory().CanForceSwapEntitiesEx( item, i1_hand, hands_item, i1 ) )
207 {
208 player.PredictiveForceSwapEntities( item, hands_item, i1);
209 }
210 else if( player.GetInventory().CanSwapEntitiesEx( item, hands_item ) )
211 {
212 player.PredictiveSwapEntities( item, hands_item );
213 }
214 }
215 else
216 {
217 bool found = false;
218 if( item.GetInventory().CanRemoveEntity())
219 {
221 found = player.GetInventory().FindFreeLocationFor( item, FindInventoryLocationType.ANY, i2 );
222 if( found )
223 {
224 if( i2.GetType() == FindInventoryLocationType.ATTACHMENT )
225 {
226 if( i2.GetParent() != player )
227 found = false;
228 }
229 }
230 }
231 if( found )
232 {
233 if(player.GetHumanInventory().CanAddEntityToInventory(item))
234 player.PredictiveTakeEntityToInventory(FindInventoryLocationType.ANY, item);
235 }
236 else
237 {
238 if( player.GetHumanInventory().CanAddEntityInHands( item ) )
239 {
240 player.PredictiveTakeEntityToHands( item );
241 }
242 }
243 }
244
245 HideOwnedTooltip();
246 if( menu )
247 {
248 menu.RefreshQuickbar();
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 receiver_ipw = ItemPreviewWidget.Cast( receiver.FindAnyWidget( "Render" ) );
264 if( m_HandsIcon )
265 {
266 receiver_ipw = ItemPreviewWidget.Cast( receiver.GetParent().FindAnyWidget( "Render" ) );
267 }
268
269 ItemPreviewWidget w_ipw = ItemPreviewWidget.Cast( w.FindAnyWidget( name ) );
270 if( w_ipw == null )
271 {
272 w_ipw = ItemPreviewWidget.Cast( w.FindAnyWidget( "Render" ) );
273 }
274
275 if( w_ipw == null )
276 {
277 return;
278 }
279
280 InventoryItem receiver_entity = InventoryItem.Cast( receiver_ipw.GetItem() );
281 InventoryItem w_entity = InventoryItem.Cast( w_ipw.GetItem() );
282 if ( !w_entity || !receiver_entity )
283 {
284 return;
285 }
286
289 receiver_entity.GetInventory().GetCurrentInventoryLocation(il_rec);
290 PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
291 int index = player.GetHumanInventory().FindUserReservedLocationIndex( m_Item );
292
293 if (index >= 0)
294 {
295 player.GetHumanInventory().GetUserReservedLocation( index, il );
296
297 if ( GameInventory.CanForceSwapEntitiesEx( w_entity, il_rec, receiver_entity, il ) )
298 {
301 ItemManager.GetInstance().GetCenterDropzone().SetAlpha( 1 );
302 }
303 else if ( GameInventory.CanSwapEntitiesEx( receiver_entity, w_entity ) )
304 {
307 ItemManager.GetInstance().GetCenterDropzone().SetAlpha( 1 );
308 }
309 else
310 {
313 }
314 }
315 else
316 {
317 if ( GameInventory.CanSwapEntitiesEx( receiver_entity, w_entity ) )
318 {
321 ItemManager.GetInstance().GetCenterDropzone().SetAlpha( 1 );
322 }
323 else if ( GameInventory.CanForceSwapEntitiesEx( w_entity, il_rec, receiver_entity, il ) )
324 {
327 ItemManager.GetInstance().GetCenterDropzone().SetAlpha( 1 );
328 }
329 else
330 {
333 }
334 }
335 }
336
337 void DraggingOverCombine( Widget w, int x, int y, Widget receiver )
338 {
339 if ( w == null )
340 {
341 return;
342 }
343
344 ItemPreviewWidget iw = ItemPreviewWidget.Cast( w.FindAnyWidget( "Render" ) );
345 if ( !iw )
346 {
347 string name = w.GetName();
348 name.Replace( "PanelWidget", "Render" );
349 iw = ItemPreviewWidget.Cast( w.FindAnyWidget( name ) );
350 }
351
352 if ( !iw )
353 {
354 iw = ItemPreviewWidget.Cast( w );
355 }
356
357 if ( !iw.GetItem() )
358 {
359 return;
360 }
361
362 int flags = ItemManager.GetCombinationFlags( GetGame().GetPlayer().GetHumanInventory().GetEntityInHands(), iw.GetItem() );
363 ShowActionMenuCombine( GetGame().GetPlayer().GetHumanInventory().GetEntityInHands(), iw.GetItem(), flags , w , true);
364 }
365
366 bool MouseEnter(Widget w, int x, int y)
367 {
368 if( !m_IsDragged )
369 {
370 PrepareOwnedTooltip( m_Obj, x, y );
371 m_SelectedPanel.Show( true );
372 }
373
374 return true;
375 }
376
377 bool MouseLeave( Widget w, Widget s, int x, int y )
378 {
379 HideOwnedTooltip();
380 if( !m_IsDragged )
381 {
382 m_SelectedPanel.Show( false );
383 }
384 return true;
385 }
386
387 void DraggingOver( Widget w, int x, int y, Widget receiver )
388 {
390
391 if( w == null )
392 {
393 return;
394 }
395 string name = w.GetName();
396 name.Replace( "PanelWidget", "Render" );
397
398 ItemPreviewWidget receiver_ipw = ItemPreviewWidget.Cast( receiver.FindAnyWidget( "Render" ) );
399 if( m_HandsIcon )
400 {
401 receiver_ipw = ItemPreviewWidget.Cast( receiver.GetParent().FindAnyWidget( "Render" ) );
402 }
403
404 ItemPreviewWidget w_ipw = ItemPreviewWidget.Cast( w.FindAnyWidget( name ) );
405 if( w_ipw == null )
406 {
407 w_ipw = ItemPreviewWidget.Cast( w.FindAnyWidget( "Render" ) );
408 }
409 if( w_ipw == null )
410 {
411 return;
412 }
413
414 PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
415 InventoryItem receiver_entity = InventoryItem.Cast( receiver_ipw.GetItem() );
416 InventoryItem w_entity = InventoryItem.Cast( w_ipw.GetItem() );
417 InventoryLocation loc_dst;
418 if (!receiver_entity || !w_entity)
419 {
420 return;
421 }
422
424 receiver_entity.GetInventory().GetCurrentInventoryLocation(i1_rec);
425
426 if( m_Lock )
427 {
428 if( receiver_entity == w_entity )
429 {
431 ItemManager.GetInstance().GetRightDropzone().SetAlpha( 1 );
432 }
433 else
434 {
435 CargoContainer c_parent = CargoContainer.Cast( m_Parent );
436
437 float parent_x;
438 float parent_y;
439
440
441 c_parent.GetRootWidget().GetScreenPos( parent_x, parent_y );
442
443 float icon_size = c_parent.GetIconSize();
444 float space_size = c_parent.GetSpaceSize();
445
446 int PosX = (x-parent_x) / (icon_size + space_size);
447 int PosY = (y-parent_y) / (icon_size + space_size);
448
449 //Print("X: " + GetPosX() + " or " + PosX + " ;Y: " + GetPosY() + " or " + PosY);
450
451 EntityAI parent = m_Lock;
452 CargoBase target_cargo = parent.GetInventory().GetCargo();
453
454 loc_dst = new InventoryLocation();
455 loc_dst.SetCargoAuto(target_cargo, w_entity, PosY, PosX, w_entity.GetInventory().GetFlipCargo());
456
457 if( parent.GetInventory().LocationCanAddEntity(loc_dst))
458 {
460 ItemManager.GetInstance().GetRightDropzone().SetAlpha( 1 );
461 }
462 else
463 {
466 }
467 }
468 }
469 else if( ( ItemBase.Cast( receiver_entity ) ).CanBeCombined( ItemBase.Cast( w_entity ) ) )
470 {
472 if( m_Obj.GetHierarchyRootPlayer() == player )
473 {
474 ItemManager.GetInstance().GetRightDropzone().SetAlpha( 1 );
475 }
476 else if( !m_HandsIcon )
477 {
478 ItemManager.GetInstance().GetLeftDropzone().SetAlpha( 1 );
479 }
480 }
481 else
482 {
483 Magazine mag = Magazine.Cast(w_entity);
484 Weapon_Base wpn = Weapon_Base.Cast(w_entity.GetHierarchyParent());
485 EntityAI w_hierarchyParent = w_entity.GetHierarchyParent();
486 EntityAI receiver_hierarchyParent = w_entity.GetHierarchyParent();
487 if ( wpn && mag )
488 {
489 if( player.GetWeaponManager().CanSwapMagazine( wpn, Magazine.Cast(receiver_entity) ) )
490 {
492 if( m_Obj.GetHierarchyRootPlayer() == player )
493 {
494 ItemManager.GetInstance().GetRightDropzone().SetAlpha( 1 );
495 }
496 else if( !m_HandsIcon )
497 {
498 ItemManager.GetInstance().GetLeftDropzone().SetAlpha( 1 );
499 }
500 }
501 else
502 {
505 }
506 }
507 else if ((w_hierarchyParent && (w_hierarchyParent.IsInherited(FenceKit) || w_hierarchyParent.IsInherited(WatchtowerKit))) || (receiver_hierarchyParent && (receiver_hierarchyParent.IsInherited(FenceKit) || receiver_hierarchyParent.IsInherited(WatchtowerKit))))
508 {
511 }
512 else
513 {
515 if (GameInventory.CanSwapEntitiesEx( receiver_entity, w_entity ))
516 {
518 if (m_Obj.GetHierarchyRootPlayer() == player)
519 {
520 ItemManager.GetInstance().GetRightDropzone().SetAlpha( 1 );
521 }
522 else if (!m_HandsIcon)
523 {
524 ItemManager.GetInstance().GetLeftDropzone().SetAlpha( 1 );
525 }
526 }
527 else if ( GameInventory.CanForceSwapEntitiesEx( w_entity, i1_rec, receiver_entity, il ) )
528 {
530 if (m_Obj.GetHierarchyRootPlayer() == player)
531 {
532 ItemManager.GetInstance().GetRightDropzone().SetAlpha( 1 );
533 }
534 else if (!m_HandsIcon)
535 {
536 ItemManager.GetInstance().GetLeftDropzone().SetAlpha( 1 );
537 }
538 }
539 else
540 {
543 }
544 }
545 }
546 }
547
548 void OnPerformCombination( int combinationFlags )
549 {
551 if( m_am_entity1 == null || m_am_entity2 == null ) return;
552
553 if( combinationFlags == InventoryCombinationFlags.NONE ) return;
554
555 Weapon_Base wpn;
556 Magazine mag;
557
558 if( combinationFlags & InventoryCombinationFlags.LOAD_CHAMBER )
559 {
560 if( Class.CastTo(wpn, m_am_entity1 ) && Class.CastTo(mag, m_am_entity2 ) )
561 {
562 if( m_player.GetWeaponManager().CanLoadBullet(wpn, mag) )
563 {
565 return;
566 }
567 }
568 }
569 if( combinationFlags & InventoryCombinationFlags.ADD_AS_ATTACHMENT )
570 {
571 float stackable = m_am_entity2.GetTargetQuantityMax(-1);
572
573 if ( stackable == 0 || stackable >= m_am_entity2.GetQuantity() )
574 {
575 m_player.PredictiveTakeEntityToTargetAttachment(m_am_entity1, m_am_entity2);
576 }
577 else
578 {
580 m_am_entity1.GetInventory().FindFreeLocationFor( m_am_entity2, FindInventoryLocationType.ATTACHMENT, il );
581 ItemBase.Cast(m_am_entity2).SplitIntoStackMaxToInventoryLocationClient( il );
582 }
583 }
584 if( combinationFlags & InventoryCombinationFlags.ADD_AS_CARGO )
585 {
586 SplitItemUtils.TakeOrSplitToInventory(m_player, m_am_entity1, m_am_entity2);
587 }
588 if( combinationFlags & InventoryCombinationFlags.SWAP )
589 {
590 if( !m_player.PredictiveSwapEntities( m_am_entity1, m_am_entity2 ) && m_player.GetHumanInventory().CanAddEntityInHands( m_am_entity2 ) )
591 {
592 m_player.PredictiveTakeEntityToHands( m_am_entity2 );
593 }
594 }
595 if( combinationFlags & InventoryCombinationFlags.TAKE_TO_HANDS )
596 {
597 if( m_player.GetHumanInventory().CanAddEntityInHands( m_am_entity2 ) )
598 {
599 m_player.PredictiveTakeEntityToHands( m_am_entity2 );
600 }
601 }
602 if( combinationFlags & InventoryCombinationFlags.PERFORM_ACTION )
603 {
605 Class.CastTo(amc, m_player.GetActionManager());
606
607 if( m_am_entity1 == m_player.GetHumanInventory().GetEntityInHands() )
608 {
609 amc.PerformActionFromInventory(ItemBase.Cast( m_am_entity1 ),ItemBase.Cast( m_am_entity2 ));
610 }
611 else
612 {
613 amc.PerformActionFromInventory(ItemBase.Cast( m_am_entity2 ),ItemBase.Cast( m_am_entity1 ));
614 }
615 }
616 if( combinationFlags & InventoryCombinationFlags.SET_ACTION )
617 {
619 Class.CastTo(amc2, m_player.GetActionManager());
620
621 if( m_am_entity1 == m_player.GetHumanInventory().GetEntityInHands() )
622 {
623 amc2.SetActionFromInventory(ItemBase.Cast( m_am_entity1 ),ItemBase.Cast( m_am_entity2 ));
624 }
625 else
626 {
627 amc2.SetActionFromInventory(ItemBase.Cast( m_am_entity2 ),ItemBase.Cast( m_am_entity1 ));
628 }
629 }
630 }
631
632
633
634
635
636 void ShowActionMenuCombine( EntityAI entity1, EntityAI entity2, int combinationFlags, Widget w , bool color_test )
637 {
638 int current_flag;
639 ContextMenu cmenu = ContextMenu.Cast(GetGame().GetUIManager().GetMenu().GetContextMenu());
640 m_am_entity1 = entity1;
641 m_am_entity2 = entity2;
642 cmenu.Hide();
643 cmenu.Clear();
644 int id = -1;
645
646 if ( entity1 == null || entity2 == null ) return;
647
648 if ( combinationFlags == InventoryCombinationFlags.NONE )
649 {
650 if ( color_test )
651 {
654 }
655 return;
656 }
657
658 if ( combinationFlags & InventoryCombinationFlags.ADD_AS_ATTACHMENT )
659 {
661 cmenu.Add( "#inv_context_add_as_attachment", this, "OnPerformCombination", new Param1<int>( current_flag ) );
662 }
663 if ( combinationFlags & InventoryCombinationFlags.LOAD_CHAMBER )
664 {
666 cmenu.Add( "#inv_context_load_chamber", this, "OnPerformCombination", new Param1<int>( current_flag ) );
667 }
668 if (combinationFlags & InventoryCombinationFlags.ATTACH_MAGAZINE)
669 {
671 cmenu.Add("#inv_context_attach_magazine", this, "OnPerformCombination", new Param1<int>( current_flag ) );
672 }
673
674 if ( combinationFlags & InventoryCombinationFlags.ADD_AS_CARGO && !(combinationFlags & InventoryCombinationFlags.SET_ACTION) )
675 {
677 cmenu.Add( "#inv_context_add_as_cargo", this, "OnPerformCombination", new Param1<int>( current_flag ) );
678 }
679
680 if ( combinationFlags & InventoryCombinationFlags.SWAP )
681 {
682 current_flag = InventoryCombinationFlags.SWAP;
683 cmenu.Add( "#inv_context_swap", this, "OnPerformCombination", new Param1<int>( current_flag ) );
684 }
685
686 if ( combinationFlags & InventoryCombinationFlags.COMBINE_QUANTITY )
687 {
689 cmenu.Add( "#inv_context_combine", this, "OnPerformCombination", new Param1<int>( current_flag ) );
690 }
691
692 if (combinationFlags & InventoryCombinationFlags.SET_ACTION)
693 {
695 cmenu.Add("#inv_context_attach_magazine", this, "OnPerformCombination", new Param1<int>( current_flag ) );
696 }
697
698 if (combinationFlags & InventoryCombinationFlags.PERFORM_ACTION)
699 {
701 cmenu.Add("Perform action", this, "OnPerformCombination", new Param1<int>( current_flag ) );
702 }
703
704 int m_am_Pos_x, m_am_Pos_y;
705 GetMousePos( m_am_Pos_x, m_am_Pos_y );
706 m_am_Pos_x -= 5;
707 m_am_Pos_y -= 5;
708
709 if ( color_test )
710 {
712 ItemManager.GetInstance().GetCenterDropzone().SetAlpha( 1 );
714 }
715 /*if( combinationFlags & InventoryCombinationFlags.RECIPE_HANDS || combinationFlags & InventoryCombinationFlags.RECIPE_ANYWHERE )
716 {
717 if( !color_test )
718 {
719 OnPerformRecipe( id );
720 return;
721 }
722 }
723 else*/ if ( cmenu.Count() >= 1 )
724 {
725 if ( !color_test )
726 {
727 OnPerformCombination( current_flag );
728 return;
729 }
730 }
731 else if ( combinationFlags & InventoryCombinationFlags.COMBINE_QUANTITY2 )
732 {
733 if ( color_test )
734 {
737 ItemManager.GetInstance().GetCenterDropzone().SetAlpha( 1 );
738 }
739 else
740 {
741 ItemBase entity = ItemBase.Cast( entity1 );
742 entity.CombineItemsClient( ItemBase.Cast( entity2 ) );
743 }
744 return;
745 }
746 else
747 {
748 if ( color_test )
749 {
752 }
753 /* else
754 {
755 cmenu.Show( m_am_Pos_x, m_am_Pos_y );
756 }*/
757 }
758 }
759
760 void OnPerformRecipe(int id)
761 {
762 if ( m_am_entity1 == null || m_am_entity2 == null ) return;
763
764 Debug.Log("OnPerformRecipe called for id:"+id.ToString(),"recipes");
765 PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
766 player.GetCraftingManager().SetInventoryCraft( id, ItemBase.Cast( m_am_entity1 ), ItemBase.Cast( m_am_entity2 ) );
767 }
768
769 void Combine( Widget w, int x, int y, Widget receiver )
770 {
773 ItemPreviewWidget iw = ItemPreviewWidget.Cast( w.FindAnyWidget( "Render" ) );
774 if ( !iw )
775 {
776 string name = w.GetName();
777 name.Replace( "PanelWidget", "Render" );
778 iw = ItemPreviewWidget.Cast( w.FindAnyWidget( name ) );
779 }
780 if ( !iw )
781 {
782 iw = ItemPreviewWidget.Cast( w );
783 }
784 if ( !iw.GetItem() )
785 {
786 return;
787 }
788
789 int flags = ItemManager.GetCombinationFlags( GetGame().GetPlayer().GetHumanInventory().GetEntityInHands(), iw.GetItem() );
790 ShowActionMenuCombine( GetGame().GetPlayer().GetHumanInventory().GetEntityInHands(), iw.GetItem(), flags , w, false );
791
792 }
793
794 bool CombineItems( EntityAI entity1, EntityAI entity2 )
795 {
796 int flags = ItemManager.GetCombinationFlags( entity1, entity2 );
797 return FlagAction( entity1, entity2, flags );
798 }
799
800 bool FlagAction( EntityAI entity1, EntityAI entity2, int combinationFlags )
801 {
802 int current_flag;
803 ContextMenu cmenu = ContextMenu.Cast(GetGame().GetUIManager().GetMenu().GetContextMenu());
804 m_am_entity1 = entity1;
805 m_am_entity2 = entity2;
806 cmenu.Hide();
807 cmenu.Clear();
808 int id = -1;
809
810 if( combinationFlags & InventoryCombinationFlags.COMBINE_QUANTITY2 )
811 {
812 ItemBase entity = ItemBase.Cast( entity1 );
813 entity.CombineItemsClient( ItemBase.Cast( entity2 ) );
814 return false;
815 }
816
817 if( entity1 == null || entity2 == null || combinationFlags == InventoryCombinationFlags.NONE )
818 return true;
819
820 if( combinationFlags & InventoryCombinationFlags.ADD_AS_ATTACHMENT )
821 {
823 cmenu.Add( "#inv_context_add_as_attachment", this, "OnPerformCombination", new Param1<int>( current_flag ) );
824 }
825 if( combinationFlags & InventoryCombinationFlags.LOAD_CHAMBER )
826 {
828 cmenu.Add( "#inv_context_load_chamber", this, "OnPerformCombination", new Param1<int>( current_flag ) );
829 }
830 if(combinationFlags & InventoryCombinationFlags.ATTACH_MAGAZINE)
831 {
833 cmenu.Add("#inv_context_attach_magazine", this, "OnPerformCombination", new Param1<int>( current_flag ) );
834 }
835
836 if( combinationFlags & InventoryCombinationFlags.ADD_AS_CARGO )
837 {
839 cmenu.Add( "#inv_context_add_as_cargo", this, "OnPerformCombination", new Param1<int>( current_flag ) );
840 }
841
842 if( combinationFlags & InventoryCombinationFlags.SWAP )
843 {
844 current_flag = InventoryCombinationFlags.SWAP;
845 cmenu.Add( "#inv_context_swap", this, "OnPerformCombination", new Param1<int>( current_flag ) );
846 }
847
848 if( combinationFlags & InventoryCombinationFlags.COMBINE_QUANTITY )
849 {
851 cmenu.Add( "#inv_context_combine", this, "OnPerformCombination", new Param1<int>( current_flag ) );
852 }
853
854 if(combinationFlags & InventoryCombinationFlags.SET_ACTION)
855 {
857 cmenu.Add("#inv_context_attach_magazine", this, "OnPerformCombination", new Param1<int>( current_flag ) );
858 }
859
860 if(combinationFlags & InventoryCombinationFlags.PERFORM_ACTION)
861 {
863 cmenu.Add("Perform Action2", this, "OnPerformCombination", new Param1<int>( current_flag ) );
864 }
865
866 int m_am_Pos_x, m_am_Pos_y;
867 GetMousePos( m_am_Pos_x, m_am_Pos_y );
868 m_am_Pos_x -= 5;
869 m_am_Pos_y -= 5;
870
871 MissionGameplay mission = MissionGameplay.Cast( GetGame().GetMission() );
872 /*if( combinationFlags & InventoryCombinationFlags.RECIPE_HANDS || combinationFlags & InventoryCombinationFlags.RECIPE_ANYWHERE )
873 {
874 OnPerformRecipe( id );
875 return true;
876 }
877 else /*if( cmenu.Count() == 1 )*/
878 //{
879 OnPerformCombination( current_flag );
880 return true;
881 //}
882 /*else
883 {
884 cmenu.Show( m_am_Pos_x, m_am_Pos_y );
885 return true;
886 }*/
887 }
888
889 void MouseClick( Widget w, int x, int y, int button )
890 {
891 if ( button == MouseState.RIGHT )
892 {
893 if ( m_Lock )
894 {
895 GetGame().GetPlayer().GetHumanInventory().ClearUserReservedLocationSynced( m_Item );
896 }
897 else
898 {
899 if ( m_Item && m_Item.IsItemBase() )
900 {
901 m_Item.OnRightClick();
902
903 if ( m_HasQuantity )
904 SetQuantity();
905 #ifdef DIAG_DEVELOPER
906 if ( GetDayZGame().IsLeftCtrlDown() )
907 ShowActionMenu( m_Item );
908 #endif
909 }
910 }
911
912 }
913 else if (!m_Lock)
914 {
915 if ( button == MouseState.MIDDLE )
916 {
918 }
919 else if ( button == MouseState.LEFT )
920 {
921 PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
922 if (g_Game.IsLeftCtrlDown())
923 {
924 if ( player && player.CanDropEntity( m_Item ) )
925 {
926 if ( m_Item.GetTargetQuantityMax() < m_Item.GetQuantity() )
927 m_Item.SplitIntoStackMaxClient( null, -1 );
928 else
929 {
930 player.PhysicalPredictiveDropItem( m_Item );
931 }
933 }
934 }
935 else
936 {
938 m_Obj.GetInventory().GetCurrentInventoryLocation( il );
939
940 bool draggable = !player.GetInventory().HasInventoryReservation( m_Obj, null ) && !player.GetInventory().IsInventoryLocked() && !player.IsItemsToDelete();
941 draggable = draggable && ( m_Obj.GetHierarchyRoot() && m_Obj.GetInventory().CanRemoveEntity() || !m_Obj.GetHierarchyRoot() && AttachmentsOutOfReach.IsAttachmentReachable( m_Obj, "", il.GetSlot() ) );
942
943 ItemManager.GetInstance().SetWidgetDraggable( w, draggable );
944 }
945 }
946 }
947 }
948
949 void DropReceivedFromMain( Widget w, int x, int y, Widget receiver )
950 {
953 string name = w.GetName();
954 name.Replace( "PanelWidget", "Render" );
955 PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
956
957 ItemPreviewWidget receiver_ipw = ItemPreviewWidget.Cast( receiver.FindAnyWidget( "Render" ) );
958 if( m_HandsIcon )
959 {
960 receiver_ipw = ItemPreviewWidget.Cast( receiver.GetParent().FindAnyWidget( "Render" ) );
961 }
962
963 ItemPreviewWidget w_ipw = ItemPreviewWidget.Cast( w.FindAnyWidget( name ) );
964 if( w_ipw == null )
965 {
966 w_ipw = ItemPreviewWidget.Cast( w.FindAnyWidget( "Render" ) );
967 }
968 if( w_ipw == null )
969 {
970 return;
971 }
972
973 InventoryItem receiver_entity = InventoryItem.Cast( receiver_ipw.GetItem() );
974 InventoryItem w_entity = InventoryItem.Cast( w_ipw.GetItem() );
975 if( !w_entity )
976 {
977 return;
978 }
979 int index;
980 InventoryLocation loc_src;
981 InventoryLocation loc_dst;
982 if( m_Lock && receiver_entity == w_entity )
983 {
984 index = player.GetHumanInventory().FindUserReservedLocationIndex( m_Item );
985 loc_src = new InventoryLocation;
986 loc_dst = new InventoryLocation;
987
988 m_Item.GetInventory().GetCurrentInventoryLocation( loc_src );
989 player.GetHumanInventory().GetUserReservedLocation( index, loc_dst );
990
991 if(loc_dst.GetParent().GetInventory().LocationCanAddEntity(loc_dst))
992 {
993
994 player.GetHumanInventory().ClearUserReservedLocation( m_Item );
995 player.PredictiveTakeToDst( loc_src, loc_dst );
996 m_Item.GetOnReleaseLock().Invoke(m_Item);
997 }
998 }
999 else if( m_Lock )
1000 {
1001 CargoContainer c_parent = CargoContainer.Cast( m_Parent );
1002
1003 float parent_x;
1004 float parent_y;
1005
1006
1007 c_parent.GetRootWidget().GetScreenPos( parent_x, parent_y );
1008
1009 float icon_size = c_parent.GetIconSize();
1010 float space_size = c_parent.GetSpaceSize();
1011
1012 int PosX = (x-parent_x) / (icon_size + space_size);
1013 int PosY = (y-parent_y) / (icon_size + space_size);
1014
1015 //Print("X: " + GetPosX() + " or " + PosX + " ;Y: " + GetPosY() + " or " + PosY);
1016
1017 EntityAI parent = m_Lock;
1018 CargoBase target_cargo = parent.GetInventory().GetCargo();
1019
1020 loc_dst = new InventoryLocation();
1021 loc_dst.SetCargoAuto(target_cargo, w_entity, PosY, PosX, w_entity.GetInventory().GetFlipCargo());
1022
1023
1024 if( parent.GetInventory().LocationCanAddEntity(loc_dst))
1025 {
1026 player.GetHumanInventory().ClearUserReservedLocation( m_Item );
1027 m_Item.GetOnReleaseLock().Invoke(m_Item);
1028
1030 }
1031
1032 //player.PredictiveTakeEntityToCargoEx( w_entity, loc_dst.GetIdx(), loc_dst.GetRow(), loc_dst.GetCol() );
1033 }
1034 else
1035 {
1036 if( ( ItemBase.Cast( receiver_entity ) ).CanBeCombined( ItemBase.Cast( w_entity ) ) )
1037 {
1038 ( ItemBase.Cast( receiver_entity ) ).CombineItemsClient( ItemBase.Cast( w_entity ) );
1039 }
1040 else
1041 {
1042 Magazine mag = Magazine.Cast(w_entity);
1043 Weapon_Base wpn = Weapon_Base.Cast(w_entity.GetHierarchyParent());
1044
1045 if( wpn && mag )
1046 {
1047 if( player.GetWeaponManager().CanSwapMagazine( wpn, Magazine.Cast(receiver_entity) ) )
1048 player.GetWeaponManager().SwapMagazine( Magazine.Cast(receiver_entity) );
1049 //return;
1050 }
1051 else
1052 {
1053 if( GameInventory.CanSwapEntitiesEx( w_entity, receiver_entity ) )
1054 {
1055 player.PredictiveSwapEntities( w_entity, receiver_entity );
1056
1058 if( m_Parent && m_Parent.IsInherited( IconsContainer ) )
1059 {
1060 ToRefresh( this, icon );
1061 }
1062 }
1063 else
1064 {
1065 loc_src = new InventoryLocation;
1066 loc_dst = new InventoryLocation;
1067
1068 InventoryLocation loc_temp = new InventoryLocation;
1069
1070 w_entity.GetInventory().GetCurrentInventoryLocation(loc_src);
1071 w_entity.GetInventory().GetCurrentInventoryLocation(loc_temp);
1072 receiver_entity.GetInventory().GetCurrentInventoryLocation(loc_dst);
1073
1074 loc_src.CopyLocationFrom(loc_dst,false);
1075 loc_src.SetFlip(w_entity.GetInventory().GetFlipCargo());
1076
1077 loc_dst.CopyLocationFrom(loc_temp,false);
1078
1079 if (w_entity.IsInherited(Rope) && loc_dst.GetType() == InventoryLocationType.ATTACHMENT)
1080 return;
1081
1082 if( GameInventory.CanForceSwapEntitiesEx( w_entity, loc_src, receiver_entity, loc_dst ) )
1083 {
1084 player.PredictiveForceSwapEntities( w_entity, receiver_entity, loc_dst );
1085 }
1086 }
1087 }
1088 }
1089 }
1090
1091 }
1092
1093 void Swap( Widget w, int x, int y, Widget receiver )
1094 {
1097 string name = w.GetName();
1098 name.Replace( "PanelWidget", "Render" );
1099
1100 ItemPreviewWidget receiver_ipw = ItemPreviewWidget.Cast( receiver.FindAnyWidget( "Render" ) );
1101 if (m_HandsIcon)
1102 {
1103 receiver_ipw = ItemPreviewWidget.Cast( receiver.GetParent().FindAnyWidget( "Render" ) );
1104 }
1105
1106 ItemPreviewWidget w_ipw = ItemPreviewWidget.Cast( w.FindAnyWidget( name ) );
1107 if (w_ipw == null)
1108 {
1109 w_ipw = ItemPreviewWidget.Cast( w.FindAnyWidget( "Render" ) );
1110 }
1111 if (w_ipw == null)
1112 {
1113 return;
1114 }
1115
1116 InventoryItem receiver_entity = InventoryItem.Cast( receiver_ipw.GetItem() );
1117 InventoryItem w_entity = InventoryItem.Cast( w_ipw.GetItem() );
1118 if (!w_entity || !receiver_entity)
1119 {
1120 return;
1121 }
1122
1123 PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
1124 EntityAI item_in_hands = player.GetHumanInventory().GetEntityInHands();
1125 Weapon_Base wpn;
1126 Magazine mag;
1127
1128 if (Class.CastTo(wpn, item_in_hands ) && Class.CastTo(mag, w_entity ) && Class.CastTo(wpn, mag.GetHierarchyParent() ))
1129 {
1130 return;
1131 }
1132
1133 InventoryLocation il_fswap = new InventoryLocation;
1135 receiver_entity.GetInventory().GetCurrentInventoryLocation(il_rec);
1137
1138 int index = player.GetHumanInventory().FindUserReservedLocationIndex(receiver_entity);
1139 if (index>=0)
1140 {
1141 player.GetHumanInventory().GetUserReservedLocation( index, il_fswap);
1142
1143 if (GameInventory.CanForceSwapEntitiesEx( w_entity, il_rec, receiver_entity, il_fswap ))
1144 {
1145 if (m_HandsIcon && !player.GetInventory().HasInventoryReservation( item_in_hands, null ) && !player.IsItemsToDelete())
1146 {
1147 GetGame().GetPlayer().PredictiveForceSwapEntities( w_entity, receiver_entity, il_fswap );
1148 }
1149 }
1150 else
1151 {
1152 if (GameInventory.CanSwapEntitiesEx( w_entity, receiver_entity ) )
1153 {
1154 if (!player.GetInventory().HasInventoryReservation( item_in_hands, null ) && !player.IsItemsToDelete())
1155 {
1156 GetGame().GetPlayer().PredictiveSwapEntities( w_entity, receiver_entity );
1157
1158 if (m_Parent.IsInherited( IconsContainer ))
1159 {
1160 ToRefresh( this, icon );
1161 }
1162 }
1163 }
1164 }
1165 }
1166 else
1167 {
1168 if (GameInventory.CanSwapEntitiesEx( w_entity, receiver_entity ) )
1169 {
1170 if( !player.GetInventory().HasInventoryReservation( item_in_hands, null ) && !player.IsItemsToDelete())
1171 {
1172 GetGame().GetPlayer().PredictiveSwapEntities( w_entity, receiver_entity );
1173
1174 if( m_Parent.IsInherited( IconsContainer ) )
1175 {
1176 ToRefresh( this, icon );
1177 }
1178 }
1179 }
1180 else if (GameInventory.CanForceSwapEntitiesEx( w_entity, il_rec, receiver_entity, il_fswap ))
1181 {
1182 if (m_HandsIcon && !player.GetInventory().HasInventoryReservation( item_in_hands, null ) && !player.IsItemsToDelete())
1183 {
1184 GetGame().GetPlayer().PredictiveForceSwapEntities( w_entity, receiver_entity, il_fswap );
1185 }
1186 }
1187 }
1188 }
1189
1190 void ToRefresh( Icon icon, Icon icon2 )
1191 {
1192 ( IconsContainer.Cast( m_Parent ) ).RemoveItem( icon );
1193 ( IconsContainer.Cast( m_Parent ) ).RemoveItem( icon2 );
1194 }
1195
1196 override void SetLayoutName()
1197 {
1198 #ifdef PLATFORM_CONSOLE
1199 m_LayoutName = WidgetLayoutName.IconXbox;
1200 #else
1201 switch( InventoryMenu.GetWidthType() )
1202 {
1203 case ScreenWidthType.NARROW:
1204 {
1205 m_LayoutName = WidgetLayoutName.IconNarrow;
1206 break;
1207 }
1208 case ScreenWidthType.MEDIUM:
1209 {
1210 m_LayoutName = WidgetLayoutName.IconMedium;
1211 break;
1212 }
1213 case ScreenWidthType.WIDE:
1214 {
1215 m_LayoutName = WidgetLayoutName.IconWide;
1216 break;
1217 }
1218 }
1219 #endif
1220
1221 }
1222
1223 void SetSize( int x, int y )
1224 {
1225 m_SizeX = x;
1226 m_SizeY = y;
1227 }
1228
1229 void SetPos( int x, int y )
1230 {
1231 m_PosX = x;
1232 m_PosY = y;
1233 }
1234
1236 {
1237 return m_CargoPos;
1238 }
1239
1240 void SetCargoPos( int x )
1241 {
1242 GetMainWidget().SetSort( x );
1243 m_CargoPos = x;
1244 }
1245
1247 {
1250 m_IsDragged = false;
1251
1253
1254 if ( m_HandsIcon )
1255 {
1258 Refresh();
1259 FullScreen();
1260 }
1261
1262 m_SelectedPanel.SetColor( ARGBF( 1, 1, 1, 1 ) );
1263 m_SelectedPanel.Show( false );
1264
1265 InventoryMenu menu = InventoryMenu.Cast( GetGame().GetUIManager().FindMenu( MENU_INVENTORY ) );
1266
1267 if ( menu )
1268 menu.RefreshQuickbar();
1269 }
1270
1272 {
1273 m_PreviousFlipOrientation = m_Item.GetInventory().GetFlipCargo();
1276 m_IsDragged = true;
1278 int ww, hh;
1279 GetGame().GetInventoryItemSize( m_Item, ww, hh );
1280 if ( m_Item.GetInventory().GetFlipCargo() )
1281 SetSize( hh, ww );
1282 else
1283 SetSize( ww, hh );
1284
1285 SetSize();
1286
1287 if ( !m_HandsIcon )
1288 {
1289 Refresh();
1290 }
1291 else
1292 {
1295 m_ColorWidget.SetAlpha( 0.1 );
1296 }
1297
1298 m_SelectedPanel.Show( true );
1299 }
1300
1301 void OnDraggingOverBackground( Widget w, int x, int y, Widget reciever )
1302 {
1304 EntityAI entity = EntityAI.Cast( m_Obj );
1305 EntityAI owner = entity.GetHierarchyParent();
1306 if( owner && owner.GetHierarchyRootPlayer() == GetGame().GetPlayer() )
1307 {
1308 ItemManager.GetInstance().GetRightDropzone().SetAlpha( 1 );
1309 }
1310 else if( !m_HandsIcon )
1311 {
1312 ItemManager.GetInstance().GetLeftDropzone().SetAlpha( 1 );
1313 }
1314
1315 if( w == null || reciever == null )
1316 {
1317 return;
1318 }
1319 Pos pa;
1320 reciever.GetUserData( pa );
1321 if( m_Parent )
1322 {
1323 ContainerWithCargo item = ContainerWithCargo.Cast( m_Parent.m_Parent );
1324 if( item )
1325 {
1326 item.DraggingOverGrid( w, m_PosY + pa.y, m_PosX + pa.x, reciever );
1327 }
1328 HandsContainer hands_item = HandsContainer.Cast( m_Parent.m_Parent );
1329 if( hands_item )
1330 {
1331 hands_item.DraggingOverGrid( w, m_PosY + pa.y, m_PosX + pa.x, reciever, null );
1332 }
1333 }
1334 }
1335
1336 void DropReceivedFromBackground( Widget w, int x, int y, Widget reciever )
1337 {
1338 Pos pa;
1339 if( reciever )
1340 {
1341 reciever.GetUserData( pa );
1342 if( m_Parent )
1343 {
1344 ContainerWithCargo item = ContainerWithCargo.Cast( m_Parent.m_Parent );
1345 if( item )
1346 {
1347 item.DropReceived(w, m_PosY + pa.y, m_PosX + pa.x );
1348 }
1349 }
1350 }
1351 }
1352
1354 {
1355 if (m_Item)
1356 {
1357 m_Item.GetInventory().SetFlipCargo(m_PreviousFlipOrientation);
1358 int ww, hh;
1360
1362 SetSize(hh, ww);
1363 else
1364 SetSize(ww, hh);
1365
1366 SetSize();
1367 }
1368 }
1369
1370 override void Refresh()
1371 {
1372 super.Refresh();
1373
1374 if ( !m_HandsIcon )
1375 SetPos();
1376
1377 if ( m_HasTemperature )
1379
1380 if ( m_IsWeapon )
1382
1383 if ( m_HasQuantity )
1384 SetQuantity();
1385 }
1386
1388 {
1390 }
1391
1393 {
1394 Refresh();
1395 GetMainWidget().Update();
1396 }
1397
1399 {
1400 if( m_IsDragged )
1401 {
1402 return;
1403 }
1404 GetRootWidget().ClearFlags( WidgetFlags.HEXACTSIZE + WidgetFlags.VEXACTSIZE );
1405 GetRootWidget().SetSize( 1, 1 );
1406 m_ColorWidget.SetColor( ARGB( 0, 0, 0, 0 ) );
1407 }
1408
1409 void RefreshPos( int row, int column )
1410 {
1411 if( row != m_PosY || column != m_PosX )
1412 {
1413 m_PosX = column;
1414 m_PosY = row;
1415 SetPos();
1417 }
1418 }
1419
1421 {
1422 return m_Obj;
1423 }
1424
1426 {
1427 Weapon_Base wpn = Weapon_Base.Cast( GetObject() );
1428 if( wpn )
1429 {
1430 int i;
1431 ImageWidget ammo_icon;
1432 if (!wpn.IsShowingChamberedBullet())
1433 {
1434 for (i = 0; i < m_AmmoIcons.Count(); i++)
1435 {
1436 ammo_icon = m_AmmoIcons.Get(i);
1437 ammo_icon.Show(false);
1438 }
1439 /* int bullet_count = 0;
1440 int fireout_count = 0;
1441
1442 for ( i = 0; i < wpn.GetMuzzleCount(); i++ )
1443 {
1444 if (wpn.IsChamberFull(i))
1445 {
1446 if (wpn.IsChamberFiredOut(i))
1447 {
1448 fireout_count++;
1449 }
1450 else
1451 {
1452 bullet_count++;
1453 }
1454 }
1455 }
1456
1457 int j;
1458 i = 0;
1459 for ( j= 0; j < bullet_count; j++ )
1460 {
1461 if ( i > m_AmmoIcons.Count() )
1462 {
1463 //add plus ammo
1464 break;
1465 }
1466
1467 ammo_icon = m_AmmoIcons.Get(i);
1468 ammo_icon.Show( true );
1469 ammo_icon.SetImage( 0 );
1470 i++;
1471 }
1472
1473 for ( j= 0; j < fireout_count; j++ )
1474 {
1475 if ( i > m_AmmoIcons.Count() )
1476 {
1477 //add plus ammo
1478 break;
1479 }
1480
1481 ammo_icon = m_AmmoIcons.Get(i);
1482 ammo_icon.Show( true );
1483 ammo_icon.SetImage( 1 );
1484 i++;
1485 }
1486
1487 for (j = i; j < m_AmmoIcons.Count(); j++)
1488 {
1489 ammo_icon = m_AmmoIcons.Get(j);
1490 ammo_icon.Show(false);
1491 }*/
1492 }
1493 else
1494 {
1495 //TODO MW - add more conplex logic
1496 for ( i = 0; i < wpn.GetMuzzleCount(); i++ )
1497 {
1498 if ( i > m_AmmoIcons.Count() )
1499 {
1500 //add plus ammo
1501 break;
1502 }
1503
1504 ammo_icon = m_AmmoIcons.Get(i);
1505
1506 if( wpn.IsChamberFull( i ) )
1507 {
1508 if( wpn.IsJammed() )
1509 {
1510 ammo_icon.Show( true );
1511 ammo_icon.SetImage( 2 );
1512 }
1513 else if( wpn.IsChamberFiredOut( i ) )
1514 {
1515 ammo_icon.Show( true );
1516 ammo_icon.SetImage( 1 );
1517 }
1518 else
1519 {
1520 ammo_icon.Show( true );
1521 ammo_icon.SetImage( 0 );
1522 }
1523 }
1524 else
1525 {
1526 ammo_icon.Show( false );
1527 }
1528 }
1529 }
1530 }
1531 }
1532
1534 {
1535 if (m_Item)
1536 {
1537 int quantityType = QuantityConversions.HasItemQuantity(m_Item);
1539 {
1541
1542 if (quantityType == QUANTITY_COUNT)
1543 {
1545
1546 if (QuantityConversions.GetItemQuantityMax(m_Item) == 1 || q_text == "")
1547 {
1548 m_QuantityStack.Show(false);
1549 }
1550 else
1551 {
1552 m_QuantityItem.SetText(q_text);
1553 m_QuantityStack.Show(true);
1554 }
1555
1556 m_QuantityProgress.Show(false);
1557 }
1558 else if (quantityType == QUANTITY_PROGRESS)
1559 {
1560 float progress_max = m_QuantityProgress.GetMax();
1561 int max = m_Item.GetQuantityMax();
1562 int count = m_Item.ConfigGetInt("count");
1563 float quantity = m_CurrQuantity;
1564
1565 if (count > 0)
1566 {
1567 max = count;
1568 }
1569
1570 if (max > 0)
1571 {
1572 float value = Math.Round((quantity / max) * 100);
1573 m_QuantityProgress.SetCurrent(value);
1574 }
1575
1576 m_QuantityStack.Show(false);
1577 m_QuantityProgress.Show(true);
1578 }
1579 }
1580 }
1581 }
1582
1583 void SetSort( int index )
1584 {
1585 GetMainWidget().SetSort( index );
1586 GetMainWidget().Update();
1587 }
1588
1590 {
1591 return GetMainWidget().GetSort( );
1592 }
1593
1594 void SetItemPreviewEx(bool refresh = true)
1595 {
1596 m_ItemPreview.Show( true, refresh );
1599 m_ItemPreview.SetView( m_Obj.GetViewIndex() );
1600 }
1601
1603 {
1605 }
1606
1607 void SetItemSizeEx(bool refresh = true)
1608 {
1609 #ifdef PLATFORM_CONSOLE
1610 m_ItemSizePanel.Show( true, refresh );
1611 m_ItemSizeWidget.Show( true, refresh );
1612
1613 int size_x, size_y;
1614 GetGame().GetInventoryItemSize( m_Item, size_x, size_y );
1615 int capacity = size_x * size_y;
1616 m_ItemSizeWidget.SetText( capacity.ToString() );
1617 #endif
1618 }
1619
1621 {
1622 SetItemSizeEx();
1623 }
1624
1625 void UpdateFlip( bool flipped )
1626 {
1627 int size_x, size_y;
1628 GetGame().GetInventoryItemSize( m_Item, size_x, size_y );
1629
1630 if ( flipped )
1631 SetSize( size_y, size_x );
1632 else
1633 SetSize( size_x, size_y );
1634
1635 SetSize();
1636 }
1637
1638 void InitLock( EntityAI parent, EntityAI obj, int x_pos, int y_pos, bool flip)
1639 {
1640 m_Lock = parent;
1641 m_Obj = obj;
1642 m_Item = ItemBase.Cast( m_Obj );
1643
1644 SetPos( x_pos, y_pos );
1645 UpdateFlip( flip );
1646
1647 ItemManager.GetInstance().SetWidgetDraggable( GetMainWidget(), false );
1648 WidgetEventHandler.GetInstance().RegisterOnMouseButtonDown( GetMainWidget(), this, "MouseClick" );
1649 WidgetEventHandler.GetInstance().RegisterOnDropReceived( GetMainWidget(), this, "DropReceivedFromMain" );
1650 WidgetEventHandler.GetInstance().RegisterOnDraggingOver( GetMainWidget(), this, "DraggingOver" );
1651
1652 m_RootWidget.FindAnyWidget( "Reserved" ).Show( true );
1656 Refresh();
1657 }
1658
1659 void InitEx( EntityAI obj, bool refresh = true )
1660 {
1661 if ( obj != m_Obj )
1662 {
1663 if ( m_Obj )
1664 {
1665 m_Obj.GetOnItemFlipped().Remove( UpdateFlip );
1666 m_Obj.GetOnViewIndexChanged().Remove( SetItemPreview );
1667 }
1668 if ( obj )
1669 {
1670 obj.GetOnItemFlipped().Insert( UpdateFlip );
1671 obj.GetOnViewIndexChanged().Insert( SetItemPreview );
1672 }
1673 }
1674
1675 if (m_HandsIcon)
1676 {
1679 }
1680
1681 m_Obj = obj;
1682 m_Item = ItemBase.Cast( m_Obj );
1683 m_Lock = null;
1684
1685 SetItemPreviewEx(refresh);
1686
1687 WidgetEventHandler.GetInstance().RegisterOnDrag( GetMainWidget(), this, "CreateWhiteBackground" );
1688 WidgetEventHandler.GetInstance().RegisterOnDrop( GetMainWidget(), this, "DestroyWhiteBackground" );
1689 WidgetEventHandler.GetInstance().RegisterOnDropReceived( GetMainWidget(), this, "DropReceivedFromMain" );
1690 WidgetEventHandler.GetInstance().RegisterOnMouseButtonDown( GetMainWidget(), this, "MouseClick" );
1691 WidgetEventHandler.GetInstance().RegisterOnDropReceived( GetMainWidget().FindAnyWidget( "Swap" ), this, "Swap" );
1692 WidgetEventHandler.GetInstance().RegisterOnDraggingOver( GetMainWidget().FindAnyWidget( "Swap" ), this, "DraggingOverSwap" );
1693 WidgetEventHandler.GetInstance().RegisterOnDropReceived( GetMainWidget().FindAnyWidget( "Combine" ), this, "Combine" );
1694 WidgetEventHandler.GetInstance().RegisterOnDraggingOver( GetMainWidget().FindAnyWidget( "Combine" ), this, "DraggingOverCombine" );
1695 WidgetEventHandler.GetInstance().RegisterOnDraggingOver( GetMainWidget(), this, "DraggingOver" );
1696 WidgetEventHandler.GetInstance().RegisterOnMouseEnter( GetMainWidget(), this, "MouseEnter" );
1697 WidgetEventHandler.GetInstance().RegisterOnMouseLeave( GetMainWidget(), this, "MouseLeave" );
1698 WidgetEventHandler.GetInstance().RegisterOnDoubleClick( GetMainWidget(), this, "DoubleClick" );
1699
1700 SetItemSizeEx(refresh);
1701 CheckIsWeapon();
1702 CheckIsMagazineEx(refresh);
1704 CheckHasQuantityEx(refresh);
1705 m_RootWidget.FindAnyWidget( "Reserved" ).Show( false, refresh );
1706
1707 if (refresh)
1708 Refresh();
1709 }
1710
1711 void Init( EntityAI obj )
1712 {
1713 InitEx( obj );
1714 }
1715
1717 {
1718 Weapon_Base wpn = Weapon_Base.Cast( m_Obj );
1719 if ( wpn )
1720 {
1722 m_IsWeapon = true;
1723 float x_pos = 0.0;
1724 float widht = 0.0, height = 0.0;
1725 for (int i = 0; i < wpn.GetMuzzleCount(); i++)
1726 {
1727 if (i == 1)
1728 {
1729 m_AmmoIcons[0].GetSize(widht,height);
1730 }
1731 x_pos += widht;
1732
1733 Widget ammo_icon = Widget.Cast( GetGame().GetWorkspace().CreateWidgets( "gui/layouts/inventory_new/ammo_icon.layout", GetMainWidget() ) );
1734 ammo_icon.SetPos(x_pos, 0.0, false);
1735
1736 ImageWidget ammo_icon_img = ImageWidget.Cast(ammo_icon.GetChildren());
1737
1738 AmmoData data = Magazine.GetAmmoData( wpn.GetChamberAmmoTypeName( i ) );
1739 if ( data )
1740 {
1741 CartridgeType c_type = data.m_CartridgeType;
1742 switch ( c_type )
1743 {
1744 case CartridgeType.Pistol:
1745 {
1746 ammo_icon_img.LoadImageFile( 0, "set:dayz_gui image:cartridge_pistol" );
1747 ammo_icon_img.LoadImageFile( 1, "set:dayz_gui image:shell_pistol" );
1748 ammo_icon_img.LoadImageFile( 2, "set:dayz_gui image:jam_pistol" );
1749 break;
1750 }
1751 case CartridgeType.Intermediate:
1752 {
1753 ammo_icon_img.LoadImageFile( 0, "set:dayz_gui image:cartridge_int" );
1754 ammo_icon_img.LoadImageFile( 1, "set:dayz_gui image:shell_int" );
1755 ammo_icon_img.LoadImageFile( 2, "set:dayz_gui image:jam_int" );
1756 break;
1757 }
1758 case CartridgeType.FullPower:
1759 {
1760 ammo_icon_img.LoadImageFile( 0, "set:dayz_gui image:cartridge_fp" );
1761 ammo_icon_img.LoadImageFile( 1, "set:dayz_gui image:shell_fp" );
1762 ammo_icon_img.LoadImageFile( 2, "set:dayz_gui image:jam_fp" );
1763 break;
1764 }
1765 case CartridgeType.Shell:
1766 {
1767 ammo_icon_img.LoadImageFile( 0, "set:dayz_gui image:cartridge_shell" );
1768 ammo_icon_img.LoadImageFile( 1, "set:dayz_gui image:shell_shell" );
1769 ammo_icon_img.LoadImageFile( 2, "set:dayz_gui image:jam_shell" );
1770 break;
1771 }
1772 }
1773 }
1774 m_AmmoIcons.Insert(ammo_icon_img);
1775 }
1776 }
1777 else
1778 {
1779 m_IsWeapon = false;
1780 }
1781 }
1782
1783 void CheckIsMagazineEx( bool refresh = true )
1784 {
1785 Magazine mag = Magazine.Cast( m_Obj );
1786 if ( mag )
1787 {
1788 m_IsMagazine = true;
1789 AmmoData data = Magazine.GetAmmoData( mag.ClassName() );
1790 if ( data )
1791 {
1792 ProjectileType p_type = data.m_ProjectileType;
1793 switch (p_type)
1794 {
1795 case ProjectileType.None:
1796 {
1797 m_AmmoTypeIcon.Show( false, refresh );
1798 break;
1799 }
1800 case ProjectileType.Tracer:
1801 {
1802 m_AmmoTypeIcon.LoadImageFile( 0, "set:dayz_gui image:tracer" );
1803 m_AmmoTypeIcon.Show( true, refresh );
1804 break;
1805 }
1806 case ProjectileType.AP:
1807 {
1808 m_AmmoTypeIcon.LoadImageFile( 0, "set:dayz_gui image:armor_piercing" );
1809 m_AmmoTypeIcon.Show( true, refresh );
1810 break;
1811 }
1812 }
1813 }
1814 }
1815 else
1816 {
1817 m_IsMagazine = false;
1818 }
1819 }
1820
1822 {
1824 }
1825
1827 {
1828 if ( m_Item )
1829 {
1830 m_HasTemperature = ( m_Item.GetTemperatureMax() != 0 && m_Item.GetTemperatureMin() != 0 );
1831 }
1832 }
1833
1834 void CheckHasQuantityEx(bool refresh = true)
1835 {
1836 if ( m_Item )
1837 {
1839
1840 if ( m_HasQuantity )
1841 m_QuantityPanel.Show( true, refresh );
1842 }
1843 }
1844
1846 {
1848 }
1849
1850 void SetPosX( int x )
1851 {
1852 m_PosX = x;
1853 }
1854
1855 void SetPosY( int y )
1856 {
1857 m_PosY = y;
1858 }
1859
1860 void SetSizeX( int x )
1861 {
1862 m_SizeX = x;
1863 }
1864
1865 void SetSizeY( int y )
1866 {
1867 m_SizeY = y;
1868 }
1869
1871 {
1872 return m_PosX;
1873 }
1874
1876 {
1877 return m_PosY;
1878 }
1879
1881 {
1882 return m_SizeX;
1883 }
1884
1886 {
1887 return m_SizeY;
1888 }
1889
1890 void SetPosEx( bool refresh = true )
1891 {
1892 CargoContainer c_parent = CargoContainer.Cast( m_Parent );
1893 HandsPreview h_parent = HandsPreview.Cast( m_Parent );
1894 Widget rootWidget = GetRootWidget();
1895 float icon_size, space_size;
1896 if ( c_parent )
1897 {
1898 icon_size = c_parent.GetIconSize();
1899 space_size = c_parent.GetSpaceSize();
1900 }
1901 else if ( h_parent )
1902 {
1903 icon_size = h_parent.GetIconSize();
1904 if (rootWidget)
1905 {
1906 rootWidget.SetFlags( WidgetFlags.EXACTSIZE, refresh );
1907 }
1908 }
1909
1910 if (rootWidget)
1911 {
1912 #ifndef PLATFORM_CONSOLE
1913 rootWidget.SetPos( icon_size * GetPosX() + ( GetPosX() + 1 ) * space_size, icon_size * GetPosY() + ( GetPosY() + 1 ) * space_size, refresh );
1914 rootWidget.SetSize( icon_size * m_SizeX + ( m_SizeX ) * space_size, icon_size * m_SizeY + ( m_SizeY ) * space_size, refresh );
1915 #else
1916 int row = m_CargoPos / 5;
1917 int column = m_CargoPos % 5;
1918 rootWidget.SetPos( icon_size * column, icon_size * row, refresh );
1919 rootWidget.SetSize( icon_size, icon_size, refresh );
1920 #endif
1921 }
1922 }
1923
1924 void SetPos()
1925 {
1926 SetPosEx();
1927 }
1928
1929 void SetSize()
1930 {
1931 CargoContainer c_parent = CargoContainer.Cast( m_Parent );
1932 HandsPreview h_parent = HandsPreview.Cast( m_Parent );
1933 float icon_size, space_size;
1934 Widget rootWidget = GetRootWidget();
1935 if( c_parent )
1936 {
1937 icon_size = c_parent.GetIconSize();
1938 space_size = c_parent.GetSpaceSize();
1939 }
1940 else if( h_parent )
1941 {
1942 icon_size = h_parent.GetIconSize();
1943 if (rootWidget)
1944 {
1945 GetRootWidget().SetFlags( WidgetFlags.EXACTSIZE );
1946 }
1947 }
1948
1949 if (rootWidget)
1950 {
1951 #ifndef PLATFORM_CONSOLE
1952 GetRootWidget().SetSize( icon_size * m_SizeX + ( m_SizeX ) * space_size, icon_size * m_SizeY + ( m_SizeY ) * space_size );
1953 #else
1954 GetRootWidget().SetSize( icon_size, icon_size );
1955 #endif
1956 }
1957 }
1958
1959 override void UpdateInterval()
1960 {
1961 if ( m_Item )
1962 {
1963 if ( m_HasTemperature )
1965
1966 if ( m_IsWeapon )
1968
1969 if ( m_HasQuantity )
1970 SetQuantity();
1971 }
1972 }
1973}
1974
1975class Pos
1976{
1977 int x, y;
1978
1979 void Pos( int _x, int _y )
1980 {
1981 x = _x;
1982 y = _y;
1983 }
1984}
DayZGame g_Game
Definition DayZGame.c:3654
DayZGame GetDayZGame()
Definition DayZGame.c:3656
Mission mission
proto string ToString()
Icon x
void Pos(int _x, int _y)
Definition Icon.c:1979
Icon y
FindInventoryLocationType
flags for searching locations in inventory
InventoryLocationType
types of Inventory Location
override ContextMenu GetContextMenu()
ScreenWidthType
void InventoryMenu()
override void CombineItemsClient(EntityAI entity2, bool use_stack_max=true)
Definition ItemBase.c:5444
CartridgeType
Definition Magazine.c:4
PlayerBase GetPlayer()
string name
ref Widget m_RootWidget[MAX_SIMULTANIOUS_PLAYERS]
DayZPlayer m_player
protected Widget m_Parent
Definition SizeToChild.c:92
void SetActive()
Definition TrapBase.c:463
protected Widget m_ParentWidget
void SetActionFromInventory(ItemBase mainItem, ItemBase targetItem)
void PerformActionFromInventory(ItemBase mainItem, ItemBase targetItem)
static bool IsAttachmentReachable(EntityAI e, string att_slot_name="", int slot_id=-1, float range=1.5)
proto void GetInventoryItemSize(InventoryItem item, out int width, out int height)
proto native DayZPlayer GetPlayer()
represents base for cargo storage for entities
Definition Cargo.c:7
Super root of all classes in Enforce script.
Definition EnScript.c:11
static int GREEN_COLOR
static ColorManager GetInstance()
static int RED_COLOR
static int SWAP_COLOR
static int BASE_COLOR
static int COMBINE_COLOR
static int FSWAP_COLOR
void SetColor(Widget w, int color)
WeaponManager GetWeaponManager()
Definition Debug.c:14
static void Log(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message with normal prio.
Definition Debug.c:133
script counterpart to engine's class Inventory
Definition Inventory.c:77
static bool CanForceSwapEntitiesEx(notnull EntityAI item1, InventoryLocation item1_dst, notnull EntityAI item2, out InventoryLocation item2_dst)
Definition Inventory.c:638
static bool CanSwapEntitiesEx(notnull EntityAI item1, notnull EntityAI item2)
Definition Inventory.c:601
bool DraggingOverGrid(Widget w, int x, int y, Widget reciever, CargoContainer cargo)
float GetIconSize()
Definition Icon.c:2
void DraggingOver(Widget w, int x, int y, Widget receiver)
Definition Icon.c:387
protected bool m_IsDragged
Definition Icon.c:19
void SetPosX(int x)
Definition Icon.c:1850
protected int m_PosX
Definition Icon.c:5
void SetSizeY(int y)
Definition Icon.c:1865
protected bool m_HasQuantity
Definition Icon.c:12
void CheckIsMagazine()
Definition Icon.c:1821
protected bool m_IsWeapon
Definition Icon.c:9
protected int m_PosY
Definition Icon.c:6
Widget GetSelectedWidget()
Definition Icon.c:79
void DropReceivedFromBackground(Widget w, int x, int y, Widget reciever)
Definition Icon.c:1336
void SetItemPreviewEx(bool refresh=true)
Definition Icon.c:1594
protected bool m_IsMagazine
Definition Icon.c:10
void Combine(Widget w, int x, int y, Widget receiver)
Definition Icon.c:769
override void Refresh()
Definition Icon.c:1370
void RefreshPos(int row, int column)
Definition Icon.c:1409
protected bool m_HandsIcon
Definition Icon.c:17
protected Widget m_SelectedPanel
Definition Icon.c:27
override void UpdateInterval()
Definition Icon.c:1959
bool MouseLeave(Widget w, Widget s, int x, int y)
Definition Icon.c:377
bool MouseEnter(Widget w, int x, int y)
Definition Icon.c:366
void SetItemSizeEx(bool refresh=true)
Definition Icon.c:1607
protected ProgressBarWidget m_QuantityProgress
Definition Icon.c:31
void OnPerformRecipe(int id)
Definition Icon.c:760
void FullScreen()
Definition Icon.c:1398
int GetPosY()
Definition Icon.c:1875
protected Widget m_QuantityPanel
Definition Icon.c:29
int GetSort()
Definition Icon.c:1589
void SetItemPreview()
Definition Icon.c:1602
protected Widget m_ColorWidget
Definition Icon.c:26
void CheckIsWeapon()
Definition Icon.c:1716
void SetSizeX(int x)
Definition Icon.c:1860
void CheckHasTemperature()
Definition Icon.c:1826
void SetSize(int x, int y)
Definition Icon.c:1223
void ~Icon()
Definition Icon.c:62
protected int m_SizeY
Definition Icon.c:4
protected bool m_PreviousFlipOrientation
Definition Icon.c:20
override void SetActive(bool active)
Definition Icon.c:89
void CheckHasQuantityEx(bool refresh=true)
Definition Icon.c:1834
protected Widget m_ItemSizePanel
Definition Icon.c:34
protected TextWidget m_QuantityItem
Definition Icon.c:30
void MouseClick(Widget w, int x, int y, int button)
Definition Icon.c:889
protected EntityAI m_Lock
Definition Icon.c:8
void SetSort(int index)
Definition Icon.c:1583
const int NUMBER_OF_TIMERS
Definition Icon.c:22
void DoubleClick(Widget w, int x, int y, int button)
Definition Icon.c:135
void ToRefresh(Icon icon, Icon icon2)
Definition Icon.c:1190
protected ItemPreviewWidget m_ItemPreview
Definition Icon.c:24
void RefreshQuickbar()
Definition Icon.c:125
int GetSizeY()
Definition Icon.c:1885
protected EntityAI m_Obj
Definition Icon.c:15
void RevertToOriginalFlip()
Definition Icon.c:1353
void ShowActionMenuCombine(EntityAI entity1, EntityAI entity2, int combinationFlags, Widget w, bool color_test)
Definition Icon.c:636
Object GetObject()
Definition Icon.c:1420
bool FlagAction(EntityAI entity1, EntityAI entity2, int combinationFlags)
Definition Icon.c:800
void Swap(Widget w, int x, int y, Widget receiver)
Definition Icon.c:1093
void RefreshIconPos()
Definition Icon.c:1392
protected bool m_HasTemperature
Definition Icon.c:11
override void SetParentWidget()
Definition Icon.c:102
void SetCargoPos(int x)
Definition Icon.c:1240
void RefreshMuzzleIcon()
Definition Icon.c:1425
protected TextWidget m_ItemSizeWidget
Definition Icon.c:35
bool IsDragged()
Definition Icon.c:84
protected ImageWidget m_AmmoTypeIcon
Definition Icon.c:38
void SetItemSize()
Definition Icon.c:1620
void CheckHasQuantity()
Definition Icon.c:1845
void OnDraggingOverBackground(Widget w, int x, int y, Widget reciever)
Definition Icon.c:1301
void DraggingOverCombine(Widget w, int x, int y, Widget receiver)
Definition Icon.c:337
void CreateWhiteBackground()
Definition Icon.c:1271
int GetCargoPos()
Definition Icon.c:1235
void InitEx(EntityAI obj, bool refresh=true)
Definition Icon.c:1659
protected int m_CargoPos
Definition Icon.c:18
protected Widget m_QuantityStack
Definition Icon.c:32
void SetPosEx(bool refresh=true)
Definition Icon.c:1890
void InitLock(EntityAI parent, EntityAI obj, int x_pos, int y_pos, bool flip)
Definition Icon.c:1638
int GetPosX()
Definition Icon.c:1870
bool CombineItems(EntityAI entity1, EntityAI entity2)
Definition Icon.c:794
int GetSizeX()
Definition Icon.c:1880
void CheckIsMagazineEx(bool refresh=true)
Definition Icon.c:1783
void DraggingOverSwap(Widget w, int x, int y, Widget receiver)
Definition Icon.c:253
void OnPerformCombination(int combinationFlags)
Definition Icon.c:548
void UpdateFlip(bool flipped)
Definition Icon.c:1625
void SetQuantity()
Definition Icon.c:1533
protected ItemBase m_Item
Definition Icon.c:16
protected float m_CurrQuantity
Definition Icon.c:13
override void SetLayoutName()
Definition Icon.c:1196
void Init(EntityAI obj)
Definition Icon.c:1711
void SetTemperature()
Definition Icon.c:1387
protected ref array< ImageWidget > m_AmmoIcons
Definition Icon.c:37
void SetPosY(int y)
Definition Icon.c:1855
protected int m_SizeX
Definition Icon.c:3
void Icon(LayoutHolder parent, bool hands_icon=false)
Definition Icon.c:40
void SetPos()
Definition Icon.c:1924
void SetPos(int x, int y)
Definition Icon.c:1229
void DropReceivedFromMain(Widget w, int x, int y, Widget receiver)
Definition Icon.c:949
void SetSize()
Definition Icon.c:1929
void DestroyWhiteBackground()
Definition Icon.c:1246
InventoryLocation.
proto native int GetType()
returns type of InventoryLocation
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 InventoryLocation CopyLocationFrom(notnull InventoryLocation rhs, bool copyFlip)
copies location to another location without m_item member
proto native void SetFlip(bool flip)
proto native EntityAI GetParent()
returns parent of current inventory location
proto native int GetSlot()
returns slot id if current type is Attachment
Widget GetCenterDropzone()
void SetDraggedIcon(Icon dragged_icon)
Icon GetDraggedIcon()
void ShowSourceDropzone(EntityAI item)
static int GetCombinationFlags(EntityAI entity1, EntityAI entity2)
Widget GetLeftDropzone()
void SetWidgetDraggable(Widget w, bool draggable)
void HideDropzones()
void SetDraggedItem(EntityAI dragged_item)
void SetIconTemperature(EntityAI item, Widget item_w)
void SetSelectedItem(EntityAI selected_item, Container selected_container, Widget selected_widget, SlotsIcon selected_icon)
Widget GetRightDropzone()
void SetIsDragging(bool is_dragging)
static ItemManager GetInstance()
proto native void SetView(int viewIndex)
proto native void SetForceFlip(bool value)
proto native void SetItem(EntityAI object)
proto native void SetForceFlipEnable(bool enable)
proto native EntityAI GetItem()
proto native void SetModelOrientation(vector vOrientation)
bool InspectItem()
Definition Container.c:351
Definition EnMath.c:7
static float GetItemQuantityMax(InventoryItem item)
static string GetItemQuantityText(EntityAI item, bool showMax=false)
static int HasItemQuantity(notnull EntityAI item)
static float GetItemQuantity(InventoryItem item)
static void TakeOrSplitToInventory(notnull PlayerBase player, notnull EntityAI target, notnull EntityAI item)
static void TakeOrSplitToInventoryLocation(notnull PlayerBase player, notnull InventoryLocation dst)
override bool IsShowingChamberedBullet()
Definition Magnum.c:291
bool LoadBullet(Magazine mag, ActionBase control_action=NULL)
bool CanLoadBullet(Weapon_Base wpn, Magazine mag, bool reservationCheck=true)
void RegisterOnMouseButtonDown(Widget w, Managed eventHandler, string functionName)
static WidgetEventHandler GetInstance()
void RegisterOnDrag(Widget w, Managed eventHandler, string functionName)
void RegisterOnDrop(Widget w, Managed eventHandler, string functionName)
void RegisterOnDoubleClick(Widget w, Managed eventHandler, string functionName)
void RegisterOnDropReceived(Widget w, Managed eventHandler, string functionName)
void RegisterOnMouseEnter(Widget w, Managed eventHandler, string functionName)
void RegisterOnDraggingOver(Widget w, Managed eventHandler, string functionName)
void RegisterOnMouseLeave(Widget w, Managed eventHandler, string functionName)
const string IconXbox
const string IconNarrow
const string IconMedium
const string IconWide
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
const int QUANTITY_PROGRESS
Definition constants.c:468
const int QUANTITY_COUNT
Definition constants.c:467
const int QUANTITY_HIDDEN
Definition constants.c:466
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
static proto float Round(float f)
Returns mathematical round of value.
const int MENU_INVENTORY
Definition constants.c:158
MouseState
Definition EnSystem.c:311
proto void GetMousePos(out int x, out int y)
proto int Replace(string sample, string replace)
Replace all occurrances of 'sample' in 'str' by 'replace'.
WidgetFlags
Definition EnWidgets.c:57
proto native Widget FindAnyWidget(string pathname)
proto native bool LoadImageFile(int num, string name, bool noCache=false)
int ARGB(int a, int r, int g, int b)
Definition proto.c:322
int ARGBF(float fa, float fr, float fg, float fb)
Converts <0.0, 1.0> ARGB into color.
Definition proto.c:332