1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 21:52:55 +08:00

Add the ability for settings items to have tooltips

This commit is contained in:
Dean Herbert 2021-02-11 16:38:17 +09:00
parent 3344e9f27f
commit dddd776802
2 changed files with 9 additions and 1 deletions

View File

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

View File

@ -21,7 +21,7 @@ using osuTK;
namespace osu.Game.Overlays.Settings 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(); protected abstract Drawable CreateControl();
@ -214,5 +214,7 @@ namespace osu.Game.Overlays.Settings
this.FadeColour(bindable.Disabled ? Color4.Gray : buttonColour, 200, Easing.OutQuint); this.FadeColour(bindable.Disabled ? Color4.Gray : buttonColour, 200, Easing.OutQuint);
} }
} }
public string TooltipText { get; set; }
} }
} }