Ejemplo n.º 1
0
 /// <summary>
 ///     Gets the width of the MenuKeyBind
 /// </summary>
 /// <returns>The <see cref="int" /></returns>
 public override int Width()
 {
     return(TechUtilities.CalcWidthItem(this.Component)
            + (int)
            (MenuSettings.ContainerHeight + TechUtilities.CalcWidthText("[" + this.Component.Key + "]")
             + MenuSettings.ContainerTextOffset));
 }
Ejemplo n.º 2
0
        /// <summary>
        ///     Draws a MenuKeyBind
        /// </summary>
        public override void Draw()
        {
            var centerY =
                (int)
                TechUtilities.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 + "]";

                Line.Width = TechUtilities.CalcWidthText(keyString) + 5;
                Line.Begin();
                Line.Draw(
                    new[]
                {
                    new Vector2((this.Component.Position.X + this.Component.MenuWidth - MenuSettings.ContainerHeight
                                 - TechUtilities.CalcWidthText(keyString) / 2 - MenuSettings.ContainerTextOffset),
                                centerY - 2),
                    new Vector2((this.Component.Position.X + this.Component.MenuWidth - MenuSettings.ContainerHeight
                                 - TechUtilities.CalcWidthText(keyString) / 2 - MenuSettings.ContainerTextOffset),
                                centerY + TechUtilities.MeasureString(keyString).Height + 2)
                },
                    new Color(17, 32, 27, 255));
                Line.End();

                MenuSettings.Font.DrawText(
                    MenuManager.Instance.Sprite,
                    keyString,
                    (int)
                    (this.Component.Position.X + this.Component.MenuWidth - MenuSettings.ContainerHeight
                     - TechUtilities.CalcWidthText(keyString) - MenuSettings.ContainerTextOffset),
                    centerY,
                    new Color(75, 215, 128, 255));
            }

            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 - 5;

            //Left
            Utils.DrawCircle(centerX, this.Component.Position.Y + MenuSettings.ContainerHeight / 2f, 7, 270, Utils.CircleType.Half, true, 32,
                             this.Component.Active ? new Color(75, 215, 128, 255) : new Color(36, 204, 205, 255));

            //Right
            Utils.DrawCircle(centerX + 15, this.Component.Position.Y + MenuSettings.ContainerHeight / 2f, 7, 90, Utils.CircleType.Half, true, 32,
                             this.Component.Active ? new Color(75, 215, 128, 255) : new Color(36, 204, 205, 255));

            //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)
            },
                this.Component.Active ? new Color(75, 215, 128, 255) : new Color(36, 204, 205, 255));
            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)
            },
                this.Component.Active ? new Color(75, 215, 128, 255) : new Color(36, 204, 205, 255));
            Line.End();

            //FullCircle
            Utils.DrawCircleFilled(this.Component.Active ? centerX + 14 : centerX + 1,
                                   this.Component.Position.Y + MenuSettings.ContainerHeight / 2f, 6, 0, Utils.CircleType.Full, true, 32,
                                   this.Component.Active ? new Color(73, 227, 139, 255) : new Color(17, 65, 65, 255));
        }