Esempio n. 1
0
    /// Refresh page content. Call when case file is opened, in case content changed on page since last time.
    public void RefreshCurrentPage(CaseFilePage[] pages)
    {
        Debug.AssertFormat(m_CurrentPageIndex < pages.Length, this,
                           "Side {0} has m_CurrentPageIndex {1}, but only {2} pages have been passed from CaseFile.",
                           this, m_CurrentPageIndex, pages.Length);

        CaseFilePage page = pages[m_CurrentPageIndex];

        page.OnShow();
    }
Esempio n. 2
0
    public CaseFilePage[] GetAllPages()
    {
        int childCount = pagesParent.childCount;

        var pages = new CaseFilePage[childCount];

        for (int i = 0; i < childCount; i++)
        {
            pages[i] = pagesParent.GetChild(i).GetComponentOrFail <CaseFilePage>();
        }

        return(pages);
    }
Esempio n. 3
0
    /// Switch to target page on target side, moving it from another side if needed.
    public void SwitchSideToPage(CaseFileSide side, int pageIndex)
    {
        // check that target page is not None
        if (pageIndex == 0)
        {
            Debug.LogWarningFormat(this,
                                   "Cannot show page index 0 (None) on side {0}, as there is only one None page " +
                                   "and it couldn't be used as fallback page for the side already displaying it.", side);
            return;
        }

        // check that target page is not already shown on target side
        if (pageIndex == side.CurrentPageIndex)
        {
            Debug.LogWarningFormat(this, "Side {0} already shows page {1}", side, pageIndex);
            return;
        }

        // check if page is not already shown on the target side
        CaseFilePage page       = pages[pageIndex];
        Transform    pageParent = page.transform.parent;
        CaseFileSide oldSide    = null;

        if (page.gameObject.activeSelf && pageParent != side.pagesParent)
        {
            // Page is on another side at the moment, so we will move it to the target side
            // in side.ShowOnlyPage more below.
            // On the old side, we will fallback to page 0 (None).
            // However, we wait for side.ShowOnlyPage below first so it doesn't re-hide
            // the None page afterward.
            oldSide = pageParent.parent.GetComponentOrFail <CaseFileSide>();
        }

        // show new page on target side, moving it if needed
        side.ShowOnlyPage(pageIndex, pages);

        // check if page has moved
        if (oldSide != null)
        {
            // We can now fallback to page 0 (None) on the old side.
            // We must not hide what the old side thinks is the current page
            // (it's now the target page on the new side), so we must use ShowPage
            // instead of ShowOnlyPage.
            oldSide.ShowPage(0, pages);
        }
    }
Esempio n. 4
0
    /// Show page of given index and transform on this side,
    /// without hiding anything else (should only be called after HideAllPages)
    public void ShowPage(int pageIndex, CaseFilePage[] pages)
    {
        CaseFilePage page          = pages[pageIndex];
        Transform    pageTransform = page.transform;

        // update model
        m_CurrentPageIndex = pageIndex;
        // if needed, move page to this side, preserving local position
        if (pageTransform.parent != pagesParent)
        {
            pageTransform.SetParent(pagesParent, false);
        }
        // show page if not already active
        page.gameObject.SetActive(true);

        page.OnShow();
    }