From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Scripts/XMainClient/XYYMallCategoryHandler.cs | 144 +++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/XYYMallCategoryHandler.cs (limited to 'Client/Assets/Scripts/XMainClient/XYYMallCategoryHandler.cs') diff --git a/Client/Assets/Scripts/XMainClient/XYYMallCategoryHandler.cs b/Client/Assets/Scripts/XMainClient/XYYMallCategoryHandler.cs new file mode 100644 index 00000000..80be4bab --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/XYYMallCategoryHandler.cs @@ -0,0 +1,144 @@ +using System; +using System.Collections.Generic; +using UILib; +using UnityEngine; +using XMainClient.UI; +using XMainClient.UI.UICommon; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class XYYMallCategoryHandler : DlgHandlerBase + { + protected override string FileName + { + get + { + return "GameSystem/Welfare/YYMallCategory"; + } + } + + private IXUIButton m_Close; + + private XUIPool m_SpritePool = new XUIPool(XSingleton.singleton.m_uiTool); + + private IXUIScrollView m_ScrollView; + + private IXUITable m_Table; + + private List m_TypeList = new List(); + + private List> m_CategoryList = new List>(); + + private List m_TypeTitle = new List(); + + protected override void OnShow() + { + base.OnShow(); + this.ShowIllustration(); + } + + protected override void Init() + { + this.m_TypeList.Clear(); + this.m_TypeTitle.Clear(); + this.m_Close = (base.PanelObject.transform.Find("Bg/Close").GetComponent("XUIButton") as IXUIButton); + for (int i = 1; i < XFastEnumIntEqualityComparer.ToInt(YYMallCategory.MAX); i++) + { + YYMallCategory yymallCategory = (YYMallCategory)i; + string s = yymallCategory.ToString(); + Transform item = base.PanelObject.transform.Find(XSingleton.singleton.StringCombine("Bg/ScrollView/Table/", s)); + this.m_TypeTitle.Add(item); + IXUIList ixuilist = base.PanelObject.transform.Find(XSingleton.singleton.StringCombine("Bg/ScrollView/Table/", s, "/Grid")).GetComponent("XUIList") as IXUIList; + ixuilist.RegisterRepositionHandle(new OnAfterRepostion(this.OnListRefreshFinished)); + this.m_TypeList.Add(ixuilist); + } + Transform transform = base.PanelObject.transform.Find("Bg/ScrollView/ItemTpl"); + this.m_SpritePool.SetupPool(transform.parent.gameObject, transform.gameObject, 10u, false); + this.m_ScrollView = (base.PanelObject.transform.Find("Bg/ScrollView").GetComponent("XUIScrollView") as IXUIScrollView); + this.m_Table = (base.PanelObject.transform.Find("Bg/ScrollView/Table").GetComponent("XUITable") as IXUITable); + } + + private void OnListRefreshFinished() + { + this.m_Table.Reposition(); + this.m_ScrollView.ResetPosition(); + } + + public override void RegisterEvent() + { + this.m_Close.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnCloseClicked)); + } + + protected override void OnHide() + { + this.m_CategoryList.Clear(); + base.OnHide(); + } + + private void ShowIllustration() + { + this.m_CategoryList = XNormalShopDocument.ShopDoc.GetShopItemByPlayLevelAndShopType(XSysDefine.XSys_Welfare_YyMall); + this.m_ScrollView.ResetPosition(); + this.m_SpritePool.FakeReturnAll(); + this.CreateIcon(YYMallCategory.Resource); + this.CreateIcon(YYMallCategory.Special); + this.CreateIcon(YYMallCategory.Privilege); + this.m_SpritePool.ActualReturnAll(true); + } + + private void CreateIcon(YYMallCategory category) + { + int index = XFastEnumIntEqualityComparer.ToInt(category) - 1; + IXUIList ixuilist = this.m_TypeList[index]; + List list = this.m_CategoryList[index]; + this.m_TypeTitle[index].gameObject.SetActive(list.Count > 0); + for (int i = 0; i < list.Count; i++) + { + GameObject gameObject = this.m_SpritePool.FetchGameObject(false); + gameObject.transform.parent = ixuilist.gameObject.transform; + XSingleton.singleton.normalItemDrawer.DrawItem(gameObject, (int)list[i], 1, false); + IXUISprite ixuisprite = gameObject.transform.Find("Icon").GetComponent("XUISprite") as IXUISprite; + ixuisprite.ID = (ulong)list[i]; + ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnClickItemIcon)); + XSingleton.singleton.m_uiTool.ChangePanel(gameObject, ixuilist.GetParentUIRect(), ixuilist.GetParentPanel()); + } + ixuilist.Refresh(); + } + + private void OnClickItemIcon(IXUISprite spr) + { + XItem mainItem = XBagDocument.MakeXItem((int)spr.ID, false); + XSingleton.singleton.ShowTooltipDialogWithSearchingCompare(mainItem, spr, false, 0u); + } + + private void SetItemInfo(GameObject obj, uint itemID) + { + IXUISprite ixuisprite = obj.transform.Find("Icon").GetComponent("XUISprite") as IXUISprite; + ixuisprite.ID = (ulong)itemID; + XSingleton.singleton.normalItemDrawer.DrawItem(obj, (int)itemID, 0, false); + ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(XSingleton.singleton.OnItemClick)); + } + + private void SetSpriteInfo(GameObject obj, uint spriteID) + { + XSingleton.singleton.normalItemDrawer.DrawItem(obj, (int)spriteID, 0, false); + IXUISprite ixuisprite = obj.transform.Find("Icon").GetComponent("XUISprite") as IXUISprite; + ixuisprite.ID = (ulong)spriteID; + ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnSpriteIconClicked)); + } + + private void OnSpriteIconClicked(IXUISprite spr) + { + uint spriteID = (uint)spr.ID; + XSpriteSystemDocument specificDocument = XDocuments.GetSpecificDocument(XSpriteSystemDocument.uuID); + DlgBase.singleton.ShowDetail(spriteID); + } + + private bool OnCloseClicked(IXUIButton sp) + { + base.SetVisible(false); + return true; + } + } +} -- cgit v1.1-26-g67d0