Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
iconscontainer.c
Go to the documentation of this file.
2 {
3  protected ref map<int, ref Icon> m_EntitiesMap = new map<int, ref Icon>;
4 
5  void IconsContainer( LayoutHolder parent )
6  {
7  }
8 
9  override void UnfocusAll()
10  {
11  for ( int i = 0; i < Count(); i++ )
12  {
13  for ( int j = 0; j < ITEMS_IN_ROW; j++ )
14  {
15  Get( i ).GetMainWidget().FindAnyWidget( "Cursor" + j ).Show( false );
16  }
17  }
18 
19 
20  for ( i = 0; i < m_EntitiesMap.Count(); ++i )
21  {
22  m_EntitiesMap.GetElement(i).SetActive(false);
23  }
24  }
25 
26  int GetItemCount()
27  {
28  return m_EntitiesMap.Count();
29  }
30 
31  void AddItem( Icon icon )
32  {
33  if( !m_EntitiesMap.Contains( icon.GetObject().GetID() ) )
34  {
35  m_EntitiesMap.Insert( icon.GetObject().GetID(), icon);
36  }
37  }
38 
39  Icon GetIcon( int entity_id )
40  {
41  return m_EntitiesMap.Get( entity_id );
42  }
43 
44  Icon GetIconByIndex( int index )
45  {
46  if( index < m_EntitiesMap.Count() && index > -1 )
47  return m_EntitiesMap.GetElement( index );
48  return null;
49  }
50 
51  void RemoveItem( Icon icon )
52  {
53  if( icon )
54  {
55  Icon icon_copy = icon; // for some reason garbage collector collects icon too soon, so copy has to be made
56  if( icon.GetObject() )
57  m_EntitiesMap.Remove( icon.GetObject().GetID() );
58  else
59  {
60  int ix = m_EntitiesMap.GetKeyByValue( icon );
61  if( m_EntitiesMap.Contains( ix ) )
62  m_EntitiesMap.Remove( ix );
63  else
64  delete icon;
65  }
66  }
67  }
68 
69  void RemoveItem( int entity )
70  {
71  m_EntitiesMap.Remove( entity );
72  }
73 
74  bool ContainsEntity( EntityAI entity )
75  {
76  return m_EntitiesMap.Contains( entity.GetID() );
77  }
78 
79  void UpdateItemsTemperature()
80  {
81  if( !ItemManager.GetInstance().IsDragging() )
82  {
83  for( int i = 0; i < m_EntitiesMap.Count(); i++ )
84  {
85  Icon icon = m_EntitiesMap.GetElement(i);
86  icon.SetTemperature();
87  }
88  }
89  }
90 
91  override void Refresh()
92  {
93  super.Refresh();
94 
95  for( int i = 0; i < m_EntitiesMap.Count(); i++ )
96  {
97  m_EntitiesMap.GetElement(i).Refresh();
98  }
99  }
100 }
LayoutHolder
Definition: container.c:1
ITEMS_IN_ROW
const int ITEMS_IN_ROW
Definition: attachments.c:1
map
map
Definition: controlsxboxnew.c:3
Container
Definition: cargocontainer.c:2
IconsContainer
Definition: iconscontainer.c:1
ItemManager
Definition: itemmanager.c:1
Get
array< ref PlayerStatBase > Get()
Definition: playerstatspco.c:103
Icon
Definition: icon.c:1
EntityAI
Definition: building.c:5
Count
@ Count
Definition: randomgeneratorsyncmanager.c:7