mirror of
https://github.com/ppy/osu.git
synced 2025-02-05 05:52:56 +08:00
Move beat snap grid implementation details to ScrollingHitObjectComposer
This commit is contained in:
parent
52c2eb93de
commit
013b5fa916
@ -40,8 +40,6 @@ namespace osu.Game.Rulesets.Catch.Edit
|
|||||||
[Cached(typeof(IDistanceSnapProvider))]
|
[Cached(typeof(IDistanceSnapProvider))]
|
||||||
protected readonly CatchDistanceSnapProvider DistanceSnapProvider = new CatchDistanceSnapProvider();
|
protected readonly CatchDistanceSnapProvider DistanceSnapProvider = new CatchDistanceSnapProvider();
|
||||||
|
|
||||||
private BeatSnapGrid beatSnapGrid = null!;
|
|
||||||
|
|
||||||
public CatchHitObjectComposer(CatchRuleset ruleset)
|
public CatchHitObjectComposer(CatchRuleset ruleset)
|
||||||
: base(ruleset)
|
: base(ruleset)
|
||||||
{
|
{
|
||||||
@ -71,44 +69,12 @@ namespace osu.Game.Rulesets.Catch.Edit
|
|||||||
Catcher.BASE_DASH_SPEED, -Catcher.BASE_DASH_SPEED,
|
Catcher.BASE_DASH_SPEED, -Catcher.BASE_DASH_SPEED,
|
||||||
Catcher.BASE_WALK_SPEED, -Catcher.BASE_WALK_SPEED,
|
Catcher.BASE_WALK_SPEED, -Catcher.BASE_WALK_SPEED,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
AddInternal(beatSnapGrid = new CatchBeatSnapGrid());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override IEnumerable<TernaryButton> CreateTernaryButtons()
|
protected override IEnumerable<TernaryButton> CreateTernaryButtons()
|
||||||
=> base.CreateTernaryButtons()
|
=> base.CreateTernaryButtons()
|
||||||
.Concat(DistanceSnapProvider.CreateTernaryButtons());
|
.Concat(DistanceSnapProvider.CreateTernaryButtons());
|
||||||
|
|
||||||
protected override void UpdateAfterChildren()
|
|
||||||
{
|
|
||||||
base.UpdateAfterChildren();
|
|
||||||
|
|
||||||
if (BlueprintContainer.CurrentTool is SelectTool)
|
|
||||||
{
|
|
||||||
if (EditorBeatmap.SelectedHitObjects.Any())
|
|
||||||
{
|
|
||||||
beatSnapGrid.SelectionTimeRange = (EditorBeatmap.SelectedHitObjects.Min(h => h.StartTime), EditorBeatmap.SelectedHitObjects.Max(h => h.GetEndTime()));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
beatSnapGrid.SelectionTimeRange = null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var result = FindSnappedPositionAndTime(InputManager.CurrentState.Mouse.Position);
|
|
||||||
if (result.Time is double time)
|
|
||||||
beatSnapGrid.SelectionTimeRange = (time, time);
|
|
||||||
else
|
|
||||||
beatSnapGrid.SelectionTimeRange = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Update()
|
|
||||||
{
|
|
||||||
base.Update();
|
|
||||||
|
|
||||||
updateDistanceSnapGrid();
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
|
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
|
||||||
{
|
{
|
||||||
switch (e.Action)
|
switch (e.Action)
|
||||||
|
@ -90,9 +90,6 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
|
|
||||||
protected DrawableRuleset<TObject> DrawableRuleset { get; private set; }
|
protected DrawableRuleset<TObject> DrawableRuleset { get; private set; }
|
||||||
|
|
||||||
[CanBeNull]
|
|
||||||
private BeatSnapGrid beatSnapGrid;
|
|
||||||
|
|
||||||
protected HitObjectComposer(Ruleset ruleset)
|
protected HitObjectComposer(Ruleset ruleset)
|
||||||
: base(ruleset)
|
: base(ruleset)
|
||||||
{
|
{
|
||||||
@ -209,8 +206,6 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Must be constructed after drawable ruleset above.
|
|
||||||
(beatSnapGrid = CreateBeatSnapGrid()) ?? Empty(),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
toolboxCollection.Items = CompositionTools
|
toolboxCollection.Items = CompositionTools
|
||||||
@ -275,37 +270,6 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void UpdateAfterChildren()
|
|
||||||
{
|
|
||||||
base.UpdateAfterChildren();
|
|
||||||
|
|
||||||
updateBeatSnapGrid();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateBeatSnapGrid()
|
|
||||||
{
|
|
||||||
if (beatSnapGrid == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (BlueprintContainer.CurrentTool is SelectTool)
|
|
||||||
{
|
|
||||||
if (EditorBeatmap.SelectedHitObjects.Any())
|
|
||||||
{
|
|
||||||
beatSnapGrid.SelectionTimeRange = (EditorBeatmap.SelectedHitObjects.Min(h => h.StartTime), EditorBeatmap.SelectedHitObjects.Max(h => h.GetEndTime()));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
beatSnapGrid.SelectionTimeRange = null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var result = FindSnappedPositionAndTime(InputManager.CurrentState.Mouse.Position);
|
|
||||||
if (result.Time is double time)
|
|
||||||
beatSnapGrid.SelectionTimeRange = (time, time);
|
|
||||||
else
|
|
||||||
beatSnapGrid.SelectionTimeRange = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Playfield Playfield => drawableRulesetWrapper.Playfield;
|
public override Playfield Playfield => drawableRulesetWrapper.Playfield;
|
||||||
|
|
||||||
public override IEnumerable<DrawableHitObject> HitObjects => drawableRulesetWrapper.Playfield.AllHitObjects;
|
public override IEnumerable<DrawableHitObject> HitObjects => drawableRulesetWrapper.Playfield.AllHitObjects;
|
||||||
@ -336,12 +300,6 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected virtual ComposeBlueprintContainer CreateBlueprintContainer() => new ComposeBlueprintContainer(this);
|
protected virtual ComposeBlueprintContainer CreateBlueprintContainer() => new ComposeBlueprintContainer(this);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Construct an optional beat snap grid.
|
|
||||||
/// </summary>
|
|
||||||
[CanBeNull]
|
|
||||||
protected virtual BeatSnapGrid CreateBeatSnapGrid() => null;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Construct a drawable ruleset for the provided ruleset.
|
/// Construct a drawable ruleset for the provided ruleset.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -8,9 +9,11 @@ using osu.Framework.Graphics.Containers;
|
|||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using osu.Game.Rulesets.Edit.Tools;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.UI.Scrolling;
|
using osu.Game.Rulesets.UI.Scrolling;
|
||||||
using osu.Game.Screens.Edit.Components.TernaryButtons;
|
using osu.Game.Screens.Edit.Components.TernaryButtons;
|
||||||
|
using osu.Game.Screens.Edit.Compose.Components;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Edit
|
namespace osu.Game.Rulesets.Edit
|
||||||
@ -21,6 +24,13 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
private readonly Bindable<TernaryState> showSpeedChanges = new Bindable<TernaryState>();
|
private readonly Bindable<TernaryState> showSpeedChanges = new Bindable<TernaryState>();
|
||||||
private Bindable<bool> configShowSpeedChanges = null!;
|
private Bindable<bool> configShowSpeedChanges = null!;
|
||||||
|
|
||||||
|
private BeatSnapGrid? beatSnapGrid;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Construct an optional beat snap grid.
|
||||||
|
/// </summary>
|
||||||
|
protected virtual BeatSnapGrid? CreateBeatSnapGrid() => null;
|
||||||
|
|
||||||
protected ScrollingHitObjectComposer(Ruleset ruleset)
|
protected ScrollingHitObjectComposer(Ruleset ruleset)
|
||||||
: base(ruleset)
|
: base(ruleset)
|
||||||
{
|
{
|
||||||
@ -57,6 +67,42 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
configShowSpeedChanges.Value = enabled;
|
configShowSpeedChanges.Value = enabled;
|
||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
beatSnapGrid = CreateBeatSnapGrid();
|
||||||
|
|
||||||
|
if (beatSnapGrid != null)
|
||||||
|
AddInternal(beatSnapGrid);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void UpdateAfterChildren()
|
||||||
|
{
|
||||||
|
base.UpdateAfterChildren();
|
||||||
|
|
||||||
|
updateBeatSnapGrid();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateBeatSnapGrid()
|
||||||
|
{
|
||||||
|
if (beatSnapGrid == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (BlueprintContainer.CurrentTool is SelectTool)
|
||||||
|
{
|
||||||
|
if (EditorBeatmap.SelectedHitObjects.Any())
|
||||||
|
{
|
||||||
|
beatSnapGrid.SelectionTimeRange = (EditorBeatmap.SelectedHitObjects.Min(h => h.StartTime), EditorBeatmap.SelectedHitObjects.Max(h => h.GetEndTime()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
beatSnapGrid.SelectionTimeRange = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var result = FindSnappedPositionAndTime(InputManager.CurrentState.Mouse.Position);
|
||||||
|
if (result.Time is double time)
|
||||||
|
beatSnapGrid.SelectionTimeRange = (time, time);
|
||||||
|
else
|
||||||
|
beatSnapGrid.SelectionTimeRange = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user