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

namespace XMainClient.UI
{
	internal class EnchantAttrPreviewHandler : DlgHandlerBase
	{
		private XEnchantDocument _doc = null;

		private IXUISprite m_Close;

		private IXUILabel m_AttrName;

		private IXUILabel m_AttrValue;

		private EnchantEquip.RowData m_Data;

		protected override void Init()
		{
			base.Init();
			this._doc = XDocuments.GetSpecificDocument<XEnchantDocument>(XEnchantDocument.uuID);
			this.m_Close = (base.PanelObject.transform.Find("Close").GetComponent("XUISprite") as IXUISprite);
			this.m_AttrName = (base.PanelObject.transform.Find("Detail/AttrName").GetComponent("XUILabel") as IXUILabel);
			this.m_AttrValue = (base.PanelObject.transform.Find("Detail/AttrValue").GetComponent("XUILabel") as IXUILabel);
		}

		public override void RegisterEvent()
		{
			base.RegisterEvent();
			this.m_Close.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this._OnCloseClicked));
		}

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

		public override void RefreshData()
		{
			base.RefreshData();
			bool flag = this.m_Data == null;
			if (!flag)
			{
				XPrefixAttributes enchantAttrs = this._doc.GetEnchantAttrs(this.m_Data.EnchantID);
				bool flag2 = enchantAttrs == null;
				if (!flag2)
				{
					XSingleton<XCommon>.singleton.shareSB.Length = 0;
					for (int i = 0; i < enchantAttrs.AttributeList.Count; i++)
					{
						XSingleton<XCommon>.singleton.shareSB.Append(XAttributeCommon.GetAttrStr((int)enchantAttrs.AttributeList[i].attrid));
						XSingleton<XCommon>.singleton.shareSB.Append('\n');
					}
					this.m_AttrName.SetText(XSingleton<XCommon>.singleton.shareSB.ToString());
					XSingleton<XCommon>.singleton.shareSB.Length = 0;
					for (int j = 0; j < enchantAttrs.AttributeList.Count; j++)
					{
						XSingleton<XCommon>.singleton.shareSB.Append(XAttributeCommon.GetAttrValueStr(enchantAttrs.AttributeList[j].attrid, (uint)enchantAttrs.AttributeList[j].minValue, true));
						XSingleton<XCommon>.singleton.shareSB.Append('~');
						XSingleton<XCommon>.singleton.shareSB.Append(XAttributeCommon.GetAttrValueStr(enchantAttrs.AttributeList[j].attrid, (uint)enchantAttrs.AttributeList[j].maxValue, false));
						XSingleton<XCommon>.singleton.shareSB.Append('\n');
					}
					this.m_AttrValue.SetText(XSingleton<XCommon>.singleton.shareSB.ToString());
				}
			}
		}

		private void _OnCloseClicked(IXUISprite iSp)
		{
			base.SetVisible(false);
		}

		public void Show(int itemid)
		{
			this.m_Data = this._doc.GetEnchantEquipData(itemid);
			bool flag = this.m_Data == null;
			if (flag)
			{
				XSingleton<XDebug>.singleton.AddErrorLog("Cant find enchant item config: " + itemid, null, null, null, null, null);
			}
			else
			{
				base.SetVisible(true);
			}
		}
	}
}