/// <summary> /// Draws a <see cref="MenuBool" /> /// </summary> public override void Draw() { var centerY = (int) DefaultUtilities.GetContainerRectangle(this.Component) .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter) .Y; MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, this.Component.DisplayName, (int)(this.Component.Position.X + MenuSettings.ContainerTextOffset), centerY, MenuSettings.TextColor); Line.Width = MenuSettings.ContainerHeight; Line.Begin(); Line.Draw( new[] { new Vector2( (this.Component.Position.X + this.Component.MenuWidth - MenuSettings.ContainerHeight) + (MenuSettings.ContainerHeight / 2f), this.Component.Position.Y + 1), new Vector2( (this.Component.Position.X + this.Component.MenuWidth - MenuSettings.ContainerHeight) + (MenuSettings.ContainerHeight / 2f), this.Component.Position.Y + MenuSettings.ContainerHeight) }, this.Component.Value ? new ColorBGRA(0, 100, 0, 255) : new ColorBGRA(255, 0, 0, 255)); Line.End(); 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.Value ? "ON" : "OFF", CenteredFlags.HorizontalCenter).X; MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, this.Component.Value ? "ON" : "OFF", centerX, centerY, MenuSettings.TextColor); }
/// <summary> /// Draws a <see cref="MenuButton" /> /// </summary> public override void Draw() { var rectangleName = DefaultUtilities.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); var buttonTextWidth = MenuSettings.Font.MeasureText(MenuManager.Instance.Sprite, this.Component.ButtonText, 0).Width; Line.Width = MenuSettings.ContainerHeight; Line.Begin(); Line.Draw( new[] { new Vector2( this.Component.Position.X + this.Component.MenuWidth - buttonTextWidth - (2 * TextGap), this.Component.Position.Y + (MenuSettings.ContainerHeight / 2f)), new Vector2( this.Component.Position.X + this.Component.MenuWidth, this.Component.Position.Y + (MenuSettings.ContainerHeight / 2f)), }, MenuSettings.HoverColor); Line.End(); Line.Width = MenuSettings.ContainerHeight - 5; Line.Begin(); Line.Draw( new[] { new Vector2( this.Component.Position.X + this.Component.MenuWidth - buttonTextWidth - (2 * TextGap) + 2, this.Component.Position.Y + (MenuSettings.ContainerHeight / 2f)), new Vector2( this.Component.Position.X + this.Component.MenuWidth - 2, this.Component.Position.Y + (MenuSettings.ContainerHeight / 2f)), }, this.Component.Hovering ? this.buttonHoverColor : this.buttonColor); Line.End(); MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, this.Component.ButtonText, (int)(this.Component.Position.X + this.Component.MenuWidth - buttonTextWidth - TextGap), (int)rectangleName.Y, MenuSettings.TextColor); }
/// <summary> /// Draws a <see cref="MenuSlider" /> /// </summary> public override void Draw() { var position = this.Component.Position; var centeredY = (int) DefaultUtilities.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 + (percent * this.Component.MenuWidth); Line.Width = 2; Line.Begin(); Line.Draw( new[] { new Vector2(x, position.Y + 1), new Vector2(x, position.Y + MenuSettings.ContainerHeight) }, this.Component.Interacting ? new ColorBGRA(255, 0, 0, 255) : new ColorBGRA(50, 154, 205, 255)); Line.End(); MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, this.Component.DisplayName, (int)(position.X + MenuSettings.ContainerTextOffset), centeredY, 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 - 5 - measureText.Width), centeredY, MenuSettings.TextColor); Line.Width = MenuSettings.ContainerHeight; Line.Begin(); Line.Draw( new[] { new Vector2(position.X, position.Y + MenuSettings.ContainerHeight / 2f), new Vector2(x, position.Y + MenuSettings.ContainerHeight / 2f) }, MenuSettings.HoverColor); Line.End(); }
/// <summary> /// Draw a <see cref="MenuSeparator" /> /// </summary> public override void Draw() { var centerY = DefaultUtilities.GetContainerRectangle(this.Component) .GetCenteredText( null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter | CenteredFlags.HorizontalCenter); MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, this.Component.DisplayName, (int)centerY.X, (int)centerY.Y, MenuSettings.TextColor); }
/// <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(DefaultUtilities.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(DefaultUtilities.GetContainerRectangle(component)); }
/// <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) DefaultUtilities.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); 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, childPos.Y + MenuSettings.ContainerHeight), new Vector2( childPos.X + childComponent.MenuWidth, childPos.Y + MenuSettings.ContainerHeight) }, MenuSettings.ContainerSeparatorColor); Line.End(); } childComponent.OnDraw(childPos); } } var contourColor = Color.Black; 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 (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 = DefaultTextures.Instance[DefaultTexture.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(DefaultUtilities.GetContainerRectangle(component)); }
/// <summary> /// Draws a MenuColor /// </summary> public override void Draw() { var rectangleName = DefaultUtilities.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; Line.Begin(); Line.Draw( new[] { new Vector2( this.Component.Position.X + this.Component.MenuWidth - (Line.Width / 2f), this.Component.Position.Y + 1), new Vector2( this.Component.Position.X + this.Component.MenuWidth - (Line.Width / 2f), this.Component.Position.Y + Line.Width) }, this.Component.Color); Line.End(); if (this.Component.HoveringPreview) { Line.Begin(); Line.Draw( new[] { new Vector2( this.Component.Position.X + this.Component.MenuWidth - (MenuSettings.ContainerHeight / 2f), this.Component.Position.Y + 1), new Vector2( this.Component.Position.X + this.Component.MenuWidth - (MenuSettings.ContainerHeight / 2f), this.Component.Position.Y + MenuSettings.ContainerHeight) }, MenuSettings.HoverColor); Line.End(); } if (this.Component.Active) { MenuManager.Instance.DrawDelayed( () => { Line.Width = PickerWidth; Line.Begin(); Line.Draw( new[] { new Vector2(this.pickerX + (PickerWidth / 2f), this.pickerY), new Vector2(this.pickerX + (PickerWidth / 2f), this.pickerY + this.pickerHeight) }, Color.Black); Line.End(); Line.Width = 30f; Line.Begin(); Line.Draw( new[] { new Vector2( this.pickerX + BorderOffset, this.pickerY + BorderOffset + (MenuSettings.ContainerHeight / 2f)), new Vector2( this.pickerX + PickerWidth - BorderOffset, this.pickerY + BorderOffset + (MenuSettings.ContainerHeight / 2f)) }, this.Component.Color); Line.End(); var previewColor = this.Component.Color; var detail = $"R:{previewColor.R} G:{previewColor.G} B:{previewColor.B} A:{previewColor.A}"; var rectanglePreview = new Rectangle( this.pickerX + BorderOffset, this.pickerY + BorderOffset, PickerWidth - (2 * BorderOffset), MenuSettings.ContainerHeight).GetCenteredText( null, MenuSettings.Font, detail, CenteredFlags.VerticalCenter | CenteredFlags.HorizontalCenter); MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, detail, (int)rectanglePreview.X, (int)rectanglePreview.Y, new ColorBGRA( previewColor.R > 128 ? 0 : 255, previewColor.G > 128 ? 0 : 255, previewColor.B > 128 ? 0 : 255, 255)); var textY = (int) new Rectangle( this.pickerX + BorderOffset, this.pickerY + BorderOffset + MenuSettings.ContainerHeight + SliderOffset, PickerWidth, SliderHeight).GetCenteredText( null, MenuSettings.Font, "Green", CenteredFlags.VerticalCenter).Y; // DRAW SLIDER NAMES string[] lineNames = { "Red", "Green", "Blue", "Opacity" }; for (var i = 0; i < lineNames.Length; i++) { MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, lineNames[i], this.pickerX + BorderOffset, textY + (i * (SliderOffset + SliderHeight)), Color.White); } // DRAW SLIDERS Line.Width = 1; Line.Begin(); for (var i = 1; i <= 4; i++) { Line.Draw( new[] { new Vector2( this.pickerX + BorderOffset + this.greenWidth + TextOffset, this.pickerY + BorderOffset + MenuSettings.ContainerHeight + (i * SliderOffset) + ((i - 1) * SliderHeight) + (SliderHeight / 2f)), new Vector2( this.pickerX + BorderOffset + this.greenWidth + TextOffset + this.sliderWidth, this.pickerY + BorderOffset + MenuSettings.ContainerHeight + (i * SliderOffset) + ((i - 1) * SliderHeight) + (SliderHeight / 2f)) }, Color.White); } Line.End(); // DRAW PREVIEW COLORS ColorBGRA[] previewColors = { new ColorBGRA(255, 0, 0, 255), new ColorBGRA(0, 255, 0, 255), new ColorBGRA(0, 0, 255, 255), new ColorBGRA(255, 255, 255, previewColor.A) }; Line.Width = SliderHeight; Line.Begin(); for (var i = 1; i <= 4; i++) { Line.Draw( new[] { new Vector2( this.pickerX + BorderOffset + this.greenWidth + (2 * TextOffset) + this.sliderWidth, this.pickerY + BorderOffset + MenuSettings.ContainerHeight + (i * SliderOffset) + ((i - 1) * SliderHeight) + (SliderHeight / 2f)), new Vector2( this.pickerX + BorderOffset + this.greenWidth + (2 * TextOffset) + this.sliderWidth + SliderHeight, this.pickerY + BorderOffset + MenuSettings.ContainerHeight + (i * SliderOffset) + ((i - 1) * SliderHeight) + (SliderHeight / 2f)) }, previewColors[i - 1]); } Line.End(); // DRAW SLIDER INDICATORS byte[] indicators = { previewColor.R, previewColor.G, previewColor.B, previewColor.A }; Line.Width = 2; Line.Begin(); for (var i = 0; i < indicators.Length; i++) { var x = (indicators[i] / 255f) * this.sliderWidth; Line.Draw( new[] { new Vector2( this.pickerX + BorderOffset + this.greenWidth + TextOffset + x, this.pickerY + BorderOffset + MenuSettings.ContainerHeight + ((i + 1) * SliderOffset) + (i * SliderHeight)), new Vector2( this.pickerX + BorderOffset + this.greenWidth + TextOffset + x, this.pickerY + BorderOffset + MenuSettings.ContainerHeight + ((i + 1) * SliderOffset) + ((i + 1) * SliderHeight)) }, new ColorBGRA(50, 154, 205, 255)); } 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 = DefaultUtilities.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); Line.Width = this.dropDownButtonWidth; Line.Begin(); Line.Draw( new[] { new Vector2( position.X + this.Component.MenuWidth - (this.dropDownButtonWidth / 2f), position.Y + 1), new Vector2( position.X + this.Component.MenuWidth - (this.dropDownButtonWidth / 2f), position.Y + MenuSettings.ContainerHeight) }, MenuSettings.HoverColor); Line.End(); if (this.Component.Hovering || this.Component.Active) { Line.Width = MenuSettings.ContainerHeight; Line.Begin(); Line.Draw( new[] { new Vector2( position.X + this.Component.MenuWidth - dropdownMenuWidth, position.Y + Line.Width / 2), new Vector2(position.X + this.Component.MenuWidth, position.Y + Line.Width / 2) }, MenuSettings.HoverColor); Line.End(); } MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, "V", (int)(position.X + this.Component.MenuWidth - this.dropDownButtonWidth + ArrowSpacing), (int)rectangleName.Y, MenuSettings.TextColor); Line.Width = 1f; Line.Begin(); Line.Draw( new[] { new Vector2(position.X + this.Component.MenuWidth - this.dropDownButtonWidth - 1, position.Y + 1), new Vector2( position.X + this.Component.MenuWidth - this.dropDownButtonWidth - 1, position.Y + MenuSettings.ContainerHeight) }, MenuSettings.ContainerSeparatorColor); Line.End(); 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); Line.Width = 1f; Line.Begin(); Line.Draw( new[] { new Vector2( position.X + this.Component.MenuWidth - this.dropDownButtonWidth - (2 * TextSpacing) - this.Component.MaxStringWidth, position.Y + 1), new Vector2( position.X + this.Component.MenuWidth - this.dropDownButtonWidth - (2 * TextSpacing) - this.Component.MaxStringWidth, position.Y + MenuSettings.ContainerHeight) }, 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, position.Y + (MenuSettings.ContainerHeight * (i + 1))), new Vector2( position.X + Component.MenuWidth, 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, "\u221A", 0).Width; MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, "\u221A", (int)(position.X + Component.MenuWidth - checkmarkWidth - TextSpacing), y, MenuSettings.TextColor); } } 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(); }); } }