Exemple #1
0
        private void _onChatMessage(MsgChatMessage msg)
        {
            Logger.Debug($"{msg.Channel}: {msg.Message}");

            // Log all incoming chat to repopulate when filter is un-toggled
            var storedMessage = new StoredChatMessage(msg);

            filteredHistory.Add(storedMessage);
            WriteChatMessage(storedMessage);

            // Local messages that have an entity attached get a speech bubble.
            if (msg.SenderEntity == default)
            {
                return;
            }

            switch (msg.Channel)
            {
            case ChatChannel.Local:
            case ChatChannel.Dead:
                AddSpeechBubble(msg, SpeechBubble.SpeechType.Say);
                break;

            case ChatChannel.Emotes:
                AddSpeechBubble(msg, SpeechBubble.SpeechType.Emote);
                break;
            }
        }
Exemple #2
0
        private void _onChatMessage(MsgChatMessage message)
        {
            Logger.Debug($"{message.Channel}: {message.Message}");

            var color       = Color.DarkGray;
            var messageText = message.Message;

            if (!string.IsNullOrEmpty(message.MessageWrap))
            {
                messageText = string.Format(message.MessageWrap, messageText);
            }

            switch (message.Channel)
            {
            case ChatChannel.Server:
                color = Color.Orange;
                break;

            case ChatChannel.OOC:
                color = Color.LightSkyBlue;
                break;
            }

            _currentChatBox?.AddLine(messageText, message.Channel, color);
        }
        private void SendServerMessage(string message)
        {
            var msg = new MsgChatMessage();

            msg.Channel = ChatChannel.Server;
            msg.Message = message;
            IoCManager.Resolve <IServerNetManager>().ServerSendToAll(msg);
        }
Exemple #4
0
        private void AddSpeechBubble(MsgChatMessage msg)
        {
            if (!_entityManager.TryGetEntity(msg.SenderEntity, out var entity))
            {
                Logger.WarningS("chat", "Got local chat message with invalid sender entity: {0}", msg.SenderEntity);
                return;
            }

            // Split message into words separated by spaces.
            var words         = msg.Message.Split(' ');
            var messages      = new List <string>();
            var currentBuffer = new List <string>();

            // Really shoddy way to approximate word length.
            // Yes, I am aware of all the crimes here.
            // TODO: Improve this to use actual glyph width etc..
            var currentWordLength = 0;

            foreach (var word in words)
            {
                // +1 for the space.
                currentWordLength += word.Length + 1;

                if (currentWordLength > SingleBubbleCharLimit)
                {
                    // Too long for the current speech bubble, flush it.
                    messages.Add(string.Join(" ", currentBuffer));
                    currentBuffer.Clear();

                    currentWordLength = word.Length;

                    if (currentWordLength > SingleBubbleCharLimit)
                    {
                        // Word is STILL too long.
                        // Truncate it with an ellipse.
                        messages.Add($"{word.Substring(0, SingleBubbleCharLimit - 3)}...");
                        currentWordLength = 0;
                        continue;
                    }
                }

                currentBuffer.Add(word);
            }

            if (currentBuffer.Count != 0)
            {
                // Don't forget the last bubble.
                messages.Add(string.Join(" ", currentBuffer));
            }

            foreach (var message in messages)
            {
                EnqueueSpeechBubble(entity, message);
            }
        }
Exemple #5
0
        private void AddSpeechBubble(MsgChatMessage msg, SpeechBubble.SpeechType speechType)
        {
            if (!_entityManager.TryGetEntity(msg.SenderEntity, out var entity))
            {
                Logger.WarningS("chat", "Got local chat message with invalid sender entity: {0}", msg.SenderEntity);
                return;
            }

            var messages = SplitMessage(msg.Message);

            foreach (var message in messages)
            {
                EnqueueSpeechBubble(entity, message, speechType);
            }
        }
Exemple #6
0
 /// <summary>
 /// Сообщения в чат
 /// </summary>
 /// <param name="source"></param>
 /// <param name="msg"></param>
 private void ChatMessageHandler(SBRemoteClient source, string msg)
 {
     lock (_syncRoot)
     {
         if (source.State == KnownClientState.InGame && this.State != GameState.Idle)
         {
             var pckt = new MsgChatMessage()
             {
                 Text = source.Name + " - " + msg
             };
             _a.Client.Send(pckt);
             _b.Client.Send(pckt);
         }
     }
 }
Exemple #7
0
        private void _onChatMessage(MsgChatMessage msg)
        {
            Logger.Debug($"{msg.Channel}: {msg.Message}");

            // Log all incoming chat to repopulate when filter is un-toggled
            var storedMessage = new StoredChatMessage(msg);

            filteredHistory.Add(storedMessage);
            WriteChatMessage(storedMessage);

            // Local messages that have an entity attached get a speech bubble.
            if ((msg.Channel == ChatChannel.Local || msg.Channel == ChatChannel.Dead) && msg.SenderEntity != default)
            {
                AddSpeechBubble(msg);
            }
        }
 private void Handle(MsgChatMessage pckt)
 {
     OnChatMessage(pckt.Text);
 }
 /// <summary>
 ///     Constructor to copy a net message into stored client variety
 /// </summary>
 public StoredChatMessage(MsgChatMessage netMsg)
 {
     Message     = netMsg.Message;
     Channel     = netMsg.Channel;
     MessageWrap = netMsg.MessageWrap;
 }