mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 17:43:05 +08:00
Implement in player
This commit is contained in:
parent
14a85a84bf
commit
617149fb27
@ -262,6 +262,17 @@ namespace osu.Game.Rulesets.UI
|
||||
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)
|
||||
{
|
||||
if (!(KeyBindingInputManager is IHasReplayHandler replayInputManager))
|
||||
@ -472,6 +483,12 @@ namespace osu.Game.Rulesets.UI
|
||||
/// <param name="replayScore">The replay, null for local input.</param>
|
||||
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>
|
||||
/// Invoked when the interactive user requests resuming from a paused state.
|
||||
/// Allows potentially delaying the resume process until an interaction is performed.
|
||||
|
@ -24,7 +24,7 @@ using MouseState = osu.Framework.Input.States.MouseState;
|
||||
|
||||
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
|
||||
{
|
||||
private ReplayRecorder recorder;
|
||||
@ -184,6 +184,11 @@ namespace osu.Game.Rulesets.UI
|
||||
ReplayInputHandler ReplayInputHandler { get; set; }
|
||||
}
|
||||
|
||||
public interface IHasRecordingHandler
|
||||
{
|
||||
public ReplayRecorder Recorder { set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Supports attaching a <see cref="KeyCounterDisplay"/>.
|
||||
/// Keys will be populated automatically and a receptor will be injected inside.
|
||||
|
@ -19,6 +19,7 @@ using osu.Game.Configuration;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Replays;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
@ -118,6 +119,23 @@ namespace osu.Game.Screens.Play
|
||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer 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]
|
||||
private void load(AudioManager audio, OsuConfigManager config)
|
||||
{
|
||||
|
@ -18,9 +18,8 @@ namespace osu.Game.Screens.Play
|
||||
this.score = score;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
protected override void PrepareReplay()
|
||||
{
|
||||
base.LoadComplete();
|
||||
DrawableRuleset?.SetReplayScore(score);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user