1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-13 05:22:54 +08:00

Rename ISkinnableDrawable to ISerialisableDrawable

This commit is contained in:
Dean Herbert 2023-02-15 16:01:26 +09:00
parent 8cb5a51aa7
commit d159d6b970
30 changed files with 67 additions and 63 deletions

View File

@ -74,7 +74,7 @@ namespace osu.Game.Tests.Skins
} }
} }
var editableTypes = SerialisedDrawableInfo.GetAllAvailableDrawables().Where(t => (Activator.CreateInstance(t) as ISkinnableDrawable)?.IsEditable == true); var editableTypes = SerialisedDrawableInfo.GetAllAvailableDrawables().Where(t => (Activator.CreateInstance(t) as ISerialisableDrawable)?.IsEditable == true);
Assert.That(instantiatedTypes, Is.EquivalentTo(editableTypes)); Assert.That(instantiatedTypes, Is.EquivalentTo(editableTypes));
} }

View File

@ -59,7 +59,7 @@ namespace osu.Game.Extensions
component.Anchor = drawableInfo.Anchor; component.Anchor = drawableInfo.Anchor;
component.Origin = drawableInfo.Origin; component.Origin = drawableInfo.Origin;
if (component is ISkinnableDrawable skinnable) if (component is ISerialisableDrawable skinnable)
{ {
skinnable.UsesFixedAnchor = drawableInfo.UsesFixedAnchor; skinnable.UsesFixedAnchor = drawableInfo.UsesFixedAnchor;

View File

@ -17,7 +17,7 @@ using osuTK.Graphics;
namespace osu.Game.Overlays.SkinEditor namespace osu.Game.Overlays.SkinEditor
{ {
public partial class SkinBlueprint : SelectionBlueprint<ISkinnableDrawable> public partial class SkinBlueprint : SelectionBlueprint<ISerialisableDrawable>
{ {
private Container box = null!; private Container box = null!;
@ -32,7 +32,7 @@ namespace osu.Game.Overlays.SkinEditor
[Resolved] [Resolved]
private OsuColour colours { get; set; } = null!; private OsuColour colours { get; set; } = null!;
public SkinBlueprint(ISkinnableDrawable component) public SkinBlueprint(ISerialisableDrawable component)
: base(component) : base(component)
{ {
} }

View File

@ -24,11 +24,11 @@ using osuTK.Input;
namespace osu.Game.Overlays.SkinEditor namespace osu.Game.Overlays.SkinEditor
{ {
public partial class SkinBlueprintContainer : BlueprintContainer<ISkinnableDrawable> public partial class SkinBlueprintContainer : BlueprintContainer<ISerialisableDrawable>
{ {
private readonly Drawable target; private readonly Drawable target;
private readonly List<BindableList<ISkinnableDrawable>> targetComponents = new List<BindableList<ISkinnableDrawable>>(); private readonly List<BindableList<ISerialisableDrawable>> targetComponents = new List<BindableList<ISerialisableDrawable>>();
[Resolved] [Resolved]
private SkinEditor editor { get; set; } = null!; private SkinEditor editor { get; set; } = null!;
@ -55,7 +55,7 @@ namespace osu.Game.Overlays.SkinEditor
foreach (var targetContainer in targetContainers) foreach (var targetContainer in targetContainers)
{ {
var bindableList = new BindableList<ISkinnableDrawable> { BindTarget = targetContainer.Components }; var bindableList = new BindableList<ISerialisableDrawable> { BindTarget = targetContainer.Components };
bindableList.BindCollectionChanged(componentsChanged, true); bindableList.BindCollectionChanged(componentsChanged, true);
targetComponents.Add(bindableList); targetComponents.Add(bindableList);
@ -69,7 +69,7 @@ namespace osu.Game.Overlays.SkinEditor
case NotifyCollectionChangedAction.Add: case NotifyCollectionChangedAction.Add:
Debug.Assert(e.NewItems != null); Debug.Assert(e.NewItems != null);
foreach (var item in e.NewItems.Cast<ISkinnableDrawable>()) foreach (var item in e.NewItems.Cast<ISerialisableDrawable>())
AddBlueprintFor(item); AddBlueprintFor(item);
break; break;
@ -77,7 +77,7 @@ namespace osu.Game.Overlays.SkinEditor
case NotifyCollectionChangedAction.Reset: case NotifyCollectionChangedAction.Reset:
Debug.Assert(e.OldItems != null); Debug.Assert(e.OldItems != null);
foreach (var item in e.OldItems.Cast<ISkinnableDrawable>()) foreach (var item in e.OldItems.Cast<ISerialisableDrawable>())
RemoveBlueprintFor(item); RemoveBlueprintFor(item);
break; break;
@ -85,16 +85,16 @@ namespace osu.Game.Overlays.SkinEditor
Debug.Assert(e.NewItems != null); Debug.Assert(e.NewItems != null);
Debug.Assert(e.OldItems != null); Debug.Assert(e.OldItems != null);
foreach (var item in e.OldItems.Cast<ISkinnableDrawable>()) foreach (var item in e.OldItems.Cast<ISerialisableDrawable>())
RemoveBlueprintFor(item); RemoveBlueprintFor(item);
foreach (var item in e.NewItems.Cast<ISkinnableDrawable>()) foreach (var item in e.NewItems.Cast<ISerialisableDrawable>())
AddBlueprintFor(item); AddBlueprintFor(item);
break; break;
} }
}); });
protected override void AddBlueprintFor(ISkinnableDrawable item) protected override void AddBlueprintFor(ISerialisableDrawable item)
{ {
if (!item.IsEditable) if (!item.IsEditable)
return; return;
@ -145,12 +145,12 @@ namespace osu.Game.Overlays.SkinEditor
// convert to game space coordinates // convert to game space coordinates
delta = firstBlueprint.ToScreenSpace(delta) - firstBlueprint.ToScreenSpace(Vector2.Zero); delta = firstBlueprint.ToScreenSpace(delta) - firstBlueprint.ToScreenSpace(Vector2.Zero);
SelectionHandler.HandleMovement(new MoveSelectionEvent<ISkinnableDrawable>(firstBlueprint, delta)); SelectionHandler.HandleMovement(new MoveSelectionEvent<ISerialisableDrawable>(firstBlueprint, delta));
} }
protected override SelectionHandler<ISkinnableDrawable> CreateSelectionHandler() => new SkinSelectionHandler(); protected override SelectionHandler<ISerialisableDrawable> CreateSelectionHandler() => new SkinSelectionHandler();
protected override SelectionBlueprint<ISkinnableDrawable> CreateBlueprintFor(ISkinnableDrawable component) protected override SelectionBlueprint<ISerialisableDrawable> CreateBlueprintFor(ISerialisableDrawable component)
=> new SkinBlueprint(component); => new SkinBlueprint(component);
protected override void Dispose(bool isDisposing) protected override void Dispose(bool isDisposing)

View File

@ -60,7 +60,7 @@ namespace osu.Game.Overlays.SkinEditor
{ {
Drawable instance = (Drawable)Activator.CreateInstance(type)!; Drawable instance = (Drawable)Activator.CreateInstance(type)!;
if (!((ISkinnableDrawable)instance).IsEditable) return; if (!((ISerialisableDrawable)instance).IsEditable) return;
fill.Add(new ToolboxComponentButton(instance, target) fill.Add(new ToolboxComponentButton(instance, target)
{ {

View File

@ -38,7 +38,7 @@ namespace osu.Game.Overlays.SkinEditor
public const float MENU_HEIGHT = 40; public const float MENU_HEIGHT = 40;
public readonly BindableList<ISkinnableDrawable> SelectedComponents = new BindableList<ISkinnableDrawable>(); public readonly BindableList<ISerialisableDrawable> SelectedComponents = new BindableList<ISerialisableDrawable>();
protected override bool StartHidden => true; protected override bool StartHidden => true;
@ -302,13 +302,13 @@ namespace osu.Game.Overlays.SkinEditor
private void placeComponent(Type type) private void placeComponent(Type type)
{ {
if (!(Activator.CreateInstance(type) is ISkinnableDrawable component)) if (!(Activator.CreateInstance(type) is ISerialisableDrawable component))
throw new InvalidOperationException($"Attempted to instantiate a component for placement which was not an {typeof(ISkinnableDrawable)}."); throw new InvalidOperationException($"Attempted to instantiate a component for placement which was not an {typeof(ISerialisableDrawable)}.");
placeComponent(component); placeComponent(component);
} }
private void placeComponent(ISkinnableDrawable component, bool applyDefaults = true) private void placeComponent(ISerialisableDrawable component, bool applyDefaults = true)
{ {
var targetContainer = getFirstTarget(); var targetContainer = getFirstTarget();
@ -400,7 +400,7 @@ namespace osu.Game.Overlays.SkinEditor
this.FadeOut(TRANSITION_DURATION, Easing.OutQuint); this.FadeOut(TRANSITION_DURATION, Easing.OutQuint);
} }
public void DeleteItems(ISkinnableDrawable[] items) public void DeleteItems(ISerialisableDrawable[] items)
{ {
foreach (var item in items) foreach (var item in items)
availableTargets.FirstOrDefault(t => t.Components.Contains(item))?.Remove(item); availableTargets.FirstOrDefault(t => t.Components.Contains(item))?.Remove(item);

View File

@ -20,7 +20,7 @@ namespace osu.Game.Overlays.SkinEditor
private readonly ISkinnableTarget? firstTarget; private readonly ISkinnableTarget? firstTarget;
// ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable // ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable
private readonly BindableList<ISkinnableDrawable>? components; private readonly BindableList<ISerialisableDrawable>? components;
public SkinEditorChangeHandler(Drawable targetScreen) public SkinEditorChangeHandler(Drawable targetScreen)
{ {
@ -33,7 +33,7 @@ namespace osu.Game.Overlays.SkinEditor
if (firstTarget == null) if (firstTarget == null)
return; return;
components = new BindableList<ISkinnableDrawable> { BindTarget = firstTarget.Components }; components = new BindableList<ISerialisableDrawable> { BindTarget = firstTarget.Components };
components.BindCollectionChanged((_, _) => SaveState()); components.BindCollectionChanged((_, _) => SaveState());
} }

View File

@ -19,7 +19,7 @@ using osuTK;
namespace osu.Game.Overlays.SkinEditor namespace osu.Game.Overlays.SkinEditor
{ {
public partial class SkinSelectionHandler : SelectionHandler<ISkinnableDrawable> public partial class SkinSelectionHandler : SelectionHandler<ISerialisableDrawable>
{ {
[Resolved] [Resolved]
private SkinEditor skinEditor { get; set; } = null!; private SkinEditor skinEditor { get; set; } = null!;
@ -147,7 +147,7 @@ namespace osu.Game.Overlays.SkinEditor
return true; return true;
} }
public override bool HandleMovement(MoveSelectionEvent<ISkinnableDrawable> moveEvent) public override bool HandleMovement(MoveSelectionEvent<ISerialisableDrawable> moveEvent)
{ {
foreach (var c in SelectedBlueprints) foreach (var c in SelectedBlueprints)
{ {
@ -178,10 +178,10 @@ namespace osu.Game.Overlays.SkinEditor
SelectionBox.CanReverse = false; SelectionBox.CanReverse = false;
} }
protected override void DeleteItems(IEnumerable<ISkinnableDrawable> items) => protected override void DeleteItems(IEnumerable<ISerialisableDrawable> items) =>
skinEditor.DeleteItems(items.ToArray()); skinEditor.DeleteItems(items.ToArray());
protected override IEnumerable<MenuItem> GetContextMenuItemsForSelection(IEnumerable<SelectionBlueprint<ISkinnableDrawable>> selection) protected override IEnumerable<MenuItem> GetContextMenuItemsForSelection(IEnumerable<SelectionBlueprint<ISerialisableDrawable>> selection)
{ {
var closestItem = new TernaryStateRadioMenuItem("Closest", MenuItemType.Standard, _ => applyClosestAnchors()) var closestItem = new TernaryStateRadioMenuItem("Closest", MenuItemType.Standard, _ => applyClosestAnchors())
{ {
@ -209,7 +209,7 @@ namespace osu.Game.Overlays.SkinEditor
foreach (var item in base.GetContextMenuItemsForSelection(selection)) foreach (var item in base.GetContextMenuItemsForSelection(selection))
yield return item; yield return item;
IEnumerable<TernaryStateMenuItem> createAnchorItems(Func<ISkinnableDrawable, Anchor, bool> checkFunction, Action<Anchor> applyFunction) IEnumerable<TernaryStateMenuItem> createAnchorItems(Func<ISerialisableDrawable, Anchor, bool> checkFunction, Action<Anchor> applyFunction)
{ {
var displayableAnchors = new[] var displayableAnchors = new[]
{ {

View File

@ -16,7 +16,7 @@ using osuTK;
namespace osu.Game.Screens.Play.HUD namespace osu.Game.Screens.Play.HUD
{ {
public partial class BPMCounter : RollingCounter<double>, ISkinnableDrawable public partial class BPMCounter : RollingCounter<double>, ISerialisableDrawable
{ {
protected override double RollingDuration => 750; protected override double RollingDuration => 750;

View File

@ -14,7 +14,7 @@ using osuTK;
namespace osu.Game.Screens.Play.HUD.ClicksPerSecond namespace osu.Game.Screens.Play.HUD.ClicksPerSecond
{ {
public partial class ClicksPerSecondCounter : RollingCounter<int>, ISkinnableDrawable public partial class ClicksPerSecondCounter : RollingCounter<int>, ISerialisableDrawable
{ {
[Resolved] [Resolved]
private ClicksPerSecondCalculator calculator { get; set; } = null!; private ClicksPerSecondCalculator calculator { get; set; } = null!;

View File

@ -7,7 +7,7 @@ using osu.Game.Skinning;
namespace osu.Game.Screens.Play.HUD namespace osu.Game.Screens.Play.HUD
{ {
public abstract partial class ComboCounter : RollingCounter<int>, ISkinnableDrawable public abstract partial class ComboCounter : RollingCounter<int>, ISerialisableDrawable
{ {
public bool UsesFixedAnchor { get; set; } public bool UsesFixedAnchor { get; set; }

View File

@ -9,7 +9,7 @@ using osu.Game.Skinning;
namespace osu.Game.Screens.Play.HUD namespace osu.Game.Screens.Play.HUD
{ {
public partial class DefaultAccuracyCounter : GameplayAccuracyCounter, ISkinnableDrawable public partial class DefaultAccuracyCounter : GameplayAccuracyCounter, ISerialisableDrawable
{ {
public bool UsesFixedAnchor { get; set; } public bool UsesFixedAnchor { get; set; }

View File

@ -19,7 +19,7 @@ using osu.Game.Skinning;
namespace osu.Game.Screens.Play.HUD namespace osu.Game.Screens.Play.HUD
{ {
public partial class DefaultHealthDisplay : HealthDisplay, IHasAccentColour, ISkinnableDrawable public partial class DefaultHealthDisplay : HealthDisplay, IHasAccentColour, ISerialisableDrawable
{ {
/// <summary> /// <summary>
/// The base opacity of the glow. /// The base opacity of the glow.

View File

@ -10,7 +10,7 @@ using osu.Game.Skinning;
namespace osu.Game.Screens.Play.HUD namespace osu.Game.Screens.Play.HUD
{ {
public partial class DefaultScoreCounter : GameplayScoreCounter, ISkinnableDrawable public partial class DefaultScoreCounter : GameplayScoreCounter, ISerialisableDrawable
{ {
public DefaultScoreCounter() public DefaultScoreCounter()
{ {

View File

@ -14,7 +14,7 @@ using osuTK.Graphics;
namespace osu.Game.Screens.Play.HUD.HitErrorMeters namespace osu.Game.Screens.Play.HUD.HitErrorMeters
{ {
public abstract partial class HitErrorMeter : CompositeDrawable, ISkinnableDrawable public abstract partial class HitErrorMeter : CompositeDrawable, ISerialisableDrawable
{ {
protected HitWindows HitWindows { get; private set; } protected HitWindows HitWindows { get; private set; }

View File

@ -15,7 +15,7 @@ using osuTK;
namespace osu.Game.Screens.Play.HUD.JudgementCounter namespace osu.Game.Screens.Play.HUD.JudgementCounter
{ {
public partial class JudgementCounterDisplay : CompositeDrawable, ISkinnableDrawable public partial class JudgementCounterDisplay : CompositeDrawable, ISerialisableDrawable
{ {
public const int TRANSFORM_DURATION = 250; public const int TRANSFORM_DURATION = 250;

View File

@ -35,7 +35,7 @@ using osuTK;
namespace osu.Game.Screens.Play.HUD namespace osu.Game.Screens.Play.HUD
{ {
public partial class PerformancePointsCounter : RollingCounter<int>, ISkinnableDrawable public partial class PerformancePointsCounter : RollingCounter<int>, ISerialisableDrawable
{ {
public bool UsesFixedAnchor { get; set; } public bool UsesFixedAnchor { get; set; }

View File

@ -14,7 +14,7 @@ using osu.Game.Skinning;
namespace osu.Game.Screens.Play.HUD namespace osu.Game.Screens.Play.HUD
{ {
public abstract partial class SongProgress : OverlayContainer, ISkinnableDrawable public abstract partial class SongProgress : OverlayContainer, ISerialisableDrawable
{ {
// Some implementations of this element allow seeking during gameplay playback. // Some implementations of this element allow seeking during gameplay playback.
// Set a sane default of never handling input to override the behaviour provided by OverlayContainer. // Set a sane default of never handling input to override the behaviour provided by OverlayContainer.

View File

@ -20,7 +20,7 @@ using osuTK;
namespace osu.Game.Screens.Play.HUD namespace osu.Game.Screens.Play.HUD
{ {
public partial class UnstableRateCounter : RollingCounter<int>, ISkinnableDrawable public partial class UnstableRateCounter : RollingCounter<int>, ISerialisableDrawable
{ {
public bool UsesFixedAnchor { get; set; } public bool UsesFixedAnchor { get; set; }

View File

@ -19,7 +19,7 @@ namespace osu.Game.Skinning.Components
/// Intended to be a test bed for skinning. May be removed at some point in the future. /// Intended to be a test bed for skinning. May be removed at some point in the future.
/// </summary> /// </summary>
[UsedImplicitly] [UsedImplicitly]
public partial class BigBlackBox : CompositeDrawable, ISkinnableDrawable public partial class BigBlackBox : CompositeDrawable, ISerialisableDrawable
{ {
public bool UsesFixedAnchor { get; set; } public bool UsesFixedAnchor { get; set; }

View File

@ -13,7 +13,7 @@ namespace osu.Game.Skinning
/// <summary> /// <summary>
/// A skin component that contains text and allows the user to choose its font. /// A skin component that contains text and allows the user to choose its font.
/// </summary> /// </summary>
public abstract partial class FontAdjustableSkinComponent : Container, ISkinnableDrawable public abstract partial class FontAdjustableSkinComponent : Container, ISerialisableDrawable
{ {
public bool UsesFixedAnchor { get; set; } public bool UsesFixedAnchor { get; set; }

View File

@ -18,7 +18,7 @@ namespace osu.Game.Skinning
/// ///
/// Serialisation is done via <see cref="SerialisedDrawableInfo"/> using <see cref="osu.Game.Extensions.DrawableExtensions.CreateSerialisedInfo"/>. /// Serialisation is done via <see cref="SerialisedDrawableInfo"/> using <see cref="osu.Game.Extensions.DrawableExtensions.CreateSerialisedInfo"/>.
/// </remarks> /// </remarks>
public interface ISkinnableDrawable : IDrawable public interface ISerialisableDrawable : IDrawable
{ {
/// <summary> /// <summary>
/// Whether this component should be editable by an end user. /// Whether this component should be editable by an end user.
@ -26,8 +26,8 @@ namespace osu.Game.Skinning
bool IsEditable => true; bool IsEditable => true;
/// <summary> /// <summary>
/// In the context of the skin layout editor, whether this <see cref="ISkinnableDrawable"/> has a permanent anchor defined. /// In the context of the skin layout editor, whether this <see cref="ISerialisableDrawable"/> has a permanent anchor defined.
/// If <see langword="false"/>, this <see cref="ISkinnableDrawable"/>'s <see cref="Drawable.Anchor"/> is automatically determined by proximity, /// If <see langword="false"/>, this <see cref="ISerialisableDrawable"/>'s <see cref="Drawable.Anchor"/> is automatically determined by proximity,
/// If <see langword="true"/>, a fixed anchor point has been defined. /// If <see langword="true"/>, a fixed anchor point has been defined.
/// </summary> /// </summary>
bool UsesFixedAnchor { get; set; } bool UsesFixedAnchor { get; set; }

View File

@ -10,7 +10,7 @@ using osu.Game.Extensions;
namespace osu.Game.Skinning namespace osu.Game.Skinning
{ {
/// <summary> /// <summary>
/// Denotes a container which can house <see cref="ISkinnableDrawable"/>s. /// Denotes a container which can house <see cref="ISerialisableDrawable"/>s.
/// </summary> /// </summary>
public interface ISkinnableTarget : IDrawable public interface ISkinnableTarget : IDrawable
{ {
@ -22,7 +22,7 @@ namespace osu.Game.Skinning
/// <summary> /// <summary>
/// A bindable list of components which are being tracked by this skinnable target. /// A bindable list of components which are being tracked by this skinnable target.
/// </summary> /// </summary>
IBindableList<ISkinnableDrawable> Components { get; } IBindableList<ISerialisableDrawable> Components { get; }
/// <summary> /// <summary>
/// Serialise all children as <see cref="SerialisedDrawableInfo"/>. /// Serialise all children as <see cref="SerialisedDrawableInfo"/>.
@ -44,12 +44,12 @@ namespace osu.Game.Skinning
/// Add a new skinnable component to this target. /// Add a new skinnable component to this target.
/// </summary> /// </summary>
/// <param name="drawable">The component to add.</param> /// <param name="drawable">The component to add.</param>
void Add(ISkinnableDrawable drawable); void Add(ISerialisableDrawable drawable);
/// <summary> /// <summary>
/// Remove an existing skinnable component from this target. /// Remove an existing skinnable component from this target.
/// </summary> /// </summary>
/// <param name="component">The component to remove.</param> /// <param name="component">The component to remove.</param>
void Remove(ISkinnableDrawable component); void Remove(ISerialisableDrawable component);
} }
} }

View File

@ -8,7 +8,7 @@ using osuTK;
namespace osu.Game.Skinning namespace osu.Game.Skinning
{ {
public partial class LegacyAccuracyCounter : GameplayAccuracyCounter, ISkinnableDrawable public partial class LegacyAccuracyCounter : GameplayAccuracyCounter, ISerialisableDrawable
{ {
public bool UsesFixedAnchor { get; set; } public bool UsesFixedAnchor { get; set; }

View File

@ -14,7 +14,7 @@ namespace osu.Game.Skinning
/// <summary> /// <summary>
/// Uses the 'x' symbol and has a pop-out effect while rolling over. /// Uses the 'x' symbol and has a pop-out effect while rolling over.
/// </summary> /// </summary>
public partial class LegacyComboCounter : CompositeDrawable, ISkinnableDrawable public partial class LegacyComboCounter : CompositeDrawable, ISerialisableDrawable
{ {
public Bindable<int> Current { get; } = new BindableInt { MinValue = 0 }; public Bindable<int> Current { get; } = new BindableInt { MinValue = 0 };

View File

@ -19,7 +19,7 @@ using osuTK.Graphics;
namespace osu.Game.Skinning namespace osu.Game.Skinning
{ {
public partial class LegacyHealthDisplay : HealthDisplay, ISkinnableDrawable public partial class LegacyHealthDisplay : HealthDisplay, ISerialisableDrawable
{ {
private const double epic_cutoff = 0.5; private const double epic_cutoff = 0.5;

View File

@ -8,7 +8,7 @@ using osuTK;
namespace osu.Game.Skinning namespace osu.Game.Skinning
{ {
public partial class LegacyScoreCounter : GameplayScoreCounter, ISkinnableDrawable public partial class LegacyScoreCounter : GameplayScoreCounter, ISerialisableDrawable
{ {
protected override double RollingDuration => 1000; protected override double RollingDuration => 1000;
protected override Easing RollingEasing => Easing.Out; protected override Easing RollingEasing => Easing.Out;

View File

@ -18,9 +18,13 @@ using osuTK;
namespace osu.Game.Skinning namespace osu.Game.Skinning
{ {
/// <summary> /// <summary>
/// Serialised backing data for <see cref="ISkinnableDrawable"/>s. /// Serialised backing data for <see cref="ISerialisableDrawable"/>s.
/// Used for json serialisation in user skins. /// Used for json serialisation in user skins.
/// </summary> /// </summary>
/// <remarks>
/// Can be created using <see cref="SerialisableDrawableExtensions.CreateSerialisedInfo"/>.
/// Can also be applied to an existing drawable using <see cref="SerialisableDrawableExtensions.ApplySerialisedInfo"/>.
/// </remarks>
[Serializable] [Serializable]
public sealed class SerialisedDrawableInfo public sealed class SerialisedDrawableInfo
{ {
@ -36,7 +40,7 @@ namespace osu.Game.Skinning
public Anchor Origin { get; set; } public Anchor Origin { get; set; }
/// <inheritdoc cref="ISkinnableDrawable.UsesFixedAnchor"/> /// <inheritdoc cref="ISerialisableDrawable.UsesFixedAnchor"/>
public bool UsesFixedAnchor { get; set; } public bool UsesFixedAnchor { get; set; }
public Dictionary<string, object> Settings { get; set; } = new Dictionary<string, object>(); public Dictionary<string, object> Settings { get; set; } = new Dictionary<string, object>();
@ -62,7 +66,7 @@ namespace osu.Game.Skinning
Anchor = component.Anchor; Anchor = component.Anchor;
Origin = component.Origin; Origin = component.Origin;
if (component is ISkinnableDrawable skinnable) if (component is ISerialisableDrawable skinnable)
UsesFixedAnchor = skinnable.UsesFixedAnchor; UsesFixedAnchor = skinnable.UsesFixedAnchor;
foreach (var (_, property) in component.GetSettingsSourceProperties()) foreach (var (_, property) in component.GetSettingsSourceProperties())
@ -74,7 +78,7 @@ namespace osu.Game.Skinning
if (component is Container<Drawable> container) if (component is Container<Drawable> container)
{ {
foreach (var child in container.OfType<ISkinnableDrawable>().OfType<Drawable>()) foreach (var child in container.OfType<ISerialisableDrawable>().OfType<Drawable>())
Children.Add(child.CreateSerialisedInfo()); Children.Add(child.CreateSerialisedInfo());
} }
} }
@ -102,7 +106,7 @@ namespace osu.Game.Skinning
{ {
return typeof(OsuGame).Assembly.GetTypes() return typeof(OsuGame).Assembly.GetTypes()
.Where(t => !t.IsInterface && !t.IsAbstract) .Where(t => !t.IsInterface && !t.IsAbstract)
.Where(t => typeof(ISkinnableDrawable).IsAssignableFrom(t)) .Where(t => typeof(ISerialisableDrawable).IsAssignableFrom(t))
.OrderBy(t => t.Name) .OrderBy(t => t.Name)
.ToArray(); .ToArray();
} }

View File

@ -21,7 +21,7 @@ namespace osu.Game.Skinning
/// <summary> /// <summary>
/// A skinnable element which uses a single texture backing. /// A skinnable element which uses a single texture backing.
/// </summary> /// </summary>
public partial class SkinnableSprite : SkinnableDrawable, ISkinnableDrawable public partial class SkinnableSprite : SkinnableDrawable, ISerialisableDrawable
{ {
protected override bool ApplySizeRestrictionsToDefault => true; protected override bool ApplySizeRestrictionsToDefault => true;

View File

@ -18,9 +18,9 @@ namespace osu.Game.Skinning
public GlobalSkinComponentLookup.LookupType Target { get; } public GlobalSkinComponentLookup.LookupType Target { get; }
public IBindableList<ISkinnableDrawable> Components => components; public IBindableList<ISerialisableDrawable> Components => components;
private readonly BindableList<ISkinnableDrawable> components = new BindableList<ISkinnableDrawable>(); private readonly BindableList<ISerialisableDrawable> components = new BindableList<ISerialisableDrawable>();
public override bool IsPresent => base.IsPresent || Scheduler.HasPendingTasks; // ensure that components are loaded even if the target container is hidden (ie. due to user toggle). public override bool IsPresent => base.IsPresent || Scheduler.HasPendingTasks; // ensure that components are loaded even if the target container is hidden (ie. due to user toggle).
@ -68,7 +68,7 @@ namespace osu.Game.Skinning
LoadComponentAsync(content, wrapper => LoadComponentAsync(content, wrapper =>
{ {
AddInternal(wrapper); AddInternal(wrapper);
components.AddRange(wrapper.Children.OfType<ISkinnableDrawable>()); components.AddRange(wrapper.Children.OfType<ISerialisableDrawable>());
ComponentsLoaded = true; ComponentsLoaded = true;
}, (cancellationSource = new CancellationTokenSource()).Token); }, (cancellationSource = new CancellationTokenSource()).Token);
} }
@ -79,7 +79,7 @@ namespace osu.Game.Skinning
/// <inheritdoc cref="ISkinnableTarget"/> /// <inheritdoc cref="ISkinnableTarget"/>
/// <exception cref="NotSupportedException">Thrown when attempting to add an element to a target which is not supported by the current skin.</exception> /// <exception cref="NotSupportedException">Thrown when attempting to add an element to a target which is not supported by the current skin.</exception>
/// <exception cref="ArgumentException">Thrown if the provided instance is not a <see cref="Drawable"/>.</exception> /// <exception cref="ArgumentException">Thrown if the provided instance is not a <see cref="Drawable"/>.</exception>
public void Add(ISkinnableDrawable component) public void Add(ISerialisableDrawable component)
{ {
if (content == null) if (content == null)
throw new NotSupportedException("Attempting to add a new component to a target container which is not supported by the current skin."); throw new NotSupportedException("Attempting to add a new component to a target container which is not supported by the current skin.");
@ -94,7 +94,7 @@ namespace osu.Game.Skinning
/// <inheritdoc cref="ISkinnableTarget"/> /// <inheritdoc cref="ISkinnableTarget"/>
/// <exception cref="NotSupportedException">Thrown when attempting to add an element to a target which is not supported by the current skin.</exception> /// <exception cref="NotSupportedException">Thrown when attempting to add an element to a target which is not supported by the current skin.</exception>
/// <exception cref="ArgumentException">Thrown if the provided instance is not a <see cref="Drawable"/>.</exception> /// <exception cref="ArgumentException">Thrown if the provided instance is not a <see cref="Drawable"/>.</exception>
public void Remove(ISkinnableDrawable component) public void Remove(ISerialisableDrawable component)
{ {
if (content == null) if (content == null)
throw new NotSupportedException("Attempting to remove a new component from a target container which is not supported by the current skin."); throw new NotSupportedException("Attempting to remove a new component from a target container which is not supported by the current skin.");