/// <summary> /// 获取上一个bringTop界面 /// </summary> /// <param name="stack"></param> /// <returns></returns> public static string Peek(UIStack <string> stack) { //string lastStr = ""; //List<string> list = stack.List; //if(list != null || list.Count > 0) //{ // for(int i = list.Count - 1; i >= 0;i--) // { // UI3Wnd curWnd = findWindow(list[i]); // if(curWnd != null && curWnd.isBringTop == true) // return lastStr = curWnd.GetClassName(); // } //} return(stack.Peek()); }
/// <summary> /// 出栈指定元素,不会返回之前的元素, /// </summary> public static bool CanPopBack(string name, int index, UIStack <string> stack) { if (index < 0 || stack == null) { return(false); } string nextName = stack.Peek(index + 1); if (string.IsNullOrEmpty(nextName) == true) { return(true); } UI3WndType wndType = GetWndType(nextName); return(wndType != UI3WndType.ReturnFullScreen); }
/// <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> /// 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(); }