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
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
using UnityEngine.Events;
 
namespace vnxbqy.UI
{
    public class GMCmdPanel : UIBase
    {
 
        [SerializeField]
        private ScrollerController _cmdCtrl;
 
        [SerializeField]
        private Button _closeBtn;
 
        GMCmdModel _cmdModel;
        GMCmdModel cmdModel{ get { return GMCmdModel.Instance; } }
 
        protected override void OnPreOpen()
        {
            base.OnPreOpen();
            _cmdCtrl.OnRefreshCell += RefreshCmdCell;
 
            _closeBtn.onClick.AddListener(OnClickCloseBtn);
         
          CreateCmdCell();
        }
 
        protected override void OnOpen()
        {
            base.OnOpen();
            this.transform.SetAsLastSibling();
        }
 
 
        private void CreateCmdCell()
        {
            _cmdCtrl.Refresh();
            var allKeys = GmCmdConfig.dic.Keys;
            foreach (var key in allKeys)
            {
                _cmdCtrl.AddCell(ScrollerDataType.Header, key);
            }
            _cmdCtrl.Restart();
        }
 
        private void RefreshCmdCell(ScrollerDataType type, CellView cell)
        {
            Button cellBtn = cell.GetComponent<Button>();
            Text cmdText = cell.transform.Find("Text").GetComponent<Text>();
            GmCmdConfig gmCmdModel = GmCmdConfig.Get(cell.index);
            if (gmCmdModel == null)
                return;
 
            cmdText.text = gmCmdModel.Cmd + "=" + gmCmdModel.ParamSet;
            cellBtn.onClick.RemoveAllListeners();
            cellBtn.onClick.AddListener(() => { OnClickCmdCell(gmCmdModel.ParamSet); });
        }
 
        private void OnClickCmdCell(string paramSet)
        {
            SplitLongGMCmd(paramSet);
        }
 
        public void SplitLongGMCmd(string value)
        {
            if (value == "RoleDead" && CrossServerUtility.IsCrossServer())
            {
                string[] longCmdArray = value.Split('|');
                for (int i = 0; i < longCmdArray.Length; i++)
                {
                    cmdModel.SendCrossServerGMQuest(longCmdArray[i].Trim());
                }
            }
            else
            {
                string[] longCmdArray = value.Split('|');
                for (int i = 0; i < longCmdArray.Length; i++)
                {
                    cmdModel.OnSendGMQuest(longCmdArray[i].Trim());
                }
            }
 
        }
 
        public void OnClickCloseBtn()
        {
            CloseWindow();
        }
 
    }
}