4 protected string m_sIcon;
6 [
Attribute(
desc:
"Widgets that are colored by the Notification Color")]
7 protected ref array<string> m_aColoredWidgets;
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;
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;
16 protected string m_sNotificationText;
19 protected string m_sGoToIndicator;
22 protected string m_sGoToControlHint;
25 protected string m_sGoToIndicatorsHolder;
28 protected Widget m_wRoot;
31 protected Widget m_GoToControlHint;
32 protected Widget m_GoToIndicator;
33 protected Widget m_GoToIndicatorsHolder;
35 protected ref ScriptInvoker Event_OnDeleted =
new ScriptInvoker();
38 protected bool m_bIsListeningToDoneFade;
39 protected bool m_bHasPosition;
40 protected bool m_bShowTeleportControlHint;
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;
62 SCR_NotificationsComponent notificationManager = notificationLog.GetNotificationManager();
66 m_NotificationsLog = notificationLog;
68 TextWidget notificationText = TextWidget.Cast(
m_wRoot.FindAnyWidget(m_sNotificationText));
69 if (!notificationText)
72 string notificationMessage =
data.GetText();
73 string param1, param2, param3, param4, param5, param6;
75 if (notificationMessage !=
string.Empty)
76 data.GetNotificationTextEntries(param1, param2, param3, param4, param5, param6);
80 if (!displayData.MergeParam1With2())
82 notificationText.SetTextFormat(notificationMessage, param1, param2, param3, param4, param5, param6);
86 string mergeParams = WidgetManager.Translate(param2, param1);
87 notificationText.SetTextFormat(notificationMessage, param1, mergeParams, param3, param4, param5, param6);
92 displayData.GetDisplayVisualizationData(
data, uiInfo, notificationColorEnum);
96 ImageWidget icon = ImageWidget.Cast(
m_wRoot.FindAnyWidget(
m_sIcon));
100 uiInfo.SetIconTo(icon);
102 icon.SetVisible(
false);
105 SetWidgetColor(m_NotificationsLog.GetNotificationWidgetColor(notificationColorEnum));
111 Widget elementWidget;
113 foreach (
string element: m_aNonGameMasterWidgets)
115 elementWidget =
m_wRoot.FindAnyWidget(element);
118 elementWidget.SetVisible(
false);
121 foreach (
string element: m_aGameMasterOnlyWidgets)
123 elementWidget =
m_wRoot.FindAnyWidget(element);
126 elementWidget.SetVisible(
true);
132 if (coloredTextNotificationUIInfo)
134 Color textColor = notificationLog.GetNotificationTextColor(displayData.GetTextColor(
data));
135 textColor.SetA(notificationText.GetColor().A());
136 notificationText.SetColor(textColor);
141 if (m_NotificationsLog.HasNotificationInput() && displayData.GetPosition(
data,
position))
143 m_NotificationsLog.GetEditorManager().GetOnOpened().Insert(EditorOpened);
144 m_NotificationsLog.GetEditorManager().GetOnClosed().Insert(EditorClosed);
145 m_NotificationsLog.GetEditorManager().GetOnLimitedChange().Insert(OnLimitedChanged);
147 m_bHasPosition =
true;
148 m_bShowTeleportControlHint =
true;
151 m_NotificationsLog.GetOnNewMessageHasPosition().Insert(OnNewNotificationHasPosition);
152 m_NotificationsLog.GetOnInputDeviceChanged().Insert(OnInputDeviceChanged);
154 if (!editorManager.IsOpened())
165 GetGame().GetCallqueue().CallLater(AutoFadeDelay, fadeDelay);
168 AnimateWidget.Opacity(
m_wRoot, 1, FADE_IN_SPEED);
174 protected void SetWidgetColor(Color notificationColor)
176 if (!m_aColoredWidgets || m_aColoredWidgets.IsEmpty())
181 foreach (
string widgetName: m_aColoredWidgets)
183 Widget widget =
m_wRoot.FindAnyWidget(widgetName);
186 color = Color.FromInt(notificationColor.PackToInt());
187 color.SetA(widget.GetColor().A());
188 widget.SetColor(notificationColor);
202 void ForceRemoveNotification()
204 FadeDelete(FORCE_DELETE_FADE_SPEED);
210 ScriptInvoker GetOnDeleted()
212 return Event_OnDeleted;
216 protected void OnNewNotificationHasPosition()
218 if (!m_GoToControlHint || !m_GoToIndicator || !m_GoToIndicatorsHolder)
221 if (!m_bShowTeleportControlHint)
224 m_bShowTeleportControlHint =
false;
226 if (!m_NotificationsLog.GetEditorManager().IsOpened())
229 bool isLimited = m_NotificationsLog.GetEditorManager().IsLimited();
232 if (!isLimited && m_NotificationsLog.GetIsUsingMouseAndKeyboard())
234 m_GoToControlHint.SetVisible(
false);
235 m_GoToIndicator.SetVisible(
true);
236 m_GoToIndicatorsHolder.SetVisible(
true);
241 m_GoToIndicatorsHolder.SetVisible(
false);
246 protected void EditorOpened()
248 bool limited = m_NotificationsLog.GetEditorManager().IsLimited();
250 if (!m_bShowTeleportControlHint)
252 if (m_GoToIndicator && m_GoToIndicatorsHolder)
254 m_GoToIndicator.SetVisible(m_NotificationsLog.GetIsUsingMouseAndKeyboard() && !limited);
255 m_GoToIndicatorsHolder.SetVisible(m_NotificationsLog.GetIsUsingMouseAndKeyboard() && !limited);
261 if (m_GoToControlHint && m_GoToIndicatorsHolder)
263 m_GoToControlHint.SetVisible(!limited);
264 m_GoToIndicatorsHolder.SetVisible(!limited);
274 protected void EditorClosed()
276 if (m_GoToControlHint)
277 m_GoToIndicatorsHolder.SetVisible(
false);
284 protected void OnLimitedChanged(
bool limited)
290 protected void OnInputDeviceChanged(
bool isUsingMouseAndKeyboard)
292 bool limited = m_NotificationsLog.GetEditorManager().IsLimited();
294 if (!m_bHasPosition || !m_NotificationsLog.GetEditorManager().IsOpened() || limited)
298 m_GoToIndicator.SetVisible(isUsingMouseAndKeyboard && !m_bShowTeleportControlHint);
300 if (m_GoToIndicatorsHolder)
301 m_GoToIndicatorsHolder.SetVisible(isUsingMouseAndKeyboard || m_bShowTeleportControlHint)
305 protected void TeleportToLocation()
307 if (!m_NotificationsLog.HasNotificationInput() || !m_Data)
310 bool limited = m_NotificationsLog.GetEditorManager().IsLimited();
315 if (m_Data.GetDisplayData().GetPosition(m_Data,
position))
322 if (!cursorManualCameraComponent)
325 cursorManualCameraComponent.TeleportCamera(
position);
330 protected void FadeDelete(
float fadeSpeed)
332 AnimateWidget.Opacity(
m_wRoot, 0, fadeSpeed);
334 if (!m_bIsListeningToDoneFade)
336 m_bIsListeningToDoneFade =
true;
337 GetGame().GetCallqueue().CallLater(AnimationDoneListenerUpdate, ANIMATION_DONE_UPDATE_SPEED,
true);
342 protected void AnimationDoneListenerUpdate()
344 if (!AnimateWidget.IsAnimating(
m_wRoot))
345 DeleteNotification();
350 void DeleteNotification()
357 protected void AutoFadeDelay()
359 if (m_bIsListeningToDoneFade)
362 FadeDelete(AUTO_FADE_SPEED);
366 override void HandlerAttached(Widget w)
373 m_GoToIndicator = w.FindAnyWidget(m_sGoToIndicator);
374 m_GoToControlHint = w.FindAnyWidget(m_sGoToControlHint);
376 m_GoToIndicatorsHolder =
m_wRoot.FindAnyWidget(m_sGoToIndicatorsHolder);
377 if (m_GoToIndicatorsHolder)
378 m_GoToIndicatorsHolder.SetVisible(
false);
382 teleportButton.Insert(TeleportToLocation);
386 override void HandlerDeattached(Widget w)
391 Event_OnDeleted.Invoke(
this);
396 if (m_bHasPosition && m_NotificationsLog && m_NotificationsLog.GetEditorManager())
398 m_NotificationsLog.GetEditorManager().GetOnOpened().Remove(EditorOpened);
399 m_NotificationsLog.GetEditorManager().GetOnClosed().Remove(EditorClosed);
400 m_NotificationsLog.GetEditorManager().GetOnLimitedChange().Remove(OnLimitedChanged);
401 m_NotificationsLog.GetOnNewMessageHasPosition().Remove(OnNewNotificationHasPosition);
403 m_NotificationsLog.GetOnInputDeviceChanged().Remove(OnInputDeviceChanged);
406 if (m_bIsListeningToDoneFade)
407 GetGame().GetCallqueue().Remove(AnimationDoneListenerUpdate);