From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Scripts/XMainClient/XInvitationDocument.cs | 573 +++++++++++++++++++++ 1 file changed, 573 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/XInvitationDocument.cs (limited to 'Client/Assets/Scripts/XMainClient/XInvitationDocument.cs') diff --git a/Client/Assets/Scripts/XMainClient/XInvitationDocument.cs b/Client/Assets/Scripts/XMainClient/XInvitationDocument.cs new file mode 100644 index 00000000..8aaf6132 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/XInvitationDocument.cs @@ -0,0 +1,573 @@ +using System; +using System.Collections.Generic; +using KKSG; +using UILib; +using XMainClient.UI; +using XMainClient.UI.UICommon; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class XInvitationDocument : XDocComponent + { + public override uint ID + { + get + { + return XInvitationDocument.uuID; + } + } + + public new static readonly uint uuID = XSingleton.singleton.XHash("InvitationDocument"); + + public static XTableAsyncLoader AsyncLoader = new XTableAsyncLoader(); + + private static NoticeTable m_NoticeTable = new NoticeTable(); + + private XInvitationDocument.InvitationChatLinkData m_ChatLinkData = new XInvitationDocument.InvitationChatLinkData(); + + private static int mLiveID = 0; + + private static int mType = 1; + + private class InvitationChatLinkData + { + public ChatChannelType channel; + + public string content; + + public List param; + + public bool bIsSystem; + + public void Reset() + { + bool flag = this.param != null; + if (flag) + { + this.param.Clear(); + } + this.param = null; + } + } + + public static void Execute(OnLoadedCallback callback = null) + { + XInvitationDocument.AsyncLoader.AddTask("Table/Notice", XInvitationDocument.m_NoticeTable, false); + XInvitationDocument.AsyncLoader.Execute(callback); + } + + public NoticeTable.RowData GetNoticeData(NoticeType type) + { + return XInvitationDocument.m_NoticeTable.GetByid(this.ToID(type)); + } + + public NoticeTable.RowData GetNoticeData(uint id) + { + return XInvitationDocument.m_NoticeTable.GetByid(id); + } + + private uint ToID(NoticeType type) + { + return (uint)XFastEnumIntEqualityComparer.ToInt(type); + } + + private bool _IsOpenSys(NoticeType type) + { + return NoticeType.NT_OPENSYS_BEGIN <= type && type < NoticeType.NT_OPENSYS_END; + } + + private void _SendMessage(uint channel, string content, List param, bool bIsSystem = true, bool isRecruit = false, bool isDragonGuildRecruit = false) + { + bool flag = channel == 1u; + if (flag) + { + this.m_ChatLinkData.Reset(); + this.m_ChatLinkData.channel = (ChatChannelType)channel; + this.m_ChatLinkData.content = content; + this.m_ChatLinkData.param = param; + this.m_ChatLinkData.bIsSystem = bIsSystem; + bool flag2 = DlgBase.singleton.CheckWorldSendMsg(false, new ButtonClickEventHandler(this._RealSendMsg), ChatChannelType.World); + if (flag2) + { + DlgBase.singleton.SendChatContent(content, (ChatChannelType)channel, true, param, bIsSystem, 0UL, 0f, isRecruit, isDragonGuildRecruit); + } + } + else + { + DlgBase.singleton.SendChatContent(content, (ChatChannelType)channel, true, param, bIsSystem, 0UL, 0f, isRecruit, isDragonGuildRecruit); + } + } + + private bool _RealSendMsg(IXUIButton btn) + { + DlgBase.singleton.SendChatContent(this.m_ChatLinkData.content, this.m_ChatLinkData.channel, true, this.m_ChatLinkData.param, this.m_ChatLinkData.bIsSystem, 0UL, 0f, false, false); + this.m_ChatLinkData.Reset(); + return DlgBase.singleton.CheckSelect(btn); + } + + public void SendGuildInvitation() + { + XGuildDocument specificDocument = XDocuments.GetSpecificDocument(XGuildDocument.uuID); + bool flag = !specificDocument.CheckInGuild(); + if (!flag) + { + NoticeTable.RowData noticeData = this.GetNoticeData(NoticeType.NT_INVITE_GUILD); + bool flag2 = noticeData == null; + if (!flag2) + { + List list = new List(); + ChatParam chatParam = new ChatParam(); + chatParam.guild = new ChatParamGuild(); + chatParam.guild.guildid = specificDocument.UID; + chatParam.guild.guildname = specificDocument.BasicData.guildName; + ChatParam chatParam2 = new ChatParam(); + chatParam2.link = new ChatParamLink(); + chatParam2.link.id = noticeData.linkparam; + chatParam2.link.content = noticeData.linkcontent; + chatParam2.guild = chatParam.guild; + list.Add(chatParam); + list.Add(chatParam2); + this._SendMessage((uint)noticeData.channel, string.Format(noticeData.info, specificDocument.BasicData.guildName), list, true, true, false); + } + } + } + + public void SendDragonGuildInvitation() + { + XDragonGuildDocument doc = XDragonGuildDocument.Doc; + bool flag = !doc.IsInDragonGuild(); + if (!flag) + { + NoticeTable.RowData noticeData = this.GetNoticeData(NoticeType.NT_INVITE_DRAGON_GUILD); + bool flag2 = noticeData == null; + if (!flag2) + { + List list = new List(); + ChatParam chatParam = new ChatParam(); + chatParam.dragonguild = new ChatParamDragonGuild(); + chatParam.dragonguild.dragonguildId = doc.UID; + chatParam.dragonguild.dragonguildname = doc.BaseData.dragonGuildName; + ChatParam chatParam2 = new ChatParam(); + chatParam2.link = new ChatParamLink(); + chatParam2.link.id = noticeData.linkparam; + chatParam2.link.content = noticeData.linkcontent; + chatParam2.dragonguild = chatParam.dragonguild; + list.Add(chatParam); + list.Add(chatParam2); + this._SendMessage((uint)noticeData.channel, string.Format(noticeData.info, doc.BaseData.dragonGuildName), list, true, false, true); + } + } + } + + public void SendSpectateInvitation(uint noticeid, uint liveID, LiveType liveType, params object[] args) + { + NoticeTable.RowData noticeData = this.GetNoticeData(noticeid); + bool flag = noticeData == null; + if (!flag) + { + List list = new List(); + list.Add(new ChatParam + { + //! + //link = new ChatParamLink(), + link = new ChatParamLink + { + id = noticeData.linkparam, + content = noticeData.linkcontent + }, + //spectate = new ChatParamSpectate(), + spectate = new ChatParamSpectate + { + liveid = liveID, + livetype = (uint)liveType + } + }); + uint activeChannelType = (uint)DlgBase.singleton.activeChannelType; + this._SendMessage(activeChannelType, string.Format(noticeData.info, args), list, true, false, false); + } + } + + public string GetSpectateLinkString(uint noticeid, params object[] args) + { + NoticeTable.RowData noticeData = this.GetNoticeData(noticeid); + bool flag = noticeData == null; + string result; + if (flag) + { + result = string.Empty; + } + else + { + string text = string.Format(noticeData.info, args); + text = text.Replace("$L", XSingleton.singleton.StringCombine("[56eaef][u]", noticeData.linkcontent, "[/u][-]")); + result = text; + } + return result; + } + + public void SendGuildInvitationPrivate() + { + XGuildDocument specificDocument = XDocuments.GetSpecificDocument(XGuildDocument.uuID); + bool flag = !specificDocument.CheckInGuild(); + if (!flag) + { + NoticeTable.RowData noticeData = this.GetNoticeData(NoticeType.NT_INVITE_GUILD_PRIVATE); + bool flag2 = noticeData == null; + if (!flag2) + { + List list = new List(); + ChatParam chatParam = new ChatParam(); + chatParam.role = new ChatParamRole(); + chatParam.role.uniqueid = XSingleton.singleton.XPlayerData.RoleID; + chatParam.role.name = XSingleton.singleton.XPlayerData.Name; + chatParam.role.profession = XSingleton.singleton.XPlayerData.TypeID; + ChatParam chatParam2 = new ChatParam(); + chatParam2.guild = new ChatParamGuild(); + chatParam2.guild.guildid = specificDocument.UID; + chatParam2.guild.guildname = specificDocument.BasicData.guildName; + ChatParam chatParam3 = new ChatParam(); + chatParam3.link = new ChatParamLink(); + chatParam3.link.id = noticeData.linkparam; + chatParam3.link.content = noticeData.linkcontent; + chatParam3.guild = chatParam2.guild; + list.Add(chatParam); + list.Add(chatParam2); + list.Add(chatParam3); + this._SendMessage((uint)noticeData.channel, string.Format(noticeData.info, XSingleton.singleton.XPlayerData.Name, specificDocument.BasicData.guildName), list, true, false, false); + } + } + } + + public void SendTeamInvitation(NoticeType teamType, uint teamid, uint expid, string expName) + { + NoticeTable.RowData noticeData = this.GetNoticeData(teamType); + bool flag = noticeData == null; + if (!flag) + { + List list = new List(); + list.Add(new ChatParam + { + //! + //team = new ChatParamTeam(), + team = new ChatParamTeam + { + teamid = teamid, + expeditionid = expid + }, + //link = new ChatParamLink(), + link = new ChatParamLink + { + id = noticeData.linkparam, + content = noticeData.linkcontent + } + }); + this._SendMessage((uint)noticeData.channel, string.Format(noticeData.info, expName), list, true, false, false); + } + } + + public string GetOpenSysLinkString(NoticeType noticeType, params object[] args) + { + NoticeTable.RowData byid = XInvitationDocument.m_NoticeTable.GetByid((uint)XFastEnumIntEqualityComparer.ToInt(noticeType)); + bool flag = byid == null; + string result; + if (flag) + { + result = string.Empty; + } + else + { + string text = string.Format(byid.info, args); + text = text.Replace("$L", XSingleton.singleton.StringCombine("[56eaef][u]", byid.linkcontent, "[/u][-]")); + result = text; + } + return result; + } + + public void SendOpenSysInvitation(NoticeType noticeType, params ulong[] param) + { + NoticeTable.RowData byid = XInvitationDocument.m_NoticeTable.GetByid((uint)XFastEnumIntEqualityComparer.ToInt(noticeType)); + bool flag = byid == null; + if (!flag) + { + List paramList = XInvitationDocument.GetParamList(byid, param); + int num = byid.channel; + bool flag2 = num == -9999; + if (flag2) + { + num = XFastEnumIntEqualityComparer.ToInt(DlgBase.singleton.activeChannelType); + } + this._SendMessage((uint)num, byid.info, paramList, true, false, false); + } + } + + public void SendOpenSysInvitation(XSysDefine sys, params ulong[] param) + { + NoticeTable.RowData noticeData = this.GetNoticeData(sys); + bool flag = noticeData == null; + if (!flag) + { + List paramList = XInvitationDocument.GetParamList(noticeData, param); + this._SendMessage((uint)noticeData.channel, noticeData.info, paramList, true, false, false); + } + } + + public void SendActivityInvitation(XSysDefine sys, ulong param = 0UL, bool self = true) + { + NoticeTable.RowData noticeData = this.GetNoticeData(sys); + bool flag = noticeData == null; + if (!flag) + { + List paramList = XInvitationDocument.GetParamList(noticeData, new ulong[] + { + param + }); + DlgBase.singleton.SendChatContent(noticeData.info, (ChatChannelType)noticeData.channel, self, paramList, true, 0UL, 0f, false, false); + } + } + + public static List GetParamList(NoticeTable.RowData data, params ulong[] param) + { + List list = new List(); + ChatParam chatParam = new ChatParam(); + chatParam.link = new ChatParamLink(); + chatParam.link.id = data.linkparam; + chatParam.link.content = data.linkcontent; + bool flag = param != null; + if (flag) + { + for (int i = 0; i < param.Length; i++) + { + chatParam.link.param.Add(param[i]); + } + } + list.Add(chatParam); + return list; + } + + public NoticeTable.RowData GetNoticeData(XSysDefine sys) + { + NoticeTable.RowData rowData = null; + uint num = 0u; + while ((ulong)num < (ulong)((long)XInvitationDocument.m_NoticeTable.Table.Length)) + { + rowData = XInvitationDocument.m_NoticeTable.Table[(int)num]; + bool flag = rowData.linkparam == (uint)sys && this._IsOpenSys((NoticeType)rowData.id); + if (flag) + { + break; + } + num += 1u; + rowData = null; + } + return rowData; + } + + public string ParseLink(ChatParam param) + { + bool flag = param.link == null; + string result; + if (flag) + { + result = ""; + } + else + { + string content = param.link.content; + bool flag2 = param.team != null; + if (flag2) + { + result = XLabelSymbolHelper.FormatTeam(content, (int)param.team.teamid, param.team.expeditionid); + } + else + { + bool flag3 = param.guild != null; + if (flag3) + { + result = XLabelSymbolHelper.FormatGuild(content, param.guild.guildid); + } + else + { + bool flag4 = param.dragonguild != null; + if (flag4) + { + result = XLabelSymbolHelper.FormatDragonGuild(content, param.dragonguild.dragonguildname); + } + else + { + bool flag5 = param.spectate != null; + if (flag5) + { + result = XLabelSymbolHelper.FormatSpectate(content, (int)param.spectate.liveid, (int)param.spectate.livetype); + } + else + { + result = XLabelSymbolHelper.FormatUI(content, (ulong)param.link.id, param.link.param); + } + } + } + } + } + return result; + } + + public static void OnUIHyperLinkClick(string param) + { + bool flag = DlgBase.singleton.IsLoaded(); + if (flag) + { + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("NOT_IN_HALL_SPECTATE"), "fece00"); + } + else + { + bool flag2 = XSingleton.singleton.CurrentStage.Stage != EXStage.Hall; + if (flag2) + { + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("NOT_IN_HALL_STAGE"), "fece00"); + } + else + { + SceneType sceneType = XSingleton.singleton.SceneType; + bool flag3 = sceneType == SceneType.SCENE_FAMILYGARDEN && XHomeCookAndPartyDocument.Doc.CurBanquetID > 0u; + if (flag3) + { + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("HomeFeasting"), "fece00"); + } + else + { + ulong num = 0UL; + List list = new List(); + bool flag4 = XLabelSymbolHelper.ParseUIParam(param, ref num, ref list); + if (flag4) + { + XSingleton.singleton.AddLog("UI link clicked: ", param, null, null, null, null, XDebugColor.XDebug_None); + bool flag5 = !XSingleton.singleton.IsSystemOpened((XSysDefine)num); + if (flag5) + { + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("SYSTEM_NOT_OPEN"), "fece00"); + } + else + { + XSysDefine xsysDefine = (XSysDefine)num; + if (xsysDefine <= XSysDefine.XSys_Home_Feast) + { + if (xsysDefine == XSysDefine.XSys_Personal_Career) + { + DlgBase.singleton.OpenOtherPush(list); + goto IL_29A; + } + if (xsysDefine == XSysDefine.XSys_Home_Feast) + { + bool flag6 = list.Count == 1; + if (flag6) + { + string name = ""; + bool flag7 = list[0] == XSingleton.singleton.XPlayerData.EntityID; + if (flag7) + { + name = XSingleton.singleton.XPlayerData.Name; + } + else + { + XFriendData friendDataById = DlgBase.singleton.GetFriendDataById(list[0]); + bool flag8 = friendDataById != null; + if (flag8) + { + name = friendDataById.name; + } + } + HomeMainDocument.Doc.ReqEnterHomeScene(list[0], name); + } + goto IL_29A; + } + } + else + { + if (xsysDefine == XSysDefine.XSys_Wedding) + { + bool flag9 = list.Count == 1; + if (flag9) + { + XWeddingDocument.Doc.WeddingInviteOperate(WeddingInviteOperType.Wedding_Apply, XSingleton.singleton.XPlayerData.RoleID, list[0]); + } + goto IL_29A; + } + if (xsysDefine == XSysDefine.XSys_GuildDialyDonate) + { + bool flag10 = list.Count == 1; + if (flag10) + { + XGuildDonateDocument.Doc.ShowViewWithID((uint)list[0], GuildDonateType.DailyDonate); + } + goto IL_29A; + } + if (xsysDefine == XSysDefine.XSys_GuildWeeklyDonate) + { + bool flag11 = list.Count == 1; + if (flag11) + { + XGuildDonateDocument.Doc.ShowViewWithID((uint)list[0], GuildDonateType.WeeklyDonate); + } + goto IL_29A; + } + } + XSingleton.singleton.OpenSystem((XSysDefine)num, 0UL); + IL_29A:; + } + } + } + } + } + } + + public static void OnSpectateClick(string param) + { + bool flag = DlgBase.singleton.IsLoaded(); + if (flag) + { + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("NOT_IN_HALL_SPECTATE"), "fece00"); + } + else + { + bool flag2 = XSingleton.singleton.CurrentStage.Stage != EXStage.Hall; + if (flag2) + { + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("NOT_IN_HALL_STAGE"), "fece00"); + } + else + { + bool flag3 = XLabelSymbolHelper.ParseSpectateParam(param, ref XInvitationDocument.mLiveID, ref XInvitationDocument.mType); + if (flag3) + { + XSingleton.singleton.AddLog(string.Concat(new object[] + { + "xxxxxxxxxxx=> liveid: ", + XInvitationDocument.mLiveID, + " type: ", + XInvitationDocument.mType + }), null, null, null, null, null, XDebugColor.XDebug_None); + DlgBase.singleton.SetVisible(true, true); + DlgBase.singleton.SetSingleButtonMode(false); + string @string = XStringDefineProxy.GetString("Spectate_Sure"); + 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(XInvitationDocument.OnGoSpectate), null); + } + } + } + } + + private static bool OnGoSpectate(IXUIButton btn) + { + DlgBase.singleton.SetVisible(false, true); + XSpectateDocument specificDocument = XDocuments.GetSpecificDocument(XSpectateDocument.uuID); + specificDocument.EnterSpectateBattle((uint)XInvitationDocument.mLiveID, (LiveType)XInvitationDocument.mType); + return true; + } + + protected override void OnReconnected(XReconnectedEventArgs arg) + { + } + } +} -- cgit v1.1-26-g67d0