Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_DeployRequestUIBaseComponent.c
Go to the documentation of this file.
1// Base class for faction, loadout, group and spawn point request handlers
3{
4 [Attribute("ExpandButton")]
5 protected string m_sExpandButton;
7
8 [Attribute("ExpandButtonText")]
9 protected string m_sExpandButtonName;
11
12 [Attribute("Freq")]
13 protected string m_sExpandButtonNameFreq;
15
16 [Attribute("ExpandButtonIcon")]
17 protected string m_sExpandButtonIcon;
19
20 [Attribute("0")]
21 protected bool m_bUseListFromButton;
22
23 protected bool m_bEnabled = true;
24 protected bool m_bLocked = false;
25 protected ref array<SCR_DeployButtonBase> m_aButtons = {};
26
27 protected Widget m_wRoot;
28
32
33 //------------------------------------------------------------------------------------------------
34 override void HandlerAttached(Widget w)
35 {
36 m_wRoot = w;
37 }
38
39 //------------------------------------------------------------------------------------------------
40 void Update(float dt)
41 {
42 if (m_bLocked)
43 {
44 foreach (SCR_DeployButtonBase button : m_aButtons)
45 {
46 button.Update(dt);
47 }
48 }
49 }
50
52 protected void Lock(SCR_DeployButtonBase btn)
53 {
54 foreach (SCR_DeployButtonBase button : m_aButtons)
55 {
56 button.Lock(button == btn);
57 }
58
59 m_bLocked = true;
60 }
61
63 void Unlock()
64 {
65 foreach (SCR_DeployButtonBase button : m_aButtons)
66 {
67 if (button)
68 button.Unlock();
69 }
70
71 m_bLocked = false;
72 }
73
74 //------------------------------------------------------------------------------------------------
75 bool IsEnabled()
76 {
77 return m_bEnabled;
78 }
79
85 {
86 foreach (SCR_DeployButtonBase btn : m_aButtons)
87 {
88 if (btn)
89 return btn;
90 }
91
92 return null;
93 }
94
95 protected void ToggleCollapsed();
96 void SetExpanded(bool expanded);
97 bool IsExpanded();
98
99 protected void OnListExpand(SCR_DeployRequestUIBaseComponent component, bool expanded)
100 {
101 if (component == this)
102 return;
103
104 SetExpanded(false);
105 }
106
109 {
110 }
111
116 {
117 }
118
119 protected void OnMouseLeft()
120 {
121 m_OnMouseLeft.Invoke();
122 }
123
128
130 {
131 return m_OnMouseLeft;
132 }
133
135 {
136 if (!s_OnListExpand)
138
139 return s_OnListExpand;
140 }
141};
142
143//------------------------------------------------------------------------------------------------
144// Base class for faction, loadout and group request buttons
146{
147 [Attribute("0.898 0.541 0.184 1", UIWidgets.ColorPicker)]
148 protected ref Color m_ColorSelected;
149
150 [Attribute("0.947 0.056 0.056 0.62", UIWidgets.ColorPicker)]
151 protected ref Color m_ColorWarning;
152
153 [Attribute("Elements")]
154 protected string m_sElements;
156
157 [Attribute("List")]
158 protected string m_sList;
159 protected Widget m_wList;
160
161 [Attribute("GridList")]
162 protected string m_sGridList;
164
165 [Attribute("BackgroundHighlight")]
166 protected string m_sBackgroundHighlight;
168
170
172
176
178
179 protected bool m_bCanBeUnlocked = true;
180 protected bool m_bShowTooltip = true;
181
182 //------------------------------------------------------------------------------------------------
183 override void HandlerAttached(Widget w)
184 {
185 super.HandlerAttached(w);
186
187 m_wRootButton = ButtonWidget.Cast(w);
188 m_wLoading = w.FindAnyWidget("Loading");
189 if (m_wLoading)
191
193
194 if (w.GetParent())
195 {
196 m_wGridList = GridLayoutWidget.Cast(w.GetParent().FindAnyWidget(m_sGridList));
197 m_wList = w.GetParent().FindAnyWidget(m_sList);
198 }
199 else
200 {
201 m_wGridList = GridLayoutWidget.Cast(w.FindAnyWidget(m_sGridList));
202 m_wList = w.FindAnyWidget(m_sList);
203 }
204 }
205
206 //------------------------------------------------------------------------------------------------
207 override void HandlerDeattached(Widget w)
208 {
209 super.HandlerDeattached(w);
210
212 }
213
214 //------------------------------------------------------------------------------------------------
215 override bool OnFocus(Widget w, int x, int y)
216 {
218 return super.OnFocus(w, x, y);
219 }
220
221 //------------------------------------------------------------------------------------------------
222 override bool OnFocusLost(Widget w, int x, int y)
223 {
225 return super.OnFocusLost(w, x, y);
226 }
227
229 {
230 return m_wList;
231 }
232
234 {
235 return m_wGridList;
236 }
237
239 {
240 if (!m_wList)
241 return;
242
243 if (s_ExpandedList)
244 s_ExpandedList.CollapseList();
245
246 m_wList.SetVisible(true);
247 s_ExpandedList = this;
248 }
249
251 {
252 if (m_wList)
253 m_wList.SetVisible(false);
254 }
255
260
262 {
264 m_ControlsTooltip.ForceHidden();
265 }
266
267 void Update(float dt)
268 {
269 if (m_Loading && m_wLoading.IsVisible())
270 {
271 m_Loading.Update(dt);
272 }
273 }
274
276 void Lock(bool loadingAnim = false)
277 {
278 if (m_wLoading)
279 m_wLoading.SetVisible(loadingAnim);
280
281 SetEnabled(false);
282 }
283
285 void Unlock()
286 {
287 if (m_wLoading)
288 m_wLoading.SetVisible(false);
289 if (ShouldUnlock())
290 SetEnabled(true);
291 }
292
294 void SetSelected(bool selected)
295 {
296 Color color = Color.FromInt(Color.WHITE);
297
298 if (selected)
299 color = Color.FromInt(m_ColorSelected.PackToInt());
300
301 if (m_wElements)
302 m_wElements.SetColor(color);
303
305 m_wBackgroundHighlight.SetVisible(selected);
306 }
307
310 {
311 GetGame().GetWorkspace().SetFocusedWidget(m_wRootButton);
312 }
313
314 override bool OnClick(Widget w, int x, int y, int button)
315 {
316 if (!m_wRoot.IsEnabled())
317 return false;
318
319 return super.OnClick(w, x, y, button);
320 }
321
322 override void SetEnabled(bool enabled, bool animate = true)
323 {
324 m_wRoot.SetEnabled(enabled);
325
326 if (enabled)
327 OnEnabled(animate);
328 else
329 OnDisabled(animate);
330 }
331
333 protected bool ShouldUnlock()
334 {
335 return m_bCanBeUnlocked;
336 }
337
339 void SetShouldUnlock(bool shouldUnlock)
340 {
341 m_bCanBeUnlocked = shouldUnlock;
342 }
343
345 protected bool ShouldShowTooltip()
346 {
347 return m_bShowTooltip;
348 }
349
351 void SetTooltipAvailable(bool available)
352 {
353 m_bShowTooltip = available;
354 }
355
356 //------------------------------------------------------------------------------------------------
358 {
359 if (!tooltip.IsValid("Join") && !tooltip.IsValid("JoinGroup"))
360 return;
361
362 if (!m_bShowTooltip)
363 tooltip.ForceHidden();
364
365 m_ControlsTooltip = tooltip;
366
368 if (!content)
369 return;
370
371 if (GetGame().GetInputManager().GetLastUsedInputDevice() == EInputDeviceType.MOUSE)
372 content.SetAction("MenuSelectMouse");
373 else
374 content.ResetAction();
375 }
376}
class RestAPIHelper< JsonApiStruct T > content
ArmaReforgerScripted GetGame()
Definition game.c:1398
InputManager GetInputManager()
Widget m_wRoot
Definition Color.c:13
override bool OnClick(Widget w, int x, int y, int button)
override bool OnFocus(Widget w, int x, int y)
void SetTooltipAvailable(bool available)
Set if tooltip should be shown.
override bool OnFocusLost(Widget w, int x, int y)
void Unlock()
Unlock the button (eg. after receiving a request response).
void SetShouldUnlock(bool shouldUnlock)
Marks if the buttons should be unlocked when calling the Unlock() method.
void SetSelected(bool selected)
Visually set the button as selected.
static SCR_DeployButtonBase s_ExpandedList
SCR_DeployRequestUIBaseComponent m_ParentHandler
override void HandlerAttached(Widget w)
bool ShouldShowTooltip()
Get if tooltip should be shown.
void OnTooltipShow(SCR_ScriptedWidgetTooltip tooltip)
void SetParentHandler(SCR_DeployRequestUIBaseComponent parent)
SCR_ScriptedWidgetTooltip m_ControlsTooltip
void Lock(bool loadingAnim=false)
Lock the button (eg. during a request).
override void HandlerDeattached(Widget w)
override void SetEnabled(bool enabled, bool animate=true)
void SetFocused()
Set the button focused.
bool ShouldUnlock()
Return true when the button should be unlocked when calling the Unlock() method.
ref array< SCR_DeployButtonBase > m_aButtons
void Unlock()
Unlock this component's buttons.
static ref ScriptInvoker< SCR_DeployRequestUIBaseComponent, bool > s_OnListExpand
void Lock(SCR_DeployButtonBase btn)
Lock this component's buttons from processing any further requests. Unlock() should be called once yo...
void OnListExpand(SCR_DeployRequestUIBaseComponent component, bool expanded)
void SetListWidget(Widget list)
Marks which widget should be used as a root for creating buttons.
void SetExpanded(bool expanded)
bool IsValid(string tag, Widget hoverWidget=null, ResourceName presets=string.Empty)
static ScriptInvokerTooltip GetOnTooltipShow()
SCR_ScriptedWidgetTooltipContentBase GetContent()
void OnEnabled(bool animate)
SCR_FieldOfViewSettings Attribute
ScriptInvokerBase< func > ScriptInvoker
Definition tools.c:134