private PanelInfo FindPanelInfoByID(int uiID) { PanelInfo panelInfo = null; if (m_ActivePanelInfoMap.TryGetValue(uiID, out panelInfo)) { return(panelInfo); } return(null); }
private PanelInfo GetPanelFromActive(int uiID) { for (int i = m_ActivePanelInfoList.Count - 1; i >= 0; --i) { if (m_ActivePanelInfoList[i].uiID == uiID) { PanelInfo panel = m_ActivePanelInfoList[i]; return(panel); } } return(null); }
private PanelInfo GetPanelFromCache(int uiID, bool remove) { for (int i = m_CachedPanelList.Count - 1; i >= 0; --i) { if (m_CachedPanelList[i].uiID == uiID) { PanelInfo panel = m_CachedPanelList[i]; if (remove) { m_CachedPanelList.RemoveAt(i); } return(panel); } } return(null); }
private void AddPanelInfo(PanelInfo panelInfo) { if (panelInfo == null) { return; } if (m_ActivePanelInfoMap.ContainsKey(panelInfo.panelID)) { Log.e("Already Add Panel to UIMgr"); return; } m_ActivePanelInfoList.Add(panelInfo); m_ActivePanelInfoMap.Add(panelInfo.panelID, panelInfo); m_IsPanelInfoListChange = true; }
private void RemovePanelInfo(PanelInfo panelInfo) { if (panelInfo == null) { return; } if (!m_ActivePanelInfoMap.ContainsKey(panelInfo.panelID)) { Log.e("Already Remove Panel:" + panelInfo.uiID); return; } m_ActivePanelInfoMap.Remove(panelInfo.panelID); m_ActivePanelInfoList.Remove(panelInfo); m_IsPanelInfoListChange = true; }
// public void HidePanel<T>(T uiID) where T : System.IConvertible // { // PanelInfo panelInfo = LoadPanelInfo(uiID.ToInt32(null)); // if (panelInfo == null) // { // return; // } // panelInfo.SetActive(false); // panelInfo.HidePanel(); // } #endregion public bool ToggleShowPanel <T>(T uiID) where T : System.IConvertible { PanelInfo panelInfo = LoadPanelInfo(uiID.ToInt32(null)); if (panelInfo == null) { return(false); } if (panelInfo.isOpen) { ClosePanel(panelInfo.abstractPanel); return(false); } else { OpenPanel(uiID, PanelSortType.Auto, null); return(true); } }
public void HidePanel(AbstractPanel panel) { if (panel == null) { return; } PanelInfo panelInfo = FindPanelInfoByID(panel.panelID); if (panelInfo == null) { panelInfo = GetPanelFromCache(panel.panelID, false); if (panelInfo == null) { Log.e("Not Find PanelInfo For Panel" + panel.name); // panel.OnPanelClose(true); panel.gameObject.SetActive(false); } return; } }
private PanelInfo LoadPanelInfo(int uiID) { UIData data = UIDataTable.Get(uiID); if (data == null) { Log.e("#Not Find UIData for UIID:" + uiID); return(null); } bool needAdd = true; PanelInfo panelInfo = GetPanelFromCache(uiID, true); if (panelInfo == null)//没有缓存 { if (data.isSingleton) { panelInfo = GetPanelFromActive(uiID); } if (panelInfo == null) { panelInfo = ObjectPool <PanelInfo> .S.Allocate(); panelInfo.Init(uiID, nextPanelID); } else { needAdd = false; } } if (needAdd) { AddPanelInfo(panelInfo); } return(panelInfo); }
private void ClosePanelInfo(PanelInfo panelInfo) { if (panelInfo == null) { return; } UIData data = UIDataTable.Get(panelInfo.uiID); bool destory = true; if (data != null && data.cacheCount > 0) { if (GetActiveAndCachedUICount(panelInfo.uiID) <= data.cacheCount) { destory = false; } } RemovePanelInfo(panelInfo); //恢复层级记录 m_UIRoot.ReleasePanelSortingOrder(panelInfo.sortingOrder); if (destory) { panelInfo.ClosePanel(true); } else { m_CachedPanelList.Add(panelInfo); panelInfo.ClosePanel(false); } if (destory) { ObjectPool <PanelInfo> .S.Recycle(panelInfo); } }
public void ClosePanel(AbstractPanel panel) { if (panel == null) { return; } PanelInfo panelInfo = FindPanelInfoByID(panel.panelID); if (panelInfo == null) { panelInfo = GetPanelFromCache(panel.panelID, false); if (panelInfo == null) { Log.e("Not Find PanelInfo For Panel" + panel.name); panel.OnPanelClose(true); GameObject.Destroy(panel.gameObject); } return; } ClosePanelInfo(panelInfo); }
public void OpenPanel <T>(T uiID, PanelSortType type, System.Action <AbstractPanel> callback, params object[] args) where T : System.IConvertible { PanelInfo panelInfo = LoadPanelInfo(uiID.ToInt32(null)); if (panelInfo == null) { return; } panelInfo.sortingOrder = m_UIRoot.RequireNextPanelSortingOrder(type); panelInfo.AddOpenCallback(callback); if (panelInfo.isReady) { // Debug.LogError("panel is Ready"); } else { panelInfo.LoadPanelRes(); } panelInfo.SetActive(true); panelInfo.OpenPanel(); }
private int PanelCompare(PanelInfo a, PanelInfo b) { return(a.sortingOrder - b.sortingOrder); }