mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 09:07:25 +08:00
Fix FramedReplayInputHandler starting at frame 0 when it shouldn't
This commit is contained in:
parent
fc59e6dec5
commit
148e26a6d4
@ -18,16 +18,18 @@ namespace osu.Game.Rulesets.Osu.Replays
|
||||
{
|
||||
}
|
||||
|
||||
protected override bool IsImportant(OsuReplayFrame frame) => frame.Actions.Any();
|
||||
protected override bool IsImportant(OsuReplayFrame frame) => frame?.Actions.Any() ?? false;
|
||||
|
||||
protected Vector2? Position
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!HasFrames)
|
||||
var frame = CurrentFrame;
|
||||
|
||||
if (frame == null)
|
||||
return null;
|
||||
|
||||
return Interpolation.ValueAt(CurrentTime, CurrentFrame.Position, NextFrame.Position, CurrentFrame.Time, NextFrame.Time);
|
||||
return Interpolation.ValueAt(CurrentTime, frame.Position, NextFrame.Position, frame.Time, NextFrame.Time);
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,7 +43,7 @@ namespace osu.Game.Rulesets.Osu.Replays
|
||||
},
|
||||
new ReplayState<OsuAction>
|
||||
{
|
||||
PressedActions = CurrentFrame.Actions
|
||||
PressedActions = CurrentFrame?.Actions ?? new List<OsuAction>()
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ using osu.Framework.Input.StateChanges;
|
||||
using osu.Game.Input.Handlers;
|
||||
using osu.Game.Replays;
|
||||
using osuTK;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Rulesets.Replays
|
||||
{
|
||||
@ -22,12 +21,12 @@ namespace osu.Game.Rulesets.Replays
|
||||
|
||||
protected List<ReplayFrame> Frames => replay.Frames;
|
||||
|
||||
public TFrame CurrentFrame => !HasFrames ? null : (TFrame)Frames[currentFrameIndex];
|
||||
public TFrame CurrentFrame => !HasFrames || !currentFrameIndex.HasValue ? null : (TFrame)Frames[currentFrameIndex.Value];
|
||||
public TFrame NextFrame => !HasFrames ? null : (TFrame)Frames[nextFrameIndex];
|
||||
|
||||
private int currentFrameIndex;
|
||||
private int? currentFrameIndex;
|
||||
|
||||
private int nextFrameIndex => MathHelper.Clamp(currentFrameIndex + (currentDirection > 0 ? 1 : -1), 0, Frames.Count - 1);
|
||||
private int nextFrameIndex => currentFrameIndex.HasValue ? MathHelper.Clamp(currentFrameIndex.Value + (currentDirection > 0 ? 1 : -1), 0, Frames.Count - 1) : 0;
|
||||
|
||||
protected FramedReplayInputHandler(Replay replay)
|
||||
{
|
||||
@ -47,9 +46,6 @@ namespace osu.Game.Rulesets.Replays
|
||||
|
||||
public override List<IInput> GetPendingInputs() => new List<IInput>();
|
||||
|
||||
public bool AtLastFrame => currentFrameIndex == Frames.Count - 1;
|
||||
public bool AtFirstFrame => currentFrameIndex == 0;
|
||||
|
||||
private const double sixty_frame_time = 1000.0 / 60;
|
||||
|
||||
protected double CurrentTime { get; private set; }
|
||||
@ -106,22 +102,5 @@ namespace osu.Game.Rulesets.Replays
|
||||
|
||||
return CurrentTime = time;
|
||||
}
|
||||
|
||||
protected class ReplayMouseState : osu.Framework.Input.States.MouseState
|
||||
{
|
||||
public ReplayMouseState(Vector2 position)
|
||||
{
|
||||
Position = position;
|
||||
}
|
||||
}
|
||||
|
||||
protected class ReplayKeyboardState : osu.Framework.Input.States.KeyboardState
|
||||
{
|
||||
public ReplayKeyboardState(List<Key> keys)
|
||||
{
|
||||
foreach (var key in keys)
|
||||
Keys.Add(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user