summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/UI/XTeamInviteView.cs
blob: 617bc6adfbb9e0dab7d8c30919a4c353bca18fd6 (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
using System;
using System.Collections.Generic;
using KKSG;
using UILib;
using UnityEngine;
using XMainClient.UI.UICommon;
using XUtliPoolLib;

namespace XMainClient.UI
{
	internal class XTeamInviteView : DlgBase<XTeamInviteView, XTeamInviteBehaviour>
	{
		public override string fileName
		{
			get
			{
				return "Team/TeamInviteDlg";
			}
		}

		public override int layer
		{
			get
			{
				return 1;
			}
		}

		public override int group
		{
			get
			{
				return 1;
			}
		}

		public override bool autoload
		{
			get
			{
				return true;
			}
		}

		private int m_SelectedTab = -1;

		private XTeamDocument _TeamDoc;

		private XTeamInviteDocument _InviteDoc;

		private XGuildDocument _GuildDoc;

		public List<IXUITexture> _WrapTextureList = new List<IXUITexture>();

		private bool hasPlatFriends = false;

		protected override void Init()
		{
			this._TeamDoc = XDocuments.GetSpecificDocument<XTeamDocument>(XTeamDocument.uuID);
			this._GuildDoc = XDocuments.GetSpecificDocument<XGuildDocument>(XGuildDocument.uuID);
			this._InviteDoc = XDocuments.GetSpecificDocument<XTeamInviteDocument>(XTeamInviteDocument.uuID);
			this._InviteDoc.InviteHandler = this;
		}

		protected override void OnHide()
		{
			this.ClearPreTabTextures();
			this.hasPlatFriends = false;
			base.OnHide();
		}

		protected override void OnUnload()
		{
			this._InviteDoc.InviteHandler = null;
			base.OnUnload();
		}

		public override void RegisterEvent()
		{
			base.RegisterEvent();
			base.uiBehaviour.m_ToggleFriend.RegisterOnCheckEventHandler(new CheckBoxOnCheckEventHandler(this._OnToggleChanged));
			base.uiBehaviour.m_ToggleGuild.RegisterOnCheckEventHandler(new CheckBoxOnCheckEventHandler(this._OnToggleChanged));
			base.uiBehaviour.m_ToggleRecommand.RegisterOnCheckEventHandler(new CheckBoxOnCheckEventHandler(this._OnToggleChanged));
			base.uiBehaviour.m_TogglePlatFriend.RegisterOnCheckEventHandler(new CheckBoxOnCheckEventHandler(this._OnToggleChanged));
			base.uiBehaviour.m_BtnAddFriendMiddle.RegisterClickEventHandler(new ButtonClickEventHandler(this._OnAddFriendClicked));
			base.uiBehaviour.m_BtnAddFriendBottom.RegisterClickEventHandler(new ButtonClickEventHandler(this._OnAddFriendClicked));
			base.uiBehaviour.m_BtnJoinGuild.RegisterClickEventHandler(new ButtonClickEventHandler(this._OnJoinGuildClicked));
			base.uiBehaviour.m_WrapContent.RegisterItemUpdateEventHandler(new WrapItemUpdateEventHandler(this._WrapContentItemUpdated));
			base.uiBehaviour.m_WrapContent.RegisterItemInitEventHandler(new WrapItemInitEventHandler(this._WrapContentItemInit));
			base.uiBehaviour.m_ClosedSpr.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this._OnCloseClicked));
		}

		protected override void OnShow()
		{
			base.OnShow();
			this._TryRefresh();
		}

		public override void StackRefresh()
		{
			this._TryRefresh();
		}

		private void _TryRefresh()
		{
			this._InviteDoc.ReqInviteList();
			bool flag = this.m_SelectedTab != -1;
			if (flag)
			{
				this.Refresh();
			}
		}

		public void LocalServerRefresh()
		{
			bool flag = this.m_SelectedTab != 3;
			if (flag)
			{
				this.Refresh();
			}
		}

		public void Refresh()
		{
			bool flag = this._TeamDoc.currentExpInfo.isCrossServerInvite && XSingleton<XGameSysMgr>.singleton.IsSystemOpened(XSysDefine.XSys_Friends_Pk);
			if (flag)
			{
				base.uiBehaviour.m_TogglePlatFriend.gameObject.SetActive(true);
			}
			else
			{
				base.uiBehaviour.m_TogglePlatFriend.gameObject.SetActive(false);
				bool flag2 = this.m_SelectedTab == 3;
				if (flag2)
				{
					this.m_SelectedTab = 0;
				}
			}
			bool flag3 = this.m_SelectedTab == 3 && !this.hasPlatFriends;
			if (flag3)
			{
				XSingleton<XDebug>.singleton.AddLog("[InvitePlatFriend]ReqPlatFriendsRank", null, null, null, null, null, XDebugColor.XDebug_None);
				XFriendsDocument specificDocument = XDocuments.GetSpecificDocument<XFriendsDocument>(XFriendsDocument.uuID);
				specificDocument.ReqPlatFriendsRank();
				this.hasPlatFriends = true;
			}
			else
			{
				int num = 0;
				bool flag4 = this.m_SelectedTab != -1;
				if (flag4)
				{
					num = this._InviteDoc.InviteLists[this.m_SelectedTab].Count;
				}
				XSingleton<XDebug>.singleton.AddGreenLog(string.Concat(new object[]
				{
					"m_SelectedTab:",
					this.m_SelectedTab,
					"\ndataCount:",
					num
				}), null, null, null, null, null);
				base.uiBehaviour.m_WrapContent.SetContentCount(num, false);
				base.uiBehaviour.m_ScrollView.ResetPosition();
				base.uiBehaviour.m_EmptyList.SetActive(num == 0);
				base.uiBehaviour.m_BtnAddFriendMiddle.SetVisible(this.m_SelectedTab == 1 && num <= 1);
				base.uiBehaviour.m_BtnAddFriendBottom.SetVisible(this.m_SelectedTab == 1 && num > 1 && num <= 2);
				base.uiBehaviour.m_BtnJoinGuild.SetVisible(this.m_SelectedTab == 2 && !this._GuildDoc.bInGuild);
			}
		}

		private void _WrapContentItemInit(Transform t, int index)
		{
			IXUIButton ixuibutton = t.Find("BtnInvite").GetComponent("XUIButton") as IXUIButton;
			ixuibutton.RegisterClickEventHandler(new ButtonClickEventHandler(this._OnInviteClick));
		}

		private void _WrapContentItemUpdated(Transform t, int index)
		{
			bool flag = this.m_SelectedTab < 0;
			if (!flag)
			{
				bool flag2 = index >= this._InviteDoc.InviteLists[this.m_SelectedTab].Count;
				if (!flag2)
				{
					XTeamInviteListData xteamInviteListData = this._InviteDoc.InviteLists[this.m_SelectedTab][index];
					bool flag3 = xteamInviteListData == null;
					if (!flag3)
					{
						IXUILabelSymbol ixuilabelSymbol = t.Find("Info/Name").GetComponent("XUILabelSymbol") as IXUILabelSymbol;
						IXUILabel ixuilabel = t.Find("Info/Level").GetComponent("XUILabel") as IXUILabel;
						IXUISprite ixuisprite = t.Find("Info/AvatarBG/Avatar").GetComponent("XUISprite") as IXUISprite;
						IXUISprite ixuisprite2 = t.Find("Info/Profession").GetComponent("XUISprite") as IXUISprite;
						IXUILabel ixuilabel2 = t.Find("Info/AvatarBG/BattlePointBG/Power").GetComponent("XUILabel") as IXUILabel;
						IXUILabel ixuilabel3 = t.Find("Info/GuildName").GetComponent("XUILabel") as IXUILabel;
						IXUIButton ixuibutton = t.Find("BtnInvite").GetComponent("XUIButton") as IXUIButton;
						GameObject gameObject = t.Find("Invited").gameObject;
						IXUILabel ixuilabel4 = t.Find("State").GetComponent("XUILabel") as IXUILabel;
						Transform t2 = t.Find("Info/AvatarBG/Relation");
						Transform transform = t.Find("Info/AvatarBG/Plat/wxLaunch");
						Transform transform2 = t.Find("Info/AvatarBG/Plat/qqLaunch");
						Transform transform3 = t.Find("Info/AvatarBG/Status/Online");
						Transform transform4 = t.Find("Info/AvatarBG/Status/Offline");
						ixuilabelSymbol.InputText = XSingleton<XCommon>.singleton.StringCombine(xteamInviteListData.name, XRechargeDocument.GetVIPIconString(xteamInviteListData.vip));
						ixuilabel.SetText("Lv." + xteamInviteListData.level.ToString());
						ixuisprite.spriteName = XSingleton<XProfessionSkillMgr>.singleton.GetProfHeadIcon2((int)xteamInviteListData.profession);
						ixuisprite2.spriteName = XSingleton<XProfessionSkillMgr>.singleton.GetProfIcon((int)xteamInviteListData.profession);
						ixuilabel2.SetText(xteamInviteListData.ppt.ToString());
						bool flag4 = string.IsNullOrEmpty(xteamInviteListData.guildname);
						if (flag4)
						{
							ixuilabel3.SetVisible(false);
						}
						else
						{
							ixuilabel3.SetText(xteamInviteListData.guildname);
							ixuilabel3.SetVisible(true);
						}
						XTeamRelation.Relation targetRelation = XTeamRelation.Relation.TR_NONE;
						bool flag5 = this.m_SelectedTab == 1;
						if (flag5)
						{
							targetRelation = (XTeamRelation.Relation)5;
						}
						else
						{
							bool flag6 = this.m_SelectedTab == 2;
							if (flag6)
							{
								targetRelation = XTeamRelation.Relation.TR_GUILD;
							}
						}
						XTeamView.SetTeamRelationUI(t2, xteamInviteListData.relation, true, targetRelation);
						ixuibutton.ID = (ulong)((long)index);
						ixuibutton.SetVisible(!xteamInviteListData.bSent);
						gameObject.SetActive(xteamInviteListData.bSent);
						bool flag7 = this.m_SelectedTab == 0;
						if (flag7)
						{
							ixuilabel4.SetText(string.Empty);
						}
						else
						{
							ixuilabel4.SetText(XStringDefineProxy.GetString(xteamInviteListData.state.ToString()));
						}
						bool flag8 = this.m_SelectedTab == 3;
						if (flag8)
						{
							transform2.gameObject.SetActive(XSingleton<XLoginDocument>.singleton.Channel == XAuthorizationChannel.XAuthorization_QQ);
							transform.gameObject.SetActive(true);
							transform3.gameObject.SetActive(false);
							transform4.gameObject.SetActive(true);
						}
						else
						{
							transform2.gameObject.SetActive(false);
							transform.gameObject.SetActive(false);
							transform3.gameObject.SetActive(false);
							transform4.gameObject.SetActive(false);
						}
						IXUITexture ixuitexture = t.Find("Info/AvatarBG/platHead").GetComponent("XUITexture") as IXUITexture;
						bool flag9 = this.m_SelectedTab == 3;
						if (flag9)
						{
							transform2.gameObject.SetActive(XSingleton<XLoginDocument>.singleton.Channel == XAuthorizationChannel.XAuthorization_QQ);
							transform.gameObject.SetActive(XSingleton<XLoginDocument>.singleton.Channel == XAuthorizationChannel.XAuthorization_WeChat);
							transform3.gameObject.SetActive(xteamInviteListData.isOnline);
							transform4.gameObject.SetActive(!xteamInviteListData.isOnline);
							ixuitexture.gameObject.SetActive(true);
							ixuitexture.ID = (ulong)((long)index);
							string bigpic = xteamInviteListData.bigpic;
							XSingleton<XUICacheImage>.singleton.Load((bigpic != "") ? bigpic : string.Empty, ixuitexture, DlgBase<XTeamInviteView, XTeamInviteBehaviour>.singleton.uiBehaviour);
							this._WrapTextureList.Add(ixuitexture);
						}
						else
						{
							transform2.gameObject.SetActive(false);
							transform.gameObject.SetActive(false);
							transform3.gameObject.SetActive(false);
							transform4.gameObject.SetActive(false);
							ixuitexture.gameObject.SetActive(false);
						}
					}
				}
			}
		}

		public void ClearPreTabTextures()
		{
			for (int i = 0; i < this._WrapTextureList.Count; i++)
			{
				this._WrapTextureList[i].SetTexturePath("");
			}
			this._WrapTextureList.Clear();
		}

		public override void OnXNGUIClick(GameObject obj, string path)
		{
			base.OnXNGUIClick(obj, path);
		}

		private void _OnCloseClicked(IXUISprite iSp)
		{
			this.SetVisible(false, true);
		}

		private bool _OnToggleChanged(IXUICheckBox go)
		{
			bool flag = !go.bChecked;
			bool result;
			if (flag)
			{
				result = true;
			}
			else
			{
				this.m_SelectedTab = (int)go.ID;
				this.Refresh();
				result = true;
			}
			return result;
		}

		private bool _OnInviteClick(IXUIButton go)
		{
			bool flag = this.m_SelectedTab < 0;
			bool result;
			if (flag)
			{
				result = true;
			}
			else
			{
				XTeamInviteListData xteamInviteListData = this._InviteDoc.InviteLists[this.m_SelectedTab][(int)go.ID];
				bool flag2 = xteamInviteListData == null;
				if (flag2)
				{
					result = true;
				}
				else
				{
					bool flag3 = xteamInviteListData.sameGuild == 0;
					if (flag3)
					{
						XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("TEAM_INVITE_NOT_SAMEGUILD"), "fece00");
						result = true;
					}
					else
					{
						bool flag4 = this.m_SelectedTab == 3;
						if (flag4)
						{
							XSingleton<XDebug>.singleton.AddLog("[InvitePlatFriend]_OnInviteClick", null, null, null, null, null, XDebugColor.XDebug_None);
							this._TeamDoc.ReqTeamOp(TeamOperate.TEAM_INVITE, 0UL, null, TeamMemberType.TMT_NORMAL, xteamInviteListData.openid);
						}
						else
						{
							this._TeamDoc.ReqTeamOp(TeamOperate.TEAM_INVITE, xteamInviteListData.uid, null, TeamMemberType.TMT_NORMAL, null);
						}
						xteamInviteListData.bSent = true;
						base.uiBehaviour.m_WrapContent.RefreshAllVisibleContents();
						result = true;
					}
				}
			}
			return result;
		}

		private bool _OnAddFriendClicked(IXUIButton btn)
		{
			this.SetVisibleWithAnimation(false, null);
			DlgBase<XFriendsView, XFriendsBehaviour>.singleton.RandomFriend();
			return true;
		}

		private bool _OnJoinGuildClicked(IXUIButton btn)
		{
			bool flag = !XSingleton<XGameSysMgr>.singleton.IsSystemOpened(XSysDefine.XSys_Guild);
			bool result;
			if (flag)
			{
				XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("GUILD_LOG_CANNOT_JOIN"), "fece00");
				result = true;
			}
			else
			{
				this.SetVisibleWithAnimation(false, null);
				DlgBase<XGuildListView, XGuildListBehaviour>.singleton.SetVisibleWithAnimation(true, null);
				result = true;
			}
			return result;
		}
	}
}