From bf65547eec7419273bd106f30d4842dd19ea86fb Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 11 May 2021 12:04:25 +0900 Subject: [PATCH] Allow some serialised components to not be mutable by the user --- osu.Game/Screens/Play/HUD/SkinnableInfo.cs | 4 ++-- osu.Game/Skinning/IImmutableSkinnableComponent.cs | 15 +++++++++++++++ osu.Game/Skinning/ISkinnableComponent.cs | 4 +--- osu.Game/Skinning/Skin.cs | 5 +---- 4 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 osu.Game/Skinning/IImmutableSkinnableComponent.cs diff --git a/osu.Game/Screens/Play/HUD/SkinnableInfo.cs b/osu.Game/Screens/Play/HUD/SkinnableInfo.cs index abeb96f647..988d73fed6 100644 --- a/osu.Game/Screens/Play/HUD/SkinnableInfo.cs +++ b/osu.Game/Screens/Play/HUD/SkinnableInfo.cs @@ -14,7 +14,7 @@ using osuTK; namespace osu.Game.Screens.Play.HUD { /// - /// Serialised information governing custom changes to an . + /// Serialised information governing custom changes to an . /// [Serializable] public class SkinnableInfo : IJsonSerializable @@ -46,7 +46,7 @@ namespace osu.Game.Screens.Play.HUD if (component is Container container) { - foreach (var child in container.Children.OfType().OfType()) + foreach (var child in container.Children.OfType().OfType()) Children.Add(child.CreateSerialisedInformation()); } } diff --git a/osu.Game/Skinning/IImmutableSkinnableComponent.cs b/osu.Game/Skinning/IImmutableSkinnableComponent.cs new file mode 100644 index 0000000000..d1777512af --- /dev/null +++ b/osu.Game/Skinning/IImmutableSkinnableComponent.cs @@ -0,0 +1,15 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Graphics; + +namespace osu.Game.Skinning +{ + /// + /// Denotes a drawable component which should be serialised as part of a skin. + /// Use for components which should be mutable by the user / editor. + /// + public interface ISkinSerialisable : IDrawable + { + } +} diff --git a/osu.Game/Skinning/ISkinnableComponent.cs b/osu.Game/Skinning/ISkinnableComponent.cs index f6b0a182b4..e44c7be13d 100644 --- a/osu.Game/Skinning/ISkinnableComponent.cs +++ b/osu.Game/Skinning/ISkinnableComponent.cs @@ -1,14 +1,12 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using osu.Framework.Graphics; - namespace osu.Game.Skinning { /// /// Denotes a drawable which, as a drawable, can be adjusted via skinning specifications. /// - public interface ISkinnableComponent : IDrawable + public interface ISkinnableComponent : ISkinSerialisable { } } diff --git a/osu.Game/Skinning/Skin.cs b/osu.Game/Skinning/Skin.cs index 34571ec688..cbbad4a607 100644 --- a/osu.Game/Skinning/Skin.cs +++ b/osu.Game/Skinning/Skin.cs @@ -22,8 +22,6 @@ namespace osu.Game.Skinning { public readonly SkinInfo SkinInfo; - private readonly IStorageResourceProvider resources; - public SkinConfiguration Configuration { get; protected set; } public IDictionary DrawableComponentInfo => drawableComponentInfo; @@ -43,7 +41,6 @@ namespace osu.Game.Skinning SkinInfo = skin; // may be null for default skin. - this.resources = resources; // we may want to move this to some kind of async operation in the future. foreach (SkinnableTarget skinnableTarget in Enum.GetValues(typeof(SkinnableTarget))) @@ -124,7 +121,7 @@ namespace osu.Game.Skinning #endregion } - public class SkinnableTargetWrapper : Container, ISkinnableComponent + public class SkinnableTargetWrapper : Container, ISkinSerialisable { public SkinnableTargetWrapper() {