mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 16:32:54 +08:00
Merge pull request #1336 from EVAST9919/replay_speed
Add replay speed adjustment setting
This commit is contained in:
commit
855b849e84
@ -3,7 +3,7 @@
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
using osu.Game.Screens.Play.ReplaySettings;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
|
@ -69,7 +69,6 @@ namespace osu.Game.Configuration
|
||||
Set(OsuSetting.KeyOverlay, false);
|
||||
|
||||
Set(OsuSetting.FloatingComments, false);
|
||||
Set(OsuSetting.PlaybackSpeed, 1.0, 0.5f, 2, 0.01);
|
||||
|
||||
// Update
|
||||
Set(OsuSetting.ReleaseStream, ReleaseStream.Lazer);
|
||||
@ -93,7 +92,6 @@ namespace osu.Game.Configuration
|
||||
ShowStoryboard,
|
||||
KeyOverlay,
|
||||
FloatingComments,
|
||||
PlaybackSpeed,
|
||||
ShowInterface,
|
||||
MouseDisableButtons,
|
||||
MouseDisableWheel,
|
||||
|
68
osu.Game/Screens/Play/HUD/ReplaySettingsOverlay.cs
Normal file
68
osu.Game/Screens/Play/HUD/ReplaySettingsOverlay.cs
Normal file
@ -0,0 +1,68 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Screens.Play.ReplaySettings;
|
||||
using OpenTK;
|
||||
using osu.Framework.Input;
|
||||
using OpenTK.Input;
|
||||
|
||||
namespace osu.Game.Screens.Play.HUD
|
||||
{
|
||||
public class ReplaySettingsOverlay : VisibilityContainer
|
||||
{
|
||||
private const int fade_duration = 200;
|
||||
|
||||
public bool ReplayLoaded;
|
||||
|
||||
public override bool HandleInput => true;
|
||||
|
||||
public readonly PlaybackSettings PlaybackSettings;
|
||||
//public readonly CollectionSettings CollectionSettings;
|
||||
//public readonly DiscussionSettings DiscussionSettings;
|
||||
|
||||
public ReplaySettingsOverlay()
|
||||
{
|
||||
AlwaysPresent = true;
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
Child = new FillFlowContainer<ReplayGroup>
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(0, 20),
|
||||
Margin = new MarginPadding { Top = 100, Right = 10 },
|
||||
Children = new []
|
||||
{
|
||||
//CollectionSettings = new CollectionSettings(),
|
||||
//DiscussionSettings = new DiscussionSettings(),
|
||||
PlaybackSettings = new PlaybackSettings(),
|
||||
}
|
||||
};
|
||||
|
||||
State = Visibility.Visible;
|
||||
}
|
||||
|
||||
protected override void PopIn() => this.FadeIn(fade_duration);
|
||||
protected override void PopOut() => this.FadeOut(fade_duration);
|
||||
|
||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||
{
|
||||
if (args.Repeat) return false;
|
||||
|
||||
if (state.Keyboard.ControlPressed)
|
||||
{
|
||||
if (args.Key == Key.H && ReplayLoaded)
|
||||
{
|
||||
ToggleVisibility();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return base.OnKeyDown(state, args);
|
||||
}
|
||||
}
|
||||
}
|
@ -32,6 +32,7 @@ namespace osu.Game.Screens.Play
|
||||
public readonly HealthDisplay HealthDisplay;
|
||||
public readonly SongProgress Progress;
|
||||
public readonly ModDisplay ModDisplay;
|
||||
public readonly ReplaySettingsOverlay ReplaySettingsOverlay;
|
||||
|
||||
private Bindable<bool> showHud;
|
||||
private bool replayLoaded;
|
||||
@ -55,7 +56,7 @@ namespace osu.Game.Screens.Play
|
||||
HealthDisplay = CreateHealthDisplay(),
|
||||
Progress = CreateProgress(),
|
||||
ModDisplay = CreateModsContainer(),
|
||||
//ReplaySettingsOverlay = CreateReplaySettingsOverlay(),
|
||||
ReplaySettingsOverlay = CreateReplaySettingsOverlay(),
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -96,9 +97,14 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
replayLoaded = rulesetContainer.HasReplayLoaded;
|
||||
|
||||
ReplaySettingsOverlay.ReplayLoaded = replayLoaded;
|
||||
|
||||
// in the case a replay isn't loaded, we want some elements to only appear briefly.
|
||||
if (!replayLoaded)
|
||||
{
|
||||
ReplaySettingsOverlay.Hide();
|
||||
ModDisplay.Delay(2000).FadeOut(200);
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||
@ -176,12 +182,7 @@ namespace osu.Game.Screens.Play
|
||||
Margin = new MarginPadding { Top = 20, Right = 10 },
|
||||
};
|
||||
|
||||
//protected virtual ReplaySettingsOverlay CreateReplaySettingsOverlay() => new ReplaySettingsOverlay
|
||||
//{
|
||||
// Anchor = Anchor.TopRight,
|
||||
// Origin = Anchor.TopRight,
|
||||
// Margin = new MarginPadding { Top = 100, Right = 10 },
|
||||
//};
|
||||
protected virtual ReplaySettingsOverlay CreateReplaySettingsOverlay() => new ReplaySettingsOverlay();
|
||||
|
||||
public virtual void BindProcessor(ScoreProcessor processor)
|
||||
{
|
||||
|
@ -156,8 +156,7 @@ namespace osu.Game.Screens.Play
|
||||
Schedule(() =>
|
||||
{
|
||||
decoupledClock.ChangeSource(adjustableSourceClock);
|
||||
foreach (var mod in working.Mods.Value.OfType<IApplicableToClock>())
|
||||
mod.ApplyToClock(adjustableSourceClock);
|
||||
applyRateFromMods();
|
||||
});
|
||||
});
|
||||
|
||||
@ -239,11 +238,20 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
breakOverlay.BindProcessor(scoreProcessor);
|
||||
|
||||
hudOverlay.ReplaySettingsOverlay.PlaybackSettings.AdjustableClock = adjustableSourceClock;
|
||||
|
||||
// Bind ScoreProcessor to ourselves
|
||||
scoreProcessor.AllJudged += onCompletion;
|
||||
scoreProcessor.Failed += onFail;
|
||||
}
|
||||
|
||||
private void applyRateFromMods()
|
||||
{
|
||||
adjustableSourceClock.Rate = 1;
|
||||
foreach (var mod in Beatmap.Value.Mods.Value.OfType<IApplicableToClock>())
|
||||
mod.ApplyToClock(adjustableSourceClock);
|
||||
}
|
||||
|
||||
private void initializeStoryboard(bool asyncLoad)
|
||||
{
|
||||
var beatmap = Beatmap.Value.Beatmap;
|
||||
@ -341,6 +349,9 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
if (HasFailed || !ValidForResume || pauseContainer?.AllowExit != false || RulesetContainer?.HasReplayLoaded != false)
|
||||
{
|
||||
// In the case of replays, we may have changed the playback rate.
|
||||
applyRateFromMods();
|
||||
|
||||
fadeOut();
|
||||
return base.OnExiting(next);
|
||||
}
|
||||
|
@ -1,9 +1,8 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Framework.Configuration;
|
||||
|
||||
namespace osu.Game.Screens.Play.ReplaySettings
|
||||
{
|
||||
@ -11,18 +10,34 @@ namespace osu.Game.Screens.Play.ReplaySettings
|
||||
{
|
||||
protected override string Title => @"playback";
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager config)
|
||||
public IAdjustableClock AdjustableClock { set; get; }
|
||||
|
||||
private readonly ReplaySliderBar<double> sliderbar;
|
||||
|
||||
public PlaybackSettings()
|
||||
{
|
||||
Children = new Drawable[]
|
||||
Child = sliderbar = new ReplaySliderBar<double>
|
||||
{
|
||||
new ReplaySliderBar<double>
|
||||
LabelText = "Playback speed",
|
||||
Bindable = new BindableDouble(1)
|
||||
{
|
||||
LabelText = "Playback speed",
|
||||
Bindable = config.GetBindable<double>(OsuSetting.PlaybackSpeed),
|
||||
KeyboardStep = 0.5f
|
||||
}
|
||||
Default = 1,
|
||||
MinValue = 0.5,
|
||||
MaxValue = 2,
|
||||
Precision = 0.01,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
if (AdjustableClock == null)
|
||||
return;
|
||||
|
||||
var clockRate = AdjustableClock.Rate;
|
||||
sliderbar.Bindable.ValueChanged += rateMultiplier => AdjustableClock.Rate = clockRate * rateMultiplier;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,24 +0,0 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Screens.Play.ReplaySettings;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
{
|
||||
public class ReplaySettingsOverlay : FillFlowContainer
|
||||
{
|
||||
public ReplaySettingsOverlay()
|
||||
{
|
||||
Direction = FillDirection.Vertical;
|
||||
AutoSizeAxes = Axes.Both;
|
||||
Spacing = new Vector2(0, 20);
|
||||
|
||||
Add(new CollectionSettings());
|
||||
Add(new DiscussionSettings());
|
||||
Add(new PlaybackSettings());
|
||||
}
|
||||
}
|
||||
}
|
@ -688,7 +688,7 @@
|
||||
<Compile Include="Screens\Play\Player.cs" />
|
||||
<Compile Include="Screens\Play\PlayerLoader.cs" />
|
||||
<Compile Include="Screens\Play\ReplayPlayer.cs" />
|
||||
<Compile Include="Screens\Play\ReplaySettingsOverlay.cs" />
|
||||
<Compile Include="Screens\Play\HUD\ReplaySettingsOverlay.cs" />
|
||||
<Compile Include="Screens\Play\ReplaySettings\CollectionSettings.cs" />
|
||||
<Compile Include="Screens\Play\ReplaySettings\DiscussionSettings.cs" />
|
||||
<Compile Include="Screens\Play\ReplaySettings\PlaybackSettings.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user