//指定页面是否为最上层页面(时间上的后打开页面,而不是视觉上的前后层) public bool IsTopView(ETopView view) { if (topViewList.Count > 0) { return(view == topViewList[topViewList.Count - 1]); } return(false); }
//页面入栈 public void AddTopView(ETopView view) { if (this.silenceViewList.ContainsKey(view)) {//静默页面状态置为打开 this.silenceViewList[view] = true; } else if (!topViewList.Contains(view)) {//记录普通页面 topViewList.Add(view); this.OnViewChanged(ADD_VIEW, view); } GuLog.Info(this.ToString()); }
//页面出栈 public void RemoveView(ETopView view) { if (this.silenceViewList.ContainsKey(view)) {//静默页面状态置为关闭 this.silenceViewList[view] = false; } else if (topViewList.Count > 0 && this.TopView != ETopView.eMainView && topViewList.Contains(view)) {//移除普通页面 topViewList.Remove(view); this.OnViewChanged(REMOVE_VIEW, this.TopView); } GuLog.Info(this.ToString()); }
//是否有指定页以上层级的模块页面打开(层级是指ETopView枚举中的位置) public bool HasSilenceViewOpened(ETopView silenceView) { if (this.topViewList != null) { if (this.silenceViewList.ContainsKey(silenceView) && this.silenceViewList[silenceView]) { //Debug.LogFormat("<><TopViewHelper.HasModulePageOpened>SilenceView: {0}, {1}", silenceView, this.silenceViewList[silenceView]); return(true); } else { return(false); } } else { return(false); } }
//是否有指定页以上层级的模块页面打开(层级是指ETopView枚举中的位置) public bool HasModulePageOpened(ETopView obstructViewLevel) { if (this.topViewList != null) { int index = this.topViewList.FindIndex(t => (int)t > (int)obstructViewLevel); if (index >= 0) { //Debug.LogFormat("<><TopViewHelper.HasModulePageOpened>ModulePage: {0}, {1}", index, this.topViewList[index]); return(true); } else { return(false); } } else { return(false); } }
//当页面栈变化时 private void OnViewChanged(string operate, ETopView topView) { Debug.LogFormat("<><TopViewHelper.OnViewChanged>operate: {0}, topView: {1}", operate, topView); this.topViewChangedSignal.Dispatch(operate, this.TopView); }
//指定页面是否已打开 public bool IsOpenedView(ETopView view) { //普通页面在列表中,或者静默页面为打开状态,则视为已打开 return((this.topViewList != null && this.topViewList.Contains(view)) || (this.silenceViewList != null && this.silenceViewList.ContainsKey(view) && this.silenceViewList[view])); }