From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../XMainClient/XSpriteIllustrationHandler.cs | 273 +++++++++++++++++++++ 1 file changed, 273 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/XSpriteIllustrationHandler.cs (limited to 'Client/Assets/Scripts/XMainClient/XSpriteIllustrationHandler.cs') diff --git a/Client/Assets/Scripts/XMainClient/XSpriteIllustrationHandler.cs b/Client/Assets/Scripts/XMainClient/XSpriteIllustrationHandler.cs new file mode 100644 index 00000000..595bdbed --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/XSpriteIllustrationHandler.cs @@ -0,0 +1,273 @@ +using System; +using System.Collections.Generic; +using UILib; +using UnityEngine; +using XMainClient.UI; +using XMainClient.UI.UICommon; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class XSpriteIllustrationHandler : DlgHandlerBase + { + protected override string FileName + { + get + { + return "GameSystem/SpriteSystem/SpriteIllustrationWindow"; + } + } + + private IXUIButton m_Close; + + private XUIPool m_SpritePool = new XUIPool(XSingleton.singleton.m_uiTool); + + private IXUIScrollView m_ScrollView; + + private IXUITable m_Table; + + private IXUILabel m_Title; + + private IXUILabelSymbol m_Tip; + + private IXUILabel m_LTypeName; + + private IXUILabel m_STypeName; + + private IXUILabel m_ATypeName; + + private IXUILabel m_BTypeName; + + private IXUILabel m_CTypeName; + + private List m_TypeList = new List(); + + private List> m_SpriteID = new List>(); + + private List m_TypeTitle = new List(); + + protected override void Init() + { + this.m_TypeList.Clear(); + this.m_TypeTitle.Clear(); + this.m_LTypeName = (base.PanelObject.transform.Find("Bg/ScrollView/Table/L/TypeL/Name").GetComponent("XUILabel") as IXUILabel); + this.m_STypeName = (base.PanelObject.transform.Find("Bg/ScrollView/Table/S/TypeL/Name").GetComponent("XUILabel") as IXUILabel); + this.m_ATypeName = (base.PanelObject.transform.Find("Bg/ScrollView/Table/A/TypeL/Name").GetComponent("XUILabel") as IXUILabel); + this.m_BTypeName = (base.PanelObject.transform.Find("Bg/ScrollView/Table/B/TypeL/Name").GetComponent("XUILabel") as IXUILabel); + this.m_CTypeName = (base.PanelObject.transform.Find("Bg/ScrollView/Table/C/TypeL/Name").GetComponent("XUILabel") as IXUILabel); + this.m_Close = (base.PanelObject.transform.Find("Bg/Close").GetComponent("XUIButton") as IXUIButton); + for (int i = 1; i < XFastEnumIntEqualityComparer.ToInt(SpriteQuality.MAX); i++) + { + SpriteQuality spriteQuality = (SpriteQuality)i; + string s = spriteQuality.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); + this.m_Title = (base.PanelObject.transform.Find("Bg/Tittle").GetComponent("XUILabel") as IXUILabel); + this.m_Tip = (base.PanelObject.transform.Find("Tip").GetComponent("XUILabelSymbol") as IXUILabelSymbol); + } + + private void OnListRefreshFinished() + { + this.m_Table.Reposition(); + this.m_ScrollView.ResetPosition(); + } + + public override void RegisterEvent() + { + this.m_Close.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnCloseClicked)); + } + + private void ClassifySpritesByQuality(List itemList, bool isItem) + { + XSpriteSystemDocument specificDocument = XDocuments.GetSpecificDocument(XSpriteSystemDocument.uuID); + this.m_SpriteID.Clear(); + List list = new List(); + List list2 = new List(); + List list3 = new List(); + List list4 = new List(); + List list5 = new List(); + int i = 0; + while (i < itemList.Count) + { + SpriteQuality spriteQuality; + //! + uint item; + if (isItem) + { + SpritePreviewTable.RowData byItemID = specificDocument._SpritePreviewTable.GetByItemID(itemList[i]); + bool flag = byItemID == null; + if (!flag) + { + spriteQuality = (SpriteQuality)byItemID.ItemQuality; + item = byItemID.ItemID; + goto IL_B9; + } + } + else + { + SpriteTable.RowData bySpriteID = specificDocument._SpriteTable.GetBySpriteID(itemList[i]); + bool flag2 = bySpriteID == null; + if (!flag2) + { + spriteQuality = (SpriteQuality)bySpriteID.SpriteQuality; + item = bySpriteID.SpriteID; + goto IL_B9; + } + } + IL_116: + i++; + continue; + IL_B9: + switch (spriteQuality) + { + case SpriteQuality.C: + { + list5.Add(item); + break; + } + case SpriteQuality.B: + { + list4.Add(item); + break; + } + case SpriteQuality.A: + { + list3.Add(item); + break; + } + case SpriteQuality.S: + { + list2.Add(item); + break; + } + case SpriteQuality.L: + { + list.Add(item); + break; + } + } + goto IL_116; + } + this.m_SpriteID.Add(list5); + this.m_SpriteID.Add(list4); + this.m_SpriteID.Add(list3); + this.m_SpriteID.Add(list2); + this.m_SpriteID.Add(list); + } + + private void ShowIllustration(List itemList, bool isItem, bool showTip) + { + this.m_Title.SetText(isItem ? XStringDefineProxy.GetString("SpriteAwardPreview") : XStringDefineProxy.GetString("SpriteIllustrationName")); + this.SetIllustrationType(isItem ? XStringDefineProxy.GetString("SpriteIllustrationType1") : XStringDefineProxy.GetString("SpriteIllustrationType2")); + XSpriteSystemDocument specificDocument = XDocuments.GetSpecificDocument(XSpriteSystemDocument.uuID); + this.m_Tip.InputText = XStringDefineProxy.GetString("SpriteLotterySafeTip", new object[] + { + specificDocument.SpecialSafeCount + }); + this.m_Tip.SetVisible(showTip); + this.m_ScrollView.ResetPosition(); + this.ClassifySpritesByQuality(itemList, isItem); + this.m_SpritePool.FakeReturnAll(); + this.CreateIcon(SpriteQuality.L, isItem); + this.CreateIcon(SpriteQuality.S, isItem); + this.CreateIcon(SpriteQuality.A, isItem); + this.CreateIcon(SpriteQuality.B, isItem); + this.CreateIcon(SpriteQuality.C, isItem); + this.m_SpritePool.ActualReturnAll(true); + } + + private void SetIllustrationType(string name) + { + this.m_LTypeName.SetText(name); + this.m_STypeName.SetText(name); + this.m_ATypeName.SetText(name); + this.m_BTypeName.SetText(name); + this.m_CTypeName.SetText(name); + } + + public void ShowSpriteEggIllustration(SpriteEggLotteryType type) + { + XSpriteSystemDocument specificDocument = XDocuments.GetSpecificDocument(XSpriteSystemDocument.uuID); + List list; + bool flag = specificDocument._SpriteEggPreviewDict.TryGetValue(XFastEnumIntEqualityComparer.ToInt(type), out list); + if (flag) + { + bool flag2 = list.Count > 0; + if (flag2) + { + this.ShowIllustration(list, true, type == SpriteEggLotteryType.Special); + } + } + } + + public void ShowSpriteAllIllustration() + { + XSpriteSystemDocument specificDocument = XDocuments.GetSpecificDocument(XSpriteSystemDocument.uuID); + bool flag = specificDocument.SpriteShowInIllustration.Count > 0; + if (flag) + { + this.ShowIllustration(specificDocument.SpriteShowInIllustration, false, false); + } + } + + private void CreateIcon(SpriteQuality quality, bool isItem) + { + int index = XFastEnumIntEqualityComparer.ToInt(quality) - 1; + IXUIList ixuilist = this.m_TypeList[index]; + List list = this.m_SpriteID[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; + if (isItem) + { + this.SetItemInfo(gameObject, list[i]); + } + else + { + this.SetSpriteInfo(gameObject, list[i]); + } + XSingleton.singleton.m_uiTool.ChangePanel(gameObject, ixuilist.GetParentUIRect(), ixuilist.GetParentPanel()); + } + ixuilist.Refresh(); + } + + 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