Merge pull request #11739 from peppy/settings-item-tooltips

Display descriptions in tooltips of mod settings adjustments
This commit is contained in:
Dan Balasescu 2021-02-12 00:18:16 +09:00 committed by GitHub
commit ca091431f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -57,6 +57,7 @@ public static IEnumerable<Drawable> CreateSettingsControls(this object obj)
yield return new SettingsSlider<float>
{
LabelText = attr.Label,
TooltipText = attr.Description,
Current = bNumber,
KeyboardStep = 0.1f,
};
@ -67,6 +68,7 @@ public static IEnumerable<Drawable> CreateSettingsControls(this object obj)
yield return new SettingsSlider<double>
{
LabelText = attr.Label,
TooltipText = attr.Description,
Current = bNumber,
KeyboardStep = 0.1f,
};
@ -77,6 +79,7 @@ public static IEnumerable<Drawable> CreateSettingsControls(this object obj)
yield return new SettingsSlider<int>
{
LabelText = attr.Label,
TooltipText = attr.Description,
Current = bNumber
};
@ -86,6 +89,7 @@ public static IEnumerable<Drawable> CreateSettingsControls(this object obj)
yield return new SettingsCheckbox
{
LabelText = attr.Label,
TooltipText = attr.Description,
Current = bBool
};
@ -95,6 +99,7 @@ public static IEnumerable<Drawable> CreateSettingsControls(this object obj)
yield return new SettingsTextBox
{
LabelText = attr.Label,
TooltipText = attr.Description,
Current = bString
};
@ -105,6 +110,7 @@ public static IEnumerable<Drawable> CreateSettingsControls(this object obj)
var dropdown = (Drawable)Activator.CreateInstance(dropdownType);
dropdownType.GetProperty(nameof(SettingsDropdown<object>.LabelText))?.SetValue(dropdown, attr.Label);
dropdownType.GetProperty(nameof(SettingsDropdown<object>.TooltipText))?.SetValue(dropdown, attr.Description);
dropdownType.GetProperty(nameof(SettingsDropdown<object>.Current))?.SetValue(dropdown, bindable);
yield return dropdown;

View File

@ -21,7 +21,7 @@
namespace osu.Game.Overlays.Settings
{
public abstract class SettingsItem<T> : Container, IFilterable, ISettingsItem, IHasCurrentValue<T>
public abstract class SettingsItem<T> : Container, IFilterable, ISettingsItem, IHasCurrentValue<T>, IHasTooltip
{
protected abstract Drawable CreateControl();
@ -37,6 +37,8 @@ public abstract class SettingsItem<T> : Container, IFilterable, ISettingsItem, I
public bool ShowsDefaultIndicator = true;
public string TooltipText { get; set; }
public virtual string LabelText
{
get => labelText?.Text ?? string.Empty;