Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_RespawnMenuWidgetComponent.c
Go to the documentation of this file.
1//------------------------------------------------------------------------------------------------
3{
4 [Attribute("DeployMenuRight", desc: "Input Action to listen to")]
5 protected string m_sRightMenuAction;
6
7 [Attribute("DeployMenuLeft", desc: "Input Action to listen to")]
8 protected string m_sToolMenuAction;
9
10 [Attribute("ExpandButton", desc: "Widget to be initially focused")]
11 protected string m_sDefaultButtonName;
12
13 [Attribute("ToolMenu")]
14 protected string m_sMapToolMenu;
15
16 [Attribute("Selectors")]
17 protected string m_sSelectorsWidgetName;
18
19 [Attribute("ControlHints")]
20 protected string m_sControlHintsWidgetName;
21
22 protected Widget m_wOwner;
23 protected Widget m_wRoot;
32 protected SCR_DeployMenuMain m_DeployMenu;
33
34 protected ref array<SCR_DeployRequestUIBaseComponent> m_aSelectors = {};
35
36 //------------------------------------------------------------------------------------------------
38 {
39 Widget focusTo = m_wOwner.FindAnyWidget("ExpandButton");
40 if (!focusTo)
41 return;
42
43 GetGame().GetWorkspace().SetFocusedWidget(focusTo);
44 }
45
46 //------------------------------------------------------------------------------------------------
48 {
50 {
51 if (selector.IsExpanded())
52 return selector;
53 }
54
55 return null;
56 }
57
58 //------------------------------------------------------------------------------------------------
59 protected void SetupSelectors()
60 {
61 Widget selectorsWidget = m_wOwner.FindAnyWidget(m_sSelectorsWidgetName);
62 if (!selectorsWidget)
63 {
64 Print("SCR_RespawnMenuWidgetComponent: Couldn't set up selectors in the respawn menu widget component because the widget with name " + m_sSelectorsWidgetName + " was not found", LogLevel.WARNING);
65 return;
66 }
67
68 SCR_DeployRequestUIBaseComponent deployReqComponent;
69 Widget selector = selectorsWidget.GetChildren();
70 while (selector)
71 {
72 deployReqComponent = SCR_DeployRequestUIBaseComponent.Cast(selector.FindHandler(SCR_DeployRequestUIBaseComponent));
73 if (deployReqComponent)
74 m_aSelectors.Insert(deployReqComponent);
75
76 selector = selector.GetSibling();
77 }
78 }
79
80 //------------------------------------------------------------------------------------------------
81 protected void ShowControlHints(Widget w, bool show)
82 {
83 Widget hintsWidget = w.GetParent().FindAnyWidget(m_sControlHintsWidgetName);
84 if (!hintsWidget)
85 return;
86
87 hintsWidget.SetVisible(show);
88 }
89
90 //------------------------------------------------------------------------------------------------
91 protected void ShowDpadWidgets(bool show)
92 {
94 m_wDpadActionWidgetRightMenu.SetVisible(show);
95
97 m_wDpadActionWidgetToolMenu.SetVisible(show);
98
100 m_wDpadActionWidgetBackground.SetVisible(show);
101 }
102
103 //------------------------------------------------------------------------------------------------
104 void EnableWidget(notnull Widget w, bool enable)
105 {
106 w.SetEnabled(enable);
107 Widget child = w.GetChildren();
108 while (child)
109 {
110 EnableWidget(child, enable);
111 child = child.GetSibling();
112 }
113 }
114
115 //------------------------------------------------------------------------------------------------
116 protected void OnInputDeviceIsGamepad(bool isGamepad)
117 {
119 if (!gallery)
120 return;
121
124
125 //Disable all widgets and have them enabled through DPAD interactions, if on gamepad.
126 if (isGamepad)
127 {
128 gallery.EnablePagingInputListeners(false);
129 gallery.SetGalleryFocused(false);
130 gallery.GetOnFocusChange().Insert(gallery.EnablePagingInputListeners);
131
134
135 EnableWidget(m_wMapToolWidget, !isGamepad);
136 return;
137 }
138
139 gallery.GetOnFocusChange().Remove(gallery.EnablePagingInputListeners);
140 gallery.EnablePagingInputListeners(true);
141
142 GetGame().GetWorkspace().SetFocusedWidget(null);
146
147 if (m_DeployMenu)
148 m_DeployMenu.AllowMapContext(true);
149 }
150
151 //------------------------------------------------------------------------------------------------
152 protected void SetupMap()
153 {
154 if (!m_DeployMenu)
155 m_DeployMenu = SCR_DeployMenuMain.GetDeployMenu();
156
157 m_wMapToolWidget = m_wRoot.FindAnyWidget(m_sMapToolMenu);
158 if (!m_wMapToolWidget)
159 return;
160
161 Widget widget = m_wRoot.FindAnyWidget("LoadoutSelector");
162 if (!widget)
163 return;
164
165 m_wLoadoutSelector = widget.FindAnyWidget("Selector");
166
167 m_wDpadActionWidgetToolMenu = m_wMapToolWidget.FindAnyWidget("Action");
168 m_wDpadActionWidgetBackground = m_wMapToolWidget.FindAnyWidget("ActionBG");
170
171 widget = m_wRoot.FindAnyWidget("PagingLeft");
172 if (widget)
174
175 widget = m_wRoot.FindAnyWidget("PagingRight");
176 if (widget)
178
179 OnInputDeviceIsGamepad(!GetGame().GetInputManager().IsUsingMouseAndKeyboard());
180 GetGame().OnInputDeviceIsGamepadInvoker().Insert(OnInputDeviceIsGamepad);
183 }
184
185 //------------------------------------------------------------------------------------------------
186 override void HandlerAttached(Widget w)
187 {
188 if (SCR_Global.IsEditMode())
189 return;
190
191 m_wOwner = w;
192 m_wRoot = SCR_WidgetHelper.GetRootWidget(m_wOwner);
193 m_wDpadActionWidgetRightMenu = w.FindAnyWidget("Control-Hint-Loadout");
195
196 //Delayed caching of other widgets, as they are initialised later
197 GetGame().GetCallqueue().CallLater(SetupMap, 1000);
198 }
199
200 //------------------------------------------------------------------------------------------------
201 override void HandlerDeattached(Widget w)
202 {
203 if (SCR_Global.IsEditMode())
204 return;
205
206 GetGame().OnInputDeviceIsGamepadInvoker().Remove(OnInputDeviceIsGamepad);
207 }
208
209 //------------------------------------------------------------------------------------------------
210 protected void AddActionListeners()
211 {
212 GetGame().GetInputManager().AddActionListener(m_sRightMenuAction, EActionTrigger.DOWN, SetFocusRightMenu);
213 GetGame().GetInputManager().AddActionListener(m_sToolMenuAction, EActionTrigger.DOWN, SetFocusToolMenu);
214
215 }
216
217 //------------------------------------------------------------------------------------------------
218 protected void RemoveActionListeners()
219 {
220 GetGame().GetInputManager().RemoveActionListener(m_sRightMenuAction, EActionTrigger.DOWN, SetFocusRightMenu);
221 GetGame().GetInputManager().RemoveActionListener(m_sToolMenuAction, EActionTrigger.DOWN, SetFocusToolMenu);
222
223 }
224
225 //------------------------------------------------------------------------------------------------
226 protected void SetFocusRightMenu()
227 {
229 return;
230
231 ShowDpadWidgets(false);
233
234 GetGame().GetWorkspace().SetFocusedWidget(m_wDefaultFocusWidget);
235
237 GetGame().GetInputManager().AddActionListener(UIConstants.MENU_ACTION_BACK, EActionTrigger.DOWN, DisableFocusRightMenu);
238
239 if (m_DeployMenu)
240 m_DeployMenu.AllowMapContext(false);
241 }
242
243 //------------------------------------------------------------------------------------------------
244 protected void SetFocusToolMenu()
245 {
246 if (!m_MapToolMenuUI)
247 return;
248
249 ShowDpadWidgets(false);
252 m_MapToolMenuUI.SetToolMenuFocused(true);
253
255 GetGame().GetInputManager().AddActionListener(UIConstants.MENU_ACTION_BACK, EActionTrigger.DOWN, DisableFocusToolMenu);
256
257 if (m_DeployMenu)
258 m_DeployMenu.AllowMapContext(false);
259 }
260
261 //------------------------------------------------------------------------------------------------
262 protected void DisableFocusRightMenu()
263 {
264 /*
265 SCR_DeployRequestUIBaseComponent selector = GetOpenedSelector();
266 if (selector && !GetGame().GetInputManager().IsUsingMouseAndKeyboard())
267 {
268 selector.SetExpanded(false);
269 GetGame().GetWorkspace().SetFocusedWidget(m_wDefaultFocusWidget);
270 return;
271 }
272 */
273
274 GetGame().GetWorkspace().SetFocusedWidget(null);
275
276 GetGame().GetInputManager().RemoveActionListener(UIConstants.MENU_ACTION_BACK, EActionTrigger.DOWN, DisableFocusRightMenu);
278
279 ShowDpadWidgets(true);
281
282 if (m_DeployMenu)
283 m_DeployMenu.AllowMapContext(true);
284 }
285
286 //------------------------------------------------------------------------------------------------
287 protected void DisableFocusToolMenu()
288 {
289 if (!m_MapToolMenuUI)
290 return;
291
292 if (IsAnyEntryActive())
293 {
295
296 m_MapToolMenuUI.SetToolMenuFocused(true);
297 return;
298 }
299
300 GetGame().GetInputManager().RemoveActionListener(UIConstants.MENU_ACTION_BACK, EActionTrigger.DOWN, DisableFocusToolMenu);
301 m_MapToolMenuUI.SetToolMenuFocused(false);
303 ShowDpadWidgets(true);
305
306 if (m_DeployMenu)
307 m_DeployMenu.AllowMapContext(true);
308 }
309
310 //------------------------------------------------------------------------------------------------
311 protected bool IsAnyEntryActive()
312 {
313 array<ref SCR_MapToolEntry> entries = m_MapToolMenuUI.GetMenuEntries();
314 if (!entries || entries.IsEmpty())
315 return false;
316
317 foreach (ref SCR_MapToolEntry entry : entries)
318 {
319 //TODO: This is far from ideal, on the contrary, this is terrible.
320 if ((entry.GetImageSet() == "ruler") || (entry.GetImageSet() == "compass") || (entry.GetImageSet() == "watch") || (entry.GetImageSet() == "editor"))
321 continue;
322
323 if (entry.IsEntryActive())
324 return true;
325 }
326
327 return false;
328 }
329
330 //------------------------------------------------------------------------------------------------
331 protected void CloseAllMapTools()
332 {
333 array<ref SCR_MapToolEntry> entries = m_MapToolMenuUI.GetMenuEntries();
334 if (!entries || entries.IsEmpty())
335 return;
336
337 foreach (ref SCR_MapToolEntry entry : entries)
338 {
339 if ((entry.GetImageSet() == "ruler") || (entry.GetImageSet() == "compass") || (entry.GetImageSet() == "watch") || (entry.GetImageSet() == "editor"))
340 continue;
341
342 if (entry.IsEntryActive())
343 entry.SetActive(false);
344 }
345 }
346}
ArmaReforgerScripted GetGame()
Definition game.c:1398
InputManager GetInputManager()
void SCR_MapToolMenuUI()
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Base class for any button, regardless its own content.
static bool IsEditMode()
Definition Functions.c:1566
SCR_MapUIBaseComponent GetMapUIComponent(typename componentType)
static SCR_MapEntity GetMapInstance()
Get map entity instance.
Map tool menu entry data class.
ref array< SCR_DeployRequestUIBaseComponent > m_aSelectors
void EnableWidget(notnull Widget w, bool enable)
SCR_DeployRequestUIBaseComponent GetOpenedSelector()
SCR_ButtonBaseComponent m_LoadoutSelectorBtnRight
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
SCR_FieldOfViewSettings Attribute
EActionTrigger