Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_NotificationMessageUIComponent.c
Go to the documentation of this file.
2{
3 [Attribute()]
4 protected string m_sIcon;
5
6 [Attribute(desc: "Widgets that are colored by the Notification Color")]
7 protected ref array<string> m_aColoredWidgets;
8
9 [Attribute(desc: "Notifications widgets that are hidden if notification is GM only. These widgets should be shown by default")]
10 protected ref array<string> m_aNonGameMasterWidgets;
11
12 [Attribute(desc: "Notifications widgets that are shown if notification is GM only. These widgets should be hidden by default")]
13 protected ref array<string> m_aGameMasterOnlyWidgets;
14
15 [Attribute()]
16 protected string m_sNotificationText;
17
18 [Attribute("GoToIndicator")]
19 protected string m_sGoToIndicator;
20
21 [Attribute("GoToControlHint")]
22 protected string m_sGoToControlHint;
23
24 [Attribute("GotoIndicatorsHolder")]
25 protected string m_sGoToIndicatorsHolder;
26
27 //Reference
28 protected Widget m_wRoot;
34
36
37 //State
39 protected bool m_bHasPosition;
41
42 //Animation speed and update
43 protected static const float ANIMATION_DONE_UPDATE_SPEED = 100;
44 protected static const float FORCE_DELETE_FADE_SPEED = 3;
45 protected static const float AUTO_FADE_SPEED = 1;
46 protected static const float FADE_IN_SPEED = 2;
47
48 //------------------------------------------------------------------------------------------------
53 void Init(SCR_NotificationData data, SCR_NotificationsLogComponent notificationLog, float fadeDelay)
54 {
55 if (!m_wRoot)
56 return;
57
58 m_Data = data;
59 if (!m_Data)
60 return;
61
62 SCR_NotificationsComponent notificationManager = notificationLog.GetNotificationManager();
63 SCR_NotificationDisplayData displayData = data.GetDisplayData();
64 SCR_EditorManagerEntity editorManager = notificationLog.GetEditorManager();
65
66 m_NotificationsLog = notificationLog;
67
68 TextWidget notificationText = TextWidget.Cast(m_wRoot.FindAnyWidget(m_sNotificationText));
69 if (!notificationText)
70 return;
71
72 UpdateText();
73
75 ENotificationColor notificationColorEnum;
76 displayData.GetDisplayVisualizationData(data, uiInfo, notificationColorEnum);
77
78 if (uiInfo)
79 {
80 ImageWidget icon = ImageWidget.Cast(m_wRoot.FindAnyWidget(m_sIcon));
81 if (icon)
82 {
83 if (uiInfo.HasIcon())
84 uiInfo.SetIconTo(icon);
85 else
86 icon.SetVisible(false);
87 }
88
89 SetWidgetColor(m_NotificationsLog.GetNotificationWidgetColor(notificationColorEnum));
90 }
91
92 //Show Gm only visuals and hide non game master visuals
93 if (data.GetNotificationReceiverType() == ENotificationReceiver.GM_ONLY || data.GetNotificationReceiverType() == ENotificationReceiver.LOCAL_GM_ONLY || data.GetNotificationReceiverType() == ENotificationReceiver.GM_OR_AFFECTED_PLAYER_ONLY)
94 {
95 Widget elementWidget;
96
97 foreach (string element: m_aNonGameMasterWidgets)
98 {
99 elementWidget = m_wRoot.FindAnyWidget(element);
100
101 if (elementWidget)
102 elementWidget.SetVisible(false);
103 }
104
105 foreach (string element: m_aGameMasterOnlyWidgets)
106 {
107 elementWidget = m_wRoot.FindAnyWidget(element);
108
109 if (elementWidget)
110 elementWidget.SetVisible(true);
111 }
112 }
113
114 //Set text color
115 SCR_ColoredTextNotificationUIInfo coloredTextNotificationUIInfo = SCR_ColoredTextNotificationUIInfo.Cast(uiInfo);
116 if (coloredTextNotificationUIInfo)
117 {
118 Color textColor = notificationLog.GetNotificationTextColor(displayData.GetTextColor(data));
119 textColor.SetA(notificationText.GetColor().A());
120 notificationText.SetColor(textColor);
121 }
122
123 //Get position
125 if (m_NotificationsLog.HasNotificationInput() && displayData.GetPosition(data, position))
126 {
127 m_NotificationsLog.GetEditorManager().GetOnOpened().Insert(EditorOpened);
128 m_NotificationsLog.GetEditorManager().GetOnClosed().Insert(EditorClosed);
129 m_NotificationsLog.GetEditorManager().GetOnLimitedChange().Insert(OnLimitedChanged);
130
131 m_bHasPosition = true;
133
134 //notificationManager.GetOnNotification().Insert(OnNotification);
135 m_NotificationsLog.GetOnNewMessageHasPosition().Insert(OnNewNotificationHasPosition);
136 m_NotificationsLog.GetOnInputDeviceChanged().Insert(OnInputDeviceChanged);
137
138 if (!editorManager.IsOpened())
139 EditorClosed();
140 else
141 EditorOpened();
142 }
143 else
144 {
145 //Disable teleport button
146 m_wRoot.SetEnabled(false);
147 }
148
149 GetGame().GetCallqueue().CallLater(AutoFadeDelay, fadeDelay);
150
151 m_wRoot.SetOpacity(0);
153 }
154
155 //------------------------------------------------------------------------------------------------
158 {
159 if (!m_Data)
160 return;
161
162 string notificationMessage = m_Data.GetText();
163 if (notificationMessage.IsEmpty())
164 {
166 return;
167 }
168
169 SCR_NotificationDisplayData displayData = m_Data.GetDisplayData();
170 if (!displayData)
171 return;
172
173 TextWidget notificationText = TextWidget.Cast(m_wRoot.FindAnyWidget(m_sNotificationText));
174 if (!notificationText)
175 return;
176
177 string param1, param2, param3, param4, param5, param6;
178
179 if (notificationMessage != string.Empty)
180 m_Data.GetNotificationTextEntries(param1, param2, param3, param4, param5, param6);
181 else
182 notificationMessage = typename.EnumToString(ENotification, m_Data.GetID());
183
184 if (!displayData.MergeParam1With2())
185 {
186 notificationText.SetTextFormat(notificationMessage, param1, param2, param3, param4, param5, param6);
187 }
188 else
189 {
190 string mergeParams = WidgetManager.Translate(param2, param1);
191 notificationText.SetTextFormat(notificationMessage, param1, mergeParams, param3, param4, param5, param6);
192 }
193 }
194
195 //======================== SET COLOR ========================\\
196
197 //------------------------------------------------------------------------------------------------
198 protected void SetWidgetColor(Color notificationColor)
199 {
200 if (!m_aColoredWidgets || m_aColoredWidgets.IsEmpty())
201 return;
202
203 Color color;
204
205 foreach (string widgetName: m_aColoredWidgets)
206 {
207 Widget widget = m_wRoot.FindAnyWidget(widgetName);
208 if (widget)
209 {
210 color = Color.FromInt(notificationColor.PackToInt());
211 color.SetA(widget.GetColor().A());
212 widget.SetColor(notificationColor);
213 }
214 }
215 }
216
217 //Removed for now but can be used for mods.
218// protected void OnNotification(SCR_NotificationData data)
219// {
220//
221// }
222
223 //Quickly fades out notification and deletes it. Called when max notification count is reached
224 //------------------------------------------------------------------------------------------------
230
231 //------------------------------------------------------------------------------------------------
235 {
236 return Event_OnDeleted;
237 }
238
239 //------------------------------------------------------------------------------------------------
241 {
243 return;
244
246 return;
247
249
250 if (!m_NotificationsLog.GetEditorManager().IsOpened())
251 return;
252
253 bool isLimited = m_NotificationsLog.GetEditorManager().IsLimited();
254
255 //Keyboard and mouse
256 if (!isLimited && m_NotificationsLog.GetIsUsingMouseAndKeyboard())
257 {
258 m_GoToControlHint.SetVisible(false);
259 m_GoToIndicator.SetVisible(true);
260 m_GoToIndicatorsHolder.SetVisible(true);
261 }
262 //Using gamepad
263 else
264 {
265 m_GoToIndicatorsHolder.SetVisible(false);
266 }
267 }
268
269 //------------------------------------------------------------------------------------------------
270 protected void EditorOpened()
271 {
272 bool limited = m_NotificationsLog.GetEditorManager().IsLimited();
273
275 {
277 {
278 m_GoToIndicator.SetVisible(m_NotificationsLog.GetIsUsingMouseAndKeyboard() && !limited);
279 m_GoToIndicatorsHolder.SetVisible(m_NotificationsLog.GetIsUsingMouseAndKeyboard() && !limited);
280 }
281
282 }
283 else
284 {
286 {
287 m_GoToControlHint.SetVisible(!limited);
288 m_GoToIndicatorsHolder.SetVisible(!limited);
289 }
290
291 }
292
293 if (m_wRoot)
294 m_wRoot.SetEnabled(!limited);
295 }
296
297 //------------------------------------------------------------------------------------------------
298 protected void EditorClosed()
299 {
301 m_GoToIndicatorsHolder.SetVisible(false);
302
303 if (m_wRoot)
304 m_wRoot.SetEnabled(false);
305 }
306
307 //------------------------------------------------------------------------------------------------
308 protected void OnLimitedChanged(bool limited)
309 {
310 EditorOpened();
311 }
312
313 //------------------------------------------------------------------------------------------------
314 protected void OnInputDeviceChanged(bool isUsingMouseAndKeyboard)
315 {
316 bool limited = m_NotificationsLog.GetEditorManager().IsLimited();
317
318 if (!m_bHasPosition || !m_NotificationsLog.GetEditorManager().IsOpened() || limited)
319 return;
320
321 if (m_GoToIndicator)
322 m_GoToIndicator.SetVisible(isUsingMouseAndKeyboard && !m_bShowTeleportControlHint);
323
325 m_GoToIndicatorsHolder.SetVisible(isUsingMouseAndKeyboard || m_bShowTeleportControlHint)
326 }
327
328 //------------------------------------------------------------------------------------------------
329 protected void TeleportToLocation()
330 {
331 if (!m_NotificationsLog.HasNotificationInput() || !m_Data)
332 return;
333
334 bool limited = m_NotificationsLog.GetEditorManager().IsLimited();
335 if (limited)
336 return;
337
339 if (m_Data.GetDisplayData().GetPosition(m_Data, position))
340 {
342 if (!camera)
343 return;
344
346 if (!cursorManualCameraComponent)
347 return;
348
349 cursorManualCameraComponent.TeleportCamera(position);
350 }
351 }
352
353 //------------------------------------------------------------------------------------------------
354 protected void FadeDelete(float fadeSpeed)
355 {
356 AnimateWidget.Opacity(m_wRoot, 0, fadeSpeed);
357
359 {
361 GetGame().GetCallqueue().CallLater(AnimationDoneListenerUpdate, ANIMATION_DONE_UPDATE_SPEED, true);
362 }
363 }
364
365 //------------------------------------------------------------------------------------------------
371
372 //------------------------------------------------------------------------------------------------
375 {
376 if (m_wRoot)
377 m_wRoot.RemoveFromHierarchy();
378 }
379
380 //------------------------------------------------------------------------------------------------
381 protected void AutoFadeDelay()
382 {
384 return;
385
387 }
388
389 //------------------------------------------------------------------------------------------------
390 override void HandlerAttached(Widget w)
391 {
392 if (SCR_Global.IsEditMode())
393 return;
394
395 m_wRoot = w;
396
397 m_GoToIndicator = w.FindAnyWidget(m_sGoToIndicator);
398 m_GoToControlHint = w.FindAnyWidget(m_sGoToControlHint);
399
402 m_GoToIndicatorsHolder.SetVisible(false);
403
404 ScriptInvoker teleportButton = ButtonActionComponent.GetOnAction(m_wRoot, false);
405 if (teleportButton)
406 teleportButton.Insert(TeleportToLocation);
407 }
408
409 //------------------------------------------------------------------------------------------------
410 override void HandlerDeattached(Widget w)
411 {
412 if (SCR_Global.IsEditMode())
413 return;
414
415 Event_OnDeleted.Invoke(this);
416
417 if (!m_Data)
418 return;
419
420 if (m_bHasPosition && m_NotificationsLog && m_NotificationsLog.GetEditorManager())
421 {
422 m_NotificationsLog.GetEditorManager().GetOnOpened().Remove(EditorOpened);
423 m_NotificationsLog.GetEditorManager().GetOnClosed().Remove(EditorClosed);
424 m_NotificationsLog.GetEditorManager().GetOnLimitedChange().Remove(OnLimitedChanged);
425 m_NotificationsLog.GetOnNewMessageHasPosition().Remove(OnNewNotificationHasPosition);
426 //m_NotificationsLog.GetNotificationManager().GetOnNotification().Remove(OnNotification);
427 m_NotificationsLog.GetOnInputDeviceChanged().Remove(OnInputDeviceChanged);
428 }
429
431 GetGame().GetCallqueue().Remove(AnimationDoneListenerUpdate);
432 }
433
434 //------------------------------------------------------------------------------------------------
437 {
438 return m_Data;
439 }
440}
ENotification
ENotificationColor
ENotificationReceiver
ArmaReforgerScripted GetGame()
Definition game.c:1398
vector position
void SCR_EditorManagerEntity(IEntitySource src, IEntity parent)
Get all prefabs that have the spawner data
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
static WidgetAnimationOpacity Opacity(Widget widget, float targetValue, float speed, bool toggleVisibility=false)
static bool IsAnimating(Widget w)
Component to execute action when the button or its shortcut is pressed.
Definition Color.c:13
static SCR_ManualCamera GetCameraInstance()
static bool IsEditMode()
Definition Functions.c:1566
SCR_BaseManualCameraComponent FindCameraComponent(typename type)
bool GetPosition(SCR_NotificationData data, out vector position)
void GetDisplayVisualizationData(SCR_NotificationData data, out SCR_UINotificationInfo info=null, out ENotificationColor colorEnum=ENotificationColor.NEUTRAL)
ENotificationColor GetTextColor(SCR_NotificationData data)
void ForceRemoveNotification()
Delete the notification with a fast fade.
void Init(SCR_NotificationData data, SCR_NotificationsLogComponent notificationLog, float fadeDelay)
void OnInputDeviceChanged(bool isUsingMouseAndKeyboard)
SCR_NotificationsComponent GetNotificationManager()
Color GetNotificationTextColor(ENotificationColor notificationColor)
Teleport the camera to the cursor's world position.
UIInfo used by the Notifications system.
SCR_FieldOfViewSettings Attribute
T4 param4
Definition tuple.c:152
T3 param3
Definition tuple.c:93
T2 param2
Definition tuple.c:92
Tuple param1
T5 param5
Definition tuple.c:153
ScriptInvokerBase< func > ScriptInvoker
Definition tools.c:134