2019-01-24 08:43:03 +00:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-02-21 10:04:31 +00:00
|
|
|
|
using osu.Framework.Bindables;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2019-02-12 04:04:46 +00:00
|
|
|
|
using osu.Game.Graphics;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Play.PlayerSettings
|
|
|
|
|
{
|
|
|
|
|
public class PlaybackSettings : PlayerSettingsGroup
|
|
|
|
|
{
|
|
|
|
|
private const int padding = 10;
|
|
|
|
|
|
2019-03-06 11:30:14 +00:00
|
|
|
|
public readonly Bindable<double> UserPlaybackRate = new BindableDouble(1)
|
|
|
|
|
{
|
|
|
|
|
Default = 1,
|
|
|
|
|
MinValue = 0.5,
|
|
|
|
|
MaxValue = 2,
|
|
|
|
|
Precision = 0.1,
|
|
|
|
|
};
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-02-22 08:51:39 +00:00
|
|
|
|
private readonly PlayerSliderBar<double> rateSlider;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-01-22 02:40:57 +00:00
|
|
|
|
private readonly OsuSpriteText multiplierText;
|
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
public PlaybackSettings()
|
2020-09-09 09:48:02 +00:00
|
|
|
|
: base("playback")
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Padding = new MarginPadding { Horizontal = padding },
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
Text = "Playback speed",
|
|
|
|
|
},
|
|
|
|
|
multiplierText = new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
|
Origin = Anchor.CentreRight,
|
2019-02-12 04:04:46 +00:00
|
|
|
|
Font = OsuFont.GetFont(weight: FontWeight.Bold),
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
2020-10-06 08:18:41 +00:00
|
|
|
|
rateSlider = new PlayerSliderBar<double> { Current = UserPlaybackRate }
|
2018-04-13 09:19:50 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
2020-10-06 08:18:41 +00:00
|
|
|
|
rateSlider.Current.BindValueChanged(multiplier => multiplierText.Text = $"{multiplier.NewValue:0.0}x", true);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|