Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
head.c
Go to the documentation of this file.
1 class Head_Default extends Head
2 {
3  bool m_handling_exception = false;
4  int m_beard_idx;
5  int m_hair_idx;
6 
7  ref map<int,ref SelectionTranslation> m_HeadHairHidingStateMap;
8  ref array<string> m_HeadHairSelectionArray;
9 
10  void Head_Default()
11  {
12  Init();
13  }
14 
15  void Init()
16  {
17  m_HeadHairHidingStateMap = new map<int,ref SelectionTranslation>;
18  m_HeadHairSelectionArray = new array<string>;
19 
20  ConfigGetTextArray("simpleHiddenSelections",m_HeadHairSelectionArray);
21 
22  m_beard_idx = m_HeadHairSelectionArray.Find("beard");
23  m_hair_idx = m_HeadHairSelectionArray.Find("hair");
24  if (!ConfigIsExisting("HairHiding"))
25  m_handling_exception = true;
26 
27  InitSelectionTranslation();
28  }
29 
30  void InitSelectionTranslation()
31  {
32  for (int i = 0; i < m_HeadHairSelectionArray.Count(); i++)
33  {
34  SelectionTranslation selTran = new SelectionTranslation(this,i);
35  selTran.SetSelectionState(true);
36  m_HeadHairHidingStateMap.Insert(i,selTran); //all considered "shown" on init
37  }
38  }
39 
40  bool GetHeadHideableSelections(out array<string> selections)
41  {
42  selections = m_HeadHairSelectionArray;
43  return true;
44  }
45 
46  int GetBeardIndex()
47  {
48  return m_beard_idx;
49  }
50 
51  int GetHairIndex()
52  {
53  return m_hair_idx;
54  }
55 
56  int GetSelectionIndex(string str)
57  {
58  return m_HeadHairSelectionArray.Find(str);
59  }
60 
61  bool IsHandlingException()
62  {
63  return m_handling_exception;
64  }
65 };
66 
68 {
69  bool m_SelectionState;
70 
71  bool m_TranslationFinished = false;
72  string m_BasePath;// = "cfgVehicles " + GetType() + " HairHiding";
73  ref array<int> m_TranslatedSelections;
74  Head_Default m_Head;
75 
76  void SelectionTranslation(Head_Default head, int idx)
77  {
78  m_Head = head;
79  m_BasePath = "cfgVehicles " + m_Head.GetType() + " HairHiding";
80  InitTranslatedSelections(idx);
81  }
82 
83  void InitTranslatedSelections(int idx)
84  {
85  if ( !m_Head.ConfigIsExisting("HairHiding") )
86  return;
87 
88  string path;
89  int selectionIdx = -1;
90  m_TranslatedSelections = new ref array<int>;
91 
92  //Hair
93  path = m_BasePath + " Group_Hair";
94  SearchAndTranslate(path,idx);
95  //Beard
96  path = m_BasePath + " Group_Beard";
97  SearchAndTranslate(path,idx);
98  //Hair + Beard
99  path = m_BasePath + " Group_HairBeard";
100  SearchAndTranslate(path,idx);
101 
102  //other
103  for (int i = 0; !m_TranslationFinished; i++)
104  {
105  path = m_BasePath + " Group_" + i;
106  if ( g_Game.ConfigIsExisting(path) )
107  {
108  SearchAndTranslate(path,idx);
109  }
110  else
111  {
112  m_TranslationFinished = true;
113  }
114  }
115  }
116 
117  bool SearchAndTranslate(string path, int idx)
118  {
119  if (!g_Game.ConfigIsExisting(path))
120  return false;
121 
122  array<string> tempArrayStr = new array<string>;
123  g_Game.ConfigGetTextArray(path + " memberSelections", tempArrayStr);
124  int indexInOriginalArray = -2;
125 
126  for (int i = 0; i < tempArrayStr.Count(); i++)
127  {
128  indexInOriginalArray = m_Head.m_HeadHairSelectionArray.Find(tempArrayStr.Get(i));
129  if ( idx == indexInOriginalArray ) //found it
130  {
131  g_Game.ConfigGetTextArray(path + " simpleSelectionName", tempArrayStr);
132  for (i = 0; i < tempArrayStr.Count(); i++)
133  {
134  m_TranslatedSelections.Insert(m_Head.m_HeadHairSelectionArray.Find(tempArrayStr.Get(i)));
135  }
136  m_TranslationFinished = true;
137  return true;
138  }
139  }
140  return false;
141  }
142 
143  void SetSelectionState(bool state)
144  {
145  m_SelectionState = state;
146  }
147 
148  bool GetSelectionState()
149  {
150  return m_SelectionState;
151  }
152 
153  ref array<int> GetTranslatedSelections()
154  {
155  return m_TranslatedSelections;
156  }
157 };
map
map
Definition: controlsxboxnew.c:3
Init
class InventoryGridController extends ScriptedWidgetEventHandler Init
Definition: uihintpanel.c:46
g_Game
DayZGame g_Game
Definition: dayzgame.c:3727
Head
Definition: head.c:1
SelectionTranslation
Definition: head.c:67
array< string >
path
string path
Definition: optionselectormultistate.c:135