Example #1
0
        /// <summary>
        ///     Draws a <see cref="MenuBool" />
        /// </summary>
        public override void Draw()
        {
            var centerY =
                (int)
                ColoredUtilities.GetContainerRectangle(this.Component)
                .GetCenteredText(
                    null,
                    MenuSettings.Font,
                    MultiLanguage.Translation(this.Component.DisplayName),
                    CenteredFlags.VerticalCenter)
                .Y;

            MenuSettings.Font.DrawText(
                MenuManager.Instance.Sprite,
                MultiLanguage.Translation(this.Component.DisplayName),
                (int)(this.Component.Position.X + MenuSettings.ContainerTextOffset),
                centerY,
                MenuSettings.TextColor);

            var centerX =
                (int)
                new Rectangle(
                    (int)(this.Component.Position.X + this.Component.MenuWidth - MenuSettings.ContainerHeight),
                    (int)this.Component.Position.Y,
                    MenuSettings.ContainerHeight,
                    MenuSettings.ContainerHeight).GetCenteredText(
                    null,
                    MenuSettings.Font,
                    this.Component.Value ? "On" : "Off",
                    CenteredFlags.HorizontalCenter).X - 5;

            //Left
            Utils.DrawCircle(
                centerX,
                this.Component.Position.Y + MenuSettings.ContainerHeight / 2f,
                7,
                270,
                Utils.CircleType.Half,
                true,
                32,
                MenuSettings.TextColor);

            //Right
            Utils.DrawCircle(
                centerX + 15,
                this.Component.Position.Y + MenuSettings.ContainerHeight / 2f,
                7,
                90,
                Utils.CircleType.Half,
                true,
                32,
                MenuSettings.TextColor);

            //Top
            Line.Width = 1;
            Line.Begin();
            Line.Draw(
                new[]
            {
                new Vector2(centerX, this.Component.Position.Y + MenuSettings.ContainerHeight / 2f - 8),
                new Vector2(centerX + 15, this.Component.Position.Y + MenuSettings.ContainerHeight / 2f - 8)
            },
                MenuSettings.TextColor);
            Line.End();

            //Bot
            Line.Width = 1;
            Line.Begin();
            Line.Draw(
                new[]
            {
                new Vector2(centerX, this.Component.Position.Y + MenuSettings.ContainerHeight / 2f + 7),
                new Vector2(centerX + 15, this.Component.Position.Y + MenuSettings.ContainerHeight / 2f + 7)
            },
                MenuSettings.TextColor);
            Line.End();

            //FullCircle
            Utils.DrawCircleFilled(
                this.Component.Value ? centerX + 14 : centerX + 1,
                this.Component.Position.Y + MenuSettings.ContainerHeight / 2f,
                6,
                0,
                Utils.CircleType.Full,
                true,
                32,
                this.Component.Value ? MenuSettings.ContainerSelectedColor : MenuSettings.TextColor);
        }
        /// <summary>
        ///     Draws a <see cref="MenuSlider" />
        /// </summary>
        public override void Draw()
        {
            //Slider

            var position  = this.Component.Position;
            var centeredY =
                (int)
                ColoredUtilities.GetContainerRectangle(this.Component)
                .GetCenteredText(
                    null,
                    MenuSettings.Font,
                    (this.Component.DisplayName),
                    CenteredFlags.VerticalCenter)
                .Y;
            var percent = (this.Component.SValue - this.Component.MinValue)
                          / (float)(this.Component.MaxValue - this.Component.MinValue);
            var x = position.X + Offset
                    + (percent * (this.Component.MenuWidth - Offset * 2 - MenuSettings.ContainerHeight));
            var maxX = position.X + Offset + ((this.Component.MenuWidth - Offset * 2 - MenuSettings.ContainerHeight));

            MenuManager.Instance.DrawDelayed(
                delegate
            {
                Utils.DrawCircleFilled(
                    x,
                    position.Y + MenuSettings.ContainerHeight / 1.5f + 3,
                    4,
                    0,
                    Utils.CircleType.Full,
                    true,
                    32,
                    MenuSettings.ContainerSelectedColor);
            });

            MenuSettings.Font.DrawText(
                MenuManager.Instance.Sprite,
                (this.Component.DisplayName),
                (int)(position.X + MenuSettings.ContainerTextOffset),
                (int)(position.Y + (centeredY - position.Y) / 2),
                MenuSettings.TextColor);

            var measureText = MenuSettings.Font.MeasureText(
                null,
                this.Component.SValue.ToString(CultureInfo.InvariantCulture),
                0);

            MenuSettings.Font.DrawText(
                MenuManager.Instance.Sprite,
                (this.Component.SValue.ToString(CultureInfo.InvariantCulture)),
                (int)(position.X + this.Component.MenuWidth - measureText.Width - Offset - MenuSettings.ContainerHeight),
                (int)(position.Y + (centeredY - position.Y) / 2),
                MenuSettings.TextColor);

            Line.Width = 2;
            Line.Begin();
            Line.Draw(
                new[]
            {
                new Vector2(position.X + Offset, position.Y + MenuSettings.ContainerHeight / 1.5f + 3),
                new Vector2(maxX, position.Y + MenuSettings.ContainerHeight / 1.5f + 3)
            },
                new ColorBGRA(193, 189, 188, 255));
            Line.End();

            Line.Width = 2;
            Line.Begin();
            Line.Draw(
                new[]
            {
                new Vector2(position.X + Offset, position.Y + MenuSettings.ContainerHeight / 1.5f + 3),
                new Vector2(x, position.Y + MenuSettings.ContainerHeight / 1.5f + 3)
            },
                MenuSettings.ContainerSelectedColor);
            Line.End();

            //On / Off Button

            var centerX =
                (int)
                new Rectangle(
                    (int)(this.Component.Position.X + this.Component.MenuWidth - MenuSettings.ContainerHeight),
                    (int)this.Component.Position.Y,
                    MenuSettings.ContainerHeight,
                    MenuSettings.ContainerHeight).GetCenteredText(
                    null,
                    MenuSettings.Font,
                    this.Component.BValue ? "On" : "Off",
                    CenteredFlags.HorizontalCenter).X - 5;

            //Left
            Utils.DrawCircle(
                centerX,
                this.Component.Position.Y + MenuSettings.ContainerHeight / 2f,
                7,
                270,
                Utils.CircleType.Half,
                true,
                32,
                MenuSettings.TextColor);

            //Right
            Utils.DrawCircle(
                centerX + 15,
                this.Component.Position.Y + MenuSettings.ContainerHeight / 2f,
                7,
                90,
                Utils.CircleType.Half,
                true,
                32,
                MenuSettings.TextColor);

            //Top
            Line.Width = 1;
            Line.Begin();
            Line.Draw(
                new[]
            {
                new Vector2(centerX, this.Component.Position.Y + MenuSettings.ContainerHeight / 2f - 8),
                new Vector2(centerX + 15, this.Component.Position.Y + MenuSettings.ContainerHeight / 2f - 8)
            },
                MenuSettings.TextColor);
            Line.End();

            //Bot
            Line.Width = 1;
            Line.Begin();
            Line.Draw(
                new[]
            {
                new Vector2(centerX, this.Component.Position.Y + MenuSettings.ContainerHeight / 2f + 7),
                new Vector2(centerX + 15, this.Component.Position.Y + MenuSettings.ContainerHeight / 2f + 7)
            },
                MenuSettings.TextColor);
            Line.End();

            //FullCircle
            Utils.DrawCircleFilled(
                this.Component.BValue ? centerX + 14 : centerX + 1,
                this.Component.Position.Y + MenuSettings.ContainerHeight / 2f,
                6,
                0,
                Utils.CircleType.Full,
                true,
                32,
                this.Component.BValue ? MenuSettings.ContainerSelectedColor : MenuSettings.TextColor);
        }