void MovePanelForeground(List <PanelStub> list, Panel panel)
        {
            var old = GetPanelIndex(list, panel);

            if (old == -1 || old == list.Count - 1)
            {
                return;
            }
            var stub = list[old];

            list.RemoveAt(old);
            list.Add(stub);
            if (mFocusStub != null)
            {
                mFocusStub.HasFocus = false;
                mFocusStub          = null;
            }
            mFindFocusWindow = true;
            if (stub.Asset.IsUseMask)
            {
                UpdateSortingOrder(list, old);
                UpdateMask();
            }
            else
            {
                var    prev    = GetRecentPanel(list, 1);
                Canvas prevcan = prev == null ? null : prev.Instance.GetCanvas();
                Canvas can     = panel.GetCanvas();
                can.sortingOrder = prevcan == null ? 1 : prevcan.sortingOrder + 2;
            }
        }
 void NotifyFocusPanel(PanelStub stub, bool focus)
 {
     if (focus)
     {
         OnPanelBecomeForeground(stub.Instance);
     }
     else
     {
         OnPanelBecomeBackground(stub.Instance);
     }
 }
Esempio n. 3
0
 static Panel FindPanel(List <PanelStub> list, FilterDelegate <Panel> filter)
 {
     for (int i = list.Count - 1; i >= 0; i--)
     {
         PanelStub stub = list[i];
         if (filter(stub.Instance))
         {
             return(stub.Instance);
         }
     }
     return(null);
 }
Esempio n. 4
0
 private void Update()
 {
     for (int i = mClosing.Count - 1; i >= 0; i--)
     {
         PanelStub stub = mClosing[i];
         if (!stub.Instance.IsClosing())
         {
             mClosing.RemoveAt(i);
             stub.Asset.UnuseAsset(stub.Instance);
         }
     }
 }
Esempio n. 5
0
 Panel GetMaskPanel(List <PanelStub> list)
 {
     for (int i = list.Count - 1; i >= 0; i--)
     {
         PanelStub stub = list[i];
         if (stub.Asset.IsUseMask)
         {
             return(stub.Instance);
         }
     }
     return(null);
 }
        public static bool ClosePanel(int pid)
        {
            PanelStub p = FindPanel((x) => x.Asset.Id == pid);

            if (p == null)
            {
                return(false);
            }
            else
            {
                return(ClosePanel(p.Instance));
            }
        }
        int ClosePanelFor(List <PanelStub> list, FilterDelegate <PanelStub> filter, bool useFocus)
        {
            bool useMask = false;
            int  num     = 0;

            for (int i = list.Count - 1; i >= 0; i--)
            {
                PanelStub stub = list[i];
                if (!filter(stub))
                {
                    continue;
                }
                if (stub.Instance.IsClosing())
                {
                    continue;
                }
                bool close = stub.Instance.ClosePanel();
                if (!close)
                {
                    continue;
                }
                list.RemoveAt(i);
                if (useFocus)
                {
                    if (mFocusStub == stub)
                    {
                        mFocusStub       = null;
                        stub.HasFocus    = false;
                        mFindFocusWindow = true;
                    }
                }
                stub.Instance.OnPanelClosed();
                OnPanelClosed(stub.Instance);
                if (stub.Instance.IsClosing())
                {
                    mClosing.Add(stub);
                }
                else
                {
                    stub.Asset.UnuseAsset(stub.Instance);
                }
                num++;

                useMask |= stub.Asset.IsUseMask;
            }
            if (useMask)
            {
                UpdateMask();
            }
            return(num);
        }
        private void Update()
        {
            for (int i = mClosing.Count - 1; i >= 0; i--)
            {
                PanelStub stub = mClosing[i];
                if (!stub.Instance.IsClosing())
                {
                    mClosing.RemoveAt(i);
                    stub.Asset.UnuseAsset(stub.Instance);
                }
            }
            if (!WaittingForOpenPanel || mClosing.Count == 0)
            {
                m_EventMask.Update();
            }

            if (mFindFocusWindow)
            {
                mFindFocusWindow = false;
                var stub = GetRecentPanel(mDialogs, 0);
                if (stub == null)
                {
                    stub = GetRecentPanel(mPanels, 0);
                }
                if (stub != null)
                {
                    mFocusStub    = stub;
                    stub.HasFocus = true;
                }
            }

            if (GameInput.GetButtonDown(m_CancelButtonName) && !string.IsNullOrEmpty(m_CancelButtonName))
            {
                InteractCancel();
            }

            //if (mFocusStub != null && mFocusStub.Instance.m_DefaultSelectable != null
            //    && EventSystem.current != null && EventSystem.current.currentSelectedGameObject == null)
            //{
            //    if (Mathf.Abs(GameInput.GetAxis(m_HorizontalAxis)) > 0.5f || Mathf.Abs(GameInput.GetAxis(m_VerticalAxis)) > 0.5f ||
            //        GameInput.GetButtonDown(m_HorizontalAxis) || GameInput.GetButtonDown(m_VerticalAxis))
            //    {
            //        EventSystem.current.SetSelectedGameObject(mFocusStub.Instance.m_DefaultSelectable.gameObject);
            //    }
            //}
        }
 void ClearPanelForAsset(PanelAsset asset, List <PanelStub> panels)
 {
     for (int i = panels.Count - 1; i >= 0; i--)
     {
         PanelStub stub = panels[i];
         if (stub.Asset == asset)
         {
             if (mFocusStub == stub)
             {
                 stub.HasFocus    = false;
                 mFocusStub       = null;
                 mFindFocusWindow = true;
             }
             stub.Instance.OnPanelLostAsset();
             asset.UnuseAsset(stub.Instance);
             panels.RemoveAt(i);
         }
     }
 }
Esempio n. 10
0
        bool ClosePanelFor(List <PanelStub> list, PanelStub stub, bool useFocus)
        {
            if (stub.Instance.IsClosing())
            {
                return(true);
            }
            bool close = stub.Instance.OnPanelClose();

            if (!close)
            {
                return(false);
            }
            list.Remove(stub);
            if (stub.Instance.IsClosing())
            {
                mClosing.Add(stub);
            }
            else
            {
                stub.Asset.UnuseAsset(stub.Instance);
            }
            if (useFocus)
            {
                if (mFocusStub == stub)
                {
                    mFocusStub.HasFocus = false;
                    mFocusStub          = null;
                }
                if (mFocusStub == null && list.Count > 0)
                {
                    mFocusStub          = GetRecentPanel(list, 0);
                    mFocusStub.HasFocus = true;
                }
            }
            if (stub.Asset.IsUseMask)
            {
                UpdateMask();
            }
            return(true);
        }
        bool ClosePanelFor(List <PanelStub> list, PanelStub stub, bool useFocus)
        {
            if (stub.Instance.IsClosing())
            {
                return(true);
            }
            bool close = stub.Instance.ClosePanel();

            if (!close)
            {
                return(false);
            }
            list.Remove(stub);
            if (useFocus)
            {
                if (mFocusStub == stub)
                {
                    mFocusStub       = null;
                    stub.HasFocus    = false;
                    mFindFocusWindow = true;
                }
            }
            stub.Instance.OnPanelClosed();
            OnPanelClosed(stub.Instance);
            if (stub.Instance.IsClosing())
            {
                mClosing.Add(stub);
            }
            else
            {
                stub.Asset.UnuseAsset(stub.Instance);
            }
            if (stub.Asset.IsUseMask)
            {
                UpdateMask();
            }
            return(true);
        }
Esempio n. 12
0
 bool ClosePanelAsStatus(PanelStub stub)
 {
     return(ClosePanelFor(mStatus, stub, false));
 }
Esempio n. 13
0
 bool ClosePanelAsNormal(PanelStub stub)
 {
     return(ClosePanelFor(mPanels, stub, true));
 }
Esempio n. 14
0
 bool ClosePanelAsDialog(PanelStub stub)
 {
     return(ClosePanelFor(mDialogs, stub, true));
 }
Esempio n. 15
0
        // asset must be usable.
        Panel OpenPanelFor(List <PanelStub> list, int sortLayer, PanelAsset asset, IPanelMessager request, bool useFocus)
        {
            Panel panel = asset.InstantiateAsset();

            if (panel == null || panel.IsClosing())
            {
                return(null);
            }
            bool open;

            if (request != null)
            {
                open = panel.OnPanelOpenForResult(request);
            }
            else
            {
                open = panel.OnPanelOpen();
            }
            if (!open)
            {
                asset.UnuseAsset(panel);
                return(null);
            }
            int close = GetPanelIndex(mClosing, panel);

            if (close != -1)
            {
                mClosing.RemoveAt(close);
            }
            panel.transform.SetParent(transform, false);

            int old = GetPanelIndex(list, panel);

            if (old != -1)
            {
                list.RemoveAt(old);
            }
            PanelStub stub = new PanelStub();

            stub.Asset    = asset;
            stub.Instance = panel;
            list.Add(stub);
            PanelStub prev    = GetRecentPanel(list, 1);
            Canvas    prevcan = prev == null ? null : prev.Instance.GetCanvas();
            Canvas    can     = panel.GetCanvas();

            can.renderMode     = RenderMode.ScreenSpaceCamera;
            can.worldCamera    = m_UICamera;
            can.sortingLayerID = sortLayer;
            can.sortingOrder   = prevcan == null ? 1 : prevcan.sortingOrder + 2;
            if (useFocus)
            {
                if (mFocusStub != null)
                {
                    mFocusStub.HasFocus = false;
                }
                mFocusStub          = stub;
                mFocusStub.HasFocus = true;
            }
            if (asset.IsUseMask)
            {
                UpdateMask();
            }
            return(panel);
        }
        // asset must be usable.
        Panel OpenPanelFor <T>(List <PanelStub> list, int sortLayer, PanelAsset asset, T request, bool useFocus)
        {
            Panel panel = asset.InstantiateAsset();

            if (panel == null || panel.IsClosing())
            {
                return(null);
            }
            bool open;
            bool handint = false;

            if (!PanelIntentData.NONE.Equals(request))
            {
                if (panel is IPanelIntent <T> )
                {
                    handint = true;
                    open    = panel.OpenPanel();
                }
                else
                {
                    open = false;
                }
            }
            else
            {
                open = panel.OpenPanel();
            }
            if (!open)
            {
                asset.UnuseAsset(panel);
                return(null);
            }
            else if (handint)
            {
                ((IPanelIntent <T>)panel).HandleIntent(request);
            }
            panel.OnPanelOpened();
            OnPanelOpened(panel);
            int close = GetPanelIndex(mClosing, panel);

            if (close != -1)
            {
                mClosing.RemoveAt(close);
            }
            //panel.transform.SetParent(transform, false);
            WaittingForOpenPanel = false;
            int old = GetPanelIndex(list, panel);

            if (old != -1)
            {
                list.RemoveAt(old);
            }
            PanelStub stub = new PanelStub(this);

            stub.Asset    = asset;
            stub.Instance = panel;
            list.Add(stub);
            PanelStub prev    = GetRecentPanel(list, 1);
            Canvas    prevcan = prev == null ? null : prev.Instance.GetCanvas();
            Canvas    can     = panel.GetCanvas();

            SetupCanvas(can);
            can.sortingLayerID = sortLayer;
            if (asset.Mode != EPanelMode.Status && asset.Mode != EPanelMode.TopStatus)
            {
                can.sortingOrder = prevcan == null?GetSortOrder(asset.Mode) : prevcan.sortingOrder + 2;
            }
            if (useFocus)
            {
                if (mFocusStub != null)
                {
                    mFocusStub.HasFocus = false;
                    mFocusStub          = null;
                }
                mFindFocusWindow = true;
            }
            if (asset.IsUseMask)
            {
                UpdateMask();
            }
            return(panel);
        }