예제 #1
0
        protected override void DoDraw(IBatchRenderer sbatch, FRectangle bounds)
        {
            var bottomrect = bounds.ToSubRectangleSouth(25);

            {             // background
                SimpleRenderHelper.DrawSimpleRect(sbatch, bounds, FlatColors.Clouds);
                SimpleRenderHelper.DrawSimpleRect(sbatch, bottomrect, FlatColors.Concrete);
            }

            {             // name
                FontRenderHelper.DrawTextVerticallyCentered(sbatch, Textures.HUDFontBold, 32, _meta?.LevelName ?? _level?.FullName, (_meta == null) ? FlatColors.Silver : FlatColors.Foreground, new FPoint(bounds.Left + 5 + 32 + 5, bounds.Top + (bounds.Height - 25) / 2));
            }

            {             // user
                sbatch.DrawCentered(Textures.TexHUDIconGenericUser, new FPoint(bottomrect.Left + 5 + 32 + 5, bottomrect.CenterY), 20, 20, (_meta == null) ? FlatColors.Silver : FlatColors.WetAsphalt);
                FontRenderHelper.DrawTextVerticallyCentered(sbatch, Textures.HUDFontBold, 20, (_meta == null) ? L10N.T(L10NImpl.STR_INF_YOU) : (_meta.Username ?? "Unknown"), (_meta == null) ? FlatColors.Silver : FlatColors.Foreground, new FPoint(bounds.Left + 5 + 32 + 5 + 16, bounds.Bottom - 12.5f));
            }


            if ((_meta != null) && _meta.GridSize != SCCMLevelData.SIZES[0])             // [XL] marker
            {
                var rr = bounds.ToSubRectangleSouthWest(32, 20);
                SimpleRenderHelper.DrawSimpleRect(sbatch, rr, FlatColors.Amethyst);
                FontRenderHelper.DrawSingleLineInBox(sbatch, Textures.HUDFontRegular, "XL", rr, 0, true, FlatColors.Foreground);
            }

            {             // star counter
                var pointPos = new FPoint(bottomrect.Right - 100, bottomrect.CenterY);
                sbatch.DrawCentered(Textures.TexIconStar, pointPos, 20, 20, FlatColors.SunFlower);
                FontRenderHelper.DrawTextVerticallyCentered(sbatch, Textures.HUDFontBold, 24, (_meta == null) ? "???" : _meta.Stars.ToString(), (_meta == null) ? FlatColors.Silver : FlatColors.MidnightBlue, pointPos + new Vector2(16, 0));
            }

            SimpleRenderHelper.DrawSimpleRectOutline(sbatch, bounds, HUD.PixelWidth, Color.Black);
        }
예제 #2
0
 protected void DrawPlaceholder(IBatchRenderer sbatch, FRectangle bounds, float leftOffset, float rightOffset)
 {
     FontRenderHelper.DrawTextVerticallyCentered(
         sbatch,
         Font,
         FontSize,
         Placeholder,
         ColorPlaceholder,
         new FPoint(bounds.X + leftOffset, bounds.Y + bounds.Height / 2));
 }
        protected override void DoDraw(IBatchRenderer sbatch, FRectangle bounds)
        {
            sbatch.FillRectangle(bounds, _colSource.Background);

            float rowHeight = _colSource.FontSize + 2 * _colSource.LineWidth;

            // rows
            {
                float x = 0;
                for (int ci = 0; ci < _data.Count; ci++)
                {
                    if (FloatMath.IsZero(_colSource.GetColumnWidth(ci)))
                    {
                        continue;
                    }

                    FontRenderHelper.DrawTextVerticallyCentered(
                        sbatch,
                        _colSource.Font,
                        _colSource.FontSize,
                        _data[ci],
                        Foreground,
                        new FPoint(bounds.Left + x + _colSource.LineWidth * 2, bounds.Top + rowHeight / 2f));

                    x += _colSource.GetColumnWidth(ci);
                }
            }

            // scroll
            {
                sbatch.FillRectangle(new FRectangle(bounds.Right - _colSource.ScrollWidth, bounds.Top, _colSource.ScrollWidth, bounds.Height), _colSource.ScrollThumbColor);
            }

            // Vert Lines
            {
                float x = 0;
                for (int i = 0; i < _data.Count; i++)
                {
                    x += _colSource.GetColumnWidth(i);
                    sbatch.DrawLine(bounds.Left + x, bounds.Top, bounds.Left + x, bounds.Bottom, _colSource.LineColor, _colSource.LineWidth);
                }
            }

            sbatch.DrawRectangle(bounds, _colSource.LineColor, _colSource.LineWidth);
        }
예제 #4
0
        protected void DrawText(IBatchRenderer sbatch, FRectangle bounds, float leftOffset, float rightOffset)
        {
            var maxWidth = bounds.Width - leftOffset - rightOffset - CursorWidth - Font.Spacing;
            var dispText = Text;

            if (IsPassword)
            {
                if (_forceShowLastChar && dispText.Length > 0)
                {
                    dispText = new string('*', dispText.Length - 1) + dispText[dispText.Length - 1];
                }
                else
                {
                    dispText = new string('*', dispText.Length);
                }
            }

            var textBounds = FontRenderHelper.MeasureStringCached(Font, dispText, FontSize);

            while (dispText.Length > 0 && textBounds.Width > maxWidth)
            {
                dispText   = Text.Substring(1);
                textBounds = FontRenderHelper.MeasureStringCached(Font, dispText, FontSize);
            }

            FontRenderHelper.DrawTextVerticallyCentered(
                sbatch,
                Font,
                FontSize,
                dispText,
                ColorText,
                new FPoint(bounds.X + leftOffset, bounds.Y + bounds.Height / 2));

            if (IsFocused && (int)(_cursorBlinkTimer / CURSOR_BLINK_TIME) % 2 == 0)
            {
                SimpleRenderHelper.DrawSimpleRect(
                    sbatch,
                    new FRectangle(
                        bounds.X + leftOffset + textBounds.Width + Font.Spacing,
                        bounds.Y + bounds.Height / 2 - FontSize / 2,
                        CursorWidth,
                        FontSize),
                    ColorText);
            }
        }
예제 #5
0
        private void DrawInfoLine(IBatchRenderer sbatch, FractionDifficulty d, int idx, string strTime, bool colorize)
        {
            var p1 = Position + new Vector2(32, HEADER_HEIGHT + 40 + 56 * idx);
            var p2 = Position + new Vector2(64, HEADER_HEIGHT + 40 + 56 * idx);
            var p3 = Position + new Vector2(224, HEADER_HEIGHT + 40 + 56 * idx);

            var ic = (node.LevelData.HasCompletedOrBetter(d) ? FractionDifficultyHelper.GetColor(d) : FlatColors.Concrete) * progressDisplay;
            var tc = (node.LevelData.HasCompletedOrBetter(d) ? FlatColors.TextHUD : FlatColors.Asbestos) * progressDisplay;

            if (colorize && node.LevelData.Data[d].GlobalBestUserID >= 0 && node.LevelData.Data[d].GlobalBestUserID == MainGame.Inst.Profile.OnlineUserID)
            {
                tc = FlatColors.SunFlower * progressDisplay;
            }

            sbatch.DrawCentered(Textures.TexCircle, p1, 48, 48, FlatColors.WetAsphalt * progressDisplay);
            sbatch.DrawCentered(FractionDifficultyHelper.GetIcon(d), p1, 32, 32, ic);
            FontRenderHelper.DrawTextVerticallyCentered(sbatch, Textures.HUDFontRegular, 32, FractionDifficultyHelper.GetDescription(d), tc, p2);
            FontRenderHelper.DrawTextVerticallyCentered(sbatch, Textures.HUDFontRegular, 32, strTime, tc, p3);
        }
        protected override void DoDraw(IBatchRenderer sbatch, FRectangle bounds)
        {
            var bottomrect = bounds.ToSubRectangleSouth(25);

            SimpleRenderHelper.DrawSimpleRect(sbatch, bounds, FlatColors.Clouds);
            SimpleRenderHelper.DrawSimpleRect(sbatch, bottomrect, FlatColors.Concrete);

            FontRenderHelper.DrawTextVerticallyCentered(sbatch, Textures.HUDFontBold, 32, _data.Name, FlatColors.Foreground, new FPoint(bounds.Left + 5 + 32 + 5, bounds.Top + (bounds.Height - 25) / 2));
            FontRenderHelper.DrawTextVerticallyCentered(sbatch, Textures.HUDFontBold, 20, MainGame.Inst.Profile.OnlineUsername, FlatColors.Foreground, new FPoint(bounds.Left + 5 + 32 + 5 + 16, bounds.Bottom - 12.5f));

            sbatch.DrawCentered(Textures.TexHUDIconGenericUser, new FPoint(bottomrect.Left + 5 + 32 + 5, bottomrect.CenterY), 20, 20, FlatColors.WetAsphalt);

            if (_data.Size != SCCMLevelData.SIZES[0])
            {
                var rr = bounds.ToSubRectangleSouthWest(32, 20);
                SimpleRenderHelper.DrawSimpleRect(sbatch, rr, FlatColors.Amethyst);
                FontRenderHelper.DrawSingleLineInBox(sbatch, Textures.HUDFontRegular, "XL", rr, 0, true, FlatColors.Foreground);
            }

            SimpleRenderHelper.DrawSimpleRectOutline(sbatch, bounds, HUD.PixelWidth, Color.Black);
        }
예제 #7
0
        protected override void DoDraw(IBatchRenderer sbatch, FRectangle bounds)
        {
            var bottomrect = bounds.ToSubRectangleSouth(25);

            {             // background
                SimpleRenderHelper.DrawSimpleRect(sbatch, bounds, FlatColors.Clouds);
                SimpleRenderHelper.DrawSimpleRect(sbatch, bottomrect, FlatColors.Concrete);
            }

            {             // difficulty
                var tex = (PersonalBest == null) ? Textures.TexDifficultyLineNone : FractionDifficultyHelper.GetIcon(PersonalBest.Value);
                var col = (PersonalBest == null) ? FlatColors.Silver : FractionDifficultyHelper.GetColor(PersonalBest.Value);
                sbatch.DrawCentered(tex, new FPoint(bounds.Left + 5 + 16, bounds.Top + (Height - 25 - 32) / 2 + 16), 32, 32, col);
            }

            {             // name
                FontRenderHelper.DrawTextVerticallyCentered(sbatch, Textures.HUDFontBold, 32, _meta.LevelName, FlatColors.Foreground, new FPoint(bounds.Left + 5 + 32 + 5, bounds.Top + (bounds.Height - 25) / 2));
            }

            {             // user
                sbatch.DrawCentered(Textures.TexHUDIconGenericUser, new FPoint(bottomrect.Left + 5 + 32 + 5, bottomrect.CenterY), 20, 20, FlatColors.WetAsphalt);
                FontRenderHelper.DrawTextVerticallyCentered(sbatch, Textures.HUDFontBold, 20, _meta.Username ?? "Unknown", FlatColors.Foreground, new FPoint(bounds.Left + 5 + 32 + 5 + 16, bounds.Bottom - 12.5f));
            }


            if (_meta.GridSize != SCCMLevelData.SIZES[0])             // [XL] marker
            {
                var rr = bounds.ToSubRectangleSouthWest(32, 20);
                SimpleRenderHelper.DrawSimpleRect(sbatch, rr, FlatColors.Amethyst);
                FontRenderHelper.DrawSingleLineInBox(sbatch, Textures.HUDFontRegular, "XL", rr, 0, true, FlatColors.Foreground);
            }

            {             // star counter
                var pointPos = new FPoint(bottomrect.Right - 100, bottomrect.CenterY);
                sbatch.DrawCentered(Textures.TexIconStar, pointPos, 20, 20, FlatColors.SunFlower);
                FontRenderHelper.DrawTextVerticallyCentered(sbatch, Textures.HUDFontBold, 24, _meta.Stars.ToString(), FlatColors.MidnightBlue, pointPos + new Vector2(16, 0));
            }

            SimpleRenderHelper.DrawSimpleRectOutline(sbatch, bounds, HUD.PixelWidth, Color.Black);
        }
예제 #8
0
        protected override void DoDraw(IBatchRenderer sbatch, FRectangle bounds)
        {
            var radiusOuter = Height / 2f;
            var radiusInner = radiusOuter * KNOB_SCALE;

            var knobPosition = new FPoint(bounds.Left + radiusOuter + (Width - 2 * radiusOuter) * _knobPosition, bounds.CenterY);
            var knobColor    = ColorMath.Blend(ColorStateOff, ColorStateOn, _knobPosition);

            var textHeight = Height / 2;

            // Background
            SimpleRenderHelper.DrawRoundedRect(sbatch, bounds, ColorBackground, radiusOuter);

            // Text[On]
            if (!string.IsNullOrWhiteSpace(TextStateOn) && _knobPosition > 0)
            {
                var pos   = new FPoint(bounds.Left + radiusOuter / 2, bounds.CenterY);
                var alpha = FloatMath.Clamp(1.5f * _knobPosition, 0f, 1f);
                if (alpha > 0)
                {
                    FontRenderHelper.DrawTextVerticallyCentered(sbatch, Font, textHeight, TextStateOn, FontColor * alpha, pos);
                }
            }

            // Text[Off]
            if (!string.IsNullOrWhiteSpace(TextStateOff) && _knobPosition < 1)
            {
                var pos   = new FPoint(bounds.Right - radiusOuter / 2, bounds.CenterY);
                var alpha = FloatMath.Clamp(1 - 1.5f * _knobPosition, 0f, 1f);
                if (alpha > 0)
                {
                    FontRenderHelper.DrawTextVerticallyCenteredRightAligned(sbatch, Font, textHeight, TextStateOff, FontColor * alpha, pos);
                }
            }

            // Knob
            sbatch.DrawCentered(StaticTextures.MonoCircle, knobPosition, radiusInner * 2, radiusInner * 2, knobColor);
        }
예제 #9
0
        protected override void DoDraw(IBatchRenderer sbatch, FRectangle bounds)
        {
            if (_needsTabRecalc)
            {
                RecalcTabData();
            }

            sbatch.FillRectangle(bounds, Background);

            float rowHeight = FontSize + 2 * LineWidth;
            float py        = 0;

            // Header
            {
                sbatch.FillRectangle(new FRectangle(bounds.X, bounds.Y, bounds.Width - ScrollWidth, rowHeight), HeaderBackground);
                float x = 0;
                for (int i = 0; i < _columns.Count; i++)
                {
                    if (FloatMath.IsZero(_columns[i].RealWidth))
                    {
                        continue;
                    }

                    FontRenderHelper.DrawTextCentered(
                        sbatch,
                        Font,
                        FontSize,
                        _columns[i].Text,
                        HeaderForeground,
                        new FPoint(bounds.Left + x + _columns[i].RealWidth / 2f, bounds.Top + rowHeight / 2f));

                    x += _columns[i].RealWidth;
                }
                sbatch.DrawLine(bounds.Left, bounds.Top + rowHeight, bounds.Right - ScrollWidth, bounds.Top + rowHeight, LineColor, LineWidth);

                py += rowHeight;
            }

            // rows
            for (int di = (int)ScrollPosition; di < _data.Count; di++)
            {
                if (py + rowHeight > Height)
                {
                    break;
                }

                float x = 0;
                for (int ci = 0; ci < _columns.Count; ci++)
                {
                    if (FloatMath.IsZero(_columns[ci].RealWidth))
                    {
                        continue;
                    }

                    FontRenderHelper.DrawTextVerticallyCentered(
                        sbatch,
                        Font,
                        FontSize,
                        _data[di].Data[ci],
                        _data[di].ForegroundOverride ?? Foreground,
                        new FPoint(bounds.Left + x + LineWidth * 2, bounds.Top + py + rowHeight / 2f));

                    x += _columns[ci].RealWidth;
                }
                sbatch.DrawLine(bounds.Left, bounds.Top + py + rowHeight, bounds.Right - ScrollWidth, bounds.Top + py + rowHeight, LineColor, LineWidth);

                py += rowHeight;
            }

            // scroll
            {
                var colPerPage = (int)(Height / rowHeight) - 1;
                var perc       = FloatMath.Clamp(((int)ScrollPosition) / (1f * _data.Count - colPerPage), 0, 1);

                var pos = perc * (Height - ScrollHeight);

                sbatch.FillRectangle(new FRectangle(bounds.Right - ScrollWidth, bounds.Top + pos, ScrollWidth, ScrollHeight), ScrollThumbColor);
            }

            // Vert Lines
            {
                float x = 0;
                for (int i = 0; i < _columns.Count; i++)
                {
                    x += _columns[i].RealWidth;
                    sbatch.DrawLine(bounds.Left + x, bounds.Top, bounds.Left + x, bounds.Bottom, LineColor, LineWidth);
                }
            }

            sbatch.DrawRectangle(bounds, LineColor, LineWidth);
        }