using Games.LogicObj; using UnityEngine; using UnityEngine.UI; using UnityEngine.EventSystems; using System.Collections; using GCGame; using Module.Log; using Games.GlobeDefine; using System.Collections.Generic; using GCGame.Table; using System; public class GuildHistoryItem : UIItemBase { public Text Time; public Text Tip; HistoryRecord m_History; public override void Show(Hashtable hash) { m_History = hash["InitObj"] as HistoryRecord; if (m_History == null) return; Tab_GuildHistory guildHistory = TableManager.GetGuildHistoryByID(m_History.Type, 0); if (guildHistory == null) return; DateTime date = GCGame.Utils.TimesToDateTime(m_History.Time); Time.text = string.Format("{0}-{1}-{2}", date.Year, date.Month, date.Day); List _params = new List(); for (int i = 0; i < guildHistory.getParamCount(); i++) { int index = guildHistory.GetParambyIndex(i); if (index != -1) { if (index == 0) { _params.Add(string.Format("[#14,{0},{1}]", m_History.Guid1, m_History.Name1)); } if (index == 1) { if (i < 2) { _params.Add(string.Format("[#14,{0},{1}]", m_History.Guid2, m_History.Name2)); //_params.Add(string.Format("{1}[{0}]", m_History.Name2, StrDictionary.GetClientDictionaryString("#{5533}"))); } else _params.Add(string.Format("{0}", m_History.Name2)); } if (index == 2) { _params.Add(m_History.Param1); } if (index == 3) { _params.Add(m_History.Param2); } } } string _ModifiedStr = string.Format(guildHistory.Describe, _params.ToArray()); CreateLink(_ModifiedStr); _ModifiedStr = GetLinkedStr(_ModifiedStr); Tip.text = _ModifiedStr; Tip.CalculateLayoutInputHorizontal(); Tip.CalculateLayoutInputVertical(); StartCoroutine(WaitLayout()); base.Show(); } protected IEnumerator WaitLayout() { yield return null; while (Tip != null && !string.IsNullOrEmpty(Tip.text)) { if (Tip.cachedTextGenerator.characterCountVisible == Tip.text.Length) { SetLinksAfterLayout(); break; } else yield return null; } } protected string GetLinkedStr(string _ModifiedStr) { int subStrStart = 0; int subStrEnd = 0; int newInputEnd = 0; string newInputText = ""; for (int i = 0; i < _LinkLists.Count; ++i) { if (i > 0) { subStrStart = _LinkLists[i - 1].EndPosInText + 1; } subStrEnd = _LinkLists[i].StartPosInText; if (subStrEnd > subStrStart) { newInputText += _ModifiedStr.Substring(subStrStart, subStrEnd - subStrStart); } _LinkLists[i].StartPosInShowText = newInputText.Length; newInputText += _LinkLists[i].StrShow; newInputEnd = _LinkLists[i].EndPosInText + 1; _LinkLists[i].EndPosInShowText = newInputText.Length; } newInputText += _ModifiedStr.Substring(newInputEnd, _ModifiedStr.Length - newInputEnd); return newInputText; } protected List _LinkLists = new List(); protected void SetLinksAfterLayout() { foreach (var link in _LinkLists) { link.SetLinkAfterLayout(Tip); } } void CreateLink(string _ModifiedStr) { int checkPos = _ModifiedStr.IndexOf(ChatLinkBase.StrSendStart); int checkEndPos = -1; string checkStr = ""; while (checkPos >= 0) { checkEndPos = _ModifiedStr.IndexOf(ChatLinkBase.StrSendEnd, checkPos); checkStr = _ModifiedStr.Substring(checkPos, checkEndPos - checkPos); if (!string.IsNullOrEmpty(checkStr)) { var chatLink = ChatLinkBase.CreateChatLinkBySendStr(Tip, null, checkStr); chatLink.StartPosInText = checkPos; chatLink.EndPosInText = checkEndPos; _LinkLists.Add(chatLink); } checkPos = _ModifiedStr.IndexOf(ChatLinkBase.StrSendStart, checkEndPos); } } }