203 lines
5.1 KiB
C#
203 lines
5.1 KiB
C#
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using System.Collections;
|
|
using Games.GlobeDefine;
|
|
using GCGame.Table;
|
|
using GCGame;
|
|
using System;
|
|
|
|
public class MessageSelectLogic : UIControllerBase<MessageSelectLogic>
|
|
{
|
|
#region static
|
|
|
|
public static void ShowMessageSelect(string title1, string title2, string question, string[] selects, MessageSelect okCallBack, Action cancelCallBack)
|
|
{
|
|
Hashtable hash = new Hashtable();
|
|
hash.Add("Title", title1);
|
|
hash.Add("Title2", title2);
|
|
hash.Add("Question", question);
|
|
hash.Add("Selects", selects);
|
|
hash.Add("OKCallBack", okCallBack);
|
|
hash.Add("CancelCallBack", cancelCallBack);
|
|
UIManager.ShowUI(UIInfo.MessageSelect, OnMessageSelectShow, hash);
|
|
}
|
|
|
|
static void OnMessageSelectShow(bool bSuccess, object param)
|
|
{
|
|
Hashtable hash = param as Hashtable;
|
|
if (!bSuccess)
|
|
{
|
|
return;
|
|
}
|
|
if (hash == null)
|
|
{
|
|
return;
|
|
}
|
|
if (MessageSelectLogic.Instance() != null)
|
|
{
|
|
MessageSelectLogic.Instance().Show((string)hash["Title"], (string)hash["Title2"], (string)hash["Question"], (string[])hash["Selects"], (MessageSelect)hash["OKCallBack"], (Action)hash["CancelCallBack"]);
|
|
}
|
|
}
|
|
|
|
public static void ShowMessageResult(string title1, string title2, string tips, string[] selects, MessageResult okCallBack, Action cancelCallBack)
|
|
{
|
|
Hashtable hash = new Hashtable();
|
|
hash.Add("Title", title1);
|
|
hash.Add("Title2", title2);
|
|
hash.Add("Tips", tips);
|
|
hash.Add("Selects", selects);
|
|
hash.Add("OKCallBack", okCallBack);
|
|
hash.Add("CancelCallBack", cancelCallBack);
|
|
UIManager.ShowUI(UIInfo.MessageSelect, OnMessageResultShow, hash);
|
|
}
|
|
|
|
static void OnMessageResultShow(bool bSuccess, object param)
|
|
{
|
|
Hashtable hash = param as Hashtable;
|
|
if (!bSuccess)
|
|
{
|
|
return;
|
|
}
|
|
if (hash == null)
|
|
{
|
|
return;
|
|
}
|
|
if (MessageSelectLogic.Instance() != null)
|
|
{
|
|
MessageSelectLogic.Instance().ShowResult((string)hash["Title"], (string)hash["Title2"], (string)hash["Tips"], (string[])hash["Selects"], (MessageResult)hash["OKCallBack"]);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region question select
|
|
|
|
public GameObject _SelectPanel;
|
|
public GameObject _ResultPanel;
|
|
|
|
public Text _Title;
|
|
public Text _Title2;
|
|
public Text _QuestionTx;
|
|
public Text[] _SelectTexts;
|
|
public GameObject[] _SelectObjs;
|
|
|
|
public delegate void MessageSelect(int resultIdx);
|
|
private MessageSelect _MessageSelect;
|
|
private Action _MessageCancel;
|
|
|
|
void OnEnable()
|
|
{
|
|
SetInstance(this);
|
|
}
|
|
|
|
void OnDisable()
|
|
{
|
|
SetInstance(null);
|
|
}
|
|
|
|
public void Show(string title1, string title2, string question, string[] selects, MessageSelect okCallBack, Action cancelCallBack)
|
|
{
|
|
_SelectPanel.SetActive(true);
|
|
_ResultPanel.SetActive(false);
|
|
|
|
_Title.text = title1;
|
|
_Title2.text = title2;
|
|
_QuestionTx.text = question;
|
|
|
|
for (int i = 0; i < _SelectObjs.Length; ++i)
|
|
{
|
|
if (i < selects.Length)
|
|
{
|
|
_SelectObjs[i].SetActive(true);
|
|
_SelectTexts[i].text = selects[i];
|
|
}
|
|
else
|
|
{
|
|
_SelectObjs[i].SetActive(false);
|
|
}
|
|
}
|
|
|
|
_MessageSelect = okCallBack;
|
|
_MessageCancel = cancelCallBack;
|
|
}
|
|
|
|
public void OnMessageSelect(int selectIdx)
|
|
{
|
|
UIManager.CloseUI(UIInfo.MessageInput);
|
|
if (null != _MessageSelect)
|
|
{
|
|
_MessageSelect(selectIdx);
|
|
}
|
|
}
|
|
|
|
public void MessageBoxCancel()
|
|
{
|
|
UIManager.CloseUI(UIInfo.MessageSelect);
|
|
|
|
if (_MessageCancel != null)
|
|
{
|
|
_MessageCancel();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region
|
|
|
|
public Text _ResultTips;
|
|
public Text[] _ResultTxs;
|
|
|
|
public delegate void MessageResult(bool isOk);
|
|
private MessageResult _MessageResult;
|
|
|
|
public void ShowResult(string title1, string title2, string tips, string[] selectResults, MessageResult okCallBack)
|
|
{
|
|
_SelectPanel.SetActive(false);
|
|
_ResultPanel.SetActive(true);
|
|
|
|
_Title.text = title1;
|
|
_Title2.text = title2;
|
|
_ResultTips.text = tips;
|
|
|
|
for (int i = 0; i < _ResultTxs.Length; ++i)
|
|
{
|
|
if (i < selectResults.Length)
|
|
{
|
|
_ResultTxs[i].text = selectResults[i];
|
|
}
|
|
else
|
|
{
|
|
_ResultTxs[i].text = "";
|
|
}
|
|
}
|
|
|
|
_MessageResult = okCallBack;
|
|
}
|
|
|
|
public void OnBtnOk()
|
|
{
|
|
UIManager.CloseUI(UIInfo.MessageSelect);
|
|
if (null != _MessageResult)
|
|
{
|
|
_MessageResult(true);
|
|
}
|
|
}
|
|
|
|
public void OnBtnCancle()
|
|
{
|
|
UIManager.CloseUI(UIInfo.MessageSelect);
|
|
if (null != _MessageResult)
|
|
{
|
|
_MessageResult(false);
|
|
}
|
|
|
|
if (_MessageCancel != null)
|
|
{
|
|
_MessageCancel();
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|