Move right-side editor toolbox to base HitObjectComposer

Move right-side editor toolbox to base `HitObjectComposer`
This commit is contained in:
Dean Herbert 2023-04-04 18:53:25 +09:00
parent 1a5707b65f
commit f9ebdadfe8
3 changed files with 37 additions and 39 deletions

View File

@ -48,7 +48,6 @@ namespace osu.Game.Rulesets.Catch.Edit
private void load() private void load()
{ {
// todo: enable distance spacing once catch supports applying it to its existing distance snap grid implementation. // todo: enable distance spacing once catch supports applying it to its existing distance snap grid implementation.
RightSideToolboxContainer.Alpha = 0;
DistanceSpacingMultiplier.Disabled = true; DistanceSpacingMultiplier.Disabled = true;
LayerBelowRuleset.Add(new PlayfieldBorder LayerBelowRuleset.Add(new PlayfieldBorder

View File

@ -11,8 +11,6 @@ using osu.Framework.Bindables;
using osu.Framework.Extensions; using osu.Framework.Extensions;
using osu.Framework.Extensions.LocalisationExtensions; using osu.Framework.Extensions.LocalisationExtensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Bindings; using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
@ -47,8 +45,6 @@ namespace osu.Game.Rulesets.Edit
IBindable<double> IDistanceSnapProvider.DistanceSpacingMultiplier => DistanceSpacingMultiplier; IBindable<double> IDistanceSnapProvider.DistanceSpacingMultiplier => DistanceSpacingMultiplier;
protected ExpandingToolboxContainer RightSideToolboxContainer { get; private set; }
private ExpandableSlider<double, SizeSlider<double>> distanceSpacingSlider; private ExpandableSlider<double, SizeSlider<double>> distanceSpacingSlider;
private ExpandableButton currentDistanceSpacingButton; private ExpandableButton currentDistanceSpacingButton;
@ -67,47 +63,29 @@ namespace osu.Game.Rulesets.Edit
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider) private void load(OverlayColourProvider colourProvider)
{ {
AddInternal(new Container RightToolbox.Add(new EditorToolboxGroup("snapping")
{ {
Anchor = Anchor.TopRight, Alpha = DistanceSpacingMultiplier.Disabled ? 0 : 1,
Origin = Anchor.TopRight,
RelativeSizeAxes = Axes.Y,
AutoSizeAxes = Axes.X,
Children = new Drawable[] Children = new Drawable[]
{ {
new Box distanceSpacingSlider = new ExpandableSlider<double, SizeSlider<double>>
{ {
Colour = colourProvider.Background5, KeyboardStep = adjust_step,
RelativeSizeAxes = Axes.Both, // Manual binding in LoadComplete to handle one-way event flow.
Current = DistanceSpacingMultiplier.GetUnboundCopy(),
}, },
RightSideToolboxContainer = new ExpandingToolboxContainer(130, 250) currentDistanceSpacingButton = new ExpandableButton
{ {
Alpha = DistanceSpacingMultiplier.Disabled ? 0 : 1, Action = () =>
Child = new EditorToolboxGroup("snapping")
{ {
Children = new Drawable[] (HitObject before, HitObject after)? objects = getObjectsOnEitherSideOfCurrentTime();
{
distanceSpacingSlider = new ExpandableSlider<double, SizeSlider<double>>
{
KeyboardStep = adjust_step,
// Manual binding in LoadComplete to handle one-way event flow.
Current = DistanceSpacingMultiplier.GetUnboundCopy(),
},
currentDistanceSpacingButton = new ExpandableButton
{
Action = () =>
{
(HitObject before, HitObject after)? objects = getObjectsOnEitherSideOfCurrentTime();
Debug.Assert(objects != null); Debug.Assert(objects != null);
DistanceSpacingMultiplier.Value = ReadCurrentDistanceSnap(objects.Value.before, objects.Value.after); DistanceSpacingMultiplier.Value = ReadCurrentDistanceSnap(objects.Value.before, objects.Value.after);
DistanceSnapToggle.Value = TernaryState.True; DistanceSnapToggle.Value = TernaryState.True;
}, },
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
}
}
}
} }
} }
}); });
@ -261,7 +239,8 @@ namespace osu.Game.Rulesets.Edit
public virtual float GetBeatSnapDistanceAt(HitObject referenceObject, bool useReferenceSliderVelocity = true) public virtual float GetBeatSnapDistanceAt(HitObject referenceObject, bool useReferenceSliderVelocity = true)
{ {
return (float)(100 * (useReferenceSliderVelocity ? referenceObject.DifficultyControlPoint.SliderVelocity : 1) * EditorBeatmap.Difficulty.SliderMultiplier * 1 / BeatSnapProvider.BeatDivisor); return (float)(100 * (useReferenceSliderVelocity ? referenceObject.DifficultyControlPoint.SliderVelocity : 1) * EditorBeatmap.Difficulty.SliderMultiplier * 1
/ BeatSnapProvider.BeatDivisor);
} }
public virtual float DurationToDistance(HitObject referenceObject, double duration) public virtual float DurationToDistance(HitObject referenceObject, double duration)

View File

@ -60,6 +60,10 @@ namespace osu.Game.Rulesets.Edit
protected ComposeBlueprintContainer BlueprintContainer { get; private set; } protected ComposeBlueprintContainer BlueprintContainer { get; private set; }
protected ExpandingToolboxContainer LeftToolbox { get; private set; }
protected ExpandingToolboxContainer RightToolbox { get; private set; }
private DrawableEditorRulesetWrapper<TObject> drawableRulesetWrapper; private DrawableEditorRulesetWrapper<TObject> drawableRulesetWrapper;
protected readonly Container LayerBelowRuleset = new Container { RelativeSizeAxes = Axes.Both }; protected readonly Container LayerBelowRuleset = new Container { RelativeSizeAxes = Axes.Both };
@ -131,7 +135,7 @@ namespace osu.Game.Rulesets.Edit
Colour = colourProvider.Background5, Colour = colourProvider.Background5,
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
}, },
new ExpandingToolboxContainer(60, 200) LeftToolbox = new ExpandingToolboxContainer(60, 200)
{ {
Children = new Drawable[] Children = new Drawable[]
{ {
@ -153,6 +157,22 @@ namespace osu.Game.Rulesets.Edit
}, },
} }
}, },
new Container
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
RelativeSizeAxes = Axes.Y,
AutoSizeAxes = Axes.X,
Children = new Drawable[]
{
new Box
{
Colour = colourProvider.Background5,
RelativeSizeAxes = Axes.Both,
},
RightToolbox = new ExpandingToolboxContainer(130, 250)
}
}
}; };
toolboxCollection.Items = CompositionTools toolboxCollection.Items = CompositionTools