Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_SuperMenuComponent.c
Go to the documentation of this file.
1 
11 {
12  [Attribute("{08CF3B69CB1ACBC4}UI/layouts/WidgetLibrary/WLib_NavigationButton.layout")]
13  protected ResourceName m_sNavigationButtonLayout;
14 
15  [Attribute("TabView", UIWidgets.EditBox, desc: "Name of tabview widget to find tab view component.")]
16  protected string m_sTabViewName;
17 
18  protected SCR_TabViewComponent m_TabViewComponent;
19 
20  protected SCR_SubMenuBase m_OpenedSubmenu;
21  protected ref array<SCR_SubMenuBase> m_aSubMenus = {};
22 
23  Widget m_wMenuRoot;
24 
25  // Menu requests
26  protected ref ScriptInvokerVoid m_OnRequestCloseMenu;
27 
28  //------------------------------------------------------------------------------------------------
29  // --- Main events, needing to be called by manager classes ---
30  //------------------------------------------------------------------------------------------------
31  // As parameter, pass a widget the sub menus can use to grab whatever they need from the menu layout (eg the SCR_DynamicFooterComponent)
32  void Init(Widget menuRoot)
33  {
34  m_wMenuRoot = menuRoot;
35 
36  // Tab view
37  Widget tabView = m_wRoot.FindAnyWidget(m_sTabViewName);
38  if (tabView)
39  m_TabViewComponent = SCR_TabViewComponent.Cast(tabView.FindHandler(SCR_TabViewComponent));
40 
41  if (!m_TabViewComponent)
42  return;
43 
44  m_TabViewComponent.GetOnContentCreate().Insert(OnTabCreate);
45  m_TabViewComponent.GetOnContentShow().Insert(OnTabShow);
46  m_TabViewComponent.GetOnContentHide().Insert(OnTabHide);
47  m_TabViewComponent.GetOnContentRemove().Insert(OnTabRemove);
48  m_TabViewComponent.GetOnTabChange().Insert(OnTabChange);
49 
50  // Init tabs
51  if (m_TabViewComponent.m_bManualInit)
52  {
53  // Init tab view and rely on it's events
54  m_TabViewComponent.Init();
55  }
56  else
57  {
58  // Tab view has already created tabs, manually init opened content
59  array<ref SCR_TabViewContent> contents = m_TabViewComponent.GetContents();
60 
61  foreach (int i, SCR_TabViewContent content : contents)
62  {
63  if (!content.m_wTab)
64  continue;
65 
66  OnTabCreate(m_TabViewComponent, content.m_wTab, i);
67 
68  if (i == m_TabViewComponent.m_iSelectedTab)
69  OnTabShow(m_TabViewComponent, content.m_wTab);
70  }
71  }
72  }
73 
74  //------------------------------------------------------------------------------------------------
75  void OnMenuShow()
76  {
77  if (m_OpenedSubmenu && m_OpenedSubmenu.GetRootWidget().IsVisible() && m_OpenedSubmenu.GetShown())
78  m_OpenedSubmenu.OnMenuShow();
79  }
80 
81  //------------------------------------------------------------------------------------------------
82  void OnMenuHide()
83  {
84  if (m_OpenedSubmenu)
85  m_OpenedSubmenu.OnMenuHide();
86  }
87 
88  //------------------------------------------------------------------------------------------------
89  void OnMenuUpdate(float tDelta)
90  {
91  if (m_OpenedSubmenu && m_OpenedSubmenu.GetRootWidget().IsVisible() && m_OpenedSubmenu.GetShown())
92  m_OpenedSubmenu.OnMenuUpdate(tDelta);
93  }
94 
95  //------------------------------------------------------------------------------------------------
96  void OnMenuFocusGained()
97  {
98  if (m_OpenedSubmenu)
99  m_OpenedSubmenu.OnMenuFocusGained();
100  }
101 
102  //------------------------------------------------------------------------------------------------
103  void OnMenuFocusLost()
104  {
105  if (m_OpenedSubmenu)
106  m_OpenedSubmenu.OnMenuFocusLost();
107  }
108 
109  //------------------------------------------------------------------------------------------------
110  void OnMenuClose()
111  {
112  foreach (SCR_SubMenuBase subMenu : m_aSubMenus)
113  {
114  if (!subMenu)
115  continue;
116 
117  subMenu.OnTabHide();
118  subMenu.OnTabRemove();
119  }
120  }
121 
122  //------------------------------------------------------------------------------------------------
123  // --- Sub menus handling ---
124  //------------------------------------------------------------------------------------------------
125  SCR_SubMenuBase OnTabCreate(SCR_TabViewComponent comp, Widget w, int index)
126  {
127  if (!w)
128  return null;
129 
130  SCR_SubMenuBase subMenu = SCR_SubMenuBase.Cast(w.FindHandler(SCR_SubMenuBase));
131  if (!subMenu)
132  return null;
133 
134  subMenu.GetOnRequestCloseMenu().Insert(OnRequestCloseMenu);
135  subMenu.GetOnRequestTabChange().Insert(OnRequestTabChange);
136 
137  // Init sub menu
138  subMenu.OnTabCreate(m_wMenuRoot, m_sNavigationButtonLayout, index);
139 
140  m_aSubMenus.Insert(subMenu);
141 
142  return subMenu;
143  }
144 
145  //------------------------------------------------------------------------------------------------
146  SCR_SubMenuBase OnTabShow(SCR_TabViewComponent comp, Widget w)
147  {
148  if (!w)
149  return null;
150 
151  SCR_SubMenuBase subMenu = SCR_SubMenuBase.Cast(w.FindHandler(SCR_SubMenuBase));
152  if (!subMenu)
153  return null;
154 
155  subMenu.OnTabShow();
156  m_OpenedSubmenu = subMenu;
157 
158  return subMenu;
159  }
160 
161  //------------------------------------------------------------------------------------------------
162  SCR_SubMenuBase OnTabHide(SCR_TabViewComponent comp, Widget w)
163  {
164  if (!w)
165  return null;
166 
167  SCR_SubMenuBase subMenu = SCR_SubMenuBase.Cast(w.FindHandler(SCR_SubMenuBase));
168  if (!subMenu)
169  return null;
170 
171  subMenu.OnTabHide();
172 
173  return subMenu;
174  }
175 
176  //------------------------------------------------------------------------------------------------
177  SCR_SubMenuBase OnTabRemove(SCR_TabViewComponent comp, Widget w)
178  {
179  if (!w)
180  return null;
181 
182  SCR_SubMenuBase subMenu = SCR_SubMenuBase.Cast(w.FindHandler(SCR_SubMenuBase));
183  if (!subMenu)
184  return null;
185 
186  subMenu.OnTabRemove();
187  m_aSubMenus.RemoveItem(subMenu);
188 
189  return subMenu;
190  }
191 
192  //------------------------------------------------------------------------------------------------
193  SCR_SubMenuBase OnTabChange(SCR_TabViewComponent comp, Widget w)
194  {
195  if (!w)
196  return null;
197 
198  SCR_SubMenuBase subMenu = SCR_SubMenuBase.Cast(w.FindHandler(SCR_SubMenuBase));
199  if (!subMenu)
200  return null;
201 
202  subMenu.OnTabChange();
203 
204  return subMenu;
205  }
206 
207  //------------------------------------------------------------------------------------------------
208  protected void OnRequestCloseMenu()
209  {
210  if (m_OnRequestCloseMenu)
211  m_OnRequestCloseMenu.Invoke();
212  }
213 
214  //------------------------------------------------------------------------------------------------
215  protected void OnRequestTabChange(int newTab, int oldTab)
216  {
217  m_TabViewComponent.ShowTab(newTab);
218  }
219 
220  //------------------------------------------------------------------------------------------------
221  // --- Public ---
222  //------------------------------------------------------------------------------------------------
223  SCR_TabViewComponent GetTabView()
224  {
225  return m_TabViewComponent;
226  }
227 
228  //------------------------------------------------------------------------------------------------
229  int GetSelectedTab()
230  {
231  return m_TabViewComponent.m_iSelectedTab;
232  }
233 
234  //------------------------------------------------------------------------------------------------
235  SCR_SubMenuBase GetOpenedSubMenu()
236  {
237  return m_OpenedSubmenu;
238  }
239 
240  //------------------------------------------------------------------------------------------------
241  SCR_SubMenuBase GetSubMenu(int index)
242  {
243  if (!m_aSubMenus.IsIndexValid(index))
244  return null;
245 
246  return m_aSubMenus[index];
247  }
248 
249  //------------------------------------------------------------------------------------------------
250  static SCR_SuperMenuComponent FindComponent(notnull Widget w)
251  {
252  return SCR_SuperMenuComponent.Cast(w.FindHandler(SCR_SuperMenuComponent));
253  }
254 
255  //------------------------------------------------------------------------------------------------
256  // --- Invokers ---
257  //------------------------------------------------------------------------------------------------
258  //------------------------------------------------------------------------------------------------
259  ScriptInvokerVoid GetOnRequestCloseMenu()
260  {
261  if (!m_OnRequestCloseMenu)
262  m_OnRequestCloseMenu = new ScriptInvokerVoid();
263 
264  return m_OnRequestCloseMenu;
265  }
266 }
m_wRoot
protected Widget m_wRoot
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:59
SCR_SuperMenuComponent
Definition: SCR_SuperMenuComponent.c:10
SCR_SubMenuBase
Definition: SCR_SubMenuBase.c:6
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
SCR_TabViewComponent
Definition: SCR_TabViewComponent.c:13
Attribute
typedef Attribute
Post-process effect of scripted camera.
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition: SCR_DestructionSynchronizationComponent.c:17
ScriptInvokerVoid
ScriptInvokerBase< ScriptInvokerVoidMethod > ScriptInvokerVoid
Definition: SCR_ScriptInvokerHelper.c:9
SCR_ScriptedWidgetComponent
Definition: SCR_ScriptedWidgetComponent.c:7