From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../XMainClient/UI/LuckyTurntableRecordView.cs | 126 +++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/UI/LuckyTurntableRecordView.cs (limited to 'Client/Assets/Scripts/XMainClient/UI/LuckyTurntableRecordView.cs') diff --git a/Client/Assets/Scripts/XMainClient/UI/LuckyTurntableRecordView.cs b/Client/Assets/Scripts/XMainClient/UI/LuckyTurntableRecordView.cs new file mode 100644 index 00000000..9fa9f3a0 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/UI/LuckyTurntableRecordView.cs @@ -0,0 +1,126 @@ +using System; +using System.Collections.Generic; +using UILib; +using UnityEngine; +using XMainClient.UI.UICommon; +using XUtliPoolLib; + +namespace XMainClient.UI +{ + internal class LuckyTurntableRecordView : DlgBase + { + public override string fileName + { + get + { + return "OperatingActivity/LuckyRecordDlg"; + } + } + + private IXUIButton m_btnBack; + + private IXUIButton m_btnClose; + + private XUIPool m_ItemPool = new XUIPool(XSingleton.singleton.m_uiTool); + + private Transform m_root; + + private Dictionary m_map = new Dictionary(); + + protected override void Init() + { + this.m_btnBack = (base.uiBehaviour.transform.Find("backclick").GetComponent("XUIButton") as IXUIButton); + this.m_btnClose = (base.uiBehaviour.transform.Find("Bg/Close").GetComponent("XUIButton") as IXUIButton); + this.m_root = base.uiBehaviour.transform.Find("Bg/ScrollView"); + GameObject gameObject = base.uiBehaviour.transform.Find("Bg/ScrollView/Item").gameObject; + this.m_ItemPool.SetupPool(this.m_root.gameObject, gameObject, 8u, false); + } + + public void ShowList(List> list) + { + this.m_map.Clear(); + foreach (KeyValuePair keyValuePair in list) + { + bool flag = !this.m_map.ContainsKey(keyValuePair.Key); + if (flag) + { + this.m_map[keyValuePair.Key] = 0; + } + Dictionary map = this.m_map; + int key = keyValuePair.Key; + map[key] += keyValuePair.Value; + } + this.SetVisibleWithAnimation(true, null); + this.RefreshList(); + } + + public void RefreshList() + { + this.m_ItemPool.ReturnAll(false); + List> list = new List>(this.m_map); + list.Sort(delegate(KeyValuePair a, KeyValuePair b) + { + ItemList.RowData itemConf = XBagDocument.GetItemConf(a.Key); + ItemList.RowData itemConf2 = XBagDocument.GetItemConf(b.Key); + bool flag = itemConf == null; + int result; + if (flag) + { + result = 1; + } + else + { + bool flag2 = itemConf2 == null; + if (flag2) + { + result = -1; + } + else + { + bool flag3 = itemConf.ItemQuality > itemConf2.ItemQuality; + if (flag3) + { + result = -1; + } + else + { + bool flag4 = itemConf.ItemQuality < itemConf2.ItemQuality; + if (flag4) + { + result = 1; + } + else + { + result = itemConf.SortID.CompareTo(itemConf2.SortID); + } + } + } + } + return result; + }); + for (int i = 0; i < list.Count; i++) + { + KeyValuePair keyValuePair = list[i]; + GameObject gameObject = this.m_ItemPool.FetchGameObject(false); + gameObject.name = keyValuePair.Key.ToString(); + gameObject.transform.localPosition = new Vector3((float)(i * this.m_ItemPool.TplWidth), 0f, 0f) + this.m_ItemPool.TplPos; + IXUISprite ixuisprite = gameObject.transform.Find("Icon").GetComponent("XUISprite") as IXUISprite; + ixuisprite.ID = (ulong)((long)keyValuePair.Key); + XSingleton.singleton.normalItemDrawer.DrawItem(gameObject, keyValuePair.Key, keyValuePair.Value, false); + ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(XSingleton.singleton.OnItemClick)); + } + } + + public override void RegisterEvent() + { + this.m_btnClose.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnCloseClicked)); + this.m_btnBack.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnCloseClicked)); + } + + private bool OnCloseClicked(IXUIButton sp) + { + this.SetVisibleWithAnimation(false, null); + return true; + } + } +} -- cgit v1.1-26-g67d0