2019-12-11 19:43:16 +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.
|
|
|
|
|
2021-07-08 13:28:13 +08:00
|
|
|
using System;
|
|
|
|
using System.Linq;
|
2019-12-11 19:43:16 +08:00
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2021-07-08 13:28:13 +08:00
|
|
|
using osu.Game.Beatmaps;
|
2019-12-22 16:45:32 +08:00
|
|
|
using osu.Game.Configuration;
|
2019-12-11 19:43:16 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mods
|
|
|
|
{
|
2019-12-20 18:30:23 +08:00
|
|
|
public abstract class ModDifficultyAdjust : Mod, IApplicableToDifficulty
|
2019-12-11 19:43:16 +08:00
|
|
|
{
|
|
|
|
public override string Name => @"Difficulty Adjust";
|
|
|
|
|
2019-12-20 18:31:16 +08:00
|
|
|
public override string Description => @"Override a beatmap's difficulty settings.";
|
2019-12-11 19:43:16 +08:00
|
|
|
|
|
|
|
public override string Acronym => "DA";
|
|
|
|
|
|
|
|
public override ModType Type => ModType.Conversion;
|
|
|
|
|
2020-01-14 21:22:00 +08:00
|
|
|
public override IconUsage? Icon => FontAwesome.Solid.Hammer;
|
2019-12-11 19:43:16 +08:00
|
|
|
|
|
|
|
public override double ScoreMultiplier => 1.0;
|
|
|
|
|
2020-01-21 00:06:36 +08:00
|
|
|
public override bool RequiresConfiguration => true;
|
|
|
|
|
2019-12-11 19:43:16 +08:00
|
|
|
public override Type[] IncompatibleMods => new[] { typeof(ModEasy), typeof(ModHardRock) };
|
|
|
|
|
2020-02-13 13:07:37 +08:00
|
|
|
protected const int FIRST_SETTING_ORDER = 1;
|
|
|
|
|
|
|
|
protected const int LAST_SETTING_ORDER = 2;
|
|
|
|
|
2021-07-08 14:53:49 +08:00
|
|
|
[SettingSource("HP Drain", "Override a beatmap's set HP.", FIRST_SETTING_ORDER, SettingControlType = typeof(DifficultyAdjustSettingsControl))]
|
2021-07-08 15:40:32 +08:00
|
|
|
public DifficultyBindable DrainRate { get; } = new DifficultyBindable
|
2019-12-22 16:45:32 +08:00
|
|
|
{
|
|
|
|
Precision = 0.1f,
|
2020-07-14 07:15:14 +08:00
|
|
|
MinValue = 0,
|
2019-12-22 16:45:32 +08:00
|
|
|
MaxValue = 10,
|
2021-07-08 15:40:32 +08:00
|
|
|
ExtendedMaxValue = 11,
|
2021-07-09 12:24:26 +08:00
|
|
|
ReadCurrentFromDifficulty = diff => diff.DrainRate,
|
2019-12-22 16:45:32 +08:00
|
|
|
};
|
|
|
|
|
2021-07-08 14:53:49 +08:00
|
|
|
[SettingSource("Accuracy", "Override a beatmap's set OD.", LAST_SETTING_ORDER, SettingControlType = typeof(DifficultyAdjustSettingsControl))]
|
2021-07-08 15:40:32 +08:00
|
|
|
public DifficultyBindable OverallDifficulty { get; } = new DifficultyBindable
|
2019-12-22 16:45:32 +08:00
|
|
|
{
|
|
|
|
Precision = 0.1f,
|
2020-07-14 07:15:14 +08:00
|
|
|
MinValue = 0,
|
2019-12-22 16:45:32 +08:00
|
|
|
MaxValue = 10,
|
2021-07-08 15:40:32 +08:00
|
|
|
ExtendedMaxValue = 11,
|
2021-07-09 12:24:26 +08:00
|
|
|
ReadCurrentFromDifficulty = diff => diff.OverallDifficulty,
|
2019-12-22 16:45:32 +08:00
|
|
|
};
|
2019-12-11 19:43:16 +08:00
|
|
|
|
2020-12-09 23:25:46 +08:00
|
|
|
[SettingSource("Extended Limits", "Adjust difficulty beyond sane limits.")]
|
|
|
|
public BindableBool ExtendedLimits { get; } = new BindableBool();
|
|
|
|
|
|
|
|
protected ModDifficultyAdjust()
|
|
|
|
{
|
2021-07-08 16:00:55 +08:00
|
|
|
foreach (var (_, property) in this.GetOrderedSettingsSourceProperties())
|
|
|
|
{
|
|
|
|
if (property.GetValue(this) is DifficultyBindable diffAdjustBindable)
|
|
|
|
diffAdjustBindable.ExtendedLimits.BindTo(ExtendedLimits);
|
|
|
|
}
|
2020-12-09 23:25:46 +08:00
|
|
|
}
|
|
|
|
|
2020-03-21 04:34:36 +08:00
|
|
|
public override string SettingDescription
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2020-03-23 10:54:21 +08:00
|
|
|
string drainRate = DrainRate.IsDefault ? string.Empty : $"HP {DrainRate.Value:N1}";
|
|
|
|
string overallDifficulty = OverallDifficulty.IsDefault ? string.Empty : $"OD {OverallDifficulty.Value:N1}";
|
2020-03-23 06:49:45 +08:00
|
|
|
|
|
|
|
return string.Join(", ", new[]
|
|
|
|
{
|
|
|
|
drainRate,
|
|
|
|
overallDifficulty
|
|
|
|
}.Where(s => !string.IsNullOrEmpty(s)));
|
2020-03-21 04:34:36 +08:00
|
|
|
}
|
|
|
|
}
|
2020-03-21 04:05:12 +08:00
|
|
|
|
2019-12-26 13:52:08 +08:00
|
|
|
public void ReadFromDifficulty(BeatmapDifficulty difficulty)
|
2019-12-11 19:43:16 +08:00
|
|
|
{
|
2019-12-22 16:45:32 +08:00
|
|
|
}
|
|
|
|
|
2019-12-26 13:52:08 +08:00
|
|
|
public void ApplyToDifficulty(BeatmapDifficulty difficulty) => ApplySettings(difficulty);
|
|
|
|
|
2019-12-25 14:20:04 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Apply all custom settings to the provided beatmap.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="difficulty">The beatmap to have settings applied.</param>
|
2019-12-22 16:45:32 +08:00
|
|
|
protected virtual void ApplySettings(BeatmapDifficulty difficulty)
|
|
|
|
{
|
2021-07-08 13:28:13 +08:00
|
|
|
if (DrainRate.Value != null) difficulty.DrainRate = DrainRate.Value.Value;
|
|
|
|
if (OverallDifficulty.Value != null) difficulty.OverallDifficulty = OverallDifficulty.Value.Value;
|
2019-12-11 19:43:16 +08:00
|
|
|
}
|
|
|
|
}
|
2019-12-11 20:12:29 +08:00
|
|
|
}
|