少年修仙传客户端代码仓库
client_Zxw
2018-09-19 6cc9f56e28978bede19629ce50947b9609080da5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using Snxxz.UI;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace EnhancedUI.EnhancedScroller
{
    public class ChatPlayerMineCell : ScrollerUI
    {
        [SerializeField] Image chatIcon;
        [SerializeField] Text vipText;
        [SerializeField] Text playerNameText;
        [SerializeField] RichText chatText;
        [SerializeField] ImageFitterText m_Fitter;
 
        ChatCenter m_ChatCenter;
        ChatCenter chatCenter
        {
            get
            {
                return m_ChatCenter ?? (m_ChatCenter = ModelCenter.Instance.GetModel<ChatCenter>());
            }
        }
        public override void Refresh(CellView cell)
        {
            ChatData _data = chatCenter.GetChatData(ChatCtrl.Inst.presentChatType, cell.index);
            if (_data == null)
            {
                return;
            }
            #region 更新高度
            chatText.AutoNewLine = false;
            chatText.text = _data.content;
            if (type == ScrollerDataType.Header)
            {
                if (chatText.preferredWidth > chatText.rectTransform.rect.width)
                {
                    chatText.alignment = TextAnchor.UpperLeft;
                }
                else
                {
                    chatText.alignment = TextAnchor.UpperRight;
                }
                m_Fitter.FiterRealTxtWidth = chatText.alignment == TextAnchor.UpperRight;
            }
            chatText.AutoNewLine = true;
            chatIcon.SetSprite(GeneralConfig.Instance.GetJobHeadPortrait((_data as ChatUeseData).job, 0));
            #endregion
            Button headBtn = chatIcon.GetComponent<Button>();
            headBtn.onClick.RemoveAllListeners();
            headBtn.onClick.AddListener(() =>
            {
                OnHeadIconClick(cell);
            });
            playerNameText.text = (_data as ChatUeseData).name;
            if ((_data as ChatUeseData).vipLv > 0)
            {
                vipText.text = string.Format("V{0}", (_data as ChatUeseData).vipLv);
            }
            else
            {
                vipText.text = string.Empty;
            }
        }
 
        private void OnHeadIconClick(CellView cell)
        {
            int index = cell.index;
            ChatData _data = chatCenter.GetChatData(ChatCtrl.Inst.presentChatType, index);
            if (_data == null)
            {
                return;
            }
            ChatUeseData user = _data as ChatUeseData;
            if (user.player == PlayerDatas.Instance.baseData.PlayerID) return;
            HrefAnalysis.Inst.ExcuteHrefEvent(string.Format("showplayer={0}", user.player));
        }
    }
}