Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_RadialMenuPair.c
Go to the documentation of this file.
1 //------------------------------------------------------------------------------------------------
7 {
8  protected ref array<Widget> m_aWidgets;
9  protected ref array<BaseSelectionMenuEntry> m_aEntries;
10  protected int m_iCount;
11 
12  //------------------------------------------------------------------------------------------------
13  protected void RecalculateCount()
14  {
15  m_iCount = m_aWidgets.Count();
16  }
17 
18  //------------------------------------------------------------------------------------------------
19  void Clear()
20  {
21  m_aWidgets.Clear();
22  m_aEntries.Clear();
23 
24  RecalculateCount();
25  }
26 
27  //------------------------------------------------------------------------------------------------
28  int Count(bool recalculate = false)
29  {
30  if (recalculate)
31  RecalculateCount();
32 
33  return m_iCount;
34  }
35 
36  //------------------------------------------------------------------------------------------------
37  void RemoveAt(int index)
38  {
39  if (index < 0 || index >= m_iCount)
40  return;
41 
42  m_aWidgets.Remove(index);
43  m_aEntries.Remove(index);
44 
45  RecalculateCount();
46  }
47 
48  //------------------------------------------------------------------------------------------------
49  void AddEntry(SCR_RadialMenuPair pair)
50  {
51  if (pair == null)
52  return;
53 
54  m_aWidgets.Insert(pair.m_pWidget);
55  m_aEntries.Insert(pair.m_pEntry);
56 
57  RecalculateCount();
58  }
59 
60  //------------------------------------------------------------------------------------------------
61  void AddEntry(Widget widget, BaseSelectionMenuEntry entry)
62  {
63  ref auto pair = new SCR_RadialMenuPair(widget, entry);
64  AddEntry(pair);
65  }
66 
67  //------------------------------------------------------------------------------------------------
68  void RemoveByWidget(Widget widget)
69  {
70  if (widget == null)
71  return;
72 
73  auto index = m_aWidgets.Find(widget);
74  if (index == -1)
75  return;
76 
77  RemoveAt(index);
78 
79  RecalculateCount();
80  }
81 
82  //------------------------------------------------------------------------------------------------
83  void RemoveByEntry(BaseSelectionMenuEntry entry)
84  {
85  if (entry == null)
86  return;
87 
88  auto index = m_aEntries.Find(entry);
89  if (index == -1)
90  return;
91 
92  RemoveAt(index);
93 
94  RecalculateCount();
95  }
96 
97  //------------------------------------------------------------------------------------------------
98  void SetEntryAt(int index, BaseSelectionMenuEntry entry)
99  {
100  // Invalid index
101  if (index < 0 || index >= m_iCount)
102  return;
103 
104  m_aEntries[index] = entry;
105  }
106 
107  //------------------------------------------------------------------------------------------------
108  void SetWidgetAt(int index, Widget value)
109  {
110  // Invalid index
111  if (index < 0 || index >= m_iCount)
112  return;
113 
114  m_aWidgets[index] = value;
115  }
116 
117  //------------------------------------------------------------------------------------------------
118  Widget GetWidgetAt(int index)
119  {
120  // Invalid index
121  if (index < 0 || index >= m_iCount)
122  return null;
123 
124  return m_aWidgets[index];
125  }
126 
127  //------------------------------------------------------------------------------------------------
128  BaseSelectionMenuEntry GetEntryAt(int index)
129  {
130  // Invalid index
131  if (index < 0 || index >= m_iCount)
132  return null;
133 
134  return m_aEntries[index];
135  }
136 
137  //------------------------------------------------------------------------------------------------
138  ref SCR_RadialMenuPair GetAt(int index)
139  {
140  // Invalid index
141  if (index < 0 || index >= m_iCount)
142  return null;
143 
144  ref auto pair = new SCR_RadialMenuPair(m_aWidgets[index], m_aEntries[index]);
145  return pair;
146  }
147 
148  //------------------------------------------------------------------------------------------------
150  {
151  m_aWidgets = new array<Widget>();
152  m_aEntries = new array<BaseSelectionMenuEntry>();
153  }
154 
155  //------------------------------------------------------------------------------------------------
157  {
158  m_aWidgets.Clear();
159  m_aEntries.Clear();
160 
161  m_aWidgets = null;
162  m_aEntries = null;
163  }
164 };
165 
166 //------------------------------------------------------------------------------------------------
171 {
172  Widget m_pWidget;
173  BaseSelectionMenuEntry m_pEntry;
174 
175  //------------------------------------------------------------------------------------------------
176  bool IsEmpty()
177  {
178  return (!m_pWidget && !m_pEntry);
179  }
180 
181  //------------------------------------------------------------------------------------------------
182  void SCR_RadialMenuPair(Widget widget, BaseSelectionMenuEntry entry)
183  {
184  m_pWidget = widget;
185  m_pEntry = entry;
186  }
187 };
SCR_RadialMenuPair
Definition: SCR_RadialMenuPair.c:170
m_aEntries
protected ref array< ref SCR_TextsTaskManagerEntry > m_aEntries
Definition: SCR_TextsTaskManagerComponent.c:3
m_aWidgets
ref array< Widget > m_aWidgets
Definition: SCR_UITaskManagerComponent.c:25
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition: SCR_DestructionSynchronizationComponent.c:17
BaseSelectionMenuEntry
Definition: BaseSelectionMenuEntry.c:12
SCR_RadialMenuWidgetPairList
Definition: SCR_RadialMenuPair.c:6