1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-17 13:42:56 +08:00
osu-lazer/osu.Game/Screens/Play/HUD/SkinnableElementTargetContainer.cs

49 lines
1.3 KiB
C#
Raw Normal View History

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Graphics;
using osu.Game.Extensions;
2021-05-07 17:18:29 +08:00
using osu.Game.Skinning;
namespace osu.Game.Screens.Play.HUD
{
2021-05-07 17:18:29 +08:00
public class SkinnableElementTargetContainer : SkinReloadableDrawable, ISkinnableTarget
{
private SkinnableTargetWrapper content;
public SkinnableTarget Target { get; }
public SkinnableElementTargetContainer(SkinnableTarget target)
{
Target = target;
}
public void Reload()
{
content = CurrentSkin.GetDrawableComponent(new SkinnableTargetComponent(Target)) as SkinnableTargetWrapper;
ClearInternal();
if (content != null)
LoadComponentAsync(content, AddInternal);
}
public void Add(Drawable drawable)
{
content.Add(drawable);
}
public IEnumerable<SkinnableInfo> CreateSerialisedChildren() =>
content.Select(d => d.CreateSerialisedInformation());
2021-05-07 17:18:29 +08:00
protected override void SkinChanged(ISkinSource skin, bool allowFallback)
{
base.SkinChanged(skin, allowFallback);
Reload();
2021-05-07 17:18:29 +08:00
}
}
}