Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
zombiecontainer.c
Go to the documentation of this file.
2 {
3  protected ref AttachmentsGroupContainer m_Container;
4  protected ref ContainerWithCargo m_CargoGrid;
5  protected ref map<int, SlotsIcon> m_InventorySlots;
6  protected ref map<EntityAI, ref Container> m_ShowedItems = new ref map<EntityAI, ref Container>;
7  protected EntityAI m_ZombieEntity;
8 
9  void ZombieContainer( LayoutHolder parent, int sort = -1 )
10  {
11  m_InventorySlots = new ref map<int, SlotsIcon>;
12  m_Container = new AttachmentsGroupContainer(this);
13 
14  m_Container.SetHeader(GetHeader());
15  SetHeaderName();
16  SetHeader(null);
17  m_Body.Insert( m_Container );
18 
19  m_MainWidget = m_RootWidget.FindAnyWidget( "body" );
20 
21  WidgetEventHandler.GetInstance().RegisterOnChildAdd( m_MainWidget, this, "OnChildAdd" );
22  WidgetEventHandler.GetInstance().RegisterOnChildRemove( m_MainWidget, this, "OnChildRemove" );
23 
24 
25  RecomputeOpenedContainers();
26  }
27 
28  void ~ZombieContainer()
29  {
30  if( m_ZombieEntity )
31  {
32  m_ZombieEntity.GetOnItemAttached().Remove(ItemAttached);
33  m_ZombieEntity.GetOnItemDetached().Remove(ItemDetached);
34  }
35  }
36 
37  void SetEntity( EntityAI zombie_entity )
38  {
39  m_ZombieEntity = zombie_entity;
40  m_ZombieEntity.GetOnItemAttached().Insert(ItemAttached);
41  m_ZombieEntity.GetOnItemDetached().Insert(ItemDetached);
42  InitGhostSlots();
43  m_Parent.Refresh();
44  }
45 
46  override void UpdateRadialIcon()
47  {
48  if ( m_SlotIcon )
49  {
50  bool show_radial_icon;
51  show_radial_icon = IsHidden();
52  Widget rip = m_SlotIcon.GetRadialIconPanel();
53  Widget icon_open = m_SlotIcon.GetRadialIcon();
54  Widget icon_closed = m_SlotIcon.GetRadialIconClosed();
55  rip.Show( !m_ZombieEntity.GetInventory().IsInventoryLockedForLockType( HIDE_INV_FROM_SCRIPT ) && m_ZombieEntity.CanDisplayCargo());
56  icon_open.Show( show_radial_icon );
57  icon_closed.Show( !show_radial_icon );
58  }
59  }
60 
61  override bool IsItemWithQuantityActive()
62  {
63  EntityAI ent = GetFocusedItem();
64  return ent && QuantityConversions.HasItemQuantity( ent ) && ent.CanBeSplit();
65  }
66 
67  bool IsContainerWithCargoActive()
68  {
69  return GetFocusedContainer().IsInherited( ContainerWithCargo );
70  }
71 
72  bool IsItemWithAttachmentsActive()
73  {
74  return GetFocusedContainer().IsInherited( ContainerWithCargoAndAttachments );
75  }
76 
77  bool IsZombieEquipmentActive()
78  {
79  return GetFocusedContainer() == m_Container;
80  }
81 
82  bool IsItemWithContainerActive()
83  {
84  EntityAI ent = GetFocusedItem();
85  return ent && ( ent.GetInventory().GetCargo() || ent.GetSlotsCountCorrect() > 0 );
86  }
87 
88  bool IsEmptyItemActive()
89  {
90  return !GetFocusedItem();
91  }
92 
93  override void ExpandCollapseContainer()
94  {
95  if( IsZombieEquipmentActive() )
96  {
97  ItemPreviewWidget item_preview = GetFocusedSlotsIcon().GetRender();
98  ToggleContainer( item_preview.GetParent() );
99  }
100  }
101 
102  override void OnDropReceivedFromHeader( Widget w, int x, int y, Widget receiver )
103  {
104  ItemPreviewWidget ipw = ItemPreviewWidget.Cast( w.FindAnyWidget( "Render" ) );
105  if( !ipw )
106  {
107  string name = w.GetName();
108  name.Replace( "PanelWidget", "Render" );
109  ipw = ItemPreviewWidget.Cast( w.FindAnyWidget( name ) );
110  }
111  if( !ipw )
112  {
113  ipw = ItemPreviewWidget.Cast( w );
114  }
115 
116  if( !ipw.IsInherited( ItemPreviewWidget ) )
117  {
118  return;
119  }
120 
121  EntityAI item = ipw.GetItem();
122 
123  if( !item.GetInventory().CanRemoveEntity() )
124  return;
125 
126  if (m_ZombieEntity.GetInventory().CanAddEntityInCargo( item, item.GetInventory().GetFlipCargo() ))
127  GetGame().GetPlayer().PredictiveTakeEntityToTargetCargo( m_ZombieEntity, item );
128  else if( m_ZombieEntity.GetInventory().CanAddEntityToInventory( item ) )
129  {
130  GetGame().GetPlayer().PredictiveTakeEntityToTargetInventory( m_ZombieEntity, FindInventoryLocationType.CARGO, item );
131  }
132  }
133 
134  override void DraggingOverHeader(Widget w, int x, int y, Widget receiver)
135  {
136  ItemPreviewWidget ipw = ItemPreviewWidget.Cast(w.FindAnyWidget( "Render" ));
137  string name = receiver.GetName();
138  name.Replace("PanelWidget", "Render");
139  ItemPreviewWidget receiver_iw = ItemPreviewWidget.Cast( receiver.FindAnyWidget( name ) );
140  EntityAI receiver_item;
141  if (receiver_iw)
142  {
143  receiver_item = receiver_iw.GetItem();
144  }
145 
146  if(!ipw)
147  {
148  name = w.GetName();
149  name.Replace("PanelWidget", "Render");
150  ipw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
151  }
152  if(!ipw)
153  {
154  ipw = ItemPreviewWidget.Cast(w);
155  }
156 
157  if( !ipw.IsInherited(ItemPreviewWidget))
158  {
159  return;
160  }
161 
162  EntityAI item = ipw.GetItem();
163  PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
164 
165  if(!item.GetInventory().CanRemoveEntity())
166  return;
167  }
168 
169  void OnDropReceivedFromGhostArea(Widget w, int x, int y, Widget receiver)
170  {
171  ItemPreviewWidget ipw = ItemPreviewWidget.Cast( w.FindAnyWidget("Render"));
172  string name = receiver.GetName();
173  name.Replace("PanelWidget", "Render");
174  ItemPreviewWidget receiver_iw = ItemPreviewWidget.Cast( receiver.FindAnyWidget(name));
175  EntityAI receiver_item;
176  if (receiver_iw)
177  {
178  receiver_item = receiver_iw.GetItem();
179  }
180 
181  if( !ipw )
182  {
183  name = w.GetName();
184  name.Replace( "PanelWidget", "Render" );
185  ipw = ItemPreviewWidget.Cast( w.FindAnyWidget(name));
186  }
187  if(!ipw)
188  {
189  ipw = ItemPreviewWidget.Cast(w);
190  }
191 
192  if(!ipw.IsInherited(ItemPreviewWidget))
193  {
194  return;
195  }
196 
197  EntityAI item = ipw.GetItem();
198  PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
199 
200  if(!item.GetInventory().CanRemoveEntity())
201  {
202  return;
203  }
204 
205  if(receiver_item)
206  {
207  if(receiver_item.GetInventory().CanAddAttachment(item))
208  {
209  player.PredictiveTakeEntityToTargetAttachment(receiver_item, item);
210  return;
211  }
212  else if(receiver_item.GetInventory().CanAddEntityInCargo(item, item.GetInventory().GetFlipCargo()) && !receiver_item.GetInventory().HasEntityInCargo(item))
213  {
214  player.PredictiveTakeEntityToTargetInventory(receiver_item, FindInventoryLocationType.ANY, item);
215  return;
216  }
217  }
218 
219  if(item)
220  {
221  if(m_ZombieEntity.GetInventory().CanAddAttachment(item))
222  {
223  player.PredictiveTakeEntityToTargetAttachment(m_ZombieEntity, item);
224  }
225  else if(m_ZombieEntity.GetInventory().CanAddEntityToInventory(item))
226  {
227  player.PredictiveTakeEntityToTargetInventory(m_ZombieEntity, FindInventoryLocationType.ANY, item);
228  }
229  }
230 
231  if( item )
232  {
233  if( m_ZombieEntity.GetInventory().CanAddEntityInto(item, FindInventoryLocationType.CARGO ))
234  {
235  player.PredictiveTakeEntityToTargetInventory(m_ZombieEntity, FindInventoryLocationType.CARGO, item);
236  }
237  }
238  }
239 
240  void SetHeaderName()
241  {
242  m_CollapsibleHeader.SetName( "#container_inventory" );
243  }
244 
245  void ItemAttached(EntityAI item, string slot_name)
246  {
247  int slot = InventorySlots.GetSlotIdFromString( slot_name );
248  SlotsIcon icon = m_InventorySlots.Get( slot );
249  if( icon )
250  {
251  icon.Init( item );
252 
253  if( m_ShowedItems.Contains( item ) == false )
254  {
255  string name;
256 
257  if( item.GetSlotsCountCorrect() > 0 )
258  {
259  ContainerWithCargoAndAttachments iwca = new ContainerWithCargoAndAttachments( this, false );
260  iwca.SetEntity( item );
261  WidgetEventHandler.GetInstance().RegisterOnMouseButtonUp( icon.GetPanelWidget(), this, "ToggleContainer" );
262 
263  icon.GetRadialIconPanel().Show( true );
264  m_ShowedItems.Insert( item, iwca );
265 
266  Refresh();
267  }
268  else if( item.GetInventory().GetCargo() )
269  {
270  ContainerWithCargo iwc = new ContainerWithCargo( this, false );
271  iwc.SetEntity( item );
272  iwc.UpdateInterval();
273  WidgetEventHandler.GetInstance().RegisterOnMouseButtonUp( icon.GetPanelWidget(), this, "ToggleContainer" );
274  m_ShowedItems.Insert( item, iwc );
275  icon.GetRadialIconPanel().Show(true);
276 
277  Refresh();
278  }
279  }
280 
281  ClosableContainer conta = ClosableContainer.Cast( m_ShowedItems.Get( item ) );
282  string config = "CfgVehicles " + item.GetType() + " GUIInventoryAttachmentsProps";
283  if( conta && conta.IsInherited( ClosableContainer ) )
284  {
285  bool show_radial_icon = ( item.GetInventory().GetCargo() || item.GetSlotsCountCorrect() > 0 ) && !GetGame().ConfigIsExisting( config );
286  Widget rip = icon.GetRadialIconPanel();
287  Widget icon_open = icon.GetRadialIcon();
288  Widget icon_closed = icon.GetRadialIconClosed();
289  rip.Show( show_radial_icon );
290  icon_open.Show( conta.IsOpened() );
291  icon_closed.Show( !conta.IsOpened() );
292  }
293  RecomputeOpenedContainers();
294  }
295  }
296 
297  void ItemDetached(EntityAI item, string slot_name)
298  {
299  int slot = InventorySlots.GetSlotIdFromString( slot_name );
300  SlotsIcon icon = m_InventorySlots.Get( slot );
301 
302  if( icon )
303  {
304  Container con = m_ShowedItems.Get( item );
305  if( con )
306  {
307  ( Container.Cast( con.m_Parent ) ).Remove( con );
308  RecomputeOpenedContainers();
309  GetMainWidget().Update();
310  Refresh();
311  m_ShowedItems.Remove( item );
312  }
313 
314  icon.Clear();
315  Inventory in = Inventory.Cast( GetRoot() );
316  if( in )
317  in.UpdateConsoleToolbar();
318  }
319  }
320 
321  override bool CanOpenCloseContainerEx(EntityAI focusedEntity)
322  {
324  if (focusedEntity)
325  {
326  c = ClosableContainer.Cast( m_ShowedItems.Get( focusedEntity ) );
327  }
328  else
329  {
330  SlotsIcon icon = GetFocusedSlotsIcon();
331  if (icon)
332  {
333  c = ClosableContainer.Cast(icon.GetContainer());
334  }
335  }
336 
337  if (c && c.IsDisplayable())
338  {
339  return true;
340  }
341 
342  return false;
343  }
344 
345  // mouse button UP or call from ExpandCollapseContainer
346  void ToggleContainer(Widget w)
347  {
348  EntityAI item;
349  SlotsIcon icon;
351  w.GetUserData(icon);
352  if (icon)
353  item = icon.GetEntity();
354 
355  if (item)
356  c = ClosableContainer.Cast(m_ShowedItems.Get(item));
357  else
358  c = ClosableContainer.Cast(icon.GetContainer());
359 
360 
361  if (c)
362  c.Toggle();
363 
364  RecomputeOpenedContainers();
365  }
366 
367  void MouseClick(Widget w, int x, int y, int button)
368  {
369  ItemBase selectedItem;
370  SlotsIcon icon;
371  w.GetUserData(icon);
372  if (icon)
373  selectedItem = ItemBase.Cast(icon.GetEntity());
374 
375  if (selectedItem)
376  {
377  switch (button)
378  {
379  case MouseState.RIGHT:
380  #ifdef DIAG_DEVELOPER
381  if (GetDayZGame().IsLeftCtrlDown())
382  ShowActionMenu(selectedItem);
383  #endif
384  break;
385 
386  case MouseState.MIDDLE:
387  InspectItem(selectedItem);
388  break;
389 
390  case MouseState.LEFT:
391  if (g_Game.IsLeftCtrlDown())
392  {
393  PlayerBase controlledPlayer = PlayerBase.Cast(GetGame().GetPlayer());
394  if (controlledPlayer.CanDropEntity(selectedItem))
395  {
396  if (selectedItem.GetTargetQuantityMax() < selectedItem.GetQuantity())
397  selectedItem.SplitIntoStackMaxClient(null, -1);
398  else
399  controlledPlayer.PhysicalPredictiveDropItem(selectedItem);
400 
401  ItemManager.GetInstance().SetWidgetDraggable(w, false);
402  }
403  }
404  break;
405  }
406  }
407  }
408 
409  SlotsIcon GetSlotsIcon( int row, int column )
410  {
411  return SlotsContainer.Cast( m_Container.Get( row ) ).GetSlotIcon( column );
412  }
413 
414  void InitGhostSlots()
415  {
416  int row, column;
417  SlotsIcon icon;
418  bool has_cargo = m_ZombieEntity.GetInventory().GetCargo() != null;
419 
420  string config_path_ghosts_slots = "CfgVehicles ZombieBase InventoryEquipment playerSlots";
421  array<string> player_ghosts_slots = new array<string>();
422  GetGame().ConfigGetTextArray( config_path_ghosts_slots, player_ghosts_slots );
423 
424  for ( int i = 0; i < player_ghosts_slots.Count(); i++ )
425  {
426  string slot_name = player_ghosts_slots.Get ( i );
427  string path = "CfgSlots" + " " + slot_name;
428 
429  if ( GetGame().ConfigIsExisting( path ) )
430  {
431  string icon_name; //icon_name must be in format "set:<setname> image:<imagename>"
432  GetGame().ConfigGetText( path + " ghostIcon", icon_name );
433  column = i % ITEMS_IN_ROW;
434 
435  //START - GetWidgetSlot
436  row = i / ITEMS_IN_ROW;
437  if( row >= m_Container.Count() )
438  {
439  if ( has_cargo )
440  {
441  if( row < ( (player_ghosts_slots.Count() + 1 )/ ITEMS_IN_ROW ) )
442  AddSlotsContainer( ITEMS_IN_ROW );
443  else
444  AddSlotsContainer( ( player_ghosts_slots.Count() + 1 ) % ITEMS_IN_ROW );
445 
446  }
447  else
448  {
449  if ( row < ( player_ghosts_slots.Count() / ITEMS_IN_ROW ) )
450  AddSlotsContainer( ITEMS_IN_ROW );
451  else
452  AddSlotsContainer( player_ghosts_slots.Count() % ITEMS_IN_ROW );
453  }
454 
455  }
456 
457  icon = GetSlotsIcon( row, column );
458 
459  icon.GetMainWidget().Show( true );
460  icon.Clear();
461 
462  WidgetEventHandler.GetInstance().RegisterOnDoubleClick( icon.GetPanelWidget(), this, "DoubleClick" );
463 
464  //END - GetWidgetSlot
465  WidgetEventHandler.GetInstance().RegisterOnDropReceived( icon.GetPanelWidget(), this, "OnDropReceivedFromGhostArea" );
466  WidgetEventHandler.GetInstance().RegisterOnDropReceived( icon.GetGhostSlot(), this, "OnDropReceivedFromGhostArea" );
467  WidgetEventHandler.GetInstance().RegisterOnDraggingOver( icon.GetPanelWidget(), this, "DraggingOver" );
468  WidgetEventHandler.GetInstance().RegisterOnDraggingOver( icon.GetGhostSlot(), this, "DraggingOver" );
469  WidgetEventHandler.GetInstance().RegisterOnDraggingOver( icon.GetPanelWidget(), this, "DraggingOver" );
470  WidgetEventHandler.GetInstance().RegisterOnMouseButtonDown( icon.GetPanelWidget(), this, "MouseClick" );
471 
472  icon.GetGhostSlot().LoadImageFile( 0, StaticGUIUtils.VerifyIconImageString(StaticGUIUtils.IMAGESETGROUP_INVENTORY,icon_name) );
473  //END - LoadIconIntoWidgetSlot
474 
475  GetGame().ConfigGetText( path + " name", slot_name );
476  int slot_id = InventorySlots.GetSlotIdFromString( slot_name );
477  icon.SetSlotID( slot_id );
478  icon.SetSlotDisplayName(InventorySlots.GetSlotDisplayName(slot_id));
479  m_InventorySlots.Set( slot_id, icon );
480 
481  int slot = InventorySlots.GetSlotIdFromString( slot_name );
482  ItemBase item = ItemBase.Cast( m_ZombieEntity.GetInventory().FindAttachment( slot ) );
483 
484  if( item )
485  ItemAttached( item, slot_name );
486  }
487  }
488 
489  if( m_ZombieEntity.GetInventory().GetCargo() )
490  {
491  row = player_ghosts_slots.Count() / ITEMS_IN_ROW;
492  column = player_ghosts_slots.Count() % ITEMS_IN_ROW;
493  if( row >= m_Container.Count() )
494  {
495  if( row < ( player_ghosts_slots.Count() + 1 / ITEMS_IN_ROW ) )
496  AddSlotsContainer( ITEMS_IN_ROW );
497  else
498  AddSlotsContainer( ( player_ghosts_slots.Count() + 1 ) % ITEMS_IN_ROW );
499  }
500 
501  icon = GetSlotsIcon( row, column );
502  icon.GetMainWidget().Show( true );
503  icon.Clear();
504  icon.GetGhostSlot().LoadImageFile( 0, StaticGUIUtils.VerifyIconImageString(StaticGUIUtils.IMAGESETGROUP_INVENTORY,m_ZombieEntity.ConfigGetString("GUIInventoryCargoIcon")) );
505  icon.SetSlotDisplayName( m_ZombieEntity.ConfigGetString("GUIInventoryCargoName") );
506  icon.GetRadialIconPanel().Show( true );
507  icon.GetRadialIcon().Show( true );
508 
509  WidgetEventHandler.GetInstance().RegisterOnMouseButtonUp( icon.GetGhostSlot(), this, "ToggleContainer" );
510  m_CargoGrid = new ContainerWithCargo( this, false );
511  m_CargoGrid.SetEntity( m_ZombieEntity );
512  m_CargoGrid.GetHeader().GetMainWidget().ClearFlags( WidgetFlags.DRAGGABLE );
513  m_ShowedItems.Insert( m_ZombieEntity, m_CargoGrid );
514  icon.SetContainer(m_CargoGrid);
515  }
516 
517  RecomputeOpenedContainers();
518  }
519 
520  void AddSlotsContainer( int row_count )
521  {
522  ref SlotsContainer s_cont = new SlotsContainer( m_Container, m_ZombieEntity );
523  s_cont.SetColumnCount( row_count );
524  m_Container.Insert( s_cont );
525  }
526 
527  Widget GetWidgetSlot( int slot_number )
528  {
529  int row = slot_number / ITEMS_IN_ROW;
530  int column = slot_number % ITEMS_IN_ROW;
531 
532  return m_Container.Get( row ).GetMainWidget().FindAnyWidget( "Render" + column );
533  }
534 
535  void DoubleClick(Widget w, int x, int y, int button)
536  {
537  if( button == MouseState.LEFT && !g_Game.IsLeftCtrlDown())
538  {
539  if( w == null )
540  {
541  return;
542  }
543  ItemPreviewWidget iw = ItemPreviewWidget.Cast( w.FindAnyWidget( "Render" ) );
544  if( !iw )
545  {
546  string name = w.GetName();
547  name.Replace( "PanelWidget", "Render" );
548  iw = ItemPreviewWidget.Cast( w.FindAnyWidget( name ) );
549  }
550 
551  if( !iw )
552  {
553  iw = ItemPreviewWidget.Cast( w );
554  }
555 
556  ItemBase item = ItemBase.Cast( iw.GetItem() );
557  if( !item )
558  {
559  return;
560  }
561 
562  PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
563 
564  if( player.GetInventory().HasInventoryReservation( item, null ) || player.IsItemsToDelete() )
565  {
566  return;
567  }
568 
569  if( !item.GetInventory().CanRemoveEntity() )
570  return;
571 
572  if ( player.GetInventory().HasEntityInInventory( item ) && GetGame().GetPlayer().GetHumanInventory().CanAddEntityInHands( item ) )
573  {
574  player.PredictiveTakeEntityToHands( item );
575  }
576  else
577  {
579  if( player.GetInventory().FindFreeLocationFor( item, FindInventoryLocationType.ANY, il) )
580  {
581  if( item.GetTargetQuantityMax(il.GetSlot()) < item.GetQuantity() )
582  item.SplitIntoStackMaxToInventoryLocationClient( il );
583  else
584  player.PredictiveTakeEntityToInventory( FindInventoryLocationType.ANY, item );
585  }
586  else if( GetGame().GetPlayer().GetHumanInventory().CanAddEntityInHands( item ) )
587  {
588  if( item.GetTargetQuantityMax() < item.GetQuantity() )
589  item.SplitIntoStackMaxHandsClient( player );
590  else
591  player.PredictiveTakeEntityToHands( item );
592  }
593  }
594 
595  HideOwnedTooltip();
596  InventoryMenu menu = InventoryMenu.Cast( GetGame().GetUIManager().FindMenu( MENU_INVENTORY ) );
597  if( menu )
598  {
599  menu.RefreshQuickbar();
600  }
601  }
602  }
603 
604  override void CollapseButtonOnMouseButtonDown(Widget w)
605  {
606  super.CollapseButtonOnMouseButtonDown(w);
607  }
608 
609  override bool SplitItem()
610  {
611  if ( CanSplit() )
612  {
613  if ( GetFocusedContainer().IsInherited( ContainerWithCargo ) || GetFocusedContainer().IsInherited( ContainerWithCargoAndAttachments ) )
614  {
615  return GetFocusedContainer().SplitItem();
616  }
617  }
618  return false;
619  }
620 
621  override bool EquipItem()
622  {
623  if (CanEquip())
624  {
625  if ( GetFocusedContainer().IsInherited( ContainerWithCargo ) || GetFocusedContainer().IsInherited( ContainerWithCargoAndAttachments ) )
626  {
627  return GetFocusedContainer().EquipItem();
628  }
629  else
630  {
631  EntityAI item = GetFocusedItem();
632  if( item )
633  {
634  GetGame().GetPlayer().PredictiveTakeEntityToInventory( FindInventoryLocationType.ATTACHMENT, item );
635  return true;
636  }
637  }
638  }
639  return false;
640  }
641 
642  override bool TransferItem()
643  {
644  LeftArea left_area = LeftArea.Cast( GetParent() );
645  EntityAI item;
646  if (CanTakeToInventory())
647  {
648 
649  if (left_area)
650  {
651  if (GetFocusedContainer().IsInherited( ContainerWithCargo ) || GetFocusedContainer().IsInherited( ContainerWithCargoAndAttachments ))
652  {
653  return GetFocusedContainer().TransferItem();
654  }
655  else
656  {
657  item = GetFocusedItem();
658  if( item )
659  {
660  GetGame().GetPlayer().PredictiveTakeEntityToInventory( FindInventoryLocationType.CARGO, item );
661  return true;
662  }
663  }
664  }
665  else
666  {
667  if (!GetFocusedContainer().IsInherited( ContainerWithCargo ) && !GetFocusedContainer().IsInherited( ContainerWithCargoAndAttachments ))
668  {
669  item = GetFocusedItem();
670  if (item)
671  {
672  GetGame().GetPlayer().PredictiveTakeEntityToInventory( FindInventoryLocationType.CARGO, item );
673  return true;
674  }
675  }
676  }
677  }
678  return false;
679  }
680 
681  override bool Select()
682  {
683  if( GetFocusedContainer().IsInherited( ContainerWithCargo ) || GetFocusedContainer().IsInherited( ContainerWithCargoAndAttachments ) )
684  {
685  return GetFocusedContainer().Select();
686  }
687  else
688  {
689  SlotsIcon selected_slot = ItemManager.GetInstance().GetSelectedIcon();
690  EntityAI focused_item = GetFocusedItem();
691  EntityAI selected_item = ItemManager.GetInstance().GetSelectedItem();
692  if( !(selected_slot && selected_slot.IsOutOfReach() ) )
693  {
694  if( selected_item )
695  {
696  if( selected_item != focused_item)
697  {
698  if( selected_item.GetInventory().CanRemoveEntity() )
699  {
700  GetGame().GetPlayer().PredictiveTakeEntityToTargetInventory( m_ZombieEntity, FindInventoryLocationType.ANY, selected_item );
701  ItemManager.GetInstance().SetSelectedItemEx(null, null, null);
702  return true;
703  }
704  }
705  }
706  else
707  {
708  if( focused_item && focused_item.GetInventory().CanRemoveEntity() )
709  {
710  EntityAI item_in_hands = GetGame().GetPlayer().GetHumanInventory().GetEntityInHands();
711  if( item_in_hands && item_in_hands.GetInventory().CanRemoveEntity() )
712  {
713  if( GameInventory.CanSwapEntitiesEx( item_in_hands, focused_item ) )
714  {
715  GetGame().GetPlayer().PredictiveSwapEntities( item_in_hands, focused_item );
716  return true;
717  }
718  else
719  {
720  InventoryLocation il_hands_dst = new InventoryLocation;
721  if( GetGame().GetPlayer().GetHumanInventory().FindFreeLocationFor( item_in_hands, FindInventoryLocationType.ANY, il_hands_dst ) )
722  {
723  InventoryMode invMode = InventoryMode.PREDICTIVE;
724 
725  if ( GetGame().GetPlayer().NeedInventoryJunctureFromServer(item_in_hands, item_in_hands.GetHierarchyParent(), il_hands_dst.GetParent()) || GetGame().GetPlayer().NeedInventoryJunctureFromServer(focused_item, focused_item.GetHierarchyParent(), GetGame().GetPlayer()) )
726  invMode = InventoryMode.JUNCTURE;
727 
728  GetGame().GetPlayer().GetHumanInventory().ForceSwapEntities( InventoryMode.JUNCTURE, focused_item, item_in_hands, il_hands_dst );
729  return true;
730  }
731  }
732  }
733  else
734  {
735  if( GetGame().GetPlayer().GetHumanInventory().CanAddEntityInHands( focused_item ) )
736  {
737  GetGame().GetPlayer().PredictiveTakeEntityToHands( focused_item );
738  return true;
739  }
740  }
741  }
742  }
743  }
744  }
745  return false;
746  }
747 
748  override bool TransferItemToVicinity()
749  {
750  if (CanDrop())
751  {
752  if ( GetFocusedContainer().IsInherited( ContainerWithCargo ) || GetFocusedContainer().IsInherited( ContainerWithCargoAndAttachments ) )
753  {
754  return GetFocusedContainer().TransferItemToVicinity();
755  }
756  else
757  {
758  Man player = GetGame().GetPlayer();
759  ItemBase item = ItemBase.Cast( GetFocusedItem() );
760  if( item && player.CanDropEntity( item ) )
761  {
762  if( item.GetTargetQuantityMax() < item.GetQuantity() )
763  item.SplitIntoStackMaxClient( null, -1 );
764  else
765  player.PhysicalPredictiveDropItem( item );
766  return true;
767  }
768  }
769  }
770  return false;
771  }
772 }
ItemBase
Definition: inventoryitem.c:730
SlotsContainer
Definition: slotscontainer.c:1
GetGame
proto native CGame GetGame()
LayoutHolder
Definition: container.c:1
QuantityConversions
Definition: quantityconversions.c:1
InventorySlots
provides access to slot configuration
Definition: inventoryslots.c:5
GetDayZGame
DayZGame GetDayZGame()
Definition: dayzgame.c:3729
m_RootWidget
ref Widget m_RootWidget[MAX_SIMULTANIOUS_PLAYERS]
Definition: pluginremoteplayerdebugclient.c:14
Remove
void Remove(Object object)
Definition: actiontargets.c:95
StaticGUIUtils
Definition: staticguiutils.c:1
y
Icon y
InventoryLocation
InventoryLocation.
Definition: inventorylocation.c:27
ITEMS_IN_ROW
const int ITEMS_IN_ROW
Definition: attachments.c:1
ZombieContainer
Definition: zombiecontainer.c:1
m_Parent
protected Widget m_Parent
Definition: sizetochild.c:92
Refresh
void Refresh()
Definition: sizetochild.c:108
MENU_INVENTORY
const int MENU_INVENTORY
Definition: constants.c:170
PlayerBase
Definition: playerbaseclient.c:1
map
map
Definition: controlsxboxnew.c:3
InventoryMode
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Definition: inventory.c:21
GetHeader
string GetHeader()
Definition: errorproperties.c:76
Container
Definition: cargocontainer.c:2
g_Game
DayZGame g_Game
Definition: dayzgame.c:3727
SlotsIcon
Definition: slotsicon.c:1
ItemManager
Definition: itemmanager.c:1
FindInventoryLocationType
FindInventoryLocationType
flags for searching locations in inventory
Definition: inventorylocation.c:15
AttachmentsGroupContainer
Definition: attachmentsgroupcontainer.c:1
MouseState
MouseState
Definition: ensystem.c:310
array< string >
name
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
x
Icon x
GetPlayer
protected void GetPlayer()
Definition: crosshairselector.c:127
ItemPreviewWidget
Definition: gameplay.c:275
WidgetFlags
WidgetFlags
Definition: enwidgets.c:57
InventoryMenu
void InventoryMenu()
Definition: inventorymenu.c:20
CollapsibleContainer
Definition: collapsiblecontainer.c:1
GetParent
proto native Widget GetParent()
Get parent of the Effect.
Definition: effect.c:405
Inventory
void Inventory(LayoutHolder parent)
Definition: inventory.c:76
Widget
Definition: enwidgets.c:189
LeftArea
Definition: leftarea.c:1
EntityAI
Definition: building.c:5
ClosableContainer
Definition: containerwithcargo.c:1
GameInventory
script counterpart to engine's class Inventory
Definition: inventory.c:78
WidgetEventHandler
Definition: widgeteventhandler.c:1
path
string path
Definition: optionselectormultistate.c:135