mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 09:27:29 +08:00
Move toggle implementation to work on all scrolling rulesets automatically
This commit is contained in:
parent
6ce251fbb5
commit
37c2b330a2
@ -26,6 +26,7 @@ using osuTK;
|
|||||||
namespace osu.Game.Rulesets.Catch.Edit
|
namespace osu.Game.Rulesets.Catch.Edit
|
||||||
{
|
{
|
||||||
public partial class CatchHitObjectComposer : DistancedHitObjectComposer<CatchHitObject>
|
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;
|
private const float distance_snap_radius = 50;
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Mods
|
|||||||
PassCondition = () =>
|
PassCondition = () =>
|
||||||
{
|
{
|
||||||
var hitObject = Player.ChildrenOfType<DrawableManiaHitObject>().FirstOrDefault();
|
var hitObject = Player.ChildrenOfType<DrawableManiaHitObject>().FirstOrDefault();
|
||||||
return hitObject?.Dependencies.Get<IScrollingInfo>().Algorithm is ConstantScrollAlgorithm;
|
return hitObject?.Dependencies.Get<IScrollingInfo>().Algorithm.Value is ConstantScrollAlgorithm;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -2,23 +2,18 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using osu.Framework.Bindables;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osuTK;
|
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Configuration;
|
|
||||||
using osu.Game.Graphics.UserInterface;
|
|
||||||
using osu.Game.Rulesets.Mania.UI;
|
using osu.Game.Rulesets.Mania.UI;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
using osu.Game.Rulesets.UI.Scrolling;
|
using osu.Game.Rulesets.UI.Scrolling;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.Edit
|
namespace osu.Game.Rulesets.Mania.Edit
|
||||||
{
|
{
|
||||||
public partial class DrawableManiaEditorRuleset : DrawableManiaRuleset
|
public partial class DrawableManiaEditorRuleset : DrawableManiaRuleset
|
||||||
{
|
{
|
||||||
public readonly IBindable<TernaryState> ShowSpeedChanges = new Bindable<TernaryState>();
|
|
||||||
|
|
||||||
public new IScrollingInfo ScrollingInfo => base.ScrollingInfo;
|
public new IScrollingInfo ScrollingInfo => base.ScrollingInfo;
|
||||||
|
|
||||||
public DrawableManiaEditorRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod>? mods)
|
public DrawableManiaEditorRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod>? mods)
|
||||||
@ -26,18 +21,6 @@ namespace osu.Game.Rulesets.Mania.Edit
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
|
||||||
{
|
|
||||||
base.LoadComplete();
|
|
||||||
|
|
||||||
ShowSpeedChanges.BindValueChanged(state =>
|
|
||||||
{
|
|
||||||
VisualisationMethod = state.NewValue == TernaryState.True
|
|
||||||
? ScrollVisualisationMethod.Sequential
|
|
||||||
: ScrollVisualisationMethod.Constant;
|
|
||||||
}, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override Playfield CreatePlayfield() => new ManiaEditorPlayfield(Beatmap.Stages)
|
protected override Playfield CreatePlayfield() => new ManiaEditorPlayfield(Beatmap.Stages)
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
|
@ -6,13 +6,8 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Framework.Graphics.Sprites;
|
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics.UserInterface;
|
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
using osu.Game.Rulesets.Edit.Tools;
|
using osu.Game.Rulesets.Edit.Tools;
|
||||||
using osu.Game.Rulesets.Mania.Objects;
|
using osu.Game.Rulesets.Mania.Objects;
|
||||||
@ -21,16 +16,13 @@ using osu.Game.Rulesets.Mods;
|
|||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
using osu.Game.Rulesets.UI.Scrolling;
|
using osu.Game.Rulesets.UI.Scrolling;
|
||||||
using osu.Game.Screens.Edit.Components.TernaryButtons;
|
|
||||||
using osu.Game.Screens.Edit.Compose.Components;
|
using osu.Game.Screens.Edit.Compose.Components;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.Edit
|
namespace osu.Game.Rulesets.Mania.Edit
|
||||||
{
|
{
|
||||||
public partial class ManiaHitObjectComposer : HitObjectComposer<ManiaHitObject>
|
public partial class ManiaHitObjectComposer : ScrollingHitObjectComposer<ManiaHitObject>
|
||||||
{
|
{
|
||||||
private readonly Bindable<TernaryState> showSpeedChanges = new Bindable<TernaryState>();
|
|
||||||
|
|
||||||
private DrawableManiaEditorRuleset drawableRuleset;
|
private DrawableManiaEditorRuleset drawableRuleset;
|
||||||
private ManiaBeatSnapGrid beatSnapGrid;
|
private ManiaBeatSnapGrid beatSnapGrid;
|
||||||
private InputManager inputManager;
|
private InputManager inputManager;
|
||||||
@ -44,21 +36,6 @@ namespace osu.Game.Rulesets.Mania.Edit
|
|||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
AddInternal(beatSnapGrid = new ManiaBeatSnapGrid());
|
AddInternal(beatSnapGrid = new ManiaBeatSnapGrid());
|
||||||
|
|
||||||
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 }))
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
@ -82,10 +59,7 @@ namespace osu.Game.Rulesets.Mania.Edit
|
|||||||
|
|
||||||
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 = null)
|
||||||
{
|
{
|
||||||
drawableRuleset = new DrawableManiaEditorRuleset(ruleset, beatmap, mods)
|
drawableRuleset = new DrawableManiaEditorRuleset(ruleset, beatmap, mods);
|
||||||
{
|
|
||||||
ShowSpeedChanges = { BindTarget = showSpeedChanges }
|
|
||||||
};
|
|
||||||
|
|
||||||
// This is the earliest we can cache the scrolling info to ourselves, before masks are added to the hierarchy and inject it
|
// This is the earliest we can cache the scrolling info to ourselves, before masks are added to the hierarchy and inject it
|
||||||
dependencies.CacheAs(drawableRuleset.ScrollingInfo);
|
dependencies.CacheAs(drawableRuleset.ScrollingInfo);
|
||||||
|
@ -9,7 +9,7 @@ using osu.Game.Screens.Edit.Compose.Components;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Taiko.Edit
|
namespace osu.Game.Rulesets.Taiko.Edit
|
||||||
{
|
{
|
||||||
public partial class TaikoHitObjectComposer : HitObjectComposer<TaikoHitObject>
|
public partial class TaikoHitObjectComposer : ScrollingHitObjectComposer<TaikoHitObject>
|
||||||
{
|
{
|
||||||
protected override bool ApplyHorizontalCentering => false;
|
protected override bool ApplyHorizontalCentering => false;
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OverlayColourProvider colourProvider)
|
private void load()
|
||||||
{
|
{
|
||||||
RightToolbox.Add(new EditorToolboxGroup("snapping")
|
RightToolbox.Add(new EditorToolboxGroup("snapping")
|
||||||
{
|
{
|
||||||
|
@ -87,6 +87,8 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
private IBindable<bool> hasTiming;
|
private IBindable<bool> hasTiming;
|
||||||
private Bindable<bool> autoSeekOnPlacement;
|
private Bindable<bool> autoSeekOnPlacement;
|
||||||
|
|
||||||
|
protected DrawableRuleset<TObject> DrawableRuleset { get; private set; }
|
||||||
|
|
||||||
protected HitObjectComposer(Ruleset ruleset)
|
protected HitObjectComposer(Ruleset ruleset)
|
||||||
: base(ruleset)
|
: base(ruleset)
|
||||||
{
|
{
|
||||||
@ -104,7 +106,8 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
|
|
||||||
try
|
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,
|
Clock = EditorClock,
|
||||||
ProcessCustomClock = false
|
ProcessCustomClock = false
|
||||||
|
62
osu.Game/Rulesets/Edit/ScrollingHitObjectComposer.cs
Normal file
62
osu.Game/Rulesets/Edit/ScrollingHitObjectComposer.cs
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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.Configuration;
|
||||||
|
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>
|
||||||
|
where TObject : HitObject
|
||||||
|
{
|
||||||
|
private readonly Bindable<TernaryState> showSpeedChanges = new Bindable<TernaryState>();
|
||||||
|
|
||||||
|
protected ScrollingHitObjectComposer(Ruleset ruleset)
|
||||||
|
: base(ruleset)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
if (DrawableRuleset is DrawableScrollingRuleset<TObject> drawableScrollingRuleset)
|
||||||
|
{
|
||||||
|
var originalVisualisationMethod = drawableScrollingRuleset.VisualisationMethod;
|
||||||
|
|
||||||
|
if (originalVisualisationMethod != ScrollVisualisationMethod.Constant)
|
||||||
|
{
|
||||||
|
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 =>
|
||||||
|
{
|
||||||
|
drawableScrollingRuleset.VisualisationMethod = state.NewValue == TernaryState.True
|
||||||
|
? originalVisualisationMethod
|
||||||
|
: ScrollVisualisationMethod.Constant;
|
||||||
|
}, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user