using Thousandto.Code.Center; using Thousandto.Plugins.Common; using System.Collections; using System.Collections.Generic; using UnityEngine; using Thousandto.Core.RootSystem; using Thousandto.Core.Base; using System; using Thousandto.Cfg.Data; using Thousandto.Core.Asset; using Thousandto.Core.Framework; namespace Thousandto.Code.Logic { /// /// 聊天插入面板逻辑类 /// public class ChatInsertSystem { public enum ChatType { Expression = 1, Item = 2, History = 3, } //历史记录最大数 public const int MAX_HISTORY_COUNT = 10; //私聊界面是否打开 public bool IsChatPrivateFormOpened = false; public void Destroy() { } /// /// 添加聊天记录到历史数据中 /// /// public void AddChatToHistoryData(List nodes) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); for(int i = 0; i < nodes.Count; ++i) { sb.Append(nodes[i].GetDisplayText()); } var historyTxt = sb.ToString().Trim(); if (string.IsNullOrEmpty(historyTxt)) return; if (GameCenter.ChatSystem.HistoryData.Count >= MAX_HISTORY_COUNT) { GameCenter.ChatSystem.HistoryData.RemoveAt(GameCenter.ChatSystem.HistoryData.Count - 1); } GameCenter.ChatSystem.HistoryData.Insert(0, nodes.ToArray()); } //是否从大聊天框打开 public void Open(bool fromMainChatForm = true, ChatType type = ChatType.Expression) { IsChatPrivateFormOpened = !fromMainChatForm; GameCenter.EventManager.PushFixEvent((int)UIEventDefine.UIChatInsertForm_OPEN, new object[] { fromMainChatForm, type }); } public void Close() { GameCenter.EventManager.PushFixEvent((int)UIEventDefine.UIChatInsertForm_CLOSE); } } }