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

namespace XMainClient.UI
{
	internal class ItemTooltipDlg : TooltipDlg<ItemTooltipDlg, ItemTooltipDlgBehaviour>
	{
		public override string fileName
		{
			get
			{
				return "GameSystem/ItemToolTipDlg";
			}
		}

		private bool m_bIsNeedTimeUpdate = false;

		private IXUILabel m_timeLab;

		private string m_tempStr = string.Empty;

		private float m_nextTime = 0f;

		protected override void Init()
		{
			base.Init();
			this.m_OperateList[0, 0] = new TooltipButtonOperateItemUse();
			this.m_OperateList[0, 1] = new TooltipButtonOperateItemAny();
			this.m_OperateList[0, 2] = new TooltipButtonOperateRecycle(XSysDefine.XSys_Bag_Item);
			this.m_OperateList[0, 3] = new TooltipButtonOperateSell();
			this.m_OperateList[0, 4] = new TooltipButtonOperateCompose();
		}

		public void ShowToolTip(ulong MainUID, ulong CompareUID, bool bShowButtons = true)
		{
			XItem itemByUID = XSingleton<XGame>.singleton.Doc.XBagDoc.GetItemByUID(MainUID);
			XItem xitem = XSingleton<XGame>.singleton.Doc.XBagDoc.GetItemByUID(CompareUID);
			bool flag = xitem.uid == 0UL;
			if (flag)
			{
				xitem = null;
			}
			this.ShowToolTip(itemByUID, xitem, bShowButtons, 0u);
		}

		protected override void SetupTopFrame(GameObject goToolTip, ItemList.RowData data, bool bMain, XItem instanceData = null, XItem compareData = null)
		{
			base.SetupTopFrame(goToolTip, data, bMain, instanceData, compareData);
			ItemType itemType = (ItemType)data.ItemType;
			if (itemType != ItemType.ENCHANT)
			{
				base._SetupLevel(goToolTip, data, 0);
				base._SetupProf(goToolTip, data, bMain, instanceData, 1);
				base._SetupType(goToolTip, data, 2);
			}
			else
			{
				XEnchantDocument specificDocument = XDocuments.GetSpecificDocument<XEnchantDocument>(XEnchantDocument.uuID);
				EnchantEquip.RowData enchantEquipData = specificDocument.GetEnchantEquipData(data.ItemID);
				base._SetTopFrameLabel(goToolTip, 0, XStringDefineProxy.GetString("ToolTipText_Level"), XStringDefineProxy.GetString("ToolTipText_UnderLevel", new object[]
				{
					data.ReqLevel.ToString()
				}));
				base._SetTopFrameLabel(goToolTip, 1, XStringDefineProxy.GetString("ToolTipText_Part"), (enchantEquipData != null) ? XStringDefineProxy.GetString("ToolTipText_EnchantType" + enchantEquipData.VisiblePos.ToString()) : string.Empty);
				base._SetupType(goToolTip, data, 2);
			}
			this.m_timeLab = goToolTip.transform.Find("TopFrame/countdown").GetComponent<IXUILabel>();
			this.m_bIsNeedTimeUpdate = true;
			this.m_timeLab.gameObject.SetActive(true);
			this.SetTimeLab();
		}

		private void SetTimeLab()
		{
			XItem itemByUID = XBagDocument.BagDoc.GetItemByUID(this.mainItemUID);
			bool flag = itemByUID == null || this.m_timeLab.gameObject == null;
			if (flag)
			{
				this.m_timeLab.gameObject.SetActive(false);
				this.m_bIsNeedTimeUpdate = false;
			}
			else
			{
				uint serverTimeSince = XActivityDocument.Doc.ServerTimeSince1970;
				bool flag2 = serverTimeSince >= itemByUID.bexpirationTime;
				if (flag2)
				{
					this.m_bIsNeedTimeUpdate = false;
					this.m_timeLab.gameObject.SetActive(false);
				}
				else
				{
					this.m_tempStr = XSingleton<UiUtility>.singleton.TimeDuarationFormatString((int)(itemByUID.bexpirationTime - serverTimeSince), 4);
					this.m_tempStr = XSingleton<UiUtility>.singleton.ReplaceReturn(string.Format("{0}{1}", XSingleton<XStringTable>.singleton.GetString("TipsEndTime"), this.m_tempStr));
					this.m_timeLab.SetText(this.m_tempStr);
				}
			}
		}

		protected override void SetAllAttrFrames(GameObject goToolTip, XAttrItem item, XAttrItem compareItem, bool bMain)
		{
		}

		protected override void SetupOtherFrame(GameObject goToolTip, XItem item, XItem compareItem, bool bMain)
		{
			ItemList.RowData itemConf = XBagDocument.GetItemConf(item.itemID);
			this._SetupDescription(goToolTip, itemConf);
		}

		protected override void SetupOtherFrame(GameObject goToolTip, ItemList.RowData data)
		{
			this._SetupDescription(goToolTip, data);
		}

		protected void _SetupDescription(GameObject goToolTip, ItemList.RowData data)
		{
			Transform transform = goToolTip.transform;
			IXUISprite ixuisprite = transform.Find("ScrollPanel/Description").GetComponent("XUISprite") as IXUISprite;
			IXUILabel ixuilabel = ixuisprite.gameObject.transform.Find("Text").GetComponent("XUILabel") as IXUILabel;
			bool flag = data == null;
			if (flag)
			{
				ixuilabel.SetText("");
			}
			else
			{
				ixuilabel.SetText(XSingleton<UiUtility>.singleton.ReplaceReturn(data.ItemDescription));
			}
			ixuisprite.spriteHeight = ixuilabel.spriteHeight + -(int)ixuilabel.gameObject.transform.localPosition.y;
			this.totalFrameHeight += (float)ixuisprite.spriteHeight;
		}

		public override void OnUpdate()
		{
			base.OnUpdate();
			bool flag = this.m_bIsNeedTimeUpdate && Time.realtimeSinceStartup >= this.m_nextTime;
			if (flag)
			{
				this.m_nextTime = Time.realtimeSinceStartup + 60f;
				this.SetTimeLab();
			}
		}

		protected override void SetupToolTipButtons(GameObject goToolTip, XItem item, bool bMain)
		{
			base.SetupToolTipButtons(goToolTip, item, bMain);
			bool flag = !this.bShowButtons;
			if (!flag)
			{
				if (bMain)
				{
					base._SetupButtonVisiability(goToolTip, 0, item);
				}
			}
		}
	}
}