using System;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace vnxbqy.UI
|
{
|
public class GMInputWin : Window
|
{
|
[SerializeField]
|
private ScrollerController _cmdCtrl;
|
|
[SerializeField]
|
private InputField _inputCmd;
|
|
[SerializeField]
|
private Button _closeBtn;
|
|
[SerializeField]
|
private Button _lookBtn;
|
|
[SerializeField]
|
private Button _sendBtn;
|
|
[SerializeField]
|
private Button m_CrossServerSend;
|
|
[SerializeField]
|
private Button _gmInfoBtn;
|
|
[SerializeField]
|
private Button _clearBtn;
|
|
[SerializeField]
|
private Button achieveJumpTestBtn;
|
|
[SerializeField]
|
private GameObject _cmdContent;
|
|
private List<string> recordCmdlist;
|
|
GMCmdModel _cmdModel;
|
GMCmdModel cmdModel
|
{
|
get
|
{
|
return _cmdModel ?? (_cmdModel = ModelCenter.Instance.GetModel<GMCmdModel>());
|
}
|
}
|
|
protected override void BindController()
|
{
|
_cmdCtrl.OnRefreshCell += RefreshCmdCell;
|
}
|
|
protected override void AddListeners()
|
{
|
_closeBtn.onClick.AddListener(OnClickCloseBtn);
|
_lookBtn.onClick.AddListener(OnClickLookBtn);
|
_sendBtn.onClick.AddListener(()=> { OnClickSendBtn(); });
|
_gmInfoBtn.onClick.AddListener(OnClickGMInfoBtn);
|
_clearBtn.onClick.AddListener(OnClickClearBtn);
|
achieveJumpTestBtn.AddListener(ClickAchieveJumpBtn);
|
m_CrossServerSend.SetListener(SendCrossServerGM);
|
}
|
|
protected override void OnPreOpen()
|
{
|
_cmdContent.SetActive(false);
|
}
|
protected override void OnAfterOpen()
|
{
|
this.transform.SetAsLastSibling();
|
}
|
|
protected override void OnPreClose()
|
{
|
|
}
|
|
protected override void OnAfterClose()
|
{
|
|
}
|
|
protected override void LateUpdate()
|
{
|
base.LateUpdate();
|
|
if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.KeypadEnter))
|
{
|
OnClickSendBtn();
|
}
|
}
|
|
private void CreateCmdCell()
|
{
|
_cmdCtrl.Refresh();
|
int i = 0;
|
for(i = recordCmdlist.Count-1; i > -1; i--)
|
{
|
_cmdCtrl.AddCell(ScrollerDataType.Header,i);
|
}
|
_cmdCtrl.Restart();
|
}
|
|
private void RefreshCmdCell(ScrollerDataType type, CellView cell)
|
{
|
Button cellBtn = cell.GetComponent<Button>();
|
Text cmdText = cell.transform.Find("Text").GetComponent<Text>();
|
string cmdStr = recordCmdlist[cell.index];
|
cmdText.text = cmdStr;
|
cellBtn.onClick.RemoveAllListeners();
|
cellBtn.onClick.AddListener(() => {
|
OnClickCmdCell(cmdStr);
|
});
|
}
|
|
private void OnClickCmdCell(string paramSet)
|
{
|
_inputCmd.text = paramSet;
|
}
|
|
private void OnClickGMInfoBtn()
|
{
|
ServerTipDetails.OpenGMPanel();
|
}
|
|
private void OnClickLookBtn()
|
{
|
if (_cmdContent.gameObject.activeInHierarchy)
|
{
|
_cmdContent.SetActive(false);
|
}
|
else
|
{
|
_cmdContent.SetActive(true);
|
recordCmdlist = cmdModel.GetRecordCmdlist();
|
CreateCmdCell();
|
}
|
}
|
|
private void OnClickSendBtn()
|
{
|
if (_inputCmd.text == null || _inputCmd.text == "" || _inputCmd.text == string.Empty)
|
return;
|
|
if(_inputCmd.text == "HappyXB")
|
{
|
WindowCenter.Instance.Open<HappyXBWin>();
|
return;
|
}
|
else if(_inputCmd.text == "TreasureFindHost")
|
{
|
WindowCenter.Instance.Open<TreasureFindHostWin>();
|
return;
|
}
|
if (_inputCmd.text.Equals("EnterFB 31250"))
|
{
|
cmdModel.OnSendGMQuest("SetFBStar 31250");
|
ClientGuardDungeon.RequestEnter();
|
return;
|
}
|
|
cmdModel.OnSendGMQuest(_inputCmd.text.Trim());
|
cmdModel.SetRecordCmdlist(_inputCmd.text);
|
}
|
|
private void SendCrossServerGM()
|
{
|
if (_inputCmd.text == null || _inputCmd.text == "" || _inputCmd.text == string.Empty)
|
return;
|
|
if (_inputCmd.text == "HappyXB")
|
{
|
WindowCenter.Instance.Open<HappyXBWin>();
|
return;
|
}
|
else if (_inputCmd.text == "TreasureFindHost")
|
{
|
WindowCenter.Instance.Open<TreasureFindHostWin>();
|
return;
|
}
|
|
cmdModel.SendCrossServerGMQuest(_inputCmd.text.Trim());
|
cmdModel.SetRecordCmdlist(_inputCmd.text);
|
}
|
|
|
private void OnClickClearBtn()
|
{
|
cmdModel.ClearRecordCmdlist();
|
OnClickLookBtn();
|
}
|
|
private void OnClickCloseBtn()
|
{
|
CloseImmediately();
|
}
|
|
private void ClickAchieveJumpBtn()
|
{
|
try
|
{
|
int achieveId = int.Parse(_inputCmd.text);
|
ModelCenter.Instance.GetModel<AchievementModel>().GotoCompleteAchievement(achieveId);
|
}
|
catch (Exception ex)
|
{
|
}
|
}
|
|
}
|
}
|