4 [
Attribute(
"DeployMenuRight",
desc:
"Input Action to listen to")]
5 protected string m_sRightMenuAction;
7 [
Attribute(
"DeployMenuLeft",
desc:
"Input Action to listen to")]
8 protected string m_sToolMenuAction;
10 [
Attribute(
"ExpandButton",
desc:
"Widget to be initially focused")]
11 protected string m_sDefaultButtonName;
14 protected string m_sMapToolMenu;
17 protected string m_sSelectorsWidgetName;
20 protected string m_sControlHintsWidgetName;
22 protected Widget m_wOwner;
23 protected Widget m_wRoot;
24 protected Widget m_wDefaultFocusWidget;
25 protected Widget m_wDpadActionWidgetRightMenu;
26 protected Widget m_wDpadActionWidgetToolMenu;
27 protected Widget m_wMapToolWidget;
28 protected Widget m_wLoadoutSelector;
31 protected SCR_DeployMenuMain m_DeployMenu;
33 protected ref array<SCR_DeployRequestUIBaseComponent> m_aSelectors = {};
36 protected void OnLoadoudSelectorBtnFocused(Widget w)
38 Widget focusTo = m_wOwner.FindAnyWidget(
"ExpandButton");
42 GetGame().GetWorkspace().SetFocusedWidget(focusTo);
50 if (selector.IsExpanded())
58 protected void SetupSelectors()
60 Widget selectorsWidget = m_wOwner.FindAnyWidget(m_sSelectorsWidgetName);
63 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);
68 Widget selector = selectorsWidget.GetChildren();
72 if (deployReqComponent)
73 m_aSelectors.Insert(deployReqComponent);
75 selector = selector.GetSibling();
80 protected void ShowControlHints(Widget w,
bool show)
82 Widget hintsWidget = w.GetParent().FindAnyWidget(m_sControlHintsWidgetName);
86 hintsWidget.SetVisible(show);
90 protected void ShowDpadWidgets(
bool show)
92 if (m_wDpadActionWidgetRightMenu)
93 m_wDpadActionWidgetRightMenu.SetVisible(show);
95 if (m_wDpadActionWidgetToolMenu)
96 m_wDpadActionWidgetToolMenu.SetVisible(show);
100 void EnableWidget(notnull Widget w,
bool enable)
102 w.SetEnabled(enable);
103 Widget child = w.GetChildren();
106 EnableWidget(child, enable);
107 child = child.GetSibling();
112 protected void OnInputDeviceIsGamepad(
bool isGamepad)
118 m_LoadoutSelectorBtnLeft.m_OnFocus.Remove(OnLoadoudSelectorBtnFocused);
119 m_LoadoutSelectorBtnRight.m_OnFocus.Remove(OnLoadoudSelectorBtnFocused);
124 gallery.EnablePagingInputListeners(
false);
125 gallery.SetGalleryFocused(
false);
126 gallery.GetOnFocusChange().Insert(gallery.EnablePagingInputListeners);
128 m_LoadoutSelectorBtnLeft.m_OnFocus.Insert(OnLoadoudSelectorBtnFocused);
129 m_LoadoutSelectorBtnRight.m_OnFocus.Insert(OnLoadoudSelectorBtnFocused);
131 EnableWidget(m_wMapToolWidget, !isGamepad);
135 gallery.GetOnFocusChange().Remove(gallery.EnablePagingInputListeners);
136 gallery.EnablePagingInputListeners(
true);
138 GetGame().GetWorkspace().SetFocusedWidget(
null);
139 EnableWidget(m_wMapToolWidget,
true);
140 ShowControlHints(m_wOwner,
false);
141 ShowControlHints(m_wMapToolWidget,
false);
144 m_DeployMenu.AllowMapContext(
true);
148 protected void SetupMap()
151 m_DeployMenu = SCR_DeployMenuMain.GetDeployMenu();
153 m_wMapToolWidget =
m_wRoot.FindAnyWidget(m_sMapToolMenu);
154 if (!m_wMapToolWidget)
157 Widget widget =
m_wRoot.FindAnyWidget(
"LoadoutSelector");
161 m_wLoadoutSelector = widget.FindAnyWidget(
"Selector");
163 m_wDpadActionWidgetToolMenu = m_wMapToolWidget.FindAnyWidget(
"Action");
166 widget =
m_wRoot.FindAnyWidget(
"PagingLeft");
170 widget =
m_wRoot.FindAnyWidget(
"PagingRight");
175 GetGame().OnInputDeviceIsGamepadInvoker().Insert(OnInputDeviceIsGamepad);
177 AddActionListeners();
181 override void HandlerAttached(Widget w)
188 m_wDpadActionWidgetRightMenu = w.FindAnyWidget(
"Action");
189 m_wDefaultFocusWidget = m_wOwner.FindAnyWidget(m_sDefaultButtonName);
192 GetGame().GetCallqueue().CallLater(SetupMap, 1000);
196 override void HandlerDeattached(Widget w)
201 GetGame().OnInputDeviceIsGamepadInvoker().Remove(OnInputDeviceIsGamepad);
205 protected void AddActionListeners()
207 GetGame().GetInputManager().AddActionListener(m_sRightMenuAction, EActionTrigger.DOWN, SetFocusRightMenu);
208 GetGame().GetInputManager().AddActionListener(m_sToolMenuAction, EActionTrigger.DOWN, SetFocusToolMenu);
213 protected void RemoveActionListeners()
215 GetGame().GetInputManager().RemoveActionListener(m_sRightMenuAction, EActionTrigger.DOWN, SetFocusRightMenu);
216 GetGame().GetInputManager().RemoveActionListener(m_sToolMenuAction, EActionTrigger.DOWN, SetFocusToolMenu);
221 protected void SetFocusRightMenu()
223 if (!m_wDefaultFocusWidget)
226 ShowDpadWidgets(
false);
227 ShowControlHints(m_wOwner,
true);
229 GetGame().GetWorkspace().SetFocusedWidget(m_wDefaultFocusWidget);
231 RemoveActionListeners();
232 GetGame().GetInputManager().AddActionListener(
"MenuBack", EActionTrigger.DOWN, DisableFocusRightMenu);
235 m_DeployMenu.AllowMapContext(
false);
239 protected void SetFocusToolMenu()
241 if (!m_MapToolMenuUI)
244 EnableWidget(m_wMapToolWidget,
true);
245 ShowControlHints(m_wMapToolWidget,
true);
246 m_MapToolMenuUI.SetToolMenuFocused(
true);
247 ShowDpadWidgets(
false);
249 RemoveActionListeners();
250 GetGame().GetInputManager().AddActionListener(
"MenuBack", EActionTrigger.DOWN, DisableFocusToolMenu);
253 m_DeployMenu.AllowMapContext(
false);
257 protected void DisableFocusRightMenu()
262 selector.SetExpanded(
false);
263 GetGame().GetWorkspace().SetFocusedWidget(m_wDefaultFocusWidget);
267 GetGame().GetWorkspace().SetFocusedWidget(
null);
269 GetGame().GetInputManager().RemoveActionListener(
"MenuBack", EActionTrigger.DOWN, DisableFocusRightMenu);
270 AddActionListeners();
272 ShowDpadWidgets(
true);
273 ShowControlHints(m_wOwner,
false);
276 m_DeployMenu.AllowMapContext(
true);
280 protected void DisableFocusToolMenu()
282 if (!m_MapToolMenuUI)
285 if (IsAnyEntryActive())
289 m_MapToolMenuUI.SetToolMenuFocused(
true);
293 GetGame().GetInputManager().RemoveActionListener(
"MenuBack", EActionTrigger.DOWN, DisableFocusToolMenu);
294 m_MapToolMenuUI.SetToolMenuFocused(
false);
295 AddActionListeners();
296 ShowDpadWidgets(
true);
297 ShowControlHints(m_wMapToolWidget,
false);
300 m_DeployMenu.AllowMapContext(
true);
304 protected bool IsAnyEntryActive()
306 array<ref SCR_MapToolEntry> entries = m_MapToolMenuUI.GetMenuEntries();
307 if (!entries || entries.IsEmpty())
313 if ((entry.GetImageSet() ==
"ruler") || (entry.GetImageSet() ==
"compass") || (entry.GetImageSet() ==
"watch") || (entry.GetImageSet() ==
"editor"))
316 if (entry.IsEntryActive())
324 protected void CloseAllMapTools()
326 array<ref SCR_MapToolEntry> entries = m_MapToolMenuUI.GetMenuEntries();
327 if (!entries || entries.IsEmpty())
332 if ((entry.GetImageSet() ==
"ruler") || (entry.GetImageSet() ==
"compass") || (entry.GetImageSet() ==
"watch") || (entry.GetImageSet() ==
"editor"))
335 if (entry.IsEntryActive())
336 entry.SetActive(
false);