Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ListMenuEntryComponent.c
Go to the documentation of this file.
1/*
2Base class for list menus, providing unified visuals
3*/
4//------------------------------------------------------------------------------------------------
6{
7 // Text scrolling anims
8 protected ref array<ref SCR_HorizontalScrollAnimationComponent> m_aScrollAnimations = {};
9
10 // Mouse buttons
11 // These arrays need to be filled by child classes with the specific buttons
13 protected ref array<SCR_ModularButtonComponent> m_aMouseButtons = {};
14
15 // Main
16 protected SCR_ModularButtonComponent m_MainModularButton;
17 protected bool m_bUnavailable; //Entry is unavailable but the widget still needs to be interactable.
18 protected bool m_bFocused;
19
20 // Tooltip
22
23 // Invokers
24 // Called when a mouse interaction button is pressed
26
30
31 // ---- OVERRIDES ----
32 //------------------------------------------------------------------------------------------------
33 override void HandlerAttached(Widget w)
34 {
35 // Setup scroll animations
37
38 // Mouse Buttons
39 foreach (SCR_ModularButtonComponent button : m_aMouseButtons)
40 {
41 button.m_OnMouseEnter.Insert(OnInnerButtonHover);
42 button.m_OnMouseLeave.Insert(OnInnerButtonLeave);
43 }
44
45 super.HandlerAttached(w);
46 }
47
48 //------------------------------------------------------------------------------------------------
49 override void HandlerDeattached(Widget w)
50 {
51 if (m_OnFocus)
52 m_OnFocus.Clear();
53
54 if (m_OnFocusLost)
55 m_OnFocusLost.Clear();
56
58 m_OnMouseEnter.Clear();
59
61
62 super.HandlerDeattached(w);
63 }
64
65 //------------------------------------------------------------------------------------------------
66 override bool OnClick(Widget w, int x, int y, int button)
67 {
68 // LMB check
69 if (button != 0 || m_bInnerButtonInteraction)
70 return false;
71
72 return super.OnClick(w, x, y, button);
73 }
74
75 //------------------------------------------------------------------------------------------------
76 override bool OnDoubleClick(Widget w, int x, int y, int button)
77 {
78 // LMB check
79 if (button != 0 || m_bInnerButtonInteraction)
80 return false;
81
82 return super.OnDoubleClick(w, x, y, button);
83 }
84
85 //------------------------------------------------------------------------------------------------
86 override bool OnFocus(Widget w, int x, int y)
87 {
88 if (m_OnFocus)
89 m_OnFocus.Invoke(this);
90
91 m_bFocused = true;
93
94 if (!m_aScrollAnimations.IsEmpty())
96
97 // Tooltips
99
100 return super.OnFocus(w, x, y);
101 }
102
103 //------------------------------------------------------------------------------------------------
104 override bool OnFocusLost(Widget w, int x, int y)
105 {
106 if (m_OnFocusLost)
107 m_OnFocusLost.Invoke(this);
108
109 m_bFocused = false;
111
112 // Stop anim
114
115 // Tooltips
117
118 return super.OnFocusLost(w, x, y);
119 }
120
121 //------------------------------------------------------------------------------------------------
122 override bool OnMouseEnter(Widget w, int x, int y)
123 {
124 if (m_OnMouseEnter)
125 m_OnMouseEnter.Invoke(this);
126
127 return super.OnMouseEnter(w, x, y);
128 }
129
130 // ---- PROTECTED ----
131 //------------------------------------------------------------------------------------------------
133 {
134 m_CurrentTooltip = tooltip;
135 }
136
137 //------------------------------------------------------------------------------------------------
138 protected void OnInnerButtonHover()
139 {
141 }
142
143 //------------------------------------------------------------------------------------------------
144 protected void OnInnerButtonLeave()
145 {
147 }
148
149 //------------------------------------------------------------------------------------------------
151 protected void EnableTextAnimations(bool enable)
152 {
153 foreach (SCR_HorizontalScrollAnimationComponent anim : m_aScrollAnimations)
154 {
155 HandleTextAnimation(anim, enable);
156 }
157 }
158
159 //------------------------------------------------------------------------------------------------
162 protected void HandleTextAnimation(SCR_HorizontalScrollAnimationComponent anim, bool enable)
163 {
164 if (!anim)
165 return;
166
167 if (enable)
168 {
169 if (!anim.GetContentFitX())
170 {
171 anim.AnimationStart();
172 }
173 else
174 {
175 anim.AnimationStop();
176 anim.ResetPosition();
177 }
178
179 return;
180 }
181
182 // Disabled
183 anim.AnimationStop();
184 anim.ResetPosition();
185 }
186
187 //------------------------------------------------------------------------------------------------
188 protected void UpdateModularButtons()
189 {
190 // --- Main elements color ---
191 // Toggling the line's main modular button component is used as a quck way to change the line's elements while mantaining it active (they inherit color)
193 m_MainModularButton = SCR_ModularButtonComponent.FindComponent(m_wRoot);
195 return;
196
197 m_MainModularButton.SetToggled(m_bUnavailable, false);
198
199 // Name
200 Color color = Color.FromInt(UIColors.NEUTRAL_INFORMATION.PackToInt());
201 if (m_bUnavailable)
202 color = Color.FromInt(UIColors.IDLE_DISABLED.PackToInt());
203
204 SCR_ButtonEffectColor nameEffect = SCR_ButtonEffectColor.Cast(m_MainModularButton.FindEffect(SCR_ListEntryHelper.EFFECT_NAME_COLOR));
205 if (nameEffect)
206 nameEffect.m_cFocusLost = color;
207
208 // Elements
209 if (!m_bUnavailable)
210 color = Color.FromInt(UIColors.NEUTRAL_ACTIVE_STANDBY.PackToInt());
211
212 array<SCR_ButtonEffectBase> effects = m_MainModularButton.FindAllEffects(SCR_ListEntryHelper.EFFECT_WRAPPER_COLOR);
213 if (effects.IsEmpty())
214 return;
215
216 foreach (SCR_ButtonEffectBase effect : effects)
217 {
218 SCR_ButtonEffectColor colorEffect = SCR_ButtonEffectColor.Cast(effect);
219 if (colorEffect)
220 colorEffect.m_cFocusLost = color;
221 }
222
223 m_MainModularButton.InvokeAllEnabledEffects(true);
224 }
225
226 //------------------------------------------------------------------------------------------------
227 protected void OpacityAnimation(int time, float opacityEnd)
228 {
229 AnimateWidget.Opacity(GetRootWidget(), opacityEnd, time);
230 }
231
232 // ---- PUBLIC ----
233 //------------------------------------------------------------------------------------------------
235 void AnimateOpacity(int delay, float animationTime, float opacityEnd, float opacityStart = -1)
236 {
237 if (opacityStart != -1)
238 GetRootWidget().SetOpacity(opacityStart);
239
240 GetGame().GetCallqueue().Remove(OpacityAnimation);
241
242 // Start animating with a delay to prevent flickering
243 GetGame().GetCallqueue().CallLater(OpacityAnimation, delay, false, animationTime, opacityEnd);
244 }
245
246 //------------------------------------------------------------------------------------------------
251
252 //------------------------------------------------------------------------------------------------
254 {
255 return m_bFocused;
256 }
257
258 //------------------------------------------------------------------------------------------------
260 {
261 return !m_bUnavailable;
262 }
263
264 //------------------------------------------------------------------------------------------------
272
273 //------------------------------------------------------------------------------------------------
281
282 //------------------------------------------------------------------------------------------------
290
291 //------------------------------------------------------------------------------------------------
299}
ArmaReforgerScripted GetGame()
Definition game.c:1398
ScriptInvokerBase< ScriptInvokerStringMethod > ScriptInvokerString
ScriptInvokerBase< ScriptInvokerScriptedWidgetComponentMethod > ScriptInvokerScriptedWidgetComponent
static WidgetAnimationOpacity Opacity(Widget widget, float targetValue, float speed, bool toggleVisibility=false)
Definition Color.c:13
Effect which colorizes a widget with given name.
bool m_bUnavailable
void EnableTextAnimations(bool enable)
Apply behavior on all potentially longer entry text.
override bool OnDoubleClick(Widget w, int x, int y, int button)
bool IsAvailable()
void OnInnerButtonLeave()
SCR_ScriptedWidgetTooltip m_CurrentTooltip
ScriptInvokerScriptedWidgetComponent GetOnFocus()
override bool OnFocus(Widget w, int x, int y)
override bool OnClick(Widget w, int x, int y, int button)
bool IsInnerButtonInteraction()
bool IsFocused()
void OnInnerButtonHover()
override void HandlerDeattached(Widget w)
override void HandlerAttached(Widget w)
ref ScriptInvokerScriptedWidgetComponent m_OnFocus
void AnimateOpacity(int delay, float animationTime, float opacityEnd, float opacityStart=-1)
Animate whole widget opacity.
override bool OnMouseEnter(Widget w, int x, int y)
ref ScriptInvokerString m_OnMouseInteractionButtonClicked
ScriptInvokerString GetOnMouseInteractionButtonClicked()
void HandleTextAnimation(SCR_HorizontalScrollAnimationComponent anim, bool enable)
bool m_bFocused
void OnTooltipShow(SCR_ScriptedWidgetTooltip tooltip)
ScriptInvokerScriptedWidgetComponent GetOnFocusLost()
override bool OnFocusLost(Widget w, int x, int y)
ref array< ref SCR_HorizontalScrollAnimationComponent > m_aScrollAnimations
ref ScriptInvokerScriptedWidgetComponent m_OnFocusLost
ref ScriptInvokerScriptedWidgetComponent m_OnMouseEnter
bool m_bInnerButtonInteraction
void OpacityAnimation(int time, float opacityEnd)
ref array< SCR_ModularButtonComponent > m_aMouseButtons
void UpdateModularButtons()
ScriptInvokerScriptedWidgetComponent GetOnMouseEnter()
SCR_ModularButtonComponent m_MainModularButton
static ScriptInvokerTooltip GetOnTooltipShow()