1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:57:39 +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.
using System;
using System.Linq;
using osu.Framework.Bindables;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
@ -35,15 +36,15 @@ namespace osu.Game.Rulesets.Catch.Mods
{
get
{
string circleSize = CircleSize.IsDefault ? "" : $"CS {CircleSize.Value}";
string drainRate = DrainRate.IsDefault ? "" : $"HP {DrainRate.Value}";
string overallDifficulty = OverallDifficulty.IsDefault ? "" : $"OD {OverallDifficulty.Value}";
string approachRate = ApproachRate.IsDefault ? "" : $"AR {ApproachRate.Value}";
string circleSize = CircleSize.IsDefault ? string.Empty : $"CS {CircleSize.Value}";
string approachRate = ApproachRate.IsDefault ? string.Empty : $"AR {ApproachRate.Value}";
string[] settings = { 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);
return string.Join(", ", new[]
{
circleSize,
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.
using System;
using System.Linq;
using osu.Framework.Bindables;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
@ -35,15 +36,15 @@ namespace osu.Game.Rulesets.Osu.Mods
{
get
{
string circleSize = CircleSize.IsDefault ? "" : $"CS {CircleSize.Value}";
string drainRate = DrainRate.IsDefault ? "" : $"HP {DrainRate.Value}";
string overallDifficulty = OverallDifficulty.IsDefault ? "" : $"OD {OverallDifficulty.Value}";
string approachRate = ApproachRate.IsDefault ? "" : $"AR {ApproachRate.Value}";
string circleSize = CircleSize.IsDefault ? string.Empty : $"CS {CircleSize.Value}";
string approachRate = ApproachRate.IsDefault ? string.Empty : $"AR {ApproachRate.Value}";
string[] settings = { 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);
return string.Join(", ", new[]
{
circleSize,
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.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
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;
@ -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>,
/// the tooltip will not have parentheses.
/// </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>
/// 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
{
@ -56,13 +57,14 @@ namespace osu.Game.Rulesets.Mods
{
get
{
string drainRate = DrainRate.IsDefault ? "" : $"HP {DrainRate.Value}";
string overallDifficulty = OverallDifficulty.IsDefault ? "" : $"OD {OverallDifficulty.Value}";
string drainRate = DrainRate.IsDefault ? string.Empty : $"HP {DrainRate.Value}";
string overallDifficulty = OverallDifficulty.IsDefault ? string.Empty : $"OD {OverallDifficulty.Value}";
string[] settings = { 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);
return string.Join(", ", new[]
{
drainRate,
overallDifficulty
}.Where(s => !string.IsNullOrEmpty(s)));
}
}

View File

@ -31,6 +31,6 @@ namespace osu.Game.Rulesets.Mods
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
};
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;

View File

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