summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/XChatSettingView.cs
blob: 21c1d3e8248789cfe1414d22f09850f8fd8cd327 (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
using System;
using System.Collections.Generic;
using UILib;
using XMainClient.UI.UICommon;

namespace XMainClient
{
	internal class XChatSettingView : DlgBase<XChatSettingView, XChatSettingBehaviour>
	{
		public override string fileName
		{
			get
			{
				return "GameSystem/ChatSettingDlg";
			}
		}

		public override int group
		{
			get
			{
				return 1;
			}
		}

		public override bool autoload
		{
			get
			{
				return true;
			}
		}

		private XChatDocument _doc = null;

		public List<ChatChannelType> m_EnableChannel = new List<ChatChannelType>();

		public XChatSettingView()
		{
			this.m_EnableChannel.Add(ChatChannelType.World);
			this.m_EnableChannel.Add(ChatChannelType.Guild);
			this.m_EnableChannel.Add(ChatChannelType.System);
			this.m_EnableChannel.Add(ChatChannelType.Team);
			this.m_EnableChannel.Add(ChatChannelType.Friends);
			this.m_EnableChannel.Add(ChatChannelType.Spectate);
		}

		protected override void Init()
		{
			this._doc = XDocuments.GetSpecificDocument<XChatDocument>(XChatDocument.uuID);
			this._doc.ChatSettingView = this;
			base.uiBehaviour.m_WorldChat.bChecked = true;
			base.uiBehaviour.m_GuildChat.bChecked = true;
			base.uiBehaviour.m_FriendsChat.bChecked = true;
			base.uiBehaviour.m_TeamChat.bChecked = true;
			base.uiBehaviour.m_SystemChat.bChecked = true;
		}

		public override void RegisterEvent()
		{
			base.uiBehaviour.m_Close.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnCloseClicked));
			base.uiBehaviour.m_WorldChat.RegisterOnCheckEventHandler(new CheckBoxOnCheckEventHandler(this.OnCheckChannel));
			base.uiBehaviour.m_GuildChat.RegisterOnCheckEventHandler(new CheckBoxOnCheckEventHandler(this.OnCheckChannel));
			base.uiBehaviour.m_FriendsChat.RegisterOnCheckEventHandler(new CheckBoxOnCheckEventHandler(this.OnCheckChannel));
			base.uiBehaviour.m_TeamChat.RegisterOnCheckEventHandler(new CheckBoxOnCheckEventHandler(this.OnCheckChannel));
			base.uiBehaviour.m_SystemChat.RegisterOnCheckEventHandler(new CheckBoxOnCheckEventHandler(this.OnCheckChannel));
			base.uiBehaviour.m_BackClick.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnCloseClicked));
		}

		protected override void OnUnload()
		{
			base.OnUnload();
			this._doc = null;
		}

		public bool OnCloseClicked(IXUIButton sp)
		{
			this.SetVisibleWithAnimation(false, null);
			return true;
		}

		public bool IsChannelEnable(ChatChannelType type)
		{
			for (int i = 0; i < this.m_EnableChannel.Count; i++)
			{
				bool flag = this.m_EnableChannel[i] == type;
				if (flag)
				{
					return true;
				}
			}
			return false;
		}

		public bool OnCheckChannel(IXUICheckBox cb)
		{
			ChatChannelType chatChannelType = (ChatChannelType)cb.ID;
			bool bChecked = cb.bChecked;
			if (bChecked)
			{
				bool flag = false;
				for (int i = 0; i < this.m_EnableChannel.Count; i++)
				{
					bool flag2 = this.m_EnableChannel[i] == chatChannelType;
					if (flag2)
					{
						flag = true;
					}
				}
				bool flag3 = !flag;
				if (flag3)
				{
					this.m_EnableChannel.Add(chatChannelType);
				}
			}
			else
			{
				for (int j = 0; j < this.m_EnableChannel.Count; j++)
				{
					bool flag4 = this.m_EnableChannel[j] == chatChannelType;
					if (flag4)
					{
						this.m_EnableChannel.RemoveAt(j);
						break;
					}
				}
			}
			return true;
		}
	}
}