| | |
| | | [SerializeField] TextEx txtSendChat; |
| | | [SerializeField] ScrollerController scrWorld; |
| | | [SerializeField] ScrollerController scrGuild; |
| | | [SerializeField] ScrollerController scrCrossServer; |
| | | |
| | | [SerializeField] ButtonEx serversBtn; |
| | | private int unreadMsgCount = 0; |
| | | [SerializeField] ButtonEx btnNewMsgTip; |
| | | [SerializeField] TextEx txtNewMsgTip; |
| | |
| | | bool isSettingOpen = false; |
| | | [SerializeField] ChatSettingButton btnWorldSetting; |
| | | [SerializeField] ChatSettingButton btnGuildSetting; |
| | | [SerializeField] ChatSettingButton btnCrossServerSetting; |
| | | ChatManager manager { get { return ChatManager.Instance; } } |
| | | |
| | | protected override void InitComponent() |
| | |
| | | RefreshChat(manager.nowChatChannel, scrGuild); |
| | | ScrollerJump(scrGuild, ChatChannel.Guild); |
| | | } |
| | | else if (manager.nowChatChannel == ChatChannel.CrossServer) |
| | | { |
| | | RefreshChat(manager.nowChatChannel, scrCrossServer); |
| | | ScrollerJump(scrCrossServer, ChatChannel.CrossServer); |
| | | } |
| | | ClearUnreadMsg(); |
| | | }); |
| | | btnSetting.SetListener(() => |
| | |
| | | isSettingOpen = !isSettingOpen; |
| | | transSettings.SetActive(isSettingOpen); |
| | | }); |
| | | |
| | | serversBtn.SetListener(() => |
| | | { |
| | | UIHelper.ShowServersPanel(GuildManager.Instance.crossServerIDList); |
| | | }); |
| | | } |
| | | |
| | | // 清理未读消息状态 |
| | |
| | | manager.OnUpdatePlayerInfoEvent += OnUpdatePlayerInfoEvent; |
| | | |
| | | scrChatTab.OnRefreshCell += OnRefreshChatTabCell; |
| | | |
| | | scrWorld.OnGetDynamicSize += OnGetWorldChatDynamicSize; |
| | | scrWorld.OnRefreshCell += OnRefreshWorldCell; |
| | | scrWorld.mScrollRect.onValueChanged.AddListener(OnWorldScrollValChange); |
| | | |
| | | scrGuild.OnGetDynamicSize += OnGetGuildChatDynamicSize; |
| | | scrGuild.OnRefreshCell += OnRefreshGuildCell; |
| | | scrGuild.mScrollRect.onValueChanged.AddListener(OnGuildScrollValChange); |
| | | |
| | | scrCrossServer.OnGetDynamicSize += OnGetChatDynamicSize; |
| | | scrCrossServer.OnRefreshCell += OnRefreshCell; |
| | | scrCrossServer.mScrollRect.onValueChanged.AddListener(OnCrossServerScrollValChange); |
| | | |
| | | clickScreenOtherSpace.AddListener(OnClickScreenOtherSpace); |
| | | GlobalTimeEvent.Instance.secondEvent += OnSecondEvent; |
| | |
| | | transSettings.SetActive(isSettingOpen); |
| | | btnWorldSetting.SetChannelType(ChatChannel.World); |
| | | btnGuildSetting.SetChannelType(ChatChannel.Guild); |
| | | btnCrossServerSetting.SetChannelType(ChatChannel.CrossServer); |
| | | inputChat.characterLimit = ChatManager.Instance.characterLimit; |
| | | CreaterAll(manager.nowChatTab); |
| | | } |
| | |
| | | scrWorld.OnGetDynamicSize -= OnGetWorldChatDynamicSize; |
| | | scrWorld.OnRefreshCell -= OnRefreshWorldCell; |
| | | scrWorld.mScrollRect.onValueChanged.RemoveListener(OnWorldScrollValChange); |
| | | |
| | | scrGuild.OnGetDynamicSize -= OnGetGuildChatDynamicSize; |
| | | scrGuild.OnRefreshCell -= OnRefreshGuildCell; |
| | | scrGuild.mScrollRect.onValueChanged.RemoveListener(OnGuildScrollValChange); |
| | | |
| | | scrCrossServer.OnGetDynamicSize -= OnGetChatDynamicSize; |
| | | scrCrossServer.OnRefreshCell -= OnRefreshCell; |
| | | scrCrossServer.mScrollRect.onValueChanged.RemoveListener(OnCrossServerScrollValChange); |
| | | |
| | | GlobalTimeEvent.Instance.secondEvent -= OnSecondEvent; |
| | | clickScreenOtherSpace.RemoveAllListeners(); |
| | | } |
| | |
| | | else if (channel == ChatChannel.Guild) |
| | | { |
| | | CreateScroller(scrGuild, channel); |
| | | } |
| | | else if (channel == ChatChannel.CrossServer) |
| | | { |
| | | CreateScroller(scrCrossServer, channel); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | if (scrWorld.lockType != EnhanceLockType.LockVerticalBottom) |
| | | scrWorld.lockType = EnhanceLockType.LockVerticalBottom; |
| | | |
| | | if (scrGuild.lockType != EnhanceLockType.LockVerticalBottom) |
| | | scrGuild.lockType = EnhanceLockType.LockVerticalBottom; |
| | | if (scrCrossServer.lockType != EnhanceLockType.LockVerticalBottom) |
| | | scrCrossServer.lockType = EnhanceLockType.LockVerticalBottom; |
| | | // 如果回到底部,直接清零消息 |
| | | ClearUnreadMsg(); |
| | | } |
| | |
| | | { |
| | | if (scrWorld.lockType != EnhanceLockType.KeepVertical) |
| | | scrWorld.lockType = EnhanceLockType.KeepVertical; |
| | | if (scrGuild.lockType != EnhanceLockType.KeepVertical) |
| | | scrGuild.lockType = EnhanceLockType.KeepVertical; |
| | | if (scrCrossServer.lockType != EnhanceLockType.KeepVertical) |
| | | scrCrossServer.lockType = EnhanceLockType.KeepVertical; |
| | | } |
| | | } |
| | | } |
| | |
| | | private void OnGuildScrollValChange(Vector2 _pos) |
| | | { |
| | | OnScrollValChange(scrGuild, _pos); |
| | | } |
| | | private void OnCrossServerScrollValChange(Vector2 _pos) |
| | | { |
| | | OnScrollValChange(scrCrossServer, _pos); |
| | | } |
| | | |
| | | private void OnScrollValChange(ScrollerController scorller, Vector2 _pos) |
| | |
| | | scrGuild.lockType = EnhanceLockType.LockVerticalBottom; // 初始锁定底部 |
| | | scrGuild.SetActive(chatTab == ChatTab.Guild); |
| | | |
| | | transInput.SetActive(chatTab == ChatTab.World || chatTab == ChatTab.Guild); |
| | | scrCrossServer.lockType = EnhanceLockType.LockVerticalBottom; // 初始锁定底部 |
| | | scrCrossServer.SetActive(chatTab == ChatTab.CrossServer); |
| | | |
| | | transInput.SetActive(true); |
| | | serversBtn.SetActive(chatTab == ChatTab.CrossServer); |
| | | |
| | | CreateChatTabScroller(); |
| | | |
| | |
| | | manager.nowChatChannel = ChatChannel.Guild; |
| | | CreateScroller(scrGuild, ChatChannel.Guild); |
| | | ScrollerJump(scrGuild, ChatChannel.Guild); |
| | | ClearUnreadMsg(); |
| | | break; |
| | | case ChatTab.CrossServer: |
| | | manager.nowChatChannel = ChatChannel.CrossServer; |
| | | CreateScroller(scrCrossServer, ChatChannel.CrossServer); |
| | | ScrollerJump(scrCrossServer, ChatChannel.CrossServer); |
| | | ClearUnreadMsg(); |
| | | break; |
| | | } |
| | |
| | | else if (type == ChatChannel.Guild) |
| | | { |
| | | RefreshChat(type, scrGuild, playerId, isUpdatePlayerInfo); |
| | | } |
| | | else if (type == ChatChannel.CrossServer) |
| | | { |
| | | RefreshChat(type, scrCrossServer, playerId, isUpdatePlayerInfo); |
| | | } |
| | | |
| | | } |
| | |
| | | return; |
| | | if (type == ChatChannel.Guild && manager.nowChatTab != ChatTab.Guild) |
| | | return; |
| | | if (type == ChatChannel.CrossServer && manager.nowChatTab != ChatTab.CrossServer) |
| | | return; |
| | | // 1. 自己发送的消息 -> 强制跳转到底部 + 清零 |
| | | if (playerId == PlayerDatas.Instance.PlayerId) |
| | | { |
| | |
| | | } |
| | | |
| | | // 特殊情况:如果未读数量巨大(超过了总显示数量),说明整个列表都被刷新了,直接消零 |
| | | if (unreadMsgCount >= scrWorld.GetNumberOfCells(scrWorld.m_Scorller)) |
| | | if (unreadMsgCount >= scroller.GetNumberOfCells(scroller.m_Scorller)) |
| | | { |
| | | ClearUnreadMsg(); |
| | | } |