/// <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 = LightUtilities.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 ? new ColorBGRA(0, 186, 255, 255) : MenuSettings.TextColor); Line.Width = 1f; Line.Begin(); Line.Draw( new[] { new Vector2( position.X + this.Component.MenuWidth - this.dropDownButtonWidth - (2 * TextSpacing) - this.Component.MaxStringWidth, position.Y + 5), new Vector2( position.X + this.Component.MenuWidth - this.dropDownButtonWidth - (2 * TextSpacing) - this.Component.MaxStringWidth, position.Y + MenuSettings.ContainerHeight - 5) }, MenuSettings.ContainerSeparatorColor); Line.End(); if (this.Component.Active) { var valueStrings = this.Component.ValuesAsStrings; var dropdownMenuHeight = valueStrings.Length * MenuSettings.ContainerHeight; MenuManager.Instance.DrawDelayed( delegate { var color = MenuSettings.RootContainerColor; var dropdownColor = new ColorBGRA(color.R, color.G, color.B, 255); Line.Width = dropdownMenuWidth; Line.Begin(); Line.Draw( new[] { new Vector2( position.X + Component.MenuWidth - (Line.Width / 2), position.Y + MenuSettings.ContainerHeight), new Vector2( position.X + Component.MenuWidth - (Line.Width / 2), position.Y + MenuSettings.ContainerHeight + dropdownMenuHeight) }, dropdownColor); Line.End(); 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(); } 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)); } } Line.Width = 1f; Line.Begin(); Line.Draw( new[] { new Vector2( position.X + Component.MenuWidth - dropdownMenuWidth, position.Y + MenuSettings.ContainerHeight), new Vector2( position.X + Component.MenuWidth - dropdownMenuWidth, position.Y + MenuSettings.ContainerHeight * (valueStrings.Length + 1)), new Vector2( position.X + Component.MenuWidth, position.Y + MenuSettings.ContainerHeight * (valueStrings.Length + 1)), new Vector2( position.X + Component.MenuWidth, position.Y + MenuSettings.ContainerHeight) }, MenuSettings.ContainerSeparatorColor); Line.End(); }); } }
/// <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) LightUtilities.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)); MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, "»", (int) (position.X + this.Component.MenuWidth - MenuSettings.ContainerTextMarkWidth - MenuSettings.ContainerTextMarkOffset), centerY, this.Component.Components.Count > 0 ? new ColorBGRA(237, 245, 254, 255) : MenuSettings.ContainerSeparatorColor); } else { MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, this.Component.DisplayName, (int)(position.X + MenuSettings.ContainerTextOffset), centerY, MenuSettings.TextColor); MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, "»", (int) (position.X + this.Component.MenuWidth - MenuSettings.ContainerTextMarkWidth - MenuSettings.ContainerTextMarkOffset), centerY, this.Component.Components.Count > 0 ? MenuSettings.TextColor : MenuSettings.ContainerSeparatorColor); } if (this.Component.Toggled) { Line.Width = this.Component.MenuWidth; Line.Begin(); Line.Draw( new[] { new Vector2(position.X + this.Component.MenuWidth / 2f, position.Y), new Vector2( position.X + this.Component.MenuWidth / 2f, position.Y + MenuSettings.ContainerHeight) }, 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; } Line.Width = width; Line.Begin(); Line.Draw( new[] { new Vector2((position.X + this.Component.MenuWidth) + width / 2, position.Y), new Vector2((position.X + this.Component.MenuWidth) + width / 2, position.Y + height) }, MenuSettings.RootContainerColor); Line.End(); 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); if (i < this.Component.Components.Count - 1) { Line.Width = 1f; Line.Begin(); Line.Draw( new[] { new Vector2(childPos.X + 15, childPos.Y + MenuSettings.ContainerHeight), new Vector2( childPos.X - 15 + childComponent.MenuWidth, childPos.Y + MenuSettings.ContainerHeight) }, MenuSettings.ContainerSeparatorColor); Line.End(); } childComponent.OnDraw(childPos); } } var contourColor = new ColorBGRA(254, 255, 255, 255); Line.Width = 1f; Line.Begin(); Line.Draw( new[] { new Vector2(position.X + this.Component.MenuWidth, position.Y), new Vector2(position.X + this.Component.MenuWidth + width, position.Y) }, contourColor); Line.Draw( new[] { new Vector2(position.X + this.Component.MenuWidth, position.Y + height), new Vector2(position.X + this.Component.MenuWidth + width, position.Y + height) }, contourColor); Line.Draw( new[] { new Vector2(position.X + this.Component.MenuWidth, position.Y), new Vector2(position.X + this.Component.MenuWidth, position.Y + height) }, contourColor); Line.Draw( new[] { new Vector2(position.X + this.Component.MenuWidth + width, position.Y), new Vector2(position.X + this.Component.MenuWidth + width, position.Y + height) }, contourColor); 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 = LightTextures.Instance[LightTexture.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> /// Draws a MenuColor /// </summary> public override void Draw() { var rectangleName = LightUtilities.GetContainerRectangle(this.Component) .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter); MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, this.Component.DisplayName, (int)(this.Component.Position.X + MenuSettings.ContainerTextOffset), (int)rectangleName.Y, MenuSettings.TextColor); Line.Width = MenuSettings.ContainerHeight - 7; Line.Begin(); Line.Draw( new[] { new Vector2( this.Component.Position.X + this.Component.MenuWidth - (Line.Width / 2f) - 4, this.Component.Position.Y + 1 + 3), new Vector2( this.Component.Position.X + this.Component.MenuWidth - (Line.Width / 2f) - 4, this.Component.Position.Y + Line.Width + 3) }, this.Component.Color); Line.End(); if (this.Component.HoveringPreview) { Line.Begin(); Line.Draw( new[] { new Vector2( this.Component.Position.X + this.Component.MenuWidth - (Line.Width / 2f) - 4, this.Component.Position.Y + 1 + 3), new Vector2( this.Component.Position.X + this.Component.MenuWidth - (Line.Width / 2f) - 4, this.Component.Position.Y + Line.Width + 3) }, MenuSettings.HoverColor); Line.End(); } if (this.Component.Active) { MenuManager.Instance.DrawDelayed( delegate { Line.Width = ColorPickerBoundaries().Width; Line.Begin(); Line.Draw( new[] { new Vector2(ColorPickerBoundaries().X + 165, ColorPickerBoundaries().Y), new Vector2( ColorPickerBoundaries().X + 165, ColorPickerBoundaries().Y + ColorPickerBoundaries().Height) }, MenuSettings.RootContainerColor); Line.End(); colorBox.DrawControl(new Vector2(ColorBoxBoundaries().X, ColorBoxBoundaries().Y)); verticalColorSlider.DrawControl( new Vector2(VerticalColorSliderBoundaries().X, VerticalColorSliderBoundaries().Y)); verticalAlphaSlider.DrawControl( new Vector2(VerticalAlphaSliderBoundaries().X, VerticalAlphaSliderBoundaries().Y)); Utils.DrawBoxFilled( PreviewBoundaries().X, PreviewBoundaries().Y, PreviewBoundaries().Width, PreviewBoundaries().Height, Color.Black); Utils.DrawBoxFilled( PreviewBoundaries().X, PreviewBoundaries().Y, PreviewBoundaries().Width, PreviewBoundaries().Height, colorBox.Rgb.ToSharpDxColor()); var applyButtonTextWidth = MenuSettings.Font.MeasureText(MenuManager.Instance.Sprite, "Apply", 0).Width; var cancelButtonTextWidth = MenuSettings.Font.MeasureText(MenuManager.Instance.Sprite, "Cancel", 0).Width; Line.Width = ApplyButtonBoundaries().Width; Line.Begin(); Line.Draw( new[] { new Vector2(ApplyButtonBoundaries().X + 25, ApplyButtonBoundaries().Y), new Vector2( ApplyButtonBoundaries().X + 25, ApplyButtonBoundaries().Y + ApplyButtonBoundaries().Height) }, new ColorBGRA(68, 160, 255, 255)); Line.End(); MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, "Apply", ApplyButtonBoundaries().X - applyButtonTextWidth / 2 + 25, (int) CancelButtonBoundaries() .GetCenteredText(null, MenuSettings.Font, "Apply", CenteredFlags.VerticalCenter) .Y, new ColorBGRA(221, 233, 255, 255)); Line.Width = CancelButtonBoundaries().Width; Line.Begin(); Line.Draw( new[] { new Vector2(CancelButtonBoundaries().X + 25, CancelButtonBoundaries().Y), new Vector2( CancelButtonBoundaries().X + 25, CancelButtonBoundaries().Y + CancelButtonBoundaries().Height) }, new ColorBGRA(68, 160, 255, 255)); Line.End(); MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, "Cancel", CancelButtonBoundaries().X - cancelButtonTextWidth / 2 + 25, (int) CancelButtonBoundaries() .GetCenteredText(null, MenuSettings.Font, "Cancel", CenteredFlags.VerticalCenter) .Y, new ColorBGRA(221, 233, 255, 255)); }); } }