mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 06:42:54 +08:00
Add toggle for distance snap
This commit is contained in:
parent
d3957e6155
commit
fb2aced3ac
@ -5,6 +5,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Caching;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -38,6 +39,13 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
new SpinnerCompositionTool()
|
||||
};
|
||||
|
||||
private readonly BindableBool distanceSnapToggle = new BindableBool(true) { Description = "Distance Snap" };
|
||||
|
||||
protected override IEnumerable<BindableBool> Toggles => new[]
|
||||
{
|
||||
distanceSnapToggle
|
||||
};
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
@ -45,6 +53,7 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
|
||||
EditorBeatmap.SelectedHitObjects.CollectionChanged += (_, __) => updateDistanceSnapGrid();
|
||||
EditorBeatmap.PlacementObject.ValueChanged += _ => updateDistanceSnapGrid();
|
||||
distanceSnapToggle.ValueChanged += _ => updateDistanceSnapGrid();
|
||||
}
|
||||
|
||||
protected override ComposeBlueprintContainer CreateBlueprintContainer(IEnumerable<DrawableHitObject> hitObjects)
|
||||
@ -87,6 +96,10 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
{
|
||||
distanceSnapGridContainer.Clear();
|
||||
distanceSnapGridCache.Invalidate();
|
||||
distanceSnapGrid = null;
|
||||
|
||||
if (!distanceSnapToggle.Value)
|
||||
return;
|
||||
|
||||
switch (BlueprintContainer.CurrentTool)
|
||||
{
|
||||
|
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input;
|
||||
@ -13,6 +14,7 @@ using osu.Framework.Input.Events;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Overlays.Settings;
|
||||
using osu.Game.Rulesets.Configuration;
|
||||
using osu.Game.Rulesets.Edit.Tools;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
@ -94,7 +96,15 @@ namespace osu.Game.Rulesets.Edit
|
||||
Padding = new MarginPadding { Right = 10 },
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new ToolboxGroup { Child = toolboxCollection = new RadioButtonCollection { RelativeSizeAxes = Axes.X } }
|
||||
new ToolboxGroup("toolbox") { Child = toolboxCollection = new RadioButtonCollection { RelativeSizeAxes = Axes.X } },
|
||||
new ToolboxGroup("toggles")
|
||||
{
|
||||
ChildrenEnumerable = Toggles.Select(b => new SettingsCheckbox
|
||||
{
|
||||
Bindable = b,
|
||||
LabelText = b?.Description ?? "unknown"
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
new Container
|
||||
@ -156,6 +166,12 @@ namespace osu.Game.Rulesets.Edit
|
||||
/// </remarks>
|
||||
protected abstract IReadOnlyList<HitObjectCompositionTool> CompositionTools { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A collection of toggles which will be displayed to the user.
|
||||
/// The display name will be decided by <see cref="Bindable{T}.Description"/>.
|
||||
/// </summary>
|
||||
protected virtual IEnumerable<BindableBool> Toggles => Enumerable.Empty<BindableBool>();
|
||||
|
||||
/// <summary>
|
||||
/// Construct a relevant blueprint container. This will manage hitobject selection/placement input handling and display logic.
|
||||
/// </summary>
|
||||
|
@ -8,8 +8,8 @@ namespace osu.Game.Rulesets.Edit
|
||||
{
|
||||
public class ToolboxGroup : PlayerSettingsGroup
|
||||
{
|
||||
public ToolboxGroup()
|
||||
: base("toolbox")
|
||||
public ToolboxGroup(string title)
|
||||
: base(title)
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Width = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user