From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Assets/Scripts/XMainClient/XFriendsDocument.cs | 433 +++++++++++++++++++++ 1 file changed, 433 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/XFriendsDocument.cs (limited to 'Client/Assets/Scripts/XMainClient/XFriendsDocument.cs') diff --git a/Client/Assets/Scripts/XMainClient/XFriendsDocument.cs b/Client/Assets/Scripts/XMainClient/XFriendsDocument.cs new file mode 100644 index 00000000..b77e29e3 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/XFriendsDocument.cs @@ -0,0 +1,433 @@ +using System; +using System.Collections.Generic; +using KKSG; +using XMainClient.UI; +using XMainClient.UI.UICommon; +using XUpdater; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class XFriendsDocument : XDocComponent + { + public override uint ID + { + get + { + return XFriendsDocument.uuID; + } + } + + public static XFriendsDocument Doc + { + get + { + return XDocuments.GetSpecificDocument(XFriendsDocument.uuID); + } + } + + public List PlatFriendsRankList + { + get + { + return this.m_listPlatFriendsRank; + } + } + + public PlatFriendRankInfo2Client SelfPlatRankInfo + { + get + { + return this.m_selfPlatRank; + } + } + + public Dictionary FriendsVipInfo + { + get + { + return this._FriendsVipInfo; + } + } + + public static int FriendsTabCount + { + get + { + return XFriendsDocument._FriendSysTable.Table.Length; + } + } + + public new static readonly uint uuID = XSingleton.singleton.XHash("XFriendsDocument"); + + public static XTableAsyncLoader AsyncLoader = new XTableAsyncLoader(); + + private static FriendTable _FriendTable = new FriendTable(); + + private static FriendSysConfigTable _FriendSysTable = new FriendSysConfigTable(); + + private List m_listPlatFriendsRank = null; + + private PlatFriendRankInfo2Client m_selfPlatRank = null; + + private Dictionary _FriendsVipInfo = new Dictionary(); + + private bool syncFriendsData = false; + + private int entertimer = 0; + + public static FriendSysConfigTable.RowData GetFriendsTabItemByID(int id) + { + return XFriendsDocument._FriendSysTable.GetByTabID(id); + } + + public static FriendSysConfigTable.RowData GetFriendsTabItemByIndex(int index) + { + return XFriendsDocument._FriendSysTable.Table[index]; + } + + public override void OnAttachToHost(XObject host) + { + base.OnAttachToHost(host); + this.syncFriendsData = false; + XSingleton.singleton.Init(); + } + + public static void Execute(OnLoadedCallback callback = null) + { + XFriendsDocument.AsyncLoader.AddTask("Table/Friend", XFriendsDocument._FriendTable, false); + XFriendsDocument.AsyncLoader.AddTask("Table/FriendSystemConfig", XFriendsDocument._FriendSysTable, false); + XFriendsDocument.AsyncLoader.Execute(callback); + } + + public FriendTable.RowData[] GetFriendLevelDatas() + { + return XFriendsDocument._FriendTable.Table; + } + + public FriendTable.RowData GetFriendLevelData(uint level) + { + for (int i = 0; i < XFriendsDocument._FriendTable.Table.Length; i++) + { + bool flag = XFriendsDocument._FriendTable.Table[i].level == level; + if (flag) + { + return XFriendsDocument._FriendTable.Table[i]; + } + } + return null; + } + + protected override void OnReconnected(XReconnectedEventArgs arg) + { + this.ReqFriendsInfo(); + } + + public override void OnDetachFromHost() + { + base.OnDetachFromHost(); + this.entertimer = 0; + this._FriendsVipInfo.Clear(); + } + + public override void OnEnterSceneFinally() + { + base.OnEnterSceneFinally(); + XSingleton.singleton.Init(); + this.ReqFriendsInfo(); + this.entertimer++; + XChatDocument specificDocument = XDocuments.GetSpecificDocument(XChatDocument.uuID); + bool flag = specificDocument != null && XSingleton.singleton.CurrentStage.Stage == EXStage.Hall; + if (flag) + { + specificDocument.SendOfflineMsg(); + } + } + + public void SDKQueryFriends() + { + XSingleton.singleton.AddLog("XFriendsDocument SDKQueryFriends", null, null, null, null, null, XDebugColor.XDebug_None); + XSingleton.singleton.XPlatform.SendGameExData("QueryFriends", ""); + } + + public void ReqFriendsInfo() + { + PtcC2M_FriendQueryReportNew ptcC2M_FriendQueryReportNew = new PtcC2M_FriendQueryReportNew(); + ptcC2M_FriendQueryReportNew.Data.op = FriendOpType.Friend_ApplyAll; + XSingleton.singleton.Send(ptcC2M_FriendQueryReportNew); + PtcC2M_FriendQueryReportNew ptcC2M_FriendQueryReportNew2 = new PtcC2M_FriendQueryReportNew(); + ptcC2M_FriendQueryReportNew2.Data.op = FriendOpType.Friend_FriendAll; + XSingleton.singleton.Send(ptcC2M_FriendQueryReportNew2); + PtcC2M_BlackListReportNew proto = new PtcC2M_BlackListReportNew(); + XSingleton.singleton.Send(proto); + } + + public void SyncPlatFriendsInfo() + { + bool flag = XSingleton.singleton.CurrentStage.Stage != EXStage.Hall; + if (!flag) + { + bool flag2 = this.syncFriendsData; + if (!flag2) + { + XSingleton.singleton.AddLog("FriendsRank SyncPlatFriendsInfo", null, null, null, null, null, XDebugColor.XDebug_None); + PtcC2M_SyncPlatFriend2MS ptcC2M_SyncPlatFriend2MS = new PtcC2M_SyncPlatFriend2MS(); + bool flag3 = XSingleton.singleton.friendsInfo != null; + if (flag3) + { + XSingleton.singleton.AddLog("FriendsRank friendsCount = " + XSingleton.singleton.friendsInfo.data.Length, null, null, null, null, null, XDebugColor.XDebug_None); + int @int = XSingleton.singleton.GetInt("SyncPlatFriendsCount"); + XSingleton.singleton.AddLog("FriendsRank SyncPlatFriendsCount = " + @int, null, null, null, null, null, XDebugColor.XDebug_None); + for (int i = 0; i < XSingleton.singleton.friendsInfo.data.Length; i++) + { + bool flag4 = i < @int; + if (!flag4) + { + break; + } + FriendInfo.Data data = XSingleton.singleton.friendsInfo.data[i]; + PlatFriend platFriend = new PlatFriend(); + platFriend.openid = data.openId; + platFriend.nickname = data.nickName; + platFriend.bigpic = data.pictureLarge; + platFriend.midpic = ""; + platFriend.smallpic = ""; + ptcC2M_SyncPlatFriend2MS.Data.friendInfo.Add(platFriend); + } + XSingleton.singleton.AddLog("FriendsRank SendCount = " + ptcC2M_SyncPlatFriend2MS.Data.friendInfo.Count, null, null, null, null, null, XDebugColor.XDebug_None); + } + bool flag5 = XSingleton.singleton.playerInfo != null; + if (flag5) + { + PlatFriend platFriend2 = new PlatFriend(); + platFriend2.openid = XSingleton.singleton.OpenID; + platFriend2.nickname = XSingleton.singleton.playerInfo.data.nickName; + platFriend2.bigpic = XSingleton.singleton.playerInfo.data.pictureLarge; + platFriend2.midpic = XSingleton.singleton.playerInfo.data.pictureMiddle; + platFriend2.smallpic = XSingleton.singleton.playerInfo.data.pictureSmall; + ptcC2M_SyncPlatFriend2MS.Data.selfInfo = platFriend2; + XSingleton.singleton.AddLog("FriendsRank SyncPlatFriendsInfo self openid = " + platFriend2.openid, null, null, null, null, null, XDebugColor.XDebug_None); + } + this.syncFriendsData = true; + XSingleton.singleton.Send(ptcC2M_SyncPlatFriend2MS); + } + } + } + + public bool IsQQFriend(string openID) + { + bool flag = XSingleton.singleton.friendsInfo != null; + if (flag) + { + for (int i = 0; i < XSingleton.singleton.friendsInfo.data.Length; i++) + { + bool flag2 = XSingleton.singleton.friendsInfo.data[i].openId == openID; + if (flag2) + { + return true; + } + } + } + return false; + } + + public void ReqPlatFriendsRank() + { + XSingleton.singleton.AddLog("FriendsRank ReqPlatFriendsRank", null, null, null, null, null, XDebugColor.XDebug_None); + RpcC2M_ReqPlatFriendRankList rpc = new RpcC2M_ReqPlatFriendRankList(); + XSingleton.singleton.Send(rpc); + } + + public void SendGift2PlatFriend(string openID) + { + XSingleton.singleton.AddLog("FriendsRank SendGift2PlatFriend openid = " + openID, null, null, null, null, null, XDebugColor.XDebug_None); + RpcC2M_SendGift2PlatFriend rpcC2M_SendGift2PlatFriend = new RpcC2M_SendGift2PlatFriend(); + rpcC2M_SendGift2PlatFriend.oArg.openid = openID; + XSingleton.singleton.Send(rpcC2M_SendGift2PlatFriend); + } + + public void SendPk2PlatFriend(string openID) + { + XSingleton.singleton.AddLog("FriendsRank SendPk2PlatFriend openid = " + openID, null, null, null, null, null, XDebugColor.XDebug_None); + RpcC2M_InvFightReqAll rpcC2M_InvFightReqAll = new RpcC2M_InvFightReqAll(); + rpcC2M_InvFightReqAll.oArg.reqtype = InvFightReqType.IFRT_INV_ONE; + rpcC2M_InvFightReqAll.oArg.iscross = true; + rpcC2M_InvFightReqAll.oArg.account = openID; + XSingleton.singleton.Send(rpcC2M_InvFightReqAll); + } + + public void OnSendGift2PlatFriend(SendGift2PlatFriendArg oArg, SendGift2PlatFriendRes oRes) + { + XSingleton.singleton.AddLog("FriendsRank OnSendGift2PlatFriend", null, null, null, null, null, XDebugColor.XDebug_None); + bool flag = oRes.error > ErrorCode.ERR_SUCCESS; + if (flag) + { + XSingleton.singleton.ShowErrorCode(oRes.error); + } + else + { + string[] andSeparateValue = XSingleton.singleton.GetAndSeparateValue("SendPlatFriendGift", XGlobalConfig.SequenceSeparator); + bool flag2 = andSeparateValue.Length == 2; + if (flag2) + { + string text = XSingleton.singleton.ChooseProfString(XBagDocument.GetItemConf(int.Parse(andSeparateValue[0])).ItemName, 0u); + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("FRIEND_SEND_PLAT_FRIEND", new object[] + { + andSeparateValue[1], + text + }), "fece00"); + } + for (int i = 0; i < this.m_listPlatFriendsRank.Count; i++) + { + bool flag3 = this.m_listPlatFriendsRank[i].platfriendBaseInfo.openid == oArg.openid; + if (flag3) + { + this.m_listPlatFriendsRank[i].hasGiveGift = true; + DlgBase.singleton.OnRefreshSendGiftState(this.m_listPlatFriendsRank[i]); + break; + } + } + bool flag4 = XSingleton.singleton.Channel != XAuthorizationChannel.XAuthorization_Guest && XSingleton.singleton.IsSystemOpened(XSysDefine.XSys_Friends_Gift_Share); + if (flag4) + { + DlgBase.singleton.NoticeFriend(oArg.openid); + } + } + } + + public void OnReqPlatFriendsRank(ReqPlatFriendRankListArg oArg, ReqPlatFriendRankListRes oRes) + { + XSingleton.singleton.AddLog("FriendsRank OnReqPlatFriendsRank", null, null, null, null, null, XDebugColor.XDebug_None); + bool flag = oRes.error > ErrorCode.ERR_SUCCESS; + if (flag) + { + XSingleton.singleton.ShowErrorCode(oRes.error); + } + else + { + XTeamInviteDocument specificDocument = XDocuments.GetSpecificDocument(XTeamInviteDocument.uuID); + bool flag2 = specificDocument.OnGetInvitePlatList(oRes); + if (!flag2) + { + this.m_listPlatFriendsRank = oRes.platFriends; + this.m_selfPlatRank = oRes.selfInfo; + XSingleton.singleton.AddLog("OnReqPlatFriendsRank count= " + oRes.platFriends.Count, null, null, null, null, null, XDebugColor.XDebug_None); + bool flag3 = XSingleton.singleton.Channel == XAuthorizationChannel.XAuthorization_QQ && XSingleton.singleton.IsSystemOpened(XSysDefine.XSys_QQVIP); + if (flag3) + { + this.ReqQQFriendsVipInfo(oRes.platFriends); + } + else + { + DlgBase.singleton.OnRefreshPlatFriendsRank(); + } + } + } + } + + public void ReqQQFriendsVipInfo(List platFriendList) + { + RpcC2G_QueryQQFriendsVipInfo rpcC2G_QueryQQFriendsVipInfo = new RpcC2G_QueryQQFriendsVipInfo(); + rpcC2G_QueryQQFriendsVipInfo.oArg.token = XSingleton.singleton.TokenCache; + rpcC2G_QueryQQFriendsVipInfo.oArg.friendopenids.Clear(); + List list = new List(); + for (int i = 0; i < platFriendList.Count; i++) + { + rpcC2G_QueryQQFriendsVipInfo.oArg.friendopenids.Add(platFriendList[i].platfriendBaseInfo.openid); + } + XSingleton.singleton.Send(rpcC2G_QueryQQFriendsVipInfo); + } + + public void OnGetQQFriendsVipInfo(QueryQQFriendsVipInfoArg oArg, QueryQQFriendsVipInfoRes oRes) + { + bool flag = oRes.result > ErrorCode.ERR_SUCCESS; + if (flag) + { + XSingleton.singleton.ShowSystemTip(oRes.result, "fece00"); + } + else + { + this._FriendsVipInfo.Clear(); + for (int i = 0; i < oRes.info.Count; i++) + { + QQVipType value = QQVipType.None; + string openid = oRes.info[i].openid; + bool is_svip = oRes.info[i].is_svip; + if (is_svip) + { + value = QQVipType.SVip; + } + else + { + bool is_vip = oRes.info[i].is_vip; + if (is_vip) + { + value = QQVipType.Vip; + } + } + this._FriendsVipInfo[openid] = value; + } + DlgBase.singleton.OnRefreshPlatFriendsRank(); + } + } + + public void OnFriendGiftOp(FriendGiftOpArg oArg, FriendGiftOpRes oRes) + { + DlgBase.singleton.OnFriendGiftOp(oArg, oRes); + } + + public void OnApply(DoAddFriendArg oArg, DoAddFriendRes oRes) + { + DlgBase.singleton.OnApply(oArg, oRes); + } + + public void AddFriendRes(ErrorCode code, ulong uid) + { + DlgBase.singleton.AddFriendRes(code, uid); + } + + public void OnFriendOpNotify(PtcM2C_FriendOpNtfNew roPtc) + { + DlgBase.singleton.OnFriendOpNotify(roPtc); + XFriendInfoChange @event = XEventPool.GetEvent(); + @event.opType = roPtc.Data.op; + @event.Firer = XSingleton.singleton.Doc; + XSingleton.singleton.FireEvent(@event); + } + + public void RemoveFriendRes(ErrorCode code, ulong roleid) + { + DlgBase.singleton.RemoveFriendRes(code, roleid); + } + + public void UpdateFriendInfo(ulong uid, uint daydegree, uint alldegree) + { + DlgBase.singleton.UpdateFriendInfo(uid, daydegree, alldegree); + } + + public void QueryRoleStateRes(RoleStateNtf rolestate) + { + DlgBase.singleton.QueryRoleStateRes(rolestate); + } + + public void RandomFriendRes(RandomFriendWaitListRes waitList) + { + DlgBase.singleton.RandomFriendRes(waitList); + } + + public void AddBlockFriendRes(Friend2Client black) + { + DlgBase.singleton.AddBlockFriendRes(black); + } + + public void RefreshBlockFriendData(BlackListNtf blacklist) + { + DlgBase.singleton.RefreshBlockFriendData(blacklist); + } + + public void RemoveBlockFriendRes(ErrorCode code, ulong roleid) + { + DlgBase.singleton.RemoveBlockFriendRes(code, roleid); + } + } +} -- cgit v1.1-26-g67d0