85 lines
2.1 KiB
C#
85 lines
2.1 KiB
C#
|
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using Games.GlobeDefine;
|
|||
|
using GCGame.Table;
|
|||
|
using GCGame;
|
|||
|
|
|||
|
public class InputBoxLogic : UIControllerBase<InputBoxLogic>
|
|||
|
{
|
|||
|
#region static
|
|||
|
|
|||
|
public static void ShowInputBoxStatic(string titleStr, string defaultStr, ReturnInput inputReturn, int charLimit = -1)
|
|||
|
{
|
|||
|
Hashtable hash = new Hashtable();
|
|||
|
hash.Add("TitleStr", titleStr);
|
|||
|
hash.Add("DesfultStr", defaultStr);
|
|||
|
hash.Add("InputReturn", inputReturn);
|
|||
|
hash.Add("CharLimit", charLimit);
|
|||
|
|
|||
|
UIManager.ShowUI(UIInfo.InputBox, InputBoxLogic.ShowUIOver, hash);
|
|||
|
}
|
|||
|
|
|||
|
static void ShowUIOver(bool bSuccess, object param)
|
|||
|
{
|
|||
|
if (bSuccess)
|
|||
|
{
|
|||
|
Hashtable hash = param as Hashtable;
|
|||
|
if (InputBoxLogic.Instance() != null && hash != null)
|
|||
|
{
|
|||
|
InputBoxLogic.Instance().ShowInputBox(hash["TitleStr"] as string, hash["DesfultStr"] as string, hash["InputReturn"] as ReturnInput, (int)hash["CharLimit"]);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void ShowInputBox(string titleStr, string defaultStr, ReturnInput returnInput, int charLimit = -1)
|
|||
|
{
|
|||
|
_ReturnInput = returnInput;
|
|||
|
_InputField.text = defaultStr;
|
|||
|
_InputTitle.text = titleStr;
|
|||
|
|
|||
|
if (charLimit > 0)
|
|||
|
{
|
|||
|
_InputField.characterLimit = charLimit;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
public InputField _InputField;
|
|||
|
public Text _InputTitle;
|
|||
|
|
|||
|
public delegate void ReturnInput(string inputStr);
|
|||
|
private ReturnInput _ReturnInput;
|
|||
|
|
|||
|
public void OnEnable()
|
|||
|
{
|
|||
|
SetInstance(this);
|
|||
|
}
|
|||
|
|
|||
|
public void OnDisable()
|
|||
|
{
|
|||
|
SetInstance(null);
|
|||
|
}
|
|||
|
|
|||
|
public void OnOkClick()
|
|||
|
{
|
|||
|
if (_ReturnInput != null)
|
|||
|
{
|
|||
|
_ReturnInput(_InputField.text);
|
|||
|
}
|
|||
|
UIManager.CloseUI(UIInfo.InputBox);
|
|||
|
}
|
|||
|
|
|||
|
public void OnCancelClick()
|
|||
|
{
|
|||
|
if (_ReturnInput != null)
|
|||
|
{
|
|||
|
_ReturnInput("");
|
|||
|
}
|
|||
|
UIManager.CloseUI(UIInfo.InputBox);
|
|||
|
}
|
|||
|
}
|