Exemple #1
0
    public void OnGUI()
    {
        // TODO: REMOVE ME
        ServiceLocator.getITouch().OnGUI();

        float scrW, scrH;

        scrW = getScreenWidth();
        scrH = getScreenHeight();

        if (menuStack.Count > 0)
        {
            IMenu menu = menuStack.Peek();

            if (menu != null)
            {
                if (_enterMenu)
                {
                    if (menu.exit(false))
                    {
                        instance.menuStack.Push(nextMenu);
                        _enterMenu = false;
                    }
                }
                else if (_exitMenu)
                {
                    if (menu.exit(true))
                    {
                        menu.Dispose();
                        menuStack.Pop();

                        menu      = menuStack.Peek();
                        _exitMenu = false;
                    }
                }
                else
                {
                    menu.enter();
                }

                float   angle = 0, xOffset = 0, yOffset = 0;
                Vector2 pivot = Vector2.zero;

                if (orientation == Orientation.PORTRAIT_DOWN)
                {
                    angle   = 180;
                    xOffset = -scrW;
                    yOffset = -scrH;
                }
                else if (orientation == Orientation.LANDSCAPE_LEFT)
                {
                    angle   = 90;
                    yOffset = -scrH;
                }
                else if (orientation == Orientation.LANDSCAPE_RIGHT)
                {
                    angle   = 270;
                    xOffset = -scrW;
                }

                GUIX.clear(menu.getColor());

                GUIX.beginRotate(pivot, angle);
                GUI.BeginClip(new Rect(xOffset, yOffset, scrW, scrH));
                menu.draw(scrW, scrH);
                GUI.EndClip();
                GUIX.endRotate();
            }
            manager.OnGUI();
        }

        Rect topBar = new Rect(0, 0, Screen.width, 20);

        if (CrhcSettings.debugShowTouchPosition)
        {
            GUIX.fillRect(topBar, CrhcConstants.COLOR_BLACK_TRANSPARENT);

            Vector2 pos = ServiceLocator.getITouch().getTouchPosition();
            int     x, y;
            x = (int)pos.x;
            y = (int)pos.y;

            GUI.Label(topBar, "Touch Position: (" + x + ", " + y + ") / (" + (int)(100f * x / scrW) + " %, " + (int)(100f * y / scrH) + " %)");
            topBar.y += 20;
        }

        if (CrhcSettings.debugShowMemory)
        {
            long allocMemory = Profiler.GetTotalAllocatedMemory(), totalMemory = Profiler.GetTotalReservedMemory();
            GUIX.fillRect(topBar, CrhcConstants.COLOR_BLACK_TRANSPARENT);
            GUI.Label(topBar, "Memory: " + (allocMemory / (Math.Pow(10, 6))) + "/" + (totalMemory / (Math.Pow(10, 6))) + " MB");
            topBar.y += 20;
        }

        if (CrhcSettings.debugShowFps)
        {
            GUIX.fillRect(topBar, CrhcConstants.COLOR_BLACK_TRANSPARENT);
            GUI.Label(topBar, "FPS: " + m_lastFramerate);
            topBar.y += 20;
        }

        if (CrhcSettings.debugShowMenuElementCount)
        {
            GUIX.fillRect(topBar, CrhcConstants.COLOR_BLACK_TRANSPARENT);
            GUI.Label(topBar, "Menu Element Count: " + IMenuThing.menuElementCount);
            topBar.y += 20;
        }

        if (CrhcSettings.debugShowReferenceCount)
        {
            GUIX.fillRect(topBar, CrhcConstants.COLOR_BLACK_TRANSPARENT);
            GUI.Label(topBar, "Reference Count: " + ServiceLocator.getILoader().getReferenceCount());
            topBar.y += 20;
        }

        if (CrhcSettings.debugShowGuixStackCounts)
        {
            GUIX.fillRect(topBar, CrhcConstants.COLOR_BLACK_TRANSPARENT);
            GUI.Label(topBar, "Clip Stack Count: " + GUIX.getClipStackSize());
            topBar.y += 20;
            GUIX.fillRect(topBar, CrhcConstants.COLOR_BLACK_TRANSPARENT);
            GUI.Label(topBar, "Local Clip Stack Count: " + GUIX.getLocalClipStackSize());
            topBar.y += 20;
            GUIX.fillRect(topBar, CrhcConstants.COLOR_BLACK_TRANSPARENT);
            GUI.Label(topBar, "Color Stack Count: " + GUIX.getColorStackSize());
            topBar.y += 20;
            GUIX.fillRect(topBar, CrhcConstants.COLOR_BLACK_TRANSPARENT);
            GUI.Label(topBar, "Action List Count: " + GUIX.getActionListSize());
            topBar.y += 20;
        }

        if (CrhcSettings.debugShowFileManagerStackCount)
        {
            GUIX.fillRect(topBar, CrhcConstants.COLOR_BLACK_TRANSPARENT);
            GUI.Label(topBar, "Directory Stack Count: " + ServiceLocator.getIFileManager().getDirectoryStackSize());
            topBar.y += 20;
        }

        ILog log = ServiceLocator.getILog();

        if (doDrawLog && log is OnScreenLog)
        {
            (log as OnScreenLog).OnGUI();
        }
    }