2021-05-06 14:16:16 +08:00
|
|
|
// 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.
|
|
|
|
|
2021-05-10 21:36:20 +08:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
2021-05-11 10:56:14 +08:00
|
|
|
using osu.Framework.Graphics;
|
2021-05-10 21:36:20 +08:00
|
|
|
using osu.Game.Extensions;
|
2021-05-07 17:18:29 +08:00
|
|
|
using osu.Game.Skinning;
|
2021-05-06 14:16:16 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Screens.Play.HUD
|
|
|
|
{
|
2021-05-07 17:18:29 +08:00
|
|
|
public class SkinnableElementTargetContainer : SkinReloadableDrawable, ISkinnableTarget
|
2021-05-06 14:16:16 +08:00
|
|
|
{
|
2021-05-10 21:36:20 +08:00
|
|
|
private SkinnableTargetWrapper content;
|
|
|
|
|
2021-05-07 18:13:38 +08:00
|
|
|
public SkinnableTarget Target { get; }
|
|
|
|
|
|
|
|
public SkinnableElementTargetContainer(SkinnableTarget target)
|
|
|
|
{
|
|
|
|
Target = target;
|
|
|
|
}
|
|
|
|
|
2021-05-11 11:42:32 +08:00
|
|
|
public IReadOnlyList<Drawable> Children => content?.Children;
|
|
|
|
|
2021-05-11 10:56:14 +08:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2021-05-10 21:36:20 +08:00
|
|
|
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);
|
|
|
|
|
2021-05-11 10:56:14 +08:00
|
|
|
Reload();
|
2021-05-07 17:18:29 +08:00
|
|
|
}
|
2021-05-06 14:16:16 +08:00
|
|
|
}
|
|
|
|
}
|