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

namespace XMainClient
{
	internal class TooltipButtonOperateItemAny : TooltipButtonOperateBase
	{
		private string m_Text;

		private ulong m_useCount;

		public override string GetButtonText()
		{
			return this.m_Text;
		}

		public override bool HasRedPoint(XItem item)
		{
			return false;
		}

		public override bool IsButtonVisible(XItem item)
		{
			ItemType type = item.Type;
			if (type != ItemType.PECK)
			{
				if (type == ItemType.EMBLEM_MATERIAL)
				{
					this.m_Text = XStringDefineProxy.GetString("Make");
					return XSingleton<XGameSysMgr>.singleton.IsSystemOpened(XSysDefine.XSys_Char_Emblem) && XSingleton<XGameSysMgr>.singleton.IsSystemOpened(XSysDefine.XSys_EquipCreate_EmblemSet);
				}
			}
			else
			{
				ChestList.RowData chestConf = XBagDocument.GetChestConf(item.itemID);
				bool flag = chestConf != null && chestConf.MultiOpen;
				if (flag)
				{
					this.m_useCount = (ulong)((long)XBagDocument.BagDoc.ItemBag.GetItemCountByUid(item.uid));
					bool flag2 = this.m_useCount > 1UL;
					if (flag2)
					{
						this.m_Text = XStringDefineProxy.GetString("OpenAll");
						return true;
					}
				}
			}
			return false;
		}

		public override void OnButtonClick(ulong mainUID, ulong compareUID)
		{
			base.OnButtonClick(mainUID, compareUID);
			XItem itemByUID = XSingleton<XGame>.singleton.Doc.XBagDoc.GetItemByUID(this.mainItemUID);
			bool flag = itemByUID == null;
			if (!flag)
			{
				ItemType type = itemByUID.Type;
				if (type != ItemType.PECK)
				{
					if (type == ItemType.EMBLEM_MATERIAL)
					{
						XSingleton<XGameSysMgr>.singleton.OpenSystem(XSysDefine.XSys_EquipCreate_EmblemSet, 0UL);
					}
				}
				else
				{
					ChestList.RowData chestConf = XBagDocument.GetChestConf(itemByUID.itemID);
					bool flag2 = chestConf != null && chestConf.MultiOpen;
					if (flag2)
					{
						this.OpenAnyTimesTip(itemByUID);
					}
				}
			}
		}

		private void OpenAnyTimesTip(XItem item)
		{
			ItemList.RowData itemConf = XBagDocument.GetItemConf(item.itemID);
			bool flag = !item.bBinding && itemConf != null && itemConf.IsNeedShowTipsPanel == 1;
			if (flag)
			{
				XSingleton<UiUtility>.singleton.ShowModalDialog(XStringDefineProxy.GetString("CanNotSeal"), XStringDefineProxy.GetString("COMMON_OK"), XStringDefineProxy.GetString("COMMON_CANCEL"), new ButtonClickEventHandler(this.UseOnceItem));
			}
			else
			{
				XSingleton<XGame>.singleton.Doc.XBagDoc.UseItem(item, 0u, 0u);
			}
		}

		private bool UseOnceItem(IXUIButton btn)
		{
			XItem itemByUID = XSingleton<XGame>.singleton.Doc.XBagDoc.GetItemByUID(this.mainItemUID);
			bool flag = itemByUID == null;
			bool result;
			if (flag)
			{
				result = true;
			}
			else
			{
				XSingleton<XGame>.singleton.Doc.XBagDoc.UseItem(itemByUID, 0u);
				XSingleton<UiUtility>.singleton.CloseModalDlg();
				result = true;
			}
			return result;
		}
	}
}