예제 #1
0
        public void PushPopTest()
        {
            var stack = new PageStack();

            Assert.That(stack.Count, Is.EqualTo(0));

            stack.Push(new Page {
                Name = "Page1", Data = null
            });
            Assert.That(stack.Count, Is.EqualTo(1));
            Assert.That(stack.Peek().Name, Is.EqualTo("Page1"));

            stack.Push(new Page {
                Name = "Page2", Data = null
            });
            Assert.That(stack.Count, Is.EqualTo(2));
            Assert.That(stack.Peek().Name, Is.EqualTo("Page2"));

            var page2 = stack.Pop();

            Assert.That(page2.Name, Is.EqualTo("Page2"));
            Assert.That(stack.Count, Is.EqualTo(1));
            Assert.That(stack.Peek().Name, Is.EqualTo("Page1"));

            var page1 = stack.Pop();

            Assert.That(page1.Name, Is.EqualTo("Page1"));
            Assert.That(stack.Count, Is.EqualTo(0));
        }
예제 #2
0
    public static Page Replace(string pageName, string param = null, Admission admision = null)
    {
        if (AdmissionManager.busing)
        {
            return(null);
        }
        Debug.Log("Replace to: " + pageName);
        var oldPage = PageStack.Find(pageName);

        if (oldPage != null)
        {
            throw new Exception("page: " + pageName + " already in stack, can't replace, try use Backto");
        }
        var fromPage = PageStack.Peek();
        var page     = TakeOrCreatePage(pageName);

        page.param = param;
        PageStack.RelpaceTop(page);
        RepositionMask();
        if (admision != null)
        {
            AdmissionManager.Play(admision, fromPage, page);
        }
        return(page);
    }
예제 #3
0
    public static void Back(object result = null, Admission admision = null)
    {
        if (AdmissionManager.busing)
        {
            return;
        }
        var page = PageStack.Pop();

        if (page != null)
        {
            pagePool.Put(page.name, page);
        }
        if (PageStack.Count > 0)
        {
            var top = PageStack.Peek();
            Debug.Log("Back to: " + top.name);
            top.OnResult(result);
        }
        else
        {
            Debug.Log("All pages poped!");
        }
        if (admision != null)
        {
            AdmissionManager.Play(admision, page, PageStack.Peek());
        }
        RepositionMask();
    }
예제 #4
0
    public static Page Forward(string pageName, object param = null, Admission admision = null)
    {
        if (AdmissionManager.busing)
        {
            return(null);
        }
        Debug.Log("Navigate to: " + pageName);
        var oldPage = PageStack.Find(pageName);

        if (oldPage != null)
        {
            throw new Exception("page: " + pageName + " already in stack, can't navigate, try use BackTo");
        }
        var fromPage = PageStack.Peek();
        var page     = TakeOrCreatePage(pageName);

        page.param = param;
        page.OnParamChanged();
        PageStack.Push(page);
        RepositionMask();
        if (admision != null)
        {
            AdmissionManager.Play(admision, fromPage, page);
        }
        return(page);
    }
예제 #5
0
        private static void HidePage(Page page, Direction direction)
        {
            page.Closing(direction);
            var previous = PageStack.Peek();    // Previous page.

            ShowPage(previous, direction);      // Show previous page.
        }
예제 #6
0
        private static bool EnableNextButton()
        {
            if (PageStack.Count == 0 || Container == null)
            {
                return(false);
            }
            var current = PageStack.Peek();

            if (current == null)
            {
                return(false);
            }
            var isNoPage = current.Next is NoPage;

            return(!isNoPage);
        }
예제 #7
0
        private static void NextButton_Callback(Direction direction)
        {
            var current = PageStack.Peek();

            // Check if "next page" happens to be a non existing page.
            // Then prevent from displaying the next page.
            if (current is NoPage)
            {
                return;
            }

            current.Closing(direction); // Close current displayed page.

            var next = current.Next;

            PageStack.Push(next);       // Store next page.
            ShowPage(next, direction);  // Show next page.
        }
예제 #8
0
    public static void RepositionMask()
    {
        Page firstPage = PageStack.Peek();

        if (firstPage.Overlay)
        {
            Floating control = ShowFlaoting("MaskControl", null, firstPage.Depth - 1);
            control.transform.SetAsLastSibling();
            control.transform.SetSiblingIndex(firstPage.transform.GetSiblingIndex());
        }
        else
        {
            Floating c = GetControl("MaskControl");
            if (c != null)
            {
                c.Active = false;
            }
        }
    }