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

namespace XMainClient.UI
{
	internal class XDragonRwdHandler : DlgHandlerBase
	{
		private IXUIWrapContent m_WrapContent;

		private IXUIScrollView m_PanelScrollView;

		private IXUILabel m_lblWeek;

		private IXUILabel m_lblIntro;

		private IXUILabel m_lblTimes;

		private IXUICheckBox m_chbx;

		private bool cbInit;

		private XDragonRewardDocument doc;

		protected override void Init()
		{
			base.Init();
			bool flag = this.doc == null;
			if (flag)
			{
				this.doc = XDocuments.GetSpecificDocument<XDragonRewardDocument>(XDragonRewardDocument.uuID);
			}
			this.m_PanelScrollView = (base.PanelObject.transform.Find("detail").GetComponent("XUIScrollView") as IXUIScrollView);
			this.m_WrapContent = (base.PanelObject.transform.Find("detail/WrapContent").GetComponent("XUIWrapContent") as IXUIWrapContent);
			this.m_lblWeek = (base.PanelObject.transform.Find("Title/T/Time").GetComponent("XUILabel") as IXUILabel);
			this.m_lblIntro = (base.PanelObject.transform.Find("Title/Intro").GetComponent("XUILabel") as IXUILabel);
			this.m_lblTimes = (base.PanelObject.transform.Find("Title/T/Times").GetComponent("XUILabel") as IXUILabel);
			this.m_chbx = (base.PanelObject.transform.Find("Title/Agreement/Category/Normal").GetComponent("XUICheckBox") as IXUICheckBox);
			this.m_WrapContent.RegisterItemUpdateEventHandler(new WrapItemUpdateEventHandler(this.WrapContentItemUpdated));
		}

		public override void RegisterEvent()
		{
			base.RegisterEvent();
			this.m_chbx.RegisterOnCheckEventHandler(new CheckBoxOnCheckEventHandler(this.OnSelectCnbx));
		}

		protected override void OnShow()
		{
			base.OnShow();
			this.doc.rwdView = this;
			this.cbInit = false;
			this.m_lblWeek.SetText(XStringDefineProxy.GetString("DragonReset"));
			this.m_lblIntro.SetText(XStringDefineProxy.GetString("DragonDesc"));
			bool flag = this.doc == null;
			if (flag)
			{
				this.doc = XDocuments.GetSpecificDocument<XDragonRewardDocument>(XDragonRewardDocument.uuID);
			}
			this.doc.FetchList();
		}

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

		public override void OnUnload()
		{
			this.doc = null;
			base.OnUnload();
		}

		private bool OnSelectCnbx(IXUICheckBox chbx)
		{
			bool flag = this.cbInit;
			if (flag)
			{
				bool flag2 = this.doc == null;
				if (flag2)
				{
					this.doc = XDocuments.GetSpecificDocument<XDragonRewardDocument>(XDragonRewardDocument.uuID);
				}
				bool flag3 = chbx.bChecked != this.doc.isAgreeHelp;
				if (flag3)
				{
					this.doc.AgreeHelp(chbx.bChecked);
				}
			}
			return true;
		}

		public void Refresh()
		{
			this.cbInit = true;
			this.m_chbx.bChecked = this.doc.isAgreeHelp;
			this.m_lblTimes.SetText(this.doc.helpCnt.ToString());
			this.m_WrapContent.SetContentCount(this.doc.rewds.Count, false);
			this.m_PanelScrollView.ResetPosition();
		}

		private void WrapContentItemUpdated(Transform t, int index)
		{
			bool flag = this.doc != null;
			if (flag)
			{
				bool flag2 = index < this.doc.rewds.Count && index >= 0;
				if (flag2)
				{
					DragonRwdItem info = this.doc.rewds[index];
					this._SetRecord(t, info);
				}
			}
		}

		private void _SetRecord(Transform t, DragonRwdItem info)
		{
			IXUILabel ixuilabel = t.Find("TLabel").GetComponent("XUILabel") as IXUILabel;
			IXUILabel ixuilabel2 = t.Find("DLabel").GetComponent("XUILabel") as IXUILabel;
			Transform transform = t.Find("ch");
			IXUISprite ixuisprite = transform.Find("Sprite").GetComponent("XUISprite") as IXUISprite;
			IXUIButton ixuibutton = t.Find("Get").GetComponent("XUIButton") as IXUIButton;
			IXUISprite ixuisprite2 = t.Find("Icon").GetComponent("XUISprite") as IXUISprite;
			IXUISprite ixuisprite3 = t.Find("Fini").GetComponent("XUISprite") as IXUISprite;
			IXUISprite ixuisprite4 = t.Find("RedPoint").GetComponent("XUISprite") as IXUISprite;
			GameObject gameObject = t.Find("bj").gameObject;
			GameObject gameObject2 = t.Find("bj/bj").gameObject;
			GameObject gameObject3 = t.Find("tmp1").gameObject;
			GameObject gameObject4 = t.Find("tmp2").gameObject;
			ixuilabel.SetText(info.row.Achievement);
			ixuilabel2.SetText(info.row.Explanation);
			string empty = string.Empty;
			string value = XSingleton<XGlobalConfig>.singleton.GetValue("AchieveColor");
			bool flag = !string.IsNullOrEmpty(info.row.DesignationName);
			gameObject3.SetActive(flag);
			gameObject4.SetActive(!flag);
			Transform transform2 = flag ? gameObject3.transform : gameObject4.transform;
			int num = Mathf.Min(3, (int)info.row.Reward.count);
			for (int i = 0; i < num; i++)
			{
				GameObject gameObject5 = transform2.GetChild(i).gameObject;
				gameObject5.transform.localScale = Vector3.one;
				IXUISprite ixuisprite5 = gameObject5.transform.Find("Icon").GetComponent("XUISprite") as IXUISprite;
				ixuisprite5.ID = (ulong)((long)info.row.Reward[i, 0]);
				XSingleton<XItemDrawerMgr>.singleton.normalItemDrawer.DrawItem(gameObject5, info.row.Reward[i, 0], info.row.Reward[i, 1], false);
				ixuisprite5.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(XSingleton<UiUtility>.singleton.OnItemClick));
			}
			int j = num;
			int num2 = 3;
			while (j < num2)
			{
				transform2.GetChild(j).gameObject.SetActive(false);
				j++;
			}
			gameObject2.SetActive(info.state == AchieveState.Claim);
			ixuisprite4.SetVisible(info.state == AchieveState.Claim);
			ixuisprite3.SetVisible(info.state == AchieveState.Claimed);
			ixuibutton.SetVisible(info.state != AchieveState.Claimed);
			gameObject.SetActive(info.state != AchieveState.Normal);
			ixuisprite2.SetSprite(info.row.ICON);
			bool flag2 = flag;
			if (flag2)
			{
				ixuisprite.SetSprite(info.row.DesignationName);
			}
			transform.gameObject.SetActive(!string.IsNullOrEmpty(info.row.DesignationName));
			ixuibutton.SetEnable(info.state != AchieveState.Normal, false);
			ixuibutton.ID = (ulong)((long)info.row.ID);
			bool flag3 = info.state != AchieveState.Normal;
			if (flag3)
			{
				ixuibutton.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnBtnClick));
			}
		}

		private bool OnBtnClick(IXUIButton btn)
		{
			bool flag = this.doc == null;
			if (flag)
			{
				this.doc = XDocuments.GetSpecificDocument<XDragonRewardDocument>(XDragonRewardDocument.uuID);
			}
			this.doc.Claim((int)btn.ID);
			return true;
		}
	}
}