1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
public class GMInputWin : UIBase
{
    [SerializeField]
    private ScrollerController _cmdCtrl;
 
    [SerializeField]
    private InputField _inputCmd;
 
    [SerializeField]
    private Button _closeBtn;
 
    [SerializeField]
    private Button _lookBtn;
 
    [SerializeField]
    private Button _sendBtn;
 
 
    [SerializeField]
    private Button _gmInfoBtn;
 
    [SerializeField]
    private Button _clearBtn;
 
    [SerializeField]
    private Button achieveJumpTestBtn;
 
    [SerializeField]
    private GameObject _cmdContent;
 
    private List<string> recordCmdlist;
 
    GMCmdManager cmdModel { get { return GMCmdManager.Instance; } }
       
 
    protected override void OnPreOpen()
    {
        base.OnPreOpen();
        _cmdCtrl.OnRefreshCell += RefreshCmdCell;
        _closeBtn.onClick.AddListener(OnClickCloseBtn);
        _lookBtn.onClick.AddListener(OnClickLookBtn);
        _sendBtn.onClick.AddListener(() => { OnClickSendBtn(); });
        _gmInfoBtn.onClick.AddListener(OnClickGMInfoBtn);
        _clearBtn.onClick.AddListener(OnClickClearBtn);
        achieveJumpTestBtn.AddListener(ClickAchieveJumpBtn);
        _cmdContent.SetActive(false);
    }
 
    protected override void OnOpen()
    {
        base.HandleOpen();
        this.transform.SetAsLastSibling();
    }
    protected void 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 OnClickClearBtn()
    {
        cmdModel.ClearRecordCmdlist();
        OnClickLookBtn();
    }
 
    private void OnClickCloseBtn()
    {
        CloseWindow();
    }
 
    private void ClickAchieveJumpBtn()
    {
        // try
        // {
        //     int achieveId = int.Parse(_inputCmd.text);
        //     ModelCenter.Instance.GetModel<AchievementModel>().GotoCompleteAchievement(achieveId);
        // }
        // catch (Exception ex)
        // {
        // }
    }
 
}