summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/UI/UICommon/TabHandleBase.cs
blob: 9877b62006c42ed7f1cf3a3e3f90ddfb3df89397 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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);
			}
		}
	}
}