|
@@ -7,12 +7,19 @@ using ET;
|
|
|
|
|
|
namespace GFGGame
|
|
|
{
|
|
|
+ public class ViewStructure
|
|
|
+ {
|
|
|
+ public string name;
|
|
|
+ public object viewData;
|
|
|
+ public IUIView iUIView;
|
|
|
+ }
|
|
|
/// <summary>
|
|
|
/// 视图管理类
|
|
|
/// 管理视图的显示、隐藏
|
|
|
/// </summary>
|
|
|
public class ViewManager
|
|
|
{
|
|
|
+ private static List<ViewStructure> _viewStack;
|
|
|
private static Dictionary<string, IUIView> _viewDic;
|
|
|
private static GComponent _bottomLayer;
|
|
|
private static GComponent _topLayer;
|
|
@@ -53,8 +60,13 @@ namespace GFGGame
|
|
|
UIConfig.bringWindowToFrontOnClick = false;
|
|
|
|
|
|
_viewDic = new Dictionary<string, IUIView>();
|
|
|
+
|
|
|
+ _viewStack = new List<ViewStructure>();
|
|
|
+
|
|
|
//初始化视图层容器
|
|
|
_bottomLayer = CreateLayer("BottomLayer");
|
|
|
+ //_bottomLayer.sortingOrder = ConstSortingOrder.Bottom;
|
|
|
+
|
|
|
_topLayer = CreateLayer("TopLayer");
|
|
|
_topLayer.sortingOrder = ConstSortingOrder.TOP;
|
|
|
|
|
@@ -121,6 +133,11 @@ namespace GFGGame
|
|
|
}
|
|
|
if (hideOthers)
|
|
|
{
|
|
|
+ for (int i = _viewStack.Count - 1; i >= 0; i--)
|
|
|
+ {
|
|
|
+ if (_viewStack[i].name != "MainUIView")
|
|
|
+ _viewStack.RemoveAt(i);
|
|
|
+ }
|
|
|
HideAllView(name);
|
|
|
}
|
|
|
IUIView obj = null;
|
|
@@ -135,6 +152,7 @@ namespace GFGGame
|
|
|
obj.viewName = name;
|
|
|
_viewDic.Add(name, obj);
|
|
|
}
|
|
|
+
|
|
|
if (obj != null)
|
|
|
{
|
|
|
IUIView view = (IUIView)obj;
|
|
@@ -147,26 +165,28 @@ namespace GFGGame
|
|
|
{
|
|
|
view.Refresh();
|
|
|
}
|
|
|
- if (resetGobackParams)
|
|
|
- {
|
|
|
- if (_goBackDatas.ContainsKey(name) == true)
|
|
|
- {
|
|
|
- _goBackDatas.Remove(name);
|
|
|
- }
|
|
|
- }
|
|
|
- if (goBackParams != null)
|
|
|
- {
|
|
|
- if (!_goBackDatas.ContainsKey(name))
|
|
|
- {
|
|
|
- _goBackDatas.Add(name, new List<object[]>());
|
|
|
- }
|
|
|
-
|
|
|
- _goBackDatas[name].Add(goBackParams);
|
|
|
- }
|
|
|
Debug.Log("当前打开:" + name);
|
|
|
}
|
|
|
- return true;
|
|
|
|
|
|
+ if (name == "MainUIView")
|
|
|
+ {
|
|
|
+ _viewStack.Clear();
|
|
|
+ }
|
|
|
+
|
|
|
+ //判断是否需要保存界面数据, 会帮助关闭上一个保存界面
|
|
|
+ if (obj.isReturnView && (_viewStack.Count <= 0 || (_viewStack.Count > 0 && _viewStack[_viewStack.Count - 1].name != name)))
|
|
|
+ {
|
|
|
+ ViewStructure viewStructure = new ViewStructure();
|
|
|
+ viewStructure.name = name;
|
|
|
+ viewStructure.viewData = viewData;
|
|
|
+ viewStructure.iUIView = obj;
|
|
|
+ _viewStack.Add(viewStructure);
|
|
|
+
|
|
|
+ if (_viewStack.Count > 1)
|
|
|
+ _viewStack[_viewStack.Count - 2].iUIView.Hide();
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
public static bool isViewOpen(string fullViewName)
|
|
@@ -185,61 +205,41 @@ namespace GFGGame
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
+
|
|
|
public static bool Show<T>(object viewData = null, object[] goBackParams = null, bool hideOthers = false, bool resetGobackParams = false) where T : class, new()
|
|
|
{
|
|
|
// string[] names = typeof(T).FullName.Split('.');
|
|
|
// string viewName = names[names.Length - 1];
|
|
|
- string name = GetName(typeof(T).FullName);
|
|
|
+ //string name = GetName(typeof(T).FullName);
|
|
|
+ return ViewManager.Show(typeof(T).FullName, viewData, null, hideOthers);
|
|
|
+ }
|
|
|
|
|
|
- if (!GameGlobal.skipCheckOpen && !FunctionOpenDataManager.Instance.CheckIsFunOpenById(name))
|
|
|
- {
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (hideOthers)
|
|
|
- {
|
|
|
- HideAllView(name);
|
|
|
- }
|
|
|
- IUIView obj = null;
|
|
|
- if (_viewDic.ContainsKey(name))
|
|
|
- {
|
|
|
- obj = _viewDic[name];
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- obj = new T() as IUIView;
|
|
|
- obj.viewName = name;
|
|
|
- _viewDic.Add(name, obj);
|
|
|
- }
|
|
|
- if (obj != null)
|
|
|
- {
|
|
|
- IUIView view = (IUIView)obj;
|
|
|
- view.viewData = viewData;
|
|
|
- if (!view.isShowing)
|
|
|
- {
|
|
|
- view.Show();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- view.Refresh();
|
|
|
- }
|
|
|
- if (goBackParams != null)
|
|
|
- {
|
|
|
- if (!_goBackDatas.ContainsKey(name))
|
|
|
- {
|
|
|
- _goBackDatas.Add(name, new List<object[]>());
|
|
|
- }
|
|
|
- _goBackDatas[name].Add(goBackParams);
|
|
|
- }
|
|
|
- else if (resetGobackParams)
|
|
|
+ public static void HideWin(string viewName)
|
|
|
+ {
|
|
|
+ if (_viewStack.Count > 1) {
|
|
|
+ ViewStructure viewStructure = _viewStack[_viewStack.Count - 1];
|
|
|
+ if (viewStructure.iUIView.isReturnView && viewStructure.name == viewName)
|
|
|
{
|
|
|
- if (_goBackDatas.ContainsKey(name) == true)
|
|
|
+ _viewStack.RemoveAt(_viewStack.Count - 1);
|
|
|
+ if (_viewStack.Count >= 1)
|
|
|
{
|
|
|
- _goBackDatas.Remove(name);
|
|
|
+ viewStructure = _viewStack[_viewStack.Count - 1];
|
|
|
+ ViewManager.Show($"GFGGame.{viewStructure.name}", viewStructure.viewData);
|
|
|
+
|
|
|
+ foreach (var objName in _viewDic.Keys)
|
|
|
+ {
|
|
|
+ if (objName != viewStructure.name)
|
|
|
+ {
|
|
|
+ IUIView view = (IUIView)_viewDic[objName];
|
|
|
+ if (view.isShowing)
|
|
|
+ {
|
|
|
+ view.Show();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- Debug.Log("当前打开:" + name);
|
|
|
}
|
|
|
- return true;
|
|
|
}
|
|
|
|
|
|
public static void Hide(string fullViewName)
|
|
@@ -249,8 +249,8 @@ namespace GFGGame
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
- IUIView obj = _viewDic[name];
|
|
|
- if (obj != null && obj.isShowing)
|
|
|
+ object obj = _viewDic[name];
|
|
|
+ if (obj != null)
|
|
|
{
|
|
|
IUIView view = (IUIView)obj;
|
|
|
view.Hide();
|
|
@@ -260,54 +260,35 @@ namespace GFGGame
|
|
|
|
|
|
public static void Hide<T>()
|
|
|
{
|
|
|
- string name = GetName(typeof(T).FullName);
|
|
|
- if (!_viewDic.ContainsKey(name))
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
- object obj = _viewDic[name];
|
|
|
- if (obj != null)
|
|
|
- {
|
|
|
- IUIView view = (IUIView)obj;
|
|
|
- view.Hide();
|
|
|
- Debug.Log("当前关闭:" + name);
|
|
|
- }
|
|
|
+ //string name = GetName(typeof(T).FullName);
|
|
|
+ Hide(typeof(T).FullName);
|
|
|
}
|
|
|
|
|
|
public static void GoBackFrom(string fullViewName, bool hideOther = true)
|
|
|
{
|
|
|
string name = GetName(fullViewName);
|
|
|
ViewManager.Hide(name);
|
|
|
- if (_goBackDatas.ContainsKey(name) && _goBackDatas[name].Count > 0)
|
|
|
- {
|
|
|
- List<object[]> goBackdatas = _goBackDatas[name];
|
|
|
- object[] gobackItems = goBackdatas[goBackdatas.Count - 1];
|
|
|
- string tViewName = gobackItems[0] as string;
|
|
|
|
|
|
- object tViewData = null;
|
|
|
- if (gobackItems.Length > 1)
|
|
|
+ foreach (var info in _viewDic.Keys)
|
|
|
+ {
|
|
|
+ IUIView objIsShowing = _viewDic[info];
|
|
|
+ if (objIsShowing != null && objIsShowing.isShowing)
|
|
|
{
|
|
|
- tViewData = gobackItems[1];
|
|
|
+ return;
|
|
|
}
|
|
|
- ViewManager.Show(tViewName, tViewData);
|
|
|
- _goBackDatas[name].RemoveAt(goBackdatas.Count - 1);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- MainDataManager.Instance.ViewType = 0;
|
|
|
-
|
|
|
- ViewManager.Show<MainUIView>(null, null, hideOther);
|
|
|
}
|
|
|
+ MainDataManager.Instance.ViewType = 0;
|
|
|
+ ViewManager.Show<MainUIView>(null, null, true);
|
|
|
}
|
|
|
|
|
|
public static object[] GetGoBackDatas(string fullViewName)
|
|
|
{
|
|
|
- string name = GetName(fullViewName);
|
|
|
+ //string name = GetName(fullViewName);
|
|
|
object[] value = null;
|
|
|
- if (_goBackDatas.ContainsKey(name) && _goBackDatas[name].Count > 0)
|
|
|
- {
|
|
|
- value = _goBackDatas[name][_goBackDatas[name].Count - 1];
|
|
|
- }
|
|
|
+ //if (_goBackDatas.ContainsKey(name) && _goBackDatas[name].Count > 0)
|
|
|
+ //{
|
|
|
+ // value = _goBackDatas[name][_goBackDatas[name].Count - 1];
|
|
|
+ //}
|
|
|
return value;
|
|
|
}
|
|
|
public static IUIView GetUIView(string viewName)
|
|
@@ -424,7 +405,7 @@ namespace GFGGame
|
|
|
/// 任务界面跳转
|
|
|
/// </summary>
|
|
|
/// <param name="jumpId"></param>
|
|
|
- public static void JumpToView(string jumpId, object[] param, object[] goBackDatas, bool hideOther = true, Action onSuccess = null)
|
|
|
+ public static void JumpToView(string jumpId, object[] param, object[] goBackDatas, bool hideOther = false, Action onSuccess = null)
|
|
|
{
|
|
|
switch (jumpId)
|
|
|
{
|