1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-27 02:32:59 +08:00

move overridability to SettingDescription method

This commit is contained in:
Liam DeVoe 2020-03-20 16:34:36 -04:00
parent 7bdbdd25f8
commit cda1efef0b
8 changed files with 67 additions and 15 deletions

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 System;
using osu.Framework.Bindables;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
@ -30,10 +31,21 @@ namespace osu.Game.Rulesets.Catch.Mods
Value = 5,
};
public override string IconTooltip => ($"{Name} ({(CircleSize.IsDefault ? "" : $"CS {CircleSize.Value}, ")}" +
$"{(DrainRate.IsDefault ? "" : $"HP {DrainRate.Value}, ")}" +
$"{(OverallDifficulty.IsDefault ? "" : $"OD {OverallDifficulty.Value}, ")}" +
$"{(ApproachRate.IsDefault ? "" : $"AR {ApproachRate.Value}")}").TrimEnd(new char[] { ',', ' ' }) + ")";
public override string SettingDescription
{
get
{
string circleSize = CircleSize.IsDefault ? "" : $"CS {CircleSize.Value.ToString()}";
string drainRate = DrainRate.IsDefault ? "" : $"HP {DrainRate.Value.ToString()}";
string overallDifficulty = OverallDifficulty.IsDefault ? "" : $"OD {OverallDifficulty.Value.ToString()}";
string approachRate = ApproachRate.IsDefault ? "" : $"AR {ApproachRate.Value.ToString()}";
string[] settings = new string[] { circleSize, drainRate, overallDifficulty, approachRate };
// filter out empty strings so we don't have orphaned commas
settings = Array.FindAll(settings, s => !string.IsNullOrEmpty(s));
return string.Join(", ", settings);
}
}
protected override void TransferSettings(BeatmapDifficulty difficulty)
{

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 System;
using osu.Framework.Bindables;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
@ -30,10 +31,21 @@ namespace osu.Game.Rulesets.Osu.Mods
Value = 5,
};
public override string IconTooltip => ($"{Name} ({(CircleSize.IsDefault ? "" : $"CS {CircleSize.Value}, ")}" +
$"{(DrainRate.IsDefault ? "" : $"HP {DrainRate.Value}, ")}" +
$"{(OverallDifficulty.IsDefault ? "" : $"OD {OverallDifficulty.Value}, ")}" +
$"{(ApproachRate.IsDefault ? "" : $"AR {ApproachRate.Value}")}").TrimEnd(new char[] { ',', ' ' }) + ")";
public override string SettingDescription
{
get
{
string circleSize = CircleSize.IsDefault ? "" : $"CS {CircleSize.Value.ToString()}";
string drainRate = DrainRate.IsDefault ? "" : $"HP {DrainRate.Value.ToString()}";
string overallDifficulty = OverallDifficulty.IsDefault ? "" : $"OD {OverallDifficulty.Value.ToString()}";
string approachRate = ApproachRate.IsDefault ? "" : $"AR {ApproachRate.Value.ToString()}";
string[] settings = new string[] { circleSize, drainRate, overallDifficulty, approachRate };
// filter out empty strings so we don't have orphaned commas
settings = Array.FindAll(settings, s => !string.IsNullOrEmpty(s));
return string.Join(", ", settings);
}
}
protected override void TransferSettings(BeatmapDifficulty difficulty)
{

View File

@ -51,7 +51,23 @@ namespace osu.Game.Rulesets.Mods
/// are displayed in the tooltip.
/// </remarks>
[JsonIgnore]
public virtual string IconTooltip => Name;
public string IconTooltip
{
get
{
string settingDescription = string.IsNullOrEmpty(SettingDescription) ? "" : $" ({SettingDescription})";
return $"{Name}{settingDescription}";
}
}
/// <summary>
/// The description of editable settings of a mod to use in the <see cref="IconTooltip"/>.
/// </summary>
/// <remarks>
/// Parentheses are added to the tooltip, surrounding the value of this property. If this property is <c>string.Empty</c>,
/// the tooltip will not have parentheses.
/// </remarks>
public virtual string SettingDescription => string.Empty;
/// <summary>
/// The score multiplier of this mod.

View File

@ -7,6 +7,7 @@ using osu.Framework.Graphics.Sprites;
using System;
using System.Collections.Generic;
using osu.Game.Configuration;
using System.Linq;
namespace osu.Game.Rulesets.Mods
{
@ -52,8 +53,19 @@ namespace osu.Game.Rulesets.Mods
Value = 5,
};
public override string IconTooltip => $"{Name} ({(DrainRate.IsDefault ? $"HP {DrainRate.Value.ToString()}, " : "")}" +
$"{(OverallDifficulty.IsDefault ? $"OD {OverallDifficulty.Value.ToString()}, " : "")})";
public override string SettingDescription
{
get
{
string drainRate = DrainRate.IsDefault ? "" : $"HP {DrainRate.Value.ToString()}";
string overallDifficulty = OverallDifficulty.IsDefault ? "" : $"OD {OverallDifficulty.Value.ToString()}";
string[] settings = new string[] { drainRate, overallDifficulty };
// filter out empty strings so we don't have orphaned commas
settings = Array.FindAll(settings, s => !string.IsNullOrEmpty(s));
return string.Join(", ", settings);
}
}
private BeatmapDifficulty difficulty;

View File

@ -31,6 +31,6 @@ namespace osu.Game.Rulesets.Mods
Precision = 0.01,
};
public override string IconTooltip => $"{Name}{(SpeedChange.IsDefault ? "" : $" ({SpeedChange.Value}x)")}";
public override string SettingDescription => SpeedChange.IsDefault ? "" : $" ({SpeedChange.Value}x)";
}
}

View File

@ -28,7 +28,7 @@ namespace osu.Game.Rulesets.Mods
MaxValue = 10
};
public override string IconTooltip => $"{Name}{(Retries.IsDefault ? "" : $" ({Retries.Value} lives)")}";
public override string SettingDescription => Retries.IsDefault ? "" : $" ({Retries.Value} lives)";
private int retries;

View File

@ -31,6 +31,6 @@ namespace osu.Game.Rulesets.Mods
Precision = 0.01,
};
public override string IconTooltip => $"{Name}{(SpeedChange.IsDefault ? "" : $" ({SpeedChange.Value}x)")}";
public override string SettingDescription => SpeedChange.IsDefault ? "" : $" ({SpeedChange.Value}x)";
}
}

View File

@ -26,7 +26,7 @@ namespace osu.Game.Rulesets.Mods
[SettingSource("Final rate", "The final speed to ramp to")]
public abstract BindableNumber<double> FinalRate { get; }
public override string IconTooltip => $"{Name} ({InitialRate.Value}x to {FinalRate.Value}x)";
public override string SettingDescription => $"{InitialRate.Value} to {FinalRate.Value}";
private double finalRateTime;
private double beginRampTime;