mirror of
https://github.com/ppy/osu.git
synced 2024-12-13 04:32:57 +08:00
Add ability to step forward/backwards single frames
This commit is contained in:
parent
dafff26d0e
commit
60e972cd15
@ -9,6 +9,16 @@ namespace osu.Game.Localisation
|
||||
{
|
||||
private const string prefix = @"osu.Game.Resources.Localisation.PlaybackSettings";
|
||||
|
||||
/// <summary>
|
||||
/// "Step backward one frame"
|
||||
/// </summary>
|
||||
public static LocalisableString StepBackward => new TranslatableString(getKey(@"step_backward_frame"), @"Step backward one frame");
|
||||
|
||||
/// <summary>
|
||||
/// "Step forward one frame"
|
||||
/// </summary>
|
||||
public static LocalisableString StepForward => new TranslatableString(getKey(@"step_forward_frame"), @"Step forward one frame");
|
||||
|
||||
/// <summary>
|
||||
/// "Seek backward {0} seconds"
|
||||
/// </summary>
|
||||
|
@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
@ -87,13 +88,20 @@ namespace osu.Game.Screens.Play.PlayerSettings
|
||||
Action = () => seek(-1, seek_amount),
|
||||
TooltipText = PlayerSettingsOverlayStrings.SeekBackwardSeconds(seek_amount / 1000),
|
||||
},
|
||||
new SeekButton
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Icon = FontAwesome.Solid.StepBackward,
|
||||
Action = () => seekFrame(-1),
|
||||
TooltipText = PlayerSettingsOverlayStrings.StepBackward,
|
||||
},
|
||||
pausePlay = new IconButton
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Scale = new Vector2(1.4f),
|
||||
IconScale = new Vector2(1.4f),
|
||||
Icon = FontAwesome.Regular.PlayCircle,
|
||||
Action = () =>
|
||||
{
|
||||
if (gameplayClock.IsRunning)
|
||||
@ -103,6 +111,14 @@ namespace osu.Game.Screens.Play.PlayerSettings
|
||||
},
|
||||
},
|
||||
new SeekButton
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Icon = FontAwesome.Solid.StepForward,
|
||||
Action = () => seekFrame(1),
|
||||
TooltipText = PlayerSettingsOverlayStrings.StepForward,
|
||||
},
|
||||
new SeekButton
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
@ -166,6 +182,21 @@ namespace osu.Game.Screens.Play.PlayerSettings
|
||||
}, true);
|
||||
}
|
||||
|
||||
private void seekFrame(int direction)
|
||||
{
|
||||
gameplayClock.Stop();
|
||||
|
||||
var frames = gameplayState.Score.Replay.Frames;
|
||||
|
||||
if (frames.Count == 0)
|
||||
return;
|
||||
|
||||
gameplayClock.Seek(direction < 0
|
||||
? (frames.LastOrDefault(f => f.Time < gameplayClock.CurrentTime) ?? frames.First()).Time
|
||||
: (frames.FirstOrDefault(f => f.Time > gameplayClock.CurrentTime) ?? frames.Last()).Time
|
||||
);
|
||||
}
|
||||
|
||||
private void seek(int direction, double amount)
|
||||
{
|
||||
double target = Math.Clamp(gameplayClock.CurrentTime + (direction * amount), 0, gameplayState.Beatmap.GetLastObjectTime());
|
||||
|
Loading…
Reference in New Issue
Block a user