Пример #1
0
 /// <summary>
 ///     Calculates the Width of an AMenuComponent
 /// </summary>
 /// <returns>
 ///     The width.
 /// </returns>
 public override int Width()
 {
     return
         (int)
         (BlueUtilities.MeasureString(MultiLanguage.Translation(this.Component.DisplayName) + " \u25B6").Width
          + (MenuSettings.ContainerTextOffset * 2) + MenuSettings.ContainerTextMarkWidth);
 }
Пример #2
0
 /// <summary>
 ///     Calculates the Width of an AMenuComponent
 /// </summary>
 /// <returns>
 ///     The width.
 /// </returns>
 public override int Width()
 {
     return
         ((int)
          (BlueUtilities.MeasureString(this.Component.DisplayName + " \u25B6").Width
           + (MenuSettings.ContainerTextOffset * 2) + MenuSettings.ContainerTextMarkWidth));
 }
Пример #3
0
        /// <summary>
        ///     Draws a <see cref="MenuSlider" />
        /// </summary>
        public override void Draw()
        {
            var position  = this.Component.Position;
            var centeredY =
                (int)
                BlueUtilities.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(0, 74, 103, 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)
            },
                new ColorBGRA(0, 37, 53, 255));
            Line.End();
        }
Пример #4
0
        /// <summary>
        ///     Draw a <see cref="MenuSeparator" />
        /// </summary>
        public override void Draw()
        {
            var centerY = BlueUtilities.GetContainerRectangle(this.Component)
                          .GetCenteredText(
                null,
                BlueMenuSettings.FontCaption,
                this.Component.DisplayName.ToUpper(),
                CenteredFlags.VerticalCenter | CenteredFlags.HorizontalCenter);

            BlueMenuSettings.FontCaption.DrawText(
                MenuManager.Instance.Sprite,
                this.Component.DisplayName.ToUpper(),
                (int)centerY.X,
                (int)centerY.Y,
                BlueMenuSettings.TextCaptionColor);
        }
Пример #5
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)
                BlueUtilities.GetContainerRectangle(this.Component)
                    .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter)
                    .Y;

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

            MenuSettings.Font.DrawText(
                MenuManager.Instance.Sprite,
                "\u25B6",
                (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)
                        },
                    BlueMenuSettings2.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);

                        childComponent.OnDraw(childPos);
                    }
                }

                var contourColor = new ColorBGRA(21, 26, 45, 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 = BlueTextures2.Instance[BlueTexture2.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();
            }
        }
Пример #6
0
        /// <summary>
        ///     Draws a <see cref="MenuSlider" />
        /// </summary>
        public override void Draw()
        {
            //Slider

            var position  = this.Component.Position;
            var centeredY =
                (int)
                BlueUtilities.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(0, 74, 103, 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)
            },
                new ColorBGRA(0, 37, 53, 255));
            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(0, 186, 255, 255) : new ColorBGRA(36, 36, 36, 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,
                this.Component.BValue ? new ColorBGRA(0, 27, 41, 255) : MenuSettings.TextColor);
        }
Пример #7
0
 /// <summary>
 ///     Gets the width of the MenuList
 /// </summary>
 /// <returns>The <see cref="int" /></returns>
 public override int Width()
 {
     return(BlueUtilities.CalcWidthItem(this.Component) + this.Component.MaxStringWidth + (2 * TextSpacing)
            + this.dropDownButtonWidth);
 }
Пример #8
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     = BlueUtilities.GetContainerRectangle(this.Component)
                                    .GetCenteredText(null, MenuSettings.Font, MultiLanguage.Translation(this.Component.DisplayName), CenteredFlags.VerticalCenter);

            MenuSettings.Font.DrawText(
                MenuManager.Instance.Sprite,
                MultiLanguage.Translation(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,
                MultiLanguage.Translation(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 + this.Component.MenuWidth - (Line.Width / 2),
                            position.Y + MenuSettings.ContainerHeight),
                        new Vector2(
                            position.X + this.Component.MenuWidth - (Line.Width / 2),
                            position.Y + MenuSettings.ContainerHeight + dropdownMenuHeight)
                    },
                        dropdownColor);
                    Line.End();

                    var x =
                        (int)
                        (position.X + this.Component.MenuWidth - this.dropDownButtonWidth - TextSpacing
                         - this.Component.MaxStringWidth);
                    var y = (int)rectangleName.Y;
                    for (var i = 0; i < valueStrings.Length; i++)
                    {
                        if (i == this.Component.HoveringIndex)
                        {
                            Line.Width = MenuSettings.ContainerHeight;
                            Line.Begin();
                            Line.Draw(
                                new[]
                            {
                                new Vector2(
                                    position.X + this.Component.MenuWidth - dropdownMenuWidth,
                                    position.Y + ((i + 1) * MenuSettings.ContainerHeight)
                                    + MenuSettings.ContainerHeight / 2f),
                                new Vector2(
                                    position.X + this.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 + this.Component.MenuWidth - dropdownMenuWidth + 10,
                                position.Y + (MenuSettings.ContainerHeight * (i + 1))),
                            new Vector2(
                                position.X + this.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 (this.Component.Index == i)
                        {
                            var checkmarkWidth = MenuSettings.Font.MeasureText(null, "\u2713", 0).Width;
                            MenuSettings.Font.DrawText(
                                MenuManager.Instance.Sprite,
                                "\u2713",
                                (int)(position.X + this.Component.MenuWidth - checkmarkWidth - TextSpacing),
                                y,
                                new ColorBGRA(1, 165, 226, 255));
                        }
                    }

                    Line.Width = 1f;
                    Line.Begin();
                    Line.Draw(
                        new[]
                    {
                        new Vector2(
                            position.X + this.Component.MenuWidth - dropdownMenuWidth,
                            position.Y + MenuSettings.ContainerHeight),
                        new Vector2(
                            position.X + this.Component.MenuWidth - dropdownMenuWidth,
                            position.Y + MenuSettings.ContainerHeight * (valueStrings.Length + 1)),
                        new Vector2(
                            position.X + this.Component.MenuWidth,
                            position.Y + MenuSettings.ContainerHeight * (valueStrings.Length + 1)),
                        new Vector2(
                            position.X + this.Component.MenuWidth,
                            position.Y + MenuSettings.ContainerHeight)
                    },
                        MenuSettings.ContainerSeparatorColor);
                    Line.End();
                });
            }
        }