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/XTitleBar.cs | 107 +++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/XTitleBar.cs (limited to 'Client/Assets/Scripts/XMainClient/XTitleBar.cs') diff --git a/Client/Assets/Scripts/XMainClient/XTitleBar.cs b/Client/Assets/Scripts/XMainClient/XTitleBar.cs new file mode 100644 index 00000000..bd155c41 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/XTitleBar.cs @@ -0,0 +1,107 @@ +using System; +using System.Collections.Generic; +using UILib; +using UnityEngine; + +namespace XMainClient +{ + internal class XTitleBar : DlgHandlerBase + { + private List m_TitleButtons = new List(); + + private Transform m_SortArrow; + + private Transform m_SortArrowDir; + + private TitleClickEventHandler m_TitleClickEventHandler; + + protected override void Init() + { + base.Init(); + for (int i = 0; i <= 20; i++) + { + Transform transform = base.PanelObject.transform.Find("Title" + i); + bool flag = transform == null; + if (!flag) + { + IXUILabel ixuilabel = transform.GetComponent("XUILabel") as IXUILabel; + ixuilabel.ID = (ulong)((long)i); + this.m_TitleButtons.Add(ixuilabel); + } + } + this.m_SortArrow = base.PanelObject.transform.Find("Sort"); + this.m_SortArrowDir = this.m_SortArrow.Find("Arrow"); + } + + public override void RegisterEvent() + { + base.RegisterEvent(); + for (int i = 0; i < this.m_TitleButtons.Count; i++) + { + IXUIButton ixuibutton = this.m_TitleButtons[i].gameObject.transform.Find("Button").GetComponent("XUIButton") as IXUIButton; + bool flag = ixuibutton == null; + if (!flag) + { + ixuibutton.RegisterClickEventHandler(new ButtonClickEventHandler(this._OnTitleClicked)); + } + } + } + + public void RegisterClickEventHandler(TitleClickEventHandler handler) + { + this.m_TitleClickEventHandler = handler; + } + + public void Refresh(ulong selectedID) + { + IXUILabel title = null; + for (int i = 0; i < this.m_TitleButtons.Count; i++) + { + bool flag = this.m_TitleButtons[i].ID == selectedID; + if (flag) + { + title = this.m_TitleButtons[i]; + break; + } + } + this._SetTitleSelect(title); + } + + private bool _OnTitleClicked(IXUIButton btn) + { + IXUILabel ixuilabel = btn.gameObject.transform.parent.GetComponent("XUILabel") as IXUILabel; + this._SetTitleSelect(ixuilabel); + bool flag = this.m_TitleClickEventHandler != null; + if (flag) + { + this.SetArrowDir(this.m_TitleClickEventHandler(ixuilabel.ID)); + } + return true; + } + + private void _SetTitleSelect(IXUILabel title) + { + this._SetSortArrow(title); + } + + private void _SetSortArrow(IXUILabel title) + { + bool flag = title != null; + if (flag) + { + this.m_SortArrow.gameObject.SetActive(true); + this.m_SortArrow.parent = title.gameObject.transform; + this.m_SortArrow.localPosition = new Vector3((float)(title.spriteWidth / 2), 0f); + } + else + { + this.m_SortArrow.gameObject.SetActive(false); + } + } + + public void SetArrowDir(bool bDirUp) + { + this.m_SortArrowDir.localRotation = Quaternion.Euler(0f, 0f, (float)(bDirUp ? -90 : 90)); + } + } +} -- cgit v1.1-26-g67d0