Add replay speed adjustment

This commit is contained in:
EVAST9919 2017-10-02 04:42:38 +03:00
parent cecfd7b0f3
commit 6d97da8b19
4 changed files with 32 additions and 17 deletions

View File

@ -32,6 +32,7 @@ namespace osu.Game.Screens.Play
public readonly HealthDisplay HealthDisplay; public readonly HealthDisplay HealthDisplay;
public readonly SongProgress Progress; public readonly SongProgress Progress;
public readonly ModDisplay ModDisplay; public readonly ModDisplay ModDisplay;
public readonly ReplaySettingsOverlay ReplaySettingsOverlay;
private Bindable<bool> showHud; private Bindable<bool> showHud;
private bool replayLoaded; private bool replayLoaded;
@ -55,7 +56,7 @@ namespace osu.Game.Screens.Play
HealthDisplay = CreateHealthDisplay(), HealthDisplay = CreateHealthDisplay(),
Progress = CreateProgress(), Progress = CreateProgress(),
ModDisplay = CreateModsContainer(), ModDisplay = CreateModsContainer(),
//ReplaySettingsOverlay = CreateReplaySettingsOverlay(), ReplaySettingsOverlay = CreateReplaySettingsOverlay(),
} }
}); });
} }
@ -98,8 +99,11 @@ namespace osu.Game.Screens.Play
// in the case a replay isn't loaded, we want some elements to only appear briefly. // in the case a replay isn't loaded, we want some elements to only appear briefly.
if (!replayLoaded) if (!replayLoaded)
{
ReplaySettingsOverlay.Hide();
ModDisplay.Delay(2000).FadeOut(200); ModDisplay.Delay(2000).FadeOut(200);
} }
}
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{ {
@ -176,12 +180,12 @@ namespace osu.Game.Screens.Play
Margin = new MarginPadding { Top = 20, Right = 10 }, Margin = new MarginPadding { Top = 20, Right = 10 },
}; };
//protected virtual ReplaySettingsOverlay CreateReplaySettingsOverlay() => new ReplaySettingsOverlay protected virtual ReplaySettingsOverlay CreateReplaySettingsOverlay() => new ReplaySettingsOverlay
//{ {
// Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
// Origin = Anchor.TopRight, Origin = Anchor.TopRight,
// Margin = new MarginPadding { Top = 100, Right = 10 }, Margin = new MarginPadding { Top = 100, Right = 10 },
//}; };
public virtual void BindProcessor(ScoreProcessor processor) public virtual void BindProcessor(ScoreProcessor processor)
{ {

View File

@ -222,6 +222,8 @@ namespace osu.Game.Screens.Play
hudOverlay.ModDisplay.Current.BindTo(working.Mods); hudOverlay.ModDisplay.Current.BindTo(working.Mods);
hudOverlay.ReplaySettingsOverlay.PlaybackSettings.BindClock(adjustableSourceClock);
// Bind ScoreProcessor to ourselves // Bind ScoreProcessor to ourselves
scoreProcessor.AllJudged += onCompletion; scoreProcessor.AllJudged += onCompletion;
scoreProcessor.Failed += onFail; scoreProcessor.Failed += onFail;

View File

@ -3,7 +3,7 @@
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Game.Configuration; using osu.Game.Configuration;
using osu.Framework.Graphics; using osu.Framework.Timing;
namespace osu.Game.Screens.Play.ReplaySettings namespace osu.Game.Screens.Play.ReplaySettings
{ {
@ -11,17 +11,24 @@ namespace osu.Game.Screens.Play.ReplaySettings
{ {
protected override string Title => @"playback"; protected override string Title => @"playback";
private ReplaySliderBar<double> sliderbar;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuConfigManager config) private void load(OsuConfigManager config)
{ {
Children = new Drawable[] Child = sliderbar = new ReplaySliderBar<double>
{
new ReplaySliderBar<double>
{ {
LabelText = "Playback speed", LabelText = "Playback speed",
Bindable = config.GetBindable<double>(OsuSetting.PlaybackSpeed) Bindable = config.GetBindable<double>(OsuSetting.PlaybackSpeed),
}
}; };
} }
public void BindClock(IAdjustableClock clock)
{
var clockRate = clock.Rate;
sliderbar.Bindable.ValueChanged += (rateMultiplier) => clock.Rate = clockRate * rateMultiplier;
sliderbar.Bindable.Value = 1;
}
} }
} }

View File

@ -10,15 +10,17 @@ namespace osu.Game.Screens.Play
{ {
public class ReplaySettingsOverlay : FillFlowContainer public class ReplaySettingsOverlay : FillFlowContainer
{ {
public readonly PlaybackSettings PlaybackSettings;
public ReplaySettingsOverlay() public ReplaySettingsOverlay()
{ {
Direction = FillDirection.Vertical; Direction = FillDirection.Vertical;
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
Spacing = new Vector2(0, 20); Spacing = new Vector2(0, 20);
Add(new CollectionSettings()); //Add(new CollectionSettings());
Add(new DiscussionSettings()); //Add(new DiscussionSettings());
Add(new PlaybackSettings()); Add(PlaybackSettings = new PlaybackSettings());
} }
} }
} }