Пример #1
0
        public void AddNotificationWrapper(TextNotification notification)
        {
            if (!IsNotificationEligible(notification))
            {
                return;
            }

            var lineToDisplay = notification;

            if (displayWidget.Children.Count > 0 && notification.CanIncrementOnDuplicate() && notification == lastLine)
            {
                repetitions++;
                lineToDisplay = new TextNotification(
                    notification.Pool,
                    notification.Prefix,
                    $"{notification.Text} ({repetitions + 1})",
                    notification.PrefixColor,
                    notification.TextColor);

                displayWidget.RemoveMostRecentNotification();
            }
            else
            {
                repetitions = 0;
            }

            lastLine = notification;

            AddNotification(lineToDisplay);
        }
Пример #2
0
        public void AddNotification(TextNotification notification)
        {
            var notificationWidget = templates[notification.Pool].Clone();

            WidgetUtils.SetupTextNotification(notificationWidget, notification, Bounds.Width, false);

            if (Children.Count == 0)
            {
                notificationWidget.Bounds.Y = Bounds.Bottom - notificationWidget.Bounds.Height - BottomSpacing;
            }
            else
            {
                foreach (var line in Children)
                {
                    line.Bounds.Y -= notificationWidget.Bounds.Height + ItemSpacing;
                }

                var lastLine = Children[Children.Count - 1];
                notificationWidget.Bounds.Y = lastLine.Bounds.Bottom + ItemSpacing;
            }

            AddChild(notificationWidget);
            expirations.Add(Game.LocalTick + RemoveTime);

            while (Children.Count > LogLength)
            {
                RemoveNotification();
            }
        }
Пример #3
0
        public void AddChatLineWrapper(TextNotification chatLine)
        {
            var chatLineToDisplay = chatLine;

            if (chatLine.CanIncrementOnDuplicate() && chatLine.Equals(lastLine))
            {
                repetitions++;
                chatLineToDisplay = new TextNotification(
                    chatLine.Pool,
                    chatLine.Prefix,
                    $"{chatLine.Text} ({repetitions + 1})",
                    chatLine.PrefixColor,
                    chatLine.TextColor);

                chatScrollPanel.RemoveChild(chatScrollPanel.Children[chatScrollPanel.Children.Count - 1]);
                chatOverlayDisplay?.RemoveMostRecentLine();
            }
            else
            {
                repetitions = 0;
            }

            lastLine = chatLine;

            chatOverlayDisplay?.AddLine(chatLineToDisplay);

            // HACK: Force disable the chat notification sound for the in-menu chat dialog
            // This works around our inability to disable the sounds for the in-game dialog when it is hidden
            AddChatLine(chatLineToDisplay, chatOverlay == null);
        }
Пример #4
0
        public static void SetupChatLine(ContainerWidget template, DateTime time, TextNotification chatLine)
        {
            var nameLabel = template.Get <LabelWidget>("NAME");
            var timeLabel = template.Get <LabelWidget>("TIME");
            var textLabel = template.Get <LabelWidget>("TEXT");

            var nameText = chatLine.Prefix + ":";
            var font     = Game.Renderer.Fonts[nameLabel.Font];
            var nameSize = font.Measure(nameText);

            timeLabel.GetText = () => $"{time.Hour:D2}:{time.Minute:D2}";

            nameLabel.GetColor     = () => chatLine.PrefixColor;
            nameLabel.GetText      = () => nameText;
            nameLabel.Bounds.Width = nameSize.X;

            textLabel.GetColor      = () => chatLine.TextColor;
            textLabel.Bounds.X     += nameSize.X;
            textLabel.Bounds.Width -= nameSize.X;

            // Hack around our hacky wordwrap behavior: need to resize the widget to fit the text
            var text = WidgetUtils.WrapText(chatLine.Text, textLabel.Bounds.Width, font);

            textLabel.GetText = () => text;
            var dh = font.Measure(text).Y - textLabel.Bounds.Height;

            if (dh > 0)
            {
                textLabel.Bounds.Height += dh;
                template.Bounds.Height  += dh;
            }
        }
Пример #5
0
    void SpawnNotification(string _text, Color _color)
    {
        GameObject       clone = Instantiate(notifcation_prefab, notification_spawn, Quaternion.identity);
        TextNotification note  = clone.GetComponent <TextNotification>();

        note.Init(transform.position + notification_spawn, notification_speed, notification_duration);
        note.SetNotificationText(_text, _color);
    }
Пример #6
0
        void AddNotification(TextNotification notification, bool suppressSound = false)
        {
            displayWidget.AddNotification(notification);

            if (!suppressSound && !string.IsNullOrEmpty(transientLineSound))
            {
                Game.Sound.PlayNotification(modRules, null, "Sounds", transientLineSound, null);
            }
        }
Пример #7
0
        public void AddNotificationWrapper(TextNotification notification)
        {
            if (!IsNotificationEligible(notification))
            {
                return;
            }

            chatOverlayDisplay?.AddNotification(notification);

            // HACK: Force disable the chat notification sound for the in-menu chat dialog
            // This works around our inability to disable the sounds for the in-game dialog when it is hidden
            AddNotification(notification, chatOverlay == null);
        }
Пример #8
0
        void AddChatLine(TextNotification chatLine, bool suppressSound)
        {
            var template  = chatTemplate.Clone();
            var nameLabel = template.Get <LabelWidget>("NAME");
            var textLabel = template.Get <LabelWidget>("TEXT");

            var name = "";

            if (!string.IsNullOrEmpty(chatLine.Prefix))
            {
                name = chatLine.Prefix + ":";
            }

            var font     = Game.Renderer.Fonts[nameLabel.Font];
            var nameSize = font.Measure(chatLine.Prefix);

            nameLabel.GetColor     = () => chatLine.PrefixColor;
            nameLabel.GetText      = () => name;
            nameLabel.Bounds.Width = nameSize.X;

            textLabel.GetColor      = () => chatLine.TextColor;
            textLabel.Bounds.X     += nameSize.X;
            textLabel.Bounds.Width -= nameSize.X;

            // Hack around our hacky wordwrap behavior: need to resize the widget to fit the text
            var text = WidgetUtils.WrapText(chatLine.Text, textLabel.Bounds.Width, font);

            textLabel.GetText = () => text;
            var dh = font.Measure(text).Y - textLabel.Bounds.Height;

            if (dh > 0)
            {
                textLabel.Bounds.Height += dh;
                template.Bounds.Height  += dh;
            }

            var scrolledToBottom = chatScrollPanel.ScrolledToBottom;

            chatScrollPanel.AddChild(template);
            if (scrolledToBottom)
            {
                chatScrollPanel.ScrollToBottom(smooth: true);
            }

            if (!suppressSound)
            {
                Game.Sound.PlayNotification(modRules, null, "Sounds", chatLineSound, null);
            }
        }
Пример #9
0
        public void AddLine(TextNotification chatLine)
        {
            recentLines.Add(chatLine);
            lineExpirations.Add(Game.LocalTick + RemoveTime);

            if (Notification != null)
            {
                Game.Sound.Play(SoundType.UI, Notification);
            }

            while (recentLines.Count > LogLength)
            {
                RemoveLine();
            }
        }
Пример #10
0
        void AddNotification(TextNotification notification, bool suppressSound)
        {
            var chatLine = templates[notification.Pool].Clone();

            WidgetUtils.SetupTextNotification(chatLine, notification, chatScrollPanel.Bounds.Width - chatScrollPanel.ScrollbarWidth, isMenuChat && !world.IsReplay);

            var scrolledToBottom = chatScrollPanel.ScrolledToBottom;

            chatScrollPanel.AddChild(chatLine);
            if (scrolledToBottom)
            {
                chatScrollPanel.ScrollToBottom(smooth: true);
            }

            if (!suppressSound)
            {
                Game.Sound.PlayNotification(modRules, null, "Sounds", chatLineSound, null);
            }
        }
Пример #11
0
 static bool IsNotificationEligible(TextNotification notification)
 {
     return(notification.Pool == TextNotificationPool.Transients || notification.Pool == TextNotificationPool.Feedback);
 }
Пример #12
0
 void CacheTextNotification(TextNotification notification)
 {
     notificationsCache.Add(notification);
 }
Пример #13
0
 static bool IsNotificationEligible(TextNotification notification)
 {
     return(notification.Pool == TextNotificationPool.Chat ||
            notification.Pool == TextNotificationPool.System ||
            notification.Pool == TextNotificationPool.Mission);
 }