Exemplo n.º 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();
        }
    }
Exemplo n.º 2
0
    public override void draw(float w, float h)
    {
        // TODO: Update outside of draw.
        // TODO: Incorporate deltaTime.
        // TODO: Make smooth deltaTime variables.

        float headerFrac = .3f, menuFrac = 1 - headerFrac;

        GUIX.beginClip(new Rect(0, h * headerFrac, w, h * menuFrac));
        menu.draw(w, h * menuFrac);
        GUIX.endClip();

        // Draw BG.
        Rect bgRect = new Rect(0, 0, w, h * headerFrac);

        GUIX.beginClip(bgRect);
        GUIX.beginColor(Color.white);
        TextureUtility.drawTexture(bgRect, bg, AspectType.CROP_IN_REGION);
        GUIX.endColor();
        GUIX.endClip();

        // Draw logo.
        float aspect = TextureUtility.getAspectRatio(logo);

        float logoW = w / 3, logoH = logoW / aspect;
        Rect  logoRegion = new Rect(w - logoW, 0, logoW, logoH);

        logoRegion = TextureUtility.drawTexture(logoRegion, logo, AspectType.FIT_IN_REGION);
        if (GUIX.didTapInsideRect(logoRegion))
        {
            onClick();
            Application.OpenURL("https://www.iusb.edu/civil-rights/");
        }
        drawTouchRing(logoRegion);
    }
Exemplo n.º 3
0
        public override bool draw(float w, float h)
        {
            bool  output = base.draw(w, h);
            float arrowW = CrhcConstants.SIZE_BACK_BUTTON.getAs(NumberType.PIXELS);
            float angle  = 180;

            //Vector2 pivot = ServiceLocator.getITouch().getTouchPosition(); // new Vector2(PADDING + arrowW / 2, AppRunner.getScreenWidth()-PADDING + arrowW / 2);
            Rect region = new Rect(PADDING, PADDING, arrowW, arrowW);

            int   count = (int)Math.Round(w / arrowW / 2);
            float sw    = (w - PADDING * 2) / count;

            for (int i = 0; i < count; i++)
            {
                float f = i / (count - 1f), o = (float)Math.Pow(1f / (i + 1), 1.2);
                Rect  subRegion = new Rect(region.x + sw * i + f * (sw - arrowW), region.y, region.width, region.height);

                GUIX.beginOpacity(o);
                TextureUtility.drawTexture(subRegion, arrowTexture, CrhcConstants.COLOR_GRAY_DARK, AspectType.FIT_IN_REGION, angle);
                GUIX.endOpacity();
            }

            drawTouchRing(new Rect(0, 0, w, h));

            return(output);
        }
Exemplo n.º 4
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);
    }
Exemplo n.º 5
0
 private void OnGUI()
 {
     _show = GUI.Toggle(new Rect(0, 0, 20, 20), _show, "");
     if (_show)
     {
         GUI.Window(wid, GUIX.DefaultRect(), ShowWindow, "我的窗口");
     }
 }
 public static void ShowWindow(int id)
 {
     if (ch == null)
     {
         return;
     }
     GUIX.Horizontal(() =>
     {
         GUIX.Label(time.ToString(), 3);
         GUIX.Label("/", 3);
         GUIX.Label(max.ToString(), 3);
     });
     GUIX.Horizontal(() =>
     {
         if (GUIX.Button("<<", 3))
         {
             time  -= delta * 5;
             change = true;
         }
         if (GUIX.Button("<", 3))
         {
             time  -= delta;
             change = true;
         }
         if (GUIX.Button(">", 3))
         {
             time  += delta;
             change = true;
         }
         if (GUIX.Button(">>", 3))
         {
             time  += delta * 5;
             change = true;
         }
         if (time < 0)
         {
             time = 0;
         }
         if (time > max)
         {
             time = max;
         }
     });
     if (GUIX.Button("CopyBone", 3))
     {
         ch.mySetAnimeSpeed(0);
         ch.myCopyBone();
         ch.mySetFKActive(true);
         hipsPos = ch.myGetBoneHips().guideObject.transformTarget.position - ch.guideObject.transformTarget.position;
     }
     if (GUIX.Button("FixPos", 3))
     {
         ch.guideObject.changeAmount.pos = hipsPos;
         hipsPos = new Vector3();
     }
     GUIX.Label(Kit.VecStr(hipsPos), 12);
 }
Exemplo n.º 7
0
 public void drawTouchRing(Rect rect)
 {
     if (touchRing != null)
     {
         GUIX.beginClip(rect);
         touchRing.draw();
         GUIX.endClip();
     }
 }
Exemplo n.º 8
0
        public static Rect drawTexture(Rect drawRect, Reference <Texture2D> textureReference, Color color, AspectType aspectType, float angle)
        {
            GUIX.beginColor(color);
            Rect useRect = drawTexture(drawRect, textureReference, aspectType, angle);

            GUIX.endColor();

            return(useRect);
        }
Exemplo n.º 9
0
        public static Rect drawTexture(Rect drawRect, Texture2D texture, Color color, AspectType aspectType)
        {
            GUIX.beginColor(color);
            Rect useRect = drawTexture(drawRect, texture, aspectType);

            GUIX.endColor();

            return(useRect);
        }
Exemplo n.º 10
0
 void OnGUI()
 {
     if (target != null)
     {
         Rect   rect = new Rect(0, Screen.height - 50, Screen.width, 50);
         string text = "Spectating " + target.racerName;
         GUIX.ShadowLabel(rect, text, guistyle, 2);
         GUI.Label(rect, text, guistyle);
     }
 }
Exemplo n.º 11
0
    public void click()
    {
        Rect    rect = GUIX.getClipRect();
        Vector2 pos  = ServiceLocator.getITouch().getTouchPosition();

        x = pos.x - rect.x;
        y = pos.y - rect.y;

        number.setFraction(0);
    }
Exemplo n.º 12
0
    public override bool draw(float w)
    {
        float h = subMenu.getPixelHeight(w);

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

        return(false);
    }
Exemplo n.º 13
0
    public override bool draw(float w, float h)
    {
        Rect rect;

        rect = new Rect(0, 0, w, h);

        GUIX.drawLabel(rect, content, style);

        return(false);
    }
Exemplo n.º 14
0
 public static void ShowWindow(int id)
 {
     _lockRecord.ForEach(r =>
     {
         GUIX.Label(r.Bone.GuideObject.transformTarget.name, 12);
     });
     _headLocks.ForEach(r =>
     {
         GUIX.Label(r.Bone.GuideObject.transformTarget.name, 12);
     });
 }
Exemplo n.º 15
0
        public static Rect drawTexture(Rect drawRect, Texture2D texture, AspectType aspectType)
        {
            Rect useRect = getUseRect(drawRect, texture, aspectType);

            if (texture != null)
            {
                GUIX.drawTexture(useRect, texture);
            }

            return((aspectType == AspectType.CROP_IN_REGION) ? drawRect : useRect);
        }
Exemplo n.º 16
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();
        }
    }
Exemplo n.º 17
0
    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);
        }
    }
Exemplo n.º 18
0
        public override bool draw(float w, float h)
        {
            bool output = base.draw(w, h);

            if (tex.isLoaded())
            {
                GUIX.beginColor(Color.white);
                GUIX.drawTexture(new Rect(0, 0, w / 4, w / 4), tex.getResource());
                GUIX.endColor();
            }

            return(output);
        }
Exemplo n.º 19
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();
        }
    }
Exemplo n.º 20
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);
        }
    }
Exemplo n.º 21
0
    void OnGUI()
    {
        if (countdownText != "")
        {
            GUI.skin = skin;
            GUIStyle style = new GUIStyle(GUI.skin.label);
            style.alignment = TextAnchor.MiddleCenter;
            style.fontSize  = countdownFontSize;
            style.fontStyle = FontStyle.Bold;
            Rect rect = new Rect(0, 0, Screen.width, 400);

            GUIX.ShadowLabel(rect, countdownText, style, 4);
            GUI.Label(rect, countdownText, style);
        }
    }
Exemplo n.º 22
0
    public override bool draw(float w, float h)
    {
        Rect rect = TextureUtility.drawTexture(new Rect(0, 0, w, h), texture, color, aspectType);

        drawTouchRing(rect);

        if (GUIX.didTapInsideRect(rect))
        {
            onClick();
            return(true);
        }
        else
        {
            return(false);
        }
    }
Exemplo n.º 23
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();
    }
Exemplo n.º 24
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);
            }
        }
Exemplo n.º 25
0
    public override bool draw(float w)
    {
        // TODO: Move panel bg to draw before and after others...??????

        openFrac.update();

        float openF = openFrac.get();

        headRow.setColor(blendColor(closedColor, openColor, openF));
        if (headRow.draw(w))
        {
            openFrac.setTargetFraction(1 - openFrac.getTargetFraction());

            if (!CrhcSettings.showAnimations)
            {
                openFrac.complete();
            }
        }

        float headH = headRow.getPixelHeight(w);
        float padding = CrhcConstants.PADDING_H.getAs(NumberType.PIXELS), s = .6f, arrowW = padding * s;
        Rect  arrowRect = new Rect(padding * (1 - s) / 2, headH / 2 - arrowW / 2, arrowW, arrowW);
        float angle     = -90 * openF;

        TextureUtility.drawTexture(arrowRect, arrowTexture, CrhcConstants.COLOR_GRAY_DARK, AspectType.FIT_IN_REGION, angle);

        float h = subMenu.getPixelHeight(w) * openF;

        if (h > .01)
        {
            GUIX.beginClip(new Rect(0, headRow.getPixelHeight(w), w, h));
            subMenu.draw(w, h);
            GUIX.endClip();
        }

        return(false);
    }
Exemplo n.º 26
0
    void OnGUI()
    {
        if (waitingForPlayers)
        {
            GUI.skin = skin;
            GUIStyle style = new GUIStyle(GUI.skin.label);
            style.fontSize  = 50;
            style.alignment = TextAnchor.MiddleCenter;
            Rect rect = new Rect(0, 0, Screen.width, 400);

            var players         = client.GetPlayerList();
            int playersNotReady = 0;
            foreach (ServerPlayer p in players)
            {
                if (!p.ready)
                {
                    playersNotReady++;
                }
            }

            string playertxt = "players";
            if (playersNotReady == 1)
            {
                playertxt = "player";
            }

            string text = "Waiting for " + playersNotReady + " " + playertxt + "\n(Timeout in " + Mathf.Ceil(waitingForPlayersTimeout) + " seconds)";
            if (playersNotReady != 1)
            {
                text += "s";                //Plural
            }

            GUIX.ShadowLabel(rect, text, style, 3);
            GUI.Label(rect, text, style);
        }
    }
Exemplo n.º 27
0
    void OnGUI()
    {
        GUI.skin = skin;

        if (checkpointTime > 0)
        {
            Rect     checkpointLapRect  = new Rect(Screen.width / 2 - 200, Screen.height / 2 - 260, 400, 100);
            GUIStyle checkpointLapStyle = new GUIStyle(GUI.skin.label);
            checkpointLapStyle.alignment = TextAnchor.UpperCenter;
            checkpointLapStyle.fontSize  = 48;

            Rect     checkpointRect  = new Rect(Screen.width / 2 - 200, Screen.height / 2 - 200, 400, 100);
            GUIStyle checkpointStyle = new GUIStyle(GUI.skin.label);
            checkpointStyle.alignment = TextAnchor.UpperCenter;
            checkpointStyle.fontSize  = 40;

            Rect     checkpointDiffRect  = new Rect(Screen.width / 2 - 200, Screen.height / 2 - 150, 400, 100);
            GUIStyle checkpointDiffStyle = new GUIStyle(checkpointStyle);
            checkpointDiffStyle.fontSize         = 36;
            checkpointDiffStyle.normal.textColor = checkpointDiffColor;

            GUIX.ShadowLabel(checkpointLapRect, checkpointLapString, checkpointLapStyle, 2);
            GUI.Label(checkpointLapRect, checkpointLapString, checkpointLapStyle);

            GUIX.ShadowLabel(checkpointRect, checkpointString, checkpointStyle, 2);
            GUI.Label(checkpointRect, checkpointString, checkpointStyle);

            GUIX.ShadowLabel(checkpointDiffRect, checkpointDiffString, checkpointDiffStyle, 2);
            GUI.Label(checkpointDiffRect, checkpointDiffString, checkpointDiffStyle);
        }

        //Basic info
        Rect   infoRect = new Rect(10, Screen.height * 0.3f + 10, 400, 400);
        string spdStr   = "fasts/h";

        if (FindObjectOfType <MlgMode>() != null)
        {
            spdStr = "MLGs/h";
        }
        string infoString = sanicspeed.ToString() + " " + spdStr + "\n" +
                            "lap " + racer.Lap + " of " + racer.totalLaps;
        GUIStyle infoStyle = new GUIStyle(GUI.skin.label);

        infoStyle.fontSize = 36;

        GUIX.ShadowLabel(infoRect, infoString, infoStyle, 2);
        GUI.Label(infoRect, infoString, infoStyle);

        //Time
        Rect     timeRect   = new Rect(Screen.width / 2 - 200, Screen.height - 80, 400, 80);
        string   timeString = Timing.GetTimeString(racer.RaceTime);
        GUIStyle timeStyle  = new GUIStyle(GUI.skin.label);

        timeStyle.fontSize  = 48;
        timeStyle.alignment = TextAnchor.UpperCenter;

        GUIX.ShadowLabel(timeRect, timeString, timeStyle, 3);
        GUI.Label(timeRect, timeString, timeStyle);

        //Finished text
        if (racer.finished)
        {
            Rect     finishedRect  = new Rect(Screen.width / 2 - 200, Screen.height - 102, 400, 80);
            GUIStyle finishedStyle = new GUIStyle(timeStyle);
            finishedStyle.fontSize = 24;
            GUIX.ShadowLabel(finishedRect, "Race finished", finishedStyle, 2);
            GUI.Label(finishedRect, "Race finished", finishedStyle);
        }

        //Player position
        Rect     playerPosRect   = new Rect(Screen.width - 420, Screen.height - 120, 400, 120);
        string   playerPosString = racer.GetPositionString();
        GUIStyle playerPosStyle  = new GUIStyle(GUI.skin.label);

        playerPosStyle.fontSize  = 86;
        playerPosStyle.fontStyle = FontStyle.Bold;
        playerPosStyle.alignment = TextAnchor.UpperRight;
        if (FindObjectOfType <MlgMode>() && racer.position == 1)
        {
            playerPosString = "#REKT";
        }

        GUIX.ShadowLabel(playerPosRect, playerPosString, playerPosStyle, 4);
        GUI.Label(playerPosRect, playerPosString, playerPosStyle);
    }
Exemplo n.º 28
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();
        }
    }
Exemplo n.º 29
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);
        }
    }
Exemplo n.º 30
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();
    }