/// <summary> /// 根据不同layer,进行入栈,当栈中已经有这个界面,不入栈,isPushBack属性,用于控制是否需要栈管理,例如,GrayScreen不需要栈管理, /// </summary> /// <param name="name"></param> public static void PushBack(string name) { if (string.IsNullOrEmpty(name) == true) { return; } string panelLayer = GetPanelLayer(name); UIStack <string> stack = GetStackByPanelLayer(panelLayer); if (stack == null) { return; } if (stack.Have(name)) { return; } else if (stack.Have(GetValid(name, true))) { UIStackBringTop(name); return; } UIResInfoAsset resInfo = GetUIResInfoAsset(name); stack.DisplayList(); OnPushBack(resInfo, stack); stack.DisplayList(); }
/// <summary> /// 出栈需要返回界面(栈顶),显示界面, /// </summary> /// <param name="wnd"></param> public static void BackPopup(string name) { UI3WndType type = GetWndType(name); if (UI3WndType.ReturnFullScreen != type) { return; } UIStack <string> stack = GetStackByWndName(name); string lastName = Peek(stack); lastName = GetValid(lastName, false); stack.DisplayList(); if (string.IsNullOrEmpty(lastName) == true) { return; } UI3Wnd wnd = createWindow(lastName); if (wnd == null) { return; } int index = stack.FindLastByName(GetValid(lastName, true)); stack.PopAt(index); wnd.show(); stack.DisplayList(); }
/// <summary> /// 入栈完成之后操作, /// 需要注意,这些步骤不能修改,修改的话,会有问题, /// 步骤1,打开ReturnFullScreen界面时候,需要先复制栈顶界面在入栈本界面, /// 步骤2,打开全屏界面时候需要隐藏之前接口,同时隐藏PopUp layer之前所有界面, /// 步骤3,打开DonotReturnFullScreen界面时候,清空栈, /// 步骤4,入栈该界面,这个时候只有一个界面, /// </summary> /// <param name="wnd"></param> public static void OnPushBack(UIResInfoAsset resInfoAsset, UIStack <string> stack = null) { stack = stack == null?GetStackByPanelLayer(resInfoAsset.layerType.ToString()) : stack; if (stack == null) { return; } stack.DisplayList(); UI3WndType wndType = (UI3WndType)resInfoAsset.wndType; //步骤1,打开ReturnFullScreen界面时候,需要先复制栈顶界面在入栈本界面, if (wndType == UI3WndType.ReturnFullScreen) { string lastT = stack.Peek(); lastT = GetValid(lastT, true); if (stack.Have(lastT) == false) { stack.PushBack(lastT); } } //步骤2,打开全屏界面时候需要隐藏之前接口,同时隐藏PopUp layer之前所有界面, if (wndType == UI3WndType.ReturnFullScreen || wndType == UI3WndType.DonotReturnFullScreen) { HideStackWindows(resInfoAsset.layerType, resInfoAsset.name); } //步骤3,打开DonotReturnFullScreen界面时候,清空栈, if (wndType == UI3WndType.DonotReturnFullScreen) { //当前layer栈clear, stack.Clear(); } //步骤4,入栈该界面,这个时候只有一个界面, if (GetIsPushStack(resInfoAsset.name) == true) { stack.PushBack(resInfoAsset.name); } }
/// <summary> /// 根据不同layer,出栈,在获取上一个bringTop界面,在进行bringTop操作, /// 该方法只适用于ReturnFullScreen界面, /// </summary> /// <param name="name"></param> public static void PopBack(string name) { if (IsVaild(name, false) == false) { return; } string panelLayer = GetPanelLayer(name); UIStack <string> stack = GetStackByPanelLayer(panelLayer); if (stack == null) { return; } stack.DisplayList(); int index = stack.FindFirstByName(name); if (index < 0) { return; } //if(CanPopBack(name,index,stack) == false) // return; bool isTop = stack.IsTop(name); bool isPopup = true; UI3Wnd wnd = findWindow(name); if (wnd != null) { isPopup = wnd.isHideOnFullScreen; } if (isPopup == false) { return; } stack.PopAt(index); }
/// <summary> /// bringTop当前栈界面, /// </summary> /// <param name="name"></param> public static void UIStackBringTop(string name, bool isClearStack = false) { string panelLayer = GetPanelLayer(name); UIStack <string> stack = GetStackByPanelLayer(panelLayer); if (stack == null) { return; } stack.DisplayList(); string pushName = GetValid(name, true); if (stack.Have(name) == false && stack.Have(pushName) == false) { return; } if (stack.IsTop(name) == true) { return; } /**** * * UI3WndType wndType = UI3WndType.None; * UI3WndType nextWndType = UI3WndType.None; * //UI3WndType lastWndType = UI3WndType.None; * int nextIndex = -1; * wndType = GetWndType(name); * int index = stack.FindFirstByName(name); * if (index < 0) * return; * string nextName = stack.FindDifferenct(index,name,out nextIndex); * if(string.IsNullOrEmpty(nextName) == false) * { * nextWndType = GetWndType(nextName); * int lastIndex = -1; * string lastName = stack.FindDifferenct(index,name,out lastIndex,false); * if (nextWndType == UI3WndType.ReturnFullScreen) * { * if (lastIndex < 0) * { * stack.PopAt(nextIndex - 1); * } * else * { * stack.SetAt(nextIndex - 1,lastName); * } * } * } * stack.PopAt(index); * if (wndType == UI3WndType.ReturnFullScreen) * { * stack.PopAt(index - 1); * } ** ****/ //当前界面存在,当前复制界面存在, if (stack.Have(name) && stack.Have(pushName)) { int index = stack.FindFirstByName(name); string lastName = stack.Peek(index - 1); //上一个界面不为空,上一个界面没有被复制,需要被复制, if (string.IsNullOrEmpty(lastName) == false && IsVaild(lastName, true) == false) { stack.SetAt(index, GetValid(lastName, true)); } } //只是当前界面存在,同时,上一个元素是当前界面的复制界面,所以需要清除复制界面, else if (stack.Have(name)) { int index = stack.FindFirstByName(name); string lastName = stack.Peek(index - 1); if (string.IsNullOrEmpty(lastName) == false && IsVaild(lastName, true) == true) { stack.PopAt(lastName); } } //只是当前界面复制界面存在,需要判断上一个界面是否被复制,没有复制就复制上一个界面, else { int index = stack.FindFirstByName(pushName); string lastName = stack.Peek(index - 1); if (string.IsNullOrEmpty(lastName) == false && IsVaild(lastName, true) == false) { stack.SetAt(index, GetValid(lastName, true)); } } //出栈当前界面原界面和复制界面, stack.PopAt(name); stack.PopAt(pushName); PushBack(name); stack.DisplayList(); }