2018-01-05 20:21:19 +09:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-05-17 16:54:49 +03:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
2017-10-02 18:09:00 +03:00
|
|
|
|
using osu.Framework.Configuration;
|
2017-11-13 05:04:21 +03:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2018-01-13 22:25:09 +03:00
|
|
|
|
using osu.Framework.Timing;
|
2017-11-13 05:04:21 +03:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2017-05-18 07:09:36 +03:00
|
|
|
|
|
2018-01-13 22:25:09 +03:00
|
|
|
|
namespace osu.Game.Screens.Play.PlayerSettings
|
2017-05-18 07:09:36 +03:00
|
|
|
|
{
|
2018-01-15 20:52:52 +03:00
|
|
|
|
public class PlaybackSettings : PlayerSettingsGroup
|
2017-05-18 07:09:36 +03:00
|
|
|
|
{
|
2017-11-13 05:52:05 +03:00
|
|
|
|
private const int padding = 10;
|
|
|
|
|
|
2017-05-28 00:56:11 +03:00
|
|
|
|
protected override string Title => @"playback";
|
2017-05-18 07:09:36 +03:00
|
|
|
|
|
2017-10-26 15:04:44 +03:00
|
|
|
|
public IAdjustableClock AdjustableClock { set; get; }
|
2017-10-03 20:05:50 +03:00
|
|
|
|
|
2018-01-13 22:25:09 +03:00
|
|
|
|
private readonly PlayerSliderBar<double> sliderbar;
|
2017-10-02 04:42:38 +03:00
|
|
|
|
|
2017-10-02 18:09:00 +03:00
|
|
|
|
public PlaybackSettings()
|
2017-05-18 07:09:36 +03:00
|
|
|
|
{
|
2017-11-13 05:58:19 +03:00
|
|
|
|
OsuSpriteText multiplierText;
|
|
|
|
|
|
2017-11-13 05:04:21 +03:00
|
|
|
|
Children = new Drawable[]
|
2017-05-18 07:09:36 +03:00
|
|
|
|
{
|
2017-11-13 05:04:21 +03:00
|
|
|
|
new Container
|
2017-10-02 18:19:55 +03:00
|
|
|
|
{
|
2017-11-13 05:04:21 +03:00
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2017-11-13 05:52:05 +03:00
|
|
|
|
Padding = new MarginPadding { Horizontal = padding },
|
2017-11-13 05:04:21 +03:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
Text = "Playback speed",
|
|
|
|
|
},
|
|
|
|
|
multiplierText = new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
|
Origin = Anchor.CentreRight,
|
|
|
|
|
Font = @"Exo2.0-Bold",
|
|
|
|
|
}
|
|
|
|
|
},
|
2017-10-02 18:19:55 +03:00
|
|
|
|
},
|
2018-01-13 22:25:09 +03:00
|
|
|
|
sliderbar = new PlayerSliderBar<double>
|
2017-11-13 05:04:21 +03:00
|
|
|
|
{
|
|
|
|
|
Bindable = new BindableDouble(1)
|
|
|
|
|
{
|
|
|
|
|
Default = 1,
|
|
|
|
|
MinValue = 0.5,
|
|
|
|
|
MaxValue = 2,
|
2018-02-07 13:28:10 +09:00
|
|
|
|
Precision = 0.1,
|
2017-11-13 05:04:21 +03:00
|
|
|
|
},
|
|
|
|
|
}
|
2017-05-29 19:00:29 +03:00
|
|
|
|
};
|
2017-11-13 05:52:05 +03:00
|
|
|
|
|
2018-02-07 13:26:41 +09:00
|
|
|
|
sliderbar.Bindable.ValueChanged += rateMultiplier => multiplierText.Text = $"{sliderbar.Bar.TooltipText}x";
|
2018-02-08 11:12:05 +09:00
|
|
|
|
sliderbar.Bindable.TriggerChange();
|
2017-05-18 07:09:36 +03:00
|
|
|
|
}
|
2017-10-02 04:42:38 +03:00
|
|
|
|
|
2017-10-03 20:05:50 +03:00
|
|
|
|
protected override void LoadComplete()
|
2017-10-02 04:42:38 +03:00
|
|
|
|
{
|
2017-10-03 20:05:50 +03:00
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
2017-10-26 15:04:44 +03:00
|
|
|
|
if (AdjustableClock == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var clockRate = AdjustableClock.Rate;
|
2017-11-13 05:52:05 +03:00
|
|
|
|
sliderbar.Bindable.ValueChanged += rateMultiplier => AdjustableClock.Rate = clockRate * rateMultiplier;
|
2017-10-02 04:42:38 +03:00
|
|
|
|
}
|
2017-05-18 07:09:36 +03:00
|
|
|
|
}
|
|
|
|
|
}
|