Пример #1
0
 /// <summary>
 ///     Gets the width of the MenuKeyBind
 /// </summary>
 /// <returns>The <see cref="int" /></returns>
 public override int Width()
 {
     return(LightUtilities.CalcWidthItem(this.Component)
            + (int)
            (MenuSettings.ContainerHeight + LightUtilities.CalcWidthText("[" + this.Component.Key + "]")
             + MenuSettings.ContainerTextOffset));
 }
Пример #2
0
 /// <summary>
 ///     Calculates the Width of an AMenuComponent
 /// </summary>
 /// <returns>
 ///     The width.
 /// </returns>
 public override int Width()
 {
     return
         ((int)
          (LightUtilities.MeasureString(this.Component.DisplayName + " »").Width
           + (MenuSettings.ContainerTextOffset * 2) + MenuSettings.ContainerTextMarkWidth));
 }
Пример #3
0
        /// <summary>
        ///     Draws a <see cref="MenuBool" />
        /// </summary>
        public override void Draw()
        {
            var centerY =
                (int)
                LightUtilities.GetContainerRectangle(this.Component)
                .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter)
                .Y;

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

            Line.Width = MenuSettings.ContainerHeight - 7;
            Line.Begin();
            Line.Draw(
                new[]
            {
                new Vector2(
                    (this.Component.Position.X + this.Component.MenuWidth - MenuSettings.ContainerHeight - 1)
                    + MenuSettings.ContainerHeight / 2f,
                    this.Component.Position.Y + 1 + 3),
                new Vector2(
                    (this.Component.Position.X + this.Component.MenuWidth - MenuSettings.ContainerHeight - 1)
                    + MenuSettings.ContainerHeight / 2f,
                    this.Component.Position.Y + MenuSettings.ContainerHeight - 3)
            },
                this.Component.Value ? new ColorBGRA(68, 160, 255, 255) : new ColorBGRA(151, 151, 151, 255));
            Line.End();

            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;

            MenuSettings.Font.DrawText(
                MenuManager.Instance.Sprite,
                this.Component.Value ? "On" : "Off",
                centerX,
                centerY,
                new ColorBGRA(221, 233, 255, 255));
        }
Пример #4
0
        /// <summary>
        ///     Draws a <see cref="MenuSlider" />
        /// </summary>
        public override void Draw()
        {
            var position  = this.Component.Position;
            var centeredY =
                (int)
                LightUtilities.GetContainerRectangle(this.Component)
                .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter)
                .Y;
            var percent = (this.Component.Value - this.Component.MinValue)
                          / (float)(this.Component.MaxValue - this.Component.MinValue);
            var x = position.X + Offset + (percent * (this.Component.MenuWidth - Offset * 2));

            Line.Width = 3;
            Line.Begin();
            Line.Draw(
                new[] { new Vector2(x, position.Y + 1), new Vector2(x, position.Y + MenuSettings.ContainerHeight) },
                this.Component.Interacting ? new ColorBGRA(90, 129, 144, 255) : new ColorBGRA(94, 170, 246, 255));
            Line.End();

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

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

            MenuSettings.Font.DrawText(
                MenuManager.Instance.Sprite,
                this.Component.Value.ToString(CultureInfo.InvariantCulture),
                (int)(position.X + this.Component.MenuWidth - 5 - measureText.Width),
                centeredY,
                MenuSettings.TextColor);

            Line.Width = MenuSettings.ContainerHeight;
            Line.Begin();
            Line.Draw(
                new[]
            {
                new Vector2(position.X + Offset, position.Y + MenuSettings.ContainerHeight / 2f),
                new Vector2(x, position.Y + MenuSettings.ContainerHeight / 2f)
            },
                LightMenuSettings.SliderColor);
            Line.End();
        }
Пример #5
0
        /// <summary>
        ///     Draw a <see cref="MenuSeparator" />
        /// </summary>
        public override void Draw()
        {
            var centerY = LightUtilities.GetContainerRectangle(this.Component)
                          .GetCenteredText(
                null,
                MenuSettings.Font,
                this.Component.DisplayName,
                CenteredFlags.VerticalCenter | CenteredFlags.HorizontalCenter);

            LightMenuSettings.FontCaption.DrawText(
                MenuManager.Instance.Sprite,
                this.Component.DisplayName,
                (int)centerY.X,
                (int)centerY.Y,
                LightMenuSettings.TextCaptionColor);
        }
Пример #6
0
        /// <summary>
        ///     Draws a <see cref="MenuButton" />
        /// </summary>
        public override void Draw()
        {
            var rectangleName = LightUtilities.GetContainerRectangle(this.Component)
                                .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter);

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

            var buttonTextWidth =
                MenuSettings.Font.MeasureText(MenuManager.Instance.Sprite, this.Component.ButtonText, 0).Width;

            Line.Width = MenuSettings.ContainerHeight - 5;
            Line.Begin();
            Line.Draw(
                new[]
            {
                new Vector2(
                    this.Component.Position.X + this.Component.MenuWidth - buttonTextWidth - (2 * TextGap) + 2,
                    this.Component.Position.Y + (MenuSettings.ContainerHeight / 2f)),
                new Vector2(
                    this.Component.Position.X + this.Component.MenuWidth - 2,
                    this.Component.Position.Y + (MenuSettings.ContainerHeight / 2f)),
            },
                this.Component.Hovering ? this.buttonHoverColor : this.buttonColor);
            Line.End();

            MenuSettings.Font.DrawText(
                MenuManager.Instance.Sprite,
                this.Component.ButtonText,
                (int)(this.Component.Position.X + this.Component.MenuWidth - buttonTextWidth - TextGap),
                (int)rectangleName.Y,
                new ColorBGRA(221, 233, 255, 255));
        }
Пример #7
0
 /// <summary>
 ///     Calculates the Width of a <see cref="MenuBool" />
 /// </summary>
 /// <returns>
 ///     The width.
 /// </returns>
 public override int Width()
 {
     return(LightUtilities.CalcWidthItem(this.Component) + MenuSettings.ContainerHeight);
 }
Пример #8
0
 /// <summary>
 ///     Calculates the Width of an AMenuComponent
 /// </summary>
 /// <returns>
 ///     The width.
 /// </returns>
 public override int Width()
 {
     return(LightUtilities.CalcWidthItem(this.Component));
 }
Пример #9
0
 /// <summary>
 ///     Gets the boundaries
 /// </summary>
 /// <param name="component">The <see cref="MenuSlider" /></param>
 /// <returns>The <see cref="Rectangle" /></returns>
 public Rectangle Bounding(MenuSlider component)
 {
     return(LightUtilities.GetContainerRectangle(component));
 }
Пример #10
0
 /// <summary>
 ///     Gets the additional boundaries.
 /// </summary>
 /// <param name="component">The <see cref="MenuSlider" /></param>
 /// <returns>The <see cref="Rectangle" /></returns>
 public Rectangle AdditionalBoundries(MenuSlider component)
 {
     return(LightUtilities.GetContainerRectangle(component));
 }
Пример #11
0
        /// <summary>
        ///     Draws a MenuColor
        /// </summary>
        public override void Draw()
        {
            var rectangleName = LightUtilities.GetContainerRectangle(this.Component)
                                .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter);

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

            Line.Width = MenuSettings.ContainerHeight - 7;
            Line.Begin();
            Line.Draw(
                new[]
            {
                new Vector2(
                    this.Component.Position.X + this.Component.MenuWidth - (Line.Width / 2f) - 4,
                    this.Component.Position.Y + 1 + 3),
                new Vector2(
                    this.Component.Position.X + this.Component.MenuWidth - (Line.Width / 2f) - 4,
                    this.Component.Position.Y + Line.Width + 3)
            },
                this.Component.Color);
            Line.End();
            if (this.Component.HoveringPreview)
            {
                Line.Begin();
                Line.Draw(
                    new[]
                {
                    new Vector2(
                        this.Component.Position.X + this.Component.MenuWidth - (Line.Width / 2f) - 4,
                        this.Component.Position.Y + 1 + 3),
                    new Vector2(
                        this.Component.Position.X + this.Component.MenuWidth - (Line.Width / 2f) - 4,
                        this.Component.Position.Y + Line.Width + 3)
                },
                    MenuSettings.HoverColor);
                Line.End();
            }

            if (this.Component.Active)
            {
                MenuManager.Instance.DrawDelayed(
                    delegate
                {
                    Line.Width = ColorPickerBoundaries().Width;
                    Line.Begin();
                    Line.Draw(
                        new[]
                    {
                        new Vector2(ColorPickerBoundaries().X + 165, ColorPickerBoundaries().Y),
                        new Vector2(
                            ColorPickerBoundaries().X + 165,
                            ColorPickerBoundaries().Y + ColorPickerBoundaries().Height)
                    },
                        MenuSettings.RootContainerColor);
                    Line.End();

                    colorBox.DrawControl(new Vector2(ColorBoxBoundaries().X, ColorBoxBoundaries().Y));
                    verticalColorSlider.DrawControl(
                        new Vector2(VerticalColorSliderBoundaries().X, VerticalColorSliderBoundaries().Y));
                    verticalAlphaSlider.DrawControl(
                        new Vector2(VerticalAlphaSliderBoundaries().X, VerticalAlphaSliderBoundaries().Y));

                    Utils.DrawBoxFilled(
                        PreviewBoundaries().X,
                        PreviewBoundaries().Y,
                        PreviewBoundaries().Width,
                        PreviewBoundaries().Height,
                        Color.Black);

                    Utils.DrawBoxFilled(
                        PreviewBoundaries().X,
                        PreviewBoundaries().Y,
                        PreviewBoundaries().Width,
                        PreviewBoundaries().Height,
                        colorBox.Rgb.ToSharpDxColor());

                    var applyButtonTextWidth =
                        MenuSettings.Font.MeasureText(MenuManager.Instance.Sprite, "Apply", 0).Width;
                    var cancelButtonTextWidth =
                        MenuSettings.Font.MeasureText(MenuManager.Instance.Sprite, "Cancel", 0).Width;

                    Line.Width = ApplyButtonBoundaries().Width;
                    Line.Begin();
                    Line.Draw(
                        new[]
                    {
                        new Vector2(ApplyButtonBoundaries().X + 25, ApplyButtonBoundaries().Y),
                        new Vector2(
                            ApplyButtonBoundaries().X + 25,
                            ApplyButtonBoundaries().Y + ApplyButtonBoundaries().Height)
                    },
                        new ColorBGRA(68, 160, 255, 255));
                    Line.End();

                    MenuSettings.Font.DrawText(
                        MenuManager.Instance.Sprite,
                        "Apply",
                        ApplyButtonBoundaries().X - applyButtonTextWidth / 2 + 25,
                        (int)
                        CancelButtonBoundaries()
                        .GetCenteredText(null, MenuSettings.Font, "Apply", CenteredFlags.VerticalCenter)
                        .Y,
                        new ColorBGRA(221, 233, 255, 255));

                    Line.Width = CancelButtonBoundaries().Width;
                    Line.Begin();
                    Line.Draw(
                        new[]
                    {
                        new Vector2(CancelButtonBoundaries().X + 25, CancelButtonBoundaries().Y),
                        new Vector2(
                            CancelButtonBoundaries().X + 25,
                            CancelButtonBoundaries().Y + CancelButtonBoundaries().Height)
                    },
                        new ColorBGRA(68, 160, 255, 255));
                    Line.End();

                    MenuSettings.Font.DrawText(
                        MenuManager.Instance.Sprite,
                        "Cancel",
                        CancelButtonBoundaries().X - cancelButtonTextWidth / 2 + 25,
                        (int)
                        CancelButtonBoundaries()
                        .GetCenteredText(null, MenuSettings.Font, "Cancel", CenteredFlags.VerticalCenter)
                        .Y,
                        new ColorBGRA(221, 233, 255, 255));
                });
            }
        }
Пример #12
0
        /// <summary>
        ///     Draws an Menu
        /// </summary>
        public override void Draw()
        {
            var position = this.Component.Position;

            if (this.hovering && !this.Component.Toggled && this.Component.Components.Count > 0)
            {
                Line.Width = MenuSettings.ContainerHeight;
                Line.Begin();
                Line.Draw(
                    new[]
                {
                    new Vector2(position.X, position.Y + MenuSettings.ContainerHeight / 2f),
                    new Vector2(
                        position.X + this.Component.MenuWidth,
                        position.Y + MenuSettings.ContainerHeight / 2f)
                },
                    MenuSettings.HoverColor);
                Line.End();
            }

            var centerY =
                (int)
                LightUtilities.GetContainerRectangle(this.Component)
                .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter)
                .Y;

            if (this.Component.Toggled)
            {
                MenuSettings.Font.DrawText(
                    MenuManager.Instance.Sprite,
                    this.Component.DisplayName,
                    (int)(position.X + MenuSettings.ContainerTextOffset),
                    centerY,
                    new ColorBGRA(237, 245, 254, 255));

                MenuSettings.Font.DrawText(
                    MenuManager.Instance.Sprite,
                    "»",
                    (int)
                    (position.X + this.Component.MenuWidth - MenuSettings.ContainerTextMarkWidth
                     - MenuSettings.ContainerTextMarkOffset),
                    centerY,
                    this.Component.Components.Count > 0 ? new ColorBGRA(237, 245, 254, 255) : MenuSettings.ContainerSeparatorColor);
            }
            else
            {
                MenuSettings.Font.DrawText(
                    MenuManager.Instance.Sprite,
                    this.Component.DisplayName,
                    (int)(position.X + MenuSettings.ContainerTextOffset),
                    centerY,
                    MenuSettings.TextColor);

                MenuSettings.Font.DrawText(
                    MenuManager.Instance.Sprite,
                    "»",
                    (int)
                    (position.X + this.Component.MenuWidth - MenuSettings.ContainerTextMarkWidth
                     - MenuSettings.ContainerTextMarkOffset),
                    centerY,
                    this.Component.Components.Count > 0 ? MenuSettings.TextColor : MenuSettings.ContainerSeparatorColor);
            }

            if (this.Component.Toggled)
            {
                Line.Width = this.Component.MenuWidth;
                Line.Begin();
                Line.Draw(
                    new[]
                {
                    new Vector2(position.X + this.Component.MenuWidth / 2f, position.Y),
                    new Vector2(
                        position.X + this.Component.MenuWidth / 2f,
                        position.Y + MenuSettings.ContainerHeight)
                },
                    MenuSettings.ContainerSelectedColor);
                Line.End();

                float height = MenuSettings.ContainerHeight * this.Component.Components.Count;
                var   width  = MenuSettings.ContainerWidth;
                if (this.Component.Components.Count > 0)
                {
                    width = this.Component.Components.First().Value.MenuWidth;
                }

                Line.Width = width;
                Line.Begin();
                Line.Draw(
                    new[]
                {
                    new Vector2((position.X + this.Component.MenuWidth) + width / 2, position.Y),
                    new Vector2((position.X + this.Component.MenuWidth) + width / 2, position.Y + height)
                },
                    MenuSettings.RootContainerColor);
                Line.End();



                for (var i = 0; i < this.Component.Components.Count; ++i)
                {
                    var childComponent = this.Component.Components.Values.ToList()[i];
                    if (childComponent != null)
                    {
                        var childPos = new Vector2(
                            position.X + this.Component.MenuWidth,
                            position.Y + i * MenuSettings.ContainerHeight);

                        if (i < this.Component.Components.Count - 1)
                        {
                            Line.Width = 1f;
                            Line.Begin();
                            Line.Draw(
                                new[]
                            {
                                new Vector2(childPos.X + 15, childPos.Y + MenuSettings.ContainerHeight),
                                new Vector2(
                                    childPos.X - 15 + childComponent.MenuWidth,
                                    childPos.Y + MenuSettings.ContainerHeight)
                            },
                                MenuSettings.ContainerSeparatorColor);
                            Line.End();
                        }

                        childComponent.OnDraw(childPos);
                    }
                }

                var contourColor = new ColorBGRA(254, 255, 255, 255);

                Line.Width = 1f;
                Line.Begin();
                Line.Draw(
                    new[]
                {
                    new Vector2(position.X + this.Component.MenuWidth, position.Y),
                    new Vector2(position.X + this.Component.MenuWidth + width, position.Y)
                },
                    contourColor);
                Line.Draw(
                    new[]
                {
                    new Vector2(position.X + this.Component.MenuWidth, position.Y + height),
                    new Vector2(position.X + this.Component.MenuWidth + width, position.Y + height)
                },
                    contourColor);
                Line.Draw(
                    new[]
                {
                    new Vector2(position.X + this.Component.MenuWidth, position.Y),
                    new Vector2(position.X + this.Component.MenuWidth, position.Y + height)
                },
                    contourColor);
                Line.Draw(
                    new[]
                {
                    new Vector2(position.X + this.Component.MenuWidth + width, position.Y),
                    new Vector2(position.X + this.Component.MenuWidth + width, position.Y + height)
                },
                    contourColor);
                Line.End();
            }

            if (this.hasDragged && !MenuCustomizer.Instance.LockPosition.Value)
            {
                var sprite    = MenuManager.Instance.Sprite;
                var oldMatrix = sprite.Transform;
                var y         =
                    (int)(MenuSettings.Position.Y + (MenuManager.Instance.Menus.Count * MenuSettings.ContainerHeight));
                var dragTexture = LightTextures.Instance[LightTexture.Dragging];
                var x           = MenuSettings.Position.X - dragTexture.Width;
                sprite.Transform = Matrix.Translation(x - 1, y + 2, 0);
                sprite.Draw(dragTexture.Texture, Color.White);
                sprite.Transform = oldMatrix;

                Line.Width = 1f;
                Line.Begin();
                Line.Draw(
                    new[]
                {
                    new Vector2(x - 1, y + 1), new Vector2(x - 1 + dragTexture.Width, y + 1),
                    new Vector2(x - 1 + dragTexture.Width, y + dragTexture.Width + 2),
                    new Vector2(x - 2, y + dragTexture.Width + 2), new Vector2(x - 2, y),
                },
                    MenuSettings.ContainerSeparatorColor);
                Line.End();
            }
        }
Пример #13
0
 /// <summary>
 ///     Gets the <c>keybind</c> boundaries
 /// </summary>
 /// <param name="component">The <see cref="MenuKeyBind" /></param>
 /// <returns>The <see cref="Rectangle" /></returns>
 public Rectangle KeyBindBoundaries(MenuKeyBind component)
 {
     return(LightUtilities.GetContainerRectangle(component));
 }
Пример #14
0
 /// <summary>
 ///     Gets the width of the <see cref="MenuButton" />
 /// </summary>
 /// <returns>
 ///     The <see cref="int" />.
 /// </returns>
 public override int Width()
 {
     return(LightUtilities.CalcWidthItem(this.Component) + (2 * TextGap)
            + MenuSettings.Font.MeasureText(MenuManager.Instance.Sprite, this.Component.ButtonText, 0).Width);
 }
Пример #15
0
        /// <summary>
        ///     Draw a <see cref="MenuList" />
        /// </summary>
        public override void Draw()
        {
            var dropdownMenuWidth = this.dropDownButtonWidth + (2 * TextSpacing) + this.Component.MaxStringWidth;
            var position          = this.Component.Position;
            var rectangleName     = LightUtilities.GetContainerRectangle(this.Component)
                                    .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter);

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

            MenuSettings.Font.DrawText(
                MenuManager.Instance.Sprite,
                "\u23EC",
                (int)(position.X + this.Component.MenuWidth - this.dropDownButtonWidth + ArrowSpacing),
                (int)rectangleName.Y,
                MenuSettings.TextColor);

            MenuSettings.Font.DrawText(
                MenuManager.Instance.Sprite,
                this.Component.SelectedValueAsObject.ToString(),
                (int)position.X + this.Component.MenuWidth - this.dropDownButtonWidth - TextSpacing
                - this.Component.MaxStringWidth,
                (int)rectangleName.Y,
                this.Component.Active ? new ColorBGRA(0, 186, 255, 255) : MenuSettings.TextColor);
            Line.Width = 1f;
            Line.Begin();
            Line.Draw(
                new[]
            {
                new Vector2(
                    position.X + this.Component.MenuWidth - this.dropDownButtonWidth - (2 * TextSpacing)
                    - this.Component.MaxStringWidth,
                    position.Y + 5),
                new Vector2(
                    position.X + this.Component.MenuWidth - this.dropDownButtonWidth - (2 * TextSpacing)
                    - this.Component.MaxStringWidth,
                    position.Y + MenuSettings.ContainerHeight - 5)
            },
                MenuSettings.ContainerSeparatorColor);
            Line.End();

            if (this.Component.Active)
            {
                var valueStrings       = this.Component.ValuesAsStrings;
                var dropdownMenuHeight = valueStrings.Length * MenuSettings.ContainerHeight;
                MenuManager.Instance.DrawDelayed(
                    delegate
                {
                    var color         = MenuSettings.RootContainerColor;
                    var dropdownColor = new ColorBGRA(color.R, color.G, color.B, 255);
                    Line.Width        = dropdownMenuWidth;
                    Line.Begin();
                    Line.Draw(
                        new[]
                    {
                        new Vector2(
                            position.X + Component.MenuWidth - (Line.Width / 2),
                            position.Y + MenuSettings.ContainerHeight),
                        new Vector2(
                            position.X + Component.MenuWidth - (Line.Width / 2),
                            position.Y + MenuSettings.ContainerHeight + dropdownMenuHeight)
                    }, dropdownColor);
                    Line.End();

                    var x =
                        (int)
                        (position.X + Component.MenuWidth - dropDownButtonWidth - TextSpacing
                         - Component.MaxStringWidth);
                    var y = (int)rectangleName.Y;
                    for (var i = 0; i < valueStrings.Length; i++)
                    {
                        if (i == Component.HoveringIndex)
                        {
                            Line.Width = MenuSettings.ContainerHeight;
                            Line.Begin();
                            Line.Draw(
                                new[]
                            {
                                new Vector2(
                                    position.X + Component.MenuWidth - dropdownMenuWidth,
                                    position.Y + ((i + 1) * MenuSettings.ContainerHeight)
                                    + MenuSettings.ContainerHeight / 2f),
                                new Vector2(
                                    position.X + Component.MenuWidth,
                                    position.Y + ((i + 1) * MenuSettings.ContainerHeight)
                                    + MenuSettings.ContainerHeight / 2f)
                            },
                                MenuSettings.HoverColor);
                            Line.End();
                        }

                        Line.Width = 1f;
                        Line.Begin();
                        Line.Draw(
                            new[]
                        {
                            new Vector2(
                                position.X + Component.MenuWidth - dropdownMenuWidth + 10,
                                position.Y + (MenuSettings.ContainerHeight * (i + 1))),
                            new Vector2(
                                position.X + Component.MenuWidth - 10,
                                position.Y + (MenuSettings.ContainerHeight * (i + 1)))
                        },
                            MenuSettings.ContainerSeparatorColor);
                        Line.End();
                        y += MenuSettings.ContainerHeight;
                        MenuSettings.Font.DrawText(
                            MenuManager.Instance.Sprite,
                            valueStrings[i],
                            x,
                            y,
                            MenuSettings.TextColor);
                        if (Component.Index == i)
                        {
                            var checkmarkWidth = MenuSettings.Font.MeasureText(null, "\u2713", 0).Width;
                            MenuSettings.Font.DrawText(
                                MenuManager.Instance.Sprite,
                                "\u2713",
                                (int)(position.X + Component.MenuWidth - checkmarkWidth - TextSpacing),
                                y,
                                new ColorBGRA(1, 165, 226, 255));
                        }
                    }

                    Line.Width = 1f;
                    Line.Begin();
                    Line.Draw(
                        new[]
                    {
                        new Vector2(
                            position.X + Component.MenuWidth - dropdownMenuWidth,
                            position.Y + MenuSettings.ContainerHeight),
                        new Vector2(
                            position.X + Component.MenuWidth - dropdownMenuWidth,
                            position.Y + MenuSettings.ContainerHeight * (valueStrings.Length + 1)),
                        new Vector2(
                            position.X + Component.MenuWidth,
                            position.Y + MenuSettings.ContainerHeight * (valueStrings.Length + 1)),
                        new Vector2(
                            position.X + Component.MenuWidth,
                            position.Y + MenuSettings.ContainerHeight)
                    },
                        MenuSettings.ContainerSeparatorColor);
                    Line.End();
                });
            }
        }
Пример #16
0
 /// <summary>
 ///     Gets the width of the MenuList
 /// </summary>
 /// <returns>The <see cref="int" /></returns>
 public override int Width()
 {
     return(LightUtilities.CalcWidthItem(this.Component) + this.Component.MaxStringWidth + (2 * TextSpacing)
            + this.dropDownButtonWidth);
 }
Пример #17
0
        /// <summary>
        ///     Draws a <see cref="MenuSliderButton" />
        /// </summary>
        public override void Draw()
        {
            //Slider

            var position  = this.Component.Position;
            var centeredY =
                (int)
                LightUtilities.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 / 2));

            Line.Width = 3;
            Line.Begin();
            Line.Draw(
                new[] { new Vector2(x, position.Y + 1), new Vector2(x, position.Y + MenuSettings.ContainerHeight) },
                this.Component.Interacting ? new ColorBGRA(90, 129, 144, 255) : new ColorBGRA(94, 170, 246, 255));
            Line.End();

            MenuSettings.Font.DrawText(
                MenuManager.Instance.Sprite,
                this.Component.DisplayName,
                (int)(position.X + MenuSettings.ContainerTextOffset),
                centeredY,
                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 - 5 - measureText.Width - MenuSettings.ContainerHeight),
                centeredY,
                MenuSettings.TextColor);

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

            //On / Off Button

            Line.Width = MenuSettings.ContainerHeight - 7;
            Line.Begin();
            Line.Draw(
                new[]
            {
                new Vector2(
                    (this.Component.Position.X + this.Component.MenuWidth - MenuSettings.ContainerHeight - 1)
                    + MenuSettings.ContainerHeight / 2f,
                    this.Component.Position.Y + 1 + 3),
                new Vector2(
                    (this.Component.Position.X + this.Component.MenuWidth - MenuSettings.ContainerHeight - 1)
                    + MenuSettings.ContainerHeight / 2f,
                    this.Component.Position.Y + MenuSettings.ContainerHeight - 3)
            },
                this.Component.BValue ? new ColorBGRA(68, 160, 255, 255) : new ColorBGRA(151, 151, 151, 255));
            Line.End();

            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;

            MenuSettings.Font.DrawText(
                MenuManager.Instance.Sprite,
                this.Component.BValue ? "On" : "Off",
                centerX,
                centeredY,
                new ColorBGRA(221, 233, 255, 255));
        }