using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace EnhancedUI.EnhancedScroller
|
{
|
public class ChatFriendCell : ScrollerUI
|
{
|
[SerializeField] RichText m_ChatText;
|
[SerializeField] Text m_VipText;
|
[SerializeField] Text m_NameText;
|
[SerializeField] Image m_ChatIcon;
|
[SerializeField] ImageFitterText m_ImageFitter;
|
|
public override void Refresh(CellView cell)
|
{
|
var _index = cell.index;
|
int _playerId = ChatCtrl.Inst.PteChatID;
|
var _list = ChatCtrl.Inst.GetChatInfo(_playerId);
|
if (_list != null && _index < _list.Count)
|
{
|
ChatFriendData chat = _list[_index];
|
m_ChatText.text = chat.content;
|
if (type == ScrollerDataType.Header)
|
{
|
m_ChatText.AutoNewLine = false;
|
if (m_ChatText.preferredWidth > m_ChatText.rectTransform.rect.width)
|
{
|
m_ChatText.alignment = TextAnchor.UpperLeft;
|
}
|
else
|
{
|
m_ChatText.alignment = TextAnchor.UpperRight;
|
}
|
m_ChatText.AutoNewLine = true;
|
}
|
m_ImageFitter.FiterRealTxtWidth = m_ChatText.alignment == TextAnchor.UpperRight;
|
m_VipText.text = chat.vipLv > 0 ? StringUtility.Contact("V", chat.vipLv) : string.Empty;
|
m_NameText.text = chat.name;
|
m_ChatIcon.SetSprite(GeneralDefine.GetJobHeadPortrait(chat.job, 0));
|
m_ChatText.text = chat.content;
|
}
|
}
|
}
|
}
|