1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 17:43:05 +08:00

Fix new SettingsItem attribute not playing well with non-Drawables

This commit is contained in:
Dean Herbert 2022-04-01 16:00:51 +09:00
parent bfd3406f5f
commit 6afed5e865
3 changed files with 3 additions and 3 deletions

View File

@ -88,7 +88,7 @@ namespace osu.Game.Configuration
throw new InvalidOperationException($"{nameof(SettingSourceAttribute)} had an unsupported custom control type ({controlType.ReadableName()})"); throw new InvalidOperationException($"{nameof(SettingSourceAttribute)} had an unsupported custom control type ({controlType.ReadableName()})");
var control = (Drawable)Activator.CreateInstance(controlType); var control = (Drawable)Activator.CreateInstance(controlType);
controlType.GetProperty(nameof(SettingsItem<object>.Source))?.SetValue(control, obj); controlType.GetProperty(nameof(SettingsItem<object>.SettingSourceObject))?.SetValue(control, obj);
controlType.GetProperty(nameof(SettingsItem<object>.LabelText))?.SetValue(control, attr.Label); controlType.GetProperty(nameof(SettingsItem<object>.LabelText))?.SetValue(control, attr.Label);
controlType.GetProperty(nameof(SettingsItem<object>.TooltipText))?.SetValue(control, attr.Description); controlType.GetProperty(nameof(SettingsItem<object>.TooltipText))?.SetValue(control, attr.Description);
controlType.GetProperty(nameof(SettingsItem<object>.Current))?.SetValue(control, value); controlType.GetProperty(nameof(SettingsItem<object>.Current))?.SetValue(control, value);

View File

@ -28,7 +28,7 @@ namespace osu.Game.Overlays.Settings
/// <summary> /// <summary>
/// The source component if this <see cref="SettingsItem{T}"/> was created via <see cref="SettingSourceAttribute"/>. /// The source component if this <see cref="SettingsItem{T}"/> was created via <see cref="SettingSourceAttribute"/>.
/// </summary> /// </summary>
public Drawable Source { get; internal set; } public object SettingSourceObject { get; internal set; }
private IHasCurrentValue<T> controlWithCurrent => Control as IHasCurrentValue<T>; private IHasCurrentValue<T> controlWithCurrent => Control as IHasCurrentValue<T>;

View File

@ -87,7 +87,7 @@ namespace osu.Game.Skinning
// Round-about way of getting the user's skin to find available resources. // Round-about way of getting the user's skin to find available resources.
// In the future we'll probably want to allow access to resources from the fallbacks, or potentially other skins // In the future we'll probably want to allow access to resources from the fallbacks, or potentially other skins
// but that requires further thought. // but that requires further thought.
var highestPrioritySkin = ((SkinnableSprite)Source).source.AllSources.First() as Skin; var highestPrioritySkin = ((SkinnableSprite)SettingSourceObject).source.AllSources.First() as Skin;
string[] availableFiles = highestPrioritySkin?.SkinInfo.PerformRead(s => s.Files string[] availableFiles = highestPrioritySkin?.SkinInfo.PerformRead(s => s.Files
.Where(f => f.Filename.EndsWith(".png", StringComparison.Ordinal) .Where(f => f.Filename.EndsWith(".png", StringComparison.Ordinal)