From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Assets/Scripts/XMainClient/XChatInputView.cs | 111 +++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/XChatInputView.cs (limited to 'Client/Assets/Scripts/XMainClient/XChatInputView.cs') diff --git a/Client/Assets/Scripts/XMainClient/XChatInputView.cs b/Client/Assets/Scripts/XMainClient/XChatInputView.cs new file mode 100644 index 00000000..840b8357 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/XChatInputView.cs @@ -0,0 +1,111 @@ +using System; +using UILib; +using UnityEngine; +using XMainClient.UI.UICommon; + +namespace XMainClient +{ + internal class XChatInputView : DlgBase + { + 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.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); + } + } +} -- cgit v1.1-26-g67d0