Simplify some default value checks (we are sure the return is an IBindable)

This commit is contained in:
Dean Herbert 2021-01-03 15:47:15 +09:00
parent 1a44338124
commit 23e216fa0b
2 changed files with 9 additions and 6 deletions

View File

@ -31,7 +31,12 @@ public APIMod(Mod mod)
Acronym = mod.Acronym;
foreach (var (_, property) in mod.GetSettingsSourceProperties())
Settings.Add(property.Name.Underscore(), property.GetValue(mod));
{
var bindable = (IBindable)property.GetValue(mod);
if (!bindable.IsDefault)
Settings.Add(property.Name.Underscore(), property.GetValue(mod));
}
}
public Mod ToMod(Ruleset ruleset)

View File

@ -84,12 +84,10 @@ public virtual string SettingDescription
foreach ((SettingSourceAttribute attr, PropertyInfo property) in this.GetOrderedSettingsSourceProperties())
{
object bindableObj = property.GetValue(this);
var bindable = (IBindable)property.GetValue(this);
if ((bindableObj as IHasDefaultValue)?.IsDefault == true)
continue;
tooltipTexts.Add($"{attr.Label} {bindableObj}");
if (!bindable.IsDefault)
tooltipTexts.Add($"{attr.Label} {bindable}");
}
return string.Join(", ", tooltipTexts.Where(s => !string.IsNullOrEmpty(s)));