diff --git a/osu.Game/Skinning/SkinComponentsContainer.cs b/osu.Game/Skinning/SkinComponentsContainer.cs index 19c16d2177..adf0a288b4 100644 --- a/osu.Game/Skinning/SkinComponentsContainer.cs +++ b/osu.Game/Skinning/SkinComponentsContainer.cs @@ -6,10 +6,8 @@ using System.Linq; using System.Threading; using osu.Framework.Bindables; -using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Game.Rulesets.UI; namespace osu.Game.Skinning { @@ -41,8 +39,6 @@ public partial class SkinComponentsContainer : SkinReloadableDrawable, ISerialis private CancellationTokenSource? cancellationSource; - private ICanAttachHUDPieces? attachTarget; - public SkinComponentsContainer(SkinComponentsContainerLookup lookup) { Lookup = lookup; @@ -66,10 +62,6 @@ public void Reload(SerialisedDrawableInfo[] skinnableInfo) public void Reload(Container? componentsContainer) { - components - .OfType() - .ForEach(c => attachTarget?.Detach(c)); - ClearInternal(); components.Clear(); ComponentsLoaded = false; @@ -85,7 +77,6 @@ public void Reload(Container? componentsContainer) LoadComponentAsync(content, wrapper => { AddInternal(wrapper); - wrapper.Children.OfType().ForEach(c => attachTarget?.Attach(c)); components.AddRange(wrapper.Children.OfType()); ComponentsLoaded = true; }, (cancellationSource = new CancellationTokenSource()).Token); @@ -102,9 +93,6 @@ public void Add(ISerialisableDrawable component) if (!(component is Drawable drawable)) throw new ArgumentException($"Provided argument must be of type {nameof(Drawable)}.", nameof(component)); - if (component is IAttachableSkinComponent attachableSkinComponent) - attachTarget?.Attach(attachableSkinComponent); - content.Add(drawable); components.Add(component); } @@ -120,24 +108,10 @@ public void Remove(ISerialisableDrawable component, bool disposeImmediately) if (!(component is Drawable drawable)) throw new ArgumentException($"Provided argument must be of type {nameof(Drawable)}.", nameof(component)); - if (component is IAttachableSkinComponent attachableSkinComponent) - attachTarget?.Detach(attachableSkinComponent); - content.Remove(drawable, disposeImmediately); components.Remove(component); } - public void SetAttachTarget(ICanAttachHUDPieces target) - { - attachTarget = target; - - foreach (var child in InternalChildren) - { - if (child is IAttachableSkinComponent attachable) - attachTarget.Attach(attachable); - } - } - protected override void SkinChanged(ISkinSource skin) { base.SkinChanged(skin);