2019-01-24 16:43:03 +08: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 17:19:50 +08:00
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2019-02-21 18:04:31 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2017-11-13 10:04:21 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2019-02-12 12:04:46 +08:00
|
|
|
|
using osu.Game.Graphics;
|
2017-11-13 10:04:21 +08:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-01-14 03:25:09 +08:00
|
|
|
|
namespace osu.Game.Screens.Play.PlayerSettings
|
2017-05-18 12:09:36 +08:00
|
|
|
|
{
|
2018-01-16 01:52:52 +08:00
|
|
|
|
public class PlaybackSettings : PlayerSettingsGroup
|
2017-05-18 12:09:36 +08:00
|
|
|
|
{
|
2017-11-13 10:52:05 +08:00
|
|
|
|
private const int padding = 10;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-03-06 19:30:14 +08:00
|
|
|
|
public readonly Bindable<double> UserPlaybackRate = new BindableDouble(1)
|
|
|
|
|
{
|
|
|
|
|
Default = 1,
|
|
|
|
|
MinValue = 0.5,
|
|
|
|
|
MaxValue = 2,
|
|
|
|
|
Precision = 0.1,
|
|
|
|
|
};
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-02-22 16:51:39 +08:00
|
|
|
|
private readonly PlayerSliderBar<double> rateSlider;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-01-22 10:40:57 +08:00
|
|
|
|
private readonly OsuSpriteText multiplierText;
|
|
|
|
|
|
2017-10-02 23:09:00 +08:00
|
|
|
|
public PlaybackSettings()
|
2020-09-09 17:48:02 +08:00
|
|
|
|
: base("playback")
|
2017-05-18 12:09:36 +08:00
|
|
|
|
{
|
2017-11-13 10:04:21 +08:00
|
|
|
|
Children = new Drawable[]
|
2017-05-18 12:09:36 +08:00
|
|
|
|
{
|
2017-11-13 10:04:21 +08:00
|
|
|
|
new Container
|
2017-10-02 23:19:55 +08:00
|
|
|
|
{
|
2017-11-13 10:04:21 +08:00
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2017-11-13 10:52:05 +08:00
|
|
|
|
Padding = new MarginPadding { Horizontal = padding },
|
2017-11-13 10:04:21 +08:00
|
|
|
|
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 12:04:46 +08:00
|
|
|
|
Font = OsuFont.GetFont(weight: FontWeight.Bold),
|
2017-11-13 10:04:21 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
2017-10-02 23:19:55 +08:00
|
|
|
|
},
|
2020-10-06 16:18:41 +08:00
|
|
|
|
rateSlider = new PlayerSliderBar<double> { Current = UserPlaybackRate }
|
2017-05-30 00:00:29 +08:00
|
|
|
|
};
|
2017-05-18 12:09:36 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-10-04 01:05:50 +08:00
|
|
|
|
protected override void LoadComplete()
|
2017-10-02 09:42:38 +08:00
|
|
|
|
{
|
2017-10-04 01:05:50 +08:00
|
|
|
|
base.LoadComplete();
|
2020-10-06 16:18:41 +08:00
|
|
|
|
rateSlider.Current.BindValueChanged(multiplier => multiplierText.Text = $"{multiplier.NewValue:0.0}x", true);
|
2017-10-02 09:42:38 +08:00
|
|
|
|
}
|
2017-05-18 12:09:36 +08:00
|
|
|
|
}
|
|
|
|
|
}
|