1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 10:47:28 +08:00

use string.Empty, use base SettingDescription for [Osu/Catch]ModDifficultyAdjust

This commit is contained in:
Liam DeVoe 2020-03-22 18:49:45 -04:00
parent 4907fb8fd1
commit 63e9b2a299
7 changed files with 54 additions and 26 deletions

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System; using System;
using System.Linq;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Configuration; using osu.Game.Configuration;
@ -35,15 +36,15 @@ namespace osu.Game.Rulesets.Catch.Mods
{ {
get get
{ {
string circleSize = CircleSize.IsDefault ? "" : $"CS {CircleSize.Value}"; string circleSize = CircleSize.IsDefault ? string.Empty : $"CS {CircleSize.Value}";
string drainRate = DrainRate.IsDefault ? "" : $"HP {DrainRate.Value}"; string approachRate = ApproachRate.IsDefault ? string.Empty : $"AR {ApproachRate.Value}";
string overallDifficulty = OverallDifficulty.IsDefault ? "" : $"OD {OverallDifficulty.Value}";
string approachRate = ApproachRate.IsDefault ? "" : $"AR {ApproachRate.Value}";
string[] settings = { circleSize, drainRate, overallDifficulty, approachRate }; return string.Join(", ", new[]
// filter out empty strings so we don't have orphaned commas {
settings = Array.FindAll(settings, s => !string.IsNullOrEmpty(s)); circleSize,
return string.Join(", ", settings); base.SettingDescription,
approachRate
}.Where(s => !string.IsNullOrEmpty(s)));
} }
} }

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System; using System;
using System.Linq;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Configuration; using osu.Game.Configuration;
@ -35,15 +36,15 @@ namespace osu.Game.Rulesets.Osu.Mods
{ {
get get
{ {
string circleSize = CircleSize.IsDefault ? "" : $"CS {CircleSize.Value}"; string circleSize = CircleSize.IsDefault ? string.Empty : $"CS {CircleSize.Value}";
string drainRate = DrainRate.IsDefault ? "" : $"HP {DrainRate.Value}"; string approachRate = ApproachRate.IsDefault ? string.Empty : $"AR {ApproachRate.Value}";
string overallDifficulty = OverallDifficulty.IsDefault ? "" : $"OD {OverallDifficulty.Value}";
string approachRate = ApproachRate.IsDefault ? "" : $"AR {ApproachRate.Value}";
string[] settings = { circleSize, drainRate, overallDifficulty, approachRate }; return string.Join(", ", new[]
// filter out empty strings so we don't have orphaned commas {
settings = Array.FindAll(settings, s => !string.IsNullOrEmpty(s)); circleSize,
return string.Join(", ", settings); base.SettingDescription,
approachRate
}.Where(s => !string.IsNullOrEmpty(s)));
} }
} }

View File

@ -2,8 +2,13 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Newtonsoft.Json; using Newtonsoft.Json;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Game.Configuration;
using osu.Game.IO.Serialization; using osu.Game.IO.Serialization;
using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI;
@ -67,7 +72,26 @@ namespace osu.Game.Rulesets.Mods
/// Parentheses are added to the tooltip, surrounding the value of this property. If this property is <c>string.Empty</c>, /// 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. /// the tooltip will not have parentheses.
/// </remarks> /// </remarks>
public virtual string SettingDescription => string.Empty; public virtual string SettingDescription
{
get
{
var tooltipTexts = new List<string>();
foreach ((SettingSourceAttribute attr, PropertyInfo property) in this.GetOrderedSettingsSourceProperties())
{
object bindableObj = property.GetValue(this);
bool? settingIsDefault = (bindableObj as IHasDefaultValue)?.IsDefault;
string tooltipText = settingIsDefault == true ? string.Empty : attr.Label + " " + bindableObj.ToString();
tooltipTexts.Add(tooltipText);
}
// filter out empty strings so we don't have orphaned commas
//tooltipTexts = tooltipTexts.Where(s => !string.IsNullOrEmpty(s)).ToList();
string joinedTooltipText = string.Join(", ", tooltipTexts);
return $"{Name}{joinedTooltipText}";
}
}
/// <summary> /// <summary>
/// The score multiplier of this mod. /// The score multiplier of this mod.

View File

@ -7,6 +7,7 @@ using osu.Framework.Graphics.Sprites;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using osu.Game.Configuration; using osu.Game.Configuration;
using System.Linq;
namespace osu.Game.Rulesets.Mods namespace osu.Game.Rulesets.Mods
{ {
@ -56,13 +57,14 @@ namespace osu.Game.Rulesets.Mods
{ {
get get
{ {
string drainRate = DrainRate.IsDefault ? "" : $"HP {DrainRate.Value}"; string drainRate = DrainRate.IsDefault ? string.Empty : $"HP {DrainRate.Value}";
string overallDifficulty = OverallDifficulty.IsDefault ? "" : $"OD {OverallDifficulty.Value}"; string overallDifficulty = OverallDifficulty.IsDefault ? string.Empty : $"OD {OverallDifficulty.Value}";
string[] settings = { drainRate, overallDifficulty }; return string.Join(", ", new[]
// filter out empty strings so we don't have orphaned commas {
settings = Array.FindAll(settings, s => !string.IsNullOrEmpty(s)); drainRate,
return string.Join(", ", settings); overallDifficulty
}.Where(s => !string.IsNullOrEmpty(s)));
} }
} }

View File

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

View File

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

View File

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