113 lines
2.3 KiB
C#
113 lines
2.3 KiB
C#
// ***********************************************************************
|
|
// Assembly : Game
|
|
// Author : Kimch
|
|
// Created : 2021-01-08
|
|
// Description :
|
|
// Last Modified By :
|
|
// Last Modified On :
|
|
// ***********************************************************************
|
|
// <copyright file= "NameBox.View" company="Kunpo"></copyright>
|
|
// <summary></summary>
|
|
// ***********************************************************************
|
|
namespace G.UI
|
|
{
|
|
using System;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
partial class NameBox
|
|
{
|
|
#region Field
|
|
|
|
#pragma warning disable CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
|
|
[KUIFlag]
|
|
TextMeshProUGUI _tmpTitle;
|
|
[KUIFlag]
|
|
TMP_InputField _inputFiled;
|
|
[KUIFlag]
|
|
Button _btnConfirm;
|
|
[KUIFlag]
|
|
Button _btnClose;
|
|
[KUIFlag]
|
|
Button _btnPaste;
|
|
|
|
#pragma warning restore CS0649 // 从未对字段“赋值,字段将一直保持其默认值 null
|
|
|
|
#endregion
|
|
|
|
#region Method
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public void InitView()
|
|
{
|
|
SetViewData();
|
|
_btnConfirm.onClick.AddListener(this.OnConfirm);
|
|
_btnClose.onClick.AddListener(this.OnCloseBtnClick);
|
|
_btnPaste.onClick.AddListener(this.OnPasteBtnClick);
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public void RefreshView()
|
|
{
|
|
if (this.data is Tuple<string, Action<string>> tuple)
|
|
{
|
|
_inputFiled.text = tuple.Item1;
|
|
}
|
|
}
|
|
|
|
private void OnConfirm()
|
|
{
|
|
SoundProxy.PlayFxAsync(GlobalDefine.BUTTON_CLICK_SOUND);
|
|
var str = _inputFiled.text;
|
|
if (str.Length == 0 || str.Length > 8)
|
|
{
|
|
ToastBox.ShowText("字符数量不符合.");
|
|
return;
|
|
}
|
|
|
|
KPlatform.Instance.VerifySensitiveWords(str, (error) =>
|
|
{
|
|
if (error == 0)
|
|
{
|
|
if (this.data is Tuple<string, Action<string>> tuple)
|
|
{
|
|
tuple.Item2?.Invoke(str);
|
|
}
|
|
CloseWindow(this);
|
|
}
|
|
else
|
|
{
|
|
ToastBox.ShowText("名字不合法");
|
|
}
|
|
});
|
|
}
|
|
|
|
private void OnPasteBtnClick()
|
|
{
|
|
KPlatform.Instance.GetClipboardData((error, message, data) =>
|
|
{
|
|
if (error == 0)
|
|
{
|
|
_inputFiled.text = data as string;
|
|
ToastBox.ShowText("粘贴成功");
|
|
}
|
|
});
|
|
}
|
|
|
|
private void OnCloseBtnClick()
|
|
{
|
|
CloseWindow(this);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|