summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/UI/AuctionSellHandler.cs
blob: 38e88f741e834de998509b7a46cdbe3ea514e30b (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
200
201
using System;
using System.Collections.Generic;
using UILib;
using UnityEngine;
using XMainClient.UI.UICommon;
using XUtliPoolLib;

namespace XMainClient.UI
{
	internal class AuctionSellHandler : DlgHandlerBase
	{
		protected override string FileName
		{
			get
			{
				return "GameSystem/Auction/AuctionSellFrame";
			}
		}

		private AuctionDocument _Doc;

		private AuctionWrapContentGroup m_auctionSellGroup;

		private XBagWindow m_bagWindow;

		private Transform m_emptyInAuction;

		private IXUILabel m_curSaleValue;

		private IXUISprite m_tqSprite;

		private IXUILabel m_tqLabel;

		private IXUISprite m_tqBgSprite;

		protected override void Init()
		{
			base.Init();
			this._Doc = XDocuments.GetSpecificDocument<AuctionDocument>(AuctionDocument.uuID);
			this.m_auctionSellGroup = new AuctionWrapContentGroup();
			this.m_auctionSellGroup.SetAuctionWrapContentTemp(base.PanelObject.transform.Find("SellList"), new WrapItemUpdateEventHandler(this.OnAuctionSellListUpdate));
			this.m_bagWindow = new XBagWindow(base.PanelObject.transform.Find("BagList").gameObject, new ItemUpdateHandler(this.OnBagItemUpdate), new GetItemHandler(this._Doc.GetItemList));
			this.m_bagWindow.Init();
			this.m_emptyInAuction = base.PanelObject.transform.Find("SellListEmpty");
			this.m_curSaleValue = (base.PanelObject.transform.Find("LeftCount/Value").GetComponent("XUILabel") as IXUILabel);
			this.m_tqSprite = (base.PanelObject.transform.Find("tq").GetComponent("XUISprite") as IXUISprite);
			this.m_tqLabel = (base.PanelObject.transform.Find("tq/t").GetComponent("XUILabel") as IXUILabel);
			this.m_tqBgSprite = (base.PanelObject.transform.Find("tq/p").GetComponent("XUISprite") as IXUISprite);
		}

		private void OnAuctionSellListUpdate(Transform t, int index)
		{
			bool flag = t == null;
			if (!flag)
			{
				Transform transform = t.Find("DetailTpl");
				IXUICheckBox ixuicheckBox = transform.GetComponent("XUICheckBox") as IXUICheckBox;
				bool flag2 = ixuicheckBox != null;
				if (flag2)
				{
					ixuicheckBox.bChecked = false;
				}
				List<AuctionSaleItem> auctionOnLineSaleList = this._Doc.AuctionOnLineSaleList;
				bool flag3 = index < 0 || index >= auctionOnLineSaleList.Count;
				if (flag3)
				{
					transform.gameObject.SetActive(false);
				}
				else
				{
					transform.gameObject.SetActive(true);
					Transform transform2 = transform.Find("ItemTpl");
					IXUILabelSymbol ixuilabelSymbol = transform.Find("Price").GetComponent("XUILabelSymbol") as IXUILabelSymbol;
					Transform transform3 = transform.Find("Time");
					IXUISprite ixuisprite = transform2.Find("Icon").GetComponent("XUISprite") as IXUISprite;
					IXUISprite ixuisprite2 = transform.GetComponent("XUISprite") as IXUISprite;
					AuctionSaleItem auctionSaleItem = auctionOnLineSaleList[index];
					transform3.gameObject.SetActive(auctionSaleItem.isOutTime);
					ixuilabelSymbol.InputText = XLabelSymbolHelper.FormatCostWithIconLast((int)auctionSaleItem.perprice, ItemEnum.DRAGON_COIN);
					XSingleton<XItemDrawerMgr>.singleton.DrawItem(transform2.gameObject, auctionSaleItem.itemData);
					ixuisprite.ID = (ulong)((long)index);
					ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnItemSaleClicked));
					ixuisprite2.ID = (ulong)((long)index);
					ixuisprite2.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnItemSaleCheckSelected));
				}
			}
		}

		public override void RegisterEvent()
		{
			this.m_tqBgSprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnMemberPrivilegeClicked));
		}

		private void OnMemberPrivilegeClicked(IXUISprite sprite)
		{
			DlgBase<XWelfareView, XWelfareBehaviour>.singleton.CheckActiveMemberPrivilege(MemberPrivilege.KingdomPrivilege_Court);
		}

		private void OnBagItemUpdate(Transform transform, int index)
		{
			IXUISprite ixuisprite = transform.Find("Icon").GetComponent("XUISprite") as IXUISprite;
			bool flag = this.m_bagWindow.m_XItemList == null || index < 0 || index >= this.m_bagWindow.m_XItemList.Count;
			if (flag)
			{
				XSingleton<XItemDrawerMgr>.singleton.DrawItem(transform.gameObject, null);
			}
			else
			{
				XItem xitem = this.m_bagWindow.m_XItemList[index];
				ixuisprite.ID = (ulong)((long)index);
				XSingleton<XItemDrawerMgr>.singleton.DrawItem(transform.gameObject, xitem);
				GameObject gameObject = transform.Find("Icon/Bind").gameObject;
				gameObject.SetActive(xitem.blocking > 0.0);
				ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnItemClicked));
			}
		}

		private void OnItemSaleCheckSelected(IXUISprite checkBox)
		{
			int num = (int)checkBox.ID;
			bool flag = num < this._Doc.AuctionOnLineSaleList.Count;
			if (flag)
			{
				AuctionSaleItem auctionSaleItem = this._Doc.AuctionOnLineSaleList[num];
				this._Doc.RequestAuctionPriceRecommend(auctionSaleItem.uid, auctionSaleItem.itemData, auctionSaleItem.isOutTime ? AuctionBillStyle.OutTime : AuctionBillStyle.RePutAway);
			}
		}

		private void OnItemSaleClicked(IXUISprite sp)
		{
			int num = (int)sp.ID;
			bool flag = num < this._Doc.AuctionOnLineSaleList.Count;
			if (flag)
			{
				XSingleton<UiUtility>.singleton.ShowTooltipDialog(this._Doc.AuctionOnLineSaleList[num].itemData, null, sp, false, 0u);
			}
		}

		private void OnItemClicked(IXUISprite sp)
		{
			int num = (int)sp.ID;
			bool flag = num < this.m_bagWindow.m_XItemList.Count;
			if (flag)
			{
				bool flag2 = this.m_bagWindow.m_XItemList[num].blocking > 0.0;
				if (flag2)
				{
					XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("AUCTION_LOCK_TIME", new object[]
					{
						XSingleton<UiUtility>.singleton.TimeDuarationFormatString((int)this.m_bagWindow.m_XItemList[num].blocking, 4)
					}), "fece00");
				}
				else
				{
					this._Doc.RequestAuctionPriceRecommend(0UL, this.m_bagWindow.m_XItemList[num], AuctionBillStyle.PutAway);
				}
			}
		}

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

		public override void RefreshData()
		{
			this.m_bagWindow.OnShow();
			this.RefreshSaleList();
		}

		private void RefreshSaleList()
		{
			bool flag = this.m_auctionSellGroup == null;
			if (!flag)
			{
				int count = this._Doc.AuctionOnLineSaleList.Count;
				this.m_auctionSellGroup.SetWrapContentSize(count);
				this.m_emptyInAuction.gameObject.SetActive(count == 0);
				XRechargeDocument specificDocument = XDocuments.GetSpecificDocument<XRechargeDocument>(XRechargeDocument.uuID);
				uint num = specificDocument.GetCurrentVipPermissions().AuctionOnSaleMax;
				XWelfareDocument specificDocument2 = XDocuments.GetSpecificDocument<XWelfareDocument>(XWelfareDocument.uuID);
				this.m_tqSprite.SetSprite(specificDocument2.GetMemberPrivilegeIcon(MemberPrivilege.KingdomPrivilege_Court));
				bool flag2 = specificDocument2.IsOwnMemberPrivilege(MemberPrivilege.KingdomPrivilege_Court);
				if (flag2)
				{
					num += (uint)specificDocument2.GetMemberPrivilegeConfig(MemberPrivilege.KingdomPrivilege_Court).AuctionCount;
					this.m_tqSprite.SetGrey(true);
					this.m_tqLabel.SetEnabled(true);
				}
				else
				{
					this.m_tqSprite.SetGrey(false);
					this.m_tqLabel.SetEnabled(false);
				}
				this.m_curSaleValue.SetText(string.Format("{0}/{1}", count, num));
			}
		}
	}
}