1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 15:47:26 +08:00

Make all control point attributes bindable

Properties are left intact for compatibility reasons.
This commit is contained in:
Dean Herbert 2019-10-28 14:44:45 +09:00
parent 50a1f06ad9
commit 8f87957c70
5 changed files with 90 additions and 20 deletions

View File

@ -1,24 +1,31 @@
// 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 osuTK;
using osu.Framework.Bindables;
namespace osu.Game.Beatmaps.ControlPoints
{
public class DifficultyControlPoint : ControlPoint
{
/// <summary>
/// The speed multiplier at this control point.
/// </summary>
public readonly BindableDouble SpeedMultiplierBindable = new BindableDouble(1)
{
MinValue = 0.1,
MaxValue = 10
};
/// <summary>
/// The speed multiplier at this control point.
/// </summary>
public double SpeedMultiplier
{
get => speedMultiplier;
set => speedMultiplier = MathHelper.Clamp(value, 0.1, 10);
get => SpeedMultiplierBindable.Value;
set => SpeedMultiplierBindable.Value = value;
}
private double speedMultiplier = 1;
public override bool EquivalentTo(ControlPoint other) =>
other is DifficultyControlPoint otherTyped && otherTyped.SpeedMultiplier.Equals(speedMultiplier);
other is DifficultyControlPoint otherTyped && otherTyped.SpeedMultiplier.Equals(SpeedMultiplier);
}
}

View File

@ -1,19 +1,39 @@
// 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.Bindables;
namespace osu.Game.Beatmaps.ControlPoints
{
public class EffectControlPoint : ControlPoint
{
/// <summary>
/// Whether this control point enables Kiai mode.
/// Whether the first bar line of this control point is ignored.
/// </summary>
public bool KiaiMode;
public readonly BindableBool OmitFirstBarLineBindable = new BindableBool();
/// <summary>
/// Whether the first bar line of this control point is ignored.
/// </summary>
public bool OmitFirstBarLine;
public bool OmitFirstBarLine
{
get => OmitFirstBarLineBindable.Value;
set => OmitFirstBarLineBindable.Value = value;
}
/// <summary>
/// Whether this control point enables Kiai mode.
/// </summary>
public readonly BindableBool KiaiModeBindable = new BindableBool();
/// <summary>
/// Whether this control point enables Kiai mode.
/// </summary>
public bool KiaiMode
{
get => KiaiModeBindable.Value;
set => KiaiModeBindable.Value = value;
}
public override bool EquivalentTo(ControlPoint other) =>
other is EffectControlPoint otherTyped &&

View File

@ -1,6 +1,7 @@
// 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.Bindables;
using osu.Game.Audio;
namespace osu.Game.Beatmaps.ControlPoints
@ -12,12 +13,34 @@ namespace osu.Game.Beatmaps.ControlPoints
/// <summary>
/// The default sample bank at this control point.
/// </summary>
public string SampleBank = DEFAULT_BANK;
public readonly Bindable<string> SampleBankBindable = new Bindable<string>(DEFAULT_BANK);
/// <summary>
/// The speed multiplier at this control point.
/// </summary>
public string SampleBank
{
get => SampleBankBindable.Value;
set => SampleBankBindable.Value = value;
}
/// <summary>
/// The default sample bank at this control point.
/// </summary>
public readonly BindableInt SampleVolumeBindable = new BindableInt(100)
{
MinValue = 0,
MaxValue = 100
};
/// <summary>
/// The default sample volume at this control point.
/// </summary>
public int SampleVolume = 100;
public int SampleVolume
{
get => SampleVolumeBindable.Value;
set => SampleVolumeBindable.Value = value;
}
/// <summary>
/// Create a SampleInfo based on the sample settings in this control point.

View File

@ -1,7 +1,7 @@
// 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 osuTK;
using osu.Framework.Bindables;
using osu.Game.Beatmaps.Timing;
namespace osu.Game.Beatmaps.ControlPoints
@ -11,23 +11,39 @@ namespace osu.Game.Beatmaps.ControlPoints
/// <summary>
/// The time signature at this control point.
/// </summary>
public TimeSignatures TimeSignature = TimeSignatures.SimpleQuadruple;
public readonly Bindable<TimeSignatures> TimeSignatureBindable = new Bindable<TimeSignatures>(TimeSignatures.SimpleQuadruple);
/// <summary>
/// The time signature at this control point.
/// </summary>
public TimeSignatures TimeSignature
{
get => TimeSignatureBindable.Value;
set => TimeSignatureBindable.Value = value;
}
public const double DEFAULT_BEAT_LENGTH = 1000;
/// <summary>
/// The beat length at this control point.
/// </summary>
public virtual double BeatLength
public readonly BindableDouble BeatLengthBindable = new BindableDouble(DEFAULT_BEAT_LENGTH)
{
get => beatLength;
set => beatLength = MathHelper.Clamp(value, 6, 60000);
}
MinValue = 6,
MaxValue = 60000
};
private double beatLength = DEFAULT_BEAT_LENGTH;
/// <summary>
/// The beat length at this control point.
/// </summary>
public double BeatLength
{
get => BeatLengthBindable.Value;
set => BeatLengthBindable.Value = value;
}
public override bool EquivalentTo(ControlPoint other) =>
other is TimingControlPoint otherTyped
&& TimeSignature == otherTyped.TimeSignature && beatLength.Equals(otherTyped.beatLength);
&& TimeSignature == otherTyped.TimeSignature && BeatLength.Equals(otherTyped.BeatLength);
}
}

View File

@ -32,7 +32,11 @@ namespace osu.Game.Beatmaps.Formats
private class LegacyDifficultyCalculatorControlPoint : TimingControlPoint
{
public override double BeatLength { get; set; } = DEFAULT_BEAT_LENGTH;
public LegacyDifficultyCalculatorControlPoint()
{
BeatLengthBindable.MinValue = double.MinValue;
BeatLengthBindable.MaxValue = double.MaxValue;
}
}
}
}