78 lines
1.9 KiB
C#
78 lines
1.9 KiB
C#
|
using Games.GlobeDefine;
|
|||
|
using GCGame;
|
|||
|
using GCGame.Table;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
|
|||
|
public class ChangeNameInputPanel : MonoBehaviour
|
|||
|
{
|
|||
|
public delegate void _CallBack(string name);
|
|||
|
|
|||
|
public static _CallBack _ChangeNameCallBack;
|
|||
|
|
|||
|
//[Serializable]
|
|||
|
//public class ChangeNameConfirmEvent : UnityEvent<string>
|
|||
|
//{
|
|||
|
// public ChangeNameConfirmEvent() { }
|
|||
|
//}
|
|||
|
//[SerializeField]
|
|||
|
//public ChangeNameConfirmEvent confirmEvent;
|
|||
|
|
|||
|
public InputField _InputText;
|
|||
|
|
|||
|
private void OnEnable()
|
|||
|
{
|
|||
|
_InputText.text = "";
|
|||
|
}
|
|||
|
|
|||
|
public static void ShowChangeNameInputPanel(_CallBack callBack = null)
|
|||
|
{
|
|||
|
//UIManager.ShowUI(UIInfo.ChangeNameInputPanel);
|
|||
|
if (callBack != null)
|
|||
|
_ChangeNameCallBack = callBack;
|
|||
|
}
|
|||
|
|
|||
|
public void OnConfirmBtn()
|
|||
|
{
|
|||
|
//空
|
|||
|
if (string.IsNullOrEmpty(_InputText.text))
|
|||
|
{
|
|||
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{46207}"));
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
//空格
|
|||
|
foreach (var curChar in _InputText.text)
|
|||
|
if (char.IsWhiteSpace(curChar))
|
|||
|
{
|
|||
|
MessageBoxLogic.OpenOKBox(46227, 1000);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (_InputText.text.Contains("*"))
|
|||
|
{
|
|||
|
MessageBoxLogic.OpenOKBox(1278, 1000);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (null == Utils.GetStrFilter(_InputText.text, (int) GameDefine_Globe.STRFILTER_TYPE.STRFILTER_NAME))
|
|||
|
{
|
|||
|
if (_ChangeNameCallBack != null)
|
|||
|
_ChangeNameCallBack.Invoke(_InputText.text);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
// 包含非法字符
|
|||
|
MessageBoxLogic.OpenOKBox(1278, 1000);
|
|||
|
}
|
|||
|
|
|||
|
//关闭界面
|
|||
|
OnCancelBtn();
|
|||
|
}
|
|||
|
|
|||
|
public void OnCancelBtn()
|
|||
|
{
|
|||
|
//UIManager.CloseUI(UIInfo.ChangeNameInputPanel);
|
|||
|
gameObject.SetActive(false);
|
|||
|
}
|
|||
|
}
|