mirror of
https://github.com/ppy/osu.git
synced 2025-01-27 00:23:01 +08:00
Expose a method to reload a SkinnableTargetContainer
from provided info
This commit is contained in:
parent
3345e34544
commit
2f30306ea2
@ -36,6 +36,11 @@ namespace osu.Game.Skinning
|
||||
/// </summary>
|
||||
void Reload();
|
||||
|
||||
/// <summary>
|
||||
/// Reload this target from the provided skinnable information.
|
||||
/// </summary>
|
||||
public void Reload(SkinnableInfo[] skinnableInfo);
|
||||
|
||||
/// <summary>
|
||||
/// Add a new skinnable component to this target.
|
||||
/// </summary>
|
||||
|
@ -2,10 +2,12 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
|
||||
namespace osu.Game.Skinning
|
||||
{
|
||||
@ -30,16 +32,31 @@ namespace osu.Game.Skinning
|
||||
Target = target;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reload all components in this container from the current skin.
|
||||
/// </summary>
|
||||
public void Reload()
|
||||
public void Reload(SkinnableInfo[] skinnableInfo)
|
||||
{
|
||||
var drawables = new List<Drawable>();
|
||||
|
||||
foreach (var i in skinnableInfo)
|
||||
drawables.Add(i.CreateInstance());
|
||||
|
||||
Reload(new SkinnableTargetComponentsContainer
|
||||
{
|
||||
Children = drawables,
|
||||
});
|
||||
}
|
||||
|
||||
public void Reload() => Reload(CurrentSkin.GetDrawableComponent(new GlobalSkinComponentLookup(Target)) as SkinnableTargetComponentsContainer);
|
||||
|
||||
public void Reload(SkinnableTargetComponentsContainer? componentsContainer)
|
||||
{
|
||||
ClearInternal();
|
||||
components.Clear();
|
||||
ComponentsLoaded = false;
|
||||
|
||||
content = CurrentSkin.GetDrawableComponent(new GlobalSkinComponentLookup(Target)) as SkinnableTargetComponentsContainer;
|
||||
if (componentsContainer == null)
|
||||
return;
|
||||
|
||||
content = componentsContainer;
|
||||
|
||||
cancellationSource?.Cancel();
|
||||
cancellationSource = null;
|
||||
|
Loading…
Reference in New Issue
Block a user