少年修仙传客户端代码仓库
client_linchunjie
2018-10-23 0995daff9bdb92383805373761206abca713aeb8
4298 【前端】【1.2】玩家发送的聊天消息(频道和个人聊天)增加日期和时间显示
5个文件已修改
120 ■■■■■ 已修改文件
System/Chat/ChatData.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Chat/ChatMineVoiceCell.cs 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Chat/ChatOtherVoiceCell.cs 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Chat/ChatPlayerMineCell.cs 58 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Chat/ChatPlayerOtherCell.cs 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Chat/ChatData.cs
@@ -3,6 +3,7 @@
using System.Text.RegularExpressions;
using UnityEngine;
using Snxxz.UI;
using System;
public class ChatData
{
@@ -15,6 +16,7 @@
        }
        richText = new StringBuilder();
        richText.Length = 0;
        createTime = DateTime.Now;
    }
    private string _content = string.Empty;
@@ -37,6 +39,8 @@
    public ChatInfoType type { get; protected set; }
    public DateTime createTime { get; private set; }
    private ChatInfoType m_DetailType = ChatInfoType.World;
    public ChatInfoType detailType
    {
System/Chat/ChatMineVoiceCell.cs
@@ -14,6 +14,7 @@
        [SerializeField] Image m_ChatBubble;
        [SerializeField] Text vipText;
        [SerializeField] Text playerNameText;
        [SerializeField] Text m_ChatTime;
        [SerializeField] Image m_ChatIcon;
        [SerializeField] ImageFitterText m_Fitter;
@@ -50,6 +51,7 @@
            m_ChatIcon.SetSprite(GeneralDefine.GetJobHeadPortrait(_data.job, 0));
            playerNameText.text = _data.name;
            m_ChatTime.text = _data.createTime.ToString("yyyy-MM-dd HH:mm");
            if (_data.vipLv > 0)
            {
                vipText.text = string.Format("V{0}", _data.vipLv);
System/Chat/ChatOtherVoiceCell.cs
@@ -14,6 +14,7 @@
        [SerializeField] Image m_ChatBubble;
        [SerializeField] Text vipText;
        [SerializeField] Text playerNameText;
        [SerializeField] Text m_ChatTime;
        [SerializeField] Image m_ChatIcon;
        [SerializeField] ImageFitterText m_Fitter;
        [SerializeField] Button m_ViewPlayer;
@@ -42,6 +43,7 @@
            m_Fitter.gameObject.SetActive(!string.IsNullOrEmpty(_data.content));
            m_ChatIcon.SetSprite(GeneralDefine.GetJobHeadPortrait(_data.job, 0));
            playerNameText.text = _data.name;
            m_ChatTime.text = _data.createTime.ToString("yyyy-MM-dd HH:mm");
            if (_data.vipLv > 0)
            {
                vipText.text = string.Format("V{0}", _data.vipLv);
System/Chat/ChatPlayerMineCell.cs
@@ -7,11 +7,13 @@
{
    public class ChatPlayerMineCell : ScrollerUI
    {
        [SerializeField] Image chatIcon;
        [SerializeField] Text vipText;
        [SerializeField] Text playerNameText;
        [SerializeField] RichText chatText;
        [SerializeField] Image m_ChatIcon;
        [SerializeField] Text m_VipLv;
        [SerializeField] Text m_PlayerName;
        [SerializeField] Text m_ChatTime;
        [SerializeField] RichText m_Chat;
        [SerializeField] ImageFitterText m_Fitter;
        [SerializeField] Button m_Func;
        ChatCenter m_ChatCenter;
        ChatCenter chatCenter
@@ -23,47 +25,50 @@
        }
        public override void Refresh(CellView cell)
        {
            ChatData _data = chatCenter.GetChatData(ChatCtrl.Inst.presentChatType, cell.index);
            if (_data == null)
            ChatData data = chatCenter.GetChatData(ChatCtrl.Inst.presentChatType, cell.index);
            if (data == null)
            {
                return;
            }
            }
            var chatUserData = data as ChatUeseData;
            #region 更新高度
            chatText.AutoNewLine = false;
            chatText.text = _data.content;
            m_Chat.AutoNewLine = false;
            m_Chat.text = data.content;
            if (type == ScrollerDataType.Header)
            {
                if (chatText.preferredWidth > chatText.rectTransform.rect.width)
                if (m_Chat.preferredWidth > m_Chat.rectTransform.rect.width)
                {
                    chatText.alignment = TextAnchor.UpperLeft;
                    m_Chat.alignment = TextAnchor.UpperLeft;
                }
                else
                {
                    chatText.alignment = TextAnchor.UpperRight;
                    m_Chat.alignment = TextAnchor.UpperRight;
                }
                m_Fitter.FiterRealTxtWidth = chatText.alignment == TextAnchor.UpperRight;
                m_Fitter.FiterRealTxtWidth = m_Chat.alignment == TextAnchor.UpperRight;
            }
            chatText.AutoNewLine = true;
            chatIcon.SetSprite(GeneralDefine.GetJobHeadPortrait((_data as ChatUeseData).job, 0));
            m_Chat.AutoNewLine = true;
            m_ChatIcon.SetSprite(GeneralDefine.GetJobHeadPortrait(chatUserData.job, 0));
            #endregion
            Button headBtn = chatIcon.GetComponent<Button>();
            headBtn.onClick.RemoveAllListeners();
            headBtn.onClick.AddListener(() =>
            m_Func.onClick.RemoveAllListeners();
            m_Func.onClick.AddListener(() =>
            {
                OnHeadIconClick(cell);
                OnFunc(cell);
            });
            playerNameText.text = (_data as ChatUeseData).name;
            if ((_data as ChatUeseData).vipLv > 0)
            m_PlayerName.text = chatUserData.name;
            m_ChatTime.text = data.createTime.ToString("yyyy-MM-dd HH:mm");
            if (chatUserData.vipLv > 0)
            {
                vipText.text = string.Format("V{0}", (_data as ChatUeseData).vipLv);
                m_VipLv.text = string.Format("V{0}", chatUserData.vipLv);
            }
            else
            {
                vipText.text = string.Empty;
                m_VipLv.text = string.Empty;
            }
        }
        private void OnHeadIconClick(CellView cell)
        private void OnFunc(CellView cell)
        {
            int index = cell.index;
            ChatData _data = chatCenter.GetChatData(ChatCtrl.Inst.presentChatType, index);
@@ -72,7 +77,10 @@
                return;
            }
            ChatUeseData user = _data as ChatUeseData;
            if (user.player == PlayerDatas.Instance.baseData.PlayerID) return;
            if (user.player == PlayerDatas.Instance.baseData.PlayerID)
            {
                return;
            }
            HrefAnalysis.Inst.ExcuteHrefEvent(string.Format("showplayer={0}", user.player));
        }
    }
System/Chat/ChatPlayerOtherCell.cs
@@ -8,11 +8,13 @@
public class ChatPlayerOtherCell : ScrollerUI
{
    [SerializeField] Image chatIcon;
    [SerializeField] Text vipText;
    [SerializeField] Text playerNameText;
    [SerializeField] RectTransform bubbleRt;
    [SerializeField] RichText chatText;
    [SerializeField] Image m_ChatIcon;
    [SerializeField] Text m_VipLv;
    [SerializeField] Text m_PlayerName;
    [SerializeField] Text m_ChatTime;
    [SerializeField] RectTransform m_Bottom;
    [SerializeField] RichText m_Chat;
    [SerializeField] Button m_Func;
    ChatCenter m_ChatCenter;
    ChatCenter chatCenter
@@ -24,45 +26,48 @@
    }
    public override void Refresh(CellView cell)
    {
        ChatData _data = chatCenter.GetChatData(ChatCtrl.Inst.presentChatType, cell.index);
        if (_data == null)
        var data = chatCenter.GetChatData(ChatCtrl.Inst.presentChatType, cell.index);
        if (data == null)
        {
            return;
        }
        #region 更新高度
        if (type == ScrollerDataType.Header)
        {
            if (chatText.preferredWidth > chatText.rectTransform.rect.width)
            if (m_Chat.preferredWidth > m_Chat.rectTransform.rect.width)
            {
                chatText.alignment = TextAnchor.UpperLeft;
                m_Chat.alignment = TextAnchor.UpperLeft;
            }
            else
            {
                chatText.alignment = TextAnchor.UpperRight;
                m_Chat.alignment = TextAnchor.UpperRight;
            }
        }
        #endregion
        Button headBtn = chatIcon.GetComponent<Button>();
        headBtn.onClick.RemoveAllListeners();
        headBtn.onClick.AddListener(() =>
        var chatUserData = data as ChatUeseData;
        m_Func.onClick.RemoveAllListeners();
        m_Func.onClick.AddListener(() =>
        {
            OnHeadIconClick(cell);
            OnFunc(cell);
        });
        chatIcon.SetSprite(GeneralDefine.GetJobHeadPortrait((_data as ChatUeseData).job, 0));
        playerNameText.text = (_data as ChatUeseData).name;
        if ((_data as ChatUeseData).vipLv > 0)
        m_ChatIcon.SetSprite(GeneralDefine.GetJobHeadPortrait(chatUserData.job, 0));
        m_PlayerName.text = chatUserData.name;
        m_ChatTime.text = data.createTime.ToString("yyyy-MM-dd HH:mm");
        if (chatUserData.vipLv > 0)
        {
            vipText.text = string.Format("V{0}", (_data as ChatUeseData).vipLv);
            m_VipLv.text = string.Format("V{0}", chatUserData.vipLv);
        }
        else
        {
            vipText.text = string.Empty;
            m_VipLv.text = string.Empty;
        }
        chatText.AutoNewLine = true;
        chatText.text = _data.content;
        m_Chat.AutoNewLine = true;
        m_Chat.text = data.content;
    }
    private void OnHeadIconClick(CellView cell)
    private void OnFunc(CellView cell)
    {
        int index = cell.index;
        ChatData _data = chatCenter.GetChatData(ChatCtrl.Inst.presentChatType, index);
@@ -71,7 +76,10 @@
            return;
        }
        ChatUeseData user = _data as ChatUeseData;
        if (user.player == PlayerDatas.Instance.baseData.PlayerID) return;
        if (user.player == PlayerDatas.Instance.baseData.PlayerID)
        {
            return;
        }
        HrefAnalysis.Inst.ExcuteHrefEvent(string.Format("showplayer={0}", user.player));
    }
}