1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-26 20:23:00 +08:00

Implement in player

This commit is contained in:
Dean Herbert 2020-03-23 19:31:43 +09:00
parent 14a85a84bf
commit 617149fb27
4 changed files with 42 additions and 3 deletions

View File

@ -262,6 +262,17 @@ namespace osu.Game.Rulesets.UI
Playfield.Add(drawableObject); Playfield.Add(drawableObject);
} }
public override void SetRecordTarget(Replay recordingReplay)
{
if (!(KeyBindingInputManager is IHasRecordingHandler recordingInputHandler))
throw new InvalidOperationException($"A {nameof(KeyBindingInputManager)} which supports recording is not available");
var recorder = CreateReplayRecorder(recordingReplay);
recorder.ScreenSpaceToGamefield = Playfield.ScreenSpaceToGamefield;
recordingInputHandler.Recorder = recorder;
}
public override void SetReplayScore(Score replayScore) public override void SetReplayScore(Score replayScore)
{ {
if (!(KeyBindingInputManager is IHasReplayHandler replayInputManager)) if (!(KeyBindingInputManager is IHasReplayHandler replayInputManager))
@ -472,6 +483,12 @@ namespace osu.Game.Rulesets.UI
/// <param name="replayScore">The replay, null for local input.</param> /// <param name="replayScore">The replay, null for local input.</param>
public abstract void SetReplayScore(Score replayScore); public abstract void SetReplayScore(Score replayScore);
/// <summary>
/// Sets a replay to be used to record gameplay.
/// </summary>
/// <param name="recordingReplay">The target to be recorded to.</param>
public abstract void SetRecordTarget(Replay recordingReplay);
/// <summary> /// <summary>
/// Invoked when the interactive user requests resuming from a paused state. /// Invoked when the interactive user requests resuming from a paused state.
/// Allows potentially delaying the resume process until an interaction is performed. /// Allows potentially delaying the resume process until an interaction is performed.

View File

@ -24,7 +24,7 @@ using MouseState = osu.Framework.Input.States.MouseState;
namespace osu.Game.Rulesets.UI namespace osu.Game.Rulesets.UI
{ {
public abstract class RulesetInputManager<T> : PassThroughInputManager, ICanAttachKeyCounter, IHasReplayHandler public abstract class RulesetInputManager<T> : PassThroughInputManager, ICanAttachKeyCounter, IHasReplayHandler, IHasRecordingHandler
where T : struct where T : struct
{ {
private ReplayRecorder recorder; private ReplayRecorder recorder;
@ -184,6 +184,11 @@ namespace osu.Game.Rulesets.UI
ReplayInputHandler ReplayInputHandler { get; set; } ReplayInputHandler ReplayInputHandler { get; set; }
} }
public interface IHasRecordingHandler
{
public ReplayRecorder Recorder { set; }
}
/// <summary> /// <summary>
/// Supports attaching a <see cref="KeyCounterDisplay"/>. /// Supports attaching a <see cref="KeyCounterDisplay"/>.
/// Keys will be populated automatically and a receptor will be injected inside. /// Keys will be populated automatically and a receptor will be injected inside.

View File

@ -19,6 +19,7 @@ using osu.Game.Configuration;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Online.API; using osu.Game.Online.API;
using osu.Game.Overlays; using osu.Game.Overlays;
using osu.Game.Replays;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
@ -118,6 +119,23 @@ namespace osu.Game.Screens.Play
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
=> dependencies = new DependencyContainer(base.CreateChildDependencies(parent)); => dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
protected override void LoadComplete()
{
base.LoadComplete();
PrepareReplay();
}
private Replay recordingReplay;
/// <summary>
/// Run any recording / playback setup for replays.
/// </summary>
protected virtual void PrepareReplay()
{
DrawableRuleset.SetRecordTarget(recordingReplay = new Replay());
}
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(AudioManager audio, OsuConfigManager config) private void load(AudioManager audio, OsuConfigManager config)
{ {

View File

@ -18,9 +18,8 @@ namespace osu.Game.Screens.Play
this.score = score; this.score = score;
} }
protected override void LoadComplete() protected override void PrepareReplay()
{ {
base.LoadComplete();
DrawableRuleset?.SetReplayScore(score); DrawableRuleset?.SetReplayScore(score);
} }