summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/XInvitationDocument.cs
blob: 8aaf6132c129ab1aa74d5c6b435db29d73194e24 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
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<XCommon>.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<ChatParam> 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<NoticeType>.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<ChatParam> 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<XChatView, XChatBehaviour>.singleton.CheckWorldSendMsg(false, new ButtonClickEventHandler(this._RealSendMsg), ChatChannelType.World);
				if (flag2)
				{
					DlgBase<XChatView, XChatBehaviour>.singleton.SendChatContent(content, (ChatChannelType)channel, true, param, bIsSystem, 0UL, 0f, isRecruit, isDragonGuildRecruit);
				}
			}
			else
			{
				DlgBase<XChatView, XChatBehaviour>.singleton.SendChatContent(content, (ChatChannelType)channel, true, param, bIsSystem, 0UL, 0f, isRecruit, isDragonGuildRecruit);
			}
		}

		private bool _RealSendMsg(IXUIButton btn)
		{
			DlgBase<XChatView, XChatBehaviour>.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<XChatView, XChatBehaviour>.singleton.CheckSelect(btn);
		}

		public void SendGuildInvitation()
		{
			XGuildDocument specificDocument = XDocuments.GetSpecificDocument<XGuildDocument>(XGuildDocument.uuID);
			bool flag = !specificDocument.CheckInGuild();
			if (!flag)
			{
				NoticeTable.RowData noticeData = this.GetNoticeData(NoticeType.NT_INVITE_GUILD);
				bool flag2 = noticeData == null;
				if (!flag2)
				{
					List<ChatParam> list = new List<ChatParam>();
					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<ChatParam> list = new List<ChatParam>();
					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<ChatParam> list = new List<ChatParam>();
				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<XChatView, XChatBehaviour>.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<XCommon>.singleton.StringCombine("[56eaef][u]", noticeData.linkcontent, "[/u][-]"));
				result = text;
			}
			return result;
		}

		public void SendGuildInvitationPrivate()
		{
			XGuildDocument specificDocument = XDocuments.GetSpecificDocument<XGuildDocument>(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<ChatParam> list = new List<ChatParam>();
					ChatParam chatParam = new ChatParam();
					chatParam.role = new ChatParamRole();
					chatParam.role.uniqueid = XSingleton<XAttributeMgr>.singleton.XPlayerData.RoleID;
					chatParam.role.name = XSingleton<XAttributeMgr>.singleton.XPlayerData.Name;
					chatParam.role.profession = XSingleton<XAttributeMgr>.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<XAttributeMgr>.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<ChatParam> list = new List<ChatParam>();
				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<NoticeType>.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<XCommon>.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<NoticeType>.ToInt(noticeType));
			bool flag = byid == null;
			if (!flag)
			{
				List<ChatParam> paramList = XInvitationDocument.GetParamList(byid, param);
				int num = byid.channel;
				bool flag2 = num == -9999;
				if (flag2)
				{
					num = XFastEnumIntEqualityComparer<ChatChannelType>.ToInt(DlgBase<XChatView, XChatBehaviour>.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<ChatParam> 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<ChatParam> paramList = XInvitationDocument.GetParamList(noticeData, new ulong[]
				{
					param
				});
				DlgBase<XChatView, XChatBehaviour>.singleton.SendChatContent(noticeData.info, (ChatChannelType)noticeData.channel, self, paramList, true, 0UL, 0f, false, false);
			}
		}

		public static List<ChatParam> GetParamList(NoticeTable.RowData data, params ulong[] param)
		{
			List<ChatParam> list = new List<ChatParam>();
			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<SpectateSceneView, SpectateSceneBehaviour>.singleton.IsLoaded();
			if (flag)
			{
				XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("NOT_IN_HALL_SPECTATE"), "fece00");
			}
			else
			{
				bool flag2 = XSingleton<XGame>.singleton.CurrentStage.Stage != EXStage.Hall;
				if (flag2)
				{
					XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("NOT_IN_HALL_STAGE"), "fece00");
				}
				else
				{
					SceneType sceneType = XSingleton<XScene>.singleton.SceneType;
					bool flag3 = sceneType == SceneType.SCENE_FAMILYGARDEN && XHomeCookAndPartyDocument.Doc.CurBanquetID > 0u;
					if (flag3)
					{
						XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("HomeFeasting"), "fece00");
					}
					else
					{
						ulong num = 0UL;
						List<ulong> list = new List<ulong>();
						bool flag4 = XLabelSymbolHelper.ParseUIParam(param, ref num, ref list);
						if (flag4)
						{
							XSingleton<XDebug>.singleton.AddLog("UI link clicked: ", param, null, null, null, null, XDebugColor.XDebug_None);
							bool flag5 = !XSingleton<XGameSysMgr>.singleton.IsSystemOpened((XSysDefine)num);
							if (flag5)
							{
								XSingleton<UiUtility>.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<PersonalCareerView, PersonalCareerBehaviour>.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<XAttributeMgr>.singleton.XPlayerData.EntityID;
											if (flag7)
											{
												name = XSingleton<XAttributeMgr>.singleton.XPlayerData.Name;
											}
											else
											{
												XFriendData friendDataById = DlgBase<XFriendsView, XFriendsBehaviour>.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<XAttributeMgr>.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<XGameSysMgr>.singleton.OpenSystem((XSysDefine)num, 0UL);
								IL_29A:;
							}
						}
					}
				}
			}
		}

		public static void OnSpectateClick(string param)
		{
			bool flag = DlgBase<SpectateSceneView, SpectateSceneBehaviour>.singleton.IsLoaded();
			if (flag)
			{
				XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("NOT_IN_HALL_SPECTATE"), "fece00");
			}
			else
			{
				bool flag2 = XSingleton<XGame>.singleton.CurrentStage.Stage != EXStage.Hall;
				if (flag2)
				{
					XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("NOT_IN_HALL_STAGE"), "fece00");
				}
				else
				{
					bool flag3 = XLabelSymbolHelper.ParseSpectateParam(param, ref XInvitationDocument.mLiveID, ref XInvitationDocument.mType);
					if (flag3)
					{
						XSingleton<XDebug>.singleton.AddLog(string.Concat(new object[]
						{
							"xxxxxxxxxxx=> liveid: ",
							XInvitationDocument.mLiveID,
							" type: ",
							XInvitationDocument.mType
						}), null, null, null, null, null, XDebugColor.XDebug_None);
						DlgBase<ModalDlg, ModalDlgBehaviour>.singleton.SetVisible(true, true);
						DlgBase<ModalDlg, ModalDlgBehaviour>.singleton.SetSingleButtonMode(false);
						string @string = XStringDefineProxy.GetString("Spectate_Sure");
						string string2 = XStringDefineProxy.GetString(XStringDefine.COMMON_OK);
						string string3 = XStringDefineProxy.GetString(XStringDefine.COMMON_CANCEL);
						DlgBase<ModalDlg, ModalDlgBehaviour>.singleton.SetLabelsWithSymbols(@string, string2, string3);
						DlgBase<ModalDlg, ModalDlgBehaviour>.singleton.SetModalCallback(new ButtonClickEventHandler(XInvitationDocument.OnGoSpectate), null);
					}
				}
			}
		}

		private static bool OnGoSpectate(IXUIButton btn)
		{
			DlgBase<ModalDlg, ModalDlgBehaviour>.singleton.SetVisible(false, true);
			XSpectateDocument specificDocument = XDocuments.GetSpecificDocument<XSpectateDocument>(XSpectateDocument.uuID);
			specificDocument.EnterSpectateBattle((uint)XInvitationDocument.mLiveID, (LiveType)XInvitationDocument.mType);
			return true;
		}

		protected override void OnReconnected(XReconnectedEventArgs arg)
		{
		}
	}
}