From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../XMainClient/UI/UICommon/TabHandleBase.cs | 60 ++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/UI/UICommon/TabHandleBase.cs (limited to 'Client/Assets/Scripts/XMainClient/UI/UICommon/TabHandleBase.cs') diff --git a/Client/Assets/Scripts/XMainClient/UI/UICommon/TabHandleBase.cs b/Client/Assets/Scripts/XMainClient/UI/UICommon/TabHandleBase.cs new file mode 100644 index 00000000..9877b620 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/UI/UICommon/TabHandleBase.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using UILib; +using UnityEngine; + +namespace XMainClient.UI.UICommon +{ + internal class TabHandleBase : DlgBase, IDlgHandlerMgr where T : IXUIDlg, new() where V : DlgBehaviourBase + { + private Dictionary m_handles = new Dictionary(); + + protected XSysDefine m_select; + + public virtual void RefreshData() + { + DlgHandlerBase dlgHandlerBase; + bool flag = this.m_handles.TryGetValue(this.m_select, out dlgHandlerBase) && dlgHandlerBase.IsVisible(); + if (flag) + { + dlgHandlerBase.RefreshData(); + } + } + + protected void SetHandleVisible(XSysDefine define, bool isVisible) + { + DlgHandlerBase dlgHandlerBase; + bool flag = this.m_handles.TryGetValue(define, out dlgHandlerBase); + if (flag) + { + dlgHandlerBase.SetVisible(isVisible); + if (isVisible) + { + this.m_select = define; + } + } + } + + protected void RegisterHandler(XSysDefine define, GameObject g, bool show = false) where C : DlgHandlerBase, new() + { + bool flag = !this.m_handles.ContainsKey(define); + if (flag) + { + C c = default(C); + c = DlgHandlerBase.EnsureCreate(ref c, g, this, false); + this.m_handles.Add(define, c); + } + } + + protected void RemoveHandler(XSysDefine define) + { + DlgHandlerBase dlgHandlerBase; + bool flag = this.m_handles.TryGetValue(define, out dlgHandlerBase); + if (flag) + { + DlgHandlerBase.EnsureUnload(ref dlgHandlerBase); + this.m_handles.Remove(define); + } + } + } +} -- cgit v1.1-26-g67d0