using UnityEngine; using UnityEngine.UI; using System.Collections; using System.Collections.Generic; using Games.GlobeDefine; using GCGame.Table; using GCGame; public class InputNumBoxLogic : UIControllerBase { #region static public static void ShowInputBoxStatic(string titleStr, int defaultStr, int maxTips, long min, long max, ReturnInput inputReturn) { Hashtable hash = new Hashtable(); hash.Add("TitleStr", titleStr); hash.Add("DesfultStr", defaultStr); hash.Add("InputReturn", inputReturn); hash.Add("MinNum", min); hash.Add("MaxNum", max); hash.Add("MaxTips", maxTips); UIManager.ShowUI(UIInfo.InputNumBox, InputNumBoxLogic.ShowUIOver, hash); } static void ShowUIOver(bool bSuccess, object param) { if (bSuccess) { Hashtable hash = param as Hashtable; if (InputNumBoxLogic.Instance() != null && hash != null) { InputNumBoxLogic.Instance().ShowInputBox(hash["TitleStr"] as string, (int)hash["DesfultStr"], (int)hash["MaxTips"], (long)hash["MinNum"], (long)hash["MaxNum"], hash["InputReturn"] as ReturnInput ); } } } public void ShowInputBox(string titleStr, int defaultStr, int maxTips, long min, long max, ReturnInput returnInput) { _ReturnInput = returnInput; _InputField.Init(0, (int)min, (int)max); _InputField.SetValue(defaultStr); _InputTitle.text = titleStr; if (max > 0 && maxTips > 0) { _MaxValueTip.text = StrDictionary.GetClientDictionaryString("#{" + maxTips + "}", max); } else { _MaxValueTip.text = ""; } } #endregion public UINumBoardInput _InputField; public Text _InputTitle; public Text _MaxValueTip; public delegate void ReturnInput(int inputNum); private ReturnInput _ReturnInput; public void OnEnable() { SetInstance(this); } public void OnDisable() { SetInstance(null); } public void OnOkClick() { if (_ReturnInput != null) { _ReturnInput(_InputField.Value); } UIManager.CloseUI(UIInfo.InputNumBox); } public void OnCancelClick() { if (_ReturnInput != null) { _ReturnInput(-1); } UIManager.CloseUI(UIInfo.InputNumBox); } }