1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-27 12:22:54 +08:00
osu-lazer/osu.Game/Screens/Edit/Timing/RowAttributes/TimingRowAttribute.cs

51 lines
1.9 KiB
C#
Raw Normal View History

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