Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
container.c
Go to the documentation of this file.
1 class Container extends LayoutHolder
2 {
3  protected ref array<ref LayoutHolder> m_Body;
4  protected ref array<LayoutHolder> m_OpenedContainers;
5  protected int m_ActiveIndex = 0;
6  protected bool m_LastIndex; //deprecated
7  protected bool m_Closed;
8  protected Container m_FocusedContainer;
9  protected float m_PrevAlpha;
10  const int ITEMS_IN_ROW = 8;
11 
12  //protected int m_RowCount;
13  protected int m_ColumnCount;
14 
15  protected int m_FocusedColumn = 0;
16  protected bool m_ForcedHide;
17  protected bool m_ForcedShow; //used to override displayability condition, but 'm_ForcedHide' takes preference
18 
19  protected SlotsIcon m_SlotIcon;
20  protected EntityAI m_Entity;
21 
22  const int SORT_ATTACHMENTS_OWN = 1; //direct attachments of the parent item
23  const int SORT_CARGO_OWN = 2; //cargo of the parent item
24  const int SORT_ATTACHMENTS_NEXT_OFFSET = 2;
25  const int SORT_CARGO_NEXT_OFFSET = 3;
26 
27  void OnDropReceivedFromHeader( Widget w, int x, int y, Widget receiver );
28  void DraggingOver( Widget w, int x, int y, Widget receiver );
29  void DraggingOverHeader( Widget w, int x, int y, Widget receiver );
30  void UpdateSpacer();
31  Header GetHeader();
32  void SetHeader(Header header);
33  void CheckHeaderDragability();
34 
35  void Container( LayoutHolder parent )
36  {
37  m_Body = new array<ref LayoutHolder>;
38  m_OpenedContainers = new array<LayoutHolder>;
39  m_PrevAlpha = m_RootWidget.GetAlpha();
40  m_SlotIcon = null;
41  m_ForcedHide = false;
42  m_ForcedShow = false;
43 
44  m_ActiveIndex = 0;
45  m_IsActive = false;
46  }
47 
48  Container GetFocusedContainer()
49  {
50  if (m_ActiveIndex < m_OpenedContainers.Count())
51  {
52  return Container.Cast(m_OpenedContainers[m_ActiveIndex]);
53  }
54  return null;
55  }
56 
57  Container GetContainer(int index)
58  {
59  if (index < m_Body.Count())
60  {
61  return Container.Cast( m_Body[index] );
62  }
63  return null;
64  }
65 
66 
67  void SetFocusedContainer( Container cont )
68  {
69  m_FocusedContainer = cont;
70  }
71 
72  SlotsIcon GetFocusedSlotsIcon()
73  {
74  Container c = GetFocusedContainer();
75  if (c)
76  {
77  return c.GetFocusedSlotsIcon();
78  }
79  return null;
80  }
81 
82  int GetActiveIndex()
83  {
84  return m_ActiveIndex;
85  }
86 
87  void SetActiveIndex( int index )
88  {
89  m_ActiveIndex = index;
90  }
91 
92  ScrollWidget GetScrollWidget()
93  {
94  return null;
95  }
96 
97  void UpdateRadialIcon()
98  {
99  if ( m_SlotIcon )
100  {
101  m_SlotIcon.GetRadialIconPanel().Show( false );
102  }
103  }
104 
105  void SetSlotIcon( SlotsIcon icon )
106  {
107  m_SlotIcon = icon;
108  }
109 
110  void SetDefaultFocus(bool while_micromanagment_mode = false)
111  {
112  m_ActiveIndex = 0;
113  }
114 
115  void SetLastFocus()
116  {
117  m_ActiveIndex = 0;
118  m_FocusedColumn = 0;
119  if ( m_OpenedContainers.Count() > 0 )
120  {
121  m_ActiveIndex = m_OpenedContainers.Count() - 1;
122  }
123  }
124 
125  void Unfocus()
126  {
127  }
128 
129  void MoveGridCursor(int direction)
130  {
131  if ( direction == Direction.UP )
132  {
133  SetPreviousActive();
134  }
135  else if ( direction == Direction.DOWN )
136  {
137  SetNextActive();
138  }
139  else if ( direction == Direction.RIGHT )
140  {
141  SetNextRightActive();
142  }
143  else if ( direction == Direction.LEFT )
144  {
145  SetNextLeftActive();
146  }
147 
148  UpdateSelectionIcons();
149 
150  Inventory.GetInstance().UpdateConsoleToolbar();
151  }
152 
153  void ScrollToActiveContainer()
154  {
155  ScrollWidget sw = GetScrollWidget();
156  if (sw)
157  {
158  float x, y, y_s;
159 
160  sw.GetScreenPos( x, y );
161  sw.GetScreenSize( x, y_s );
162  float f_y,f_h;
163  float amount;
164  f_y = GetFocusedContainerYScreenPos( true );
165  f_h = GetFocusedContainerHeight( true );
166 
167  float next_pos = f_y + f_h;
168 
169  if (next_pos > ( y + y_s ))
170  {
171  amount = sw.GetVScrollPos() + next_pos - ( y + y_s ) + 2;
172  sw.VScrollToPos( amount );
173  }
174  else if (f_y < y)
175  {
176  amount = sw.GetVScrollPos() + f_y - y - 2;
177  sw.VScrollToPos(amount);
178  }
179 
180  //CheckScrollbarVisibility();
181  }
182  }
183 
184  void CheckScrollbarVisibility()
185  {
186  ScrollWidget sw = GetScrollWidget();
187  if (sw)
188  {
189  if (!sw.IsScrollbarVisible())
190  {
191  sw.VScrollToPos01(0.0);
192  }
193  else if (sw.GetVScrollPos01() > 1.0)
194  {
195  sw.VScrollToPos01(1.0);
196  }
197  }
198  }
199 
200  void Open()
201  {
202  m_Closed = false;
203  UpdateSelectionIcons();
204  }
205 
206  void Close()
207  {
208  m_Closed = true;
209  UpdateSelectionIcons();
210  }
211 
212  bool IsOpened()
213  {
214  return !m_Closed;
215  }
216 
217  void SetOpenForSlotIcon(bool open, SlotsIcon icon = null/*m_SlotIcon*/)
218  {
219  if (!icon)
220  {
221  icon = m_SlotIcon;
222  }
223 
224  if (icon)
225  {
226  icon.GetRadialIcon().Show(open);
227  icon.GetRadialIconClosed().Show(!open);
228  }
229  /*else
230  {
231  ErrorEx("Dbg No Icon");
232  }*/
233  }
234 
235  void Toggle()
236  {
237  if (IsOpened())
238  {
239  Close();
240  }
241  else
242  {
243  Open();
244  }
245  SetOpenForSlotIcon(IsOpened());
246  }
247 
248  float GetFocusedContainerHeight( bool contents = false )
249  {
250  float x, y, result;
251  if( GetFocusedContainer() )
252  y = GetFocusedContainer().GetFocusedContainerHeight( contents );
253  else if( GetRootWidget() )
254  GetRootWidget().GetScreenSize( x, y );
255 
256  result = y;
257 
258  if ( m_ActiveIndex == 0 )
259  {
260  if ( GetHeader() )
261  {
262  GetHeader().GetRootWidget().GetScreenSize( x, y );
263  result += y;
264  }
265  }
266  return result;
267  }
268 
269  float GetFocusedContainerYPos( bool contents = false )
270  {
271  float x, y;
272  if( GetFocusedContainer() )
273  y = GetFocusedContainer().GetFocusedContainerYPos( contents );
274  else if( GetRootWidget() )
275  GetRootWidget().GetPos( x, y );
276 
277  return y;
278  }
279 
280  float GetFocusedContainerYScreenPos( bool contents = false )
281  {
282  float x, y, result;
283  if( GetFocusedContainer() )
284  y = GetFocusedContainer().GetFocusedContainerYScreenPos( contents );
285  else if( GetRootWidget() )
286  GetRootWidget().GetScreenPos( x, y );
287 
288 
289  result = y;
290 
291  if ( m_ActiveIndex == 0 )
292  {
293  if ( GetHeader() )
294  {
295  GetHeader().GetRootWidget().GetScreenPos( x, y );
296  result = y;
297  }
298  }
299  return result;
300  }
301 
302  int Count()
303  {
304  return m_Body.Count();
305  }
306 
307  bool SelectItem()
308  {
309  if( GetFocusedContainer() )
310  return GetFocusedContainer().SelectItem();
311  return false;
312  }
313 
314  bool Select()
315  {
316  if( GetFocusedContainer() )
317  return GetFocusedContainer().Select();
318  return false;
319  }
320 
321  bool OnSelectButton()
322  {
323  if(GetFocusedContainer())
324  {
325  return GetFocusedContainer().OnSelectButton();
326  }
327  return false;
328  }
329 
330  bool Combine()
331  {
332  if( GetFocusedContainer() )
333  return GetFocusedContainer().Combine();
334  return true;
335  }
336 
337  bool TransferItemToVicinity()
338  {
339  if( GetFocusedContainer() )
340  return GetFocusedContainer().TransferItemToVicinity();
341  return false;
342  }
343 
344  bool TransferItem()
345  {
346  if( GetFocusedContainer() )
347  return GetFocusedContainer().TransferItem();
348  return false;
349  }
350 
351  bool InspectItem()
352  {
353  if( GetFocusedContainer() )
354  return GetFocusedContainer().InspectItem();
355  return false;
356  }
357 
358  bool SplitItem()
359  {
360  if( GetFocusedContainer() )
361  return GetFocusedContainer().SplitItem();
362  return false;
363  }
364 
365  bool EquipItem()
366  {
367  if( GetFocusedContainer() )
368  return GetFocusedContainer().EquipItem();
369  return false;
370  }
371 
372  bool CanOpenCloseContainer()
373  {
374  if ( ItemManager.GetInstance().IsMicromanagmentMode() )
375  return false;
376 
377  EntityAI focusedEntity = GetFocusedItem();
378  if (focusedEntity)
379  {
380  if (GetFocusedContainer())
381  return GetFocusedContainer().CanOpenCloseContainerEx(focusedEntity);
382 
383  return CanOpenCloseContainerEx(focusedEntity);
384  }
385 
386  return false;
387  }
388 
389  bool CanOpenCloseContainerEx(EntityAI focusedEntity)
390  {
391  return false;
392  }
393 
394  bool CanSplit()
395  {
396  EntityAI focusedEntity = GetFocusedItem();
397  if (focusedEntity)
398  {
399  if (GetFocusedContainer())
400  return GetFocusedContainer().CanSplitEx(focusedEntity);
401 
402  return CanSplitEx(focusedEntity);
403  }
404 
405  return false;
406  }
407 
408  bool CanSplitEx(EntityAI focusedEntity)
409  {
410  if ( ItemManager.GetInstance().IsMicromanagmentMode() )
411  return false;
412 
413  if (focusedEntity)
414  {
415  return focusedEntity.CanBeSplit();
416  }
417  return false;
418  }
419 
420  bool CanDrop()
421  {
422  EntityAI focusedEntity = GetFocusedItem();
423  if (focusedEntity)
424  {
425  if (GetFocusedContainer())
426  return GetFocusedContainer().CanDropEx(focusedEntity);
427 
428  return CanDropEx(focusedEntity);
429 
430  }
431 
432  return false;
433  }
434 
435  bool CanDropEx(EntityAI focusedEntity)
436  {
437  if ( ItemManager.GetInstance().IsMicromanagmentMode() )
438  return false;
439 
440  if (focusedEntity)
441  {
442  PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
443 
444  if (player)
445  {
446  return player.CanDropEntity(focusedEntity);
447  }
448  }
449  return false;
450  }
451 
452  bool CanSwapOrTakeToHands()
453  {
454  EntityAI focusedEntity = GetFocusedItem();
455  if (focusedEntity)
456  {
457  if (GetFocusedContainer())
458  return GetFocusedContainer().CanSwapOrTakeToHandsEx(focusedEntity);
459 
460  return CanSwapOrTakeToHandsEx(focusedEntity);
461  }
462 
463  return false;
464  }
465 
466  bool CanSwapOrTakeToHandsEx(EntityAI focusedEntity)
467  {
468  if ( ItemManager.GetInstance().IsMicromanagmentMode() )
469  return false;
470 
471  if (focusedEntity)
472  {
473  PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
474  EntityAI entityInHands = player.GetItemInHands();
475  if (entityInHands)
476  {
478 
479  if (!GameInventory.CanSwapEntitiesEx(focusedEntity, entityInHands))
480  {
481  return GameInventory.CanForceSwapEntitiesEx( focusedEntity, null, entityInHands, il );
482  }
483  else
484  {
485  return true;
486  }
487  }
488  else
489  {
490  return player.GetInventory().CanAddEntityIntoHands(focusedEntity);
491  }
492  }
493  return false;
494  }
495 
496  bool CanEquip()
497  {
498  EntityAI focusedEntity = GetFocusedItem();
499  if (focusedEntity)
500  {
501  if (GetFocusedContainer())
502  return GetFocusedContainer().CanEquipEx(focusedEntity);
503 
504  return CanEquipEx(focusedEntity);
505  }
506 
507  return false;
508  }
509 
510  bool CanEquipEx(EntityAI focusedEntity)
511  {
512  if ( ItemManager.GetInstance().IsMicromanagmentMode() )
513  return false;
514 
515  bool found = false;
516  if (focusedEntity)
517  {
519  PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
520  found = player.GetInventory().FindFreeLocationFor(focusedEntity,FindInventoryLocationType.ATTACHMENT,il);
521 
522  if (!found)
523  {
524  for (int i = 0; i < focusedEntity.GetInventory().GetSlotIdCount(); i++)
525  {
526  int slot_id = focusedEntity.GetInventory().GetSlotId(i);
527  EntityAI slot_item = player.GetInventory().FindAttachment( slot_id );
528  if (slot_item && player.GetInventory().CanSwapEntitiesEx( focusedEntity, slot_item ))
529  {
530  found = true;
531  break;
532  }
533 
534  }
535  }
536  }
537  return found;
538  }
539 
540  bool CanTakeToInventory()
541  {
542  EntityAI focusedEntity = GetFocusedItem();
543  if (focusedEntity)
544  {
545  if (GetFocusedContainer())
546  return GetFocusedContainer().CanTakeToInventoryEx(focusedEntity);
547 
548  return CanTakeToInventoryEx(focusedEntity);
549  }
550 
551  return false;
552  }
553 
554  bool CanTakeToInventoryEx(EntityAI focusedEntity)
555  {
556  if ( ItemManager.GetInstance().IsMicromanagmentMode() )
557  return false;
558 
559  if (focusedEntity)
560  {
561  PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
562  return player.GetInventory().CanAddEntityToInventory(focusedEntity,FindInventoryLocationType.CARGO);
563  }
564  return false;
565  }
566 
567  bool CanCombine()
568  {
569  EntityAI focusedEntity = GetFocusedItem();
570  if (focusedEntity)
571  {
572  if (GetFocusedContainer())
573  return GetFocusedContainer().CanCombineEx(focusedEntity);
574 
575  return CanCombineEx(focusedEntity);
576  }
577 
578  return false;
579  }
580 
581  bool CanCombineEx(EntityAI focusedEntity)
582  {
583  if (ItemManager.GetInstance().IsMicromanagmentMode())
584  return false;
585 
586  if (focusedEntity)
587  {
588  EntityAI entityInHands = PlayerBase.Cast(GetGame().GetPlayer()).GetItemInHands();
589  if (focusedEntity != entityInHands)
590  {
591  return (ItemManager.GetCombinationFlags(entityInHands, focusedEntity) != 0);
592  }
593  }
594  return false;
595  }
596 
597  bool CanCombineAmmo()
598  {
599  if( GetFocusedContainer() )
600  return GetFocusedContainer().CanCombineAmmo();
601  return false;
602  }
603 
604  bool CanAddToQuickbarEx(EntityAI focusedEntity)
605  {
606  if ( ItemManager.GetInstance().IsMicromanagmentMode() )
607  return false;
608 
609  if (focusedEntity)
610  {
611  PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
612  if (focusedEntity.GetHierarchyRootPlayer() == player)
613  {
614  return true;
615  }
616  }
617 
618  return false;
619  }
620 
621  bool AddItemToQuickbarRadial(EntityAI itemToAssign)
622  {
623  if ( CanAddToQuickbarEx(itemToAssign) )
624  {
625  PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
627  dpi = player.GetDayZPlayerInventory();
628 
629  if (itemToAssign && dpi && !dpi.IsProcessing())
630  {
631  RadialQuickbarMenu.SetItemToAssign(itemToAssign);
632 
633  //open radial quickbar menu
634  if (!GetGame().GetUIManager().IsMenuOpen(MENU_RADIAL_QUICKBAR))
635  {
636  RadialQuickbarMenu.OpenMenu(GetGame().GetUIManager().FindMenu(MENU_INVENTORY));
637  }
638  }
639  return true;
640  }
641  return false;
642  }
643 
644  bool IsEmpty()
645  {
646  return m_OpenedContainers.Count() == 0;
647  }
648 
649  bool IsItemActive()
650  {
651  if( GetFocusedContainer() )
652  return GetFocusedContainer().IsItemActive();
653  return false;
654  }
655 
656  bool IsItemWithQuantityActive()
657  {
658  if( GetFocusedContainer() )
659  return GetFocusedContainer().IsItemWithQuantityActive();
660  return false;
661  }
662 
663  EntityAI GetFocusedItem()
664  {
665  EntityAI item;
666  if( GetFocusedContainer() )
667  item = GetFocusedContainer().GetFocusedItem();
668 
669  return item;
670  }
671 
672  EntityAI GetFocusedContainerEntity()
673  {
674  EntityAI item;
675  if( GetFocusedContainer() )
676  item = GetFocusedContainer().GetFocusedContainerEntity();
677  return item;
678  }
679 
680  int GetColumnCount()
681  {
682  return m_ColumnCount;
683  }
684 
685  void SetColumnCount( int count )
686  {
687  m_ColumnCount = count;
688  }
689 
690  int GetFocusedColumn()
691  {
692  return m_FocusedColumn;
693  }
694 
695  void SetFocusedColumn( int column )
696  {
697  m_FocusedColumn = column;
698  }
699 
700  override void UpdateInterval()
701  {
702  for ( int i = 0; i < m_Body.Count(); i++ )
703  {
704  if ( m_Body.Get( i ) )
705  m_Body.Get( i ).UpdateInterval();
706  }
707 
708  CheckHeaderDragability();
709  }
710 
711  override void SetLastActive()
712  {
713  if (m_IsActive)
714  {
715  m_IsActive = true;
716  if (m_OpenedContainers.Count())
717  {
718  SetLastFocus();
719  if (!m_OpenedContainers[m_ActiveIndex].IsActive())
720  {
721  for (int i = 0; i < m_OpenedContainers.Count() - 1; i++)
722  {
723  if (m_OpenedContainers[i].IsActive())
724  {
725  m_OpenedContainers[i].SetActive(false);
726  }
727  }
728  m_OpenedContainers[m_ActiveIndex].SetLastActive();
729  }
730  else
731  {
732  m_OpenedContainers[m_ActiveIndex].SetLastActive();
733  }
734  }
735  }
736  else
737  {
738  m_IsActive = true;
739  if (GetHeader())
740  {
741  GetHeader().SetActive(m_IsActive);
742  }
743  SetLastFocus();
744  if (m_OpenedContainers.Count())
745  {
746  Container c = Container.Cast(m_OpenedContainers.Get( m_ActiveIndex ));
747  if (c)
748  {
749  c.SetLastActive( );
750  }
751  }
752  }
753  }
754 
755  override void SetFirstActive()
756  {
757  if (!m_IsActive)
758  {
759  SetActive(true);
760  }
761  else
762  {
763  if (m_OpenedContainers.Count())
764  {
765  SetDefaultFocus();
766  if (!m_OpenedContainers[m_ActiveIndex].IsActive())
767  {
768  for (int i = 1; i < m_OpenedContainers.Count(); i++)
769  {
770  if (m_OpenedContainers[i].IsActive())
771  {
772  m_OpenedContainers[i].SetActive(false);
773  }
774  }
775  m_OpenedContainers[m_ActiveIndex].SetActive(true);
776  }
777  else
778  {
779  m_OpenedContainers[m_ActiveIndex].SetFirstActive();
780  }
781  }
782  }
783  }
784 
785  override void SetActive(bool active)
786  {
787  if (!active)
788  {
789  HideOwnedTooltip();
790  }
791 
792  if (!active && !m_IsActive)
793  return;
794 
795  super.SetActive( active );
796  if ( GetHeader() )
797  {
798  GetHeader().SetActive(active);
799  }
800 
801  if (m_MainWidget.FindAnyWidget("SelectedContainer"))
802  {
803  m_MainWidget.FindAnyWidget("SelectedContainer").Show(active);
804  }
805 
806  Container c;
807  if( active )
808  {
809 
810  SetDefaultFocus();
811  if( m_OpenedContainers.Count() )
812  {
813  c = Container.Cast(m_OpenedContainers.Get( m_ActiveIndex ));
814  if (c)
815  {
816  c.SetActive(active);
817  }
818  }
819  }
820  else
821  {
822  c = GetFocusedContainer();
823  if (c)
824  {
825  GetFocusedContainer().SetActive(false);
826  }
827  Unfocus();
828  m_ActiveIndex = 0;
829  m_FocusedColumn = 0;
830  }
831  }
832 
833  void UnfocusAll()
834  {
835  for ( int i = 0; i < Count(); i++ )
836  {
837  for ( int j = 0; j < ITEMS_IN_ROW; j++ )
838  {
839  SlotsIcon icon;
840  if (Get(i) && Get(i).GetMainWidget())
841  Get( i ).GetMainWidget().GetUserData(icon);
842 
843  if (icon)
844  icon.GetCursorWidget().Show( false );
845  }
846  }
847  }
848 
849  void UnfocusGrid()
850  {
851  if( GetFocusedContainer() )
852  {
853  m_FocusedColumn = 0;
854  GetFocusedContainer().UnfocusAll();
855  }
856  }
857 
858  bool IsLastIndex()
859  {
860  return m_ActiveIndex == ( m_OpenedContainers.Count() - 1 );
861  }
862 
863  bool IsFirstIndex()
864  {
865  return m_ActiveIndex == 0;
866  }
867 
868  bool IsFirstContainerFocused()
869  {
870  return m_ActiveIndex == 0;
871  }
872 
873  bool IsLastContainerFocused()
874  {
875  return m_ActiveIndex >= ( m_OpenedContainers.Count() - 1 );
876  }
877 
878  void ResetFocusedContainer()
879  {
880  if ( GetFocusedContainer() )
881  {
882  GetFocusedContainer().ResetFocusedContainer();
883  }
884 
885  m_ActiveIndex == 0;
886  }
887 
888  void SetNextActive()
889  {
890  HideOwnedTooltip();
891 
892  Container active;
893  if (m_OpenedContainers.Count())
894  {
895  active = Container.Cast(m_OpenedContainers[m_ActiveIndex]);
896  }
897 
898  if (active && active.IsActive())
899  {
900  active.SetNextActive();
901  }
902  if (!active || !active.IsActive())
903  {
904  Container next;
905  if (!IsLastContainerFocused())
906  {
907  m_ActiveIndex++;
908 
909  next = Container.Cast(m_OpenedContainers[m_ActiveIndex]);
910  next.SetActive(true);
911  }
912  else if (Container.Cast( GetParent() ))
913  {
914  SetActive(false);
915  }
916  else
917  {
918  SetActive(false);
919  SetFirstActive();
920  }
921  }
922  }
923 
924  void SetPreviousActive(bool force = false)
925  {
926  HideOwnedTooltip();
927  Container active;
928  if (m_OpenedContainers.Count())
929  {
930  active = Container.Cast(m_OpenedContainers[m_ActiveIndex]);
931  }
932 
933  if (active && active.IsActive())
934  {
935  active.SetPreviousActive();
936  }
937 
938  if (!active || !active.IsActive())
939  {
940  Container prev;
941  if (!IsFirstContainerFocused())
942  {
943  m_ActiveIndex--;
944 
945  prev = Container.Cast(m_OpenedContainers[m_ActiveIndex]);
946  prev.SetLastActive();
947  }
948  else if (Container.Cast( GetParent() ))
949  {
950  SetActive(false);
951  }
952  else
953  {
954  SetActive(false);
955  SetLastActive();
956  }
957  }
958  }
959 
960  void SetNextRightActive()
961  {
962  Container active;
963  if (m_OpenedContainers.Count())
964  {
965  active = Container.Cast(m_OpenedContainers[m_ActiveIndex]);
966  }
967 
968  if (active)
969  {
970  active.SetNextRightActive();
971  }
972  }
973 
974  void SetNextLeftActive()
975  {
976  Container active;
977  if (m_OpenedContainers.Count())
978  {
979  active = Container.Cast(m_OpenedContainers[m_ActiveIndex]);
980  }
981 
982  if (active)
983  {
984  active.SetNextLeftActive();
985  }
986  }
987 
988  void SetSameLevelNextActive()
989  {
990  Container active;
991  active = Container.Cast(m_OpenedContainers[m_ActiveIndex]);
992  active.SetActive(false);
993 
994  m_ActiveIndex++;
995  if (m_ActiveIndex > m_OpenedContainers.Count() - 1)
996  {
997  m_ActiveIndex = 0;
998  }
999 
1000  active = Container.Cast(m_OpenedContainers[m_ActiveIndex]);
1001  active.SetActive(true);
1002  }
1003 
1004  void SetSameLevelPreviousActive()
1005  {
1006  Container active;
1007  active = Container.Cast(m_OpenedContainers[m_ActiveIndex]);
1008  active.SetActive(false);
1009 
1010  m_ActiveIndex--;
1011  if (m_ActiveIndex < 0)
1012  {
1013  m_ActiveIndex = m_OpenedContainers.Count() - 1;
1014  }
1015 
1016  active = Container.Cast(m_OpenedContainers[m_ActiveIndex]);
1017  active.SetActive(true);
1018  }
1019 
1020  void RecomputeOpenedContainers()
1021  {
1022  m_OpenedContainers.Clear();
1023  int i;
1024  bool need_reset_focus = false;
1025  Container c;
1026  for (i = 0; i < m_Body.Count(); i++)
1027  {
1028  c = Container.Cast(m_Body.Get( i ));
1029  if ( c )
1030  {
1031  c.RecomputeOpenedContainers();
1032  if (c.IsDisplayable() && c.IsVisible())
1033  {
1034  m_OpenedContainers.Insert(c);
1035  }
1036  else if (c.IsActive())
1037  {
1038  c.SetActive(false);
1039  need_reset_focus = true;
1040  }
1041 
1042  }
1043  }
1044 
1045  //In case of removing focused container or change order of containers
1046  if (IsActive())
1047  {
1048  if (!need_reset_focus && ( m_ActiveIndex >= m_OpenedContainers.Count() || !m_OpenedContainers[m_ActiveIndex].IsActive() ))
1049  {
1050  need_reset_focus = true;
1051  for (i = 0; i < m_OpenedContainers.Count(); i++)
1052  {
1053  if (m_OpenedContainers[i].IsActive())
1054  {
1055  need_reset_focus = false;
1056  m_ActiveIndex = i;
1057  }
1058  }
1059  }
1060 
1061  if (need_reset_focus)
1062  {
1063  SetFirstActive();
1064  }
1065  }
1066  }
1067 
1068  override void SetLayoutName()
1069  {
1070  m_LayoutName = WidgetLayoutName.Container;
1071  }
1072 
1073  void Insert( LayoutHolder container, int pos = -1, bool immedUpdate = true )
1074  {
1075  if ( pos > -1 && pos < m_Body.Count() )
1076  {
1077  if ( pos <= m_ActiveIndex )
1078  m_ActiveIndex++;
1079  m_Body.InsertAt( container, pos );
1080  }
1081  else
1082  m_Body.Insert( container );
1083 
1084  if ( immedUpdate )
1085  Refresh();
1086  }
1087 
1088  void Remove( LayoutHolder container )
1089  {
1090  if( m_Body )
1091  {
1092  int index = m_Body.Find( container );
1093  if( index > -1 )
1094  {
1095  index = m_OpenedContainers.Find( container );
1096  if (index > -1)
1097  {
1098  if (index <= m_ActiveIndex)
1099  {
1100  if (GetFocusedContainer() == container)
1101  {
1102  SetPreviousActive( true );
1103  }
1104  else
1105  {
1106  m_ActiveIndex--;
1107  }
1108  }
1109  m_OpenedContainers.RemoveItem( container );
1110  }
1111  m_Body.RemoveItem( container );
1112  }
1113  }
1114 
1115  Refresh();
1116  }
1117 
1118  LayoutHolder Get( int x )
1119  {
1120  return m_Body.Get( x );
1121  }
1122 
1123  override void Refresh()
1124  {
1125  for ( int i = 0; i < m_Body.Count(); i++ )
1126  {
1127  if( m_Body.Get( i ) )
1128  m_Body.Get( i ).Refresh();
1129  }
1130  }
1131 
1132  void UpdateBodySpacers()
1133  {
1134  for ( int i = 0; i < m_Body.Count(); i++ )
1135  {
1136  Container c = Container.Cast( m_Body.Get( i ) );
1137  if( c && c.IsInherited( Container ) )
1138  {
1139  c.UpdateSpacer();
1140  }
1141  }
1142 
1143  UpdateSpacer();
1144  }
1145 
1146  void HideContent( bool force_hide = false )
1147  {
1148  if( !m_ForcedHide )
1149  {
1150  m_ForcedHide = force_hide;
1151  }
1152  for(int i = 0; i < m_Body.Count(); i++)
1153  {
1154  if( m_Body.Get( i ) )
1155  m_Body.Get( i ).OnHide();
1156  }
1157  }
1158 
1159  void ShowContent( bool force_show = false )
1160  {
1161  if( force_show )
1162  m_ForcedHide = false;
1163 
1164  if( !m_ForcedHide )
1165  {
1166  for(int i = 0; i < m_Body.Count(); i++)
1167  {
1168  if( m_Body.Get( i ) )
1169  m_Body.Get( i ).OnShow();
1170  }
1171  }
1172  }
1173 
1174  void SetForceShow(bool value)
1175  {
1176  m_ForcedShow = value;
1177  }
1178 
1179  override void UpdateSelectionIcons()
1180  {
1181  m_Parent.UpdateSelectionIcons();
1182  }
1183 
1184  void ExpandCollapseContainer(){}
1185 }
GetGame
proto native CGame GetGame()
LayoutHolder
Definition: container.c:1
m_RootWidget
ref Widget m_RootWidget[MAX_SIMULTANIOUS_PLAYERS]
Definition: pluginremoteplayerdebugclient.c:14
Remove
void Remove(Object object)
Definition: actiontargets.c:95
DayZPlayerInventory
Definition: dayzplayerinventory.c:111
MENU_RADIAL_QUICKBAR
const int MENU_RADIAL_QUICKBAR
Definition: constants.c:188
y
Icon y
InventoryLocation
InventoryLocation.
Definition: inventorylocation.c:27
Container
const string Container
Definition: centraleconomy.c:72
ITEMS_IN_ROW
const int ITEMS_IN_ROW
Definition: attachments.c:1
WidgetLayoutName
Definition: widgetlayoutname.c:1
m_Parent
protected Widget m_Parent
Definition: sizetochild.c:92
MENU_INVENTORY
const int MENU_INVENTORY
Definition: constants.c:170
PlayerBase
Definition: playerbaseclient.c:1
m_IsActive
bool m_IsActive
Definition: modifierbase.c:20
Header
Definition: header.c:1
GetHeader
string GetHeader()
Definition: errorproperties.c:76
Container
Definition: cargocontainer.c:2
SlotsIcon
Definition: slotsicon.c:1
ItemManager
Definition: itemmanager.c:1
FindInventoryLocationType
FindInventoryLocationType
flags for searching locations in inventory
Definition: inventorylocation.c:15
array< ref LayoutHolder >
x
Icon x
GetPlayer
protected void GetPlayer()
Definition: crosshairselector.c:127
IsActive
bool IsActive()
Definition: modifierbase.c:130
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
EntityAI
Definition: building.c:5
m_Entity
EntityAI m_Entity
Definition: actiondebug.c:11
IsOpened
bool IsOpened()
Definition: inventorymenu.c:136
Count
@ Count
Definition: randomgeneratorsyncmanager.c:7
GameInventory
script counterpart to engine's class Inventory
Definition: inventory.c:78
Direction
Direction
Definition: inventory.c:18