From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- Client/Assets/Scripts/XMainClient/AuctionView.cs | 232 +++++++++++++++++++++++ 1 file changed, 232 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/AuctionView.cs (limited to 'Client/Assets/Scripts/XMainClient/AuctionView.cs') diff --git a/Client/Assets/Scripts/XMainClient/AuctionView.cs b/Client/Assets/Scripts/XMainClient/AuctionView.cs new file mode 100644 index 00000000..2dbba34c --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/AuctionView.cs @@ -0,0 +1,232 @@ +using System; +using System.Collections.Generic; +using UILib; +using XMainClient.UI; +using XMainClient.UI.UICommon; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class AuctionView : DlgBase + { + public override string fileName + { + get + { + return "GameSystem/Auction/AuctionDlg"; + } + } + + public override int group + { + get + { + return 1; + } + } + + public override bool pushstack + { + get + { + return true; + } + } + + public override bool hideMainMenu + { + get + { + return true; + } + } + + public override bool autoload + { + get + { + return true; + } + } + + public override bool fullscreenui + { + get + { + return true; + } + } + + private AuctionDocument _Doc; + + private Dictionary m_handlers = new Dictionary(); + + private AuctionSys m_curAuctionSys; + + protected override void Init() + { + base.Init(); + this._Doc = XDocuments.GetSpecificDocument(AuctionDocument.uuID); + this.RegisterHandler(AuctionSys.Sell); + this.RegisterHandler(AuctionSys.Buy); + this.RegisterHandler(AuctionSys.GuildAuc); + } + + public override void RegisterEvent() + { + base.RegisterEvent(); + base.uiBehaviour.m_Close.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnCloseClicked)); + base.uiBehaviour.m_BuyFrameCheckBox.RegisterOnCheckEventHandler(new CheckBoxOnCheckEventHandler(this.OnBuyFrameCheckBoxClicked)); + base.uiBehaviour.m_SellFrameCheckBox.RegisterOnCheckEventHandler(new CheckBoxOnCheckEventHandler(this.OnSellFrameCheckBoxClicked)); + base.uiBehaviour.m_GuildAucFrameCheckBox.RegisterOnCheckEventHandler(new CheckBoxOnCheckEventHandler(this.OnGuildAucFrameCheckBoxClicked)); + base.uiBehaviour.m_Help.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnHelpClicked)); + } + + public bool OnHelpClicked(IXUIButton button) + { + DlgBase.singleton.ShowHelp(XSysDefine.XSys_Auction); + return true; + } + + public void RefreshData() + { + DlgHandlerBase dlgHandlerBase; + bool flag = this.m_handlers.TryGetValue(this.m_curAuctionSys, out dlgHandlerBase) && dlgHandlerBase.IsVisible(); + if (flag) + { + dlgHandlerBase.RefreshData(); + } + } + + protected override void OnShow() + { + base.OnShow(); + this.m_uiBehaviour.m_BuyFrameCheckBox.bChecked = true; + this._Doc.SetSendAuctionState(false); + this.SetHandlerVisible(AuctionSys.Buy, true); + this.RefreshData(); + base.uiBehaviour.m_GuildAucRedPoint.SetActive(XSingleton.singleton.GetSysRedPointStateConsiderBlock(XSysDefine.XSys_Auction)); + } + + protected override void OnHide() + { + this.SetHandlerVisible(AuctionSys.Sell, false); + this.SetHandlerVisible(AuctionSys.Buy, false); + this.SetHandlerVisible(AuctionSys.GuildAuc, false); + base.OnHide(); + } + + protected override void OnUnload() + { + this.RemoveHandler(AuctionSys.Sell); + this.RemoveHandler(AuctionSys.Buy); + this.RemoveHandler(AuctionSys.GuildAuc); + base.OnUnload(); + } + + private bool OnCloseClicked(IXUIButton btn) + { + this.SetVisibleWithAnimation(false, null); + return true; + } + + private bool OnBuyFrameCheckBoxClicked(IXUICheckBox box) + { + bool flag = !box.bChecked; + bool result; + if (flag) + { + result = false; + } + else + { + this.OnTabChanged(AuctionSys.Buy); + result = true; + } + return result; + } + + private bool OnSellFrameCheckBoxClicked(IXUICheckBox box) + { + bool flag = !box.bChecked; + bool result; + if (flag) + { + result = false; + } + else + { + this.OnTabChanged(AuctionSys.Sell); + result = true; + } + return result; + } + + private bool OnGuildAucFrameCheckBoxClicked(IXUICheckBox box) + { + bool flag = !box.bChecked; + bool result; + if (flag) + { + result = false; + } + else + { + this.OnTabChanged(AuctionSys.GuildAuc); + result = true; + } + return result; + } + + private void OnTabChanged(AuctionSys define) + { + bool flag = define == this.m_curAuctionSys; + if (!flag) + { + this.SetHandlerVisible(this.m_curAuctionSys, false); + this.SetHandlerVisible(define, true); + } + } + + private void SetHandlerVisible(AuctionSys define, bool isVisble) + { + DlgHandlerBase dlgHandlerBase; + bool flag = this.m_handlers.TryGetValue(define, out dlgHandlerBase); + if (flag) + { + dlgHandlerBase.SetVisible(isVisble); + if (isVisble) + { + this.m_curAuctionSys = define; + } + } + } + + private void RegisterHandler(AuctionSys define) where T : DlgHandlerBase, new() + { + bool flag = !this.m_handlers.ContainsKey(define); + if (flag) + { + T t = default(T); + t = DlgHandlerBase.EnsureCreate(ref t, base.uiBehaviour.m_framesTransform, false, this); + this.m_handlers.Add(define, t); + } + } + + private void RemoveHandler(AuctionSys define) + { + DlgHandlerBase dlgHandlerBase; + bool flag = this.m_handlers.TryGetValue(define, out dlgHandlerBase); + if (flag) + { + DlgHandlerBase.EnsureUnload(ref dlgHandlerBase); + this.m_handlers.Remove(define); + } + } + + public void SetGuildAuctionRedPointState(bool state) + { + base.uiBehaviour.m_GuildAucRedPoint.SetActive(state); + } + } +} -- cgit v1.1-26-g67d0