/// <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 = ColoredUtilities.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, this.Component.Active ? MenuSettings.ContainerSelectedColor : 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> /// Draws a MenuKeyBind /// </summary> public override void Draw() { var centerY = (int) ColoredUtilities.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 - ColoredUtilities.CalcWidthText(keyString) - MenuSettings.ContainerTextOffset), centerY, MenuSettings.ContainerSelectedColor); } 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, MenuSettings.TextColor); //Right Utils.DrawCircle(centerX + 15, this.Component.Position.Y + MenuSettings.ContainerHeight / 2f, 7, 90, Utils.CircleType.Half, true, 32, MenuSettings.TextColor); //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) }, MenuSettings.TextColor); 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) }, MenuSettings.TextColor); 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 ? MenuSettings.ContainerSelectedColor : MenuSettings.TextColor); }
/// <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) ColoredUtilities.GetContainerRectangle(this.Component) .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter) .Y; if (this.Component.Toggled) { MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, this.Component.DisplayName, (int)(position.X + MenuSettings.ContainerTextOffset), centerY, new ColorBGRA(237, 245, 254, 255)); } else { MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, this.Component.DisplayName, (int)(position.X + MenuSettings.ContainerTextOffset), centerY, MenuSettings.TextColor); } MenuManager.Instance.DrawDelayed( delegate { var symbolCenterY = (int) ColoredUtilities.GetContainerRectangle(this.Component) .GetCenteredText(null, ColoredMenuSettings.FontMenuSymbol, this.Component.DisplayName, CenteredFlags.VerticalCenter) .Y; Utils.DrawCircleFilled( (position.X + this.Component.MenuWidth - MenuSettings.ContainerTextMarkWidth - MenuSettings.ContainerTextMarkOffset) + 4, symbolCenterY + 11, 6, 0, Utils.CircleType.Full, true, 16, new ColorBGRA(252, 248, 245, 255)); ColoredMenuSettings.FontMenuSymbol.DrawText( MenuManager.Instance.Sprite, "›", (int) (position.X + this.Component.MenuWidth - MenuSettings.ContainerTextMarkWidth - MenuSettings.ContainerTextMarkOffset) + 1, symbolCenterY, this.Component.Components.Count > 0 ? ColoredMenuSettings.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, 4, true, MenuSettings.RootContainerColor, new ColorBGRA(55, 76, 95, 255)); 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 (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 = ColoredTextures.Instance[ColoredTexture.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> /// Gets the <c>keybind</c> boundaries /// </summary> /// <param name="component">The <see cref="MenuKeyBind" /></param> /// <returns>The <see cref="Rectangle" /></returns> public Rectangle KeyBindBoundaries(MenuKeyBind component) { return(ColoredUtilities.GetContainerRectangle(component)); }