1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 09:32:55 +08:00

Integrate beat snap divisor into editor seeking

This commit is contained in:
smoogipoo 2018-03-19 20:42:06 +09:00
parent c5eab7a227
commit b1d09500f2
4 changed files with 14 additions and 11 deletions

View File

@ -18,6 +18,7 @@ using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Edit.Tools;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Screens.Edit.Screens.Compose;
using osu.Game.Tests.Beatmaps;
using OpenTK;
using OpenTK.Graphics;
@ -31,6 +32,8 @@ namespace osu.Game.Tests.Visual
private Track track;
private HitObjectComposer composer;
private readonly BindableBeatDivisor beatDivisor = new BindableBeatDivisor(4);
private DecoupleableInterpolatingFramedClock clock;
private DependencyContainer dependencies;
@ -44,6 +47,7 @@ namespace osu.Game.Tests.Visual
clock = new DecoupleableInterpolatingFramedClock { IsCoupled = false };
dependencies.CacheAs<IAdjustableClock>(clock);
dependencies.CacheAs<IFrameBasedClock>(clock);
dependencies.Cache(beatDivisor);
var testBeatmap = new Beatmap
{

View File

@ -14,6 +14,7 @@ using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Edit;
using osu.Game.Rulesets.Osu.Edit.Layers.Selection.Overlays;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Screens.Edit.Screens.Compose;
using osu.Game.Screens.Edit.Screens.Compose.Layers;
using osu.Game.Tests.Beatmaps;
@ -68,6 +69,7 @@ namespace osu.Game.Tests.Visual
var clock = new DecoupleableInterpolatingFramedClock { IsCoupled = false };
dependencies.CacheAs<IAdjustableClock>(clock);
dependencies.CacheAs<IFrameBasedClock>(clock);
dependencies.Cache(new BindableBeatDivisor());
Child = new OsuHitObjectComposer(new OsuRuleset());
}

View File

@ -16,6 +16,7 @@ using osu.Game.Beatmaps;
using osu.Game.Rulesets.Edit.Tools;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.UI;
using osu.Game.Screens.Edit.Screens.Compose;
using osu.Game.Screens.Edit.Screens.Compose.Layers;
using osu.Game.Screens.Edit.Screens.Compose.RadioButtons;
@ -31,6 +32,7 @@ namespace osu.Game.Rulesets.Edit
private readonly List<Container> layerContainers = new List<Container>();
private readonly Bindable<WorkingBeatmap> beatmap = new Bindable<WorkingBeatmap>();
private readonly Bindable<int> beatDivisor = new Bindable<int>();
private IAdjustableClock adjustableClock;
@ -42,9 +44,10 @@ namespace osu.Game.Rulesets.Edit
}
[BackgroundDependencyLoader]
private void load(OsuGameBase osuGame, IAdjustableClock adjustableClock, IFrameBasedClock framedClock)
private void load(OsuGameBase osuGame, IAdjustableClock adjustableClock, IFrameBasedClock framedClock, BindableBeatDivisor beatDivisor)
{
this.adjustableClock = adjustableClock;
this.beatDivisor.BindTo(beatDivisor);
beatmap.BindTo(osuGame.Beatmap);
@ -167,9 +170,6 @@ namespace osu.Game.Rulesets.Edit
private void seek(int direction, bool snapped)
{
// Todo: This should not be a constant, but feels good for now
const int beat_snap_divisor = 4;
var cpi = beatmap.Value.Beatmap.ControlPointInfo;
var timingPoint = cpi.TimingPointAt(adjustableClock.CurrentTime);
@ -181,7 +181,7 @@ namespace osu.Game.Rulesets.Edit
timingPoint = cpi.TimingPoints[--activeIndex];
}
double seekAmount = timingPoint.BeatLength / beat_snap_divisor;
double seekAmount = timingPoint.BeatLength / beatDivisor;
double seekTime = adjustableClock.CurrentTime + seekAmount * direction;
if (!snapped || cpi.TimingPoints.Count == 0)
@ -222,9 +222,6 @@ namespace osu.Game.Rulesets.Edit
public void SeekTo(double seekTime, bool snapped = false)
{
// Todo: This should not be a constant, but feels good for now
const int beat_snap_divisor = 4;
if (!snapped)
{
adjustableClock.Seek(seekTime);
@ -232,7 +229,7 @@ namespace osu.Game.Rulesets.Edit
}
var timingPoint = beatmap.Value.Beatmap.ControlPointInfo.TimingPointAt(seekTime);
double beatSnapLength = timingPoint.BeatLength / beat_snap_divisor;
double beatSnapLength = timingPoint.BeatLength / beatDivisor;
// We will be snapping to beats within the timing point
seekTime -= timingPoint.Time;

View File

@ -7,8 +7,8 @@ namespace osu.Game.Screens.Edit.Screens.Compose
{
public class BindableBeatDivisor : Bindable<int>
{
public BindableBeatDivisor()
: base(1)
public BindableBeatDivisor(int value = 1)
: base(value)
{
}
}