Exemplo n.º 1
0
    void Update()
    {
        if (m_AnimationTransform != null)
        {
            tempTime += Time.unscaledDeltaTime;
            if (tempTime > updateInterval)
            {
                tempTime = tempTime % updateInterval;
                m_AnimationTransform.Rotate(new Vector3(0, 0, rotateAngle));
            }
        }

        if (StartCountDown)
        {
            MaxLastTime -= Time.unscaledDeltaTime;
            if (MaxLastTime <= 0)
            {
                if (MaxTimeCloseWindowCallBack != null)
                {
                    MaxTimeCloseWindowCallBack();
                }
                WindowManager.Instance.CloseWindow(this.WindowNode);
                openedWindowNode = null;
            }
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// 显示提示框
    /// </summary>
    /// <param name="uiData"></param>
    /// <param name="parent"></param>
    public static void Show(MessageBoxData uiData, WindowNode parent = null)
    {
        WindowNodeInitParam initParam = new WindowNodeInitParam(UIAssetName);

        if (uiData.LuaCallBack != null)
        {
            System.Action <MessageBoxResult> luaCallBack = (result) =>
            {
                uiData.LuaCallBack((int)result);
            };

            if (uiData.CallBack != null)
            {
                uiData.CallBack += luaCallBack;
            }
            else
            {
                uiData.CallBack = luaCallBack;
            }
        }


        if (parent != null)
        {
            initParam.ParentNode = parent;
        }
        else
        {
            initParam.NodeType = BaseNodeType.Propmt;
        }
        initParam.WindowData = uiData;
        WindowManager.Instance.OpenWindow(initParam);
    }
Exemplo n.º 3
0
 /// <summary>
 /// 开启UI
 /// </summary>
 /// <param name="windowName"></param>
 /// <param name="parentNode"></param>
 /// <returns></returns>
 public WindowNode OpenWindow(string windowName, WindowNode parentNode, bool matchIphoneX = true)
 {
     return(OpenWindow(new WindowNodeInitParam(windowName, matchIphoneX)
     {
         ParentNode = parentNode
     }));
 }
Exemplo n.º 4
0
 /// <summary>
 /// 开启UI
 /// </summary>
 /// <param name="windowName"></param>
 /// <param name="parentNode"></param>
 /// <returns></returns>
 public WindowNode OpenWindow(string windowName, WindowNode parentNode)
 {
     return(OpenWindow(new WindowNodeInitParam(windowName)
     {
         ParentNode = parentNode
     }));
 }
Exemplo n.º 5
0
    /// <summary>
    /// 清理Window Node 信息
    /// </summary>
    /// <param name="windowNode">窗体节点信息</param>
    void RemoveWindowNode(WindowNode windowNode, bool isReleaseToPool)
    {
        for (int index = windowNode.ChildWindows.Count - 1; index >= 0; index--)
        {
            RemoveWindowNode(windowNode.ChildWindows[index], isReleaseToPool);
        }

        windowNode.CloseWindow();
        if (windowNode.WindowGameObject != null)
        {
            if (isReleaseToPool)
            {
                windowNode.WindowGameObject.transform.SetParent(m_HideNodeTransform, false);
                m_WindowPool.ReleaseGameObject(windowNode.WindowName, windowNode.WindowGameObject);
            }
            else
            {
                Destroy(windowNode.WindowGameObject);
            }
        }

        windowNode.ParentWindow.ChildWindows.Remove(windowNode);// 从父节点删除当前结点
        windowNode.ParentWindow = null;
        m_WindowNodeList.Remove(windowNode);
        windowNode.ChildWindows.Clear();
        windowNode.WindowData       = null;
        windowNode.WindowGameObject = null;
        windowNode = null;
    }
Exemplo n.º 6
0
 /// <summary>
 /// 关闭窗体
 /// </summary>
 /// <param name="windowNode">窗体节点信息</param>
 /// <param name="isRemoveParentNode">是否关闭父节点</param>
 public void CloseWindow(WindowNode windowNode, bool isReleaseToPool = true, bool isRemoveParentNode = false)
 {
     if (windowNode == null)
     {
         return;
     }
     CloseWindow(windowNode.WindowName, isReleaseToPool, isRemoveParentNode);
 }
Exemplo n.º 7
0
 /// <summary>
 /// 隐藏数据加载界面
 /// </summary>
 public static void Hide()
 {
     if (openedWindowNode != null)
     {
         WindowManager.Instance.CloseWindow(openedWindowNode, false);
         openedWindowNode = null;
     }
 }
Exemplo n.º 8
0
 /// <summary>
 /// 隐藏数据加载界面
 /// </summary>
 public static void Hide()
 {
     if (openedWindowNode != null)
     {
         HotFix.HotFixUpdate.HotfixProgressChangedEvent -= HotFixUpdate_HotfixProgressChangedEvent;
         WindowManager.Instance.CloseWindow(openedWindowNode, false);
         openedWindowNode = null;
     }
 }
Exemplo n.º 9
0
        protected virtual NodeParseResult ParseLeaf(WindowNode node)
        {
            var obj       = AllocObject();
            var objects   = new List <GraphObject>();
            var relations = new List <GraphRelation>();
            var clusters  = new List <GraphCluster>();

            obj.Label = node.ShortName;

            return(new NodeParseResult(obj, objects, relations, clusters));
        }
Exemplo n.º 10
0
 /// <summary>
 /// 显示数据加载界面
 /// </summary>
 public static void Show(System.Action <WindowNode> complatedCallBack = null)
 {
     if (openedWindowNode == null)
     {
         WindowNodeInitParam initParam = new WindowNodeInitParam(UIAssetName);
         initParam.NodeType = BaseNodeType.Loading;
         initParam.LoadComplatedCallBack = complatedCallBack;
         openedWindowNode = WindowManager.Instance.OpenWindow(initParam);
         HotFix.HotFixUpdate.HotfixProgressChangedEvent += HotFixUpdate_HotfixProgressChangedEvent;
     }
 }
Exemplo n.º 11
0
    /// <summary>
    /// 设置WindowNode父节点
    /// </summary>
    /// <param name="windowNode"></param>
    /// <param name="windowGameObject"></param>
    private void SetWindowNodeGameObject(WindowNode windowNode, GameObject windowGameObject)
    {
        Transform windowTransform = windowGameObject.transform;

        windowTransform.SetParent(m_UIParentTransform, false);
        windowTransform.name        = windowNode.WindowName;
        windowNode.WindowGameObject = windowGameObject;
        //SetTransformSiblingIndex(windowNode, windowTransform);
        windowNode.WindowMonoBehaviour = windowTransform.GetComponent <WindowBase>();
        windowNode.ShowWindow();
    }
Exemplo n.º 12
0
    public void Init()
    {
        int max = (int)BaseNodeType.Propmt;

        m_RootWindowNodes = new WindowNode[max + 1];
        for (int i = 0; i <= max; i++)
        {
            WindowNode node = new WindowNode((BaseNodeType)i);
            m_WindowNodeList.Add(node);
            m_RootWindowNodes[i] = node;
        }
    }
Exemplo n.º 13
0
    /// <summary>
    /// 设置WindowNode数据
    /// </summary>
    /// <param name="windowNode"></param>
    void SetWindowNodeGameObject(WindowNode windowNode)
    {
        GameObject poolGameObject = m_WindowPool.GetWindowGameObject(windowNode.WindowName);

        if (poolGameObject != null)
        {
            SetWindowNodeGameObject(windowNode, poolGameObject);
        }
        else
        {
            StartCoroutine(LoadWindowGameObjectByWindowNode(windowNode));
        }
    }
Exemplo n.º 14
0
    /// <summary>
    /// 泛型查找
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <returns></returns>
    public T FindWindowBaseByType <T>() where T : WindowBase
    {
        WindowNode node = m_WindowNodeList.Find(temp => temp.WindowMonoBehaviour is T);

        if (node != null)
        {
            return(node.WindowMonoBehaviour as T);
        }
        else
        {
            return(null);
        }
    }
Exemplo n.º 15
0
 /// <summary>
 /// 显示数据加载界面
 /// </summary>
 /// <param name="timeOut"></param>
 /// <param name="timeOutCallBack"></param>
 public static void Show(int timeOut = 5, System.Action timeOutCallBack = null)
 {
     if (openedWindowNode == null)
     {
         WindowNodeInitParam initParam = new WindowNodeInitParam(UIAssetName);
         initParam.NodeType = BaseNodeType.AboveNormal;
         LoadingDataUIData uiData = new LoadingDataUIData();
         uiData.MaxLastTime = timeOut;
         uiData.MaxTimeCloseWindowCallBack = timeOutCallBack;
         initParam.WindowData = uiData;
         openedWindowNode     = WindowManager.Instance.OpenWindow(initParam);
     }
 }
Exemplo n.º 16
0
    public static void ForceActiveProgress()
    {
        WindowNode tNode = WindowManager.Instance.FindWindowNodeByName(LoadingUI.UIAssetName);

        if (tNode != null)
        {
            LoadingUI tMonoBehaviour = tNode.WindowMonoBehaviour as LoadingUI;
            if (tMonoBehaviour != null)
            {
                tMonoBehaviour.ForceProgressSetActive();
            }
        }
    }
Exemplo n.º 17
0
    /// <summary>
    /// 加载WindowNode
    ///
    /// </summary>
    /// <param name="windowNode"></param>
    /// <returns></returns>
    IEnumerator LoadWindowGameObjectByWindowNode(WindowNode windowNode)
    {
        AssetBundleManager assetBundleManager = AssetBundleManager.Instance;

        if (assetBundleManager == null)
        {
            Debug.LogErrorFormat("Load window asset[{0}] error[AssetBundleManager is null when window been loading]. windowNode[ID:{1}] be clear!", windowNode.WindowAssetName, windowNode.WindowName);
            CloseWindow(windowNode.WindowName, false, false);
            yield break;
        }
        LoadAssetAsyncOperation operation = assetBundleManager.LoadAssetAsync <GameObject>(windowNode.WindowAssetName, false);

        if (operation != null && !operation.IsDone)
        {
            yield return(operation);
        }
        if (m_WindowNodeList.Contains(windowNode))
        {
            if (operation != null && operation.IsDone)
            {
                UnityEngine.Object resource = operation.GetAsset <UnityEngine.Object>();
                if (resource != null)
                {
                    GameObject windowGameObject = Instantiate(resource) as GameObject;
                    if (windowGameObject != null)
                    {
                        SetWindowNodeGameObject(windowNode, windowGameObject);
                    }
                    else
                    {
                        Debug.LogErrorFormat("Load window asset[{0}] error[Asset was not a gameObject]. windowNode[ID:{1}] be clear!", windowNode.WindowAssetName, windowNode.WindowName);
                        CloseWindow(windowNode.WindowName, false, false);
                    }
                }
                else
                {
                    Debug.LogErrorFormat("Load window asset[{0}] error[Asset was null]. windowNode[ID:{1}] be clear!", windowNode.WindowAssetName, windowNode.WindowName);
                    CloseWindow(windowNode.WindowName, false, false);
                }
            }
            else
            {
                Debug.LogErrorFormat("Load window asset[{0}] error. windowNode[ID:{1}] be clear!", windowNode.WindowAssetName, windowNode.WindowName);
                CloseWindow(windowNode.WindowName, false, false);
            }
        }
        else
        {
            // 在加载的过程中,本窗体已经被删除掉了
        }
    }
Exemplo n.º 18
0
        private void OnDragMenuClick(object o)
        {
            Type type = (Type)o;

            if (_canvas == null)
            {
                return;
            }

            if (_canvas.Graph == null)
            {
                return;
            }

            if (type == typeof(ActionNode))
            {
                ActionNode actionNode =
                    (ActionNode)_canvas.Graph.Editor().Repository.CreateNode(type, _lastMousePosition);;

                actionNode.TargetGameObject = (GameObject)_dragGameObject;
            }

            if (type == typeof(FollowMachineNode))
            {
                FollowMachineNode followMachineNode =
                    (FollowMachineNode)_canvas.Graph.Editor().Repository.CreateNode(type, _lastMousePosition);;

                followMachineNode.FollowMachine = _dragGameObject.GetComponent <FollowMachine>();
                followMachineNode.Editor().UpdateFollowMachine();
            }

            if (type == typeof(WindowNode))
            {
                WindowNode windowNode =
                    (WindowNode)_canvas.Graph.Editor().Repository.CreateNode(type, _lastMousePosition);;

                windowNode.Window = _dragGameObject.GetComponent <MgsUIWindow>();
                windowNode.Editor().OnShow();
            }

            if (type == typeof(DialogeNode))
            {
                DialogeNode dialogeNode =
                    (DialogeNode)_canvas.Graph.Editor().Repository.CreateNode(type, _lastMousePosition);;

                dialogeNode.Window = _dragGameObject.GetComponent <MgsDialougWindow>();
                dialogeNode.Editor().OnShow();
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// Creates an WindowNode based on <c ref="hWnd" />
        /// </summary>
        /// <param name="hWnd">window handler to base our windownode on</param>
        /// <param name="validation">instruction on what to validate</param>
        /// <returns>null if anything wrong or if window handler deems not possible</returns>
        public WindowNode CreateNode(IntPtr hWnd, ValidateHwndParams validation = null)
        {
            WindowNode node = null;

            if (CanHandleHwnd(hWnd, validation ?? new ValidateHwndParams()))
            {
                if (!pinvokeHandler.GetWindowRect(hWnd, out RECT rect))
                {
                    Log.Warning($"{nameof(WindowNode)}.{nameof(CreateNode)} Could not retrieve rect for hWnd {hWnd}, error: {pinvokeHandler.GetLastError()}");
                    return(null);
                }

                node = windowNodeCreater?.Invoke(rect, hWnd);
            }

            return(node);
        }
Exemplo n.º 20
0
        public virtual WindowNode Create(RECT rect, IntPtr hWnd, Direction dir = Direction.Horizontal)
        {
            try
            {
                var node = new WindowNode(dragHandler,
                                          focusHandler, signalHandler, windowHandler,
                                          windowTracker, pinvokeHandler,
                                          rect, hWnd, dir);
                node.PostInit();
                return(node);
            }
            catch (Exception ex)
            {
                Log.Fatal(ex, $"Could not create an window node for {hWnd}");
            }

            return(null);
        }
Exemplo n.º 21
0
    /// <summary>
    /// 设置
    /// </summary>
    /// <param name="windowNode"></param>
    /// <param name="transform"></param>
    void SetTransformSiblingIndex(WindowNode windowNode, Transform transform)
    {
        int index = 0;

        for (int i = 0; i < m_WindowNodeList.Count; i++)
        {
            if (m_WindowNodeList[i].IsRootNode)
            {
                continue;
            }
            if (m_WindowNodeList[i] == windowNode)
            {
                break;
            }
            index++;
        }
        transform.SetSiblingIndex(index);
    }
Exemplo n.º 22
0
        public void When_Initialize_With_hWnd_Then_AddWindow_To_Tracker()
        {
            // Arrange
            var hWnd           = new IntPtr(1);
            var dragHandler    = new Mock <IDragHandler>();
            var focusHandler   = new Mock <IFocusHandler>();
            var signalHandler  = new Mock <ISignalHandler>();
            var windowHandler  = new Mock <IWindowEventHandler>();
            var windowTracker  = new Mock <IWindowTracker>();
            var pinvokeHandler = new Mock <IPInvokeHandler>();

            pinvokeHandler.Setup(m => m.GetClassName(hWnd, It.IsAny <StringBuilder>(), It.IsAny <int>())).Returns(1);

            // Arrange & Act
            var sut = new WindowNode(dragHandler.Object, focusHandler.Object, signalHandler.Object, windowHandler.Object, windowTracker.Object, pinvokeHandler.Object, new RECT(10, 20, 30, 40), hWnd);

            // Assert
            windowTracker.Verify(m => m.AddWindow(new IntPtr(1), sut));
        }
Exemplo n.º 23
0
    /// <summary>
    /// 开启UI
    /// </summary>
    /// <param name="initParam"></param>
    /// <returns></returns>
    public WindowNode OpenWindow(WindowNodeInitParam initParam)
    {
        if (initParam == null)
        {
            return(null);
        }
        if (initParam.ParentNode == null)
        {
            initParam.ParentNode = GetBaseWindowNodeByNodeType(initParam.NodeType);
        }
        WindowNode windowNode = new WindowNode(initParam);

        windowNode.ParentWindow = initParam.ParentNode;
        SetWindowNodeInfo(windowNode, initParam.NearNode, initParam.NearNodeIsPreNode);
        ResetAllWindowIndex();
        // 统计SDK
        EventDispatcher.Instance.TriggerEvent("OpenWindowEvent", initParam.WindowName);
        return(windowNode);
    }
Exemplo n.º 24
0
    /// <summary>
    /// 关闭UI
    /// </summary>
    /// <param name="windowName"></param>
    /// <param name="isReleaseToPool"></param>
    /// <param name="isRemoveParentNode"></param>
    public void CloseWindow(string windowName, bool isReleaseToPool, bool isRemoveParentNode = false)
    {
        // 统计SDK
        WindowNode findNode = m_WindowNodeList.Find(temp => temp.WindowName == windowName);

        if (findNode == null)
        {
            return;
        }
        if (isRemoveParentNode)
        {
            while (!findNode.ParentWindow.IsRootNode)// 循环找父节点
            {
                findNode = findNode.ParentWindow;
            }
        }
        RemoveWindowNode(findNode, isReleaseToPool);
        ResetAllWindowIndex();
        EventDispatcher.Instance.TriggerEvent("CloseWindowEvent", windowName);
    }
Exemplo n.º 25
0
        public bool RevalidateHwnd(WindowNode node, IntPtr hWnd)
        {
            var cb = new StringBuilder(1024);

            if (node == null)
            {
                return(false);
            }

            if (!pinvokeHandler.IsWindow(hWnd))
            {
                return(false);
            }

            if (pinvokeHandler.GetClassName(hWnd, cb, cb.Capacity) == 0)
            {
                return(false);
            }

            return(cb.ToString() == node.ClassName);
        }
Exemplo n.º 26
0
    /// <summary>
    /// 显示提示框
    /// </summary>
    /// <param name="uiData"></param>
    /// <param name="parent"></param>
    public static void Show(MessageBoxData uiData, WindowNode parent = null)
    {
        string  UIAssetName_X = "MessageBoxUI";
        Vector2 screenSize    = new Vector2(Screen.width, Screen.height);

        if (screenSize.x == 1125 && screenSize.y == 2436)
        {
            UIAssetName_X = "MessageBoxUI_X";
        }
        WindowNodeInitParam initParam = new WindowNodeInitParam(UIAssetName_X);

        if (uiData.LuaCallBack != null)
        {
            System.Action <MessageBoxResult> luaCallBack = (result) =>
            {
                uiData.LuaCallBack((int)result);
            };

            if (uiData.CallBack != null)
            {
                uiData.CallBack += luaCallBack;
            }
            else
            {
                uiData.CallBack = luaCallBack;
            }
        }


        if (parent != null)
        {
            initParam.ParentNode = parent;
        }
        else
        {
            initParam.NodeType = BaseNodeType.Propmt;
        }
        initParam.WindowData = uiData;
        WindowManager.Instance.OpenWindow(initParam);
    }
Exemplo n.º 27
0
    /// <summary>
    /// 设置UI节点数据
    /// </summary>
    /// <param name="windowNode"></param>
    /// <param name="nearNode"></param>
    /// <param name="nearNodeIsPreNode"></param>
    void SetWindowNodeInfo(WindowNode windowNode, WindowNode nearNode, bool nearNodeIsPreNode)
    {
        WindowNode preNearNode = null;

        // 附近节点为空或者父节点不包括此附近节点
        if (nearNode == null || !windowNode.ParentWindow.ChildWindows.Contains(nearNode))
        {
            preNearNode = windowNode.ParentWindow.ChildWindows.Count == 0 ? windowNode.ParentWindow : windowNode.ParentWindow.ChildWindows[windowNode.ParentWindow.ChildWindows.Count - 1];
            while (preNearNode.ChildWindows.Count > 0)
            {
                preNearNode = preNearNode.ChildWindows[preNearNode.ChildWindows.Count - 1];
            }
            windowNode.ParentWindow.ChildWindows.Add(windowNode);
        }
        else
        {
            int index = windowNode.ParentWindow.ChildWindows.IndexOf(nearNode);
            if (!nearNodeIsPreNode)// 新节点在 靠近节点的后面
            {
                preNearNode = nearNode;
                index      += 1;
            }
            else // 新的节点在靠近节点的前面
            {
                preNearNode = index == 0 ? windowNode.ParentWindow : windowNode.ParentWindow.ChildWindows[index - 1];
            }

            while (preNearNode.ChildWindows.Count > 0)
            {
                preNearNode = preNearNode.ChildWindows[preNearNode.ChildWindows.Count - 1];
            }
            windowNode.ParentWindow.ChildWindows.Insert(index, windowNode);
        }
        m_WindowNodeList.Insert(m_WindowNodeList.IndexOf(preNearNode) + 1, windowNode);
        SetWindowNodeGameObject(windowNode);
    }
Exemplo n.º 28
0
 /// <summary>
 /// 设置窗体节点
 /// </summary>
 /// <param name="windowNode"></param>
 internal void SetWindowNode(WindowNode windowNode)
 {
     WindowNode = windowNode;
 }
Exemplo n.º 29
0
 /// <summary>
 /// 释放资源
 /// </summary>
 public virtual void Dispose()
 {
     WindowNode = null;
 }
Exemplo n.º 30
0
 public EWindowNode(WindowNode windowNode) : base(windowNode)
 {
     _windowNode = windowNode;
 }