2019-01-24 16:43:03 +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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2022-06-20 13:56:04 +08:00
|
|
|
using System;
|
2019-10-28 13:44:45 +08:00
|
|
|
using osu.Framework.Bindables;
|
2017-05-23 12:55:18 +08:00
|
|
|
using osu.Game.Beatmaps.Timing;
|
2020-10-01 18:29:34 +08:00
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osuTK.Graphics;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2017-05-23 12:55:18 +08:00
|
|
|
namespace osu.Game.Beatmaps.ControlPoints
|
|
|
|
{
|
2022-06-20 13:56:04 +08:00
|
|
|
public class TimingControlPoint : ControlPoint, IEquatable<TimingControlPoint>
|
2017-05-23 12:55:18 +08:00
|
|
|
{
|
2017-05-23 13:11:37 +08:00
|
|
|
/// <summary>
|
|
|
|
/// The time signature at this control point.
|
|
|
|
/// </summary>
|
2022-01-23 00:27:27 +08:00
|
|
|
public readonly Bindable<TimeSignature> TimeSignatureBindable = new Bindable<TimeSignature>(TimeSignature.SimpleQuadruple);
|
2019-10-28 13:44:45 +08:00
|
|
|
|
2023-02-28 18:29:31 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Whether the first bar line of this control point is ignored.
|
|
|
|
/// </summary>
|
|
|
|
public readonly BindableBool OmitFirstBarLineBindable = new BindableBool();
|
|
|
|
|
2020-07-18 10:53:04 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Default length of a beat in milliseconds. Used whenever there is no beatmap or track playing.
|
|
|
|
/// </summary>
|
|
|
|
private const double default_beat_length = 60000.0 / 60.0;
|
|
|
|
|
2024-07-12 12:39:40 +08:00
|
|
|
public override Color4 GetRepresentingColour(OsuColour colours) => colours.Red2;
|
2020-10-01 18:29:34 +08:00
|
|
|
|
2020-07-18 10:53:04 +08:00
|
|
|
public static readonly TimingControlPoint DEFAULT = new TimingControlPoint
|
|
|
|
{
|
2020-07-18 11:03:49 +08:00
|
|
|
BeatLengthBindable =
|
|
|
|
{
|
|
|
|
Value = default_beat_length,
|
|
|
|
Disabled = true
|
|
|
|
},
|
2023-02-28 18:29:31 +08:00
|
|
|
OmitFirstBarLineBindable = { Disabled = true },
|
2020-07-18 10:53:04 +08:00
|
|
|
TimeSignatureBindable = { Disabled = true }
|
|
|
|
};
|
|
|
|
|
2019-10-28 13:44:45 +08:00
|
|
|
/// <summary>
|
|
|
|
/// The time signature at this control point.
|
|
|
|
/// </summary>
|
2022-01-23 00:27:27 +08:00
|
|
|
public TimeSignature TimeSignature
|
2019-10-28 13:44:45 +08:00
|
|
|
{
|
|
|
|
get => TimeSignatureBindable.Value;
|
|
|
|
set => TimeSignatureBindable.Value = value;
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2023-02-28 18:29:31 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Whether the first bar line of this control point is ignored.
|
|
|
|
/// </summary>
|
|
|
|
public bool OmitFirstBarLine
|
|
|
|
{
|
|
|
|
get => OmitFirstBarLineBindable.Value;
|
|
|
|
set => OmitFirstBarLineBindable.Value = value;
|
|
|
|
}
|
|
|
|
|
2019-08-28 19:22:16 +08:00
|
|
|
public const double DEFAULT_BEAT_LENGTH = 1000;
|
|
|
|
|
2017-05-23 13:11:37 +08:00
|
|
|
/// <summary>
|
|
|
|
/// The beat length at this control point.
|
|
|
|
/// </summary>
|
2019-10-28 13:44:45 +08:00
|
|
|
public readonly BindableDouble BeatLengthBindable = new BindableDouble(DEFAULT_BEAT_LENGTH)
|
2018-02-28 21:53:16 +08:00
|
|
|
{
|
2019-10-28 13:44:45 +08:00
|
|
|
MinValue = 6,
|
|
|
|
MaxValue = 60000
|
|
|
|
};
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2019-10-30 17:44:07 +08:00
|
|
|
/// <summary>
|
2019-10-28 13:44:45 +08:00
|
|
|
/// The beat length at this control point.
|
|
|
|
/// </summary>
|
|
|
|
public double BeatLength
|
|
|
|
{
|
|
|
|
get => BeatLengthBindable.Value;
|
|
|
|
set => BeatLengthBindable.Value = value;
|
2018-02-28 21:53:16 +08:00
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2019-10-28 11:31:38 +08:00
|
|
|
/// <summary>
|
|
|
|
/// The BPM at this control point.
|
|
|
|
/// </summary>
|
|
|
|
public double BPM => 60000 / BeatLength;
|
|
|
|
|
2024-06-11 15:14:46 +08:00
|
|
|
public TimingControlPoint()
|
|
|
|
{
|
|
|
|
TimeSignatureBindable.BindValueChanged(_ => RaiseChanged());
|
|
|
|
OmitFirstBarLineBindable.BindValueChanged(_ => RaiseChanged());
|
|
|
|
BeatLengthBindable.BindValueChanged(_ => RaiseChanged());
|
|
|
|
}
|
|
|
|
|
2020-04-17 16:04:09 +08:00
|
|
|
// Timing points are never redundant as they can change the time signature.
|
2022-06-20 15:52:01 +08:00
|
|
|
public override bool IsRedundant(ControlPoint? existing) => false;
|
2021-01-04 15:37:07 +08:00
|
|
|
|
|
|
|
public override void CopyFrom(ControlPoint other)
|
|
|
|
{
|
|
|
|
TimeSignature = ((TimingControlPoint)other).TimeSignature;
|
2023-02-28 18:29:31 +08:00
|
|
|
OmitFirstBarLine = ((TimingControlPoint)other).OmitFirstBarLine;
|
2021-01-04 15:37:07 +08:00
|
|
|
BeatLength = ((TimingControlPoint)other).BeatLength;
|
|
|
|
|
|
|
|
base.CopyFrom(other);
|
|
|
|
}
|
2022-06-20 13:56:04 +08:00
|
|
|
|
|
|
|
public override bool Equals(ControlPoint? other)
|
|
|
|
=> other is TimingControlPoint otherTimingControlPoint
|
|
|
|
&& Equals(otherTimingControlPoint);
|
|
|
|
|
|
|
|
public bool Equals(TimingControlPoint? other)
|
|
|
|
=> base.Equals(other)
|
|
|
|
&& TimeSignature.Equals(other.TimeSignature)
|
2023-02-28 18:29:31 +08:00
|
|
|
&& OmitFirstBarLine == other.OmitFirstBarLine
|
2022-06-20 13:56:04 +08:00
|
|
|
&& BeatLength.Equals(other.BeatLength);
|
|
|
|
|
2023-02-28 18:29:31 +08:00
|
|
|
public override int GetHashCode() => HashCode.Combine(base.GetHashCode(), TimeSignature, BeatLength, OmitFirstBarLine);
|
2017-05-23 12:55:18 +08:00
|
|
|
}
|
2018-01-05 19:21:19 +08:00
|
|
|
}
|