From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- Client/Assets/Scripts/XMainClient/XChatView.cs | 2607 ++++++++++++++++++++++++ 1 file changed, 2607 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/XChatView.cs (limited to 'Client/Assets/Scripts/XMainClient/XChatView.cs') diff --git a/Client/Assets/Scripts/XMainClient/XChatView.cs b/Client/Assets/Scripts/XMainClient/XChatView.cs new file mode 100644 index 00000000..64d82612 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/XChatView.cs @@ -0,0 +1,2607 @@ +using System; +using System.Collections.Generic; +using System.Text.RegularExpressions; +using KKSG; +using MiniJSON; +using UILib; +using UnityEngine; +using XMainClient.UI; +using XMainClient.UI.UICommon; +using XUpdater; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class XChatView : DlgBase + { + public XChatView.ChatGroupState groupState + { + get + { + return this._groupState; + } + set + { + this.ShowGroup(value); + this._groupState = value; + } + } + + public XChatView.ChatFriendState friendState + { + get + { + return this._friendState; + } + set + { + this.ShowFriend(value == XChatView.ChatFriendState.FRIENDS); + this._friendState = value; + } + } + + private bool isFighting + { + get + { + return XSingleton.singleton.CurrentStage.Stage == EXStage.World || XSingleton.singleton.SceneType == SceneType.SCENE_BIGMELEE_READY; + } + } + + public XChatDocument ChatDoc + { + get + { + return XDocuments.GetSpecificDocument(XChatDocument.uuID); + } + } + + public int ChatIdIndex + { + get + { + return this.m_ChatIdIndex; + } + set + { + this.m_ChatIdIndex = value; + } + } + + public bool IsInited + { + get + { + return this.Inited; + } + } + + public XChatUIOP UIOP + { + get + { + return this.m_UIOP; + } + } + + public ChatChannelType CurrentSpeakChannel + { + get + { + return this.currentSpeakChannel; + } + set + { + this.currentSpeakChannel = value; + } + } + + public override string fileName + { + get + { + return "GameSystem/ChatNewDlg"; + } + } + + public string PrivateChatCurrName + { + get + { + return this.m_sPrivateChatCurrName; + } + set + { + this.m_sPrivateChatCurrName = value; + } + } + + public SetEffectInfo Info + { + get + { + bool flag = this.m_iSetEffectInfo == null; + if (flag) + { + this.m_iSetEffectInfo = new SetEffectInfo(); + } + return this.m_iSetEffectInfo; + } + set + { + this.m_iSetEffectInfo = value; + } + } + + public override int group + { + get + { + return 1; + } + } + + public uint worldSpeakTimes + { + get + { + XWelfareDocument specificDocument = XDocuments.GetSpecificDocument(XWelfareDocument.uuID); + bool flag = specificDocument != null && specificDocument.PayMemberPrivilege != null; + uint result; + if (flag) + { + bool flag2 = specificDocument.IsOwnMemberPrivilege(MemberPrivilege.KingdomPrivilege_Court); + int num = specificDocument.GetMemberPrivilegeConfig(MemberPrivilege.KingdomPrivilege_Court).ChatCount - specificDocument.PayMemberPrivilege.usedChatCount; + result = (flag2 ? (this._worldSpeadTimes + (uint)num) : this._worldSpeadTimes); + } + else + { + result = this._worldSpeadTimes; + } + return result; + } + } + + private XChatView.ChatGroupState _groupState = XChatView.ChatGroupState.GROUPS; + + private XChatView.ChatFriendState _friendState = XChatView.ChatFriendState.FRIENDS; + + private ChatChannelType cacheChannelType = ChatChannelType.World; + + private List cacheLoopList = new List(); + + private Action mOnSend; + + private InputUIType mInputType; + + private string mLinkContent; + + private Transform[] mTransTab = new Transform[11]; + + private IXUICheckBox[] mCheckbox = new IXUICheckBox[11]; + + private XChatDocument _doc = null; + + private ChatChannelType currentSpeakChannel = ChatChannelType.World; + + private SetEffectInfo m_iSetEffectInfo = null; + + private const int CHAT_CHANNEL_NUM = 11; + + private bool Inited = false; + + private int m_ChatIdIndex = 1; + + private XChatUIOP m_UIOP = XSingleton.singleton; + + public static bool m_YunvaInited = false; + + private bool m_CancelRecord = false; + + private Vector2 m_DragDistance = Vector2.zero; + + private uint _GetFlowerCDToken; + + private DateTime[] m_lastChatTime = new DateTime[15]; + + public List chatContentItem = new List(); + + public ulong ChatFriendId = 0UL; + + public ulong ChatGroupId = 0UL; + + private string m_sPrivateChatCurrName = ""; + + public bool cacheShow = false; + + public uint _worldSpeadTimes; + + public ChatChannelType activeChannelType = ChatChannelType.World; + + private ChatChannelType[] showChannelIds = new ChatChannelType[] + { + ChatChannelType.World, + ChatChannelType.Guild, + ChatChannelType.Friends, + ChatChannelType.Curr, + ChatChannelType.Team, + ChatChannelType.Partner, + ChatChannelType.Group, + ChatChannelType.Broadcast, + ChatChannelType.Spectate, + ChatChannelType.Battle, + ChatChannelType.System + }; + + private ChatChannelType[] showVoiceBar = new ChatChannelType[] + { + ChatChannelType.World, + ChatChannelType.Curr, + ChatChannelType.Team, + ChatChannelType.Guild + }; + + private ChatInfo mChatInfo; + + private bool mIsVoice; + + public enum ChatGroupState + { + GROUPS, + CHATS + } + + public enum ChatFriendState + { + FRIENDS, + CHATS + } + + private void RegistGroupEvent() + { + base.uiBehaviour.m_sprGroupQuit.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnGroupQuitClick)); + base.uiBehaviour.m_sprGroupClear.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnGroupClearClick)); + base.uiBehaviour.m_sprGroupBind.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnGroupBindClick)); + base.uiBehaviour.m_sprGroupBack.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnGroupBackClick)); + base.uiBehaviour.m_sprMember.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnMemberClick)); + base.uiBehaviour.m_sprList.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnListClick)); + base.uiBehaviour.m_sprMore.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnMoreClick)); + base.uiBehaviour.m_sprGroupCreate.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnGroupCreateClick)); + } + + private void ShowGroup(XChatView.ChatGroupState state) + { + bool flag = state == XChatView.ChatGroupState.GROUPS; + base.uiBehaviour.m_sprGroupBack.SetVisible(!flag); + base.uiBehaviour.m_sprGroupBind.SetVisible(!flag); + base.uiBehaviour.m_sprGroupClear.SetVisible(flag); + base.uiBehaviour.m_sprGroupQuit.SetVisible(!flag); + base.uiBehaviour.m_sprMore.SetVisible(!flag); + base.uiBehaviour.m_lblGroupChat.SetVisible(!flag); + base.uiBehaviour.m_sprGroupCreate.SetVisible(flag); + this.m_uiBehaviour.m_friendView.gameobject.SetActive(false); + base.uiBehaviour.m_loopView.gameobject.SetActive(!flag); + base.uiBehaviour.m_TextBoard.SetVisible(!flag); + this.m_uiBehaviour.m_groupView.gameobject.SetActive(flag); + GroupChatDocument specificDocument = XDocuments.GetSpecificDocument(GroupChatDocument.uuID); + base.uiBehaviour.m_sprMember.SetVisible(!flag && specificDocument.currGroup != null && specificDocument.currGroup.captain); + base.uiBehaviour.m_sprList.SetVisible(!flag && specificDocument.currGroup != null && !specificDocument.currGroup.captain); + bool flag2 = specificDocument.currGroup != null; + if (flag2) + { + base.uiBehaviour.m_lblGroupChat.SetText(XStringDefineProxy.GetString("CHAT_GROUP_SIGN", new object[] + { + specificDocument.currGroup.name + })); + } + } + + public void OnFocus() + { + for (int i = 0; i < 11; i++) + { + bool flag = this.showChannelIds[i] == ChatChannelType.Group; + if (flag) + { + this.mCheckbox[i].ForceSetFlag(true); + break; + } + } + } + + public void ProcessGroupMsg() + { + bool flag = base.IsVisible() && this.activeChannelType == ChatChannelType.Group; + if (flag) + { + bool flag2 = this.groupState == XChatView.ChatGroupState.GROUPS; + if (flag2) + { + this.RefreshGrouplist(); + } + else + { + this.JumpToGrouplist(null); + } + } + } + + private void JumpToGrouplist(IXUISprite spr) + { + this.ShowGroup(XChatView.ChatGroupState.GROUPS); + this.RefreshGrouplist(); + } + + public void JumpToGroupChat(IXUISprite spr) + { + this.groupState = XChatView.ChatGroupState.CHATS; + this.ShowGroup(XChatView.ChatGroupState.CHATS); + this.ShowMore(false); + this.RefreshLoopScroll(ChatChannelType.Group); + } + + private void OnMoreClick(IXUISprite spr) + { + bool flag = base.uiBehaviour.m_sprGroupQuit.IsVisible(); + this.ShowMore(!flag); + } + + private void ShowMore(bool show) + { + GroupChatDocument specificDocument = XDocuments.GetSpecificDocument(GroupChatDocument.uuID); + bool flag = false; + bool flag2 = specificDocument.currGroup != null; + if (flag2) + { + flag = specificDocument.currGroup.captain; + } + base.uiBehaviour.m_sprMember.gameObject.SetActive(show && flag); + base.uiBehaviour.m_sprList.gameObject.SetActive(show && !flag); + base.uiBehaviour.m_sprGroupQuit.gameObject.SetActive(show); + } + + private void OnMemberClick(IXUISprite spr) + { + DlgBase.singleton.SetVisible(true, true); + } + + private void OnGroupClearClick(IXUISprite spr) + { + GroupChatDocument specificDocument = XDocuments.GetSpecificDocument(GroupChatDocument.uuID); + specificDocument.ReqClearGroup(); + bool flag = specificDocument.groups != null; + if (flag) + { + specificDocument.groups.Clear(); + } + this.RefreshGrouplist(); + } + + private void OnListClick(IXUISprite spr) + { + DlgBase.singleton.SetVisible(true, true); + } + + private bool IsGroupWith(ChatInfo data) + { + bool flag = DlgBase.singleton.IsVisible() && DlgBase.singleton.activeChannelType == ChatChannelType.Group && this._friendState == XChatView.ChatFriendState.CHATS; + return flag && data.group != null && this.ChatGroupId == data.group.groupchatID; + } + + public bool HasNewGroupMsg() + { + this._doc = XDocuments.GetSpecificDocument(XChatDocument.uuID); + List chatInfoList = this._doc.GetChatInfoList(ChatChannelType.Group); + bool flag = chatInfoList != null; + if (flag) + { + for (int i = 0; i < chatInfoList.Count; i++) + { + bool flag2 = !this.IsGroupWith(chatInfoList[i]) && !chatInfoList[i].isUIShowed && !chatInfoList[i].isSelfSender; + if (flag2) + { + return true; + } + } + } + return false; + } + + public bool HasRedpointGroupMsg(ulong groupid) + { + List groupChatInfoList = this._doc.GetGroupChatInfoList(DlgBase.singleton.ChatGroupId); + bool flag = groupChatInfoList != null; + if (flag) + { + for (int i = 0; i < groupChatInfoList.Count; i++) + { + bool flag2 = !groupChatInfoList[i].isUIShowed && !groupChatInfoList[i].isSelfSender; + if (flag2) + { + return true; + } + } + } + return false; + } + + private void OnGroupBindClick(IXUISprite spr) + { + DlgBase.singleton.SetVisible(true, true); + DlgBase.singleton.SetSingleButtonMode(false); + string @string = XStringDefineProxy.GetString("CHAT_CLEAR"); + string string2 = XStringDefineProxy.GetString(XStringDefine.COMMON_OK); + string string3 = XStringDefineProxy.GetString(XStringDefine.COMMON_CANCEL); + DlgBase.singleton.SetLabelsWithSymbols(@string, string2, string3); + DlgBase.singleton.SetModalCallback(new ButtonClickEventHandler(this.OnOKClearGroups), null); + } + + private bool OnOKClearGroups(IXUIButton btn) + { + return true; + } + + public void OnGroupQuitClick(IXUISprite spr) + { + GroupChatDocument specificDocument = XDocuments.GetSpecificDocument(GroupChatDocument.uuID); + CBrifGroupInfo currGroup = specificDocument.currGroup; + bool flag = currGroup == null; + if (!flag) + { + bool captain = currGroup.captain; + DlgBase.singleton.SetVisible(true, true); + DlgBase.singleton.SetSingleButtonMode(false); + string key = captain ? "CHAT_GROUP_QUIT1" : "CHAT_GROUP_QUIT2"; + string @string = XStringDefineProxy.GetString(key); + string string2 = XStringDefineProxy.GetString(XStringDefine.COMMON_OK); + string string3 = XStringDefineProxy.GetString(XStringDefine.COMMON_CANCEL); + DlgBase.singleton.SetLabelsWithSymbols(@string, string2, string3); + DlgBase.singleton.SetModalCallback(new ButtonClickEventHandler(this.OnModalDlgOK), null); + } + } + + private void OnGroupBackClick(IXUISprite spr) + { + this.JumpToGrouplist(spr); + } + + private void OnGroupCreateClick(IXUISprite spr) + { + DlgBase.singleton.SetVisible(true, true); + DlgBase.singleton.SetCallBack(new CreatechatGroupCall(this.OnCreateGroup)); + } + + private bool OnCreateGroup(string groupname) + { + GroupChatDocument specificDocument = XDocuments.GetSpecificDocument(GroupChatDocument.uuID); + return specificDocument.ReqCreateGroupChat(groupname, 1u); + } + + private bool OnModalDlgOK(IXUIButton btn) + { + DlgBase.singleton.SetVisible(false, true); + this.groupState = XChatView.ChatGroupState.GROUPS; + GroupChatDocument specificDocument = XDocuments.GetSpecificDocument(GroupChatDocument.uuID); + CBrifGroupInfo currGroup = specificDocument.currGroup; + bool flag = currGroup == null; + if (flag) + { + XSingleton.singleton.AddErrorLog("quit group id is null", null, null, null, null, null); + } + specificDocument.ReqQuitGroup(currGroup.id); + return true; + } + + private void RegistFriendEvent() + { + base.uiBehaviour.m_sprFriendAdd.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnAddFriendClick)); + base.uiBehaviour.m_sprFriendBack.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.JumpToFriends)); + base.uiBehaviour.m_sprFriendClear.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnClearFriendClick)); + base.uiBehaviour.m_sprFriendChat.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.ShowFriendsUI)); + } + + private void RefreshFriendList() + { + List friends = this._doc.FetchFriendsIcons(); + this.RefreshFriendsScroll(friends); + } + + public void RefreshFriendUI() + { + this.RefreshFriendUI(this.friendState); + } + + public void RefreshFriendUI(XChatView.ChatFriendState _state) + { + bool flag = this.ChatFriendId == 0UL || this._doc.ChatFriendList.Count <= 0 || _state == XChatView.ChatFriendState.FRIENDS; + if (flag) + { + this.friendState = XChatView.ChatFriendState.FRIENDS; + this.RefreshFriendList(); + } + else + { + this.friendState = XChatView.ChatFriendState.CHATS; + this.RefreshLoopScroll(ChatChannelType.Friends); + } + } + + private void OnAddFriendClick(IXUISprite spr) + { + DlgBase.singleton.AddFriendById(this.ChatFriendId); + } + + private void OnClearFriendClick(IXUISprite spr) + { + DlgBase.singleton.SetVisible(true, true); + DlgBase.singleton.SetSingleButtonMode(false); + DlgBase.singleton.uiBehaviour.m_OKButton.ID = 0UL; + string @string = XStringDefineProxy.GetString("CHAT_CLEAR"); + string string2 = XStringDefineProxy.GetString(XStringDefine.COMMON_OK); + string string3 = XStringDefineProxy.GetString(XStringDefine.COMMON_CANCEL); + DlgBase.singleton.SetLabelsWithSymbols(@string, string2, string3); + DlgBase.singleton.SetModalCallback(new ButtonClickEventHandler(this.OnOKClearFriends), null); + } + + private bool OnOKClearFriends(IXUIButton btn) + { + ulong id = btn.ID; + this.OnSendClearFriend(id); + return true; + } + + public void OnSendClearFriend(ulong uid) + { + this.ChatFriendId = 0UL; + this._doc.ClearFriendMsg(uid); + this.RefreshFriendUI(XChatView.ChatFriendState.FRIENDS); + this.ShowTabFriendRed(); + DlgBase.singleton.SetVisible(false, true); + RpcC2M_ClearPrivateChatList rpcC2M_ClearPrivateChatList = new RpcC2M_ClearPrivateChatList(); + rpcC2M_ClearPrivateChatList.oArg.roleid = uid; + XSingleton.singleton.Send(rpcC2M_ClearPrivateChatList); + } + + private void ShowFriendsUI(IXUISprite spr) + { + bool flag = !XSingleton.singleton.IsSystemOpened(XSysDefine.XSys_Friends); + if (flag) + { + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("FRIEND_UI_LOCK"), "fece00"); + } + else + { + XSingleton.singleton.OpenSystem(XSysDefine.XSys_Friends, 0UL); + } + } + + private void JumpToFriends(IXUISprite spr) + { + this.friendState = XChatView.ChatFriendState.FRIENDS; + this.RefreshFriendUI(); + this.ShowFriend(true); + } + + public void JumpToChats(IXUISprite spr) + { + this.friendState = XChatView.ChatFriendState.CHATS; + this.ChatFriendId = spr.ID; + this.ResetRedpointMsg(DlgBase.singleton.ChatFriendId); + this.ShowTabFriendRed(); + this.ShowFriend(false); + this.RefreshLoopScroll(ChatChannelType.Friends); + } + + private void ShowFriend(bool isFriends) + { + ulong chatFriendId = DlgBase.singleton.ChatFriendId; + bool flag = chatFriendId > 0UL && DlgBase.singleton.IsMyFriend(chatFriendId); + this.m_uiBehaviour.m_friendView.gameobject.SetActive(isFriends); + this.m_uiBehaviour.m_loopView.gameobject.SetActive(!isFriends); + base.uiBehaviour.m_groupView.gameobject.SetActive(false); + base.uiBehaviour.m_TextBoard.SetVisible(!isFriends); + this.m_uiBehaviour.m_sprFriendAdd.SetVisible(!isFriends && !flag); + this.m_uiBehaviour.m_sprFriendClear.SetVisible(isFriends && this._doc.ChatFriendList.Count > 0); + this.m_uiBehaviour.m_sprFriendBack.SetVisible(!isFriends); + this.m_uiBehaviour.m_lblFriendTip.SetVisible(!isFriends); + this.m_uiBehaviour.m_sprFriendChat.SetVisible(isFriends && this._doc.ChatFriendList.Count <= 0); + bool flag2 = !isFriends; + if (flag2) + { + ChatFriendData currChatFriendData = this.UIOP.CurrChatFriendData; + bool flag3 = currChatFriendData != null; + if (flag3) + { + this.m_uiBehaviour.m_lblFriendTip.SetText(XStringDefineProxy.GetString("CHAT_WITH", new object[] + { + currChatFriendData.name + })); + } + } + } + + public void ResetRedpointMsg(ulong uid) + { + bool flag = this._doc == null; + if (flag) + { + this._doc = XDocuments.GetSpecificDocument(XChatDocument.uuID); + } + List friendChatInfoList = this._doc.GetFriendChatInfoList(uid); + for (int i = 0; i < friendChatInfoList.Count; i++) + { + friendChatInfoList[i].isUIShowed = true; + } + for (int j = 0; j < this._doc.ChatFriendList.Count; j++) + { + bool flag2 = this._doc.ChatFriendList[j].roleid == uid; + if (flag2) + { + this._doc.ChatFriendList[j].hasOfflineRead = false; + break; + } + } + } + + public bool HasRedpointMsg(ulong uid) + { + this._doc = XDocuments.GetSpecificDocument(XChatDocument.uuID); + List chatFriendList = this._doc.ChatFriendList; + for (int i = 0; i < chatFriendList.Count; i++) + { + bool flag = chatFriendList[i].roleid == uid && chatFriendList[i].hasOfflineRead; + if (flag) + { + return true; + } + } + List friendChatInfoList = this._doc.GetFriendChatInfoList(uid); + for (int j = 0; j < friendChatInfoList.Count; j++) + { + bool flag2 = !friendChatInfoList[j].isUIShowed && !friendChatInfoList[j].isSelfSender; + if (flag2) + { + return true; + } + } + return false; + } + + private bool IsChatWith(ChatInfo data) + { + bool flag = DlgBase.singleton.IsVisible() && DlgBase.singleton.activeChannelType == ChatChannelType.Friends && this._friendState == XChatView.ChatFriendState.CHATS; + return flag && (this.ChatFriendId == data.mReceiverId || this.ChatFriendId == data.mSenderId); + } + + private bool IsInFriendsList(ChatInfo data, List friends) + { + for (int i = 0; i < friends.Count; i++) + { + ulong roleid = friends[i].roleid; + ulong num = data.isSelfSender ? data.mReceiverId : data.mSenderId; + bool flag = roleid == num; + if (flag) + { + return true; + } + } + return false; + } + + public bool HasNewFriendMsg() + { + this._doc = XDocuments.GetSpecificDocument(XChatDocument.uuID); + List chatFriendList = this._doc.ChatFriendList; + for (int i = 0; i < chatFriendList.Count; i++) + { + bool hasOfflineRead = chatFriendList[i].hasOfflineRead; + if (hasOfflineRead) + { + return true; + } + } + List chatInfoList = this._doc.GetChatInfoList(ChatChannelType.Friends); + bool flag = chatInfoList != null; + if (flag) + { + for (int j = 0; j < chatInfoList.Count; j++) + { + bool flag2 = !this.IsChatWith(chatInfoList[j]) && !chatInfoList[j].isUIShowed && !chatInfoList[j].isSelfSender && this.IsInFriendsList(chatInfoList[j], chatFriendList); + if (flag2) + { + return true; + } + } + } + return false; + } + + private void LoopInit() + { + GameObject tpl = base.uiBehaviour.m_loopView.GetTpl(); + bool flag = tpl != null && tpl.GetComponent() == null; + if (flag) + { + tpl.AddComponent(); + } + tpl = base.uiBehaviour.m_systemView.GetTpl(); + bool flag2 = tpl != null && tpl.GetComponent() == null; + if (flag2) + { + tpl.AddComponent(); + } + tpl = base.uiBehaviour.m_friendView.GetTpl(); + bool flag3 = tpl != null && tpl.GetComponent() == null; + if (flag3) + { + tpl.AddComponent(); + } + tpl = base.uiBehaviour.m_groupView.GetTpl(); + bool flag4 = tpl != null && tpl.GetComponent() == null; + if (flag4) + { + tpl.AddComponent(); + } + } + + private void SetLoopActive(ChatChannelType type) + { + base.uiBehaviour.m_systemView.gameobject.SetActive(type == ChatChannelType.System); + bool flag = type != ChatChannelType.Friends; + if (flag) + { + base.uiBehaviour.m_loopView.gameobject.SetActive(type != ChatChannelType.System); + base.uiBehaviour.m_friendView.gameobject.SetActive(false); + base.uiBehaviour.m_groupView.gameobject.SetActive(false); + bool flag2 = type != ChatChannelType.System; + if (flag2) + { + base.uiBehaviour.m_loopView.ResetScroll(); + } + } + float num = (float)((type == ChatChannelType.Friends || type == ChatChannelType.Group || this.IsVoicebarShow()) ? -24 : 0); + base.uiBehaviour.m_tranOffset.localPosition = new Vector3(0f, num, 0f); + } + + public void RefreshLoopScroll(ChatChannelType type) + { + bool flag = base.IsVisible(); + if (flag) + { + bool flag2 = type == ChatChannelType.Friends; + if (flag2) + { + bool flag3 = this.friendState == XChatView.ChatFriendState.CHATS; + if (flag3) + { + List friendChatInfoList = this._doc.GetFriendChatInfoList(DlgBase.singleton.ChatFriendId); + base.uiBehaviour.m_loopView.SetClipSize(new Vector2(434f, 504f)); + this.RefreshLoopScroll(type, friendChatInfoList); + this.cacheChannelType = type; + } + else + { + this.friendState = XChatView.ChatFriendState.FRIENDS; + this.RefreshFriendList(); + } + } + else + { + bool flag4 = type == ChatChannelType.Group; + if (flag4) + { + bool flag5 = this.groupState == XChatView.ChatGroupState.CHATS; + if (flag5) + { + List groupChatInfoList = this._doc.GetGroupChatInfoList(DlgBase.singleton.ChatGroupId); + base.uiBehaviour.m_loopView.SetClipSize(new Vector2(434f, 504f)); + this.RefreshLoopScroll(type, groupChatInfoList); + this.cacheChannelType = type; + } + else + { + this.groupState = XChatView.ChatGroupState.GROUPS; + } + } + else + { + bool flag6 = type == ChatChannelType.System; + if (flag6) + { + List chatInfoList = this._doc.GetChatInfoList(type); + this.RefreshSystemScroll(chatInfoList); + } + else + { + List chatInfoList2 = this._doc.GetChatInfoList(type); + base.uiBehaviour.m_loopView.SetClipSize(this.IsVoicebarShow() ? new Vector2(434f, 504f) : new Vector2(434f, 544f)); + this.RefreshLoopScroll(type, chatInfoList2); + this.cacheChannelType = type; + } + } + } + } + } + + private void RefreshLoopScroll(ChatChannelType type, List chats) + { + List list = new List(); + bool flag = chats != null; + if (flag) + { + for (int i = 0; i < chats.Count; i++) + { + chats[i].LoopID = XSingleton.singleton.XHash(XSingleton.singleton.StringCombine(chats[i].mContent, chats[i].mSenderPaymemberid.ToString())); + list.Add(chats[i]); + } + } + this.cacheLoopList = list; + bool flag2 = base.uiBehaviour.m_loopView.IsScrollLast() || this.cacheChannelType != type || this.cacheChannelType == ChatChannelType.Friends || this.cacheChannelType == ChatChannelType.Group; + if (flag2) + { + bool activeInHierarchy = base.uiBehaviour.m_loopView.gameobject.activeInHierarchy; + if (activeInHierarchy) + { + base.uiBehaviour.m_loopView.Init(list, new DelegateHandler(this.RefreshItem), new Action(this.OnDragFinish), (list.Count > 5) ? 1 : 0, false); + } + } + } + + private void OnDragFinish() + { + base.uiBehaviour.m_loopView.Init(this.cacheLoopList, new DelegateHandler(this.RefreshItem), new Action(this.OnDragFinish), (this.cacheLoopList.Count > 5) ? 1 : 0, false); + } + + private void RefreshFriendsScroll(List friends) + { + List list = new List(); + bool flag = friends != null; + if (flag) + { + for (int i = 0; i < friends.Count; i++) + { + list.Add(new ChatFriendData + { + isfriend = friends[i].isfriend, + name = friends[i].name, + powerpoint = friends[i].powerpoint, + profession = friends[i].profession, + roleid = friends[i].roleid, + msgtime = friends[i].msgtime, + viplevel = friends[i].viplevel, + setid = friends[i].setid, + LoopID = XSingleton.singleton.XHash(friends[i].name + Time.unscaledTime.ToString()) + }); + } + } + base.uiBehaviour.m_friendView.Init(list, new DelegateHandler(this.RefreshFriendItem), null, 0, false); + } + + private void RefreshGrouplist() + { + GroupChatDocument specificDocument = XDocuments.GetSpecificDocument(GroupChatDocument.uuID); + HashSet groups = specificDocument.groups; + bool flag = groups != null; + if (flag) + { + List list = new List(); + foreach (CBrifGroupInfo item in groups) + { + list.Add(item); + } + list.Sort(new Comparison(this.SortGroup)); + base.uiBehaviour.m_groupView.Init(list, new DelegateHandler(this.RefreshGroupItem), null, 0, true); + } + } + + private int SortGroup(LoopItemData x, LoopItemData y) + { + CBrifGroupInfo cbrifGroupInfo = x as CBrifGroupInfo; + CBrifGroupInfo cbrifGroupInfo2 = y as CBrifGroupInfo; + return cbrifGroupInfo.createTime.CompareTo(cbrifGroupInfo2.createTime); + } + + private void RefreshSystemScroll(List chats) + { + List list = new List(); + bool flag = chats != null; + if (flag) + { + for (int i = 0; i < chats.Count; i++) + { + chats[i].LoopID = XSingleton.singleton.XHash(chats[i].mContent); + list.Add(chats[i]); + } + } + base.uiBehaviour.m_systemView.Init(list, new DelegateHandler(this.RefreshSystemItem), null, (list.Count > 5) ? 1 : 0, false); + } + + private void RefreshItem(ILoopItemObject item, LoopItemData data) + { + ChatInfo chatInfo = data as ChatInfo; + bool flag = chatInfo != null; + if (flag) + { + item.GetObj().GetComponent().Refresh(chatInfo); + } + else + { + XSingleton.singleton.AddErrorLog("info is nil", null, null, null, null, null); + } + } + + private void RefreshFriendItem(ILoopItemObject item, LoopItemData data) + { + ChatFriendData chatFriendData = data as ChatFriendData; + bool flag = chatFriendData != null; + if (flag) + { + item.GetObj().GetComponent().Refresh(chatFriendData); + } + else + { + XSingleton.singleton.AddErrorLog("friend info is null", null, null, null, null, null); + } + } + + private void RefreshGroupItem(ILoopItemObject item, LoopItemData data) + { + CBrifGroupInfo cbrifGroupInfo = data as CBrifGroupInfo; + bool flag = cbrifGroupInfo != null; + if (flag) + { + item.GetObj().GetComponent().Refresh(cbrifGroupInfo); + } + else + { + XSingleton.singleton.AddErrorLog("group info is null", null, null, null, null, null); + } + } + + private void RefreshSystemItem(ILoopItemObject item, LoopItemData data) + { + ChatInfo chatInfo = data as ChatInfo; + bool flag = chatInfo != null; + if (flag) + { + item.GetObj().GetComponent().Refresh(chatInfo); + } + else + { + XSingleton.singleton.AddErrorLog("system info is nil", null, null, null, null, null); + } + } + + private void InitTabs() + { + for (int i = 0; i < 11; i++) + { + int num = (int)this.showChannelIds[i]; + Transform transform = base.uiBehaviour.transform.Find("Bg/tabs/tab" + num); + this.mTransTab[i] = transform; + IXUICheckBox ixuicheckBox = transform.Find("template/Bg").GetComponent("XUICheckBox") as IXUICheckBox; + this.mCheckbox[i] = ixuicheckBox; + } + } + + private void ResetTabs() + { + for (int i = 0; i < this.mCheckbox.Length; i++) + { + this.mCheckbox[i].bChecked = false; + } + } + + private void SetDepth() + { + int num = 16; + XTeamDocument specificDocument = XDocuments.GetSpecificDocument(XTeamDocument.uuID); + bool flag = specificDocument != null && specificDocument.MyTeamView != null && specificDocument.MyTeamView.IsVisible(); + if (flag) + { + num = 13; + } + base.uiBehaviour.m_panelText.SetDepth(num + 1); + base.uiBehaviour.m_panelRoot.SetDepth(num); + base.uiBehaviour.m_loopView.SetDepth(num + 1); + base.uiBehaviour.m_friendView.SetDepth(num + 1); + base.uiBehaviour.m_systemView.SetDepth(num + 1); + base.uiBehaviour.m_panelSubMenu.SetDepth(num + 2); + } + + private void ShowTextboard(ChatChannelType channel) + { + bool flag = channel == ChatChannelType.World && !this.ChatDoc.CheckLevelLimit(channel); + if (flag) + { + base.uiBehaviour.m_TextBoard.SetVisible(false); + base.uiBehaviour.m_LimitBoard.SetVisible(true); + } + else + { + base.uiBehaviour.m_LimitBoard.SetVisible(false); + base.uiBehaviour.m_TextBoard.SetVisible(channel != ChatChannelType.System); + } + } + + private void ShowTabs() + { + int num = 0; + IXUISprite ixuisprite = base.uiBehaviour.transform.Find("Bg/tabs/tab1").GetComponent("XUISprite") as IXUISprite; + int spriteHeight = ixuisprite.spriteHeight; + int i = 0; + while (i < 11) + { + ChatChannelType chatChannelType = this.showChannelIds[i]; + Transform transform = base.uiBehaviour.transform.Find("Bg/tabs/tab" + (int)chatChannelType); + bool flag = transform != null; + if (flag) + { + bool flag2 = chatChannelType == ChatChannelType.Guild; + if (flag2) + { + bool flag3 = this.CheckGuildOpen(); + this.mCheckbox[i].ForceSetFlag(false); + transform.gameObject.SetActive(flag3); + bool flag4 = !flag3 && this.activeChannelType == ChatChannelType.Guild; + if (flag4) + { + this.activeChannelType = ChatChannelType.World; + } + bool flag5 = !flag3; + if (flag5) + { + goto IL_4B2; + } + } + else + { + bool flag6 = chatChannelType == ChatChannelType.Team; + if (flag6) + { + bool flag7 = this.CheckTeamOpen(); + this.mCheckbox[i].ForceSetFlag(false); + transform.gameObject.SetActive(flag7); + bool flag8 = !flag7 && this.activeChannelType == ChatChannelType.Team; + if (flag8) + { + this.activeChannelType = ChatChannelType.World; + } + bool flag9 = !flag7; + if (flag9) + { + goto IL_4B2; + } + } + else + { + bool flag10 = chatChannelType == ChatChannelType.Friends; + if (flag10) + { + transform.gameObject.SetActive(!this.isFighting); + bool isFighting = this.isFighting; + if (isFighting) + { + bool flag11 = this.activeChannelType == ChatChannelType.Friends; + if (flag11) + { + this.activeChannelType = ChatChannelType.World; + } + goto IL_4B2; + } + } + else + { + bool flag12 = chatChannelType == ChatChannelType.Spectate; + if (flag12) + { + bool flag13 = DlgBase.singleton.IsVisible(); + this.mCheckbox[i].ForceSetFlag(false); + transform.gameObject.SetActive(flag13); + bool flag14 = !flag13; + if (flag14) + { + bool flag15 = this.activeChannelType == ChatChannelType.Spectate; + if (flag15) + { + this.activeChannelType = ChatChannelType.World; + } + goto IL_4B2; + } + } + else + { + bool flag16 = chatChannelType == ChatChannelType.Curr; + if (flag16) + { + bool flag17 = !DlgBase.singleton.IsVisible(); + bool flag18 = !flag17; + if (flag18) + { + this.mCheckbox[i].bChecked = false; + } + transform.gameObject.SetActive(flag17); + bool flag19 = !flag17; + if (flag19) + { + bool flag20 = this.activeChannelType == ChatChannelType.Curr; + if (flag20) + { + this.activeChannelType = ChatChannelType.World; + } + goto IL_4B2; + } + } + else + { + bool flag21 = chatChannelType == ChatChannelType.Partner; + if (flag21) + { + bool flag22 = this.CheckDragonGuildOpen(); + this.mCheckbox[i].ForceSetFlag(false); + transform.gameObject.SetActive(flag22); + bool flag23 = !flag22; + if (flag23) + { + bool flag24 = this.activeChannelType == ChatChannelType.Partner; + if (flag24) + { + this.activeChannelType = ChatChannelType.World; + } + goto IL_4B2; + } + } + else + { + bool flag25 = chatChannelType == ChatChannelType.Battle; + if (flag25) + { + bool flag26 = XSingleton.singleton.CurrentStage.Stage == EXStage.World && this.ChatDoc.GetBattleRaw().battle == 1; + bool flag27 = !flag26; + if (flag27) + { + this.mCheckbox[i].bChecked = false; + } + transform.gameObject.SetActive(flag26); + bool flag28 = !flag26; + if (flag28) + { + bool flag29 = this.activeChannelType == ChatChannelType.Battle; + if (flag29) + { + this.activeChannelType = ChatChannelType.World; + } + goto IL_4B2; + } + } + else + { + bool flag30 = chatChannelType == ChatChannelType.Broadcast; + if (flag30) + { + this.mCheckbox[i].ForceSetFlag(false); + XOptionsDocument specificDocument = XDocuments.GetSpecificDocument(XOptionsDocument.uuID); + int value = specificDocument.GetValue(XOptionsDefine.OD_RADIO); + int @int = XSingleton.singleton.GetInt("RadioChatOpen"); + bool flag31 = (long)@int <= (long)((ulong)XSingleton.singleton.XPlayerData.Level); + bool flag32 = value == 1 && flag31; + transform.gameObject.SetActive(flag32); + bool flag33 = !flag32; + if (flag33) + { + bool flag34 = this.activeChannelType == ChatChannelType.Broadcast; + if (flag34) + { + this.activeChannelType = ChatChannelType.World; + } + goto IL_4B2; + } + } + else + { + bool flag35 = chatChannelType == ChatChannelType.Group; + if (flag35) + { + this.mCheckbox[i].ForceSetFlag(false); + int int2 = XSingleton.singleton.GetInt("GroupChatOpen"); + bool flag36 = (long)int2 <= (long)((ulong)XSingleton.singleton.XPlayerData.Level); + bool flag37 = flag36; + transform.gameObject.SetActive(flag37); + bool flag38 = !flag37; + if (flag38) + { + bool flag39 = this.activeChannelType == ChatChannelType.Group; + if (flag39) + { + this.activeChannelType = ChatChannelType.World; + } + goto IL_4B2; + } + } + } + } + } + } + } + } + } + } + transform.transform.localPosition = new Vector3(0f, (float)(272 - spriteHeight * num), 0f); + num++; + } + IL_4B2: + i++; + continue; + goto IL_4B2; + } + } + + public void ShowBtns() + { + bool flag = XSingleton.singleton.IsSystemOpened(XSysDefine.XSys_Mail); + base.uiBehaviour.m_sprMail.SetVisible(!this.isFighting && flag); + base.uiBehaviour.m_sprSet.SetVisible(!this.isFighting); + } + + public void ShowMailRedpoint() + { + bool flag = base.IsVisible(); + if (flag) + { + bool sysRedPointState = XSingleton.singleton.GetSysRedPointState(XSysDefine.XSys_Mail); + base.uiBehaviour.m_sprMailRedpoint.SetVisible(sysRedPointState); + } + bool flag2 = DlgBase.singleton.IsVisible(); + if (flag2) + { + DlgBase.singleton.ShowMailRedpoint(); + } + } + + public void ShowTabFriendRed() + { + bool flag = this.HasNewFriendMsg(); + bool flag2 = DlgBase.singleton.IsLoaded(); + if (flag2) + { + ChatChannelType chatChannelType = ChatChannelType.Friends; + Transform transform = base.uiBehaviour.transform.Find("Bg/tabs/tab" + (int)chatChannelType); + GameObject gameObject = transform.Find("template/Bg/redpoint").gameObject; + bool flag3 = gameObject != null; + if (flag3) + { + gameObject.SetActive(flag); + } + } + bool flag4 = DlgBase.singleton.IsVisible(); + if (flag4) + { + DlgBase.singleton.SetRedpoint(flag); + } + } + + private bool CheckTeamOpen() + { + XTeamDocument specificDocument = XDocuments.GetSpecificDocument(XTeamDocument.uuID); + bool flag = specificDocument.MyTeam == null || specificDocument.MyTeam.teamBrief.teamID == 0; + return !flag; + } + + public bool CheckGuildOpen() + { + XGuildDocument specificDocument = XDocuments.GetSpecificDocument(XGuildDocument.uuID); + return specificDocument.bInGuild; + } + + public bool CheckDragonGuildOpen() + { + XDragonGuildDocument specificDocument = XDocuments.GetSpecificDocument(XDragonGuildDocument.uuID); + return specificDocument.IsInDragonGuild(); + } + + public void RegistLinkSend(string content, Action onSend) + { + this.mLinkContent = content; + this.mInputType = InputUIType.Linked; + this.mOnSend = onSend; + XSingleton.singleton.AddLog("length: ", content.Length.ToString(), " content:", content, null, null, XDebugColor.XDebug_None); + base.uiBehaviour.m_Input.SetText(content); + } + + private void DispatchLinkClick() + { + bool flag = this.mOnSend != null; + if (flag) + { + this.mOnSend(); + } + this.mInputType = InputUIType.Normal; + this.ResetInput(); + } + + private void OnUIInputChanged(IXUIInput input) + { + bool flag = this.mInputType == InputUIType.Linked; + if (flag) + { + bool flag2 = input.GetText().Length != this.mLinkContent.Length; + if (flag2) + { + this.mInputType = InputUIType.Normal; + this.ResetInput(); + } + } + } + + private void OnUIInputSubmit(IXUIInput input) + { + bool flag = (int) Application.platform == 7; + if (flag) + { + this.DoSendTextChat(null); + } + } + + protected override void Init() + { + this._doc = XDocuments.GetSpecificDocument(XChatDocument.uuID); + this._doc.ChatView = this; + this.InitTabs(); + for (int i = 0; i < 11; i++) + { + ulong id = (ulong)((long)this.showChannelIds[i]); + this.mCheckbox[i].RegisterOnCheckEventHandler(new CheckBoxOnCheckEventHandler(this.SelectChatChannel)); + this.mCheckbox[i].ID = id; + bool flag = this.showChannelIds[i] == this.activeChannelType; + if (flag) + { + this.mCheckbox[i].bChecked = true; + } + } + this.LoopInit(); + XOptionsView singleton = DlgBase.singleton; + singleton.OnOptionClose = (Action)Delegate.Combine(singleton.OnOptionClose, new Action(this.RefreshVoiceBarStatus)); + this.mInputType = InputUIType.Normal; + this.Inited = true; + } + + public override void RegisterEvent() + { + base.uiBehaviour.m_ChangeToVoice.RegisterPressEventHandler(new ButtonPressEventHandler(this.OnVoiceChatButton)); + base.uiBehaviour.m_ChangeToVoice.RegisterDragEventHandler(new ButtonDragEventHandler(this.OnVoiceButtonDrag)); + base.uiBehaviour.m_DoSendChat.RegisterClickEventHandler(new ButtonClickEventHandler(this.DoSendTextChat)); + base.uiBehaviour.m_Close.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnCloseClicked)); + base.uiBehaviour.m_btnAdd.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnBtmAddClick)); + base.uiBehaviour.m_GetFlowerBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnGetFlower)); + this.RegistFriendEvent(); + this.RegistGroupEvent(); + base.uiBehaviour.m_sprMail.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnMailClick)); + base.uiBehaviour.m_sprSet.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnSetClick)); + base.uiBehaviour.m_sprXinyue.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnXinyueClick)); + base.uiBehaviour.m_sprFriend.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnFriendsClick)); + base.uiBehaviour.m_chxAutoVoice.RegisterOnCheckEventHandler(new CheckBoxOnCheckEventHandler(this.OnAutoVoiceClick)); + base.uiBehaviour.m_Input.RegisterChangeEventHandler(new InputChangeEventHandler(this.OnUIInputChanged)); + base.uiBehaviour.m_Input.RegisterSubmitEventHandler(new InputSubmitEventHandler(this.OnUIInputSubmit)); + base.uiBehaviour.m_sprTq.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnMemberPrivilegeClick)); + } + + private void OnMemberPrivilegeClick(IXUISprite btn) + { + bool isFighting = this.isFighting; + if (!isFighting) + { + DlgBase.singleton.CheckActiveMemberPrivilege(MemberPrivilege.KingdomPrivilege_Court); + } + } + + protected override void OnShow() + { + base.OnShow(); + this.SetDepth(); + this.cacheShow = true; + this.ShowTabs(); + this.ShowBtns(); + this.ShowMailRedpoint(); + bool flag = this.activeChannelType == ChatChannelType.Friends; + if (flag) + { + DlgBase.singleton.QueryRoleState(); + } + this.DoSelectChannel(this.activeChannelType); + this.SwitchTab(this.activeChannelType); + XSingleton.singleton.SetAutoPlayChannel(this.activeChannelType); + this.ResetInput(); + base.uiBehaviour.m_sprXinyueRed.SetVisible(XSingleton.singleton.GetSysRedPointStateConsiderBlock(XSysDefine.XSys_GC_XiaoYueGuanJia)); + base.uiBehaviour.m_Flower.SetActive(false); + bool flag2 = DlgBase.singleton.IsVisible(); + if (flag2) + { + DlgBase.singleton.SetRelatedDlg(this); + } + } + + protected override void OnHide() + { + this.ResetTabs(); + this.mInputType = InputUIType.Normal; + this.mOnSend = null; + XSingleton.singleton.SetAutoPlayChannel(ChatChannelType.DEFAULT); + bool flag = DlgBase.singleton.IsVisible(); + if (flag) + { + DlgBase.singleton.SetRelatedDlg(null); + } + bool flag2 = DlgBase.singleton.IsVisible(); + if (flag2) + { + DlgBase.singleton.SetVisible(false, true); + } + base.OnHide(); + } + + protected override void OnUnload() + { + this._doc = null; + base.OnUnload(); + } + + public void TryCloseChat(IXUIDlg dlg) + { + bool flag = base.IsVisible() && dlg.fileName != this.fileName && dlg.isHideChat; + if (flag) + { + DlgBase.singleton.SetVisible(false, true); + } + } + + public void TryShowChat(IXUIDlg dlg) + { + List showedUI = XSingleton.singleton.GetShowedUI(); + bool flag = !XSingleton.singleton.IsUIShowed() && showedUI.Count < 3; + if (flag) + { + bool flag2 = dlg.fileName != this.fileName && this.cacheShow; + if (flag2) + { + this.SetVisible(true, true); + } + } + bool flag3 = base.IsVisible(); + if (flag3) + { + this.ShowMailRedpoint(); + } + } + + private void DoChatWith(ulong friendId) + { + this.ChatFriendId = friendId; + this.activeChannelType = ChatChannelType.Friends; + bool flag = !base.IsVisible(); + if (flag) + { + this.SetVisibleWithAnimation(true, new DlgBase.OnAnimationOver(this.DoChatRefresh)); + } + else + { + this.DoChatRefresh(); + } + } + + public void DoChatRefresh() + { + ChatFriendData chatFriendData = this._doc.FindFriendData(this.ChatFriendId); + bool flag = chatFriendData != null; + if (flag) + { + chatFriendData.msgtime = DateTime.Now; + this.SelectChatFriends(this.ChatFriendId); + } + } + + public void SelectChatFriends(object obj) + { + this.ChatFriendId = (ulong)obj; + this.activeChannelType = ChatChannelType.Friends; + this.SwitchTab(ChatChannelType.Friends); + this.RefreshFriendUI(XChatView.ChatFriendState.CHATS); + } + + public void SelectChatTeam() + { + this.SwitchTab(ChatChannelType.Team); + } + + public void ShowMyChatVoiceInfo(ChatVoiceInfo info) + { + this.mChatInfo = new ChatInfo(); + bool isLocalPath = info.isLocalPath; + if (isLocalPath) + { + this.mChatInfo.mChannelId = this.activeChannelType; + } + else + { + this.mChatInfo.mChannelId = info.channel + 1; + } + this.mChatInfo.voice = info; + this.mChatInfo.mSenderId = info.sendIndexId; + this.mChatInfo.mSenderName = info.sendName; + this.mChatInfo.mChatType = ChatType.SelfVoice; + XRechargeDocument specificDocument = XDocuments.GetSpecificDocument(XRechargeDocument.uuID); + this.mChatInfo.mSenderVip = specificDocument.VipLevel; + this.mChatInfo.mServerProfession = (uint)XSingleton.singleton.XPlayerData.Profession; + this.mChatInfo.isSelfSender = true; + this.mChatInfo.mTime = DateTime.Now; + this.mChatInfo.isAudioPlayed = true; + bool flag = this.mChatInfo.mChannelId == ChatChannelType.Friends; + if (flag) + { + this.mChatInfo.mReceiverId = this.ChatFriendId; + this.mChatInfo.mReceiverName = this.m_sPrivateChatCurrName; + } + this.mChatInfo.mContent = ""; + this._doc.ReceiveChatInfo(this.mChatInfo); + bool flag2 = base.IsVisible(); + if (flag2) + { + IXUILabelSymbol ixuilabelSymbol = this.mChatInfo.mUIObject.transform.Find("voice/content").GetComponent("XUILabelSymbol") as IXUILabelSymbol; + ixuilabelSymbol.InputText = " "; + } + } + + public bool CheckWorldSendMsg(bool isVoice, ButtonClickEventHandler okClickHandler = null, ChatChannelType channel = ChatChannelType.DEFAULT) + { + bool result = true; + bool flag = okClickHandler == null; + if (flag) + { + okClickHandler = new ButtonClickEventHandler(this.OKClickEventHandler); + } + bool flag2 = channel == ChatChannelType.DEFAULT; + if (flag2) + { + channel = this.activeChannelType; + } + bool flag3 = channel == ChatChannelType.World; + if (flag3) + { + bool flag4 = this.worldSpeakTimes > 0u; + if (flag4) + { + return result; + } + bool flag5 = XSingleton.singleton.Doc.XBagDoc.GetItemCount(51) < 1UL; + if (flag5) + { + string[] array = XSingleton.singleton.GetValue("ChatItemCost").Split(XGlobalConfig.SequenceSeparator); + ulong num = 1UL; + ulong.TryParse(array[1], out num); + int num2 = DateTime.Now.Month + DateTime.Now.Day; + int @int = PlayerPrefs.GetInt("chat_timestamp", 0); + this.mIsVoice = isVoice; + bool flag6 = @int == 0 || @int != num2; + if (flag6) + { + DlgBase.singleton.SetVisible(true, true); + DlgBase.singleton.SetSingleButtonMode(false); + string @string = XStringDefineProxy.GetString("CHAT_BUY", new object[] + { + num + }); + string string2 = XStringDefineProxy.GetString("CHAT_BUY_OK"); + string string3 = XStringDefineProxy.GetString("CHAT_BUY_CANCEL"); + DlgBase.singleton.ShowNoTip(XTempTipDefine.OD_CHAT_WORLD); + DlgBase.singleton.SetLabelsWithSymbols(@string, string2, string3); + DlgBase.singleton.SetModalCallback(okClickHandler, new ButtonClickEventHandler(this.CheckSelect)); + } + else + { + okClickHandler(null); + } + result = false; + } + } + return result; + } + + public bool CheckSelect(IXUIButton select) + { + bool tempTip = DlgBase.singleton.GetTempTip(XTempTipDefine.OD_CHAT_WORLD); + bool flag = tempTip; + if (flag) + { + int num = DateTime.Now.Month + DateTime.Now.Day; + PlayerPrefs.SetInt("chat_timestamp", num); + } + bool flag2 = DlgBase.singleton.IsVisible(); + if (flag2) + { + DlgBase.singleton.DoClose(null); + } + return true; + } + + private bool OKClickEventHandler(IXUIButton button) + { + this.CheckSelect(button); + string[] array = XSingleton.singleton.GetValue("ChatItemCost").Split(XGlobalConfig.SequenceSeparator); + ulong num = 7UL; + ulong num2 = 1UL; + ulong.TryParse(array[0], out num); + ulong.TryParse(array[1], out num2); + bool flag = XSingleton.singleton.Doc.XBagDoc.GetItemCount(7) >= num2; + if (flag) + { + XSingleton.singleton.AddLog("buy lanniao msg send", null, null, null, null, null, XDebugColor.XDebug_None); + XPurchaseDocument specificDocument = XDocuments.GetSpecificDocument(XPurchaseDocument.uuID); + bool flag2 = this.mIsVoice; + if (flag2) + { + XSingleton.singleton.ResendLastWorldChat(); + } + else + { + string text = base.uiBehaviour.m_ChatText.GetText(); + this.SendChatContent(text, this.activeChannelType, true, null, false, 0UL, 0f, false, false); + this.ResetInput(); + } + } + else + { + DlgBase.singleton.ShowBorad((ItemEnum)num); + this.ResetInput(); + } + DlgBase.singleton.DoCancel(button); + return true; + } + + public void ShowOtherChatVoiceInfo(ChatVoiceInfo info) + { + ChatInfo chatInfo = new ChatInfo(); + bool isLocalPath = info.isLocalPath; + if (isLocalPath) + { + chatInfo.mChannelId = this.CurrentSpeakChannel; + } + else + { + chatInfo.mChannelId = info.channel; + } + chatInfo.voice = info; + chatInfo.mSenderId = info.sendIndexId; + chatInfo.mSenderName = info.sendName; + chatInfo.mChatType = ChatType.OtherVoice; + chatInfo.isSelfSender = false; + chatInfo.mContent = info.txt; + chatInfo.mTime = DateTime.Now; + bool flag = chatInfo.mChannelId == ChatChannelType.Team; + if (flag) + { + chatInfo.isAudioPlayed = true; + } + XFriendData friendDataById = DlgBase.singleton.GetFriendDataById(chatInfo.mSenderId); + bool flag2 = friendDataById != null; + if (flag2) + { + chatInfo.mSenderVip = friendDataById.viplevel; + chatInfo.mServerProfession = friendDataById.profession; + } + else + { + chatInfo.mSenderVip = 0u; + uint mServerProfession = 1u; + bool flag3 = uint.TryParse(info.sendProf, out mServerProfession); + if (flag3) + { + chatInfo.mServerProfession = mServerProfession; + } + else + { + chatInfo.mServerProfession = 1u; + } + } + bool flag4 = this._doc == null; + if (flag4) + { + this._doc = XDocuments.GetSpecificDocument(XChatDocument.uuID); + } + bool flag5 = info.channel == ChatChannelType.Team && XSingleton.singleton.IsAutoPlayEnable; + if (flag5) + { + XSingleton.singleton.AddAutoPlayList(chatInfo); + } + this._doc.ReceiveChatInfo(chatInfo); + } + + public void PrivateChatTo(ChatFriendData data) + { + bool flag = this._doc == null; + if (flag) + { + this._doc = this.ChatDoc; + } + XPlayerAttributes xplayerData = XSingleton.singleton.XPlayerData; + bool flag2 = xplayerData == null || data.roleid == xplayerData.RoleID; + if (flag2) + { + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("CHAT_NOT_SELF"), "fece00"); + } + else + { + bool flag3 = XSingleton.singleton.CurrentStage.Stage == EXStage.World; + if (flag3) + { + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("CHAT_FORBIT_WORLD"), "fece00"); + } + else + { + ChatFriendData chatFriendData = this._doc.FindFriendData(data.roleid); + bool flag4 = chatFriendData == null; + if (flag4) + { + this._doc.ChatFriendList.Add(data); + } + else + { + chatFriendData.msgtime = DateTime.Now; + } + this.DoChatWith(data.roleid); + } + } + } + + private bool IsContentValid(string content, ChatChannelType type) + { + bool flag = content == XStringDefineProxy.GetString("CHAT_DEFAULT"); + bool result; + if (flag) + { + result = false; + } + else + { + content = content.Replace("{@", "").Replace("@}", ""); + string pattern = "[\\u4e00-\\u9fa5]"; + string text = Regex.Replace(content, pattern, "aa", RegexOptions.IgnoreCase); + bool flag2 = this._doc == null; + if (flag2) + { + this._doc = XDocuments.GetSpecificDocument(XChatDocument.uuID); + this._doc.ChatView = this; + } + uint length = this._doc.GetRawData(type).length; + text = text.Trim(); + bool flag3 = length != 0u && (long)text.Length > (long)((ulong)length); + if (flag3) + { + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("CHAT_TOO_LONG"), "fece00"); + result = false; + } + else + { + bool flag4 = text.Length == 0; + if (flag4) + { + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("CHAT_TOO_SHORT"), "fece00"); + result = false; + } + else + { + string pattern2 = "\\[[0-9a-fA-F]{6}\\]"; + string pattern3 = "\\[[a-fA-F\\-]{1}\\]"; + string pattern4 = "\\[[0-9a-fA-F]{2}\\]"; + bool flag5 = Regex.IsMatch(content, pattern2) || Regex.IsMatch(content, pattern3) || Regex.IsMatch(content, pattern4) || content.Contains("[color=#"); + if (flag5) + { + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("CHAT_INVALID"), "fece00"); + result = false; + } + else + { + result = true; + } + } + } + } + return result; + } + + public void SendVoiceChat(string content, ChatChannelType channelType, ulong audioid, float audiotime) + { + this.SendChatContent(content, channelType, true, null, false, audioid, audiotime, false, false); + } + + private string HandlerContent(string content) + { + content = content.Replace("[b]", "").Replace("[/b]", "").Replace("[\\b]", ""); + content = content.Replace("[i]", "").Replace("[/i]", "").Replace("[\\i]", ""); + content = content.Replace("[u]", "").Replace("[/u]", "").Replace("[\\u]", ""); + content = content.Replace("[s]", "").Replace("[/s]", "").Replace("[\\s]", ""); + content = content.Replace("[sub]", "").Replace("[/sub]", "").Replace("[\\sub]", ""); + content = content.Replace("[url=http", "").Replace("[/url]", "").Replace("[\\url]", ""); + bool flag = content.IndexOf("{@") != -1; + if (flag) + { + string pattern = "\\{\\@[0-9]*[A-Za-z0-9_\\u4e00-\\u9fa5]*\\@\\}"; + MatchCollection matchCollection = Regex.Matches(content, pattern, RegexOptions.IgnoreCase); + bool flag2 = matchCollection != null; + if (flag2) + { + bool flag3 = matchCollection.Count > 0; + if (flag3) + { + content += "e@equip"; + } + for (int i = 0; i < matchCollection.Count; i++) + { + string value = matchCollection[i].Value; + string text = value.Replace("{@", "").Replace("@}", ""); + int num = -1; + int.TryParse(text.Split(new char[] + { + '_' + })[0], out num); + bool flag4 = num <= 0 || num - 1 >= this.chatContentItem.Count; + if (flag4) + { + content = content.Replace(value, text.Replace(num + "_", "")); + } + else + { + string text2 = this.chatContentItem[num - 1]; + text2 = text2.Replace(";", ""); + int num2 = -1; + int.TryParse(text2.Split(new char[] + { + '_' + })[5], out num2); + bool flag5 = num2 <= 0; + if (flag5) + { + content = content.Replace(value, text.Replace(num + "_", "")); + } + else + { + bool flag6 = num != num2; + if (flag6) + { + content = content.Replace(value, text.Replace(num + "_", "")); + } + else + { + string str = text2.Split(new char[] + { + '_' + })[4]; + content = content.Replace(value, "{@" + str + "@}"); + content += this.chatContentItem[num - 1]; + } + } + } + } + } + } + bool flag7 = content.IndexOf("\\\\") == 0; + if (flag7) + { + bool flag8 = content.IndexOf("\\\\n") == 0; + if (flag8) + { + string str2 = content.Substring(0, 3); + string str3 = content.Substring(3, content.Length - 3).Replace("\\\\n", "//n").Replace("\\", "/"); + content = str2 + str3; + } + else + { + string str4 = content.Substring(0, 2); + string str5 = content.Substring(2, content.Length - 2).Replace("\\\\n", "//n").Replace("\\", "/"); + content = str4 + str5; + } + } + else + { + content = content.Replace("\\n", "/n").Replace("\\", "/"); + } + return XSingleton.singleton.FilterForbidWord(content); + } + + public void SendChatContent(string content, ChatChannelType channelType, bool selfReceive = true, List param = null, bool bIsSystem = false, ulong audioid = 0UL, float audiotime = 0f, bool isRecruit = false, bool isDragonGuildRecruit = false) + { + XPlayerAttributes xplayerData = XSingleton.singleton.XPlayerData; + bool flag = !this.IsContentValid(content, channelType) || xplayerData == null; + if (!flag) + { + bool flag2 = channelType == ChatChannelType.Friends && DlgBase.singleton.IsBlock(this.ChatFriendId); + if (flag2) + { + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("CHAT_BLOCK_2"), "fece00"); + } + else + { + content = this.HandlerContent(content); + RpcC2M_chat rpcC2M_chat = new RpcC2M_chat(); + rpcC2M_chat.oArg.chatinfo = new KKSG.ChatInfo(); + rpcC2M_chat.oArg.chatinfo.channel = (uint)channelType; + bool flag3 = channelType == ChatChannelType.Friends; + if (flag3) + { + rpcC2M_chat.oArg.chatinfo.dest = new ChatDest(); + rpcC2M_chat.oArg.chatinfo.dest.roleid.Add(this.ChatFriendId); + ChatInfo chatInfo = new ChatInfo(); + chatInfo.mSenderName = xplayerData.Name; + chatInfo.mSenderId = xplayerData.RoleID; + chatInfo.mReceiverId = this.ChatFriendId; + chatInfo.mReceiverName = ((this.UIOP.CurrChatFriendData == null) ? "" : this.UIOP.CurrChatFriendData.name); + chatInfo.mReceiverVip = ((this.UIOP.CurrChatFriendData == null) ? 1u : this.UIOP.CurrChatFriendData.viplevel); + chatInfo.mRecieverProfession = ((this.UIOP.CurrChatFriendData == null) ? 1u : this.UIOP.CurrChatFriendData.profession); + chatInfo.mReciverPowerPoint = ((this.UIOP.CurrChatFriendData == null) ? 0u : this.UIOP.CurrChatFriendData.powerpoint); + chatInfo.mContent = content; + chatInfo.mChannelId = ChatChannelType.Friends; + chatInfo.mChatType = ChatType.SelfText; + chatInfo.isSelfSender = true; + chatInfo.mAudioId = audioid; + chatInfo.mAudioTime = (uint)audiotime; + bool flag4 = DlgBase.singleton.IsBlock(this.ChatFriendId); + if (flag4) + { + XSingleton.singleton.ShowSystemTip(DlgBase.singleton.GetBlockFriendNameById(this.ChatFriendId) + XStringDefineProxy.GetString("CHAT_BAN_LIST"), "fece00"); + return; + } + } + bool flag5 = channelType == ChatChannelType.Group; + if (flag5) + { + rpcC2M_chat.oArg.chatinfo.groupchatinfo = new GroupChatTeamInfo(); + rpcC2M_chat.oArg.chatinfo.groupchatinfo.groupchatID = DlgBase.singleton.ChatGroupId; + } + rpcC2M_chat.oArg.chatinfo.info = content; + bool flag6 = param != null; + if (flag6) + { + for (int i = 0; i < param.Count; i++) + { + rpcC2M_chat.oArg.chatinfo.param.Add(param[i]); + } + } + rpcC2M_chat.oArg.chatinfo.param.Add(new ChatParam()); + rpcC2M_chat.oArg.chatinfo.issystem = bIsSystem; + rpcC2M_chat.oArg.chatinfo.isRecruit = isRecruit; + rpcC2M_chat.oArg.chatinfo.audioUid = audioid; + rpcC2M_chat.oArg.chatinfo.audioLen = ((audiotime >= 1000f) ? ((uint)audiotime) : 1000u); + rpcC2M_chat.oArg.chatinfo.isDragonGuildRecruit = isDragonGuildRecruit; + XSingleton.singleton.Send(rpcC2M_chat); + } + } + } + + public void SendExternalFriendChat(string content, ChatInfo recvInfo, ulong audioid = 0UL, float audiotime = 0f, List param = null) + { + bool flag = DlgBase.singleton.IsBlock(recvInfo.mReceiverId); + if (flag) + { + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("CHAT_BLOCK_2"), "fece00"); + } + else + { + this.HandlerContent(content); + RpcC2M_chat rpcC2M_chat = new RpcC2M_chat(); + rpcC2M_chat.oArg.chatinfo = new KKSG.ChatInfo(); + rpcC2M_chat.oArg.chatinfo.channel = 3u; + rpcC2M_chat.oArg.chatinfo.dest = new ChatDest(); + rpcC2M_chat.oArg.chatinfo.dest.roleid.Add(recvInfo.mReceiverId); + ChatInfo chatInfo = new ChatInfo(); + chatInfo.mSenderName = XSingleton.singleton.XPlayerData.Name; + chatInfo.mSenderId = XSingleton.singleton.XPlayerData.RoleID; + chatInfo.mReceiverId = recvInfo.mReceiverId; + chatInfo.mReceiverName = recvInfo.mReceiverName; + chatInfo.mReceiverVip = recvInfo.mReceiverVip; + chatInfo.mRecieverProfession = recvInfo.mRecieverProfession; + chatInfo.mReciverPowerPoint = recvInfo.mReciverPowerPoint; + chatInfo.mContent = content; + chatInfo.mChannelId = ChatChannelType.Friends; + chatInfo.mChatType = ChatType.SelfText; + chatInfo.isSelfSender = true; + chatInfo.mAudioId = audioid; + chatInfo.mAudioTime = (uint)audiotime; + this.ProcessText(chatInfo, param); + bool flag2 = this._doc != null; + if (flag2) + { + this._doc.ReceiveChatInfo(chatInfo); + } + rpcC2M_chat.oArg.chatinfo.info = content; + bool flag3 = param != null; + if (flag3) + { + for (int i = 0; i < param.Count; i++) + { + rpcC2M_chat.oArg.chatinfo.param.Add(param[i]); + } + } + rpcC2M_chat.oArg.chatinfo.param.Add(new ChatParam()); + rpcC2M_chat.oArg.chatinfo.issystem = false; + rpcC2M_chat.oArg.chatinfo.isRecruit = false; + rpcC2M_chat.oArg.chatinfo.audioUid = audioid; + rpcC2M_chat.oArg.chatinfo.audioLen = ((audiotime >= 1000f) ? ((uint)audiotime) : 1000u); + XSingleton.singleton.Send(rpcC2M_chat); + } + } + + private void ProcessText(ChatInfo chatInfo, List chatParam = null) + { + bool flag = chatParam == null; + if (!flag) + { + for (int i = 0; i < chatParam.Count; i++) + { + ChatParam chatParam2 = chatParam[i]; + bool flag2 = chatParam2 == null; + if (!flag2) + { + for (int j = 0; j < chatInfo.mContent.Length; j++) + { + bool flag3 = chatInfo.mContent[j] == '$'; + if (flag3) + { + string str = ""; + bool flag4 = chatParam2.link != null && chatInfo.mContent[j + 1] == 'L'; + if (flag4) + { + XInvitationDocument specificDocument = XDocuments.GetSpecificDocument(XInvitationDocument.uuID); + str = specificDocument.ParseLink(chatParam2); + } + string str2 = chatInfo.mContent.Substring(0, j); + string str3 = chatInfo.mContent.Substring(j + 2, chatInfo.mContent.Length - (j + 2)); + chatInfo.mContent = str2 + str + str3; + break; + } + } + } + } + } + } + + public void AddChat(string content, ChatChannelType type, List param = null, bool bIsSystem = false) + { + this.SendChatContent(content, type, true, param, bIsSystem, 0UL, 0f, false, false); + } + + public void SetActiveChannel(ChatChannelType type) + { + this.activeChannelType = type; + bool flag = base.IsVisible(); + if (flag) + { + this.SwitchTab(type); + } + } + + public void ShowChannel(ChatChannelType type) + { + this.SetVisibleWithAnimation(true, null); + XSingleton.singleton.SetTimer(0.5f, new XTimerMgr.ElapsedEventHandler(this.SwitchTab), type); + } + + public void SwitchTab(object obj) + { + int num = (int)obj; + for (int i = 0; i < 11; i++) + { + bool flag = num == (int)this.showChannelIds[i]; + if (flag) + { + this.mCheckbox[i].bChecked = true; + } + } + } + + public void RefeshWorldSpeakTimes() + { + bool flag = base.uiBehaviour != null && base.uiBehaviour.m_lblWorldTimes != null; + if (flag) + { + base.uiBehaviour.m_lblWorldTimes.SetVisible(this.worldSpeakTimes > 0u); + bool flag2 = this.worldSpeakTimes > 0u && this.activeChannelType == ChatChannelType.World; + if (flag2) + { + base.uiBehaviour.m_worldTween.ResetTween(true); + base.uiBehaviour.m_worldTween.PlayTween(true, -1f); + } + XWelfareDocument specificDocument = XDocuments.GetSpecificDocument(XWelfareDocument.uuID); + bool flag3 = specificDocument.IsOwnMemberPrivilege(MemberPrivilege.KingdomPrivilege_Court); + PayMemberPrivilege payMemberPrivilege = specificDocument.PayMemberPrivilege; + bool flag4 = flag3 && payMemberPrivilege != null && payMemberPrivilege.usedChatCount < specificDocument.GetMemberPrivilegeConfig(MemberPrivilege.KingdomPrivilege_Court).ChatCount; + if (flag4) + { + base.uiBehaviour.m_lblWorldTimes.SetText(XStringDefineProxy.GetString("CHAT_WORLD2", new object[] + { + "[ffff00]" + this.worldSpeakTimes + "[-]" + })); + } + else + { + base.uiBehaviour.m_lblWorldTimes.SetText(XStringDefineProxy.GetString("CHAT_WORLD2", new object[] + { + this.worldSpeakTimes + })); + } + } + bool flag5 = base.uiBehaviour != null && base.uiBehaviour.m_ChatTextCost != null; + if (flag5) + { + base.uiBehaviour.m_ChatTextCost.SetText((this.worldSpeakTimes > 0u) ? XStringDefineProxy.GetString("DRAW_FREE") : XStringDefineProxy.GetString("DRAW_BIRD")); + } + } + + public void DoSelectChannel(ChatChannelType type) + { + this.activeChannelType = type; + this.ShowTabFriendRed(); + this.RefeshWorldSpeakTimes(); + base.uiBehaviour.m_objFriendBar.SetActive(type == ChatChannelType.Friends); + base.uiBehaviour.m_objGroupBar.SetActive(type == ChatChannelType.Group); + base.uiBehaviour.m_lblWorldTimes.SetVisible(type == ChatChannelType.World && this.worldSpeakTimes > 0u); + XWelfareDocument specificDocument = XDocuments.GetSpecificDocument(XWelfareDocument.uuID); + bool flag = specificDocument.IsOwnMemberPrivilege(MemberPrivilege.KingdomPrivilege_Court); + base.uiBehaviour.m_sprTq.gameObject.SetActive(type == ChatChannelType.World && this.worldSpeakTimes > 0u); + base.uiBehaviour.m_sprTq.SetSprite(specificDocument.GetMemberPrivilegeIcon(MemberPrivilege.KingdomPrivilege_Court)); + int chatCount = specificDocument.GetMemberPrivilegeConfig(MemberPrivilege.KingdomPrivilege_Court).ChatCount; + base.uiBehaviour.m_lblPriviledge.SetText(XStringDefineProxy.GetString("CHAT_PRIVILEDGE", new object[] + { + chatCount + })); + base.uiBehaviour.m_sprTq.SetGrey(flag); + base.uiBehaviour.m_lblPriviledge.SetEnabled(flag); + base.uiBehaviour.m_sprFriend.SetAlpha((float)((XSingleton.singleton.CurrentStage.Stage == EXStage.Hall) ? 1 : 0)); + this.RefreshVoiceBarStatus(); + this.ShowTextboard(type); + this.m_uiBehaviour.m_ChatTextCost.SetVisible(type == ChatChannelType.World); + this.SetLoopActive(type); + bool flag2 = type == ChatChannelType.Friends; + if (flag2) + { + this.RefreshFriendUI(this.friendState); + } + else + { + bool flag3 = type == ChatChannelType.Group; + if (flag3) + { + this.groupState = XChatView.ChatGroupState.GROUPS; + this.RefreshGrouplist(); + } + else + { + this.RefreshLoopScroll(type); + } + } + XSingleton.singleton.SetAutoPlayChannel(type); + } + + private void RefreshVoiceBarStatus() + { + bool flag = base.IsVisible(); + if (flag) + { + base.uiBehaviour.m_btns.SetActive(this.IsVoicebarShow()); + base.uiBehaviour.m_lblAutoVoice.SetText(XStringDefineProxy.GetString("CHAT_AutoPlay", new object[] + { + this.ChatDoc.GetRawData(this.activeChannelType).name + })); + base.uiBehaviour.m_chxAutoVoice.bChecked = this.GetAutoVoiceSetting(this.activeChannelType); + } + } + + private bool IsVoicebarShow() + { + bool result = false; + int i = 0; + int num = this.showVoiceBar.Length; + while (i < num) + { + bool flag = this.activeChannelType == this.showVoiceBar[i]; + if (flag) + { + result = true; + break; + } + i++; + } + return result; + } + + private bool GetAutoVoiceSetting(ChatChannelType type) + { + XOptionsDocument specificDocument = XDocuments.GetSpecificDocument(XOptionsDocument.uuID); + return Convert.ToBoolean(specificDocument.GetValue(this.Channel2OptionDef(type))); + } + + private void SetAutoVoice(ChatChannelType type, bool val) + { + XOptionsDocument specificDocument = XDocuments.GetSpecificDocument(XOptionsDocument.uuID); + specificDocument.SetValue(this.Channel2OptionDef(type), val ? 1 : 0, false); + specificDocument.SaveSetting(); + } + + private XOptionsDefine Channel2OptionDef(ChatChannelType type) + { + switch (type) + { + case ChatChannelType.ZeroChannel: + return XOptionsDefine.OD_RADIO_WIFI; + case ChatChannelType.World: + return XOptionsDefine.OD_RADIO_WORLD; + case ChatChannelType.Guild: + return XOptionsDefine.OD_RADIO_PUBLIC; + case ChatChannelType.Friends: + return XOptionsDefine.OD_RADIO_PRIVATE; + case ChatChannelType.Team: + return XOptionsDefine.OD_RADIO_TEAM; + case ChatChannelType.Camp: + return XOptionsDefine.OD_RADIO_CAMP; + case ChatChannelType.Curr: + return XOptionsDefine.OD_RADIO_AUTO_PALY; + } + return XOptionsDefine.OD_RADIO_WORLD; + } + + private string GetPlayerNameById(ulong uid) + { + return DlgBase.singleton.GetFriendNameById(uid); + } + + public void OnRefreshGetFlowerInfo() + { + bool flag = !base.IsVisible(); + if (!flag) + { + base.uiBehaviour.m_GetFlowerLeftTime.gameObject.SetActive(this._doc.getFlowerLeftTime > 0); + base.uiBehaviour.m_GetFlowerBtn.SetEnable(this._doc.getFlowerLeftTime == 0, false); + base.uiBehaviour.m_FlowerEff.SetActive(this._doc.getFlowerLeftTime == 0 && this._doc.canGetFlower); + bool flag2 = !this._doc.canGetFlower; + if (flag2) + { + base.uiBehaviour.m_GetFlowerBtn.SetGrey(this._doc.canGetFlower); + } + bool flag3 = this._doc.getFlowerLeftTime == 0 && this._doc.canGetFlower; + if (flag3) + { + base.uiBehaviour.m_FlowerTween.PlayTween(true, -1f); + } + else + { + base.uiBehaviour.m_FlowerTween.StopTween(); + } + bool flag4 = this._doc.getFlowerLeftTime > 0; + if (flag4) + { + base.uiBehaviour.m_GetFlowerLeftTime.SetText(string.Format("{0}", XSingleton.singleton.TimeFormatString(this._doc.getFlowerLeftTime, 2, 3, 4, false, true))); + XSingleton.singleton.KillTimer(this._GetFlowerCDToken); + this._GetFlowerCDToken = XSingleton.singleton.SetTimer(1f, new XTimerMgr.ElapsedEventHandler(this.GetFlowerCDUpdate), null); + } + this.UpdateFlowerCount(); + } + } + + private void GetFlowerCDUpdate(object o) + { + this._doc.getFlowerLeftTime = (int)XSingleton.singleton.GetFlowerRemainTime; + this.OnRefreshGetFlowerInfo(); + } + + private bool OnGetFlower(IXUIButton go) + { + bool canGetFlower = this._doc.canGetFlower; + if (canGetFlower) + { + this._doc.ReqGetFlower(); + } + else + { + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("FLOWER_CHATDLG_MAX_TIMES_ERR"), "fece00"); + } + return true; + } + + private void UpdateFlowerCount() + { + string[] array = XSingleton.singleton.GetValue("GetFlowerTime").Split(XGlobalConfig.SequenceSeparator); + int itemid = int.Parse(array[0]); + base.uiBehaviour.m_FlowerOwnCount.SetText(string.Format(XStringDefineProxy.GetString("FLOWER_CHATDLG_OWN_COUNT"), XSingleton.singleton.Doc.XBagDoc.GetItemCount(itemid).ToString())); + } + + public bool OnCloseClicked(IXUIButton sp) + { + this.cacheShow = false; + this.SetVisibleWithAnimation(false, null); + DlgBase.singleton.RefreshUI(); + return true; + } + + private bool OnBtmAddClick(IXUIButton btn) + { + DlgBase.singleton.Show(new ChatInputStringBack(this.OnAddSelect), ChatAssetType.EMOTION); + return true; + } + + private void OnSetClick(IXUISprite spr) + { + bool flag = !XSingleton.singleton.IsPVPScene() && !XSingleton.singleton.IsPVEScene(); + if (flag) + { + DlgBase.singleton.prefabTab = OptionsTab.VoiceTab; + DlgBase.singleton.SetVisibleWithAnimation(true, null); + } + } + + public void OnMailClick(IXUISprite sp) + { + DlgBase.singleton.ShowWorkGameSystem(XSysDefine.XSys_Mail_System); + } + + private void OnXinyueClick(IXUISprite spr) + { + Dictionary dictionary = new Dictionary(); + XSingleton.singleton.CloseSysAndNoticeServer((uint)XFastEnumIntEqualityComparer.ToInt(XSysDefine.XSys_GC_XiaoYueGuanJia)); + base.uiBehaviour.m_sprXinyueRed.SetVisible(false); + string text = ((int)Application.platform == 11) ? "1" : "0"; + string text2 = string.Format("{0}?game_id={1}&opencode={2}&sig={3}×tamp={4}&role_id={5}&partition_id={6}&plat_id={7}", new object[] + { + XSingleton.singleton.GetValue("XiaoYueUrl"), + XSingleton.singleton.GetValue("XiaoYueGameID"), + XSingleton.singleton.OpenCode, + XSingleton.singleton.XPlatform.GetMD5(string.Format("{0}{1}", XSingleton.singleton.MSDKKey, XSingleton.singleton.GetTimeStamp())), + XSingleton.singleton.GetTimeStamp(), + XSingleton.singleton.GetRoleId(), + XSingleton.singleton.ServerID, + text + }); + XSingleton.singleton.AddLog("url = " + text2, null, null, null, null, null, XDebugColor.XDebug_None); + dictionary["url"] = text2; + dictionary["screendir"] = "SENSOR"; + XSingleton.singleton.XPlatform.SendExtDara("open_url", Json.Serialize(dictionary)); + } + + private void OnFriendsClick(IXUISprite spr) + { + DlgBase.singleton.SetVisible(true, true); + } + + private bool OnAutoVoiceClick(IXUICheckBox box) + { + this.SetAutoVoice(this.activeChannelType, box.bChecked); + return true; + } + + private void OnAddSelect(string motionstr) + { + string text = base.uiBehaviour.m_ChatInput.GetText(); + string text2 = text + motionstr; + base.uiBehaviour.m_ChatInput.SetText(text2); + bool flag = base.uiBehaviour.m_ChatInput.GetText().Length - text.Length < motionstr.Length; + if (flag) + { + base.uiBehaviour.m_ChatInput.SetText(text); + } + } + + public bool DoSendTextChat(IXUIButton sp) + { + bool flag = this.mInputType == InputUIType.Normal; + if (flag) + { + bool flag2 = this.activeChannelType == ChatChannelType.Guild; + if (flag2) + { + bool flag3 = !this.CheckGuildOpen(); + if (flag3) + { + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("CHAT_NOT_IN_GUILD"), "fece00"); + this.ResetInput(); + return false; + } + } + else + { + bool flag4 = this.activeChannelType == ChatChannelType.Partner; + if (flag4) + { + bool flag5 = !this.CheckDragonGuildOpen(); + if (flag5) + { + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("ERR_DG_NOT_IN_GUILD"), "fece00"); + this.ResetInput(); + return false; + } + } + else + { + bool flag6 = this.activeChannelType == ChatChannelType.Team; + if (flag6) + { + bool flag7 = !this.CheckTeamOpen(); + if (flag7) + { + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("CHAT_NOT_IN_TEAM"), "fece00"); + this.ResetInput(); + return false; + } + } + else + { + bool flag8 = this.activeChannelType == ChatChannelType.World; + if (flag8) + { + bool flag9 = !this.CheckWorldSendMsg(false, null, ChatChannelType.DEFAULT); + if (flag9) + { + return false; + } + } + else + { + bool flag10 = this.activeChannelType == ChatChannelType.Friends; + if (flag10) + { + bool flag11 = this.ChatFriendId == 0UL; + if (flag11) + { + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("CHAT_NOT_HAVE_FRIEND"), "fece00"); + this.ResetInput(); + return false; + } + } + } + } + } + } + string text = base.uiBehaviour.m_ChatText.GetText(); + bool flag12 = !XSingleton.singleton.IsSystemExpress(text); + if (flag12) + { + this.SendChatContent(text, this.activeChannelType, true, null, false, 0UL, 0f, false, false); + } + this.ResetInput(); + } + else + { + bool flag13 = this.mInputType == InputUIType.Linked; + if (flag13) + { + this.DispatchLinkClick(); + } + } + return true; + } + + private void ResetInput() + { + bool flag = base.IsVisible(); + if (flag) + { + base.uiBehaviour.m_ChatText.SetText(""); + base.uiBehaviour.m_Input.SetText(""); + base.uiBehaviour.m_Input.SetDefault(XStringDefineProxy.GetString("CHAT_DEFAULT")); + } + } + + public void OnVoiceButtonDrag(IXUIButton sp, Vector2 delta) + { + this.m_DragDistance += delta; + this.m_CancelRecord = (this.m_DragDistance.magnitude >= 100f); + } + + public void OnVoiceChatButton(IXUIButton sp, bool state) + { + if (state) + { + this.m_CancelRecord = false; + this.m_DragDistance = Vector2.zero; + this.m_uiBehaviour.m_SpeakEff.SetActive(true); + this.StartRecord(); + } + else + { + this.m_uiBehaviour.m_SpeakEff.SetActive(false); + bool useApollo = XChatDocument.UseApollo; + if (useApollo) + { + XSingleton.singleton.StopRecord(this.m_CancelRecord); + } + else + { + XSingleton.singleton.StopRecord(this.m_CancelRecord); + } + this.m_CancelRecord = false; + } + } + + private void StartRecord() + { + bool useApollo = XChatDocument.UseApollo; + if (useApollo) + { + XSingleton.singleton.StartRecord(VoiceUsage.CHAT, new EndRecordCallBack(this.AutoQuitRecord)); + } + else + { + XSingleton.singleton.StartRecord(VoiceUsage.CHAT, new EndRecordCallBack(this.AutoQuitRecord)); + } + } + + private void AutoQuitRecord() + { + } + + private bool SelectChatChannel(IXUICheckBox iXUICheckBox) + { + ChatChannelType type = (ChatChannelType)iXUICheckBox.ID; + bool bChecked = iXUICheckBox.bChecked; + if (bChecked) + { + this.DoSelectChannel(type); + } + return true; + } + + public void OnAddFriend(IXUILabel sp) + { + DlgBase.singleton.AddFriendById(this.ChatFriendId); + } + + private void OnStopAudioRecord(ChatInfo chatinfo) + { + bool flag = this._doc == null; + if (flag) + { + this._doc = XDocuments.GetSpecificDocument(XChatDocument.uuID); + this._doc.ChatView = this; + } + ChatVoiceInfo voice = chatinfo.voice; + bool flag2 = voice != null; + if (flag2) + { + ChatChannelType chatChannelType = this.activeChannelType; + voice.channel = chatChannelType; + bool flag3 = chatChannelType == ChatChannelType.Friends; + if (flag3) + { + ulong roleID = XSingleton.singleton.XPlayerData.RoleID; + this.PrivateChatCurrName = this.GetPlayerNameById(this.ChatFriendId) + "_" + this.ChatFriendId.ToString(); + } + else + { + DateTime now = DateTime.Now; + uint num = 0u; + bool flag4 = chatChannelType == ChatChannelType.World; + if (flag4) + { + num = 60u; + } + int num2 = chatChannelType - ChatChannelType.World; + bool flag5 = (now - this.m_lastChatTime[num2]).TotalSeconds <= num; + if (!flag5) + { + this.m_lastChatTime[chatChannelType - ChatChannelType.World] = DateTime.Now; + } + this.ShowMyChatVoiceInfo(voice); + } + this.OnStartVoiceCD(); + } + } + + private void OnRefreshChatTextRecognize(ChatInfo info) + { + bool flag = this._doc != null; + if (flag) + { + this._doc.OnReceiveChatSmallInfo(info); + } + } + + public void OnStartVoiceCD() + { + } + } +} -- cgit v1.1-26-g67d0