Пример #1
0
        /// <summary>
        ///     On draw event.
        /// </summary>
        internal void OnDraw()
        {
            var s = MultiLanguage._(this.DisplayName);

            MenuDrawHelper.DrawBox(
                this.Position,
                this.Width,
                this.Height,
                MenuSettings.BackgroundColor,
                1,
                System.Drawing.Color.Black);

            if (this.DrawingTooltip)
            {
                MenuDrawHelper.DrawToolTipText(
                    new Vector2(this.Position.X + this.Width, this.Position.Y),
                    this,
                    this.TooltipColor);
            }

            var style = this.FontStyle;

            style &= ~FontStyle.Strikeout;
            style &= ~FontStyle.Underline;

            var font = MenuDrawHelper.GetFont(style);

            switch (this.ValueType)
            {
            case MenuValueType.Boolean:
                MenuDrawHelper.DrawOnOff(
                    this.GetValue <bool>(),
                    new Vector2(this.Position.X + this.Width - this.Height, this.Position.Y),
                    this);
                break;

            case MenuValueType.Slider:
                MenuDrawHelper.DrawSlider(this.Position, this);
                break;

            case MenuValueType.KeyBind:
                var val = this.GetValue <KeyBind>();

                if (this.Interacting)
                {
                    s = MultiLanguage._("Press new key(s)");
                }

                if (val.Key != 0)
                {
                    var x = !string.IsNullOrEmpty(this.Tooltip)
                                    ? (int)this.Position.X + this.Width - this.Height
                            - font.MeasureText("[" + Utils.KeyToText(val.Key) + "]").Width - 35
                                    : (int)this.Position.X + this.Width - this.Height
                            - font.MeasureText("[" + Utils.KeyToText(val.Key) + "]").Width - 10;

                    font.DrawText(
                        null,
                        "[" + Utils.KeyToText(val.Key) + "]",
                        new Rectangle(x, (int)this.Position.Y, this.Width, this.Height),
                        FontDrawFlags.VerticalCenter,
                        new ColorBGRA(1, 169, 234, 255));
                }

                if (val.SecondaryKey != 0)
                {
                    var x_secondary = !string.IsNullOrEmpty(this.Tooltip)
                                              ? (int)this.Position.X + this.Width - this.Height
                                      - font.MeasureText("[" + Utils.KeyToText(val.Key) + "]").Width
                                      - font.MeasureText("[" + Utils.KeyToText(val.Key) + "]").Width / 4
                                      - font.MeasureText("[" + Utils.KeyToText(val.SecondaryKey) + "]").Width
                                      - 35
                                              : (int)this.Position.X + this.Width - this.Height
                                      - font.MeasureText("[" + Utils.KeyToText(val.Key) + "]").Width
                                      - font.MeasureText("[" + Utils.KeyToText(val.Key) + "]").Width / 4
                                      - font.MeasureText("[" + Utils.KeyToText(val.SecondaryKey) + "]").Width
                                      - 10;

                    font.DrawText(
                        null,
                        "[" + Utils.KeyToText(val.SecondaryKey) + "]",
                        new Rectangle(x_secondary, (int)this.Position.Y, this.Width, this.Height),
                        FontDrawFlags.VerticalCenter,
                        new ColorBGRA(1, 169, 234, 255));
                }

                MenuDrawHelper.DrawOnOff(
                    val.Active,
                    new Vector2(this.Position.X + this.Width - this.Height, this.Position.Y),
                    this);

                break;

            case MenuValueType.Integer:
                var intVal = this.GetValue <int>();
                MenuDrawHelper.Font.DrawText(
                    null,
                    intVal.ToString(),
                    new Rectangle((int)this.Position.X + 5, (int)this.Position.Y, this.Width, this.Height),
                    FontDrawFlags.VerticalCenter | FontDrawFlags.Right,
                    new ColorBGRA(255, 255, 255, 255));
                break;

            case MenuValueType.Color:
                var colorVal = this.GetValue <System.Drawing.Color>();
                MenuDrawHelper.DrawBox(
                    this.Position + new Vector2(this.Width - this.Height, 0),
                    this.Height,
                    this.Height,
                    colorVal,
                    1,
                    System.Drawing.Color.Black);
                break;

            case MenuValueType.Circle:
                var circleVal = this.GetValue <Circle>();
                MenuDrawHelper.DrawBox(
                    this.Position + new Vector2(this.Width - this.Height * 2, 0),
                    this.Height,
                    this.Height,
                    circleVal.Color,
                    1,
                    System.Drawing.Color.Black);
                MenuDrawHelper.DrawOnOff(
                    circleVal.Active,
                    new Vector2(this.Position.X + this.Width - this.Height, this.Position.Y),
                    this);
                break;

            case MenuValueType.StringList:
                var slVal = this.GetValue <StringList>();

                var t = slVal.SList[slVal.SelectedIndex];

                MenuDrawHelper.DrawArrow(
                    "<<",
                    this.Position + new Vector2(this.Width - this.Height * 2, 0),
                    this,
                    System.Drawing.Color.Black);
                MenuDrawHelper.DrawArrow(
                    ">>",
                    this.Position + new Vector2(this.Width - this.Height, 0),
                    this,
                    System.Drawing.Color.Black);

                MenuDrawHelper.Font.DrawText(
                    null,
                    MultiLanguage._(t),
                    new Rectangle(
                        (int)this.Position.X - 5 - 2 * this.Height,
                        (int)this.Position.Y,
                        this.Width,
                        this.Height),
                    FontDrawFlags.VerticalCenter | FontDrawFlags.Right,
                    new ColorBGRA(255, 255, 255, 255));
                break;
            }

            if (!string.IsNullOrEmpty(this.Tooltip))
            {
                MenuDrawHelper.DrawToolTipButton(new Vector2(this.Position.X + this.Width, this.Position.Y), this);
            }

            font.DrawText(
                null,
                s,
                new Rectangle((int)this.Position.X + 5, (int)this.Position.Y, this.Width, this.Height),
                FontDrawFlags.VerticalCenter,
                this.FontColor);

            var textWidth = font.MeasureText(null, MultiLanguage._(this.DisplayName));

            if ((this.FontStyle & FontStyle.Strikeout) != 0)
            {
                Drawing.DrawLine(
                    this.Position.X + 5,
                    this.Position.Y + (MenuSettings.MenuItemHeight / 2f),
                    this.Position.X + 5 + textWidth.Width,
                    this.Position.Y + (MenuSettings.MenuItemHeight / 2f),
                    1f,
                    System.Drawing.Color.FromArgb(
                        this.FontColor.A,
                        this.FontColor.R,
                        this.FontColor.G,
                        this.FontColor.B));
            }

            if ((this.FontStyle & FontStyle.Underline) != 0)
            {
                Drawing.DrawLine(
                    this.Position.X + 5,
                    this.Position.Y + (MenuSettings.MenuItemHeight / 1.5f),
                    this.Position.X + 5 + textWidth.Width,
                    this.Position.Y + (MenuSettings.MenuItemHeight / 1.5f),
                    1f,
                    System.Drawing.Color.FromArgb(
                        this.FontColor.A,
                        this.FontColor.R,
                        this.FontColor.G,
                        this.FontColor.B));
            }
        }
Пример #2
0
        /// <summary>
        ///     Fired when everything has been drawn.
        /// </summary>
        /// <param name="args">The <see cref="EventArgs" /> instance containing the event data.</param>
        /// <exception cref="Exception">[PermaShow] - MenuItem not supported</exception>
        private static void Drawing_OnEndScene(EventArgs args)
        {
            if (Drawing.Direct3DDevice == null || Drawing.Direct3DDevice.IsDisposed)
            {
                return;
            }

            if (!placetosave.Item("enablepermashow").GetValue <bool>())
            {
                Unsub();
                return;
            }

            PermaArea();

            var halfwidth = 0.96f * (PermaShowWidth / 2);

            var baseposition = new Vector2(BoxPosition.X - halfwidth, BoxPosition.Y);

            var boxx = BoxPosition.X + (PermaShowWidth / 2) - (SmallBoxWidth / 2);

            foreach (var permaitem in PermaShowItems)
            {
                var index  = PermaShowItems.IndexOf(permaitem);
                var boxpos = new Vector2(boxx, baseposition.Y + (Text.Description.Height * 1.2f * index));
                var endpos = new Vector2(
                    BoxPosition.X + (PermaShowWidth / 2),
                    baseposition.Y + (Text.Description.Height * 1.2f * index));
                var itempos = new Vector2(baseposition.X, baseposition.Y + (Text.Description.Height * 1.2f * index));

                var textpos = (int)(endpos.X - (SmallBoxWidth / 1.2f));

                switch (permaitem.Item.ValueType)
                {
                case MenuValueType.Boolean:
                    DrawBox(boxpos, permaitem.Item.GetValue <bool>());
                    Text.DrawText(
                        null,
                        permaitem.DisplayName + ":",
                        (int)itempos.X,
                        (int)itempos.Y,
                        permaitem.Color);
                    Text.DrawText(
                        null,
                        permaitem.Item.GetValue <bool>().ToString(),
                        textpos,
                        (int)itempos.Y,
                        permaitem.Color);
                    break;

                case MenuValueType.Slider:
                    Text.DrawText(
                        null,
                        permaitem.DisplayName + ":",
                        (int)itempos.X,
                        (int)itempos.Y,
                        permaitem.Color);
                    Text.DrawText(
                        null,
                        permaitem.Item.GetValue <Slider>().Value.ToString(),
                        textpos,
                        (int)itempos.Y,
                        permaitem.Color);
                    break;

                case MenuValueType.KeyBind:
                    DrawBox(boxpos, permaitem.Item.GetValue <KeyBind>().Active);
                    Text.DrawText(
                        null,
                        permaitem.DisplayName + " [" + Utils.KeyToText(permaitem.Item.GetValue <KeyBind>().Key)
                        + "] :",
                        (int)itempos.X,
                        (int)itempos.Y,
                        permaitem.Color);

                    Text.DrawText(
                        null,
                        permaitem.Item.GetValue <KeyBind>().Active.ToString(),
                        textpos,
                        (int)(boxpos.Y),
                        permaitem.Color);
                    break;

                case MenuValueType.StringList:
                    Text.DrawText(
                        null,
                        permaitem.DisplayName + ":",
                        (int)itempos.X,
                        (int)itempos.Y,
                        permaitem.Color);
                    var dimen = Text.MeasureText(sprite, permaitem.Item.GetValue <StringList>().SelectedValue);
                    Text.DrawText(
                        null,
                        permaitem.Item.GetValue <StringList>().SelectedValue,
                        (int)(textpos + dimen.Width < endpos.X ? textpos : endpos.X - dimen.Width),
                        (int)itempos.Y,
                        permaitem.Color);
                    break;

                case MenuValueType.Integer:
                    Text.DrawText(
                        null,
                        permaitem.DisplayName + ":",
                        (int)itempos.X,
                        (int)itempos.Y,
                        permaitem.Color);
                    Text.DrawText(
                        null,
                        permaitem.Item.GetValue <int>().ToString(),
                        textpos,
                        (int)itempos.Y,
                        permaitem.Color);
                    break;

                case MenuValueType.None:
                    break;

                default:
                    throw new Exception("[PermaShow] - MenuItem not supported");
                }
            }
        }