Beispiel #1
0
    /// <summary>
    /// Creates the window.
    /// </summary>
    /// <returns>The window.</returns>
    /// <param name="windowName">UI预设名</param>
    /// <param name="type">UI类型</param>
    /// <param name="layer">UI层级</param>
    public UIWindow CreateWindow(string windowName, UIWindowType type, UIWindowLayer layer = UIWindowLayer.Normal)
    {
        GameObject uiPrefab = LoadPrefab(windowName);

        if (uiPrefab == null)
        {
            Debug.LogError($"{GetType()}.CreateWindow, cannot find window resource : {windowName}");
            return(null);
        }

        UIWindow   window = null;
        GameObject obj    = Instantiate(uiPrefab, mRoot.transform, false) as GameObject;

        string[] dirs      = windowName.Split('/');
        string   className = dirs[dirs.Length - 1] + "Controller";

        window = obj.AddComponent(Type.GetType(className)) as UIWindow;
        if (window == null)
        {
            Debug.LogError($"Cant find UIWindow: {className}, check the name or remove any outter namespace.");
            return(null);
        }

        return(window);
    }
    public bool GetTopWindow(out UIWindow window, out UIWindowLayer layer, int banLayerMask)
    {
        for (int i = (int)UIWindowLayer.Max; i >= 0; i--)
        {
            if (((1 << i) & banLayerMask) == 0)
            {
                LinkedList <UIWindow> highLayerWindows;
                if (_layerList.TryGetValue(i, out highLayerWindows))
                {
                    if (highLayerWindows.Count > 0)
                    {
                        window = highLayerWindows.Last.Value;
                        if (window != null)
                        {
                            layer = (UIWindowLayer)i;
                            return(true);
                        }
                    }
                }
            }
        }

        window = null;
        layer  = UIWindowLayer.Max;
        return(false);
    }
    public T OpenCookingWindow <T>(string uipath, UIWindowLayer uiWindowLayer,
                                   UIWindowType windowType = UIWindowType.PopupTip, params object[] objs) where T : UIWindow
    {
        UIWindow window = null;

        window = OpenCookingWindow(uipath, uiWindowLayer, windowType, objs);
        if (window == null)
        {
            return(default(T));
        }

        return((T)window);
    }
 public int LayerMask(UIWindowLayer layer)
 {
     return(1 << ((int)layer));
 }
    public T OpenCookingWindow <T>(string uipath, UIWindowType windowType = UIWindowType.PopupTip, params object[] objs) where T : UIWindow
    {
        UIWindowLayer uiWindowLayer = UIWindowLayer.Tips;

        return(OpenCookingWindow <T>(uipath, uiWindowLayer, windowType, objs));
    }
    public UIWindow OpenCookingWindow(string uipath, UIWindowLayer uiWindowLayer, UIWindowType windowType = UIWindowType.PopupTip, params object[] objs)
    {
        UIWindow window = null;

        //if (windowType != UIWindowType.Fixed && ConflictDialogManager.Instance.CheckConflict(uipath, mMemoryWindows))
        //{
        //    return window;
        //}
        if (!mMemoryWindows.TryGetValue(uipath, out window))
        {
            window = UIRoot.Instance.CreateWindow(uipath, windowType);
            if (window != null)
            {
                mMemoryWindows[uipath] = window;
                window.WindowName      = uipath;
                window.m_WindowType    = windowType;
                window.uiWindowLayer   = uiWindowLayer;
            }
            else
            {
                Debug.LogError("Create ui fail: " + uipath);
                return(window);
            }
        }

        if (windowType != UIWindowType.Fixed)          //不是常显UI
        {
            if (!mStackWindows.Contains(window))       // 不在打开队列里
            {
                if (windowType == UIWindowType.Normal) //对于Normal类型的UI,需要在打开的时候,将前面打开的UI关闭掉
                {
                    if (mStackWindows.Count > 0)
                    {
                        UIWindow stackWindow = null;
                        try
                        {
                            stackWindow = mStackWindows.Peek();
                        }
                        catch (System.Exception e)
                        {
                            Debug.Log(e.Message);
                        }

                        if (stackWindow != null)
                        {
//                            List<string> friends = DragonPlus.ConflictDialogManager.Instance.GetFrinends(uipath);
//                            if (!friends.Contains(stackWindow.WindowName))//如果不在白名单里, 则关闭
//                            {
//                                stackWindow.CloseWindowWithinUIMgr(true);
//                            }
                        }
                    }
                }
                mStackWindows.Push(window);//添加到打开队列
            }
            else
            {
                //在打开队列里,从队列里移除所有挡住该UI的其他UI
                if (mStackWindows.Count > 0)
                {
                    while (!mStackWindows.Peek().Equals(window))
                    {
                        mStackWindows.Peek().CloseWindowWithinUIMgr(true);
                        mStackWindows.Pop();
                    }
                }
            }
        }
        else
        {
            //常显UI,单独处理
        }
        if (uiWindowLayer != UIWindowLayer.None)
        {
            LayerListInsertWindow(window);
        }
        window.OpenWindow(objs);
        return(window);
    }
    public UIWindow OpenCookingWindow(string uipath, UIWindowType windowType = UIWindowType.PopupTip, params object[] objs)
    {
        UIWindowLayer uiWindowLayer = UIWindowLayer.Tips;

        return(OpenCookingWindow(uipath, uiWindowLayer, windowType, objs));
    }
Beispiel #8
0
 private void _WindowMeta(string name, UIWindowLayer windowLayer)
 {
     _windowsInfo.Add(name, new WindowInfo {
         windowType = UIWindowType.PopupTip, windowLayer = windowLayer
     });
 }