Simplify string construction logic

This commit is contained in:
Dean Herbert 2020-03-23 15:20:56 +09:00
parent a6b153673e
commit 205f4dcb54

View File

@ -60,8 +60,9 @@ namespace osu.Game.Rulesets.Mods
{ {
get get
{ {
string settingDescription = string.IsNullOrEmpty(SettingDescription) ? string.Empty : $" ({SettingDescription})"; string description = SettingDescription;
return $"{Name}{settingDescription}";
return string.IsNullOrEmpty(description) ? Name : $"{Name} ({description})";
} }
} }
@ -81,13 +82,14 @@ namespace osu.Game.Rulesets.Mods
foreach ((SettingSourceAttribute attr, PropertyInfo property) in this.GetOrderedSettingsSourceProperties()) foreach ((SettingSourceAttribute attr, PropertyInfo property) in this.GetOrderedSettingsSourceProperties())
{ {
object bindableObj = property.GetValue(this); object bindableObj = property.GetValue(this);
bool? settingIsDefault = (bindableObj as IHasDefaultValue)?.IsDefault;
string tooltipText = settingIsDefault == true ? string.Empty : attr.Label + " " + bindableObj; if ((bindableObj as IHasDefaultValue)?.IsDefault == true)
tooltipTexts.Add(tooltipText); continue;
tooltipTexts.Add($"{attr.Label} {bindableObj}");
} }
string joinedTooltipText = string.Join(", ", tooltipTexts.Where(s => !string.IsNullOrEmpty(s))); return string.Join(", ", tooltipTexts.Where(s => !string.IsNullOrEmpty(s)));
return $"{joinedTooltipText}";
} }
} }