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

Add back extended limits support

This commit is contained in:
Dean Herbert 2021-07-08 16:40:32 +09:00
parent c4313d6e96
commit a6e94dd491
8 changed files with 121 additions and 121 deletions

View File

@ -13,35 +13,28 @@ namespace osu.Game.Rulesets.Catch.Mods
public class CatchModDifficultyAdjust : ModDifficultyAdjust, IApplicableToBeatmapProcessor
{
[SettingSource("Circle Size", "Override a beatmap's set CS.", FIRST_SETTING_ORDER - 1)]
public Bindable<float?> CircleSize { get; } = new Bindable<float?>
public DifficultyBindable CircleSize { get; } = new DifficultyBindable
{
/*
Precision = 0.1f,
MinValue = 1,
MaxValue = 10,
*/
};
[SettingSource("Approach Rate", "Override a beatmap's set AR.", LAST_SETTING_ORDER + 1)]
public Bindable<float?> ApproachRate { get; } = new Bindable<float?>
public DifficultyBindable ApproachRate { get; } = new DifficultyBindable
{
/*
Precision = 0.1f,
MinValue = 1,
MaxValue = 10,
*/
};
[SettingSource("Spicy Patterns", "Adjust the patterns as if Hard Rock is enabled.")]
public BindableBool HardRockOffsets { get; } = new BindableBool();
protected override void ApplyLimits(bool extended)
public CatchModDifficultyAdjust()
{
base.ApplyLimits(extended);
// TODO: reimplement
// CircleSize.MaxValue = extended ? 11 : 10;
// ApproachRate.MaxValue = extended ? 11 : 10;
CircleSize.ExtendedLimits.BindTo(ExtendedLimits);
ApproachRate.ExtendedLimits.BindTo(ExtendedLimits);
}
public override string SettingDescription

View File

@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text.
using System.Linq;
using osu.Framework.Bindables;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Rulesets.Mods;
@ -12,32 +11,27 @@ namespace osu.Game.Rulesets.Osu.Mods
public class OsuModDifficultyAdjust : ModDifficultyAdjust
{
[SettingSource("Circle Size", "Override a beatmap's set CS.", FIRST_SETTING_ORDER - 1, SettingControlType = typeof(DifficultyAdjustSettingsControl))]
public Bindable<float?> CircleSize { get; } = new Bindable<float?>
public DifficultyBindable CircleSize { get; } = new DifficultyBindable
{
/*
Precision = 0.1f,
MinValue = 0,
MaxValue = 10,
*/
ExtendedMaxValue = 11,
};
[SettingSource("Approach Rate", "Override a beatmap's set AR.", LAST_SETTING_ORDER + 1, SettingControlType = typeof(ApproachRateSettingsControl))]
public Bindable<float?> ApproachRate { get; } = new Bindable<float?>
public DifficultyBindable ApproachRate { get; } = new DifficultyBindable
{
/*
Precision = 0.1f,
MinValue = 0,
MaxValue = 10,
*/
ExtendedMaxValue = 11,
};
protected override void ApplyLimits(bool extended)
public OsuModDifficultyAdjust()
{
base.ApplyLimits(extended);
// TODO: reimplement
// CircleSize.MaxValue = extended ? 11 : 10;
// ApproachRate.MaxValue = extended ? 11 : 10;
CircleSize.ExtendedLimits.BindTo(ExtendedLimits);
ApproachRate.ExtendedLimits.BindTo(ExtendedLimits);
}
public override string SettingDescription

View File

@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text.
using System.Linq;
using osu.Framework.Bindables;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Rulesets.Mods;
@ -11,14 +10,12 @@ namespace osu.Game.Rulesets.Taiko.Mods
{
public class TaikoModDifficultyAdjust : ModDifficultyAdjust
{
[SettingSource("Scroll Speed", "Adjust a beatmap's set scroll speed", LAST_SETTING_ORDER + 1)]
public Bindable<float?> ScrollSpeed { get; } = new Bindable<float?>
[SettingSource("Scroll Speed", "Adjust a beatmap's set scroll speed", LAST_SETTING_ORDER + 1, SettingControlType = typeof(DifficultyAdjustSettingsControl))]
public DifficultyBindable ScrollSpeed { get; } = new DifficultyBindable
{
/*
Precision = 0.05f,
MinValue = 0.25f,
MaxValue = 4,
*/
};
public override string SettingDescription
@ -39,7 +36,7 @@ namespace osu.Game.Rulesets.Taiko.Mods
{
base.ApplySettings(difficulty);
if (ScrollSpeed.Value != null) difficulty.SliderMultiplier = ScrollSpeed.Value.Value;
if (ScrollSpeed.Value != null) difficulty.SliderMultiplier *= ScrollSpeed.Value.Value;
}
}
}

View File

@ -56,7 +56,7 @@ namespace osu.Game.Tests.Visual.UserInterface
private void setBeatmapWithDifficultyParameters(float value)
{
AddStep($"set beatmap with all {value}", () => Beatmap.Value = CreateWorkingBeatmap(new Beatmap()
AddStep($"set beatmap with all {value}", () => Beatmap.Value = CreateWorkingBeatmap(new Beatmap
{
BeatmapInfo = new BeatmapInfo
{

View File

@ -7,14 +7,6 @@ namespace osu.Game.Rulesets.Mods
{
public class ApproachRateSettingsControl : DifficultyAdjustSettingsControl
{
public ApproachRateSettingsControl()
{
CurrentNumber.Precision = 0.1f;
CurrentNumber.MinValue = 0;
CurrentNumber.MaxValue = 10;
}
protected override float UpdateFromDifficulty(BeatmapDifficulty difficulty) => difficulty.ApproachRate;
}
}

View File

@ -17,17 +17,26 @@ namespace osu.Game.Rulesets.Mods
[Resolved]
private IBindable<WorkingBeatmap> beatmap { get; set; }
protected readonly BindableNumber<float> CurrentNumber = new BindableNumber<float>
{
// TODO: these need to be pulled out of the main bindable.
MinValue = 0,
MaxValue = 10,
};
protected readonly BindableNumber<float> CurrentNumber = new BindableNumber<float>();
protected override Drawable CreateControl() => new ControlDrawable(CurrentNumber);
private bool isInternalChange;
private DifficultyBindable difficultyBindable;
public override Bindable<float?> Current
{
get => base.Current;
set
{
// intercept and extract the DifficultyBindable.
difficultyBindable = (DifficultyBindable)value;
CurrentNumber.BindTo(difficultyBindable.CurrentNumber);
base.Current = value;
}
}
protected override void LoadComplete()
{
base.LoadComplete();

View File

@ -0,0 +1,84 @@
// 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 System;
using osu.Framework.Bindables;
namespace osu.Game.Rulesets.Mods
{
public class DifficultyBindable : Bindable<float?>
{
/// <summary>
/// Whether the extended limits should be applied to this bindable.
/// </summary>
public BindableBool ExtendedLimits { get; } = new BindableBool();
/// <summary>
/// An internal numeric bindable to hold and propagate min/max/precision.
/// The value of this bindable should not be set.
/// </summary>
public readonly BindableFloat CurrentNumber = new BindableFloat
{
MinValue = 0,
MaxValue = 10,
};
public float Precision
{
set => CurrentNumber.Precision = value;
}
public float MinValue
{
set => CurrentNumber.MinValue = value;
}
private float maxValue;
public float MaxValue
{
set
{
if (value == maxValue)
return;
maxValue = value;
updateMaxValue();
}
}
private float? extendedMaxValue;
/// <summary>
/// The maximum value to be used when extended limits are applied.
/// </summary>
public float? ExtendedMaxValue
{
set
{
if (value == extendedMaxValue)
return;
extendedMaxValue = value;
updateMaxValue();
}
}
public DifficultyBindable()
{
ExtendedLimits.BindValueChanged(_ => updateMaxValue());
BindValueChanged(val =>
{
// Ensure that in the case serialisation runs in the wrong order (and limit extensions aren't applied yet) the deserialised value is still propagated.
if (val.NewValue != null)
CurrentNumber.MaxValue = MathF.Max(CurrentNumber.MaxValue, val.NewValue.Value);
});
}
private void updateMaxValue()
{
CurrentNumber.MaxValue = ExtendedLimits.Value && extendedMaxValue != null ? extendedMaxValue.Value : maxValue;
}
}
}

View File

@ -33,23 +33,21 @@ namespace osu.Game.Rulesets.Mods
protected const int LAST_SETTING_ORDER = 2;
[SettingSource("HP Drain", "Override a beatmap's set HP.", FIRST_SETTING_ORDER, SettingControlType = typeof(DifficultyAdjustSettingsControl))]
public Bindable<float?> DrainRate { get; } = new Bindable<float?>
public DifficultyBindable DrainRate { get; } = new DifficultyBindable
{
/*
Precision = 0.1f,
MinValue = 0,
MaxValue = 10,
*/
ExtendedMaxValue = 11,
};
[SettingSource("Accuracy", "Override a beatmap's set OD.", LAST_SETTING_ORDER, SettingControlType = typeof(DifficultyAdjustSettingsControl))]
public Bindable<float?> OverallDifficulty { get; } = new Bindable<float?>
public DifficultyBindable OverallDifficulty { get; } = new DifficultyBindable
{
/*
Precision = 0.1f,
MinValue = 0,
MaxValue = 10,
*/
ExtendedMaxValue = 11,
};
[SettingSource("Extended Limits", "Adjust difficulty beyond sane limits.")]
@ -57,18 +55,8 @@ namespace osu.Game.Rulesets.Mods
protected ModDifficultyAdjust()
{
ExtendedLimits.BindValueChanged(extend => ApplyLimits(extend.NewValue));
}
/// <summary>
/// Changes the difficulty adjustment limits. Occurs when the value of <see cref="ExtendedLimits"/> is changed.
/// </summary>
/// <param name="extended">Whether limits should extend beyond sane ranges.</param>
protected virtual void ApplyLimits(bool extended)
{
// TODO: reimplement
// DrainRate.MaxValue = extended ? 11 : 10;
// OverallDifficulty.MaxValue = extended ? 11 : 10;
OverallDifficulty.ExtendedLimits.BindTo(ExtendedLimits);
DrainRate.ExtendedLimits.BindTo(ExtendedLimits);
}
public override string SettingDescription
@ -101,62 +89,5 @@ namespace osu.Game.Rulesets.Mods
if (DrainRate.Value != null) difficulty.DrainRate = DrainRate.Value.Value;
if (OverallDifficulty.Value != null) difficulty.OverallDifficulty = OverallDifficulty.Value.Value;
}
/// <summary>
/// A <see cref="BindableDouble"/> that extends its min/max values to support any assigned value.
/// </summary>
protected class BindableDoubleWithLimitExtension : BindableDouble
{
public override double Value
{
get => base.Value;
set
{
if (value < MinValue)
MinValue = value;
if (value > MaxValue)
MaxValue = value;
base.Value = value;
}
}
}
/// <summary>
/// A <see cref="BindableFloat"/> that extends its min/max values to support any assigned value.
/// </summary>
protected class BindableFloatWithLimitExtension : BindableFloat
{
public override float Value
{
get => base.Value;
set
{
if (value < MinValue)
MinValue = value;
if (value > MaxValue)
MaxValue = value;
base.Value = value;
}
}
}
/// <summary>
/// A <see cref="BindableInt"/> that extends its min/max values to support any assigned value.
/// </summary>
protected class BindableIntWithLimitExtension : BindableInt
{
public override int Value
{
get => base.Value;
set
{
if (value < MinValue)
MinValue = value;
if (value > MaxValue)
MaxValue = value;
base.Value = value;
}
}
}
}
}