summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/UI/UICommon/TabHandleBase.cs
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-01-25 14:28:30 +0800
committerchai <chaifix@163.com>2021-01-25 14:28:30 +0800
commit6eb915c129fc90c6f4c82ae097dd6ffad5239efc (patch)
tree7dd2be50edf41f36b60fac84696e731c13afe617 /Client/Assets/Scripts/XMainClient/UI/UICommon/TabHandleBase.cs
+scripts
Diffstat (limited to 'Client/Assets/Scripts/XMainClient/UI/UICommon/TabHandleBase.cs')
-rw-r--r--Client/Assets/Scripts/XMainClient/UI/UICommon/TabHandleBase.cs60
1 files changed, 60 insertions, 0 deletions
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<T, V> : DlgBase<T, V>, IDlgHandlerMgr where T : IXUIDlg, new() where V : DlgBehaviourBase
+ {
+ private Dictionary<XSysDefine, DlgHandlerBase> m_handles = new Dictionary<XSysDefine, DlgHandlerBase>();
+
+ 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<C>(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<C>(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<DlgHandlerBase>(ref dlgHandlerBase);
+ this.m_handles.Remove(define);
+ }
+ }
+ }
+}