| | |
| | | |
| | | public class BuffInfoCell : CellView |
| | | { |
| | | private const float BaseCellWidth = 607f; |
| | | private const float BaseDescWidth = 564.48f; |
| | | |
| | | [SerializeField] TextEx buffNameText; |
| | | [SerializeField] TextEx roundText; |
| | | [SerializeField] ImageEx buffImage; |
| | | [SerializeField] TextEx buffCountText; |
| | | [SerializeField] RichText descText; |
| | | |
| | | RectTransform cellRectTransform; |
| | | RectTransform descRectTransform; |
| | | |
| | | private void Awake() |
| | | { |
| | | ResetWidth(); |
| | | SetDescAutoNewLine(); |
| | | } |
| | | |
| | | public void Display(int index, BattleClickBuffData data) |
| | | { |
| | | if (data.datas?.Count <= index) return; |
| | |
| | | buffCountText.text = info.Layer == 0 ? "" : info.Layer.ToString(); |
| | | |
| | | buffNameText.text = UIHelper.AppendColor(config.IsDebuff() ? TextColType.Red : TextColType.LightGreen, config.SkillName); |
| | | ResetWidth(); |
| | | SetDescAutoNewLine(); |
| | | descText.text = config.Description; |
| | | roundText.text = info.LastTime <= 0 ? "" : Language.Get("BuffInfo01", info.LastTime); |
| | | |
| | |
| | | |
| | | public float GetTextHeight(string content) |
| | | { |
| | | ResetWidth(); |
| | | SetDescAutoNewLine(); |
| | | descText.text = content; |
| | | return string.IsNullOrEmpty(content) ? 0 : descText.preferredHeight + 80; |
| | | } |
| | | } |
| | | |
| | | private void ResetWidth() |
| | | { |
| | | if (cellRectTransform == null) |
| | | { |
| | | cellRectTransform = transform as RectTransform; |
| | | } |
| | | |
| | | if (descRectTransform == null && descText != null) |
| | | { |
| | | descRectTransform = descText.rectTransform; |
| | | } |
| | | |
| | | SetWidth(cellRectTransform, BaseCellWidth); |
| | | SetWidth(descRectTransform, BaseDescWidth); |
| | | } |
| | | |
| | | private void SetDescAutoNewLine() |
| | | { |
| | | if (descText != null && !descText.AutoNewLine) |
| | | { |
| | | descText.AutoNewLine = true; |
| | | } |
| | | } |
| | | |
| | | private void SetWidth(RectTransform rectTransform, float width) |
| | | { |
| | | if (rectTransform != null) |
| | | { |
| | | rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, width); |
| | | } |
| | | } |
| | | } |