using EnhancedUI.EnhancedScroller;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
using System;
|
using Snxxz.UI;
|
|
public class ChatPlayerOtherCell : ScrollerUI
|
{
|
[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
|
{
|
get
|
{
|
return m_ChatCenter ?? (m_ChatCenter = ModelCenter.Instance.GetModel<ChatCenter>());
|
}
|
}
|
public override void Refresh(CellView cell)
|
{
|
var data = chatCenter.GetChatData(ChatCtrl.Inst.presentChatType, cell.index);
|
if (data == null)
|
{
|
return;
|
}
|
|
#region 更新高度
|
if (type == ScrollerDataType.Header)
|
{
|
if (m_Chat.preferredWidth > m_Chat.rectTransform.rect.width)
|
{
|
m_Chat.alignment = TextAnchor.UpperLeft;
|
}
|
else
|
{
|
m_Chat.alignment = TextAnchor.UpperRight;
|
}
|
}
|
#endregion
|
|
var chatUserData = data as ChatUeseData;
|
m_Func.onClick.RemoveAllListeners();
|
m_Func.onClick.AddListener(() =>
|
{
|
OnFunc(cell);
|
});
|
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)
|
{
|
m_VipLv.text = string.Format("V{0}", chatUserData.vipLv);
|
}
|
else
|
{
|
m_VipLv.text = string.Empty;
|
}
|
m_Chat.AutoNewLine = true;
|
m_Chat.text = data.content;
|
}
|
|
private void OnFunc(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));
|
}
|
}
|