From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Scripts/XMainClient/UI/ItemUseListDlg.cs | 107 +++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/UI/ItemUseListDlg.cs (limited to 'Client/Assets/Scripts/XMainClient/UI/ItemUseListDlg.cs') diff --git a/Client/Assets/Scripts/XMainClient/UI/ItemUseListDlg.cs b/Client/Assets/Scripts/XMainClient/UI/ItemUseListDlg.cs new file mode 100644 index 00000000..2724279f --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/UI/ItemUseListDlg.cs @@ -0,0 +1,107 @@ +using System; +using System.Collections.Generic; +using UILib; +using UnityEngine; +using XMainClient.UI.UICommon; +using XUtliPoolLib; + +namespace XMainClient.UI +{ + internal class ItemUseListDlg : DlgBase + { + public override string fileName + { + get + { + return "Hall/ShapeshiftDlg"; + } + } + + public override int layer + { + get + { + return 100; + } + } + + public override bool autoload + { + get + { + return true; + } + } + + private List m_ItemList = null; + + private ButtonClickEventHandler m_ClickHandler = null; + + protected override void Init() + { + } + + public override void RegisterEvent() + { + base.uiBehaviour.m_Close.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnCloseClicked)); + base.uiBehaviour.m_WrapContent.RegisterItemUpdateEventHandler(new WrapItemUpdateEventHandler(this.OnWrapContentUpdated)); + } + + public void SetTitle(string text) + { + base.uiBehaviour.m_Title.SetText(text); + } + + public void Set(ButtonClickEventHandler clickHandler, List itemList) + { + bool flag = itemList == null; + if (!flag) + { + this.m_ItemList = itemList; + this.m_ClickHandler = clickHandler; + this.SetVisible(true, true); + } + } + + protected override void OnShow() + { + base.OnShow(); + bool flag = this.m_ItemList != null; + if (flag) + { + base.uiBehaviour.m_WrapContent.SetContentCount(this.m_ItemList.Count, false); + } + base.uiBehaviour.m_ScrollView.ResetPosition(); + } + + private void OnWrapContentUpdated(Transform t, int index) + { + bool flag = index < 0 || this.m_ItemList == null || index >= this.m_ItemList.Count; + if (!flag) + { + XItem item = this.m_ItemList[index]; + Transform transform = t.Find("Item"); + IXUIButton ixuibutton = t.Find("BtnUse").GetComponent("XUIButton") as IXUIButton; + XSingleton.singleton.DrawItem(transform.gameObject, item); + ixuibutton.ID = (ulong)((long)index); + ixuibutton.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnUseClicked)); + } + } + + private bool OnUseClicked(IXUIButton btn) + { + bool flag = this.m_ClickHandler != null; + if (flag) + { + this.m_ClickHandler(btn); + } + this.SetVisible(false, true); + return true; + } + + private void OnCloseClicked(IXUISprite iSp) + { + this.SetVisible(false, true); + } + } +} -- cgit v1.1-26-g67d0