public async Task SendChatToServer(string chat, string targetCharacter) { var chatType = _chatTypeCalculator.CalculateChatType(chat); if (chatType == ChatType.Command) { if (HandleCommand(chat)) { return; } //treat unhandled command as local chat chatType = ChatType.Local; } if (chatType == ChatType.PM) { if (string.IsNullOrEmpty(_chatRepository.PMTarget1)) { _chatRepository.PMTarget1 = targetCharacter; } else if (string.IsNullOrEmpty(_chatRepository.PMTarget2)) { _chatRepository.PMTarget2 = targetCharacter; } } chat = _chatProcessor.RemoveFirstCharacterIfNeeded(chat, chatType, targetCharacter); var chatPacket = _chatPacketBuilder.BuildChatPacket(chatType, chat, targetCharacter); await _packetSendService.SendPacketAsync(chatPacket); AddChatForLocalDisplay(chatType, chat, targetCharacter); }
public string GetTargetCharacter(string localTypedText) { //todo: error status bar message if there is no text following a character name if (_chatTypeCalculator.CalculateChatType(localTypedText) != ChatType.PM) { return(""); } if (CurrentTab == ChatTab.Private1) { return(_chatProvider.PMTarget1); } if (CurrentTab == ChatTab.Private2) { return(_chatProvider.PMTarget2); } var characterArray = localTypedText.Skip(1) .TakeWhile(x => x != ' ') .ToArray(); var characterName = new string(characterArray); ChatPanel.TryStartNewPrivateChat(characterName); return(characterName); }
public void ShowChatBubbleForMainCharacter(string input) { //todo: don't show chat bubble if group chat and character is not in a group (party) var chatType = _chatTypeCalculator.CalculateChatType(input); if (chatType != ChatType.Local && chatType != ChatType.Party && chatType != ChatType.Announce) { return; } var text = _chatProcessor.RemoveFirstCharacterIfNeeded(input, chatType, string.Empty); if (_chatBubbleRepository.MainCharacterChatBubble.HasValue) { _chatBubbleRepository.MainCharacterChatBubble.Value.SetMessage(text, chatType == ChatType.Party); } else { var chatBubble = new ChatBubble(text, _characterRendererProvider.MainCharacterRenderer, _chatBubbleTextureProvider); _chatBubbleRepository.MainCharacterChatBubble = chatBubble; } }