mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 11:37:28 +08:00
Add the ability to not get controls for disabled bindables
This commit is contained in:
parent
3c21c83cc8
commit
8635abbc4a
@ -63,16 +63,21 @@ namespace osu.Game.Configuration
|
||||
|
||||
public static class SettingSourceExtensions
|
||||
{
|
||||
public static IEnumerable<Drawable> CreateSettingsControls(this object obj) => createSettingsControls(obj, obj.GetOrderedSettingsSourceProperties());
|
||||
public static IReadOnlyList<Drawable> CreateSettingsControls(this object obj, bool includeDisabled = true) =>
|
||||
createSettingsControls(obj, obj.GetOrderedSettingsSourceProperties(), includeDisabled).ToArray();
|
||||
|
||||
public static IEnumerable<Drawable> CreateSettingsControlsFromAllBindables(this object obj) => createSettingsControls(obj, obj.GetSettingsSourcePropertiesFromBindables());
|
||||
public static IReadOnlyList<Drawable> CreateSettingsControlsFromAllBindables(this object obj, bool includeDisabled = true) =>
|
||||
createSettingsControls(obj, obj.GetSettingsSourcePropertiesFromBindables(), includeDisabled).ToArray();
|
||||
|
||||
private static IEnumerable<Drawable> createSettingsControls(object obj, IEnumerable<(SettingSourceAttribute, PropertyInfo)> sourceAttribs)
|
||||
private static IEnumerable<Drawable> createSettingsControls(object obj, IEnumerable<(SettingSourceAttribute, PropertyInfo)> sourceAttribs, bool includeDisabled = true)
|
||||
{
|
||||
foreach (var (attr, property) in sourceAttribs)
|
||||
{
|
||||
object value = property.GetValue(obj);
|
||||
|
||||
if ((value as IBindable)?.Disabled == true)
|
||||
continue;
|
||||
|
||||
switch (value)
|
||||
{
|
||||
case BindableNumber<float> bNumber:
|
||||
|
Loading…
Reference in New Issue
Block a user