mirror of
https://github.com/ppy/osu
synced 2025-01-11 08:39:31 +00:00
Update autoplay and replay handling to result in actions, not keys
This commit is contained in:
parent
189988236b
commit
a7a7e0323f
32
osu.Game.Rulesets.Osu/Replays/OsuReplayInputHandler.cs
Normal file
32
osu.Game.Rulesets.Osu/Replays/OsuReplayInputHandler.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Rulesets.Replays;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Replays
|
||||
{
|
||||
public class OsuReplayInputHandler : FramedReplayInputHandler
|
||||
{
|
||||
public OsuReplayInputHandler(Replay replay)
|
||||
: base(replay)
|
||||
{
|
||||
}
|
||||
|
||||
public override List<InputState> GetPendingStates()
|
||||
{
|
||||
List<OsuAction> actions = new List<OsuAction>();
|
||||
|
||||
if (CurrentFrame?.MouseLeft ?? false) actions.Add(OsuAction.LeftButton);
|
||||
if (CurrentFrame?.MouseRight ?? false) actions.Add(OsuAction.RightButton);
|
||||
|
||||
return new List<InputState>
|
||||
{
|
||||
new ReplayState<OsuAction>
|
||||
{
|
||||
Mouse = new ReplayMouseState(ToScreenSpace(Position ?? Vector2.Zero)),
|
||||
PressedActions = actions
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -10,9 +10,11 @@ using osu.Game.Rulesets.Osu.Beatmaps;
|
||||
using osu.Game.Rulesets.Osu.Judgements;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Osu.Replays;
|
||||
using osu.Game.Rulesets.Osu.Scoring;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Rulesets.Replays;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.UI
|
||||
{
|
||||
@ -49,6 +51,8 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
return null;
|
||||
}
|
||||
|
||||
protected override FramedReplayInputHandler CreateReplayInputHandler(Replay replay) => new OsuReplayInputHandler(replay);
|
||||
|
||||
protected override Vector2 GetPlayfieldAspectAdjust() => new Vector2(0.75f);
|
||||
}
|
||||
}
|
||||
|
@ -78,6 +78,7 @@
|
||||
<Compile Include="OsuDifficulty\Skills\Speed.cs" />
|
||||
<Compile Include="OsuDifficulty\Utils\History.cs" />
|
||||
<Compile Include="OsuInputManager.cs" />
|
||||
<Compile Include="Replays\OsuReplayInputHandler.cs" />
|
||||
<Compile Include="UI\Cursor\CursorTrail.cs" />
|
||||
<Compile Include="UI\Cursor\GameplayCursor.cs" />
|
||||
<Compile Include="UI\OsuSettings.cs" />
|
||||
|
@ -4,7 +4,6 @@
|
||||
using osu.Game.Rulesets.Replays;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Input;
|
||||
using OpenTK.Input;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Replays
|
||||
{
|
||||
@ -17,21 +16,18 @@ namespace osu.Game.Rulesets.Taiko.Replays
|
||||
|
||||
public override List<InputState> GetPendingStates()
|
||||
{
|
||||
var keys = new List<Key>();
|
||||
var keys = new List<TaikoAction>();
|
||||
|
||||
if (CurrentFrame?.MouseRight1 == true)
|
||||
keys.Add(Key.F);
|
||||
keys.Add(TaikoAction.LeftCentre);
|
||||
if (CurrentFrame?.MouseRight2 == true)
|
||||
keys.Add(Key.J);
|
||||
keys.Add(TaikoAction.RightCentre);
|
||||
if (CurrentFrame?.MouseLeft1 == true)
|
||||
keys.Add(Key.D);
|
||||
keys.Add(TaikoAction.LeftRim);
|
||||
if (CurrentFrame?.MouseLeft2 == true)
|
||||
keys.Add(Key.K);
|
||||
keys.Add(TaikoAction.RightRim);
|
||||
|
||||
return new List<InputState>
|
||||
{
|
||||
new InputState { Keyboard = new ReplayKeyboardState(keys) }
|
||||
};
|
||||
return new List<InputState> { new ReplayState<TaikoAction> { PressedActions = keys } };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,8 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Input.Handlers;
|
||||
using osu.Framework.Platform;
|
||||
using OpenTK;
|
||||
@ -29,5 +31,18 @@ namespace osu.Game.Input.Handlers
|
||||
public override bool IsActive => true;
|
||||
|
||||
public override int Priority => 0;
|
||||
|
||||
public class ReplayState<T> : InputState
|
||||
where T : struct
|
||||
{
|
||||
public List<T> PressedActions;
|
||||
|
||||
public override InputState Clone()
|
||||
{
|
||||
var clone = (ReplayState<T>)base.Clone();
|
||||
clone.PressedActions = new List<T>(PressedActions);
|
||||
return clone;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -3,7 +3,6 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Game.Input.Handlers;
|
||||
@ -18,7 +17,7 @@ namespace osu.Game.Rulesets.Replays
|
||||
/// The ReplayHandler will take a replay and handle the propagation of updates to the input stack.
|
||||
/// It handles logic of any frames which *must* be executed.
|
||||
/// </summary>
|
||||
public class FramedReplayInputHandler : ReplayInputHandler
|
||||
public abstract class FramedReplayInputHandler : ReplayInputHandler
|
||||
{
|
||||
private readonly Replay replay;
|
||||
|
||||
@ -31,7 +30,7 @@ namespace osu.Game.Rulesets.Replays
|
||||
|
||||
private int nextFrameIndex => MathHelper.Clamp(currentFrameIndex + (currentDirection > 0 ? 1 : -1), 0, Frames.Count - 1);
|
||||
|
||||
public FramedReplayInputHandler(Replay replay)
|
||||
protected FramedReplayInputHandler(Replay replay)
|
||||
{
|
||||
this.replay = replay;
|
||||
}
|
||||
@ -51,7 +50,7 @@ namespace osu.Game.Rulesets.Replays
|
||||
{
|
||||
}
|
||||
|
||||
private Vector2? position
|
||||
protected Vector2? Position
|
||||
{
|
||||
get
|
||||
{
|
||||
@ -62,23 +61,7 @@ namespace osu.Game.Rulesets.Replays
|
||||
}
|
||||
}
|
||||
|
||||
public override List<InputState> GetPendingStates()
|
||||
{
|
||||
var buttons = new HashSet<MouseButton>();
|
||||
if (CurrentFrame?.MouseLeft ?? false)
|
||||
buttons.Add(MouseButton.Left);
|
||||
if (CurrentFrame?.MouseRight ?? false)
|
||||
buttons.Add(MouseButton.Right);
|
||||
|
||||
return new List<InputState>
|
||||
{
|
||||
new InputState
|
||||
{
|
||||
Mouse = new ReplayMouseState(ToScreenSpace(position ?? Vector2.Zero), buttons),
|
||||
Keyboard = new ReplayKeyboardState(new List<Key>())
|
||||
}
|
||||
};
|
||||
}
|
||||
public override List<InputState> GetPendingStates() => new List<InputState>();
|
||||
|
||||
public bool AtLastFrame => currentFrameIndex == Frames.Count - 1;
|
||||
public bool AtFirstFrame => currentFrameIndex == 0;
|
||||
@ -133,10 +116,9 @@ namespace osu.Game.Rulesets.Replays
|
||||
|
||||
protected class ReplayMouseState : MouseState
|
||||
{
|
||||
public ReplayMouseState(Vector2 position, IEnumerable<MouseButton> list)
|
||||
public ReplayMouseState(Vector2 position)
|
||||
{
|
||||
Position = position;
|
||||
list.ForEach(b => SetPressed(b, true));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ namespace osu.Game.Rulesets.UI
|
||||
/// <returns>The input manager.</returns>
|
||||
public abstract PassThroughInputManager CreateInputManager();
|
||||
|
||||
protected virtual FramedReplayInputHandler CreateReplayInputHandler(Replay replay) => new FramedReplayInputHandler(replay);
|
||||
protected virtual FramedReplayInputHandler CreateReplayInputHandler(Replay replay) => null;
|
||||
|
||||
public Replay Replay { get; private set; }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user