113 lines
3.1 KiB
C#
113 lines
3.1 KiB
C#
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using Cysharp.Threading.Tasks;
|
|
|
|
public partial class UIManager
|
|
{
|
|
private Stack<UIWindow> _uiWindowStack = new Stack<UIWindow>(8);
|
|
|
|
public void PushWindow(UIWindow window)
|
|
{
|
|
if (window)
|
|
{
|
|
_uiWindowStack.Push(window);
|
|
}
|
|
}
|
|
|
|
public UIWindow PopWindow()
|
|
{
|
|
if (_uiWindowStack.Count > 0)
|
|
{
|
|
return _uiWindowStack.Pop();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public UIWindow PopWindow(string checkWindowName)
|
|
{
|
|
if (_uiWindowStack.Count > 0)
|
|
{
|
|
var window = _uiWindowStack.Peek();
|
|
if (string.IsNullOrEmpty(checkWindowName) || checkWindowName.Equals(window.WindowName))
|
|
{
|
|
return _uiWindowStack.Pop();
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public void ClearHideStack()
|
|
{
|
|
_uiWindowStack.Clear();
|
|
}
|
|
|
|
public static async UniTask<UIWindow> AnimSwitchWindow(UIWindow hideWindow, UIWindowCloseType closeType, string showWindowName, object data = null)
|
|
{
|
|
if (hideWindow != null)
|
|
{
|
|
await hideWindow.AnimHide();
|
|
}
|
|
|
|
var showWindow = await UIManager.Instance.OpenWindow(showWindowName, data);
|
|
|
|
|
|
if (showWindow != null)
|
|
{
|
|
await showWindow.AnimShow();
|
|
}
|
|
|
|
|
|
if (hideWindow != null)
|
|
{
|
|
hideWindow.CloseWindow(closeType);
|
|
}
|
|
|
|
return showWindow;
|
|
}
|
|
|
|
public static async UniTask<UIWindow> AnimSwitchWindow(UIWindow hideWindow, UIWindowCloseType closeType, UIWindow showWindow, object data)
|
|
{
|
|
if (hideWindow != null)
|
|
{
|
|
await hideWindow.AnimHide();
|
|
}
|
|
|
|
if (showWindow != null)
|
|
{
|
|
showWindow.OpenWindow(data);
|
|
await showWindow.AnimShow();
|
|
}
|
|
|
|
if (hideWindow != null)
|
|
{
|
|
hideWindow.CloseWindow(closeType);
|
|
}
|
|
|
|
return showWindow;
|
|
}
|
|
|
|
//常规的关闭一个最后打开的界面
|
|
public static async UniTask NormalCloseWindow(UIWindow hideWindow, String showWindowStr, Object data = null)
|
|
{
|
|
var window = Instance.PopWindow();
|
|
if (!window)
|
|
{
|
|
hideWindow.OnBack();
|
|
return;
|
|
}
|
|
await AnimSwitchWindow(hideWindow, UIWindowCloseType.OnlyHide, showWindowStr, data);
|
|
}
|
|
|
|
public static async UniTask NormalCloseWindow(UIWindow hideWindow, Object data = null)
|
|
{
|
|
var showWindow = Instance.PopWindow();
|
|
if (!showWindow)
|
|
{
|
|
hideWindow.OnBack();
|
|
return;
|
|
}
|
|
await AnimSwitchWindow(hideWindow, UIWindowCloseType.OnlyHide, showWindow, data);
|
|
}
|
|
}
|