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

namespace XMainClient
{
	internal class CapacityDownDlg : DlgBase<CapacityDownDlg, CapacityBehaviour>
	{
		public override string fileName
		{
			get
			{
				return "GameSystem/CapacityDownDlg";
			}
		}

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

		public override bool isHideChat
		{
			get
			{
				return false;
			}
		}

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

		public int m_oldPPT = 0;

		private bool m_init = false;

		private XOptionsDocument m_optionsDoc;

		public bool IsInit = false;

		private XOptionsDefine m_define;

		private string m_strKey;

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

		public override void RegisterEvent()
		{
			base.RegisterEvent();
			base.uiBehaviour.m_closeSpr.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnClickCloseSpr));
			base.uiBehaviour.m_checkBox.RegisterOnCheckEventHandler(new CheckBoxOnCheckEventHandler(this.OnClickChexckBox));
		}

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

		protected override void Init()
		{
			base.Init();
			this.IsInit = true;
			this.m_optionsDoc = XDocuments.GetSpecificDocument<XOptionsDocument>(XOptionsDocument.uuID);
		}

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

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

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

		public void InitPPT()
		{
			bool flag = !this.m_init;
			if (flag)
			{
				this.m_init = true;
				XPlayer player = XSingleton<XEntityMgr>.singleton.Player;
				bool flag2 = player != null;
				if (flag2)
				{
					XPlayerAttributes xplayerAttributes = player.Attributes as XPlayerAttributes;
					bool flag3 = xplayerAttributes != null;
					if (flag3)
					{
						this.m_oldPPT = (int)xplayerAttributes.GetAttr(XAttributeDefine.XAttr_POWER_POINT_Basic);
					}
				}
			}
		}

		public void UpdatePPT(int newPPT)
		{
			bool flag = !EquipFusionDocument.IsEquipDown || newPPT > this.m_oldPPT;
			if (flag)
			{
				this.m_oldPPT = newPPT;
				EquipFusionDocument.IsEquipDown = false;
			}
			else
			{
				EquipFusionDocument.IsEquipDown = false;
				this.m_oldPPT = newPPT;
				this.m_define = XOptionsDefine.OD_NO_CAPACITYDOWN_TIPS;
				this.m_strKey = "PowerDownTips";
				this.m_optionsDoc = XDocuments.GetSpecificDocument<XOptionsDocument>(XOptionsDocument.uuID);
				bool flag2 = this.m_optionsDoc.GetValue(this.m_define) == 1;
				if (!flag2)
				{
					this.SetVisible(true, true);
				}
			}
		}

		public void ShowRecycleTips()
		{
			this.m_define = XOptionsDefine.OD_RECYCLE_TIPS;
			this.m_strKey = "RecycleTips";
			this.m_optionsDoc = XDocuments.GetSpecificDocument<XOptionsDocument>(XOptionsDocument.uuID);
			bool flag = this.m_optionsDoc.GetValue(this.m_define) == 1;
			if (!flag)
			{
				this.SetVisible(true, true);
			}
		}

		public void ShowTips(XOptionsDefine opt, string key)
		{
			this.m_define = opt;
			this.m_strKey = key;
			this.m_optionsDoc = XDocuments.GetSpecificDocument<XOptionsDocument>(XOptionsDocument.uuID);
			bool flag = this.m_optionsDoc.GetValue(this.m_define) == 1;
			if (!flag)
			{
				this.SetVisible(true, true);
			}
		}

		private void FillContent()
		{
			base.uiBehaviour.m_checkBox.bChecked = false;
			base.uiBehaviour.m_checkBox.ForceSetFlag(false);
			base.uiBehaviour.m_lable.SetText(XSingleton<UiUtility>.singleton.ReplaceReturn(XSingleton<XStringTable>.singleton.GetString(this.m_strKey)));
		}

		private void OnClickCloseSpr(IXUISprite spr)
		{
			this.SetVisible(false, true);
		}

		private bool OnClickChexckBox(IXUICheckBox box)
		{
			bool isInit = this.IsInit;
			bool result;
			if (isInit)
			{
				this.IsInit = false;
				result = false;
			}
			else
			{
				bool flag = this.m_optionsDoc.GetValue(this.m_define) == 1;
				if (flag)
				{
					this.m_optionsDoc.SetValue(this.m_define, 0, true);
				}
				else
				{
					this.m_optionsDoc.SetValue(this.m_define, 1, true);
				}
				result = true;
			}
			return result;
		}
	}
}