예제 #1
0
    public void OnGUI()
    {
        GUIStyle   s = new GUIStyle();
        GUIContent c = new GUIContent();

        s.fixedHeight = 0;
        s.clipping    = TextClipping.Clip;
        s.wordWrap    = true;

        float y = 0, w = Screen.width, h, lh = 8;
        Rect  r = new Rect(0, 0, 0, 0), rb = new Rect(0, 0, 0, 0);

        foreach (string str in log)
        {
            GUIX.beginOpacity(.5f);
            c.text = str;
            h      = s.CalcHeight(c, w);
            h     += lh;

            r.Set(0, y, w, h);
            rb.Set(0, y, w, h - lh);

            GUIX.fillRect(rb, Color.black);
            GUI.Label(r, c);

            y += h - lh;
            GUIX.endOpacity();
        }
    }
예제 #2
0
    public override bool draw(float w, float h)
    {
        Rect rect = TextureUtility.getUseRect(new Rect(0, 0, w, h), AspectType.FIT_IN_REGION);

        float s = CrhcConstants.FONT_HEIGHT_NORMAL.getAs(general.number.NumberType.PIXELS);

        float x = rect.x, y = rect.y;

        w = Math.Min(s, rect.width);
        h = Math.Min(s, rect.height);

        x += rect.width / 2 - w / 2;
        y += rect.height / 2 - h / 2;

        rect = new Rect(x, y, w, h);

        filledAmount.update();

        float th = w / 10, p = 1.5f * th, f = filledAmount.get(), sx = (w - 2 * p) * f, sy = (h - 2 * p) * f;

        GUIX.fillRect(rect, Color.white);
        GUIX.strokeRect(rect, Color.black, th);

        GUIX.fillRect(new Rect(x + w / 2 - sx / 2, y + h / 2 - sy / 2, sx, sy), Color.black);

        return(false);
    }
예제 #3
0
파일: Menu.cs 프로젝트: ryanmcgrail95/CRHC
    public override void draw(float w, float h)
    {
        // TODO: Fix offscreen issues.

        float y = 0;

        // If any of heights different, recalculate all.
        bool didChange = false;

        for (int i = 0, len = rows.Count; i < len; i++)
        {
            IRow  row = rows[i];
            float height = rowHeights[i], calcHeight = row.getPixelHeight(w);

            if (height != calcHeight)
            {
                rowHeights[i] = height;
                didChange     = true;
            }
        }

        if (didChange)
        {
            invalidateHeight();
        }

        float menuH = getPixelHeight(w);

        GUIX.fillRect(new Rect(0, 0, w, menuH), color);

        Rect  clipRect = GUIX.getClipRect();
        float cY = clipRect.y, cH = clipRect.height;

        float sH = AppRunner.getScreenHeight();

        foreach (IRow row in rows)
        {
            if (AppRunner.doHandleOffscreen && cY + y > sH)
            {
                return;
            }

            h = row.getPixelHeight(w);

            if (!AppRunner.doHandleOffscreen || cY + y + h > 0)
            {
                GUIX.beginClip(new Rect(0, y, w, h + 1));
                row.draw(w);
                GUIX.endClip();
            }

            y += row.getPixelHeight(w);
        }
    }
예제 #4
0
    public override void draw(float w, float h)
    {
        menu.draw(w, h);

        if (CrhcSettings.showAnimations && fadeAmount.get() < 1)
        {
            GUIX.beginOpacity(1 - fadeAmount.get());
            GUIX.fillRect(new Rect(0, 0, w, h), Color.black);
            GUIX.endOpacity();
        }
    }
예제 #5
0
    public override void draw(float w, float h)
    {
        // TODO: Update outside of draw.
        // TODO: Incorporate deltaTime.
        // TODO: Make smooth deltaTime variables.

        //float fadeDis = menu.getHeight(w);
        fadeDis = w;

        float fadeAmount = this.fadeAmount.get();

        GUIX.fillRect(new Rect(0, 0, w, h), color);

        if (CrhcSettings.showAnimations)
        {
            GUIX.beginOpacity(fadeAmount);
        }

        /*float fadeY, menuH;
         * fadeY = -fadeDis * (1 - fadeInAmount);
         * menuH = h - fadeY;
         * Rect menuRect = new Rect(0, fadeY, w, menuH);*/
        float fadeX = 0, menuH;

        menuH = h;

        Rect menuRect;

        if (CrhcSettings.showAnimations)
        {
            if (!hasEntered || isClosing)
            {
                fadeX = fadeDis * (1 - fadeAmount);
            }
            else
            {
                fadeX = -fadeDis * (1 - fadeAmount);
            }
        }
        menuRect = new Rect(fadeX, 0, w, menuH);

        GUIX.beginClip(menuRect);
        menu.draw(w, menuH);
        GUIX.endClip();

        if (CrhcSettings.showAnimations)
        {
            GUIX.endOpacity();
        }
    }
예제 #6
0
    public override bool draw(float w, float h)
    {
        Rect rect = new Rect(0, 0, w, h);

        GUIX.fillRect(rect, color);
        if (GUIX.didTapInsideRect(rect))
        {
            onClick();
            return(true);
        }
        else
        {
            return(false);
        }
    }
예제 #7
0
        public static Rect drawTexture(Rect drawRect, Reference <Texture2D> textureReference, AspectType aspectType, float angle)
        {
            if (textureReference.isLoaded())
            {
                return(drawTexture(drawRect, textureReference.getResource(), aspectType, angle));
            }
            else
            {
                Rect useRect = getUseRect(drawRect, textureReference.getResource(), aspectType);

                GUIX.beginOpacity(.5f);
                GUIX.strokeRect(useRect, 1);
                GUIX.fillRect(new Rect(useRect.x, useRect.y, useRect.width * textureReference.getLoadFraction(), useRect.height));
                GUIX.endOpacity();

                return(useRect);
            }
        }
예제 #8
0
    public void draw()
    {
        if (!CrhcSettings.showAnimations || number.isDone())
        {
            return;
        }

        number.update();

        float f = number.get(), s = CrhcConstants.SIZE_TOUCH_RING.getAs(general.number.NumberType.PIXELS) * f, b = 10000;

        GUIX.beginOpacity(1 - f);
        GUIX.drawTexture(new Rect(x - s / 2, y - s / 2, s, s), tex.getResource());
        GUIX.endOpacity();
        GUIX.beginOpacity(f * (1 - f));
        GUIX.fillRect(new Rect(-b / 2, -b / 2, b, b), Color.white);
        GUIX.endOpacity();
    }
예제 #9
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();
        }
    }
예제 #10
0
    public void OnGUI()
    {
        if (!VuforiaBehaviour.Instance.enabled)
        {
            return;
        }

        if (exp == null)
        {
            return;
        }

        Reference <Texture2D> img, overlay, outline;

        img     = exp.getImg();
        overlay = exp.getOverlay();
        outline = exp.getOutline();

        if (!img.isLoaded())
        {
            return;
        }

        Texture2D imgTex = img.getResource();

        float scrW = AppRunner.getScreenWidth(), scrH = AppRunner.getScreenHeight(), angle = 0, xOffset = 0, yOffset = 0;
        float s = CrhcConstants.SIZE_VUFORIA_FRAME.getAs(NumberType.PIXELS), p = 30;

        Orientation orientation = AppRunner.getOrientation();

        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;
        }


        Rect region             = TextureUtility.getUseRect(new Rect(xOffset + scrW - s - p, yOffset + p, s, s), imgTex, AspectType.FIT_IN_REGION);

        if (didMatch)
        {
            frameAlpha += (0 - frameAlpha) / 10;
        }

        alphaAngle += .5f * Time.deltaTime;

        float a = .5f + .5f * Mathf.Sin(alphaAngle);

        Vector2 pivot = Vector2.zero;

        GUIX.beginRotate(pivot, angle);

        GUIX.beginOpacity(frameAlpha);

        if (img != null)
        {
            if (img.isLoaded())
            {
                GUIX.beginColor(Color.white);
                GUIX.drawTexture(region, img.getResource());
                GUIX.endColor();
            }
        }

        GUIX.beginOpacity(a);

        GUIX.beginOpacity(.75f);
        GUIX.fillRect(region, Color.black);
        GUIX.endOpacity();

        if (outline != null)
        {
            if (outline.isLoaded())
            {
                GUIX.beginColor(Color.white);
                GUIX.drawTexture(region, outline.getResource());
                GUIX.endColor();
            }
        }
        GUIX.endOpacity();

        GUIX.beginOpacity(1 - a);
        if (overlay != null)
        {
            if (overlay.isLoaded())
            {
                Texture2D tex = overlay.getResource();
                GUIX.drawTexture(region, tex);

                if (overlayPlane != null)
                {
                    MeshRenderer renderer = overlayPlane.GetComponent <MeshRenderer>();
                    renderer.material.shader      = shader;
                    renderer.material.mainTexture = tex;

                    float tw = tex.width, th = tex.height, f = tw / th, nf = th / tw;
                    float ss = .1f;
                    float xv = -ss, yv = ss, zv = -ss;

                    zv *= nf;

                    overlayPlane.transform.localScale = new Vector3(xv, yv, zv);
                }
            }
        }
        GUIX.endOpacity();

        GUIStyle style = new GUIStyle();

        GUIX.strokeRect(region, Color.white, 3);
        GUIX.endOpacity();

        if (!isMatching)
        {
            //TODO: Draw on screen too.
            GUIX.beginColor(Color.white);
            TextureUtility.drawTexture(new Rect(xOffset, yOffset, scrW, scrH), outline, AspectType.FIT_IN_REGION);
            GUIX.endColor();
        }

        if (debugMessage != null && debugMessage != "")
        {
            float x, y, w, h;
            w = scrW;
            h = 20;
            x = xOffset;
            y = yOffset + scrH - h;

            GUIX.fillRect(new Rect(x, y, w, h), Color.black);
            GUI.Label(new Rect(x, y, w, h), debugMessage);
        }

        GUIX.endRotate();
    }
예제 #11
0
    public override void draw(float w, float h)
    {
        // TODO: Pass w/h in via draw, or constructor??
        // might not work right?

        Rect clipRect = GUIX.getClipRect();

        h = Math.Min(h, clipRect.height);

        float menuH = menu.getPixelHeight(w), scrollY;
        float heightDiff = menuH - h;

        ITouch iTouch = ServiceLocator.getITouch();

        GUIX.fillRect(new Rect(0, 0, w, h), color);

        if (heightDiff > 0)
        {
            // Scroll menu.
            if (!float.IsInfinity(prevHeightDiff))
            {
                if (heightDiff != prevHeightDiff)
                {
                    scrollFrac = -prevScrollY / heightDiff;
                }
            }

            scrollFrac = Math.Max(0, Math.Min(scrollFrac, 1));
            scrollY    = -scrollFrac * heightDiff;
        }
        else
        {
            scrollY = 0;
        }

        prevHeightDiff = heightDiff;
        prevScrollY    = scrollY;

        Vector2 scrollPosition = new Vector2(0, scrollY);

        GUIX.beginClip(new Rect(0, 0, w, h), scrollPosition);
        menu.draw(w, h);
        GUIX.endClip();

        // Draw scrollbar.
        if (heightDiff > 0)
        {
            float PADDING = 8, scrollBarWidth = CrhcConstants.PADDING_H.getAs(general.number.NumberType.PIXELS) - PADDING * 2;
            float scrollRegion    = h - 4 * PADDING - 2 * scrollBarWidth;
            float scrollBarHeight = h / menuH * scrollRegion;

            if (CrhcSettings.showScrollbar)
            {
                GUIX.beginClip(new Rect(w - PADDING - scrollBarWidth, 0, scrollBarWidth, h));

                GUIX.beginOpacity(.5f);
                TextureUtility.drawTexture(new Rect(0, PADDING, scrollBarWidth, scrollBarWidth), arrowTexture, AspectType.FIT_IN_REGION, 90);

                float hh = scrollRegion - scrollBarHeight;
                GUIX.fillRect(new Rect(0, 2 * PADDING + scrollBarWidth + hh * scrollFrac, scrollBarWidth, scrollBarHeight));
                TextureUtility.drawTexture(new Rect(0, h - PADDING - scrollBarWidth, scrollBarWidth, scrollBarWidth), arrowTexture, AspectType.FIT_IN_REGION, -90);
                GUIX.endOpacity();
                GUIX.endClip();
            }

            scrollFrac -= (iTouch.getDragVector().y / heightDiff);
        }
    }
예제 #12
0
    public override bool draw(float w)
    {
        // Create player.

        float padding = CrhcConstants.PADDING_H.getAs(NumberType.PIXELS);

        w -= 2 * padding;
        float h = getPixelHeight(w);

        Rect region = new Rect(0, 0, w, h), paddingRegion = new Rect(padding, 0, w, h);

        GUIX.beginClip(paddingRegion);

        if (hasWaveformTexture)
        {
            GUIX.drawTexture(region, waveformTexture);

            ITouch iTouch = ServiceLocator.getITouch();
            if (GUIX.isTouchInsideRect(region))
            {
                if (iTouch.checkTap())
                {
                    onClick();
                    togglePlayPause();
                }
                else if (!wasHeld && iTouch.isHeld())
                {
                    if (!isScrubbing)
                    {
                        onClick();
                        isScrubbing = true;
                        pause();
                    }
                }
            }
            wasHeld = iTouch.isHeld();

            if (iTouch.isDown())
            {
                if (isScrubbing)
                {
                    float len = audioClip.getResource().length;

                    audioSource.time = Math.Max(0, Math.Min(len * (iTouch.getTouchPosition().x - padding) / w, len));
                    iTouch.clearDragVector();
                }
            }
            else
            {
                if (isScrubbing)
                {
                    isScrubbing = false;
                    play();
                }
            }

            if (!audioSource.isPlaying && playState == PlayState.PLAYING)
            {
                stop();
            }

            if (playState != PlayState.STOPPED)
            {
                Color color = (playState == PlayState.PLAYING) ? CrhcConstants.COLOR_RED : CrhcConstants.COLOR_BLUE_DARK;
                float frac = audioSource.time / audioSource.clip.length, bx = w * frac, bw = 5;
                GUIX.fillRect(new Rect(bx - bw / 2, 0, bw, h), color);
            }

            drawTouchRing(region);
        }
        else
        {
            if (audioClip.isLoaded() && waveformTexture == null)
            {
                AudioClip_onLoad();
            }

            GUIX.strokeRect(region, CrhcConstants.COLOR_GRAY_DARK, 1);
            GUIX.fillRect(new Rect(0, 0, w * progress, h), CrhcConstants.COLOR_GRAY_DARK);
        }

        GUIX.endClip();

        return(false);
    }
예제 #13
0
    public override bool draw(float w)
    {
        float x = 0, h = getPixelHeight(w);

        bool alreadyClicked = false;

        Rect position = new Rect(0, 0, w, h + 1);

        GUIX.fillRect(position, color);

        if (doXPad)
        {
            float pad = CrhcConstants.PADDING_H.getAs(NumberType.PIXELS);
            w -= 2 * pad;
            x += pad;
        }

        float y = 0;

        if (doYPadTop)
        {
            y += CrhcConstants.PADDING_V.getAs(NumberType.PIXELS);
            h -= CrhcConstants.PADDING_V.getAs(NumberType.PIXELS);
        }
        if (doYPadBottom)
        {
            h -= CrhcConstants.PADDING_V.getAs(NumberType.PIXELS);
        }

        IItem item;
        float totalPriority = 0, sw;

        foreach (Pair pair in items)
        {
            totalPriority += pair.priority;
        }

        foreach (Pair pair in items)
        {
            item = pair.item;
            sw   = pair.priority / totalPriority * w;

            GUIX.beginClip(new Rect(x, y, sw, h));
            alreadyClicked = item.draw(sw, h) || alreadyClicked;
            GUIX.endClip();
            x += sw;
        }

        drawTouchRing(position);

        if (doSupercedeChildClick || !alreadyClicked)
        {
            if (GUIX.didTapInsideRect(position))
            {
                onClick();
                return(true);
            }
            else
            {
                return(false);
            }
        }
        else
        {
            return(false);
        }
    }