1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 15:03:13 +08:00

Revert "use SettingSource to define IconTooltip format"

This reverts commit 5a6d8f1932.
This commit is contained in:
Liam DeVoe 2020-03-20 16:05:12 -04:00
parent 3d95592130
commit 7bdbdd25f8
8 changed files with 30 additions and 56 deletions

View File

@ -10,7 +10,7 @@ namespace osu.Game.Rulesets.Catch.Mods
{
public class CatchModDifficultyAdjust : ModDifficultyAdjust
{
[SettingSource("Circle Size", "Override a beatmap's set CS.", "CS {0}", FIRST_SETTING_ORDER - 1)]
[SettingSource("Circle Size", "Override a beatmap's set CS.", FIRST_SETTING_ORDER - 1)]
public BindableNumber<float> CircleSize { get; } = new BindableFloat
{
Precision = 0.1f,
@ -20,7 +20,7 @@ namespace osu.Game.Rulesets.Catch.Mods
Value = 5,
};
[SettingSource("Approach Rate", "Override a beatmap's set AR.", "AR {0}", LAST_SETTING_ORDER + 1)]
[SettingSource("Approach Rate", "Override a beatmap's set AR.", LAST_SETTING_ORDER + 1)]
public BindableNumber<float> ApproachRate { get; } = new BindableFloat
{
Precision = 0.1f,
@ -30,6 +30,11 @@ 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[] { ',', ' ' }) + ")";
protected override void TransferSettings(BeatmapDifficulty difficulty)
{
base.TransferSettings(difficulty);

View File

@ -10,7 +10,7 @@ namespace osu.Game.Rulesets.Osu.Mods
{
public class OsuModDifficultyAdjust : ModDifficultyAdjust
{
[SettingSource("Circle Size", "Override a beatmap's set CS.", "CS {0}", FIRST_SETTING_ORDER - 1)]
[SettingSource("Circle Size", "Override a beatmap's set CS.", FIRST_SETTING_ORDER - 1)]
public BindableNumber<float> CircleSize { get; } = new BindableFloat
{
Precision = 0.1f,
@ -20,7 +20,7 @@ namespace osu.Game.Rulesets.Osu.Mods
Value = 5,
};
[SettingSource("Approach Rate", "Override a beatmap's set AR.", "AR {0}", LAST_SETTING_ORDER + 1)]
[SettingSource("Approach Rate", "Override a beatmap's set AR.", LAST_SETTING_ORDER + 1)]
public BindableNumber<float> ApproachRate { get; } = new BindableFloat
{
Precision = 0.1f,
@ -30,6 +30,11 @@ 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[] { ',', ' ' }) + ")";
protected override void TransferSettings(BeatmapDifficulty difficulty)
{
base.TransferSettings(difficulty);

View File

@ -30,25 +30,16 @@ namespace osu.Game.Configuration
public int? OrderPosition { get; }
public string TooltipText { get; }
public SettingSourceAttribute(string label, string description = null)
{
Label = label ?? string.Empty;
Description = description ?? string.Empty;
}
public SettingSourceAttribute(string label, string description, string tooltipText, int orderPosition)
public SettingSourceAttribute(string label, string description, int orderPosition)
: this(label, description)
{
OrderPosition = orderPosition;
TooltipText = tooltipText;
}
public SettingSourceAttribute(string label, string description, string tooltipText)
: this(label, description)
{
TooltipText = tooltipText;
}
}

View File

@ -2,12 +2,8 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Sprites;
using osu.Game.Configuration;
using osu.Game.IO.Serialization;
using osu.Game.Rulesets.UI;
@ -55,39 +51,7 @@ namespace osu.Game.Rulesets.Mods
/// are displayed in the tooltip.
/// </remarks>
[JsonIgnore]
public virtual string IconTooltip
{
get
{
var attributes = new List<string>();
foreach ((SettingSourceAttribute attr, System.Reflection.PropertyInfo property) in this.GetOrderedSettingsSourceProperties())
{
// use TooltipText from SettingSource if available, but fall back to Label, which has to be provided
string tooltipText = attr.TooltipText ?? attr.Label + " {0}";
object bindableObj = property.GetValue(this);
if (bindableObj is BindableInt bindableInt && !bindableInt.IsDefault)
{
attributes.Add(string.Format(tooltipText, bindableInt.Value));
continue;
}
if (bindableObj is BindableFloat bindableFloat && !bindableFloat.IsDefault)
{
attributes.Add(string.Format(tooltipText, bindableFloat.Value));
continue;
}
if (bindableObj is BindableDouble bindableDouble && !bindableDouble.IsDefault)
{
attributes.Add(string.Format(tooltipText, bindableDouble.Value));
}
}
return $"{Name}{(attributes.Any() ? $" ({string.Join(", ", attributes)})" : "")}";
}
}
public virtual string IconTooltip => Name;
/// <summary>
/// The score multiplier of this mod.

View File

@ -32,7 +32,7 @@ namespace osu.Game.Rulesets.Mods
protected const int LAST_SETTING_ORDER = 2;
[SettingSource("HP Drain", "Override a beatmap's set HP.", "HP {0}", FIRST_SETTING_ORDER)]
[SettingSource("HP Drain", "Override a beatmap's set HP.", FIRST_SETTING_ORDER)]
public BindableNumber<float> DrainRate { get; } = new BindableFloat
{
Precision = 0.1f,
@ -42,7 +42,7 @@ namespace osu.Game.Rulesets.Mods
Value = 5,
};
[SettingSource("Accuracy", "Override a beatmap's set OD.", "OD {0}", LAST_SETTING_ORDER)]
[SettingSource("Accuracy", "Override a beatmap's set OD.", LAST_SETTING_ORDER)]
public BindableNumber<float> OverallDifficulty { get; } = new BindableFloat
{
Precision = 0.1f,
@ -52,6 +52,9 @@ namespace osu.Game.Rulesets.Mods
Value = 5,
};
public override string IconTooltip => $"{Name} ({(DrainRate.IsDefault ? $"HP {DrainRate.Value.ToString()}, " : "")}" +
$"{(OverallDifficulty.IsDefault ? $"OD {OverallDifficulty.Value.ToString()}, " : "")})";
private BeatmapDifficulty difficulty;
public void ReadFromDifficulty(BeatmapDifficulty difficulty)

View File

@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Mods
public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(ModHalfTime)).ToArray();
[SettingSource("Speed increase", "The actual increase to apply", "{0}x")]
[SettingSource("Speed increase", "The actual increase to apply")]
public override BindableNumber<double> SpeedChange { get; } = new BindableDouble
{
MinValue = 1.01,
@ -30,5 +30,7 @@ namespace osu.Game.Rulesets.Mods
Value = 1.5,
Precision = 0.01,
};
public override string IconTooltip => $"{Name}{(SpeedChange.IsDefault ? "" : $" ({SpeedChange.Value}x)")}";
}
}

View File

@ -21,13 +21,15 @@ namespace osu.Game.Rulesets.Mods
public override bool Ranked => true;
public override Type[] IncompatibleMods => new[] { typeof(ModHardRock), typeof(ModDifficultyAdjust) };
[SettingSource("Extra Lives", "Number of extra lives", "{0} lives")]
[SettingSource("Extra Lives", "Number of extra lives")]
public Bindable<int> Retries { get; } = new BindableInt(2)
{
MinValue = 0,
MaxValue = 10
};
public override string IconTooltip => $"{Name}{(Retries.IsDefault ? "" : $" ({Retries.Value} lives)")}";
private int retries;
private BindableNumber<double> health;

View File

@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Mods
public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(ModDoubleTime)).ToArray();
[SettingSource("Speed decrease", "The actual decrease to apply", "{0}x")]
[SettingSource("Speed decrease", "The actual decrease to apply")]
public override BindableNumber<double> SpeedChange { get; } = new BindableDouble
{
MinValue = 0.5,
@ -30,5 +30,7 @@ namespace osu.Game.Rulesets.Mods
Value = 0.75,
Precision = 0.01,
};
public override string IconTooltip => $"{Name}{(SpeedChange.IsDefault ? "" : $" ({SpeedChange.Value}x)")}";
}
}