using System.Collections.Generic; using Game.Common; namespace Game { public class PageGmPanel : UIPageBase { private Dictionary> _mGmDict; public PageGmPanel() { _mGmDict = new Dictionary>(); } protected override void OnCreate() { CreateUI(true); View.m_ConsoleInput.onClick.Clear(); View.m_ConsoleInput.onClick.Add(() => { View.m_ConsoleInput.RequestFocus(); }); } protected override void OnDestroy() { } protected override void OnOpen() { View.m_LayerList.RemoveChildrenToPool(); _mGmDict.Clear(); var gmList = GmManager.Instance.MGmList; foreach (var gmInfo in gmList) { var layerName = gmInfo.MLayer.ToString(); if (!_mGmDict.ContainsKey(layerName)) { _mGmDict[layerName] = new List(); var item = View.m_LayerList.AddItemFromPool().asButton; item.title = layerName; item.onClick.Clear(); item.onClick.Add(() => { RefreshSubPanel(item.title); }); } _mGmDict[layerName].Add(gmInfo); } RefreshSubPanel("_first"); } protected override void OnClose() { } public override void Update() { } public void RefreshSubPanel(string layerName) { View.m_GmList.RemoveChildrenToPool(); if (layerName == "_first") { if (_mGmDict.Count == 0) { return; } else { var e = _mGmDict.Keys.GetEnumerator(); e.MoveNext(); layerName = e.Current; } } var gmList = _mGmDict[layerName]; foreach (var gmInfo in gmList) { var item = View.m_GmList.AddItemFromPool().asButton; item.title = gmInfo.MName; item.onClick.Clear(); item.onClick.Add(() => { gmInfo.MCallback(StringHelper.ParseToParam(View.m_ConsoleInput.text)); }); } } protected override void OnInput(PPlayerInput context) { if (context.Action == EKeyActionType.Press) { if (context.Key == EFunctionKey.Menu) { UIManager.Instance.Close(); } } } } }