summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/XChatInputView.cs
blob: 840b8357e6e6694546fca138f2a3589a4fa7053a (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
using System;
using UILib;
using UnityEngine;
using XMainClient.UI.UICommon;

namespace XMainClient
{
	internal class XChatInputView : DlgBase<XChatInputView, XChatInputBehaviour>
	{
		public override string fileName
		{
			get
			{
				return "Common/ChatInput";
			}
		}

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

		private string _tips;

		private ChatInputStringBack _func = null;

		public ChatInputType inputType = ChatInputType.TEXT;

		public void ShowChatInput(ChatInputStringBack func)
		{
			this._func = func;
			this.SetVisible(true, true);
		}

		protected override void Init()
		{
			base.Init();
			this._tips = XStringDefineProxy.GetString("ChatInput_DefaultTips");
		}

		public override void RegisterEvent()
		{
			base.RegisterEvent();
			base.uiBehaviour.m_BlackBg.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnCanCelBlackClick));
			base.uiBehaviour.m_SendBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnSendBtnClick));
			base.uiBehaviour.m_btnChatpic.RegisterClickEventHandler(new ButtonClickEventHandler(this.OpenEmotion));
		}

		protected override void OnShow()
		{
			this.TextInit();
		}

		protected override void OnHide()
		{
			this.inputType = ChatInputType.TEXT;
			this.SetInputType(this.inputType);
			base.OnHide();
		}

		public void SetInputType(ChatInputType type)
		{
			this.inputType = type;
			base.uiBehaviour.m_btnChatpic.SetVisible(type == ChatInputType.EMOTION);
		}

		public void SetCharacterLimit(int num)
		{
			base.uiBehaviour.m_TextInput.SetCharacterLimit(num);
		}

		private void OnCanCelBlackClick(IXUISprite iSp)
		{
			this.TextInit();
			this.SetVisible(false, true);
		}

		private bool OnSendBtnClick(IXUIButton btn)
		{
			bool flag = this._func != null;
			if (flag)
			{
				this._func(base.uiBehaviour.m_TextInput.GetText());
			}
			this.SetVisible(false, true);
			return true;
		}

		private void TextInit()
		{
			base.uiBehaviour.m_TextInput.SetText("");
			base.uiBehaviour.m_ShowLabel.SetText(this._tips);
		}

		private bool OpenEmotion(IXUIButton btn)
		{
			DlgBase<ChatEmotionView, ChatEmotionBehaviour>.singleton.ShowChatEmotion(new ChatSelectStringBack(this.OnSelectEmotion), new Vector3(16f, 143f, 0f), 0);
			return true;
		}

		public void OnSelectEmotion(string motionstr)
		{
			string text = base.uiBehaviour.m_TextInput.GetText();
			text += motionstr;
			base.uiBehaviour.m_TextInput.SetText(text);
		}
	}
}