<commit_before>﻿// Copyright (c) ppy Pty Ltd <<EMAIL>>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Timing;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;

namespace osu.Game.Screens.Play.PlayerSettings
{
    public class PlaybackSettings : PlayerSettingsGroup
    {
        private const int padding = 10;

        protected override string Title => @"playback";

        public IAdjustableClock AdjustableClock { set; get; }

        private readonly PlayerSliderBar<double> rateSlider;

        private readonly OsuSpriteText multiplierText;

        public PlaybackSettings()
        {
            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,
                            Font = OsuFont.GetFont(weight: FontWeight.Bold),
                        }
                    },
                },
                rateSlider = new PlayerSliderBar<double>
                {
                    Bindable = new BindableDouble(1)
                    {
                        Default = 1,
                        MinValue = 0.5,
                        MaxValue = 2,
                        Precision = 0.1,
                    },
                }
            };
        }

        protected override void LoadComplete()
        {
            base.LoadComplete();

            if (AdjustableClock == null)
                return;

            var clockRate = AdjustableClock.Rate;

            // can't trigger this line instantly as the underlying clock may not be ready to accept adjustments yet.
            rateSlider.Bindable.ValueChanged += multiplier => AdjustableClock.Rate = clockRate * multiplier.NewValue;

            rateSlider.Bindable.BindValueChanged(multiplier => multiplierText.Text = $"{multiplier:0.0}x", true);
        }
    }
}<commit_msg>Fix regression causing playback rate to display incorrectly<commit_after>﻿// Copyright (c) p<NAME> <<EMAIL>>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Timing;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;

namespace osu.Game.Screens.Play.PlayerSettings
{
    public class PlaybackSettings : PlayerSettingsGroup
    {
        private const int padding = 10;

        protected override string Title => @"playback";

        public IAdjustableClock AdjustableClock { set; get; }

        private readonly PlayerSliderBar<double> rateSlider;

        private readonly OsuSpriteText multiplierText;

        public PlaybackSettings()
        {
            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,
                            Font = OsuFont.GetFont(weight: FontWeight.Bold),
                        }
                    },
                },
                rateSlider = new PlayerSliderBar<double>
                {
                    Bindable = new BindableDouble(1)
                    {
                        Default = 1,
                        MinValue = 0.5,
                        MaxValue = 2,
                        Precision = 0.1,
                    },
                }
            };
        }

        protected override void LoadComplete()
        {
            base.LoadComplete();

            if (AdjustableClock == null)
                return;

            var clockRate = AdjustableClock.Rate;

            // can't trigger this line instantly as the underlying clock may not be ready to accept adjustments yet.
            rateSlider.Bindable.ValueChanged += multiplier => AdjustableClock.Rate = clockRate * multiplier.NewValue;

            rateSlider.Bindable.BindValueChanged(multiplier => multiplierText.Text = $"{multiplier.NewValue:0.0}x", true);
        }
    }
}
{'fraction_non_alphanumeric': 0.0708341039393379, 'fraction_numerical': 0.004068799704087294, 'mean_word_length': 1.28474862695395, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1886192', 'n_tokens_mistral': 1341, 'n_tokens_neox': 1234, 'n_words': 315}