Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_DeployRequestUIBaseComponent.c
Go to the documentation of this file.
1 // Base class for faction, loadout, group and spawn point request handlers
2 class SCR_DeployRequestUIBaseComponent : ScriptedWidgetComponent
3 {
4  [Attribute("ExpandButton")]
5  protected string m_sExpandButton;
6  protected Widget m_wExpandButton;
7 
8  [Attribute("ExpandButtonText")]
9  protected string m_sExpandButtonName;
10  protected TextWidget m_wExpandButtonName;
11 
12  [Attribute("ExpandButtonIcon")]
13  protected string m_sExpandButtonIcon;
14  protected ImageWidget m_wExpandButtonIcon;
15 
16  [Attribute("0")]
17  protected bool m_bUseListFromButton;
18 
19  protected bool m_bEnabled = true;
20  protected bool m_bLocked = false;
21  protected ref array<SCR_DeployButtonBase> m_aButtons = {};
22 
23  protected Widget m_wRoot;
24 
25  protected ref ScriptInvoker m_OnButtonFocused = new ScriptInvoker();
26  protected ref ScriptInvoker m_OnMouseLeft = new ScriptInvoker();
27  protected static ref ScriptInvoker<SCR_DeployRequestUIBaseComponent, bool> s_OnListExpand;
28 
29  //------------------------------------------------------------------------------------------------
30  override void HandlerAttached(Widget w)
31  {
32  m_wRoot = w;
33  }
34 
35  //------------------------------------------------------------------------------------------------
36  void Update(float dt)
37  {
38  if (m_bLocked)
39  {
40  foreach (SCR_DeployButtonBase button : m_aButtons)
41  {
42  button.Update(dt);
43  }
44  }
45  }
46 
48  protected void Lock(SCR_DeployButtonBase btn)
49  {
50  foreach (SCR_DeployButtonBase button : m_aButtons)
51  {
52  button.Lock(button == btn);
53  }
54 
55  m_bLocked = true;
56  }
57 
59  void Unlock()
60  {
61  foreach (SCR_DeployButtonBase button : m_aButtons)
62  {
63  if (button)
64  button.Unlock();
65  }
66 
67  m_bLocked = false;
68  }
69 
70  //------------------------------------------------------------------------------------------------
71  bool IsEnabled()
72  {
73  return m_bEnabled;
74  }
75 
80  SCR_DeployButtonBase GetFirstValidButton()
81  {
82  foreach (SCR_DeployButtonBase btn : m_aButtons)
83  {
84  if (btn)
85  return btn;
86  }
87 
88  return null;
89  }
90 
91  protected void ToggleCollapsed();
92  void SetExpanded(bool expanded);
93  bool IsExpanded();
94 
95  protected void OnListExpand(SCR_DeployRequestUIBaseComponent component, bool expanded)
96  {
97  if (component == this)
98  return;
99 
100  SetExpanded(false);
101  }
102 
104  void SetListWidget(Widget list)
105  {
106  }
107 
111  Widget GetListWidget()
112  {
113  }
114 
115  protected void OnMouseLeft()
116  {
117  m_OnMouseLeft.Invoke();
118  }
119 
120  ScriptInvoker GetOnButtonFocused()
121  {
122  return m_OnButtonFocused;
123  }
124 
125  ScriptInvoker GetOnMouseLeft()
126  {
127  return m_OnMouseLeft;
128  }
129 
130  static ScriptInvoker GetOnListCollapse()
131  {
132  if (!s_OnListExpand)
133  s_OnListExpand = new ScriptInvoker();
134 
135  return s_OnListExpand;
136  }
137 };
138 
139 //------------------------------------------------------------------------------------------------
140 // Base class for faction, loadout and group request buttons
142 {
143  [Attribute("0.898 0.541 0.184 1", UIWidgets.ColorPicker)]
144  protected ref Color m_ColorSelected;
145 
146  [Attribute("0.947 0.056 0.056 0.62", UIWidgets.ColorPicker)]
147  protected ref Color m_ColorWarning;
148 
149  [Attribute("Elements")]
150  protected string m_sElements;
151  protected Widget m_wElements;
152 
153  [Attribute("List")]
154  protected string m_sList;
155  protected Widget m_wList;
156 
157  [Attribute("GridList")]
158  protected string m_sGridList;
159  protected GridLayoutWidget m_wGridList;
160 
161  [Attribute("BackgroundHighlight")]
162  protected string m_sBackgroundHighlight;
163  protected Widget m_wBackgroundHighlight;
164 
165  protected static SCR_DeployButtonBase s_ExpandedList;
166 
167  protected SCR_DeployRequestUIBaseComponent m_ParentHandler;
168 
169  protected ButtonWidget m_wRootButton;
170  protected Widget m_wLoading;
171  protected SCR_LoadingSpinner m_Loading;
172 
173  protected SCR_BrowserHoverTooltipComponent m_ControlsTooltip;
174 
175  protected bool m_bCanBeUnlocked = true;
176  protected bool m_bShowTooltip = true;
177 
178  //------------------------------------------------------------------------------------------------
179  override void HandlerAttached(Widget w)
180  {
181  super.HandlerAttached(w);
182 
183  m_wRootButton = ButtonWidget.Cast(w);
184  m_wLoading = w.FindAnyWidget("Loading");
185  if (m_wLoading)
186  m_Loading = SCR_LoadingSpinner.Cast(m_wLoading.FindHandler(SCR_LoadingSpinner));
187 
188  m_ControlsTooltip = SCR_BrowserHoverTooltipComponent.FindComponent(w);
189  m_wBackgroundHighlight = w.FindAnyWidget(m_sBackgroundHighlight);
190 
191  if (w.GetParent())
192  {
193  m_wGridList = GridLayoutWidget.Cast(w.GetParent().FindAnyWidget(m_sGridList));
194  m_wList = w.GetParent().FindAnyWidget(m_sList);
195  }
196  else
197  {
198  m_wGridList = GridLayoutWidget.Cast(w.FindAnyWidget(m_sGridList));
199  m_wList = w.FindAnyWidget(m_sList);
200  }
201  }
202 
203  override bool OnFocus(Widget w, int x, int y)
204  {
205  super.OnFocus(w, x, y);
206 
207  if (ShouldShowTooltip())
208  HandleTooltip();
209 
210  return false;
211  }
212 
213  Widget GetList()
214  {
215  return m_wList;
216  }
217 
218  GridLayoutWidget GetGridList()
219  {
220  return m_wGridList;
221  }
222 
223  void ExpandList()
224  {
225  if (!m_wList)
226  return;
227 
228  if (s_ExpandedList)
229  s_ExpandedList.CollapseList();
230 
231  m_wList.SetVisible(true);
232  s_ExpandedList = this;
233  }
234 
235  void CollapseList()
236  {
237  if (m_wList)
238  m_wList.SetVisible(false);
239  }
240 
241  void SetParentHandler(SCR_DeployRequestUIBaseComponent parent)
242  {
243  m_ParentHandler = parent;
244  }
245 
246  protected void HandleTooltip()
247  {
248  if (m_ControlsTooltip)
249  m_ControlsTooltip.CreateTooltip();
250  }
251 
252  void HideTooltip()
253  {
254  if (m_ControlsTooltip)
255  m_ControlsTooltip.ForceDeleteTooltip();
256  }
257 
258  void Update(float dt)
259  {
260  if (m_Loading && m_wLoading.IsVisible())
261  {
262  m_Loading.Update(dt);
263  }
264  }
265 
267  void Lock(bool loadingAnim = false)
268  {
269  if (m_wLoading)
270  m_wLoading.SetVisible(loadingAnim);
271 
272  SetEnabled(false);
273  }
274 
276  void Unlock()
277  {
278  if (m_wLoading)
279  m_wLoading.SetVisible(false);
280  if (ShouldUnlock())
281  SetEnabled(true);
282  }
283 
285  void SetSelected(bool selected)
286  {
287  Color color = Color.FromInt(Color.WHITE);
288  if (selected)
289  color = Color.FromInt(m_ColorSelected.PackToInt());
290  if (m_wElements)
291  m_wElements.SetColor(color);
292  if (m_wBackgroundHighlight)
293  m_wBackgroundHighlight.SetVisible(selected);
294  }
295 
297  void SetFocused()
298  {
299  GetGame().GetWorkspace().SetFocusedWidget(m_wRootButton);
300  }
301 
302  override bool OnClick(Widget w, int x, int y, int button)
303  {
304  if (!m_wRoot.IsEnabled())
305  return false;
306 
307  return super.OnClick(w, x, y, button);
308  }
309 
310  override void SetEnabled(bool enabled, bool animate = true)
311  {
312  m_wRoot.SetEnabled(enabled);
313 
314  if (enabled)
315  OnEnabled(animate);
316  else
317  OnDisabled(animate);
318  }
319 
321  protected bool ShouldUnlock()
322  {
323  return m_bCanBeUnlocked;
324  }
325 
327  void SetShouldUnlock(bool shouldUnlock)
328  {
329  m_bCanBeUnlocked = shouldUnlock;
330  }
331 
333  protected bool ShouldShowTooltip()
334  {
335  return m_bShowTooltip;
336  }
337 
339  void SetTooltipAvailable(bool available)
340  {
341  m_bShowTooltip = available;
342  }
343 };
OnDisabled
void OnDisabled()
Definition: SCR_CampaignMilitaryBaseComponent.c:557
m_wRoot
protected Widget m_wRoot
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:59
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
m_sList
protected string m_sList
Definition: SCR_DownloadManagerListComponent.c:3
SCR_BrowserHoverTooltipComponent
Definition: SCR_BrowserHoverTooltipComponent.c:1
m_wList
protected Widget m_wList
Definition: SCR_DownloadManagerListComponent.c:12
SCR_DeployRequestUIBaseComponent
Definition: SCR_DeployRequestUIBaseComponent.c:2
Attribute
typedef Attribute
Post-process effect of scripted camera.
m_bEnabled
private bool m_bEnabled
Definition: SCR_BaseManualCameraComponent.c:3
m_wLoading
protected Widget m_wLoading
Definition: SCR_ServerBrowserEntryComponent.c:40
SCR_ButtonImageComponent
Definition: SCR_ButtonImageComponent.c:2
m_aButtons
protected ref array< ref SCR_BrowserTooltipButtonPresetData > m_aButtons
Definition: SCR_BrowserHoverTooltipComponent.c:9
SCR_DeployButtonBase
Definition: SCR_DeployRequestUIBaseComponent.c:141