Merge branch 'master' into infrastructure

This commit is contained in:
Huo Yaoyuan 2019-11-08 21:19:59 +08:00
commit 6ebe02f409
2 changed files with 23 additions and 4 deletions

View File

@ -69,9 +69,11 @@ protected override void Update()
{
Vector2 offset = (input.CurrentState.Mouse == null ? Vector2.Zero : ToLocalSpace(input.CurrentState.Mouse.Position) - DrawSize / 2) * ParallaxAmount;
double elapsed = MathHelper.Clamp(Clock.ElapsedFrameTime, 0, 1000);
const float parallax_duration = 100;
content.Position = Interpolation.ValueAt(elapsed, content.Position, offset, 0, 1000, Easing.OutQuint);
double elapsed = MathHelper.Clamp(Clock.ElapsedFrameTime, 0, parallax_duration);
content.Position = Interpolation.ValueAt(elapsed, content.Position, offset, 0, parallax_duration, Easing.OutQuint);
content.Scale = Interpolation.ValueAt(elapsed, content.Scale, new Vector2(1 + System.Math.Abs(ParallaxAmount)), 0, 1000, Easing.OutQuint);
}

View File

@ -36,6 +36,8 @@ public class Editor : OsuScreen, IKeyBindingHandler<GlobalAction>
{
protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4");
public override float BackgroundParallaxAmount => 0.1f;
public override bool AllowBackButton => false;
public override bool HideOverlaysOnEnter => true;
@ -244,7 +246,8 @@ public override void OnEntering(IScreen last)
base.OnEntering(last);
Background.FadeColour(Color4.DarkGray, 500);
resetTrack();
resetTrack(true);
}
public override bool OnExiting(IScreen next)
@ -255,10 +258,24 @@ public override bool OnExiting(IScreen next)
return base.OnExiting(next);
}
private void resetTrack()
private void resetTrack(bool seekToStart = false)
{
Beatmap.Value.Track?.ResetSpeedAdjustments();
Beatmap.Value.Track?.Stop();
if (seekToStart)
{
double targetTime = 0;
if (Beatmap.Value.Beatmap.HitObjects.Count > 0)
{
// seek to one beat length before the first hitobject
targetTime = Beatmap.Value.Beatmap.HitObjects[0].StartTime;
targetTime -= Beatmap.Value.Beatmap.ControlPointInfo.TimingPointAt(targetTime).BeatLength;
}
clock.Seek(Math.Max(0, targetTime));
}
}
private void exportBeatmap() => host.OpenFileExternally(Beatmap.Value.Save());