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

namespace XMainClient.UI
{
	internal class FirstPassGuindRankHandler : DlgHandlerBase
	{
		protected override string FileName
		{
			get
			{
				return "OperatingActivity/FirstPassGuildRank";
			}
		}

		private IXUILabel m_TimeLabel;

		private IXUILabel m_DescLabel;

		private IXUILabel m_MarkLabel;

		private IXUILabel m_UnJoinLabel;

		private IXUILabel m_GuildRankLabel;

		private IXUIButton m_ShowRank;

		private IXUIButton m_JoinGuild;

		private IXUIScrollView m_ScrollView;

		private IXUIWrapContent m_WrapContent;

		private uint m_timer = 0u;

		private XGuildRankDocument _Doc;

		protected override void Init()
		{
			base.Init();
			this._Doc = XDocuments.GetSpecificDocument<XGuildRankDocument>(XGuildRankDocument.uuID);
			this.m_TimeLabel = (base.transform.Find("Titles/Time").GetComponent("XUILabel") as IXUILabel);
			this.m_DescLabel = (base.transform.Find("Titles/Desc").GetComponent("XUILabel") as IXUILabel);
			this.m_MarkLabel = (base.transform.Find("Titles/Mark").GetComponent("XUILabel") as IXUILabel);
			this.m_UnJoinLabel = (base.transform.Find("Control/UnJoin").GetComponent("XUILabel") as IXUILabel);
			this.m_GuildRankLabel = (base.transform.Find("Control/Rank").GetComponent("XUILabel") as IXUILabel);
			this.m_ShowRank = (base.transform.Find("Control/ShowRank").GetComponent("XUIButton") as IXUIButton);
			this.m_JoinGuild = (base.transform.Find("Control/JoinGuild").GetComponent("XUIButton") as IXUIButton);
			this.m_ScrollView = (base.transform.Find("RankContent/ScrollView").GetComponent("XUIScrollView") as IXUIScrollView);
			this.m_WrapContent = (base.transform.Find("RankContent/ScrollView/GuildList").GetComponent("XUIWrapContent") as IXUIWrapContent);
			this.m_WrapContent.RegisterItemUpdateEventHandler(new WrapItemUpdateEventHandler(this.OnWrapContentUpdate));
		}

		protected override void OnShow()
		{
			base.OnShow();
			this._Doc.SendGuildRankInfo();
			this.CheckInGuild();
			this.RefreshTitles();
			this.SetRewardInfo();
			this.CheckTime();
		}

		public override void StackRefresh()
		{
			base.StackRefresh();
			this.CheckInGuild();
			this.RefreshTitles();
			this.CheckTime();
		}

		public override void RefreshData()
		{
			base.RefreshData();
			this.RefreshTitles();
			this.CheckInGuild();
			this.CheckTime();
		}

		private void SetRewardInfo()
		{
			this.m_WrapContent.SetContentCount(XGuildRankDocument.m_RankRewardTable.Table.Length, false);
			this.m_ScrollView.ResetPosition();
		}

		private void OnWrapContentUpdate(Transform t, int index)
		{
			GuildRankRewardTable.RowData rowData = XGuildRankDocument.m_RankRewardTable.Table[index];
			IXUILabel ixuilabel = t.Find("Rank").GetComponent("XUILabel") as IXUILabel;
			IXUISprite ixuisprite = t.Find("IndexSprite").GetComponent("XUISprite") as IXUISprite;
			bool flag = rowData.Rank[0] == rowData.Rank[1];
			if (flag)
			{
				bool flag2 = rowData.Rank[0] <= 3u;
				if (flag2)
				{
					ixuisprite.SetAlpha(1f);
					ixuilabel.Alpha = 0f;
					ixuisprite.SetSprite(XSingleton<XCommon>.singleton.StringCombine("N", rowData.Rank[0].ToString()));
				}
				else
				{
					ixuisprite.SetAlpha(0f);
					ixuilabel.Alpha = 1f;
					ixuilabel.SetText(XStringDefineProxy.GetString("Qualifying_Rank_Reward_Desc1", new object[]
					{
						rowData.Rank[0]
					}));
				}
			}
			else
			{
				ixuisprite.SetAlpha(0f);
				ixuilabel.Alpha = 1f;
				ixuilabel.SetText(XStringDefineProxy.GetString("Qualifying_Rank_Reward_Desc4", new object[]
				{
					rowData.Rank[0],
					rowData.Rank[1]
				}));
			}
			this.SetRewardList(t.Find("Leader"), ref rowData.LeaderReward);
			this.SetRewardList(t.Find("Officer"), ref rowData.OfficerRreward);
			this.SetRewardList(t.Find("Member"), ref rowData.MemberReward);
		}

		private void SetRewardList(Transform t, ref SeqListRef<uint> rewards)
		{
			IXUIList ixuilist = t.GetComponent("XUIList") as IXUIList;
			int i = 0;
			int num = 3;
			while (i < num)
			{
				Transform transform = t.Find(XSingleton<XCommon>.singleton.StringCombine("Item", i.ToString()));
				bool flag = i < rewards.Count;
				if (flag)
				{
					transform.gameObject.SetActive(true);
					IXUISprite ixuisprite = transform.Find("Icon").GetComponent("XUISprite") as IXUISprite;
					ixuisprite.ID = (ulong)rewards[i, 0];
					XSingleton<XItemDrawerMgr>.singleton.normalItemDrawer.DrawItem(transform.gameObject, (int)rewards[i, 0], (int)rewards[i, 1], false);
					ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnIconClick));
				}
				else
				{
					transform.gameObject.SetActive(false);
				}
				i++;
			}
			ixuilist.Refresh();
		}

		private void OnIconClick(IXUISprite spr)
		{
			XItem mainItem = XBagDocument.MakeXItem((int)spr.ID, false);
			XSingleton<UiUtility>.singleton.ShowTooltipDialogWithSearchingCompare(mainItem, spr, false, 0u);
		}

		private void RefreshTitles()
		{
			this.m_MarkLabel.SetText(XStringDefineProxy.GetString("GUILD_RANK_MARK", new object[]
			{
				XSingleton<UiUtility>.singleton.TimeFormatSince1970((int)this._Doc.KeepTime, XStringDefineProxy.GetString("TIME_FORMAT_YYMMDD"), true)
			}));
			this.m_DescLabel.SetText(XStringDefineProxy.GetString("GUILD_RANK_DESC"));
		}

		private void CheckTime()
		{
			XSingleton<XTimerMgr>.singleton.KillTimer(this.m_timer);
			bool flag = this._Doc.LastTime > 0;
			if (flag)
			{
				XGuildRankDocument doc = this._Doc;
				int lastTime = doc.LastTime;
				doc.LastTime = lastTime - 1;
				this.m_timer = XSingleton<XTimerMgr>.singleton.SetTimer(1f, new XTimerMgr.ElapsedEventHandler(this.DoTimer), null);
				bool flag2 = this._Doc.LastTime >= 86400;
				if (flag2)
				{
					this.m_TimeLabel.SetText(XStringDefineProxy.GetString("GUILD_RANK_TIME", new object[]
					{
						XSingleton<UiUtility>.singleton.TimeFormatSince1970((int)this._Doc.EndTime, XStringDefineProxy.GetString("TIME_FORMAT_YYMMDD"), true),
						XStringDefineProxy.GetString("GUILD_QUALIFER_STYLE1", new object[]
						{
							XSingleton<UiUtility>.singleton.TimeDuarationFormatString(this._Doc.LastTime, 2)
						})
					}));
				}
				else
				{
					this.m_TimeLabel.SetText(XStringDefineProxy.GetString("GUILD_RANK_TIME", new object[]
					{
						XSingleton<UiUtility>.singleton.TimeFormatSince1970((int)this._Doc.EndTime, XStringDefineProxy.GetString("TIME_FORMAT_YYMMDD"), true),
						XStringDefineProxy.GetString("GUILD_QUALIFER_STYLE1", new object[]
						{
							XSingleton<UiUtility>.singleton.TimeDuarationFormatString(this._Doc.LastTime, 5)
						})
					}));
				}
			}
			else
			{
				this.m_TimeLabel.SetText(XStringDefineProxy.GetString("GUILD_RANK_TIME", new object[]
				{
					XSingleton<UiUtility>.singleton.TimeFormatSince1970((int)this._Doc.EndTime, XStringDefineProxy.GetString("TIME_FORMAT_YYMMDD"), true),
					XStringDefineProxy.GetString("GUILD_QUALIFER_STYLE2")
				}));
			}
		}

		private void DoTimer(object o = null)
		{
			XSingleton<XTimerMgr>.singleton.KillTimer(this.m_timer);
			this.CheckTime();
		}

		protected override void OnHide()
		{
			XSingleton<XTimerMgr>.singleton.KillTimer(this.m_timer);
			base.OnHide();
		}

		public override void OnUnload()
		{
			XSingleton<XTimerMgr>.singleton.KillTimer(this.m_timer);
			base.OnUnload();
		}

		public override void RegisterEvent()
		{
			base.RegisterEvent();
			this.m_ShowRank.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnShowRankClick));
			this.m_JoinGuild.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnJoinGuild));
		}

		private bool OnShowRankClick(IXUIButton btn)
		{
			DlgBase<XRankView, XRankBehaviour>.singleton.ShowRank(XSysDefine.XSys_Rank_Guild);
			return false;
		}

		private bool OnJoinGuild(IXUIButton btn)
		{
			bool flag = XSingleton<XGameSysMgr>.singleton.IsSystemOpened(XSysDefine.XSys_Guild);
			if (flag)
			{
				XGuildDocument specificDocument = XDocuments.GetSpecificDocument<XGuildDocument>(XGuildDocument.uuID);
				bool flag2 = specificDocument != null;
				if (flag2)
				{
					specificDocument.TryShowGuildHallUI();
				}
			}
			else
			{
				XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("GUILD_UNJION"), "fece00");
			}
			return true;
		}

		private void CheckInGuild()
		{
			XGuildDocument specificDocument = XDocuments.GetSpecificDocument<XGuildDocument>(XGuildDocument.uuID);
			bool bInGuild = specificDocument.bInGuild;
			if (bInGuild)
			{
				this.m_JoinGuild.SetVisible(false);
				this.m_UnJoinLabel.SetVisible(false);
				this.m_GuildRankLabel.SetVisible(true);
				this.m_GuildRankLabel.SetText(this._Doc.RankIndex.ToString());
			}
			else
			{
				this.m_JoinGuild.SetVisible(true);
				this.m_UnJoinLabel.SetVisible(true);
				this.m_GuildRankLabel.SetVisible(false);
			}
		}
	}
}