Пример #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>
        ///     Draws a MenuKeyBind
        /// </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.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
                     - LightUtilities.CalcWidthText(keyString) - MenuSettings.ContainerTextOffset),
                    centerY,
                    LightMenuSettings.KeyBindColor);
            }

            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.Active ? 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.Active ? "On" : "Off",
                    CenteredFlags.HorizontalCenter).X;

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