mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 03:13:21 +08:00
Avoid the need for per-settings control classes
This commit is contained in:
parent
a6e94dd491
commit
bd7c334588
@ -18,6 +18,8 @@ namespace osu.Game.Rulesets.Catch.Mods
|
|||||||
Precision = 0.1f,
|
Precision = 0.1f,
|
||||||
MinValue = 1,
|
MinValue = 1,
|
||||||
MaxValue = 10,
|
MaxValue = 10,
|
||||||
|
ExtendedMaxValue = 11,
|
||||||
|
ReadFromDifficulty = diff => diff.CircleSize,
|
||||||
};
|
};
|
||||||
|
|
||||||
[SettingSource("Approach Rate", "Override a beatmap's set AR.", LAST_SETTING_ORDER + 1)]
|
[SettingSource("Approach Rate", "Override a beatmap's set AR.", LAST_SETTING_ORDER + 1)]
|
||||||
@ -26,6 +28,8 @@ namespace osu.Game.Rulesets.Catch.Mods
|
|||||||
Precision = 0.1f,
|
Precision = 0.1f,
|
||||||
MinValue = 1,
|
MinValue = 1,
|
||||||
MaxValue = 10,
|
MaxValue = 10,
|
||||||
|
ExtendedMaxValue = 11,
|
||||||
|
ReadFromDifficulty = diff => diff.ApproachRate,
|
||||||
};
|
};
|
||||||
|
|
||||||
[SettingSource("Spicy Patterns", "Adjust the patterns as if Hard Rock is enabled.")]
|
[SettingSource("Spicy Patterns", "Adjust the patterns as if Hard Rock is enabled.")]
|
||||||
|
@ -17,15 +17,17 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
MinValue = 0,
|
MinValue = 0,
|
||||||
MaxValue = 10,
|
MaxValue = 10,
|
||||||
ExtendedMaxValue = 11,
|
ExtendedMaxValue = 11,
|
||||||
|
ReadFromDifficulty = diff => diff.CircleSize,
|
||||||
};
|
};
|
||||||
|
|
||||||
[SettingSource("Approach Rate", "Override a beatmap's set AR.", LAST_SETTING_ORDER + 1, SettingControlType = typeof(ApproachRateSettingsControl))]
|
[SettingSource("Approach Rate", "Override a beatmap's set AR.", LAST_SETTING_ORDER + 1, SettingControlType = typeof(DifficultyAdjustSettingsControl))]
|
||||||
public DifficultyBindable ApproachRate { get; } = new DifficultyBindable
|
public DifficultyBindable ApproachRate { get; } = new DifficultyBindable
|
||||||
{
|
{
|
||||||
Precision = 0.1f,
|
Precision = 0.1f,
|
||||||
MinValue = 0,
|
MinValue = 0,
|
||||||
MaxValue = 10,
|
MaxValue = 10,
|
||||||
ExtendedMaxValue = 11,
|
ExtendedMaxValue = 11,
|
||||||
|
ReadFromDifficulty = diff => diff.ApproachRate,
|
||||||
};
|
};
|
||||||
|
|
||||||
public OsuModDifficultyAdjust()
|
public OsuModDifficultyAdjust()
|
||||||
|
@ -16,6 +16,7 @@ namespace osu.Game.Rulesets.Taiko.Mods
|
|||||||
Precision = 0.05f,
|
Precision = 0.05f,
|
||||||
MinValue = 0.25f,
|
MinValue = 0.25f,
|
||||||
MaxValue = 4,
|
MaxValue = 4,
|
||||||
|
ReadFromDifficulty = _ => 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
public override string SettingDescription
|
public override string SettingDescription
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
// 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.Game.Beatmaps;
|
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mods
|
|
||||||
{
|
|
||||||
public class ApproachRateSettingsControl : DifficultyAdjustSettingsControl
|
|
||||||
{
|
|
||||||
protected override float UpdateFromDifficulty(BeatmapDifficulty difficulty) => difficulty.ApproachRate;
|
|
||||||
}
|
|
||||||
}
|
|
@ -11,7 +11,6 @@ using osu.Game.Overlays.Settings;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Mods
|
namespace osu.Game.Rulesets.Mods
|
||||||
{
|
{
|
||||||
// TODO: make abstract once we finish making each implementation.
|
|
||||||
public class DifficultyAdjustSettingsControl : SettingsItem<float?>
|
public class DifficultyAdjustSettingsControl : SettingsItem<float?>
|
||||||
{
|
{
|
||||||
[Resolved]
|
[Resolved]
|
||||||
@ -69,14 +68,11 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
if (Current.Value == null)
|
if (Current.Value == null)
|
||||||
{
|
{
|
||||||
isInternalChange = true;
|
isInternalChange = true;
|
||||||
CurrentNumber.Value = UpdateFromDifficulty(difficulty);
|
CurrentNumber.Value = difficultyBindable.ReadFromDifficulty(difficulty);
|
||||||
isInternalChange = false;
|
isInternalChange = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: make abstract
|
|
||||||
protected virtual float UpdateFromDifficulty(BeatmapDifficulty difficulty) => 0;
|
|
||||||
|
|
||||||
private class ControlDrawable : CompositeDrawable, IHasCurrentValue<float?>
|
private class ControlDrawable : CompositeDrawable, IHasCurrentValue<float?>
|
||||||
{
|
{
|
||||||
private readonly BindableWithCurrent<float?> current = new BindableWithCurrent<float?>();
|
private readonly BindableWithCurrent<float?> current = new BindableWithCurrent<float?>();
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mods
|
namespace osu.Game.Rulesets.Mods
|
||||||
{
|
{
|
||||||
@ -23,6 +24,11 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
MaxValue = 10,
|
MaxValue = 10,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A function that can extract the current value of this setting from a beatmap difficulty for display purposes.
|
||||||
|
/// </summary>
|
||||||
|
public Func<BeatmapDifficulty, float> ReadFromDifficulty;
|
||||||
|
|
||||||
public float Precision
|
public float Precision
|
||||||
{
|
{
|
||||||
set => CurrentNumber.Precision = value;
|
set => CurrentNumber.Precision = value;
|
||||||
|
@ -39,6 +39,7 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
MinValue = 0,
|
MinValue = 0,
|
||||||
MaxValue = 10,
|
MaxValue = 10,
|
||||||
ExtendedMaxValue = 11,
|
ExtendedMaxValue = 11,
|
||||||
|
ReadFromDifficulty = diff => diff.DrainRate,
|
||||||
};
|
};
|
||||||
|
|
||||||
[SettingSource("Accuracy", "Override a beatmap's set OD.", LAST_SETTING_ORDER, SettingControlType = typeof(DifficultyAdjustSettingsControl))]
|
[SettingSource("Accuracy", "Override a beatmap's set OD.", LAST_SETTING_ORDER, SettingControlType = typeof(DifficultyAdjustSettingsControl))]
|
||||||
@ -48,6 +49,7 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
MinValue = 0,
|
MinValue = 0,
|
||||||
MaxValue = 10,
|
MaxValue = 10,
|
||||||
ExtendedMaxValue = 11,
|
ExtendedMaxValue = 11,
|
||||||
|
ReadFromDifficulty = diff => diff.OverallDifficulty,
|
||||||
};
|
};
|
||||||
|
|
||||||
[SettingSource("Extended Limits", "Adjust difficulty beyond sane limits.")]
|
[SettingSource("Extended Limits", "Adjust difficulty beyond sane limits.")]
|
||||||
|
Loading…
Reference in New Issue
Block a user