/// <summary> /// Gets the width of the MenuList /// </summary> /// <returns>The <see cref="int" /></returns> public override int Width() { return(TechUtilities.CalcWidthItem(this.Component) + this.Component.MaxStringWidth + (2 * TextSpacing) + this.dropDownButtonWidth); }
/// <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) TechUtilities.GetContainerRectangle(this.Component) .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter) .Y; MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, this.Component.DisplayName, (int)(position.X + MenuSettings.ContainerTextOffset), centerY, MenuSettings.TextColor); MenuManager.Instance.DrawDelayed( delegate { var symbolCenterY = (int) TechUtilities.GetContainerRectangle(this.Component) .GetCenteredText(null, TechMenuSettings.FontMenuSymbol, this.Component.DisplayName, CenteredFlags.VerticalCenter) .Y; TechMenuSettings.FontMenuSymbol.DrawText( MenuManager.Instance.Sprite, "›", (int) (position.X + this.Component.MenuWidth - MenuSettings.ContainerTextMarkWidth - MenuSettings.ContainerTextMarkOffset) + 1, symbolCenterY, this.Component.Components.Count > 0 ? TechMenuSettings.TextCaptionColor : MenuSettings.ContainerSeparatorColor); }); if (this.Component.Toggled) { Line.Width = this.Component.MenuWidth - 3; Line.Begin(); Line.Draw( new[] { new Vector2(position.X + this.Component.MenuWidth / 2f - 1, position.Y + 1), new Vector2( position.X + this.Component.MenuWidth / 2f - 1, position.Y + MenuSettings.ContainerHeight - 1) }, MenuSettings.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; } Utils.DrawBoxRounded(position.X + this.Component.MenuWidth, position.Y, width, height + 1, 4, true, MenuSettings.RootContainerColor, MenuSettings.TextColor); 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); if (i < this.Component.Components.Count - 1) { var rec = TechUtilities.GetContainerRectangle(childComponent); Line.Width = 1; if (childComponent is MenuSeparator) { Line.Width = 3; Line.Begin(); Line.Draw( new[] { new Vector2(rec.Left + 1, rec.Bottom - 2), new Vector2(rec.Right - 2, rec.Bottom - 2) }, TechMenuSettings.TextCaptionColor); } else if (childComponent is MenuBool || childComponent is MenuButton || childComponent is MenuColor || childComponent is MenuKeyBind || childComponent is MenuList || childComponent is MenuSlider) { Line.Begin(); Line.Draw( new[] { new Vector2(rec.Left + 1, rec.Bottom), new Vector2(rec.Right - 2, rec.Bottom) }, new Color(13, 34, 37, 255)); Line.Draw( new[] { new Vector2(rec.Left + 1, rec.Bottom), new Vector2(rec.Left + 5, rec.Bottom) }, TechMenuSettings.TextCaptionColor); Line.Draw( new[] { new Vector2(rec.Right - 6, rec.Bottom), new Vector2(rec.Right - 2, rec.Bottom) }, TechMenuSettings.TextCaptionColor); } else { Line.Begin(); Line.Draw( new[] { new Vector2(rec.Left + 1, rec.Bottom), new Vector2(rec.Right - 2, rec.Bottom) }, TechMenuSettings.TextCaptionColor); } 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 = TechTextures.Instance[TechTexture.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(); } }
/// <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 = TechUtilities.GetContainerRectangle(this.Component) .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter); MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, 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, this.Component.SelectedValueAsObject.ToString(), (int)position.X + this.Component.MenuWidth - this.dropDownButtonWidth - TextSpacing - this.Component.MaxStringWidth, (int)rectangleName.Y, MenuSettings.TextColor); if (this.Component.Active) { var valueStrings = this.Component.ValuesAsStrings; var dropdownMenuHeight = valueStrings.Length * MenuSettings.ContainerHeight; MenuManager.Instance.DrawDelayed( delegate { var color = MenuSettings.RootContainerColor; Utils.DrawBoxRounded(position.X + Component.MenuWidth - dropdownMenuWidth, position.Y + MenuSettings.ContainerHeight, dropdownMenuWidth, dropdownMenuHeight, 4, true, MenuSettings.RootContainerColor, new ColorBGRA(55, 76, 95, 255)); var x = (int) (position.X + Component.MenuWidth - dropDownButtonWidth - TextSpacing - Component.MaxStringWidth); var y = (int)rectangleName.Y; for (var i = 0; i < valueStrings.Length; i++) { if (i == Component.HoveringIndex) { Line.Width = MenuSettings.ContainerHeight; Line.Begin(); Line.Draw( new[] { new Vector2( position.X + Component.MenuWidth - dropdownMenuWidth, position.Y + ((i + 1) * MenuSettings.ContainerHeight) + MenuSettings.ContainerHeight / 2f), new Vector2( position.X + Component.MenuWidth, position.Y + ((i + 1) * MenuSettings.ContainerHeight) + MenuSettings.ContainerHeight / 2f) }, MenuSettings.HoverColor); Line.End(); } if (i != 0) { Line.Width = 1f; Line.Begin(); Line.Draw( new[] { new Vector2( position.X + Component.MenuWidth - dropdownMenuWidth + 10, position.Y + (MenuSettings.ContainerHeight * (i + 1))), new Vector2( position.X + 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 (Component.Index == i) { var checkmarkWidth = MenuSettings.Font.MeasureText(null, "\u2713", 0).Width; MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, "\u2713", (int)(position.X + Component.MenuWidth - checkmarkWidth - TextSpacing), y, new ColorBGRA(1, 165, 226, 255)); } } }); } }
/// <summary> /// Calculates the width of this component /// </summary> /// <returns> /// The width. /// </returns> public override int Width() { return(TechUtilities.CalcWidthItem(this.Component) + 100); }
/// <summary> /// Draws a <see cref="MenuSliderButton" /> /// </summary> public override void Draw() { //Slider var position = this.Component.Position; var centeredY = (int) TechUtilities.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)); var maxX = position.X + Offset + ((this.Component.MenuWidth - Offset * 2 - MenuSettings.ContainerHeight)); MenuManager.Instance.DrawDelayed( delegate { Utils.DrawCircleFilled( x, position.Y + MenuSettings.ContainerHeight / 1.5f + 3, 4, 0, Utils.CircleType.Full, true, 32, new Color(73, 227, 139, 255)); }); MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, this.Component.DisplayName, (int)(position.X + MenuSettings.ContainerTextOffset), (int)(position.Y + (centeredY - position.Y) / 2), 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 - measureText.Width - Offset - MenuSettings.ContainerHeight), (int)(position.Y + (centeredY - position.Y) / 2), MenuSettings.TextColor); Line.Width = 2; Line.Begin(); Line.Draw( new[] { new Vector2(position.X + Offset, position.Y + MenuSettings.ContainerHeight / 1.5f + 3), new Vector2(maxX, position.Y + MenuSettings.ContainerHeight / 1.5f + 3) }, MenuSettings.ContainerSelectedColor); Line.End(); Line.Width = 2; Line.Begin(); Line.Draw( new[] { new Vector2(position.X + Offset, position.Y + MenuSettings.ContainerHeight / 1.5f + 3), new Vector2(x, position.Y + MenuSettings.ContainerHeight / 1.5f + 3) }, MenuSettings.TextColor); Line.End(); //On / Off Button 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 - 5; //Left Utils.DrawCircle(centerX, this.Component.Position.Y + MenuSettings.ContainerHeight / 2f, 7, 270, Utils.CircleType.Half, true, 32, this.Component.BValue ? 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.BValue ? 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.BValue ? 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.BValue ? new Color(75, 215, 128, 255) : new Color(36, 204, 205, 255)); Line.End(); //FullCircle Utils.DrawCircleFilled(this.Component.BValue ? centerX + 14 : centerX + 1, this.Component.Position.Y + MenuSettings.ContainerHeight / 2f, 6, 0, Utils.CircleType.Full, true, 32, this.Component.BValue ? new Color(73, 227, 139, 255) : new Color(17, 65, 65, 255)); }
/// <summary> /// Gets the boundaries /// </summary> /// <param name="component">The <see cref="MenuSlider" /></param> /// <returns>The <see cref="Rectangle" /></returns> public Rectangle Bounding(MenuSlider component) { return(TechUtilities.GetContainerRectangle(component)); }
/// <summary> /// Gets the additional boundaries. /// </summary> /// <param name="component">The <see cref="MenuSlider" /></param> /// <returns>The <see cref="Rectangle" /></returns> public Rectangle AdditionalBoundries(MenuSlider component) { return(TechUtilities.GetContainerRectangle(component)); }
/// <summary> /// Draws a <see cref="MenuSlider" /> /// </summary> public override void Draw() { var position = this.Component.Position; var centeredY = (int) TechUtilities.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)); var maxX = position.X + Offset + ((this.Component.MenuWidth - Offset * 2)); MenuManager.Instance.DrawDelayed( delegate { Utils.DrawCircleFilled( x, position.Y + MenuSettings.ContainerHeight / 1.5f + 3, 4, 0, Utils.CircleType.Full, true, 32, new Color(73, 227, 139, 255)); }); MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, this.Component.DisplayName, (int)(position.X + MenuSettings.ContainerTextOffset), (int)(position.Y + (centeredY - position.Y) / 2), 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 - measureText.Width - Offset), (int)(position.Y + (centeredY - position.Y) / 2), MenuSettings.TextColor); Line.Width = 2; Line.Begin(); Line.Draw( new[] { new Vector2(position.X + Offset, position.Y + MenuSettings.ContainerHeight / 1.5f + 3), new Vector2(maxX, position.Y + MenuSettings.ContainerHeight / 1.5f + 3) }, MenuSettings.ContainerSelectedColor); Line.End(); Line.Width = 2; Line.Begin(); Line.Draw( new[] { new Vector2(position.X + Offset, position.Y + MenuSettings.ContainerHeight / 1.5f + 3), new Vector2(x, position.Y + MenuSettings.ContainerHeight / 1.5f + 3) }, MenuSettings.TextColor); Line.End(); }