Esempio n. 1
0
 /// <summary>
 ///     Gets the width of the MenuKeyBind
 /// </summary>
 /// <returns>The <see cref="int" /></returns>
 public override int Width()
 {
     return(DefaultUtilities.CalcWidthItem(this.Component)
            + (int)
            (MenuSettings.ContainerHeight + DefaultUtilities.CalcWidthText("[" + this.Component.Key + "]")
             + MenuSettings.ContainerTextOffset));
 }
Esempio n. 2
0
        /// <summary>
        ///     Draws a MenuKeyBind
        /// </summary>
        public override void Draw()
        {
            var centerY =
                (int)
                DefaultUtilities.GetContainerRectangle(this.Component)
                .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter)
                .Y;

            MenuSettings.Font.DrawText(
                MenuManager.Instance.Sprite,
                (this.Component.Interacting ? "Press a key" : this.Component.DisplayName),
                (int)(this.Component.Position.X + MenuSettings.ContainerTextOffset),
                centerY,
                MenuSettings.TextColor);

            if (!this.Component.Interacting)
            {
                var keyString = "[" + this.Component.Key + "]";
                MenuSettings.Font.DrawText(
                    MenuManager.Instance.Sprite,
                    keyString,
                    (int)
                    (this.Component.Position.X + this.Component.MenuWidth - MenuSettings.ContainerHeight
                     - DefaultUtilities.CalcWidthText(keyString) - MenuSettings.ContainerTextOffset),
                    centerY,
                    MenuSettings.TextColor);
            }

            Line.Width = MenuSettings.ContainerHeight;
            Line.Begin();
            Line.Draw(
                new[]
            {
                new Vector2(
                    (this.Component.Position.X + this.Component.MenuWidth - MenuSettings.ContainerHeight)
                    + (MenuSettings.ContainerHeight / 2f),
                    this.Component.Position.Y + 1),
                new Vector2(
                    (this.Component.Position.X + this.Component.MenuWidth - MenuSettings.ContainerHeight)
                    + (MenuSettings.ContainerHeight / 2f),
                    this.Component.Position.Y + MenuSettings.ContainerHeight)
            },
                this.Component.Active ? new ColorBGRA(0, 100, 0, 255) : new ColorBGRA(255, 0, 0, 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.Active ? "ON" : "OFF",
                    CenteredFlags.HorizontalCenter).X;

            MenuSettings.Font.DrawText(
                MenuManager.Instance.Sprite,
                (this.Component.Active ? "ON" : "OFF"),
                centerX,
                centerY,
                MenuSettings.TextColor);
        }