| | |
| | | public Dictionary<int, ChatBubbleData> chatBubbles = new Dictionary<int, ChatBubbleData>(); |
| | | //<ChannelType,时间戳> |
| | | public Dictionary<int, int> chatChannelSendTime = new Dictionary<int, int>(); |
| | | public event Action<ChatChannel, TalkData> OnUpdateTalkEvent; |
| | | public event Action<ChatChannel, TalkData, bool> OnUpdateTalkEvent; |
| | | public event Action OnUpdateTalkCacheListEvent; |
| | | |
| | | public Dictionary<int, int> chatChannelCD = new Dictionary<int, int>(); |
| | |
| | | public Color32 areaOtherColor; |
| | | public Dictionary<int, int[]> chatChannelBulletColorArrDict = new Dictionary<int, int[]>(); |
| | | public Dictionary<ChatChannel, Color32> chatChannelBulletColorDict = new Dictionary<ChatChannel, Color32>(); |
| | | |
| | | public int[] defaultChannelBulletColorArr; |
| | | public Color32 defaultChannelBulletColor; |
| | | public int characterLimit; |
| | |
| | | |
| | | config = FuncConfigConfig.Get("TalkColor"); |
| | | areaMyColorArr = ConfigParse.GetMultipleStr<int>(config.Numerical1); |
| | | areaMyColor = new Color32() |
| | | { |
| | | r = (byte)(areaMyColorArr.Length > 0 ? areaMyColorArr[0] : 0), |
| | | g = (byte)(areaMyColorArr.Length > 1 ? areaMyColorArr[1] : 0), |
| | | b = (byte)(areaMyColorArr.Length > 2 ? areaMyColorArr[2] : 0), |
| | | a = (byte)(areaMyColorArr.Length > 3 ? areaMyColorArr[3] : 255), |
| | | }; |
| | | areaMyColor = ParseColor32(areaMyColorArr); |
| | | |
| | | areaOtherColorArr = ConfigParse.GetMultipleStr<int>(config.Numerical2); |
| | | areaOtherColor = new Color32() |
| | | { |
| | | r = (byte)(areaOtherColorArr.Length > 0 ? areaOtherColorArr[0] : 0), |
| | | g = (byte)(areaOtherColorArr.Length > 1 ? areaOtherColorArr[1] : 0), |
| | | b = (byte)(areaOtherColorArr.Length > 2 ? areaOtherColorArr[2] : 0), |
| | | a = (byte)(areaOtherColorArr.Length > 3 ? areaOtherColorArr[3] : 255), |
| | | }; |
| | | areaOtherColor = ParseColor32(areaOtherColorArr); |
| | | |
| | | chatChannelBulletColorArrDict = ConfigParse.ParseIntArrayDict(config.Numerical3); |
| | | foreach (var kv in chatChannelBulletColorArrDict) |
| | | { |
| | | if (!IsValidChatChannel(kv.Key)) |
| | | continue; |
| | | chatChannelBulletColorDict[(ChatChannel)kv.Key] = new Color32() |
| | | { |
| | | r = (byte)(kv.Value.Length > 0 ? kv.Value[0] : 0), |
| | | g = (byte)(kv.Value.Length > 1 ? kv.Value[1] : 0), |
| | | b = (byte)(kv.Value.Length > 2 ? kv.Value[2] : 0), |
| | | a = (byte)(kv.Value.Length > 3 ? kv.Value[3] : 0), |
| | | }; |
| | | chatChannelBulletColorDict[(ChatChannel)kv.Key] = ParseColor32(kv.Value); |
| | | } |
| | | |
| | | defaultChannelBulletColorArr = ConfigParse.GetMultipleStr<int>(config.Numerical4); |
| | | defaultChannelBulletColor = new Color32() |
| | | { |
| | | r = (byte)(defaultChannelBulletColorArr.Length > 0 ? defaultChannelBulletColorArr[0] : 0), |
| | | g = (byte)(defaultChannelBulletColorArr.Length > 1 ? defaultChannelBulletColorArr[1] : 0), |
| | | b = (byte)(defaultChannelBulletColorArr.Length > 2 ? defaultChannelBulletColorArr[2] : 0), |
| | | a = (byte)(defaultChannelBulletColorArr.Length > 3 ? defaultChannelBulletColorArr[3] : 255), |
| | | }; |
| | | defaultChannelBulletColor = ParseColor32(defaultChannelBulletColorArr); |
| | | |
| | | config = FuncConfigConfig.Get("TalkLimit"); |
| | | characterLimit = int.Parse(config.Numerical1); |
| | |
| | | config = FuncConfigConfig.Get("TalkBubble"); |
| | | sysBubbleID = int.Parse(config.Numerical1); |
| | | sysBubbleColorArr = ConfigParse.GetMultipleStr<int>(config.Numerical2); |
| | | sysBubbleColor = new Color32() |
| | | { |
| | | r = (byte)(sysBubbleColorArr.Length > 0 ? sysBubbleColorArr[0] : 0), |
| | | g = (byte)(sysBubbleColorArr.Length > 1 ? sysBubbleColorArr[1] : 0), |
| | | b = (byte)(sysBubbleColorArr.Length > 2 ? sysBubbleColorArr[2] : 0), |
| | | a = (byte)(sysBubbleColorArr.Length > 3 ? sysBubbleColorArr[3] : 255), |
| | | }; |
| | | sysBubbleColor = ParseColor32(sysBubbleColorArr); |
| | | |
| | | ParseChatBubbleConfig(); |
| | | } |
| | | |
| | | public Color32 ParseColor32(int[] colorArr) |
| | | { |
| | | return new Color32() |
| | | { |
| | | r = (byte)(colorArr.Length > 0 ? colorArr[0] : 0), |
| | | g = (byte)(colorArr.Length > 1 ? colorArr[1] : 0), |
| | | b = (byte)(colorArr.Length > 2 ? colorArr[2] : 0), |
| | | a = (byte)(colorArr.Length > 3 ? colorArr[3] : 255), |
| | | }; |
| | | } |
| | | |
| | | public override void Release() |
| | |
| | | GuildManager.Instance.EnterOrQuitGuildEvent -= EnterOrQuitGuildEvent; |
| | | } |
| | | |
| | | //被踢出/退出工会时,切换聊天频道 |
| | | //被踢出/退出工会时,切换聊天频道,清理缓存的旧公会信息 |
| | | private void EnterOrQuitGuildEvent(bool obj) |
| | | { |
| | | if (!obj) |
| | | { |
| | | nowChatChannel = ChatChannel.World; |
| | | nowChatTab = ChatTab.World; |
| | | if (talkDict.ContainsKey(ChatChannel.Guild)) |
| | | { |
| | | talkDict[ChatChannel.Guild].Clear(); |
| | | } |
| | | if (lastTalkDataDict.ContainsKey(ChatChannel.Guild)) |
| | | { |
| | | lastTalkDataDict.Remove(ChatChannel.Guild); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | private void OnBeforePlayerDataInitializeEvent() |
| | | { |
| | | talkDict.Clear(); |
| | | lastTalkDataDict.Clear(); |
| | | currentDay = -1; |
| | | nowChatChannel = ChatChannel.World; |
| | | nowChatTab = ChatTab.World; |
| | |
| | | top = config.RightOffset.Length > 2 ? config.RightOffset[2] : 0, |
| | | bottom = config.RightOffset.Length > 3 ? config.RightOffset[3] : 0, |
| | | }; |
| | | bubble.myColor = new Color32() |
| | | { |
| | | r = (byte)(config.MyColor.Length > 0 ? config.MyColor[0] : 0), |
| | | g = (byte)(config.MyColor.Length > 1 ? config.MyColor[1] : 0), |
| | | b = (byte)(config.MyColor.Length > 2 ? config.MyColor[2] : 0), |
| | | a = (byte)(config.MyColor.Length > 3 ? config.MyColor[3] : 255), |
| | | }; |
| | | bubble.otherColor = new Color32() |
| | | { |
| | | r = (byte)(config.OtherColor.Length > 0 ? config.OtherColor[0] : 0), |
| | | g = (byte)(config.OtherColor.Length > 1 ? config.OtherColor[1] : 0), |
| | | b = (byte)(config.OtherColor.Length > 2 ? config.OtherColor[2] : 0), |
| | | a = (byte)(config.OtherColor.Length > 3 ? config.OtherColor[3] : 255), |
| | | }; |
| | | bubble.myColor = ParseColor32(config.MyColor); |
| | | bubble.otherColor = ParseColor32(config.OtherColor); |
| | | bubble.top = config.Top; |
| | | chatBubbles.Add(config.ID, bubble); |
| | | } |
| | |
| | | OnDeleteTalkEvent?.Invoke(type); |
| | | } |
| | | |
| | | public int currentDay = -1; |
| | | public void AddTalkData(ChatChannel type, TalkData data, bool isSend) |
| | | |
| | | |
| | | //记录各个频道最后一条聊天记录 |
| | | public Dictionary<ChatChannel, TalkData> lastTalkDataDict = new Dictionary<ChatChannel, TalkData>(); |
| | | public bool TryGetLastTalkData(out ChatChannel type, out TalkData data) |
| | | { |
| | | type = ChatChannel.World; |
| | | data = null; |
| | | bool isFound = false; |
| | | foreach (var kvp in lastTalkDataDict) |
| | | { |
| | | ChatChannel channelType = kvp.Key; |
| | | TalkData talkData = kvp.Value; |
| | | bool isOpen = GetBulletSetting(channelType); |
| | | if (!isOpen) |
| | | continue; |
| | | if (channelType == ChatChannel.Guild && !IsTabOpen(ChatTab.Guild, false)) |
| | | continue; |
| | | if (data == null || talkData.TalkTime > data.TalkTime) |
| | | { |
| | | isFound = true; |
| | | type = channelType; |
| | | data = talkData; |
| | | } |
| | | } |
| | | return isFound; |
| | | } |
| | | |
| | | |
| | | public void AddTalkData(ChatChannel type, TalkData data, bool isSendBullet) |
| | | { |
| | | //如果超过限制先删除旧数据 |
| | | TryDeleteTalkData(type); |
| | |
| | | talkDict[type] = new List<TalkData>(); |
| | | } |
| | | talkDict[type].Add(data); |
| | | if (isSend) |
| | | |
| | | if (!lastTalkDataDict.ContainsKey(type) || lastTalkDataDict[type].TalkTime <= data.TalkTime) |
| | | { |
| | | OnUpdateTalkEvent?.Invoke(type, data); |
| | | //展示的消息不能是日期行和系统行 |
| | | if (!data.isDate && !data.isSystem) |
| | | { |
| | | lastTalkDataDict[type] = data; |
| | | } |
| | | } |
| | | |
| | | if (isSendBullet) |
| | | { |
| | | OnUpdateTalkEvent?.Invoke(type, data, isSendBullet); |
| | | } |
| | | } |
| | | |
| | | public bool TryAddDate(int allSeconds, ChatChannel type, bool isSend) |
| | | public int currentDay = -1; |
| | | public bool TryAddDate(int allSeconds, ChatChannel type, bool isSendBullet) |
| | | { |
| | | DateTime talkTime = TimeUtility.GetTime((uint)allSeconds); |
| | | if (talkTime.Day != currentDay) |
| | |
| | | isDate = true, |
| | | Content = Language.Get("Chat09", talkTime.Month, talkTime.Day), |
| | | TalkTime = (uint)allSeconds, |
| | | }, isSend); |
| | | }, isSendBullet); |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | public void AddSysData(string msg, ArrayList infoList, ChatChannel type, bool isSend) |
| | | public void AddSysData(string msg, ArrayList infoList, ChatChannel type, bool isSendBullet) |
| | | { |
| | | int allSeconds = TimeUtility.AllSeconds; |
| | | // 如果隔天,增加日期行 |
| | | TryAddDate(allSeconds, type, isSend); |
| | | TryAddDate(allSeconds, type, isSendBullet); |
| | | |
| | | if (!talkDict.ContainsKey(type)) |
| | | { |
| | |
| | | BubbleBox = 1, |
| | | TalkTime = (uint)allSeconds, |
| | | InfoList = new ArrayList(infoList), |
| | | }, isSend); |
| | | }, isSendBullet); |
| | | } |
| | | |
| | | public void UpdateTalk(HB310_tagMCTalk vNetData) |
| | |
| | | |
| | | private Dictionary<ChatChannel, bool> bulletSettingDict = new Dictionary<ChatChannel, bool>(); |
| | | |
| | | |
| | | private string settingsKey { get { return StringUtility.Concat("BulletChatSettings_", PlayerDatas.Instance.PlayerId.ToString()); } } |
| | | |
| | | // 设置特定频道的弹幕开关状态 |