1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 21:47:25 +08:00

Merge branch 'master' into remove-hud-overlay-unused-pieces

This commit is contained in:
Dan Balasescu 2021-05-10 14:39:32 +09:00 committed by GitHub
commit 78952c07b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 66 additions and 107 deletions

View File

@ -1,28 +1,22 @@
// 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 System.Collections.Generic;
using osu.Game.Beatmaps;
using osu.Game.Replays;
using osu.Game.Rulesets.EmptyFreeform.Objects;
using osu.Game.Rulesets.Replays;
namespace osu.Game.Rulesets.EmptyFreeform.Replays
{
public class EmptyFreeformAutoGenerator : AutoGenerator
public class EmptyFreeformAutoGenerator : AutoGenerator<EmptyFreeformReplayFrame>
{
protected Replay Replay;
protected List<ReplayFrame> Frames => Replay.Frames;
public new Beatmap<EmptyFreeformHitObject> Beatmap => (Beatmap<EmptyFreeformHitObject>)base.Beatmap;
public EmptyFreeformAutoGenerator(IBeatmap beatmap)
: base(beatmap)
{
Replay = new Replay();
}
public override Replay Generate()
protected override void GenerateFrames()
{
Frames.Add(new EmptyFreeformReplayFrame());
@ -35,8 +29,6 @@ namespace osu.Game.Rulesets.EmptyFreeform.Replays
// todo: add required inputs and extra frames.
});
}
return Replay;
}
}
}

View File

@ -1,28 +1,22 @@
// 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 System.Collections.Generic;
using osu.Game.Beatmaps;
using osu.Game.Replays;
using osu.Game.Rulesets.Pippidon.Objects;
using osu.Game.Rulesets.Replays;
namespace osu.Game.Rulesets.Pippidon.Replays
{
public class PippidonAutoGenerator : AutoGenerator
public class PippidonAutoGenerator : AutoGenerator<PippidonReplayFrame>
{
protected Replay Replay;
protected List<ReplayFrame> Frames => Replay.Frames;
public new Beatmap<PippidonHitObject> Beatmap => (Beatmap<PippidonHitObject>)base.Beatmap;
public PippidonAutoGenerator(IBeatmap beatmap)
: base(beatmap)
{
Replay = new Replay();
}
public override Replay Generate()
protected override void GenerateFrames()
{
Frames.Add(new PippidonReplayFrame());
@ -34,8 +28,6 @@ namespace osu.Game.Rulesets.Pippidon.Replays
Position = hitObject.Position,
});
}
return Replay;
}
}
}

View File

@ -1,28 +1,22 @@
// 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 System.Collections.Generic;
using osu.Game.Beatmaps;
using osu.Game.Replays;
using osu.Game.Rulesets.EmptyScrolling.Objects;
using osu.Game.Rulesets.Replays;
namespace osu.Game.Rulesets.EmptyScrolling.Replays
{
public class EmptyScrollingAutoGenerator : AutoGenerator
public class EmptyScrollingAutoGenerator : AutoGenerator<EmptyScrollingReplayFrame>
{
protected Replay Replay;
protected List<ReplayFrame> Frames => Replay.Frames;
public new Beatmap<EmptyScrollingHitObject> Beatmap => (Beatmap<EmptyScrollingHitObject>)base.Beatmap;
public EmptyScrollingAutoGenerator(IBeatmap beatmap)
: base(beatmap)
{
Replay = new Replay();
}
public override Replay Generate()
protected override void GenerateFrames()
{
Frames.Add(new EmptyScrollingReplayFrame());
@ -34,8 +28,6 @@ namespace osu.Game.Rulesets.EmptyScrolling.Replays
// todo: add required inputs and extra frames.
});
}
return Replay;
}
}
}

View File

@ -2,29 +2,23 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using osu.Game.Beatmaps;
using osu.Game.Replays;
using osu.Game.Rulesets.Pippidon.Objects;
using osu.Game.Rulesets.Pippidon.UI;
using osu.Game.Rulesets.Replays;
namespace osu.Game.Rulesets.Pippidon.Replays
{
public class PippidonAutoGenerator : AutoGenerator
public class PippidonAutoGenerator : AutoGenerator<PippidonReplayFrame>
{
protected Replay Replay;
protected List<ReplayFrame> Frames => Replay.Frames;
public new Beatmap<PippidonHitObject> Beatmap => (Beatmap<PippidonHitObject>)base.Beatmap;
public PippidonAutoGenerator(IBeatmap beatmap)
: base(beatmap)
{
Replay = new Replay();
}
public override Replay Generate()
protected override void GenerateFrames()
{
int currentLane = 0;
@ -55,8 +49,6 @@ namespace osu.Game.Rulesets.Pippidon.Replays
currentLane = hitObject.Lane;
}
return Replay;
}
private void addFrame(double time, PippidonAction direction)

View File

@ -5,7 +5,6 @@ using System;
using System.Linq;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
using osu.Game.Replays;
using osu.Game.Rulesets.Catch.Beatmaps;
using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Catch.UI;
@ -13,26 +12,19 @@ using osu.Game.Rulesets.Replays;
namespace osu.Game.Rulesets.Catch.Replays
{
internal class CatchAutoGenerator : AutoGenerator
internal class CatchAutoGenerator : AutoGenerator<CatchReplayFrame>
{
public const double RELEASE_DELAY = 20;
public new CatchBeatmap Beatmap => (CatchBeatmap)base.Beatmap;
public CatchAutoGenerator(IBeatmap beatmap)
: base(beatmap)
{
Replay = new Replay();
}
protected Replay Replay;
private CatchReplayFrame currentFrame;
public override Replay Generate()
protected override void GenerateFrames()
{
if (Beatmap.HitObjects.Count == 0)
return Replay;
return;
// todo: add support for HT DT
const double dash_speed = Catcher.BASE_SPEED;
@ -119,15 +111,11 @@ namespace osu.Game.Rulesets.Catch.Replays
}
}
}
return Replay;
}
private void addFrame(double time, float? position = null, bool dashing = false)
{
var last = currentFrame;
currentFrame = new CatchReplayFrame(time, position, dashing, last);
Replay.Frames.Add(currentFrame);
Frames.Add(new CatchReplayFrame(time, position, dashing, LastFrame));
}
}
}

View File

@ -3,7 +3,6 @@
using System.Collections.Generic;
using System.Linq;
using osu.Game.Replays;
using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.Objects;
@ -11,7 +10,7 @@ using osu.Game.Rulesets.Replays;
namespace osu.Game.Rulesets.Mania.Replays
{
internal class ManiaAutoGenerator : AutoGenerator
internal class ManiaAutoGenerator : AutoGenerator<ManiaReplayFrame>
{
public const double RELEASE_DELAY = 20;
@ -22,8 +21,6 @@ namespace osu.Game.Rulesets.Mania.Replays
public ManiaAutoGenerator(ManiaBeatmap beatmap)
: base(beatmap)
{
Replay = new Replay();
columnActions = new ManiaAction[Beatmap.TotalColumns];
var normalAction = ManiaAction.Key1;
@ -43,12 +40,10 @@ namespace osu.Game.Rulesets.Mania.Replays
}
}
protected Replay Replay;
public override Replay Generate()
protected override void GenerateFrames()
{
if (Beatmap.HitObjects.Count == 0)
return Replay;
return;
var pointGroups = generateActionPoints().GroupBy(a => a.Time).OrderBy(g => g.First().Time);
@ -70,10 +65,8 @@ namespace osu.Game.Rulesets.Mania.Replays
}
}
Replay.Frames.Add(new ManiaReplayFrame(group.First().Time, actions.ToArray()));
Frames.Add(new ManiaReplayFrame(group.First().Time, actions.ToArray()));
}
return Replay;
}
private IEnumerable<IActionPoint> generateActionPoints()

View File

@ -2,10 +2,8 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Game.Beatmaps;
using osu.Game.Replays;
using osu.Game.Rulesets.Taiko.Objects;
using osu.Game.Rulesets.Replays;
using osu.Game.Rulesets.Taiko.Beatmaps;
@ -13,7 +11,7 @@ using osu.Game.Rulesets.Objects;
namespace osu.Game.Rulesets.Taiko.Replays
{
public class TaikoAutoGenerator : AutoGenerator
public class TaikoAutoGenerator : AutoGenerator<TaikoReplayFrame>
{
public new TaikoBeatmap Beatmap => (TaikoBeatmap)base.Beatmap;
@ -22,16 +20,12 @@ namespace osu.Game.Rulesets.Taiko.Replays
public TaikoAutoGenerator(IBeatmap beatmap)
: base(beatmap)
{
Replay = new Replay();
}
protected Replay Replay;
protected List<ReplayFrame> Frames => Replay.Frames;
public override Replay Generate()
protected override void GenerateFrames()
{
if (Beatmap.HitObjects.Count == 0)
return Replay;
return;
bool hitButton = true;
@ -128,8 +122,6 @@ namespace osu.Game.Rulesets.Taiko.Replays
hitButton = !hitButton;
}
return Replay;
}
}
}

View File

@ -1,40 +1,36 @@
// 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 System.Collections.Generic;
using System.Linq;
using JetBrains.Annotations;
using osu.Game.Beatmaps;
using osu.Game.Replays;
using osu.Game.Rulesets.Objects;
namespace osu.Game.Rulesets.Replays
{
public abstract class AutoGenerator : IAutoGenerator
public abstract class AutoGenerator
{
/// <summary>
/// Creates the auto replay and returns it.
/// Every subclass of OsuAutoGeneratorBase should implement this!
/// The default duration of a key press in milliseconds.
/// </summary>
public abstract Replay Generate();
#region Parameters
public const double KEY_UP_DELAY = 50;
/// <summary>
/// The beatmap we're making.
/// The beatmap the autoplay is generated for.
/// </summary>
protected IBeatmap Beatmap;
#endregion
protected IBeatmap Beatmap { get; }
protected AutoGenerator(IBeatmap beatmap)
{
Beatmap = beatmap;
}
#region Constants
// Shared amongst all modes
public const double KEY_UP_DELAY = 50;
#endregion
/// <summary>
/// Generate the replay of the autoplay.
/// </summary>
public abstract Replay Generate();
protected virtual HitObject GetNextObject(int currentIndex)
{
@ -44,4 +40,37 @@ namespace osu.Game.Rulesets.Replays
return Beatmap.HitObjects[currentIndex + 1];
}
}
public abstract class AutoGenerator<TFrame> : AutoGenerator
where TFrame : ReplayFrame
{
/// <summary>
/// The replay frames of the autoplay.
/// </summary>
protected readonly List<TFrame> Frames = new List<TFrame>();
[CanBeNull]
protected TFrame LastFrame => Frames.Count == 0 ? null : Frames[^1];
protected AutoGenerator(IBeatmap beatmap)
: base(beatmap)
{
}
public sealed override Replay Generate()
{
Frames.Clear();
GenerateFrames();
return new Replay
{
Frames = Frames.OrderBy(frame => frame.Time).Cast<ReplayFrame>().ToList()
};
}
/// <summary>
/// Generate the replay frames of the autoplay and populate <see cref="Frames"/>.
/// </summary>
protected abstract void GenerateFrames();
}
}

View File

@ -1,12 +0,0 @@
// 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.Game.Replays;
namespace osu.Game.Rulesets.Replays
{
public interface IAutoGenerator
{
Replay Generate();
}
}

View File

@ -39,7 +39,8 @@ namespace osu.Game.Screens.Play.HUD
private void onNewJudgement(JudgementResult judgement)
{
if (judgement.IsHit && judgement.Type != HitResult.IgnoreHit) Flash(judgement);
if (judgement.IsHit && judgement.Type != HitResult.IgnoreHit)
Flash(judgement);
}
protected override void Dispose(bool isDisposing)