mirror of
https://github.com/ppy/osu.git
synced 2025-01-27 17:53:15 +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>
|
/// </summary>
|
||||||
void Reload();
|
void Reload();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reload this target from the provided skinnable information.
|
||||||
|
/// </summary>
|
||||||
|
public void Reload(SkinnableInfo[] skinnableInfo);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add a new skinnable component to this target.
|
/// Add a new skinnable component to this target.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -2,10 +2,12 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Screens.Play.HUD;
|
||||||
|
|
||||||
namespace osu.Game.Skinning
|
namespace osu.Game.Skinning
|
||||||
{
|
{
|
||||||
@ -30,16 +32,31 @@ namespace osu.Game.Skinning
|
|||||||
Target = target;
|
Target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
public void Reload(SkinnableInfo[] skinnableInfo)
|
||||||
/// Reload all components in this container from the current skin.
|
{
|
||||||
/// </summary>
|
var drawables = new List<Drawable>();
|
||||||
public void Reload()
|
|
||||||
|
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();
|
ClearInternal();
|
||||||
components.Clear();
|
components.Clear();
|
||||||
ComponentsLoaded = false;
|
ComponentsLoaded = false;
|
||||||
|
|
||||||
content = CurrentSkin.GetDrawableComponent(new GlobalSkinComponentLookup(Target)) as SkinnableTargetComponentsContainer;
|
if (componentsContainer == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
content = componentsContainer;
|
||||||
|
|
||||||
cancellationSource?.Cancel();
|
cancellationSource?.Cancel();
|
||||||
cancellationSource = null;
|
cancellationSource = null;
|
||||||
|
Loading…
Reference in New Issue
Block a user