8 [
Attribute(
"0",
desc:
"If false notifications can never be clicked on and do not have any key hints or teleport icons. This is used if the notifications are part of a menu")]
9 protected bool m_bHasNotificationInput;
11 [
Attribute(
"5",
desc:
"How many notifications will be displayed (not counting sticky notifications that do not effect the normal notifications) Can never be higher then SCR_NotificationsComponent.NOTIFICATION_HISTORY_LENGTH")]
12 protected int m_iMaxNotifications;
14 [
Attribute(
"15",
desc:
"Notification display time in seconds. This can be diffrent for each notification log. Can never be higher then SCR_NotificationsComponent.NOTIFICATION_DELETE_TIME")]
15 protected float m_fNotificationDisplayTime;
18 protected string m_sNotificationHolderName;
21 protected string m_sPriorityNotificationHolderName;
23 [
Attribute(
"2",
desc:
"Size of priority Notification (Default: Priority Notification has the size of 2 normal Notifications")]
24 protected int m_iPriorityNotificationSize;
27 protected string m_sNotificationHolderParent;
29 [
Attribute(
"{8ADB878F8DD9BD53}UI/layouts/HUD/Notifications/Notifications_Message.layout")]
30 protected ResourceName m_sNotificationEntityPrefab;
32 [
Attribute(
"{8904986114C6F944}UI/layouts/HUD/Notifications/Notifications_Message_Split.layout")]
33 protected ResourceName m_sSplitNotificationEntityPrefab;
35 protected SCR_NotificationsComponent m_NotificationsManager;
38 protected VerticalLayoutWidget m_wNotificationHolder;
39 protected VerticalLayoutWidget m_wPriorityNotificationHolder;
40 protected VerticalLayoutWidget m_wNotificationHolderParent;
43 protected Widget m_wRoot;
44 protected int m_iCurrentMaxNotifications;
45 protected int m_iCurrentPriorityNotifications;
48 protected bool m_bIsUsingMouseAndKeyboard =
true;
50 protected ref ScriptInvoker m_OnNewMessageHasPosition =
new ScriptInvoker();
51 protected ref ScriptInvoker m_OnInputDeviceChanged =
new ScriptInvoker();
53 protected ref array<ref SCR_NotificationMessageUIComponent> m_aNotificationMessages = {};
54 protected ref array<ref SCR_NotificationMessageUIComponent> m_aPriorityNotificationMessages = {};
56 protected ref map<ENotificationColor, SCR_NotificationDisplayColor> m_NotificationDisplayColorMap =
new map<ENotificationColor, SCR_NotificationDisplayColor>();
67 if (displayTimeLeft <= 0)
76 Widget newNotification;
86 WorkspaceWidget workspaceWidget =
GetGame().GetWorkspace();
88 if (displayData.GetPriority())
89 newNotification = workspaceWidget.CreateWidgets(m_sNotificationEntityPrefab, m_wPriorityNotificationHolder);
90 else if (!splituiInfo)
91 newNotification = workspaceWidget.CreateWidgets(m_sNotificationEntityPrefab, m_wNotificationHolder);
93 newNotification = workspaceWidget.CreateWidgets(m_sSplitNotificationEntityPrefab, m_wNotificationHolder);
99 if (!notificationMessage)
100 newNotification.RemoveFromHierarchy();
102 if (displayData.GetPriority())
105 OnPriorityNotificationChange(
true);
112 notificationMessage.GetOnDeleted().Insert(OnNotificationDeleted);
114 notificationMessage.Init(
data,
this, displayTimeLeft * 1000);
118 RemoveOldestNotification();
126 ScriptInvoker GetOnNewMessageHasPosition()
134 ScriptInvoker GetOnInputDeviceChanged()
148 if (priorityIndex >= 0)
150 OnPriorityNotificationChange(
false);
156 protected void RemoveOldestNotification()
164 if (m_PrevOverFlowNotification)
176 protected void OnInputDeviceIsGamepad(
bool isGamepad)
185 bool GetIsUsingMouseAndKeyboard()
199 SCR_NotificationsComponent GetNotificationManager()
214 Print(
"Notification color '" +
typename.EnumToString(
ENotificationColor, notificationColor) +
"' has no color assigned to it in 'SCR_NotificationsLogComponent'", LogLevel.WARNING);
229 Print(
"Notification color '" +
typename.EnumToString(
ENotificationColor, notificationColor) +
"' has no color assigned to it in 'SCR_NotificationsLogComponent'", LogLevel.WARNING);
236 bool HasNotificationInput()
242 protected void GenerateNotificationColorMap()
244 array<ref SCR_NotificationDisplayColor> m_aNotificationDisplayColor =
m_NotificationsManager.GetNotificationDisplayColor();
246 for (
int i = 0, count = m_aNotificationDisplayColor.Count(); i < count; i++)
251 Print(
"Notification Color in 'SCR_NotificationsLogComponent' has duplicate notification color key: '" +
typename.EnumToString(
ENotificationColor, m_aNotificationDisplayColor[i].m_NotificationColor) +
"'. There should only be one of each key!", LogLevel.WARNING);
258 protected void OnStickyNotificationChanged(
bool newActive)
265 RemoveOldestNotification();
274 protected void OnPriorityNotificationChange(
bool newActive)
279 Math.Clamp(m_iCurrentMaxNotifications, 0, m_iMaxNotifications);
281 RemoveOldestNotification();
290 override void HandlerAttachedScripted(Widget w)
298 if (m_iMaxNotifications > SCR_NotificationsComponent.NOTIFICATION_HISTORY_LENGTH)
300 Print(
"Max display Notification in notification log is higher than total notification history in notification component and thus are set the same", LogLevel.ERROR);
307 if (!m_NotificationsManager)
309 Print(
"SCR_NotificationsLogDisplay requires SCR_NotificationsComponent on PlayerController!", LogLevel.WARNING);
317 if (!m_wNotificationHolder || !m_wNotificationHolderParent)
321 FrameSlot.SetAlignment(m_wNotificationHolderParent, 1, 1);
323 FrameSlot.SetAnchorMin(m_wNotificationHolderParent, 1, 1);
325 FrameSlot.SetAnchorMax(m_wNotificationHolderParent, 1, 1);
327 if (m_fNotificationDisplayTime > SCR_NotificationsComponent.NOTIFICATION_DELETE_TIME)
329 Print(
"Notification display time in notification log is higher than delete time in notification component and thus are set the same time", LogLevel.ERROR);
336 GetGame().OnInputDeviceIsGamepadInvoker().Insert(OnInputDeviceIsGamepad);
338 EInputDeviceType inputDevice =
GetGame().GetInputManager().GetLastUsedInputDevice();
343 GenerateNotificationColorMap();
345 Widget stickyNotificationWidget;
350 stickyNotificationWidget = w.FindAnyWidget(notificationWidget);
351 if (!stickyNotificationWidget)
353 Print(
"NotificationsLog could not find stickNotification: " + notificationWidget, LogLevel.NORMAL);
358 if (!stickyNotificationComponent)
360 Print(
"NotificationsLog could not find SCR_StickyNotificationUIComponent on: " + notificationWidget, LogLevel.NORMAL);
365 stickyNotificationComponent.OnInit(
this);
367 if (!stickyNotificationComponent.InfluenceNotificationListSize())
370 stickyNotificationComponent.GetOnStickyActiveChanged().Insert(OnStickyNotificationChanged);
372 if (stickyNotificationComponent.isStickyActive())
373 OnStickyNotificationChanged(
true);
376 array<SCR_NotificationData> notificationHistory = {};
380 for (
int i = 0; i < count; i++)
382 OnNotification(notificationHistory[i]);
387 override void HandlerDeattached(Widget w)
389 super.HandlerDeattached(w);
391 if (!m_NotificationsManager)
395 GetGame().OnInputDeviceIsGamepadInvoker().Remove(OnInputDeviceIsGamepad);
400 void OnSlotResize(
int maxNotifications)
405 Print(
"Max display Notification in notification log is higher than total notification history in notification component and thus are set the same", LogLevel.ERROR);
411 Math.Clamp(m_iCurrentMaxNotifications, 0, m_iMaxNotifications);
414 RemoveOldestNotification();
420 void ChangeInsertOrder(
bool fromTop)
422 if(!m_wNotificationHolder)
428 FrameSlot.SetAlignment(m_wNotificationHolderParent, 1, 0);
430 FrameSlot.SetAnchorMin(m_wNotificationHolderParent, 1, 0);
432 FrameSlot.SetAnchorMax(m_wNotificationHolderParent, 1, 0);
437 FrameSlot.SetAlignment(m_wNotificationHolderParent, 1, 1);
439 FrameSlot.SetAnchorMin(m_wNotificationHolderParent, 1, 1);
441 FrameSlot.SetAnchorMax(m_wNotificationHolderParent, 1, 1);
448 class SCR_NotificationDisplayColor
453 [
Attribute(defvalue:
"255,255,255,255",
desc:
"Color of images within the notification message")]
454 protected ref Color m_cWidgetNotificationColor;
456 [
Attribute(defvalue:
"255,255,255,255",
desc:
"Color of message text. Only relevant with Split notifications")]
457 protected ref Color m_TextNotificationColor;
461 Color GetWidgetColor()
463 return Color.FromInt(m_cWidgetNotificationColor.PackToInt());
470 return Color.FromInt(m_TextNotificationColor.PackToInt());