2021-04-19 15:10:37 +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.
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Edit.Timing.RowAttributes
|
|
|
|
{
|
|
|
|
public partial class SampleRowAttribute : RowAttribute
|
|
|
|
{
|
2023-01-14 07:23:21 +08:00
|
|
|
private AttributeText sampleText = null!;
|
|
|
|
private OsuSpriteText volumeText = null!;
|
2021-04-19 15:10:37 +08:00
|
|
|
|
|
|
|
private readonly Bindable<string> sampleBank;
|
|
|
|
private readonly BindableNumber<int> volume;
|
|
|
|
|
|
|
|
public SampleRowAttribute(SampleControlPoint sample)
|
|
|
|
: base(sample, "sample")
|
|
|
|
{
|
|
|
|
sampleBank = sample.SampleBankBindable.GetBoundCopy();
|
|
|
|
volume = sample.SampleVolumeBindable.GetBoundCopy();
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
AttributeProgressBar progress;
|
|
|
|
|
|
|
|
Content.AddRange(new Drawable[]
|
|
|
|
{
|
2021-04-19 16:57:07 +08:00
|
|
|
sampleText = new AttributeText(Point),
|
|
|
|
progress = new AttributeProgressBar(Point),
|
|
|
|
volumeText = new AttributeText(Point)
|
2021-04-19 15:10:37 +08:00
|
|
|
{
|
2021-04-19 16:57:07 +08:00
|
|
|
Width = 40,
|
2021-04-19 15:10:37 +08:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
volume.BindValueChanged(vol =>
|
|
|
|
{
|
|
|
|
progress.Current.Value = vol.NewValue / 100f;
|
|
|
|
updateText();
|
|
|
|
}, true);
|
|
|
|
|
|
|
|
sampleBank.BindValueChanged(_ => updateText(), true);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updateText()
|
|
|
|
{
|
|
|
|
volumeText.Text = $"{volume.Value}%";
|
|
|
|
sampleText.Text = $"{sampleBank.Value}";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|