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

namespace XMainClient.UI
{
	internal class XMentorshipCandidatesView : DlgBase<XMentorshipCandidatesView, XMentorshipCandidatesBehavior>
	{
		public override string fileName
		{
			get
			{
				return "GameSystem/TeacherPupilInvitation";
			}
		}

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

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

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

		protected override void Init()
		{
			this.InitProperties();
		}

		protected override void OnUnload()
		{
			base.OnUnload();
		}

		public override void RegisterEvent()
		{
			base.RegisterEvent();
		}

		protected override void OnShow()
		{
			base.OnShow();
			this.RefreshTitleAndDownBtn();
			bool flag = XMentorshipDocument.Doc.CurViewType == CandidatesViewType.Application;
			if (flag)
			{
				XMentorshipDocument.Doc.SendCandidatesOpReq(EMentorMsgOpType.EMentorMsgOp_Get, 0UL, MentorMsgApplyType.MentorMsgApplyMax, 0, false);
			}
			else
			{
				bool flag2 = XMentorshipDocument.Doc.CurViewType == CandidatesViewType.Recommend;
				if (flag2)
				{
					bool flag3 = XMentorshipDocument.Doc.CurRecommendType == CandidatesViewRecommendType.Master;
					if (flag3)
					{
						XMentorshipDocument.Doc.SendToGetMyApplyMasterInfo(false);
					}
					else
					{
						XMentorshipDocument.Doc.SendToGetMyApplyPupilsInfo(false);
					}
				}
			}
		}

		private void RefreshTitleAndDownBtn()
		{
			bool flag = XMentorshipDocument.Doc.CurViewType == CandidatesViewType.Application;
			if (flag)
			{
				base.uiBehaviour.titleContent.SetText(XSingleton<XStringTable>.singleton.GetString("MentorshipApply"));
				base.uiBehaviour.btnContent.SetText(XSingleton<XStringTable>.singleton.GetString("MentorshipClear"));
			}
			else
			{
				bool flag2 = XMentorshipDocument.Doc.CurViewType == CandidatesViewType.Recommend;
				if (flag2)
				{
					base.uiBehaviour.titleContent.SetText(XSingleton<XStringTable>.singleton.GetString("MentorshipRecommend"));
					base.uiBehaviour.btnContent.SetText(XSingleton<XStringTable>.singleton.GetString("FRIEND_ADDDLG_NO_COUNTDOWN"));
				}
			}
			base.uiBehaviour.ClearBtn.SetEnable(true, false);
			base.uiBehaviour.btnContent.SetText(XStringDefineProxy.GetString("FRIEND_ADDDLG_NO_COUNTDOWN"));
		}

		protected override void OnHide()
		{
			base.OnHide();
			XMentorshipDocument.Doc.ResetCandidatesView();
		}

		public void RefreshUI()
		{
			int canidatesShowMsgCount = XMentorshipDocument.Doc.GetCanidatesShowMsgCount();
			base.uiBehaviour.WrapContent.SetContentCount(canidatesShowMsgCount, false);
			base.uiBehaviour.ScrollView.ResetPosition();
		}

		public void RefreshAllVisible()
		{
			base.uiBehaviour.WrapContent.RefreshAllVisibleContents();
		}

		public void RefreshCDTimeLabel(int leftTime)
		{
			bool flag = leftTime > 0;
			if (flag)
			{
				base.uiBehaviour.ClearBtn.SetEnable(false, false);
				base.uiBehaviour.btnContent.SetText(string.Format(XStringDefineProxy.GetString("FRIEND_ADDDLG_COUNTDOWN_FMT"), leftTime));
			}
			else
			{
				base.uiBehaviour.ClearBtn.SetEnable(true, false);
				base.uiBehaviour.btnContent.SetText(XStringDefineProxy.GetString("FRIEND_ADDDLG_NO_COUNTDOWN"));
			}
		}

		private void InitProperties()
		{
			base.uiBehaviour.CloseBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnCloseDialog));
			base.uiBehaviour.ClearBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnClearNews));
			base.uiBehaviour.WrapContent.RegisterItemInitEventHandler(new WrapItemInitEventHandler(this.OnWrapContentItemInit));
			base.uiBehaviour.WrapContent.RegisterItemUpdateEventHandler(new WrapItemUpdateEventHandler(this.OnWrapContentItemUpdate));
		}

		private bool OnClearNews(IXUIButton button)
		{
			bool flag = XMentorshipDocument.Doc.CurViewType == CandidatesViewType.Application;
			if (flag)
			{
				XMentorshipDocument.Doc.SendCandidatesOpReq(EMentorMsgOpType.EMentorMsgOpType_Clear, 0UL, MentorMsgApplyType.MentorMsgApplyMax, 0, false);
			}
			else
			{
				bool flag2 = XMentorshipDocument.Doc.CurViewType == CandidatesViewType.Recommend;
				if (flag2)
				{
					bool flag3 = XMentorshipDocument.Doc.CurRecommendType == CandidatesViewRecommendType.Master;
					if (flag3)
					{
						XMentorshipDocument.Doc.SendToGetMyApplyMasterInfo(true);
					}
					else
					{
						XMentorshipDocument.Doc.SendToGetMyApplyPupilsInfo(true);
					}
				}
			}
			return true;
		}

		private bool OnCloseDialog(IXUIButton button)
		{
			this.SetVisibleWithAnimation(false, null);
			return true;
		}

		private void OnWrapContentItemUpdate(Transform itemTransform, int index)
		{
			IXUIButton ixuibutton = itemTransform.Find("Accept").GetComponent("XUIButton") as IXUIButton;
			ixuibutton.gameObject.SetActive(XMentorshipDocument.Doc.CurViewType == CandidatesViewType.Application);
			IXUIButton ixuibutton2 = itemTransform.Find("Refuse").GetComponent("XUIButton") as IXUIButton;
			ixuibutton2.gameObject.SetActive(XMentorshipDocument.Doc.CurViewType == CandidatesViewType.Application);
			IXUIButton ixuibutton3 = itemTransform.Find("Mentorship").GetComponent("XUIButton") as IXUIButton;
			ixuibutton3.gameObject.SetActive(XMentorshipDocument.Doc.CurViewType == CandidatesViewType.Recommend);
			MessageShowInfoItem candidateMsgShowInfo = XMentorshipDocument.Doc.GetCandidateMsgShowInfo(index);
			bool flag = candidateMsgShowInfo != null;
			if (flag)
			{
				IXUILabel ixuilabel = itemTransform.Find("level").GetComponent("XUILabel") as IXUILabel;
				ixuilabel.SetText(candidateMsgShowInfo.roleInfo.level.ToString());
				uint titleID = (candidateMsgShowInfo.roleInfo.outlook != null && candidateMsgShowInfo.roleInfo.outlook.title != null) ? candidateMsgShowInfo.roleInfo.outlook.title.titleID : 0u;
				IXUILabelSymbol ixuilabelSymbol = itemTransform.Find("Name").GetComponent("XUILabelSymbol") as IXUILabelSymbol;
				ixuilabelSymbol.InputText = XTitleDocument.GetTitleWithFormat(titleID, candidateMsgShowInfo.roleInfo.name);
				IXUISprite ixuisprite = itemTransform.Find("head").GetComponent("XUISprite") as IXUISprite;
				ixuisprite.spriteName = XSingleton<XProfessionSkillMgr>.singleton.GetProfHeadIcon2((int)((int)candidateMsgShowInfo.roleInfo.type % 10));
				IXUISprite ixuisprite2 = itemTransform.Find("Profession").GetComponent("XUISprite") as IXUISprite;
				ixuisprite2.spriteName = XSingleton<XProfessionSkillMgr>.singleton.GetProfIcon((int)((int)candidateMsgShowInfo.roleInfo.type % 10));
				IXUILabel ixuilabel2 = itemTransform.Find("PromiseWords").GetComponent("XUILabel") as IXUILabel;
				ixuilabel2.SetText(candidateMsgShowInfo.promiseWords);
				IXUILabel ixuilabel3 = itemTransform.Find("Mentorship/T").GetComponent("XUILabel") as IXUILabel;
				bool flag2 = XMentorshipDocument.Doc.CurViewType == CandidatesViewType.Application;
				if (flag2)
				{
					ixuibutton.ID = (ulong)((long)index);
					ixuibutton2.ID = (ulong)((long)index);
				}
				else
				{
					ixuibutton3.ID = candidateMsgShowInfo.roleInfo.roleID;
					bool applied = candidateMsgShowInfo.applied;
					if (applied)
					{
						ixuibutton3.SetEnable(false, false);
						ixuilabel3.SetText(XSingleton<XStringTable>.singleton.GetString("CHAT_SENT"));
					}
					else
					{
						ixuibutton3.SetEnable(true, false);
						bool flag3 = XMentorshipDocument.Doc.CurRecommendType == CandidatesViewRecommendType.Master;
						if (flag3)
						{
							ixuilabel3.SetText(XSingleton<XStringTable>.singleton.GetString("MentorshipMaster"));
						}
						else
						{
							ixuilabel3.SetText(XSingleton<XStringTable>.singleton.GetString("MentorshipPupil"));
						}
					}
				}
			}
		}

		private void OnStartPlayAudio(IXUISprite uiSprite)
		{
		}

		private void OnStopSignPlay(object ob)
		{
			IXUISpriteAnimation ixuispriteAnimation = (IXUISpriteAnimation)ob;
			bool flag = ixuispriteAnimation != null;
			if (flag)
			{
				ixuispriteAnimation.SetFrameRate(0);
				ixuispriteAnimation.Reset();
			}
		}

		private void UpdateOpBtnState(Transform itemTransform)
		{
			IXUIButton ixuibutton = itemTransform.Find("Accept").GetComponent("XUIButton") as IXUIButton;
			ixuibutton.gameObject.SetActive(XMentorshipDocument.Doc.CurViewType == CandidatesViewType.Application);
			IXUIButton ixuibutton2 = itemTransform.Find("Refuse").GetComponent("XUIButton") as IXUIButton;
			ixuibutton2.gameObject.SetActive(XMentorshipDocument.Doc.CurViewType == CandidatesViewType.Application);
			IXUIButton ixuibutton3 = itemTransform.Find("Mentorship").GetComponent("XUIButton") as IXUIButton;
			ixuibutton3.gameObject.SetActive(XMentorshipDocument.Doc.CurViewType == CandidatesViewType.Recommend);
		}

		private void OnPlayPromiseVoice(IXUISprite uiSprite)
		{
		}

		private void OnWrapContentItemInit(Transform itemTransform, int index)
		{
			IXUIButton ixuibutton = itemTransform.Find("Accept").GetComponent("XUIButton") as IXUIButton;
			ixuibutton.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnClickAcceptCandidate));
			IXUIButton ixuibutton2 = itemTransform.Find("Refuse").GetComponent("XUIButton") as IXUIButton;
			ixuibutton2.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnClickRefuseCandidate));
			IXUIButton ixuibutton3 = itemTransform.Find("Mentorship").GetComponent("XUIButton") as IXUIButton;
			ixuibutton3.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnMentorshipClicked));
		}

		private bool OnMentorshipClicked(IXUIButton button)
		{
			bool flag = XMentorshipDocument.Doc.CurRecommendType == CandidatesViewRecommendType.Master;
			if (flag)
			{
				XMentorshipDocument.Doc.SendMentorRelationOp(MentorRelationOpType.MentorRelationOp_ApplyMaster, button.ID, 0);
			}
			else
			{
				XMentorshipDocument.Doc.SendMentorRelationOp(MentorRelationOpType.MentorRelationOp_ApplyStudent, button.ID, 0);
			}
			return true;
		}

		private bool OnClickRefuseCandidate(IXUIButton button)
		{
			MessageShowInfoItem candidateMsgShowInfo = XMentorshipDocument.Doc.GetCandidateMsgShowInfo((int)button.ID);
			bool flag = candidateMsgShowInfo != null;
			if (flag)
			{
				XMentorshipDocument.Doc.SendCandidatesOpReq(EMentorMsgOpType.EMentorMsgOpType_Reject, candidateMsgShowInfo.roleInfo.roleID, candidateMsgShowInfo.msgType, 0, false);
			}
			return true;
		}

		private bool OnClickAcceptCandidate(IXUIButton button)
		{
			MessageShowInfoItem candidateMsgShowInfo = XMentorshipDocument.Doc.GetCandidateMsgShowInfo((int)button.ID);
			bool flag = candidateMsgShowInfo != null;
			if (flag)
			{
				XMentorshipDocument.Doc.SendCandidatesOpReq(EMentorMsgOpType.EMentorMsgOpType_Agree, candidateMsgShowInfo.roleInfo.roleID, candidateMsgShowInfo.msgType, 0, false);
			}
			return true;
		}
	}
}