Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_SubMenuBase.c
Go to the documentation of this file.
1/*
2Component for SCR_SuperMenuComponent tab.
3Relies on a SCR_DynamicFooterComponent somewhere in the layout under the menuRoot widget passed on creation to handle input buttons of the tab
4*/
5
7{
9
11 protected ref array<SCR_InputButtonComponent> m_aNavigationButtons = {};
13
15 protected int m_iIndex;
16
17 protected bool m_bShown;
18 protected bool m_bFocused;
19
20 // Menu requests
23
24 //------------------------------------------------------------------------------------------------
25 // --- Menu events ---
26 //------------------------------------------------------------------------------------------------
28 {
29 m_bFocused = true;
30 }
31
32 //------------------------------------------------------------------------------------------------
34 {
35 m_bFocused = false;
36 }
37
38 //------------------------------------------------------------------------------------------------
39 void OnMenuShow();
40 void OnMenuHide();
41 void OnMenuUpdate(float tDelta);
42
43 //------------------------------------------------------------------------------------------------
44 // --- Tab events ---
45 //------------------------------------------------------------------------------------------------
46 // Tab initialization, depending on SCR_TabViewComponent settings it can happen before or after OnMenuOpen, or even when the tab is first selected
47 void OnTabCreate(Widget menuRoot, ResourceName buttonsLayout, int index)
48 {
50 m_wMenuRoot = menuRoot;
51 m_DynamicFooter = SCR_DynamicFooterComponent.FindComponentInHierarchy(menuRoot);
52 m_sNavigationButtonLayout = buttonsLayout;
53 }
54
55 //------------------------------------------------------------------------------------------------
56 // Tab has actively been selected, or it's the default one after creation
57 void OnTabShow()
58 {
60 m_bShown = true;
61 }
62
63 //------------------------------------------------------------------------------------------------
64 // Another tab has been selected
65 void OnTabHide()
66 {
68 m_bShown = false;
69 }
70
71 //------------------------------------------------------------------------------------------------
72 // Tab destruction
74 {
76 {
77 Widget w = comp.GetRootWidget();
78 if (!w)
79 continue;
80
81 w.RemoveFromHierarchy();
82 }
83 }
84
85 //------------------------------------------------------------------------------------------------
86 // Generic, happens anytime a tab is selected
88
89 //------------------------------------------------------------------------------------------------
90 // --- Protected ---
91 //------------------------------------------------------------------------------------------------
92 protected void ShowNavigationButtons(bool show)
93 {
94 bool visible;
96 {
97 if (m_aNavigationButtonsVisibilityFlags.Contains(comp))
98 visible = m_aNavigationButtonsVisibilityFlags.Get(comp);
99
100 visible = visible && show;
101
102 comp.SetVisible(visible, false);
103 }
104 }
105
106 //------------------------------------------------------------------------------------------------
107 // Flags a button to be set visible the next time ShowNavigationButtons() is called, like on TabShow
109 {
110 if (!button)
111 return;
112
113 if (!m_aNavigationButtonsVisibilityFlags.Contains(button) || !m_aNavigationButtons.Contains(button))
114 {
116 "SCR_SubMenuBase - FlagNavigationButtonVisibility() - button %1, %2 is not a sub menu footer button as it was not created with CreateNavigationButton() method",
117 button,
118 button.GetRootWidget().GetName()
119 );
120
121 return;
122 }
123
124 m_aNavigationButtonsVisibilityFlags.Set(button, show);
125 }
126
127 //------------------------------------------------------------------------------------------------
128 // Use this to control the visibility of buttons created with CreateNavigationButton() method
129 protected void SetNavigationButtonVisible(SCR_InputButtonComponent button, bool show, bool animate = false)
130 {
131 if (!button)
132 return;
133
134 if (!m_aNavigationButtonsVisibilityFlags.Contains(button) || !m_aNavigationButtons.Contains(button))
135 {
137 "SCR_SubMenuBase - SetFooterButtonVisibile() - button %1, %2 is not a sub menu footer button as it was not created with CreateNavigationButton() method",
138 button,
139 button.GetRootWidget().GetName()
140 );
141
142 return;
143 }
144
145 FlagNavigationButtonVisibility(button, show);
146 button.SetVisible(m_bShown && show, animate);
147 }
148
149 //------------------------------------------------------------------------------------------------
150 // If used on tab show, make sure to avoid creating duplicates
151 protected SCR_InputButtonComponent CreateNavigationButton(string actionName, string label, bool rightFooter = false, bool show = true)
152 {
153 if (!m_DynamicFooter)
154 return null;
155
156 SCR_EDynamicFooterButtonAlignment alignment = SCR_EDynamicFooterButtonAlignment.LEFT;
157 if (rightFooter)
158 alignment = SCR_EDynamicFooterButtonAlignment.RIGHT;
159
160 SCR_InputButtonComponent comp = m_DynamicFooter.CreateButton(m_sNavigationButtonLayout, label + m_iIndex, label, actionName, alignment, show);
161
162 if (!comp)
163 return null;
164
165 m_aNavigationButtons.Insert(comp);
166 m_aNavigationButtonsVisibilityFlags.Insert(comp, show);
167 return comp;
168 }
169
170 //------------------------------------------------------------------------------------------------
171 protected void RequestCloseMenu()
172 {
174 m_OnRequestCloseMenu.Invoke();
175 }
176
177 //------------------------------------------------------------------------------------------------
178 // Provides the desired tab and the current index
179 protected void RequestTabChange(int newTabIndex)
180 {
182 m_OnRequestTabChange.Invoke(newTabIndex, m_iIndex);
183 }
184
185 //------------------------------------------------------------------------------------------------
186 // --- Public ---
187 //------------------------------------------------------------------------------------------------
188 bool GetShown()
189 {
190 return m_bShown;
191 }
192
193 //------------------------------------------------------------------------------------------------
195 {
196 return m_iIndex;
197 }
198
199 //------------------------------------------------------------------------------------------------
207
208 //------------------------------------------------------------------------------------------------
216}
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
ScriptInvokerBase< ScriptInvokerVoidMethod > ScriptInvokerVoid
ScriptInvokerBase< ScriptInvokerInt2Method > ScriptInvokerInt2
ScriptInvokerVoid GetOnRequestCloseMenu()
void FlagNavigationButtonVisibility(SCR_InputButtonComponent button, bool show)
ResourceName m_sNavigationButtonLayout
SCR_InputButtonComponent CreateNavigationButton(string actionName, string label, bool rightFooter=false, bool show=true)
SCR_DynamicFooterComponent m_DynamicFooter
void OnMenuUpdate(float tDelta)
void RequestTabChange(int newTabIndex)
ref ScriptInvokerInt2 m_OnRequestTabChange
ref ScriptInvokerVoid m_OnRequestCloseMenu
ScriptInvokerInt2 GetOnRequestTabChange()
ref map< SCR_InputButtonComponent, bool > m_aNavigationButtonsVisibilityFlags
void ShowNavigationButtons(bool show)
ref array< SCR_InputButtonComponent > m_aNavigationButtons
void OnTabCreate(Widget menuRoot, ResourceName buttonsLayout, int index)
void SetNavigationButtonVisible(SCR_InputButtonComponent button, bool show, bool animate=false)
Definition Types.c:486
proto void PrintFormat(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL, LogLevel level=LogLevel.NORMAL)