mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Integrate beat snap divisor into editor seeking
This commit is contained in:
@ -18,6 +18,7 @@ using osu.Game.Rulesets.Edit;
|
|||||||
using osu.Game.Rulesets.Edit.Tools;
|
using osu.Game.Rulesets.Edit.Tools;
|
||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
|
using osu.Game.Screens.Edit.Screens.Compose;
|
||||||
using osu.Game.Tests.Beatmaps;
|
using osu.Game.Tests.Beatmaps;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
@ -31,6 +32,8 @@ namespace osu.Game.Tests.Visual
|
|||||||
private Track track;
|
private Track track;
|
||||||
private HitObjectComposer composer;
|
private HitObjectComposer composer;
|
||||||
|
|
||||||
|
private readonly BindableBeatDivisor beatDivisor = new BindableBeatDivisor(4);
|
||||||
|
|
||||||
private DecoupleableInterpolatingFramedClock clock;
|
private DecoupleableInterpolatingFramedClock clock;
|
||||||
|
|
||||||
private DependencyContainer dependencies;
|
private DependencyContainer dependencies;
|
||||||
@ -44,6 +47,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
clock = new DecoupleableInterpolatingFramedClock { IsCoupled = false };
|
clock = new DecoupleableInterpolatingFramedClock { IsCoupled = false };
|
||||||
dependencies.CacheAs<IAdjustableClock>(clock);
|
dependencies.CacheAs<IAdjustableClock>(clock);
|
||||||
dependencies.CacheAs<IFrameBasedClock>(clock);
|
dependencies.CacheAs<IFrameBasedClock>(clock);
|
||||||
|
dependencies.Cache(beatDivisor);
|
||||||
|
|
||||||
var testBeatmap = new Beatmap
|
var testBeatmap = new Beatmap
|
||||||
{
|
{
|
||||||
|
@ -14,6 +14,7 @@ using osu.Game.Rulesets.Osu;
|
|||||||
using osu.Game.Rulesets.Osu.Edit;
|
using osu.Game.Rulesets.Osu.Edit;
|
||||||
using osu.Game.Rulesets.Osu.Edit.Layers.Selection.Overlays;
|
using osu.Game.Rulesets.Osu.Edit.Layers.Selection.Overlays;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
|
using osu.Game.Screens.Edit.Screens.Compose;
|
||||||
using osu.Game.Screens.Edit.Screens.Compose.Layers;
|
using osu.Game.Screens.Edit.Screens.Compose.Layers;
|
||||||
using osu.Game.Tests.Beatmaps;
|
using osu.Game.Tests.Beatmaps;
|
||||||
|
|
||||||
@ -68,6 +69,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
var clock = new DecoupleableInterpolatingFramedClock { IsCoupled = false };
|
var clock = new DecoupleableInterpolatingFramedClock { IsCoupled = false };
|
||||||
dependencies.CacheAs<IAdjustableClock>(clock);
|
dependencies.CacheAs<IAdjustableClock>(clock);
|
||||||
dependencies.CacheAs<IFrameBasedClock>(clock);
|
dependencies.CacheAs<IFrameBasedClock>(clock);
|
||||||
|
dependencies.Cache(new BindableBeatDivisor());
|
||||||
|
|
||||||
Child = new OsuHitObjectComposer(new OsuRuleset());
|
Child = new OsuHitObjectComposer(new OsuRuleset());
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ using osu.Game.Beatmaps;
|
|||||||
using osu.Game.Rulesets.Edit.Tools;
|
using osu.Game.Rulesets.Edit.Tools;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.UI;
|
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.Layers;
|
||||||
using osu.Game.Screens.Edit.Screens.Compose.RadioButtons;
|
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 List<Container> layerContainers = new List<Container>();
|
||||||
|
|
||||||
private readonly Bindable<WorkingBeatmap> beatmap = new Bindable<WorkingBeatmap>();
|
private readonly Bindable<WorkingBeatmap> beatmap = new Bindable<WorkingBeatmap>();
|
||||||
|
private readonly Bindable<int> beatDivisor = new Bindable<int>();
|
||||||
|
|
||||||
private IAdjustableClock adjustableClock;
|
private IAdjustableClock adjustableClock;
|
||||||
|
|
||||||
@ -42,9 +44,10 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[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.adjustableClock = adjustableClock;
|
||||||
|
this.beatDivisor.BindTo(beatDivisor);
|
||||||
|
|
||||||
beatmap.BindTo(osuGame.Beatmap);
|
beatmap.BindTo(osuGame.Beatmap);
|
||||||
|
|
||||||
@ -167,9 +170,6 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
|
|
||||||
private void seek(int direction, bool snapped)
|
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 cpi = beatmap.Value.Beatmap.ControlPointInfo;
|
||||||
|
|
||||||
var timingPoint = cpi.TimingPointAt(adjustableClock.CurrentTime);
|
var timingPoint = cpi.TimingPointAt(adjustableClock.CurrentTime);
|
||||||
@ -181,7 +181,7 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
timingPoint = cpi.TimingPoints[--activeIndex];
|
timingPoint = cpi.TimingPoints[--activeIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
double seekAmount = timingPoint.BeatLength / beat_snap_divisor;
|
double seekAmount = timingPoint.BeatLength / beatDivisor;
|
||||||
double seekTime = adjustableClock.CurrentTime + seekAmount * direction;
|
double seekTime = adjustableClock.CurrentTime + seekAmount * direction;
|
||||||
|
|
||||||
if (!snapped || cpi.TimingPoints.Count == 0)
|
if (!snapped || cpi.TimingPoints.Count == 0)
|
||||||
@ -222,9 +222,6 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
|
|
||||||
public void SeekTo(double seekTime, bool snapped = false)
|
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)
|
if (!snapped)
|
||||||
{
|
{
|
||||||
adjustableClock.Seek(seekTime);
|
adjustableClock.Seek(seekTime);
|
||||||
@ -232,7 +229,7 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
}
|
}
|
||||||
|
|
||||||
var timingPoint = beatmap.Value.Beatmap.ControlPointInfo.TimingPointAt(seekTime);
|
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
|
// We will be snapping to beats within the timing point
|
||||||
seekTime -= timingPoint.Time;
|
seekTime -= timingPoint.Time;
|
||||||
|
@ -7,8 +7,8 @@ namespace osu.Game.Screens.Edit.Screens.Compose
|
|||||||
{
|
{
|
||||||
public class BindableBeatDivisor : Bindable<int>
|
public class BindableBeatDivisor : Bindable<int>
|
||||||
{
|
{
|
||||||
public BindableBeatDivisor()
|
public BindableBeatDivisor(int value = 1)
|
||||||
: base(1)
|
: base(value)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user