756 lines
26 KiB
C#
756 lines
26 KiB
C#
using System.Collections;
|
|
using Games.GlobeDefine;
|
|
using GCGame;
|
|
using GCGame.Table;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class MessageBoxLogic : UIControllerBase<MessageBoxLogic>
|
|
{
|
|
public delegate void OnCancelClick();
|
|
|
|
public delegate void OnOKClick();
|
|
|
|
public delegate void OnToggleChange(bool state);
|
|
|
|
public delegate void OnWaitTimeOut();
|
|
|
|
public delegate void voidNoneDel(); // 当消息盒关闭时(无论主动被动,还是被顶替)调用
|
|
|
|
public enum PASSWORD
|
|
{
|
|
INVALID = -1,
|
|
MARRYROOT = 0
|
|
}
|
|
|
|
public int _AutoBtn;
|
|
public GameObject _BtnClose; //关闭按钮
|
|
public GameObject _BtnPanel;
|
|
|
|
public int _OkBtnDelay;
|
|
public Text labelText; // 提示内容
|
|
public Text labelTitle; // 提示标题
|
|
public Text m_CancleText;
|
|
public Button m_MessageBoxCancelButton; // 取消按钮
|
|
public Button m_MessageBoxOKButton; // 确定按钮
|
|
public Button m_MessageBoxToggle; //状态按钮
|
|
public GameObject toggleSelect; //开启状态
|
|
public Text m_OkText;
|
|
|
|
public GameObject TitleBack;
|
|
private OnCancelClick deleCancel; // 取消按钮响应函数托管
|
|
private OnOKClick deleOK; // 确定按钮响应函数托管
|
|
private OnWaitTimeOut delWaitTimeOut; // 等待超时
|
|
private string[] icons = new string[4] {"qian1", "qian2", "qian3", "qian5"};
|
|
private float m_delayTimer;
|
|
private PASSWORD m_ePassword = PASSWORD.INVALID;
|
|
private float m_fCountDown = -1; //倒计时时间 -1代表无倒计时,秒标记
|
|
|
|
private float m_waitTimer;
|
|
private voidNoneDel OnDisableBox;
|
|
|
|
private string[] symbols = new string[4] {"#q1", "#q2", "#q3", "#q5"};
|
|
private float TextHeight = GlobeVar.INVALID_ID;
|
|
private OnToggleChange toggleChange;
|
|
private bool toggleState; //开关状态
|
|
|
|
public PASSWORD EPassword
|
|
{
|
|
get { return m_ePassword; }
|
|
set { m_ePassword = value; }
|
|
}
|
|
|
|
private void Awake()
|
|
{
|
|
SetInstance(this);
|
|
}
|
|
|
|
//void Start()
|
|
//{
|
|
|
|
//}
|
|
|
|
//void OnDestroy()
|
|
//{
|
|
|
|
//}
|
|
|
|
private void Update()
|
|
{
|
|
if (m_delayTimer > 0)
|
|
{
|
|
m_delayTimer -= Time.deltaTime;
|
|
if (m_delayTimer <= 0) ShowBox();
|
|
|
|
return;
|
|
}
|
|
|
|
if (m_waitTimer > 0)
|
|
{
|
|
m_waitTimer -= Time.deltaTime;
|
|
if (m_waitTimer <= 0)
|
|
{
|
|
UIManager.CloseUI(UIInfo.MessageBox);
|
|
if (null != delWaitTimeOut) delWaitTimeOut();
|
|
}
|
|
}
|
|
|
|
if (m_fCountDown > 0)
|
|
{
|
|
m_fCountDown -= Time.deltaTime;
|
|
if (m_fCountDown <= 0)
|
|
{
|
|
UIManager.CloseUI(UIInfo.MessageBox);
|
|
if (null != deleCancel) deleCancel();
|
|
}
|
|
}
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
TitleBack.SetActive(false);
|
|
labelText.alignment = TextAnchor.MiddleCenter;
|
|
m_OkText.text = StrDictionary.GetClientDictionaryString("#{1762}");
|
|
m_CancleText.text = StrDictionary.GetClientDictionaryString("#{1763}");
|
|
_BtnClose.SetActive(false);
|
|
|
|
if (OnDisableBox != null)
|
|
{
|
|
OnDisableBox.Invoke();
|
|
OnDisableBox = null;
|
|
}
|
|
|
|
StopAllCoroutines();
|
|
}
|
|
|
|
public void SetTitle(string title)
|
|
{
|
|
if (string.IsNullOrEmpty(title))
|
|
{
|
|
TitleBack.SetActive(false);
|
|
return;
|
|
}
|
|
|
|
TitleBack.SetActive(true);
|
|
labelTitle.text = title;
|
|
}
|
|
|
|
public void SetOkBtnName(string name)
|
|
{
|
|
if (string.IsNullOrEmpty(name))
|
|
{
|
|
m_OkText.text = StrDictionary.GetClientDictionaryString("#{1762}");
|
|
return;
|
|
}
|
|
|
|
m_OkText.text = name;
|
|
}
|
|
|
|
public void SetCancleBtnName(string name)
|
|
{
|
|
if (string.IsNullOrEmpty(name))
|
|
{
|
|
m_CancleText.text = StrDictionary.GetClientDictionaryString("#{1763}");
|
|
return;
|
|
}
|
|
|
|
m_CancleText.text = name;
|
|
}
|
|
|
|
public void MessageBoxOK()
|
|
{
|
|
UIManager.CloseUI(UIInfo.MessageBox);
|
|
if (null != deleOK) deleOK();
|
|
}
|
|
|
|
public void MessageBoxCancel()
|
|
{
|
|
UIManager.CloseUI(UIInfo.MessageBox);
|
|
if (null != deleCancel) deleCancel();
|
|
}
|
|
|
|
public void MessageBoxToggle()
|
|
{
|
|
toggleState = !toggleState;
|
|
if (null != toggleSelect) toggleSelect.SetActive(!toggleState);
|
|
if (null != toggleChange) toggleChange(toggleState);
|
|
}
|
|
|
|
public void Close()
|
|
{
|
|
CleanData();
|
|
UIManager.CloseUI(UIInfo.MessageBox);
|
|
}
|
|
|
|
private void CleanData()
|
|
{
|
|
deleOK = null;
|
|
deleCancel = null;
|
|
delWaitTimeOut = null;
|
|
_BtnClose.SetActive(false);
|
|
m_waitTimer = 0;
|
|
m_delayTimer = 0;
|
|
m_ePassword = PASSWORD.INVALID;
|
|
ShowBox();
|
|
m_MessageBoxOKButton.interactable = true;
|
|
m_MessageBoxCancelButton.interactable = true;
|
|
m_MessageBoxToggle.gameObject.SetActive(false);
|
|
}
|
|
|
|
// private static Color transColor = new Color(1, 1, 1, 0);
|
|
private void HideBox()
|
|
{
|
|
//sprBackGround.color = transColor;
|
|
m_OkText.gameObject.SetActive(false);
|
|
}
|
|
|
|
private void ShowBox()
|
|
{
|
|
//sprBackGround.color = Color.white;
|
|
m_OkText.gameObject.SetActive(true);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 显示MessageBox
|
|
/// </summary>
|
|
/// <param name="strInfo">提示信息</param>
|
|
/// <param name="eType">MessageBox类型</param>
|
|
/// <param name="funcOKClicked">确定按钮响应函数</param>
|
|
/// <param name="funcCancelClicked">取消按钮响应函数</param>
|
|
public void ShowMessageBox(string title, string text, GameDefine_Globe.MESSAGEBOX_TYPE eType,
|
|
string okBtnName = null)
|
|
{
|
|
labelTitle.text = title;
|
|
SetTextAnalyseSymbol(text);
|
|
|
|
var btnStr = StrDictionary.GetClientDictionaryString("#{1762}");
|
|
m_OkText.text = btnStr;
|
|
|
|
switch (eType)
|
|
{
|
|
case GameDefine_Globe.MESSAGEBOX_TYPE.TYPE_OK:
|
|
{
|
|
m_MessageBoxOKButton.gameObject.SetActive(true);
|
|
m_MessageBoxCancelButton.gameObject.SetActive(false);
|
|
_BtnPanel.SetActive(true);
|
|
}
|
|
break;
|
|
case GameDefine_Globe.MESSAGEBOX_TYPE.TYPE_OKCANCEL:
|
|
case GameDefine_Globe.MESSAGEBOX_TYPE.TYPE_AUTOCANCEL:
|
|
case GameDefine_Globe.MESSAGEBOX_TYPE.TYPE_AUTOCONFIRM:
|
|
{
|
|
m_MessageBoxOKButton.gameObject.SetActive(true);
|
|
m_MessageBoxCancelButton.gameObject.SetActive(true);
|
|
_BtnPanel.SetActive(true);
|
|
}
|
|
break;
|
|
case GameDefine_Globe.MESSAGEBOX_TYPE.TYPE_WAIT:
|
|
{
|
|
m_MessageBoxOKButton.gameObject.SetActive(false);
|
|
m_MessageBoxCancelButton.gameObject.SetActive(false);
|
|
_BtnPanel.SetActive(false);
|
|
}
|
|
break;
|
|
case GameDefine_Globe.MESSAGEBOX_TYPE.TYPE_RECHARGE:
|
|
{
|
|
m_MessageBoxOKButton.gameObject.SetActive(true);
|
|
m_MessageBoxCancelButton.gameObject.SetActive(true);
|
|
|
|
m_OkText.text = okBtnName;
|
|
|
|
_BtnPanel.SetActive(true);
|
|
}
|
|
break;
|
|
}
|
|
|
|
gameObject.SetActive(true);
|
|
}
|
|
|
|
public void SetLabelTextTextAnchor(TextAnchor textAnchor)
|
|
{
|
|
labelText.alignment = textAnchor;
|
|
}
|
|
|
|
public void SetTextAnalyseSymbol(string text)
|
|
{
|
|
labelText.text = text;
|
|
}
|
|
|
|
public static void CloseBox()
|
|
{
|
|
if (null != Instance()) Instance().CleanData();
|
|
UIManager.CloseUI(UIInfo.MessageBox);
|
|
}
|
|
|
|
public static void OpenRechargeBox(string desc, string titleName, string okname, OnOKClick funcOKClicked = null,
|
|
OnCancelClick funcCancelClicked = null, PASSWORD password = PASSWORD.INVALID)
|
|
{
|
|
var info = new RechargeInfo(desc, titleName, okname, funcOKClicked, funcCancelClicked);
|
|
ShowUI(OnOpenRechargeBox, info);
|
|
}
|
|
|
|
private static void OnOpenRechargeBox(bool bSucess, object param)
|
|
{
|
|
if (!bSucess) return;
|
|
if (Instance())
|
|
{
|
|
var curInfo = param as RechargeInfo;
|
|
if (curInfo != null)
|
|
{
|
|
Instance().CleanData();
|
|
Instance().deleOK = curInfo._delOkClick;
|
|
Instance().m_ePassword = curInfo._password;
|
|
Instance().ShowMessageBox(curInfo._title, curInfo._text, GameDefine_Globe.MESSAGEBOX_TYPE.TYPE_RECHARGE,
|
|
curInfo._okBtnName);
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void OpenAutoConfirmBox(string desc, string titleName, float time, OnOKClick funcOKClicked = null,
|
|
OnCancelClick funcCancelClicked = null, PASSWORD password = PASSWORD.INVALID)
|
|
{
|
|
var info = new OKCancelInfo(desc, titleName, funcOKClicked, funcCancelClicked);
|
|
info._autoCancelTime = time;
|
|
ShowUI(OnOpenAutoConfirmBox, info);
|
|
}
|
|
|
|
private static void OnOpenAutoConfirmBox(bool bSucess, object param)
|
|
{
|
|
var curInfo = param as OKCancelInfo;
|
|
if (bSucess && Instance() && curInfo != null)
|
|
{
|
|
Instance().CleanData();
|
|
Instance().deleOK = curInfo._delOkClick;
|
|
Instance().deleCancel = curInfo._delCancelClick;
|
|
Instance().m_ePassword = curInfo._password;
|
|
Instance().ShowMessageBox(curInfo._title, curInfo._text, GameDefine_Globe.MESSAGEBOX_TYPE.TYPE_AUTOCONFIRM);
|
|
if (curInfo._autoCancelTime > 0f)
|
|
Instance().StartCoroutine(Instance().AutoConfirmFlow(curInfo._autoCancelTime));
|
|
}
|
|
}
|
|
|
|
private IEnumerator AutoConfirmFlow(float time)
|
|
{
|
|
var endTime = Time.time + time;
|
|
var buttonText = Instance().m_OkText.text;
|
|
var lastInt = -1;
|
|
while (Time.time < endTime)
|
|
{
|
|
var current = Mathf.CeilToInt(endTime - Time.time);
|
|
if (current != lastInt)
|
|
{
|
|
lastInt = current;
|
|
Instance().m_OkText.text = string.Format("{0}({1})", buttonText, current);
|
|
}
|
|
|
|
yield return null;
|
|
}
|
|
|
|
if (Instance().deleOK != null)
|
|
Instance().deleOK.Invoke();
|
|
UIManager.CloseUI(UIInfo.MessageBox);
|
|
}
|
|
|
|
|
|
public static void OpenAutoCancelBox(string desc, string titleName, float time, OnOKClick funcOKClicked = null,
|
|
OnCancelClick funcCancelClicked = null, PASSWORD password = PASSWORD.INVALID)
|
|
{
|
|
var info = new OKCancelInfo(desc, titleName, funcOKClicked, funcCancelClicked);
|
|
info._autoCancelTime = time;
|
|
|
|
ShowUI(OnOpenAutoCancelBox, info);
|
|
}
|
|
|
|
private static void OnOpenAutoCancelBox(bool bSucess, object param)
|
|
{
|
|
if (!bSucess) return;
|
|
if (Instance())
|
|
{
|
|
var curInfo = param as OKCancelInfo;
|
|
Instance().CleanData();
|
|
Instance().deleOK = curInfo._delOkClick;
|
|
Instance().deleCancel = curInfo._delCancelClick;
|
|
Instance().m_ePassword = curInfo._password;
|
|
Instance().ShowMessageBox(curInfo._title, curInfo._text, GameDefine_Globe.MESSAGEBOX_TYPE.TYPE_AUTOCANCEL);
|
|
if (curInfo._autoCancelTime > 0)
|
|
Instance().StartCoroutine(Instance().AutoCancelOpt(curInfo._autoCancelTime));
|
|
}
|
|
}
|
|
|
|
private IEnumerator AutoCancelOpt(float time)
|
|
{
|
|
while (time > 0)
|
|
{
|
|
--time;
|
|
var btnStr = StrDictionary.GetClientDictionaryString("#{1763}") + "(" +
|
|
StrDictionary.GetClientDictionaryString("#{1794}", time) + ")";
|
|
m_CancleText.text = btnStr;
|
|
yield return new WaitForSeconds(1);
|
|
}
|
|
|
|
//yield return new WaitForSeconds(time);
|
|
//GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{44039}")); //请求超时
|
|
MessageBoxCancel();
|
|
UIManager.CloseUI(UIInfo.MessageBox);
|
|
}
|
|
|
|
|
|
// 只有一个确定按钮
|
|
public static void OpenOKBox(string text, string title = null, OnOKClick funcOKClicked = null,
|
|
PASSWORD password = PASSWORD.INVALID)
|
|
{
|
|
var curInfo = new OKCancelInfo(text, title, funcOKClicked, null, GlobeVar.INVALID_ID, password);
|
|
ShowUI(OnOpenOkBox, curInfo);
|
|
}
|
|
|
|
// 只有一个确定按钮,带自动确认
|
|
public static void OpenAutoOKBox(string text, string title = null, OnOKClick funcOKClicked = null,
|
|
voidNoneDel disableCallBack = null, PASSWORD password = PASSWORD.INVALID, int autoOKBtn = 0)
|
|
{
|
|
var curInfo = new OKCancelInfo(text, title, funcOKClicked, null, GlobeVar.INVALID_ID, password);
|
|
curInfo._autoOkBtn = autoOKBtn;
|
|
curInfo._onDisableCallBack = disableCallBack;
|
|
|
|
ShowUI(OnOpenOkBox, curInfo);
|
|
}
|
|
|
|
private static void OnOpenOkBox(bool bSuccess, object param)
|
|
{
|
|
if (!bSuccess) return;
|
|
if (Instance() != null)
|
|
{
|
|
var curInfo = param as OKCancelInfo;
|
|
Instance().CleanData();
|
|
Instance().deleOK = curInfo._delOkClick;
|
|
Instance().OnDisableBox = curInfo._onDisableCallBack;
|
|
Instance().m_ePassword = curInfo._password;
|
|
Instance().ShowMessageBox(curInfo._title, curInfo._text, GameDefine_Globe.MESSAGEBOX_TYPE.TYPE_OK);
|
|
|
|
if (curInfo._autoOkBtn > 0)
|
|
{
|
|
Instance()._AutoBtn = curInfo._autoOkBtn;
|
|
Instance().StartCoroutine(Instance().UpdateAutoOkBtn());
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void OpenOKCancelToggleBox(string text, OnToggleChange toggleChangeCB, bool toggleDefault = false,
|
|
string OkBtnName = "", string CancleBtnName = "", string title = null, OnOKClick funcOKClicked = null,
|
|
OnCancelClick funcCancelClicked = null, TextAnchor textAnchor = TextAnchor.MiddleCenter,
|
|
int nCountDown = GlobeVar.INVALID_ID,
|
|
PASSWORD password = PASSWORD.INVALID, int okBtnDelay = 0, int autoOKBtn = 0, bool needShock = false,
|
|
bool showCloseBtn = false)
|
|
{
|
|
var curInfo = new OKCancelInfo(text, title, funcOKClicked, funcCancelClicked, nCountDown, password);
|
|
curInfo._okBtnDelay = okBtnDelay;
|
|
curInfo._autoOkBtn = autoOKBtn;
|
|
curInfo._OkBtnName = OkBtnName;
|
|
curInfo._CancleBtnName = CancleBtnName;
|
|
curInfo._textAnchor = textAnchor;
|
|
curInfo._needShock = needShock;
|
|
curInfo._showCloseBtn = showCloseBtn;
|
|
ShowUI((bSuccess, param) =>
|
|
{
|
|
OnOpenOkCancelBox(bSuccess, param);
|
|
if (Instance() != null)
|
|
{
|
|
Instance().m_MessageBoxToggle.gameObject.SetActive(true);
|
|
Instance().toggleChange = toggleChangeCB;
|
|
Instance().toggleState = toggleDefault;
|
|
Instance().toggleSelect.SetActive(!toggleDefault);
|
|
}
|
|
}, curInfo);
|
|
}
|
|
|
|
// 有确定取消按钮
|
|
public static void OpenOKCancelBoxWithBtnName(string text, string title = null, string OkBtnName = "",
|
|
string CancleBtnName = "", OnOKClick funcOKClicked = null, OnCancelClick funcCancelClicked = null,
|
|
TextAnchor textAnchor = TextAnchor.MiddleCenter, int nCountDown = GlobeVar.INVALID_ID,
|
|
PASSWORD password = PASSWORD.INVALID, int okBtnDelay = 0, int autoOKBtn = 0, bool needShock = false,
|
|
bool showCloseBtn = false)
|
|
{
|
|
var curInfo = new OKCancelInfo(text, title, funcOKClicked, funcCancelClicked, nCountDown, password);
|
|
curInfo._okBtnDelay = okBtnDelay;
|
|
curInfo._autoOkBtn = autoOKBtn;
|
|
curInfo._OkBtnName = OkBtnName;
|
|
curInfo._CancleBtnName = CancleBtnName;
|
|
curInfo._textAnchor = textAnchor;
|
|
curInfo._needShock = needShock;
|
|
curInfo._showCloseBtn = showCloseBtn;
|
|
ShowUI(OnOpenOkCancelBox, curInfo);
|
|
}
|
|
|
|
// 有确定取消按钮
|
|
public static void OpenOKCancelBox(string text, string title = null, OnOKClick funcOKClicked = null,
|
|
OnCancelClick funcCancelClicked = null, int nCountDown = GlobeVar.INVALID_ID,
|
|
PASSWORD password = PASSWORD.INVALID, int okBtnDelay = 0, int autoOKBtn = 0, bool NeedShock = false,
|
|
bool showCloseBtn = false, voidNoneDel disableCallBack = null)
|
|
{
|
|
var curInfo = new OKCancelInfo(text, title, funcOKClicked, funcCancelClicked, nCountDown, password)
|
|
{
|
|
_okBtnDelay = okBtnDelay,
|
|
_autoOkBtn = autoOKBtn,
|
|
_showCloseBtn = showCloseBtn,
|
|
_onDisableCallBack = disableCallBack
|
|
};
|
|
ShowUI(OnOpenOkCancelBox, curInfo);
|
|
if (NeedShock || curInfo._needShock)
|
|
SdkControl.instance.ShakeDevice();
|
|
}
|
|
|
|
private static void OnOpenOkCancelBox(bool bSuccess, object param)
|
|
{
|
|
if (!bSuccess) return;
|
|
if (Instance() != null)
|
|
{
|
|
var curInfo = param as OKCancelInfo;
|
|
Instance().CleanData();
|
|
Instance().deleOK = curInfo._delOkClick;
|
|
Instance().deleCancel = curInfo._delCancelClick;
|
|
Instance().OnDisableBox = curInfo._onDisableCallBack;
|
|
Instance().m_fCountDown = curInfo._fCountDown;
|
|
Instance().m_ePassword = curInfo._password;
|
|
Instance().ShowMessageBox(curInfo._title, curInfo._text, GameDefine_Globe.MESSAGEBOX_TYPE.TYPE_OKCANCEL);
|
|
Instance().SetTitle(curInfo._title);
|
|
Instance().SetOkBtnName(curInfo._OkBtnName);
|
|
Instance().SetCancleBtnName(curInfo._CancleBtnName);
|
|
Instance().SetLabelTextTextAnchor(curInfo._textAnchor);
|
|
Instance().ShowCloseBtn(curInfo._showCloseBtn);
|
|
if (curInfo._okBtnDelay > 0)
|
|
{
|
|
Instance()._OkBtnDelay = curInfo._okBtnDelay;
|
|
Instance().StartCoroutine(Instance().UpdateOkBtn());
|
|
}
|
|
|
|
if (curInfo._autoOkBtn > 0)
|
|
{
|
|
Instance()._AutoBtn = curInfo._autoOkBtn;
|
|
Instance().StartCoroutine(Instance().UpdateAutoOkBtn());
|
|
}
|
|
else if (curInfo._autoOkBtn < 0)
|
|
{
|
|
Instance()._AutoBtn = curInfo._autoOkBtn;
|
|
Instance().StartCoroutine(Instance().UpdateAutoCancleBtn());
|
|
}
|
|
}
|
|
}
|
|
|
|
public IEnumerator UpdateOkBtn()
|
|
{
|
|
while (_OkBtnDelay > 0)
|
|
{
|
|
--_OkBtnDelay;
|
|
var btnStr = StrDictionary.GetClientDictionaryString("#{1762}") + "(" + _OkBtnDelay + ")";
|
|
m_OkText.text = btnStr;
|
|
m_MessageBoxOKButton.interactable = false;
|
|
yield return new WaitForSeconds(1);
|
|
}
|
|
|
|
var btnStr1 = StrDictionary.GetClientDictionaryString("#{1762}");
|
|
m_OkText.text = btnStr1;
|
|
m_MessageBoxOKButton.interactable = true;
|
|
}
|
|
|
|
public void ShowCloseBtn(bool state)
|
|
{
|
|
_BtnClose.SetActive(state);
|
|
}
|
|
|
|
public IEnumerator UpdateAutoOkBtn()
|
|
{
|
|
while (_AutoBtn > 0)
|
|
{
|
|
--_AutoBtn;
|
|
var btnStr = StrDictionary.GetClientDictionaryString("#{1762}") + "(" +
|
|
StrDictionary.GetClientDictionaryString("#{1794}", _AutoBtn) + ")";
|
|
m_OkText.text = btnStr;
|
|
yield return new WaitForSeconds(1);
|
|
}
|
|
|
|
MessageBoxOK();
|
|
}
|
|
|
|
public IEnumerator UpdateAutoCancleBtn()
|
|
{
|
|
while (_AutoBtn < 0)
|
|
{
|
|
++_AutoBtn;
|
|
var btnStr = StrDictionary.GetClientDictionaryString("#{1763}") + "(" +
|
|
StrDictionary.GetClientDictionaryString("#{1794}", _AutoBtn * -1) + ")";
|
|
m_CancleText.text = btnStr;
|
|
yield return new WaitForSeconds(1);
|
|
}
|
|
|
|
MessageBoxCancel();
|
|
}
|
|
|
|
// 等待界面
|
|
// duration 等待时间,如果<=0 则无限等待,
|
|
// delay 延时弹出时间,如有延时,则会先以透明底版的形式弹出,延时结束后显示内容
|
|
public static void OpenWaitBox(string text, float duration = 0, float delay = 0,
|
|
OnWaitTimeOut delWaitTimeOutFun = null, PASSWORD password = PASSWORD.INVALID)
|
|
{
|
|
var curInfo = new WaitBoxInfo(text, duration, delay, delWaitTimeOutFun, password);
|
|
ShowUI(OnOpenWaitBox, curInfo);
|
|
}
|
|
|
|
// 再封装一层,便于处理被顶替 MessageBox 事件 OnDisableBox的处理。
|
|
private static void ShowUI(UIManager.OnOpenUIDelegate delOpenUI, object param)
|
|
{
|
|
if (Instance() != null && Instance().gameObject.activeInHierarchy) UIManager.CloseUI(UIInfo.MessageBox);
|
|
|
|
UIManager.ShowUI(UIInfo.MessageBox, delOpenUI, param);
|
|
}
|
|
|
|
private static void OnOpenWaitBox(bool bSuccess, object param)
|
|
{
|
|
if (!bSuccess) return;
|
|
if (Instance() != null)
|
|
{
|
|
var curInfo = param as WaitBoxInfo;
|
|
|
|
Instance().CleanData();
|
|
Instance().delWaitTimeOut = curInfo._delWaitTimeOut;
|
|
Instance().m_waitTimer = curInfo._duration;
|
|
Instance().m_delayTimer = curInfo._delay;
|
|
Instance().m_ePassword = curInfo._password;
|
|
Instance().ShowMessageBox("", curInfo._text, GameDefine_Globe.MESSAGEBOX_TYPE.TYPE_WAIT);
|
|
if (curInfo._delay > 0) Instance().HideBox();
|
|
}
|
|
}
|
|
|
|
//----------------------------------重载便捷函数-------------------------------------------------------/
|
|
public static void OpenOKBox(int textDicID, int titleDicID = -1, OnOKClick funcOKClicked = null,
|
|
PASSWORD password = PASSWORD.INVALID)
|
|
{
|
|
OpenOKBox(Utils.GetDicByID(textDicID), titleDicID == -1 ? "" : Utils.GetDicByID(titleDicID), funcOKClicked,
|
|
password);
|
|
}
|
|
|
|
public static void OpenOKCancelBox(int textDicID, int titleDicID = -1, OnOKClick funcOKClicked = null,
|
|
OnCancelClick funcCancelClicked = null, PASSWORD password = PASSWORD.INVALID, int okBtnDelay = 0,
|
|
int autoOkBtn = 0, bool NeedShock = false)
|
|
{
|
|
var title = "";
|
|
if (titleDicID > 0) title = Utils.GetDicByID(titleDicID);
|
|
OpenOKCancelBox(Utils.GetDicByID(textDicID), title, funcOKClicked, funcCancelClicked, GlobeVar.INVALID_ID,
|
|
password, okBtnDelay, autoOkBtn, NeedShock);
|
|
}
|
|
|
|
public static void OpenWaitBox(int textDicID, float duration = GameDefines.CONNECT_TIMEOUT,
|
|
float delay = GameDefines.CONNECT_WAIT_DELAY, OnWaitTimeOut delWaitTimeOutFun = null,
|
|
PASSWORD password = PASSWORD.INVALID)
|
|
{
|
|
OpenWaitBox(Utils.GetDicByID(textDicID), duration, delay, delWaitTimeOutFun, password);
|
|
}
|
|
|
|
public static void ShowEnterCopySceneEnsureMessageBox(int fubenId, int _PageIndex, int _SubPageIndex = 0,
|
|
bool isTeam = false)
|
|
{
|
|
var fuben = TableManager.GetFubenByID(fubenId);
|
|
if (fuben == null) return;
|
|
|
|
if (GameManager.gameManager.ActiveScene.IsCopyScene())
|
|
{
|
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{2343}"));
|
|
UIManager.CloseUI(UIInfo.MessageBox);
|
|
return;
|
|
}
|
|
|
|
var packet = (CG_REQ_ENTER_COPY) PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_ENTER_COPY);
|
|
packet.SetCopyid(fubenId);
|
|
packet.SetChallengeType(isTeam ? 1 : 0);
|
|
packet.SendPacket();
|
|
|
|
GlobalData.NeedShowCopyBaseUISceneId = fubenId;
|
|
GlobalData.NeedShowCopyBaseSubPageIndex = _PageIndex;
|
|
GlobalData.NeedShowSubPageIndex = _SubPageIndex;
|
|
|
|
//if (CopyScenePanelCtr.Instance)
|
|
//{
|
|
// CopyScenePanelCtr.Instance.OnCloseBtnClick();
|
|
//}
|
|
UIManager.CloseUI(UIInfo.MessageBox);
|
|
}
|
|
|
|
private class RechargeInfo
|
|
{
|
|
public readonly OnOKClick _delOkClick;
|
|
public readonly string _okBtnName;
|
|
|
|
public readonly PASSWORD _password;
|
|
|
|
public readonly string _text;
|
|
public readonly string _title;
|
|
public int _autoOkBtn;
|
|
public OnCancelClick _delCancelClick;
|
|
public float _fCountDown;
|
|
public int _okBtnDelay;
|
|
|
|
public RechargeInfo(string text, string titleName, string okBtnName, OnOKClick funcOKClicked = null,
|
|
OnCancelClick funcCancelClicked = null, float fCountDown = GlobeVar.INVALID_ID,
|
|
PASSWORD password = PASSWORD.INVALID)
|
|
{
|
|
_text = text;
|
|
_title = titleName;
|
|
_okBtnName = okBtnName;
|
|
_delOkClick = funcOKClicked;
|
|
_delCancelClick = funcCancelClicked;
|
|
_fCountDown = fCountDown;
|
|
_password = password;
|
|
}
|
|
}
|
|
|
|
private class OKCancelInfo
|
|
{
|
|
public readonly OnCancelClick _delCancelClick;
|
|
public readonly OnOKClick _delOkClick;
|
|
public readonly float _fCountDown;
|
|
public readonly PASSWORD _password;
|
|
|
|
public readonly string _text;
|
|
public readonly string _title;
|
|
public float _autoCancelTime;
|
|
public int _autoOkBtn;
|
|
public string _CancleBtnName;
|
|
public bool _needShock;
|
|
public int _okBtnDelay;
|
|
|
|
public string _OkBtnName;
|
|
public voidNoneDel _onDisableCallBack;
|
|
public bool _showCloseBtn;
|
|
public TextAnchor _textAnchor = TextAnchor.MiddleCenter;
|
|
|
|
public OKCancelInfo(string text, string title = null, OnOKClick funcOKClicked = null,
|
|
OnCancelClick funcCancelClicked = null, float fCountDown = GlobeVar.INVALID_ID,
|
|
PASSWORD password = PASSWORD.INVALID, voidNoneDel onDisableCallBack = null)
|
|
{
|
|
_text = text;
|
|
_title = title;
|
|
_delOkClick = funcOKClicked;
|
|
_delCancelClick = funcCancelClicked;
|
|
_onDisableCallBack = onDisableCallBack;
|
|
_fCountDown = fCountDown;
|
|
_password = password;
|
|
}
|
|
}
|
|
|
|
private class WaitBoxInfo
|
|
{
|
|
public readonly float _delay;
|
|
public readonly OnWaitTimeOut _delWaitTimeOut;
|
|
public readonly float _duration;
|
|
public readonly PASSWORD _password;
|
|
|
|
public readonly string _text;
|
|
|
|
public WaitBoxInfo(string text, float duration, float delay, OnWaitTimeOut delWaitTimeOutFun, PASSWORD password)
|
|
{
|
|
_text = text;
|
|
_duration = duration;
|
|
_delay = delay;
|
|
_delWaitTimeOut = delWaitTimeOutFun;
|
|
_password = password;
|
|
}
|
|
}
|
|
} |