private Color GetChannelColor(BroadcastMessageData data) { if (IsFromSystem(data)) { return(UiCommonColor.SystemMessageColor); } var channel = ChatTypeToChannel((ChatType)data.ChatType); return(UiCommonColor.GetChatColorByChatChannel(channel)); }
private void UpdateChannel() { _viewModel.ChannelTipText = GetChannelChannelTip(_curChannel); _viewModel.ChannelTipColor = UiCommonColor.GetChatColorByChatChannel(_curChannel); if (inputField == null || inputField.textComponent == null) { Logger.Error("can't found text in inputfield"); return; } inputField.textComponent.color = _curChannel == ChatChannel.PrivateChat ? UiCommonColor.GetChatColorByChatChannel(ChatChannel.PrivateChat) : Color.white; }
public void AddMessage(BroadcastMessageData data) { var tf = GetNewMessageItem(); var channelColor = GetChannelColor(data); var channelName = GetChannelNamePrefix(data, channelColor); var messageText = string.Empty; var textComponent = tf.GetComponent <Text>(); var channelRoot = textComponent.transform.GetChild(0); var channelTextComponent = channelRoot != null?channelRoot.GetComponent <Text>() : null; if (tf != null && data != null && data.ChatMessage != null) { if (TargetIdDict != null) { if (!TargetIdDict.ContainsKey(data.SendRoleId)) { TargetIdDict[data.SendRoleId] = string.Empty; } TargetIdDict[data.SendRoleId] = data.SendRoleName; } if (IsFromSystem(data)) { var color = ColorUtility.ToHtmlStringRGB(UiCommonColor.SystemMessageColor); messageText = string.Format(commonMessageWithColorFormat, color, data.ChatMessage.Message); } else if (data.ChatType == (int)ChatType.PrivateChat) { var color = ColorUtility.ToHtmlStringRGB( UiCommonColor.GetChatColorByChatChannel(ChatChannel.PrivateChat)); messageText = string.Format(commonMessageWithColorFormat, color, messageText); long privateChatId = 0; if (data.SendRoleId == _chatState.MyselfId) { privateChatId = data.TargetId; messageText = string.Format(ScriptLocalization.hall_chat.word231, TargetIdDict[privateChatId]) + data.ChatMessage.Message; } else { privateChatId = data.SendRoleId; var name = string.Format(ScriptLocalization.hall_chat.PlayerNameFormat, data.SendRoleName); messageText = name + data.ChatMessage.Message; } PrivateChatRecentUseQueueUpdate(privateChatId); messageText = string.Format(commonMessageWithColorFormat, color, messageText); if (ChatListState != EUIChatListState.Send) { _curChannel = ChatChannel.PrivateChat; SetPrivateTarget(privateChatId); UpdateChannel(); } } else { var color = ColorUtility.ToHtmlStringRGB(UiCommonColor.ChatSenderColor); var name = string.Format(ScriptLocalization.hall_chat.PlayerNameFormat, data.SendRoleName); messageText = string.Format(commonMessageWithColorFormat, color, name) + data.ChatMessage.Message; } if (channelTextComponent != null) { channelTextComponent.text = channelName; } textComponent.text = messageText; } else { Logger.Error("Null object,can't addMessage"); } if (ChatListState == EUIChatListState.None) { ChatListState = EUIChatListState.Receive; } ResetTime(); //_closeViewAnim.Rewind(); }