| using System; | 
| using System.Collections.Generic; | 
| using UnityEngine; | 
| using UnityEngine.UI; | 
|   | 
| using UnityEngine.Events; | 
|   | 
| public class GMCmdPanel : UIBase | 
| { | 
|   | 
|     [SerializeField] | 
|     private ScrollerController _cmdCtrl; | 
|   | 
|     [SerializeField] | 
|     private Button _closeBtn; | 
|   | 
|     GMCmdManager _cmdModel; | 
|     GMCmdManager cmdModel{ get { return GMCmdManager.Instance; } } | 
|   | 
|     protected override void InitComponent() | 
|     {  | 
|         _closeBtn.AddListener(OnClickCloseBtn); | 
|     } | 
|     protected override void OnPreOpen() | 
|     { | 
|         base.OnPreOpen(); | 
|         _cmdCtrl.OnRefreshCell += RefreshCmdCell; | 
|   | 
|   | 
|         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) | 
|     { | 
|   | 
|         string[] longCmdArray = value.Split('|'); | 
|         for (int i = 0; i < longCmdArray.Length; i++) | 
|         { | 
|             cmdModel.OnSendGMQuest(longCmdArray[i].Trim()); | 
|         } | 
|   | 
|   | 
|     } | 
|   | 
|     public void OnClickCloseBtn() | 
|     { | 
|         CloseWindow(); | 
|     } | 
|   | 
| } |