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

namespace XMainClient
{
	internal class TooltipButtonOperateSell : TooltipButtonOperateBase
	{
		private int itemCount = 0;

		private ItemList.RowData itemRowData = null;

		private uint moneyID = 0u;

		private uint moneyCount = 0u;

		public override string GetButtonText()
		{
			return XStringDefineProxy.GetString("SELL");
		}

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

		public override bool IsButtonVisible(XItem item)
		{
			return this._CanItemBeSold(item);
		}

		public override void OnButtonClick(ulong mainUID, ulong compareUID)
		{
			base.OnButtonClick(mainUID, compareUID);
			ItemList.RowData itemConf = XBagDocument.GetItemConf((int)this.moneyID);
			bool flag = itemConf == null || this.itemRowData == null;
			if (!flag)
			{
				string @string = XStringDefineProxy.GetString("ItemSellConfirm", new object[]
				{
					this.itemCount.ToString(),
					XSingleton<UiUtility>.singleton.ChooseProfString(this.itemRowData.ItemName, 0u),
					((long)((ulong)this.moneyCount * (ulong)((long)this.itemCount))).ToString(),
					XSingleton<UiUtility>.singleton.ChooseProfString(itemConf.ItemName, 0u)
				});
				XSingleton<UiUtility>.singleton.ShowModalDialog(@string, XStringDefineProxy.GetString(XStringDefine.COMMON_OK), XStringDefineProxy.GetString(XStringDefine.COMMON_CANCEL), new ButtonClickEventHandler(this._OnSellClicked));
			}
		}

		protected bool _CanItemBeSold(XItem item)
		{
			bool flag = item == null || item.itemConf == null;
			bool result;
			if (flag)
			{
				result = false;
			}
			else
			{
				bool flag2 = item.itemConf.Sell[0] > 0u;
				if (flag2)
				{
					this.itemCount = item.itemCount;
					this.itemRowData = item.itemConf;
					this.moneyID = item.itemConf.Sell[0];
					this.moneyCount = item.itemConf.Sell[1];
					result = true;
				}
				else
				{
					result = false;
				}
			}
			return result;
		}

		private bool _OnSellClicked(IXUIButton btn)
		{
			XSingleton<UiUtility>.singleton.CloseModalDlg();
			XSingleton<XGame>.singleton.Doc.XBagDoc.ReqItemSell(this.mainItemUID);
			return true;
		}
	}
}