Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust osu!taiko and osu!mania editors to not visualise velocity changes by default #24550

Merged
merged 11 commits into from
Sep 21, 2023
Merged
3 changes: 2 additions & 1 deletion osu.Game.Rulesets.Catch/Edit/CatchHitObjectComposer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
namespace osu.Game.Rulesets.Catch.Edit
{
public partial class CatchHitObjectComposer : DistancedHitObjectComposer<CatchHitObject>
// we're also a ScrollingHitObjectComposer candidate, but can't be everything can we?
{
private const float distance_snap_radius = 50;

Expand Down Expand Up @@ -140,7 +141,7 @@ public override bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
return base.OnPressed(e);
}

protected override DrawableRuleset<CatchHitObject> CreateDrawableRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod>? mods = null) =>
protected override DrawableRuleset<CatchHitObject> CreateDrawableRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods) =>
new DrawableCatchEditorRuleset(ruleset, beatmap, mods)
{
TimeRangeMultiplier = { BindTarget = timeRangeMultiplier, }
Expand Down
3 changes: 1 addition & 2 deletions osu.Game.Rulesets.Catch/UI/DrawableCatchRuleset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@ namespace osu.Game.Rulesets.Catch.UI
{
public partial class DrawableCatchRuleset : DrawableScrollingRuleset<CatchHitObject>
{
protected override ScrollVisualisationMethod VisualisationMethod => ScrollVisualisationMethod.Constant;

protected override bool UserScrollSpeedAdjustment => false;

public DrawableCatchRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod>? mods = null)
: base(ruleset, beatmap, mods)
{
Direction.Value = ScrollingDirection.Down;
TimeRange.Value = GetTimeRange(beatmap.Difficulty.ApproachRate);
VisualisationMethod = ScrollVisualisationMethod.Constant;
}

[BackgroundDependencyLoader]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void TestConstantScroll() => CreateModTest(new ModTestData
PassCondition = () =>
{
var hitObject = Player.ChildrenOfType<DrawableManiaHitObject>().FirstOrDefault();
return hitObject?.Dependencies.Get<IScrollingInfo>().Algorithm is ConstantScrollAlgorithm;
return hitObject?.Dependencies.Get<IScrollingInfo>().Algorithm.Value is ConstantScrollAlgorithm;
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private class TestScrollingInfo : IScrollingInfo

IBindable<ScrollingDirection> IScrollingInfo.Direction => Direction;
IBindable<double> IScrollingInfo.TimeRange { get; } = new Bindable<double>(5000);
IScrollAlgorithm IScrollingInfo.Algorithm { get; } = new ConstantScrollAlgorithm();
IBindable<IScrollAlgorithm> IScrollingInfo.Algorithm { get; } = new Bindable<IScrollAlgorithm>(new ConstantScrollAlgorithm());
}
}
}
15 changes: 13 additions & 2 deletions osu.Game.Rulesets.Mania/Edit/DrawableManiaEditorRuleset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,36 @@
// See the LICENCE file in the repository root for full licence text.

using System.Collections.Generic;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osuTK;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Rulesets.Mania.UI;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.UI;
using osu.Game.Rulesets.UI.Scrolling;
using osuTK;

namespace osu.Game.Rulesets.Mania.Edit
{
public partial class DrawableManiaEditorRuleset : DrawableManiaRuleset
public partial class DrawableManiaEditorRuleset : DrawableManiaRuleset, ISupportConstantAlgorithmToggle
{
public BindableBool ShowSpeedChanges { get; set; } = new BindableBool();

public new IScrollingInfo ScrollingInfo => base.ScrollingInfo;

public DrawableManiaEditorRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod>? mods)
: base(ruleset, beatmap, mods)
{
}

protected override void LoadComplete()
{
base.LoadComplete();

ShowSpeedChanges.BindValueChanged(showChanges => VisualisationMethod = showChanges.NewValue ? ScrollVisualisationMethod.Sequential : ScrollVisualisationMethod.Constant, true);
}

protected override Playfield CreatePlayfield() => new ManiaEditorPlayfield(Beatmap.Stages)
{
Anchor = Anchor.Centre,
Expand Down
4 changes: 2 additions & 2 deletions osu.Game.Rulesets.Mania/Edit/ManiaHitObjectComposer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

namespace osu.Game.Rulesets.Mania.Edit
{
public partial class ManiaHitObjectComposer : HitObjectComposer<ManiaHitObject>
public partial class ManiaHitObjectComposer : ScrollingHitObjectComposer<ManiaHitObject>
{
private DrawableManiaEditorRuleset drawableRuleset;
private ManiaBeatSnapGrid beatSnapGrid;
Expand Down Expand Up @@ -57,7 +57,7 @@ protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnl
protected override Playfield PlayfieldAtScreenSpacePosition(Vector2 screenSpacePosition) =>
Playfield.GetColumnByPosition(screenSpacePosition);

protected override DrawableRuleset<ManiaHitObject> CreateDrawableRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
protected override DrawableRuleset<ManiaHitObject> CreateDrawableRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods)
{
drawableRuleset = new DrawableManiaEditorRuleset(ruleset, beatmap, mods);

Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Mania/Mods/ManiaModConstantSpeed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class ManiaModConstantSpeed : Mod, IApplicableToDrawableRuleset<ManiaHitO
public void ApplyToDrawableRuleset(DrawableRuleset<ManiaHitObject> drawableRuleset)
{
var maniaRuleset = (DrawableManiaRuleset)drawableRuleset;
maniaRuleset.ScrollMethod = ScrollVisualisationMethod.Constant;
maniaRuleset.VisualisationMethod = ScrollVisualisationMethod.Constant;
}
}
}
18 changes: 0 additions & 18 deletions osu.Game.Rulesets.Mania/UI/DrawableManiaRuleset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#nullable disable

using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
Expand All @@ -14,7 +13,6 @@
using osu.Framework.Input;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Configuration;
using osu.Game.Input.Handlers;
using osu.Game.Replays;
using osu.Game.Rulesets.Mania.Beatmaps;
Expand Down Expand Up @@ -52,22 +50,6 @@ public partial class DrawableManiaRuleset : DrawableScrollingRuleset<ManiaHitObj

protected new ManiaRulesetConfigManager Config => (ManiaRulesetConfigManager)base.Config;

public ScrollVisualisationMethod ScrollMethod
{
get => scrollMethod;
set
{
if (IsLoaded)
throw new InvalidOperationException($"Can't alter {nameof(ScrollMethod)} after ruleset is already loaded");

scrollMethod = value;
}
}

private ScrollVisualisationMethod scrollMethod = ScrollVisualisationMethod.Sequential;

protected override ScrollVisualisationMethod VisualisationMethod => scrollMethod;

private readonly Bindable<ManiaScrollingDirection> configDirection = new Bindable<ManiaScrollingDirection>();
private readonly BindableInt configScrollSpeed = new BindableInt();
private double smoothTimeRange;
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public OsuHitObjectComposer(Ruleset ruleset)
{
}

protected override DrawableRuleset<OsuHitObject> CreateDrawableRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
protected override DrawableRuleset<OsuHitObject> CreateDrawableRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods)
=> new DrawableOsuEditorRuleset(ruleset, beatmap, mods);

protected override IReadOnlyList<HitObjectCompositionTool> CompositionTools => new HitObjectCompositionTool[]
Expand Down
37 changes: 37 additions & 0 deletions osu.Game.Rulesets.Taiko/Edit/DrawableTaikoEditorRuleset.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using System.Collections.Generic;
using osu.Framework.Bindables;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Taiko.UI;
using osu.Game.Rulesets.UI.Scrolling;

namespace osu.Game.Rulesets.Taiko.Edit
{
public partial class DrawableTaikoEditorRuleset : DrawableTaikoRuleset, ISupportConstantAlgorithmToggle
{
public BindableBool ShowSpeedChanges { get; set; } = new BindableBool();

public DrawableTaikoEditorRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods)
: base(ruleset, beatmap, mods)
{
}

protected override void LoadComplete()
{
base.LoadComplete();

ShowSpeedChanges.BindValueChanged(showChanges => VisualisationMethod = showChanges.NewValue ? ScrollVisualisationMethod.Overlapping : ScrollVisualisationMethod.Constant, true);
}

protected override double ComputeTimeRange()
{
// Adjust when we're using constant algorithm to not be sluggish.
double multiplier = ShowSpeedChanges.Value ? 1 : 4;
return base.ComputeTimeRange() / multiplier;
}
}
}
8 changes: 7 additions & 1 deletion osu.Game.Rulesets.Taiko/Edit/TaikoHitObjectComposer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
// See the LICENCE file in the repository root for full licence text.

using System.Collections.Generic;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Edit.Tools;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Taiko.Objects;
using osu.Game.Rulesets.UI;
using osu.Game.Screens.Edit.Compose.Components;

namespace osu.Game.Rulesets.Taiko.Edit
{
public partial class TaikoHitObjectComposer : HitObjectComposer<TaikoHitObject>
public partial class TaikoHitObjectComposer : ScrollingHitObjectComposer<TaikoHitObject>
{
protected override bool ApplyHorizontalCentering => false;

Expand All @@ -25,6 +28,9 @@ public TaikoHitObjectComposer(TaikoRuleset ruleset)
new SwellCompositionTool()
};

protected override DrawableRuleset<TaikoHitObject> CreateDrawableRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods) =>
new DrawableTaikoEditorRuleset(ruleset, beatmap, mods);

protected override ComposeBlueprintContainer CreateBlueprintContainer()
=> new TaikoBlueprintContainer(this);
}
Expand Down
10 changes: 7 additions & 3 deletions osu.Game.Rulesets.Taiko/UI/DrawableTaikoRuleset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ public partial class DrawableTaikoRuleset : DrawableScrollingRuleset<TaikoHitObj

public new TaikoInputManager KeyBindingInputManager => (TaikoInputManager)base.KeyBindingInputManager;

protected override ScrollVisualisationMethod VisualisationMethod => ScrollVisualisationMethod.Overlapping;

protected override bool UserScrollSpeedAdjustment => false;

private SkinnableDrawable scroller;
Expand All @@ -45,6 +43,7 @@ public DrawableTaikoRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod
: base(ruleset, beatmap, mods)
{
Direction.Value = ScrollingDirection.Left;
VisualisationMethod = ScrollVisualisationMethod.Overlapping;
}

[BackgroundDependencyLoader]
Expand All @@ -65,6 +64,11 @@ protected override void Update()
{
base.Update();

TimeRange.Value = ComputeTimeRange();
}

protected virtual double ComputeTimeRange()
{
// Taiko scrolls at a constant 100px per 1000ms. More notes become visible as the playfield is lengthened.
const float scroll_rate = 10;

Expand All @@ -73,7 +77,7 @@ protected override void Update()
// We clamp the ratio to the maximum aspect ratio to keep scroll speed consistent on widths lower than the default.
float ratio = Math.Max(DrawSize.X / 768f, TaikoPlayfieldAdjustmentContainer.MAXIMUM_ASPECT);

TimeRange.Value = (Playfield.HitObjectContainer.DrawWidth / ratio) * scroll_rate;
return (Playfield.HitObjectContainer.DrawWidth / ratio) * scroll_rate;
}

protected override void UpdateAfterChildren()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,14 +311,13 @@ private partial class TestDrawableScrollingRuleset : DrawableScrollingRuleset<Te

protected override bool RelativeScaleBeatLengths => RelativeScaleBeatLengthsOverride;

protected override ScrollVisualisationMethod VisualisationMethod => ScrollVisualisationMethod.Overlapping;

public new Bindable<double> TimeRange => base.TimeRange;

public TestDrawableScrollingRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
: base(ruleset, beatmap, mods)
{
TimeRange.Value = time_range;
VisualisationMethod = ScrollVisualisationMethod.Overlapping;
}

public override DrawableHitObject<TestHitObject> CreateDrawableRepresentation(TestHitObject h)
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Rulesets/Edit/DistancedHitObjectComposer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected DistancedHitObjectComposer(Ruleset ruleset)
}

[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider)
private void load()
{
RightToolbox.Add(new EditorToolboxGroup("snapping")
{
Expand Down
7 changes: 5 additions & 2 deletions osu.Game/Rulesets/Edit/HitObjectComposer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ public abstract partial class HitObjectComposer<TObject> : HitObjectComposer, IP
private IBindable<bool> hasTiming;
private Bindable<bool> autoSeekOnPlacement;

protected DrawableRuleset<TObject> DrawableRuleset { get; private set; }

protected HitObjectComposer(Ruleset ruleset)
: base(ruleset)
{
Expand All @@ -104,7 +106,8 @@ private void load(OsuConfigManager config)

try
{
drawableRulesetWrapper = new DrawableEditorRulesetWrapper<TObject>(CreateDrawableRuleset(Ruleset, EditorBeatmap.PlayableBeatmap, new[] { Ruleset.GetAutoplayMod() }))
DrawableRuleset = CreateDrawableRuleset(Ruleset, EditorBeatmap.PlayableBeatmap, new[] { Ruleset.GetAutoplayMod() });
drawableRulesetWrapper = new DrawableEditorRulesetWrapper<TObject>(DrawableRuleset)
{
Clock = EditorClock,
ProcessCustomClock = false
Expand Down Expand Up @@ -304,7 +307,7 @@ protected override void Update()
/// <param name="beatmap">The loaded beatmap.</param>
/// <param name="mods">The mods to be applied.</param>
/// <returns>An editor-relevant <see cref="DrawableRuleset{TObject}"/>.</returns>
protected virtual DrawableRuleset<TObject> CreateDrawableRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
protected virtual DrawableRuleset<TObject> CreateDrawableRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods)
=> (DrawableRuleset<TObject>)ruleset.CreateDrawableRulesetWith(beatmap, mods);

#region Tool selection logic
Expand Down
51 changes: 51 additions & 0 deletions osu.Game/Rulesets/Edit/ScrollingHitObjectComposer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.UI.Scrolling;
using osu.Game.Screens.Edit.Components.TernaryButtons;
using osuTK;

namespace osu.Game.Rulesets.Edit
{
public abstract partial class ScrollingHitObjectComposer<TObject> : HitObjectComposer<TObject>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This though I'm feeling kind of bearish about since it's starting to feel like a potential future inheritance finger trap. But I trust that we'll be able to recognise when it gets bad enough so probably fine for now...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah.

where TObject : HitObject
{
private readonly Bindable<TernaryState> showSpeedChanges = new Bindable<TernaryState>();

protected ScrollingHitObjectComposer(Ruleset ruleset)
: base(ruleset)
{
}

[BackgroundDependencyLoader]
private void load()
{
if (DrawableRuleset is ISupportConstantAlgorithmToggle toggleRuleset)
{
LeftToolbox.Add(new EditorToolboxGroup("playfield")
{
Child = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 5),
Children = new[]
{
new DrawableTernaryButton(new TernaryButton(showSpeedChanges, "Show speed changes", () => new SpriteIcon { Icon = FontAwesome.Solid.TachometerAlt }))
}
},
});

showSpeedChanges.BindValueChanged(state => toggleRuleset.ShowSpeedChanges.Value = state.NewValue == TernaryState.True, true);
}
}
}
}
Loading