2021-04-19 14:06:07 +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.Extensions;
|
2023-02-28 18:29:31 +08:00
|
|
|
using osu.Framework.Graphics;
|
2021-04-19 14:06:07 +08:00
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
|
|
|
using osu.Game.Beatmaps.Timing;
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2022-05-28 07:20:04 +08:00
|
|
|
using osu.Game.Overlays;
|
2021-04-19 14:06:07 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Screens.Edit.Timing.RowAttributes
|
|
|
|
{
|
2021-04-19 14:27:38 +08:00
|
|
|
public partial class TimingRowAttribute : RowAttribute
|
2021-04-19 14:06:07 +08:00
|
|
|
{
|
|
|
|
private readonly BindableNumber<double> beatLength;
|
2023-02-28 18:29:31 +08:00
|
|
|
private readonly Bindable<bool> omitBarLine;
|
2022-01-23 00:27:27 +08:00
|
|
|
private readonly Bindable<TimeSignature> timeSignature;
|
2023-02-28 18:29:31 +08:00
|
|
|
private AttributeText omitBarLineBubble = null!;
|
2023-01-14 07:23:21 +08:00
|
|
|
private OsuSpriteText text = null!;
|
2021-04-19 14:06:07 +08:00
|
|
|
|
|
|
|
public TimingRowAttribute(TimingControlPoint timing)
|
2021-04-19 14:27:38 +08:00
|
|
|
: base(timing, "timing")
|
2021-04-19 14:06:07 +08:00
|
|
|
{
|
|
|
|
timeSignature = timing.TimeSignatureBindable.GetBoundCopy();
|
2023-02-28 18:29:31 +08:00
|
|
|
omitBarLine = timing.OmitFirstBarLineBindable.GetBoundCopy();
|
2021-04-19 14:06:07 +08:00
|
|
|
beatLength = timing.BeatLengthBindable.GetBoundCopy();
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2022-05-28 07:20:04 +08:00
|
|
|
private void load(OverlayColourProvider colourProvider)
|
2021-04-19 14:06:07 +08:00
|
|
|
{
|
2023-02-28 18:29:31 +08:00
|
|
|
Content.AddRange(new[]
|
|
|
|
{
|
|
|
|
text = new AttributeText(Point),
|
|
|
|
omitBarLineBubble = new AttributeText(Point) { Text = "no barline" },
|
|
|
|
});
|
2021-04-19 14:06:07 +08:00
|
|
|
|
2022-05-28 07:20:04 +08:00
|
|
|
Background.Colour = colourProvider.Background4;
|
|
|
|
|
2021-04-19 14:06:07 +08:00
|
|
|
timeSignature.BindValueChanged(_ => updateText());
|
2023-02-28 18:29:31 +08:00
|
|
|
omitBarLine.BindValueChanged(enabled => omitBarLineBubble.FadeTo(enabled.NewValue ? 1 : 0), true);
|
2021-04-19 14:06:07 +08:00
|
|
|
beatLength.BindValueChanged(_ => updateText(), true);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updateText() =>
|
|
|
|
text.Text = $"{60000 / beatLength.Value:n1}bpm {timeSignature.Value.GetDescription()}";
|
|
|
|
}
|
|
|
|
}
|