Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_HintUIComponent.c
Go to the documentation of this file.
2{
3 [Attribute()]
4 protected string m_sTitleWidgetName;
5
6 [Attribute()]
7 protected string m_sDescriptionWidgetName;
8
9 [Attribute()]
10 protected string m_sIconWidgetName;
11
12 [Attribute()]
13 protected string m_sToggleButtonWidgetName;
14
15 [Attribute()]
17
18 [Attribute()]
20
21 [Attribute()]
22 protected string m_sTimeLeftWidgetName;
23
24 [Attribute()]
25 protected string m_sPageWidgetName;
26
27 [Attribute()]
28 protected string m_sVisibilitySelectorName;
29
30 [Attribute()]
31 protected string m_sColorWidgetName;
32
33 [Attribute("Name of a widget under the same parent in which highlights will be created.\nOptional; when undefined, highlights will be created directly in workspace.")]
35
36 [Attribute(uiwidget: UIWidgets.LocaleEditBox)]
38
39 [Attribute(uiwidget: UIWidgets.LocaleEditBox)]
41
42 [Attribute(uiwidget: UIWidgets.LocaleEditBox)]
44
45 [Attribute("1", desc: "When enabled, the widget will show currently shown hint opn init.\nWhen disabled, currently shown hint will be cleared upon init.")]
46 protected bool m_bPreserveCurrentHint;
47
48 [Attribute(params: "layout")]
50
51 [Attribute(defvalue: "0.76078 0.39216 0.07843 1.0", UIWidgets.ColorPicker, desc: "Reforger default color")]
52 protected ref Color m_cReforgerColor;
53
54 [Attribute(defvalue: "0.760006 0.392004 0.078004 1.000000", UIWidgets.ColorPicker, desc: "Color of the time bar")]
55 protected ref Color m_cTimerColor;
56
57 protected Widget m_Widget;
62 protected ref array<Widget> m_aHighlightWidgets;
72 protected MenuBase m_Menu;
74 protected bool m_bMenuScanned;
76
77 protected bool m_bCanShow;
78 protected bool m_bIsHintShown;
80
81 protected const string PAGINATION_LOC_STRING = "#AR-Editor_ContentBrowser_PageIndex_Text";
82
83 //------------------------------------------------------------------------------------------------
84 protected void OnHintShow(SCR_HintUIInfo info, bool isSilent)
85 {
86 //--- When part of a menu, check if the menu is focused
87 if (!m_bMenuScanned && SCR_WidgetTools.InHierarchy(m_Widget, GetGame().GetWorkspace()))
88 {
89 m_bMenuScanned = true;
91 }
92
93 m_Widget.SetVisible(m_bCanShow);
94
95 if (m_OnHintShown)
96 m_OnHintShown.Invoke(true);
97
98 m_bIsHintShown = true;
99
100 if (m_Widget.IsVisibleInHierarchy() && info && info.HasDescription() && (!m_Menu || m_Menu.IsFocused()))
101 {
102 bool showName = info.SetNameTo(m_NameWidget);
103 bool showDescription = info.SetDescriptionTo(m_DescriptionWidget);
104 bool showIcon = info.SetIconTo(m_IconWidget);
105
106 m_NameWidget.SetVisible(showName);
107 m_DescriptionWidget.SetVisible(showDescription);
108 m_IconWidget.SetVisible(showIcon);
111
112 //--- Initialize pagination label
113 int sequencePage = info.GetSequencePage();
114 int sequenceCount = info.GetSequenceCount();
115 bool showNextButton;
116 if (sequenceCount > 1)
117 {
118 m_PageWidget.SetTextFormat(m_sPageText, sequencePage, sequenceCount);
119 m_PageWidget.SetVisible(true);
120 showNextButton = sequenceCount != sequencePage;
121 }
122 else
123 {
124 m_PageWidget.SetVisible(false);
125 }
126
127 m_ProgressBar.StopProgressAnimation();
128
129 if (showNextButton)
131 else
133
134 float startvalue;
135 int duration;
136 ChimeraWorld world = GetGame().GetWorld();
137 WorldTimestamp currentTime = world.GetServerTimestamp();
138 if (info.GetTimeStarted() != 0 || currentTime == info.GetTimeStarted() || info.GetDuration() == -1 || !info.IsTimerVisible())
139 {
140 startvalue = 1;
141 duration = info.GetDuration();
142 }
143 else
144 {
145 int timeDifferenceFromStart = currentTime.DiffMilliseconds(info.GetTimeStarted());
146 startvalue = 1 - timeDifferenceFromStart / info.GetDuration() / 1000;
147 duration = info.GetDuration() - timeDifferenceFromStart / 1000;
148 }
149
150 if (info.IsTimerVisible() && m_TimeWidget)
151 {
152 m_TimeWidget.SetVisible(true);
153 m_BarColor.SetColor(m_cTimerColor);
154 m_ProgressBar.SetValue(startvalue, false);
155 m_ProgressBar.SetAnimationTime(duration);
156 m_ProgressBar.SetValue(0);
157 }
158 else if (m_TimeWidget)
159 {
160 m_TimeWidget.SetVisible(false);
161 }
162
163 if (!info.GetName())
164 m_VisibilitySelector.SetVisible(false);
165 else
166 m_VisibilitySelector.SetVisible(true);
167
168 if (info.GetDuration() == -1 || !info.IsTimerVisible())
169 {
171 m_ProgressBar.SetValue(1, false);
172 }
173
174 AnimateWidget.Opacity(m_Widget, 1, UIConstants.FADE_RATE_FAST);
175
176 //--- Create highlights a bit later, so widgets which are part of the menu this hint UI belongs to have time to register
178 GetGame().GetCallqueue().CallLater(CreateHighlights, 1, false, info);
179
180 if (!isSilent)
181 SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.HINT, true);
182 }
183 else
184 {
185 OnHintHide(info, isSilent);
186 }
187 }
188
189 //------------------------------------------------------------------------------------------------
190 protected void OnHintHide(SCR_HintUIInfo info, bool isSilent)
191 {
192 AnimateWidget.Opacity(m_Widget, 0, UIConstants.FADE_RATE_DEFAULT, true);
193
195 {
196 foreach (Widget hightlightWidget: m_aHighlightWidgets)
197 {
198 if (hightlightWidget)
199 hightlightWidget.RemoveFromHierarchy();
200 }
201 }
202
203 if (m_OnHintShown)
204 m_OnHintShown.Invoke(false);
205
206 m_bIsHintShown = false;
207 }
208
209 //------------------------------------------------------------------------------------------------
210 protected void CreateHighlights(SCR_HintUIInfo info)
211 {
214
215 array<string> hightlightWidgetNames = {};
217 Widget hightlightWidget;
218 for (int i, count = info.GetHighlightWidgetNames(hightlightWidgetNames); i < count; i++)
219 {
221 if (hightlightWidget)
222 m_aHighlightWidgets.Insert(hightlightWidget);
223 }
224 }
225
226 //------------------------------------------------------------------------------------------------
227 override bool OnClick(Widget w, int x, int y, int button)
228 {
229 if (SCR_WidgetTools.InHierarchy(w, m_ToggleButtonWidget))
230 {
231 SCR_HintManagerComponent hintManager = SCR_HintManagerComponent.GetInstance();
232 if (hintManager)
233 hintManager.Toggle();
234 }
235
236 if (SCR_WidgetTools.InHierarchy(w, m_ContextButtonWidget))
237 {
238 SCR_HintManagerComponent hintManager = SCR_HintManagerComponent.GetInstance();
239 if (hintManager)
240 hintManager.OpenContext();
241 }
242
243 if (SCR_WidgetTools.InHierarchy(w, m_DismissButtonWidget))
244 {
245 SCR_HintManagerComponent hintManager = SCR_HintManagerComponent.GetInstance();
246 if (hintManager)
247 hintManager.DontShowAgainCurrent();
248 }
249
250 return false;
251 }
252
253 //------------------------------------------------------------------------------------------------
254 //--- Refresh hint, as it sometimes uses device-specific lines
255 protected void OnInputDeviceIsGamepad(bool isGamepad)
256 {
257 SCR_HintManagerComponent hintManager = SCR_HintManagerComponent.GetInstance();
258 if (hintManager)
259 hintManager.Refresh();
260 }
261
262 //------------------------------------------------------------------------------------------------
263 protected void OnSettingsChanged()
264 {
266 if (!hudManager)
267 return;
268
269 BaseContainer interfaceSettings = GetGame().GetGameUserSettings().GetModule(hudManager.GetInterfaceSettingsClass());
270 if (!interfaceSettings)
271 return;
272
273 bool state;
274 interfaceSettings.Get("m_bShowHints", state);
275 m_bCanShow = state;
276 }
277
278 //------------------------------------------------------------------------------------------------
279 override void HandlerAttached(Widget w)
280 {
281 m_Widget = w;
282
285 if (m_ToggleButton)
287
289 return;
290
293 if (m_DismissButton && !m_DismissButtonText.IsEmpty())
295
296 m_Widget.SetOpacity(0);
297 m_Widget.SetVisible(false);
298
299 // Since Hints still work as component inside Editor, we need to apply the same logic as to the InfoDisplay here.
301 if (hudManager)
302 {
303 BaseContainer interfaceSettings = GetGame().GetGameUserSettings().GetModule(hudManager.GetInterfaceSettingsClass());
304 if (interfaceSettings)
305 {
306 bool state;
307 interfaceSettings.Get("m_bShowHints", state);
308 m_bCanShow = state;
309
310 GetGame().OnUserSettingsChangedInvoker().Insert(OnSettingsChanged);
311 }
312 }
313
314
315 SCR_HintManagerComponent hintManager = SCR_HintManagerComponent.GetInstance();
316 if (!hintManager)
317 return;
318
319 m_NameWidget = TextWidget.Cast(m_Widget.FindAnyWidget(m_sTitleWidgetName));
321 m_IconWidget = ImageWidget.Cast(m_Widget.FindAnyWidget(m_sIconWidgetName));
323 m_PageWidget = TextWidget.Cast(m_Widget.FindAnyWidget(m_sPageWidgetName));
327 m_BarColor = ImageWidget.Cast(m_Widget.FindAnyWidget(m_sColorWidgetName));
329
330 hintManager.GetOnHintShow().Insert(OnHintShow);
331 hintManager.GetOnHintHide().Insert(OnHintHide);
332
333 SCR_HintUIInfo currentHint = hintManager.GetCurrentHint();
334 if (currentHint)
335 {
337 {
338 //--- Show the current hint again in the new area
339 OnHintShow(currentHint, true);
340 }
341 else if (!currentHint.IsInSequence())
342 {
343 //--- Hide the current hint because it doesn't make sense in the current context (not sequence hints, they should not be interrupted)
344 hintManager.Hide();
345 }
346 }
347
348 GetGame().OnInputDeviceIsGamepadInvoker().Insert(OnInputDeviceIsGamepad);
349 }
350
351 //------------------------------------------------------------------------------------------------
352 override void HandlerDeattached(Widget w)
353 {
354 GetGame().OnInputDeviceIsGamepadInvoker().Remove(OnInputDeviceIsGamepad);
355 GetGame().OnUserSettingsChangedInvoker().Remove(OnSettingsChanged);
356
357 SCR_HintManagerComponent hintManager = SCR_HintManagerComponent.GetInstance();
358 if (!hintManager)
359 return;
360
361 hintManager.GetOnHintShow().Remove(OnHintShow);
362 hintManager.GetOnHintHide().Remove(OnHintHide);
363
364 // Keep persistent hint opened
365 SCR_HintUIInfo hint = hintManager.GetCurrentHint();
366 if (hint && hintManager.IsShown() && hint.IsPersistent())
367 {
368 hintManager.Hide();
369 hintManager.Show(hint, true);
370 }
371 }
372
373 //------------------------------------------------------------------------------------------------
381
382 //------------------------------------------------------------------------------------------------
384 {
385 return m_bIsHintShown;
386 }
387}
EFieldManualEntryId
used to grab the first id-matching Field Manual entry
ArmaReforgerScripted GetGame()
Definition game.c:1398
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
ScriptInvokerBase< ScriptInvokerBoolMethod > ScriptInvokerBool
static WidgetAnimationOpacity Opacity(Widget widget, float targetValue, float speed, bool toggleVisibility=false)
Definition Color.c:13
static bool IsEditMode()
Definition Functions.c:1566
static SCR_HUDManagerComponent GetHUDManager()
override void HandlerAttached(Widget w)
SCR_WLibProgressBarComponent m_ProgressBar
void OnInputDeviceIsGamepad(bool isGamepad)
LocalizedString m_ToggleButtonTextNext
ref array< Widget > m_aHighlightWidgets
SCR_InputButtonComponent m_ToggleButton
override void HandlerDeattached(Widget w)
void OnHintHide(SCR_HintUIInfo info, bool isSilent)
ref ScriptInvokerBool m_OnHintShown
SCR_InputButtonComponent m_DismissButton
void CreateHighlights(SCR_HintUIInfo info)
void OnHintShow(SCR_HintUIInfo info, bool isSilent)
override bool OnClick(Widget w, int x, int y, int button)
LocalizedString m_sPageText
ScriptInvokerBool GetOnHintShown()
const string PAGINATION_LOC_STRING
LocalizedString m_DismissButtonText
LocalizedString m_ToggleButtonTextHide
SizeLayoutWidget m_TimeWidget
override bool SetDescriptionTo(TextWidget textWidget)
bool GetIsDontShowAgainVisible()
EFieldManualEntryId GetFieldManualLink()
WorldTimestamp GetTimeStarted()
int GetHighlightWidgetNames(out notnull array< string > outWidgetNames)
Minimalist progress bar.
static SCR_WLibProgressBarComponent GetProgressBar(string name, Widget parent, bool searchAllChildren=true)
static Widget CreateHighlight(Widget widget, ResourceName layout, Widget parent=null)
SCR_FieldOfViewSettings Attribute