Dayz  1.11.153731
Dayz Code Explorer by Zeroy
VicinitySlotsContainer.c
Go to the documentation of this file.
2 {
3  protected ref Container m_Container;
4  protected int m_ItemsCount;
5  protected int m_SlotsCount;
6  protected ref array<EntityAI> m_ShowedItems;
7 
9  {
10  m_Container = new Container( this );
11  ref SlotsContainer con = new SlotsContainer( m_Container, null );
12  m_Container.Insert( con );
13  m_Body.Insert( m_Container );
14  for( int j = 0; j < ITEMS_IN_ROW; j++ )
15  {
16  SlotsIcon icon = con.GetSlotIcon( j );
17  WidgetEventHandler.GetInstance().RegisterOnDropReceived( icon.GetPanelWidget(), m_Parent, "OnDropReceivedFromIcon" );
18  WidgetEventHandler.GetInstance().RegisterOnDropReceived( icon.GetGhostSlot(), m_Parent, "OnDropReceivedFromHeader" );
19  WidgetEventHandler.GetInstance().RegisterOnDropReceived( icon.GetMainWidget(), m_Parent, "OnDropReceivedFromHeader" );
20 
23  WidgetEventHandler.GetInstance().RegisterOnDraggingOver( icon.GetMainWidget(), m_Parent, "DraggingOverHeader" );
24 
25  WidgetEventHandler.GetInstance().RegisterOnDoubleClick( icon.GetPanelWidget(), this, "DoubleClick" );
27  WidgetEventHandler.GetInstance().RegisterOnMouseButtonDown( icon.GetPanelWidget(), this, "MouseButtonDown" );
28  }
29 
30  SlotsContainer.Cast( m_Container.Get( 0 ) ).SetColumnCount( 0 );
31 
32  WidgetEventHandler.GetInstance().RegisterOnDropReceived( m_Container.GetMainWidget(), m_Parent, "OnDropReceivedFromHeader" );
33  WidgetEventHandler.GetInstance().RegisterOnDraggingOver( m_Container.GetMainWidget(), m_Parent, "DraggingOverHeader" );
34  m_SlotsCount++;
35 
36  m_ShowedItems = new array<EntityAI>;
37  }
38 
39  void SetDefaultFocus( bool while_micromanagment_mode = false )
40  {
41  if( !while_micromanagment_mode && ItemManager.GetInstance().IsMicromanagmentMode() )
42  {
43  return;
44  }
45 
46  m_FocusedColumn = 0;
47  m_FocusedRow = 0;
48 
49  SlotsIcon icon = GetFocusedIcon();
50  EntityAI focused_item = GetFocusedItem();
51 
52  if( focused_item )
53  {
54  float x, y;
55  Widget w = icon.GetCursorWidget();
56  w.Show( true );
57  w.GetScreenPos( x, y );
58  ItemManager.GetInstance().PrepareTooltip( focused_item, x, y );
59  }
60  }
61 
63  {
65  if( ipw )
66  {
67  return ipw.GetItem();
68  }
69  return null;
70  }
71 
73  {
74  if( m_FocusedRow < m_Container.Count() )
75  {
76  SlotsContainer cont = SlotsContainer.Cast( m_Container.Get( m_FocusedRow ) );
77  return cont.GetSlotIcon( m_FocusedColumn );
78  }
79  return null;
80  }
81 
83  {
84  EntityAI ent = GetFocusedItem();
85  return ent && ( ent.GetInventory().GetCargo() || ent.GetSlotsCountCorrect() > 0 );
86  }
87 
88  override bool IsItemWithQuantityActive()
89  {
90  EntityAI ent = GetFocusedItem();
91  return ent && QuantityConversions.HasItemQuantity( ent );
92  }
93 
94  override bool IsItemActive()
95  {
96  EntityAI ent = GetFocusedItem();
98  }
99 
101  {
102  EntityAI ent = GetFocusedItem();
103  return ent == null;
104  }
105 
106  override void UnfocusAll()
107  {
108  for ( int i = 0; i < m_Container.m_Body.Count(); i++ )
109  {
110  SlotsContainer con = SlotsContainer.Cast( m_Container.Get( i ) );
111  for ( int j = 0; j < ITEMS_IN_ROW; j++ )
112  {
113  con.GetSlotIcon( j ).GetCursorWidget().Show( false );
114  }
115  }
116  }
117 
118  override void MoveGridCursor( int direction )
119  {
121  UnfocusAll();
122 
123  if( direction == Direction.RIGHT )
124  {
125  m_FocusedColumn++;
126  if( m_FocusedColumn >= GetRowSlotCount() )
127  m_FocusedColumn = 0;
128  }
129  else if( direction == Direction.LEFT )
130  {
131  m_FocusedColumn--;
132  if( m_FocusedColumn < 0 )
133  m_FocusedColumn = GetRowSlotCount() - 1;
134  }
135  else if( direction == Direction.UP )
136  {
137  m_FocusedRow--;
138  if( m_FocusedRow < 0 )
139  {
140  m_FocusedRow = 0 ;
141  LeftArea left_area = LeftArea.Cast( GetParent().GetParent() );
142  left_area.SetPreviousActive();
143  return;
144  }
145  }
146  else if( direction == Direction.DOWN )
147  {
148  m_FocusedRow++;
149  if( m_FocusedRow == m_Container.m_Body.Count() )
150  {
151  m_FocusedRow = 0 ;
152  left_area = LeftArea.Cast( GetParent().GetParent() );
153  left_area.SetNextActive();
154  return;
155  }
156  }
157 
158  if( m_FocusedColumn < 0 )
159  m_FocusedColumn = 0;
160 
161  SlotsIcon icon = GetFocusedIcon();
162 
163  icon.GetCursorWidget().Show( true );
164  EntityAI focused_item = GetFocusedItem();
165 
166  if( focused_item )
167  {
168  float x, y;
169  icon.GetCursorWidget().GetScreenPos( x, y );
170  ItemManager.GetInstance().PrepareTooltip( focused_item, x, y );
171  }
172  }
173 
174  override bool CanCombine()
175  {
176  ItemBase ent = ItemBase.Cast( GetFocusedItem() );
177  ItemBase item_in_hands = ItemBase.Cast( GetGame().GetPlayer().GetHumanInventory().GetEntityInHands() );
178 
179  return ( ItemManager.GetCombinationFlags( ent, item_in_hands ) != 0 );
180  }
181 
182  override bool CanCombineAmmo()
183  {
185  ItemBase ent = ItemBase.Cast( GetFocusedItem() );
186  ItemBase item_in_hands = ItemBase.Cast( GetGame().GetPlayer().GetHumanInventory().GetEntityInHands() );
188  Class.CastTo(amc, m_player.GetActionManager());
189 
190  return ( amc.CanPerformActionFromInventory( item_in_hands, ent ) || amc.CanSetActionFromInventory( item_in_hands, ent ) );
191  }
192 
193  override bool CanEquip()
194  {
195  EntityAI ent = GetFocusedItem();
197  bool found = GetGame().GetPlayer().GetInventory().FindFreeLocationFor(ent,FindInventoryLocationType.ATTACHMENT,il);
198  if (found)
199  {
200  return true;
201  }
202  else
203  {
204  return false;
205  }
206  }
207 
208  override bool EquipItem()
209  {
210  EntityAI ent = GetFocusedItem();
211  bool res = false;
212 
213  if( ent && !ent.IsInherited( Magazine ))
214  {
215  res = GetGame().GetPlayer().PredictiveTakeOrSwapAttachment( ent );
216  if(!res)
217  {
218  res = GetGame().GetPlayer().GetInventory().TakeEntityToInventory(InventoryMode.PREDICTIVE,FindInventoryLocationType.ATTACHMENT,ent);
219  }
220  }
221  return res;
222  }
223 
224  override bool InspectItem()
225  {
226  EntityAI ent = GetFocusedItem();
227 
228  if( ent )
229  {
230  InspectItem( ent );
231  return true;
232  }
233  return false;
234  }
235 
236  override bool TransferItem()
237  {
238  EntityAI ent = GetFocusedItem();
239  if( ent )
240  {
242  GetGame().GetPlayer().GetInventory().FindFreeLocationFor( ent, FindInventoryLocationType.CARGO, il );
243  if( il.IsValid() && GetGame().GetPlayer().GetInventory().LocationCanAddEntity( il ) )
244  {
246  return true;
247  }
248  }
249  return false;
250  }
251 
252  override bool Combine( )
253  {
254  ItemBase ent = ItemBase.Cast( GetFocusedItem() );
255 
256  ItemBase item_in_hands = ItemBase.Cast( GetGame().GetPlayer().GetHumanInventory().GetEntityInHands() );
257 
259 
260  if( item_in_hands && ent && hands_icon )
261  {
262  return hands_icon.CombineItems( item_in_hands, ent );
263  }
264  return true;
265  }
266 
267  override bool SelectItem()
268  {
269  EntityAI ent = GetFocusedItem();
270  SlotsIcon icon = GetFocusedIcon();
271  if( ent )
272  {
273  ItemManager.GetInstance().SetSelectedItem( ent, null, icon.GetCursorWidget(), icon );
274  return true;
275  }
276  return false;
277  }
278 
279  override bool Select()
280  {
281  SlotsIcon selected_slot = ItemManager.GetInstance().GetSelectedIcon();
282  EntityAI ent = GetFocusedItem();
283  ItemBase selected_item = ItemBase.Cast(ItemManager.GetInstance().GetSelectedItem());
284 
285  if( !(selected_slot && selected_slot.IsOutOfReach() ) )
286  {
287  if( selected_item )
288  {
289  if( ent != selected_item)
290  {
291  if( selected_item && GetGame().GetPlayer().CanDropEntity( selected_item ) )
292  {
293  bool draggable = false;
294 
295  PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
296  draggable = !player.GetInventory().HasInventoryReservation( selected_item, null ) && !player.IsItemsToDelete();
297  draggable = draggable && selected_item.GetInventory().CanRemoveEntity();
298 
299  if( draggable && m_ShowedItems.Find( selected_item ) == -1 )
300  {
301  if( selected_item.GetTargetQuantityMax() < selected_item.GetQuantity() )
302  selected_item.SplitIntoStackMaxClient( null, -1 );
303  else
304  player.PhysicalPredictiveDropItem( selected_item );
305  ItemManager.GetInstance().SetSelectedItem( null, null, null, null );
306  return true;
307  }
308  }
309  }
310  }
311  else
312  {
313  if( ent && ent.GetInventory().CanRemoveEntity())
314  {
315  EntityAI item_in_hands = GetGame().GetPlayer().GetHumanInventory().GetEntityInHands();
316  if( item_in_hands )
317  {
318  if( GameInventory.CanSwapEntitiesEx( item_in_hands, ent ) )
319  {
320  GetGame().GetPlayer().PredictiveSwapEntities( item_in_hands, ent );
321  return true;
322  }
323  }
324  else
325  {
326  if( GetGame().GetPlayer().GetHumanInventory().CanAddEntityInHands( ent ) )
327  {
328  GetGame().GetPlayer().PredictiveTakeEntityToHands( ent );
329  return true;
330  }
331  }
332  }
333  }
334  }
335 
336  return false;
337  }
338 
340  {
341  for ( int i = 0; i < m_Container.Count(); i++ )
342  {
344  if( c && c.GetMainWidget() )
345  {
346  delete m_Container.Get( i / ITEMS_IN_ROW ).GetMainWidget();
347  }
348  }
349  }
350 
351  override void SetLayoutName()
352  {
353  m_LayoutName = WidgetLayoutName.Container;
354  }
355 
356  override void OnShow()
357  {
358  super.OnShow();
359  }
360 
362  {
363  return SlotsContainer.Cast( m_Container.Get( m_FocusedRow ) ).GetColumnCount();
364  }
365 
367  {
368  if ( item.IsInherited(DayZAnimal) && item.IsAlive() )
369  {
370  return true;
371  }
372  else if ( item.IsInherited( DayZInfected ) || item.IsInherited( SurvivorBase ) || item.IsInherited( Car ) || item.IsInherited( GardenBase ) || item.IsInherited(DayZAnimal) || item.IsInherited( BaseBuildingBase ) )
373  {
374  return true;
375  }
376  return false;
377  }
378 
379  void ShowItemsInContainers( array<EntityAI> items )
380  {
381  EntityAI item;
382  SlotsIcon icon;
383  int x;
384  int visible_items_count = 0;
385  int visible_rows = 0;
386  ref array<EntityAI> visible_items = new array<EntityAI>;
387 
388  for( x = 0; x < items.Count(); x++ )
389  {
390  item = items.Get( x );
391 
392  if (item == null || ExcludeFromContainer(item))
393  continue;
394 
395  visible_items.Insert( item );
396  visible_items_count++;
397  }
398 
399  RecomputeNumberOfContainers( visible_items );
400 
401  for( x = 0; x < visible_items_count; x++ )
402  {
403  item = visible_items.Get( x );
404  int row = Math.Floor( x / ITEMS_IN_ROW );
405  int column = x % ITEMS_IN_ROW;
406  icon = SlotsContainer.Cast( m_Container.Get( row ) ).GetSlotIcon( column );
407  string config = "CfgVehicles " + item.GetType() + " GUIInventoryAttachmentsProps";
408 
409  icon.GetMainWidget().Show( true );
410  icon.GetPanelWidget().SetUserID( item.GetID() );
411 
412  if( m_ShowedItems.Find( item ) != x )
413  icon.Init( item );
414  icon.UpdateInterval();
415 
417  {
419  }
420 
421  bool draggable = false;
422  if( ItemBase.Cast( item ) )
423  {
424  PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
425  draggable = !player.GetInventory().HasInventoryReservation( item, null ) && !player.IsItemsToDelete();
426  draggable = draggable && item.CanPutIntoHands( GetGame().GetPlayer() );
427  draggable = draggable && item.GetInventory().CanRemoveEntity();
428  }
429 
430  if( !draggable && GetDragWidget() == icon.GetPanelWidget() )
433 
434  ref map<int, ref Container> showed_items = ( VicinityContainer.Cast( m_Parent ) ).m_ShowedItemsIDs;
435 
436  int showed = showed_items.Count();
437  ClosableContainer conta = ClosableContainer.Cast( showed_items.Get( item.GetID() ) );
438  CollapsibleContainer conta2 = CollapsibleContainer.Cast( showed_items.Get( item.GetID() ) );
439 
440  bool show_radial_icon;
441  if( conta )
442  {
443  show_radial_icon = conta.IsOpened();
444  show_radial_icon = show_radial_icon && ( item.GetInventory().GetCargo() || item.GetSlotsCountCorrect() > 0 );
445  show_radial_icon = show_radial_icon && !GetGame().ConfigIsExisting( config );
446  show_radial_icon = show_radial_icon && !item.GetInventory().IsInventoryLockedForLockType( HIDE_INV_FROM_SCRIPT );
447  icon.GetRadialIconPanel().Show( true );
448  icon.GetRadialIcon().Show( !show_radial_icon );
449  icon.GetRadialIconClosed().Show( show_radial_icon );
450  }
451  else if( conta2 )
452  {
453  show_radial_icon = !conta2.IsHidden();
454  Widget rip = icon.GetRadialIconPanel();
455  rip.Show( !item.GetInventory().IsInventoryLockedForLockType( HIDE_INV_FROM_SCRIPT ) );
456  icon.GetRadialIcon().Show( !show_radial_icon );
457  icon.GetRadialIconClosed().Show( show_radial_icon );
458  }
459  else
460  {
461  icon.GetRadialIconPanel().Show( false );
462  }
463  }
464 
465  SlotsContainer slots_last = SlotsContainer.Cast( m_Container.Get( visible_items.Count() / ITEMS_IN_ROW ) );
466  for(int c = visible_items_count % ITEMS_IN_ROW; c < ITEMS_IN_ROW; c++)
467  {
468  icon = slots_last.GetSlotIcon( c );
469  icon.GetMainWidget().Show( false );
470  icon.Clear();
471  }
472 
473  #ifndef PLATFORM_CONSOLE
474  if( visible_items_count % ITEMS_IN_ROW == 0 )
475  {
476  slots_last = SlotsContainer.Cast( m_Container.Get( m_Container.Count() - 1 ) );
477  slots_last.GetSlotIcon( 0 ).GetMainWidget().Show( true );
478  slots_last.GetSlotIcon( 0 ).GetGhostSlot().Show( false );
479  slots_last.GetMainWidget().Update();
480  }
481  #endif
482 
483  m_ShowedItems = visible_items;
484  }
485 
486  void DoubleClick(Widget w, int x, int y, int button)
487  {
488  if( button == MouseState.LEFT )
489  {
490  if( w == null )
491  {
492  return;
493  }
494  ItemPreviewWidget iw = ItemPreviewWidget.Cast( w.FindAnyWidget( "Render" ) );
495  if( !iw )
496  {
497  string name = w.GetName();
498  name.Replace( "PanelWidget", "Render" );
499  iw = ItemPreviewWidget.Cast( w.FindAnyWidget( name ) );
500  }
501 
502  if( !iw )
503  {
504  iw = ItemPreviewWidget.Cast( w );
505  }
506 
507  ItemBase item = ItemBase.Cast( iw.GetItem() );
508  if( !item )
509  {
510  return;
511  }
512 
513  if( GetGame().GetPlayer().GetInventory().HasInventoryReservation( item, null ) )
514  {
515  return;
516  }
517 
518  if( !item.GetInventory().CanRemoveEntity() )
519  return;
520 
521  PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
522 
523  if ( player.GetInventory().HasEntityInInventory( item ) && GetGame().GetPlayer().GetHumanInventory().CanAddEntityInHands( item ) )
524  {
525  player.PredictiveTakeEntityToHands( item );
526  }
527  else
528  {
530  player.GetInventory().FindFreeLocationFor( item, FindInventoryLocationType.ANY, dst );
531  if( dst.IsValid() && player.GetInventory().LocationCanAddEntity( dst ) )
532  {
534  }
535  }
536 
538  InventoryMenu menu = InventoryMenu.Cast( GetGame().GetUIManager().FindMenu( MENU_INVENTORY ) );
539  if( menu )
540  {
541  menu.RefreshQuickbar();
542  }
543  }
544  }
545 
547  {
548  string quantity_text = "";
549  if ( item.IsInherited( InventoryItem ) )
550  {
551  ItemBase item_base = ItemBase.Cast( item );
552  float quantity = item_base.GetQuantity();
553  int ammo;
554  if ( item.IsInherited( Magazine ) )
555  {
556  Magazine magazine_item = Magazine.Cast( item );
557  ammo = magazine_item.GetAmmoCount();
558  quantity_text = ammo.ToString();
559  return quantity_text;
560  }
561  else if ( item.IsInherited( ItemBook ) )
562  {
563  return "";
564  }
565  int max = item.GetQuantityMax();
566  string unit = item.ConfigGetString( "stackedUnit" );
567 
568  if ( max > 0 )
569  {
570  if ( max == 1 )
571  {
572  float tmp = Math.Round( ( quantity / max ) * 100 );
573  quantity_text = tmp.ToString() + "%";
574  }
575  else
576  {
577  quantity_text = quantity.ToString();
578  }
579  }
580  }
581  return quantity_text;
582  }
583 
585  {
586  if ( item.IsInherited( InventoryItem ) )
587  {
588  ItemBase item_base = ItemBase.Cast( item );
589  if ( item.IsInherited( Magazine ) )
590  {
591  return QUANTITY_COUNT;
592  }
593  else if ( item.IsInherited( ItemBook ) )
594  {
595  return QUANTITY_HIDDEN;
596  }
597  int max = item.GetQuantityMax();
598  bool bar = item.ConfigGetBool( "quantityBar" );
599  if ( max > 0 )
600  {
601  if ( max == 1 || bar )
602  {
603  return QUANTITY_PROGRESS;
604  }
605  else
606  {
607  return QUANTITY_COUNT;
608  }
609  }
610  }
611  return QUANTITY_HIDDEN;
612  }
613 
615  {
616  float quantity = 0;
617  if ( item.IsInherited( InventoryItem ) )
618  {
619  ItemBase item_base = ItemBase.Cast( item );
620  if ( item.IsInherited( Magazine ) )
621  {
622  Magazine magazine_item = Magazine.Cast( item );
623  quantity = magazine_item.GetAmmoCount();
624  }
625  else
626  {
627  quantity = item_base.GetQuantity();
628  }
629  }
630  return quantity;
631  }
632 
633  void MouseButtonDown( Widget w, int x, int y, int button)
634  {
635  string name = w.GetName();
636  name.Replace( "PanelWidget", "Render" );
637  ItemPreviewWidget item_preview = ItemPreviewWidget.Cast( w.FindAnyWidget( name ) );
638  ItemBase item = ItemBase.Cast( item_preview.GetItem() );
639  bool draggable = false;
640  if( item )
641  {
642  PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
643  draggable = !player.GetInventory().HasInventoryReservation( item, null ) && !player.IsItemsToDelete();
644  draggable = draggable && item.CanPutIntoHands( GetGame().GetPlayer() );
645  draggable = draggable && item.GetInventory().CanRemoveEntity();
646  }
647 
648  ItemManager.GetInstance().SetWidgetDraggable( w, draggable );
649  }
650 
651  void MouseClick( Widget w, int x, int y, int button)
652  {
653  string name = w.GetName();
654  name.Replace( "PanelWidget", "Render" );
655  ItemPreviewWidget item_preview = ItemPreviewWidget.Cast( w.FindAnyWidget( name ) );
656  EntityAI item = item_preview.GetItem();
657  InventoryItem itemAtPos = InventoryItem.Cast( item );
658  Container conta;
659 
660  if( m_Parent )
661  {
662  ref map<int, ref Container> showed_items = ( VicinityContainer.Cast( m_Parent ) ).m_ShowedItemsIDs;
663 
664  if( item && showed_items )
665  {
666  conta = showed_items.Get( item.GetID() );
667  ( VicinityContainer.Cast( m_Parent ) ).ToggleContainer( conta );
668  int showed = showed_items.Count();
669  string config = "CfgVehicles " + item.GetType() + " GUIInventoryAttachmentsProps";
670 
671  if ( button == MouseState.RIGHT )
672  {
673  if ( itemAtPos )
674  {
675  itemAtPos.OnRightClick();
676  }
677  }
678  else if ( button == MouseState.MIDDLE )
679  {
680  InspectItem( itemAtPos );
681  return;
682  }
683  }
684  }
685  }
686 
687  override void OnDropReceivedFromHeader( Widget w, int x, int y, Widget receiver )
688  {
689  ItemPreviewWidget ipw = ItemPreviewWidget.Cast( w.FindAnyWidget("Render") );
690  if( !ipw )
691  {
692  string name = w.GetName();
693  name.Replace( "PanelWidget", "Render" );
694  ipw = ItemPreviewWidget.Cast( w.FindAnyWidget( name ) );
695  }
696  if( !ipw )
697  {
698  ipw = ItemPreviewWidget.Cast( w );
699  }
700 
701  if( !ipw.IsInherited( ItemPreviewWidget ) )
702  {
703  return;
704  }
705 
706  PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
707  ItemBase item = ItemBase.Cast(ipw.GetItem());
708 
709  if( item )
710  {
711  if( !item.GetInventory().CanRemoveEntity() )
712  return;
713 
714  if( player.CanDropEntity( item ) )
715  {
716  if( item.GetTargetQuantityMax() < item.GetQuantity() )
717  item.SplitIntoStackMaxClient( null, -1 );
718  else
719  player.PhysicalPredictiveDropItem( item );
720  }
721  }
722  }
723 
724  void RecomputeNumberOfContainers( array<EntityAI> items )
725  {
726  int number_of_containers = m_Container.m_Body.Count();
727  int number_of_containers_needed = ( items.Count() / ITEMS_IN_ROW ) + 1;
728  int difference = number_of_containers_needed - number_of_containers;
729 
730  if( difference != 0 )
731  {
732  if( difference > 0 )
733  {
734  for( int g = 0; g < difference; g++ )
735  {
736  SlotsContainer con = new SlotsContainer( m_Container, null );
737  m_Container.Insert( con );
738  for( int j = 0; j < ITEMS_IN_ROW; j++ )
739  {
740  SlotsIcon icon = con.GetSlotIcon( j );
741  WidgetEventHandler.GetInstance().RegisterOnDropReceived( icon.GetPanelWidget(), m_Parent, "OnDropReceivedFromIcon" );
742  WidgetEventHandler.GetInstance().RegisterOnDropReceived( icon.GetGhostSlot(), m_Parent, "OnDropReceivedFromHeader" );
743  WidgetEventHandler.GetInstance().RegisterOnDropReceived( icon.GetMainWidget(), m_Parent, "OnDropReceivedFromHeader" );
744 
747  WidgetEventHandler.GetInstance().RegisterOnDraggingOver( icon.GetMainWidget(), m_Parent, "DraggingOverHeader" );
748 
749  WidgetEventHandler.GetInstance().RegisterOnDoubleClick( icon.GetPanelWidget(), this, "DoubleClick" );
751  WidgetEventHandler.GetInstance().RegisterOnMouseButtonDown( icon.GetPanelWidget(), this, "MouseButtonDown" );
752  }
753 
754  con.SetColumnCount( items.Count() % ITEMS_IN_ROW );
755  m_SlotsCount++;
756  }
757  }
758  else
759  {
760  for( int gx = 0; gx < ( difference * -1 ); gx++ )
761  {
762  Widget w = m_Container.m_Body.Get( m_SlotsCount - 1 ).GetMainWidget();
763  delete w;
764  m_Container.m_Body.Remove( m_SlotsCount - 1 );
765  m_SlotsCount--;
766  }
767  }
768  if( m_Parent )
769  {
770  m_Parent.Refresh();
771  if( m_Parent.m_Parent )
772  {
773  m_Parent.m_Parent.Refresh();
774  }
775  }
776  }
777 
778  if( (items.Count() % ITEMS_IN_ROW) == 0 )
779  {
780  SlotsContainer.Cast( m_Container.Get( number_of_containers_needed - 1 ) ).SetColumnCount( ITEMS_IN_ROW );
781  }
782  else
783  {
784  SlotsContainer.Cast( m_Container.Get( number_of_containers_needed - 1 ) ).SetColumnCount( items.Count() % ITEMS_IN_ROW );
785  }
786 
787  for( int i = 0; i < number_of_containers_needed - 1; i++ )
788  {
789  SlotsContainer.Cast( m_Container.Get( i ) ).SetColumnCount( ITEMS_IN_ROW );
790  }
791  }
792 }
ItemBase
Definition: InventoryItem.c:445
SlotsContainer
Definition: SlotsContainer.c:1
GetGame
proto native CGame GetGame()
ActionManagerClient::CanSetActionFromInventory
bool CanSetActionFromInventory(ItemBase mainItem, ItemBase targetItem)
Definition: ActionManagerClient.c:883
LayoutHolder
Definition: Container.c:1
LayoutHolder::Count
int Count()
Definition: Container.c:69
Icon::CombineItems
bool CombineItems(EntityAI entity1, EntityAI entity2)
Definition: Icon.c:823
SlotsIcon::Init
void Init(EntityAI obj, bool reservation=false)
Definition: SlotsIcon.c:394
QuantityConversions
Definition: QuantityConversions.c:1
VicinitySlotsContainer::MouseClick
void MouseClick(Widget w, int x, int y, int button)
Definition: VicinitySlotsContainer.c:651
m_Parent
protected Widget m_Parent
Definition: SizeToChild.c:92
Math::Round
proto static native float Round(float f)
Returns mathematical round of value.
CanDropEntity
bool CanDropEntity(notnull EntityAI item)
Returns if item can be dropped out from this entity.
Definition: EntityAI.c:1462
VicinitySlotsContainer::IsItemWithQuantityActive
override bool IsItemWithQuantityActive()
Definition: VicinitySlotsContainer.c:88
ItemManager::SetWidgetDraggable
void SetWidgetDraggable(Widget w, bool draggable)
Definition: ItemManager.c:484
VicinitySlotsContainer::IsItemActive
override bool IsItemActive()
Definition: VicinitySlotsContainer.c:94
SlotsContainer::GetSlotIcon
SlotsIcon GetSlotIcon(int index)
Definition: SlotsContainer.c:50
VicinitySlotsContainer::IsItemWithContainerActive
bool IsItemWithContainerActive()
Definition: VicinitySlotsContainer.c:82
VicinitySlotsContainer::MoveGridCursor
override void MoveGridCursor(int direction)
Definition: VicinitySlotsContainer.c:118
InventoryMenu
void InventoryMenu()
Definition: InventoryMenu.c:20
SlotsContainer::SetColumnCount
void SetColumnCount(int column_count)
Definition: SlotsContainer.c:40
WidgetEventHandler::GetInstance
static WidgetEventHandler GetInstance()
Definition: WidgetEventHandler.c:22
ItemBase::CanPutIntoHands
override bool CanPutIntoHands(EntityAI player)
Definition: PlantBase.c:439
VicinitySlotsContainer::CanEquip
override bool CanEquip()
Definition: VicinitySlotsContainer.c:193
VicinitySlotsContainer::ExcludeFromContainer
bool ExcludeFromContainer(EntityAI item)
Definition: VicinitySlotsContainer.c:366
CGame::ConfigIsExisting
proto native bool ConfigIsExisting(string path)
InventoryMode
InventoryMode
Definition: Inventory.c:19
InventoryLocation
InventoryLocation.
Definition: InventoryLocation.c:27
y
Icon y
SlotsIcon::IsOutOfReach
bool IsOutOfReach()
Definition: SlotsIcon.c:545
ITEMS_IN_ROW
const int ITEMS_IN_ROW
Definition: Attachments.c:1
VicinitySlotsContainer::CanCombineAmmo
override bool CanCombineAmmo()
Definition: VicinitySlotsContainer.c:182
ItemManager::HideTooltip
void HideTooltip()
Definition: ItemManager.c:326
Direction
Direction
Definition: Inventory.c:1
WidgetLayoutName
Definition: WidgetLayoutName.c:1
DayZInfected
Definition: ZombieBase.c:1
VicinitySlotsContainer::RecomputeNumberOfContainers
void RecomputeNumberOfContainers(array< EntityAI > items)
Definition: VicinitySlotsContainer.c:724
SlotsIcon::Clear
void Clear()
Definition: SlotsIcon.c:435
m_player
DayZPlayer m_player
Definition: RandomGeneratorSyncManager.c:15
SplitItemUtils
Definition: SplitItemUtils.c:1
InventoryItem
Definition: ItemBase.c:7
FindInventoryLocationType
FindInventoryLocationType
flags for searching locations in inventory
Definition: InventoryLocation.c:15
ItemManager::GetSelectedIcon
SlotsIcon GetSelectedIcon()
Definition: ItemManager.c:85
VicinitySlotsContainer::OnDropReceivedFromHeader
override void OnDropReceivedFromHeader(Widget w, int x, int y, Widget receiver)
Definition: VicinitySlotsContainer.c:687
QUANTITY_PROGRESS
const int QUANTITY_PROGRESS
Definition: constants.c:368
SlotsIcon::UpdateInterval
override void UpdateInterval()
Definition: SlotsIcon.c:578
SlotsIcon::GetRadialIcon
Widget GetRadialIcon()
Definition: SlotsIcon.c:231
GameInventory::CanSwapEntitiesEx
static bool CanSwapEntitiesEx(notnull EntityAI item1, notnull EntityAI item2)
Definition: Inventory.c:512
MENU_INVENTORY
const int MENU_INVENTORY
Definition: constants.c:53
CancelWidgetDragging
proto native Widget CancelWidgetDragging()
VicinitySlotsContainer::m_SlotsCount
protected int m_SlotsCount
Definition: VicinitySlotsContainer.c:5
VicinitySlotsContainer::MouseButtonDown
void MouseButtonDown(Widget w, int x, int y, int button)
Definition: VicinitySlotsContainer.c:633
VicinitySlotsContainer::HasItemQuantity
int HasItemQuantity(EntityAI item)
Definition: VicinitySlotsContainer.c:584
ItemManager::GetSelectedItem
EntityAI GetSelectedItem()
Definition: ItemManager.c:70
VicinitySlotsContainer::GetItemQuantityText
string GetItemQuantityText(EntityAI item)
Definition: VicinitySlotsContainer.c:546
map< int, ref Container >
string::ToString
static proto string ToString(void var, bool type=false, bool name=false, bool quotes=true)
Return string representation of variable.
VicinitySlotsContainer::OnShow
override void OnShow()
Definition: VicinitySlotsContainer.c:356
QuantityConversions::HasItemQuantity
static int HasItemQuantity(notnull EntityAI item)
Definition: QuantityConversions.c:119
ActionManagerClient::CanPerformActionFromInventory
bool CanPerformActionFromInventory(ItemBase mainItem, ItemBase targetItem)
Definition: ActionManagerClient.c:821
ItemPreviewWidget::GetItem
proto native EntityAI GetItem()
VicinitySlotsContainer::UnfocusAll
override void UnfocusAll()
Definition: VicinitySlotsContainer.c:106
PlayerBase
Definition: PlayerBaseClient.c:1
float::ToString
proto string ToString()
VicinityContainer
Definition: VicinityContainer.c:1
WidgetLayoutName::Container
const string Container
Definition: WidgetLayoutName.c:47
ItemManager::IsDragging
bool IsDragging()
Definition: ItemManager.c:321
VicinitySlotsContainer::GetFocusedIcon
SlotsIcon GetFocusedIcon()
Definition: VicinitySlotsContainer.c:72
SlotsIcon::GetRadialIconClosed
Widget GetRadialIconClosed()
Definition: SlotsIcon.c:226
name
string name
Definition: PluginDayZInfectedDebug.c:32
BaseBuildingBase
Definition: Fence.c:1
VicinitySlotsContainer::~VicinitySlotsContainer
void ~VicinitySlotsContainer()
Definition: VicinitySlotsContainer.c:339
VicinitySlotsContainer::SelectItem
override bool SelectItem()
Definition: VicinitySlotsContainer.c:267
VicinitySlotsContainer::m_ItemsCount
protected int m_ItemsCount
Definition: VicinitySlotsContainer.c:4
Container
Definition: CargoContainer.c:1
GetDragWidget
proto native Widget GetDragWidget()
VicinitySlotsContainer::SetLayoutName
override void SetLayoutName()
Definition: VicinitySlotsContainer.c:351
QUANTITY_HIDDEN
const int QUANTITY_HIDDEN
Definition: constants.c:366
VicinitySlotsContainer::m_Container
protected ref Container m_Container
Definition: VicinitySlotsContainer.c:3
ItemManager::SetTemperature
void SetTemperature(EntityAI item, Widget item_w)
Definition: ItemManager.c:373
VicinitySlotsContainer::VicinitySlotsContainer
void VicinitySlotsContainer(LayoutHolder parent)
Definition: VicinitySlotsContainer.c:8
SplitItemUtils::TakeOrSplitToInventoryLocation
static void TakeOrSplitToInventoryLocation(notnull PlayerBase player, notnull InventoryLocation dst)
Definition: SplitItemUtils.c:34
string::Replace
proto int Replace(string sample, string replace)
Replace all occurrances of 'sample' in 'str' by 'replace'.
Class::CastTo
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
SlotsIcon
Definition: SlotsIcon.c:1
ItemManager
Definition: ItemManager.c:1
WidgetEventHandler::RegisterOnDraggingOver
void RegisterOnDraggingOver(Widget w, Managed eventHandler, string functionName)
Definition: WidgetEventHandler.c:112
VicinitySlotsContainer::EquipItem
override bool EquipItem()
Definition: VicinitySlotsContainer.c:208
Container
const string Container
Definition: CentralEconomy.c:64
ActionManagerClient
Definition: ActionManagerClient.c:4
QUANTITY_COUNT
const int QUANTITY_COUNT
Definition: constants.c:367
ItemManager::GetHandsPreview
HandsPreview GetHandsPreview()
Definition: ItemManager.c:60
MouseState
MouseState
Definition: EnSystem.c:310
VicinitySlotsContainer::ShowItemsInContainers
void ShowItemsInContainers(array< EntityAI > items)
Definition: VicinitySlotsContainer.c:379
VicinitySlotsContainer::GetRowSlotCount
int GetRowSlotCount()
Definition: VicinitySlotsContainer.c:361
VicinitySlotsContainer::TransferItem
override bool TransferItem()
Definition: VicinitySlotsContainer.c:236
VicinitySlotsContainer::SetDefaultFocus
void SetDefaultFocus(bool while_micromanagment_mode=false)
Definition: VicinitySlotsContainer.c:39
SlotsIcon::GetGhostSlot
ImageWidget GetGhostSlot()
Definition: SlotsIcon.c:166
WidgetEventHandler::RegisterOnMouseButtonDown
void RegisterOnMouseButtonDown(Widget w, Managed eventHandler, string functionName)
Definition: WidgetEventHandler.c:70
VicinitySlotsContainer::InspectItem
override bool InspectItem()
Definition: VicinitySlotsContainer.c:224
x
Icon x
Math::Floor
proto static native float Floor(float f)
Returns floor of value.
Icon
Definition: Icon.c:1
LeftArea::SetPreviousActive
override void SetPreviousActive(bool force=false)
Definition: LeftArea.c:203
ItemPreviewWidget
Definition: gameplay.c:259
ItemManager::GetInstance
static ItemManager GetInstance()
Definition: ItemManager.c:224
WidgetEventHandler::RegisterOnDoubleClick
void RegisterOnDoubleClick(Widget w, Managed eventHandler, string functionName)
Definition: WidgetEventHandler.c:140
CollapsibleContainer
Definition: CollapsibleContainer.c:1
CGame::GetPlayer
proto native DayZPlayer GetPlayer()
SlotsIcon::GetPanelWidget
Widget GetPanelWidget()
Definition: SlotsIcon.c:136
VicinitySlotsContainer::Combine
override bool Combine()
Definition: VicinitySlotsContainer.c:252
SlotsIcon::GetRender
ItemPreviewWidget GetRender()
Definition: SlotsIcon.c:161
Container::Get
override LayoutHolder Get(int x)
Definition: ClosableContainer.c:72
VicinitySlotsContainer
Definition: VicinitySlotsContainer.c:1
SlotsContainer::GetColumnCount
int GetColumnCount()
Definition: SlotsContainer.c:45
GetParent
proto native Widget GetParent()
Definition: Construction.c:40
LeftArea::SetNextActive
override void SetNextActive()
Definition: LeftArea.c:159
ItemManager::GetCombinationFlags
static int GetCombinationFlags(EntityAI entity1, EntityAI entity2)
Definition: ItemManager.c:503
Widget
Definition: EnWidgets.c:166
SlotsIcon::GetRadialIconPanel
Widget GetRadialIconPanel()
Definition: SlotsIcon.c:221
InventoryItem::OnRightClick
override void OnRightClick()
Definition: ItemBase.c:1693
CollapsibleContainer::IsHidden
bool IsHidden()
Definition: CollapsibleContainer.c:169
LeftArea
Definition: LeftArea.c:1
Math
Definition: EnMath.c:6
ItemManager::PrepareTooltip
void PrepareTooltip(EntityAI item, int x=0, int y=0)
Definition: ItemManager.c:428
GardenBase
Definition: GardenPlot.c:1
VicinitySlotsContainer::Select
override bool Select()
Definition: VicinitySlotsContainer.c:279
HandsPreview::GetIcon
Icon GetIcon()
Definition: HandsPreview.c:30
Class
Super root of all classes in Enforce script.
Definition: EnScript.c:7
VicinitySlotsContainer::GetItemQuantity
float GetItemQuantity(InventoryItem item)
Definition: VicinitySlotsContainer.c:614
VicinitySlotsContainer::CanCombine
override bool CanCombine()
Definition: VicinitySlotsContainer.c:174
GetPlayer
PlayerBase GetPlayer()
Definition: ModifiersManager.c:264
VicinitySlotsContainer::GetFocusedItem
override EntityAI GetFocusedItem()
Definition: VicinitySlotsContainer.c:62
InventoryLocation::IsValid
proto native bool IsValid()
verify current set inventory location
ItemManager::SetSelectedItem
void SetSelectedItem(EntityAI selected_item, Container selected_container, Widget selected_widget, SlotsIcon selected_icon)
Definition: ItemManager.c:90
EntityAI
Base native class of all vehicles in game.
Definition: Building.c:4
WidgetEventHandler::RegisterOnDropReceived
void RegisterOnDropReceived(Widget w, Managed eventHandler, string functionName)
Definition: WidgetEventHandler.c:91
GetInventory
proto native GameInventory GetInventory()
ClosableContainer
Definition: ContainerWithCargoAndAttachments.c:1
VicinitySlotsContainer::DoubleClick
void DoubleClick(Widget w, int x, int y, int button)
Definition: VicinitySlotsContainer.c:486
GameInventory
script counterpart to engine's class Inventory
Definition: Inventory.c:30
SlotsIcon::GetCursorWidget
Widget GetCursorWidget()
Definition: SlotsIcon.c:141
VicinitySlotsContainer::IsEmptyItemActive
bool IsEmptyItemActive()
Definition: VicinitySlotsContainer.c:100
VicinitySlotsContainer::m_ShowedItems
protected ref array< EntityAI > m_ShowedItems
Definition: VicinitySlotsContainer.c:6
WidgetEventHandler
Definition: WidgetEventHandler.c:1
ItemManager::IsMicromanagmentMode
bool IsMicromanagmentMode()
Definition: ItemManager.c:55
DayZAnimal
Definition: AnimalBase.c:1
WidgetEventHandler::RegisterOnMouseButtonUp
void RegisterOnMouseButtonUp(Widget w, Managed eventHandler, string functionName)
Definition: WidgetEventHandler.c:77