Rename SkinnableInfo to SkinnableDrawableInfo

This commit is contained in:
Dean Herbert 2023-02-15 15:36:18 +09:00
parent 6010dde86e
commit 9e651a7ca2
9 changed files with 30 additions and 30 deletions

View File

@ -74,7 +74,7 @@ namespace osu.Game.Tests.Skins
}
}
var editableTypes = SkinnableInfo.GetAllAvailableDrawables().Where(t => (Activator.CreateInstance(t) as ISkinnableDrawable)?.IsEditable == true);
var editableTypes = SkinnableDrawableInfo.GetAllAvailableDrawables().Where(t => (Activator.CreateInstance(t) as ISkinnableDrawable)?.IsEditable == true);
Assert.That(instantiatedTypes, Is.EquivalentTo(editableTypes));
}

View File

@ -90,15 +90,15 @@ namespace osu.Game.Tests.Visual.Gameplay
return almostEqual(actualInfo, expectedInfo);
}
private static bool almostEqual(SkinnableInfo info, SkinnableInfo? other) =>
private static bool almostEqual(SkinnableDrawableInfo drawableInfo, SkinnableDrawableInfo? other) =>
other != null
&& info.Type == other.Type
&& info.Anchor == other.Anchor
&& info.Origin == other.Origin
&& Precision.AlmostEquals(info.Position, other.Position, 1)
&& Precision.AlmostEquals(info.Scale, other.Scale)
&& Precision.AlmostEquals(info.Rotation, other.Rotation)
&& info.Children.SequenceEqual(other.Children, new FuncEqualityComparer<SkinnableInfo>(almostEqual));
&& drawableInfo.Type == other.Type
&& drawableInfo.Anchor == other.Anchor
&& drawableInfo.Origin == other.Origin
&& Precision.AlmostEquals(drawableInfo.Position, other.Position, 1)
&& Precision.AlmostEquals(drawableInfo.Scale, other.Scale)
&& Precision.AlmostEquals(drawableInfo.Rotation, other.Rotation)
&& drawableInfo.Children.SequenceEqual(other.Children, new FuncEqualityComparer<SkinnableDrawableInfo>(almostEqual));
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard? storyboard = null)
=> new CustomSkinWorkingBeatmap(beatmap, storyboard, Clock, Audio, currentBeatmapSkin);

View File

@ -48,26 +48,26 @@ namespace osu.Game.Extensions
public static Vector2 ScreenSpaceDeltaToParentSpace(this Drawable drawable, Vector2 delta) =>
drawable.Parent.ToLocalSpace(drawable.Parent.ToScreenSpace(Vector2.Zero) + delta);
public static SkinnableInfo CreateSkinnableInfo(this Drawable component) => new SkinnableInfo(component);
public static SkinnableDrawableInfo CreateSkinnableInfo(this Drawable component) => new SkinnableDrawableInfo(component);
public static void ApplySkinnableInfo(this Drawable component, SkinnableInfo info)
public static void ApplySkinnableInfo(this Drawable component, SkinnableDrawableInfo drawableInfo)
{
// todo: can probably make this better via deserialisation directly using a common interface.
component.Position = info.Position;
component.Rotation = info.Rotation;
component.Scale = info.Scale;
component.Anchor = info.Anchor;
component.Origin = info.Origin;
component.Position = drawableInfo.Position;
component.Rotation = drawableInfo.Rotation;
component.Scale = drawableInfo.Scale;
component.Anchor = drawableInfo.Anchor;
component.Origin = drawableInfo.Origin;
if (component is ISkinnableDrawable skinnable)
{
skinnable.UsesFixedAnchor = info.UsesFixedAnchor;
skinnable.UsesFixedAnchor = drawableInfo.UsesFixedAnchor;
foreach (var (_, property) in component.GetSettingsSourceProperties())
{
var bindable = ((IBindable)property.GetValue(component)!);
if (!info.Settings.TryGetValue(property.Name.ToSnakeCase(), out object? settingValue))
if (!drawableInfo.Settings.TryGetValue(property.Name.ToSnakeCase(), out object? settingValue))
{
// TODO: We probably want to restore default if not included in serialisation information.
// This is not simple to do as SetDefault() is only found in the typed Bindable<T> interface right now.
@ -80,7 +80,7 @@ namespace osu.Game.Extensions
if (component is Container container)
{
foreach (var child in info.Children)
foreach (var child in drawableInfo.Children)
container.Add(child.CreateInstance());
}
}

View File

@ -48,7 +48,7 @@ namespace osu.Game.Overlays.SkinEditor
{
fill.Clear();
var skinnableTypes = SkinnableInfo.GetAllAvailableDrawables();
var skinnableTypes = SkinnableDrawableInfo.GetAllAvailableDrawables(target?.Ruleset);
foreach (var type in skinnableTypes)
attemptAddComponent(type);
}

View File

@ -52,12 +52,12 @@ namespace osu.Game.Overlays.SkinEditor
if (firstTarget == null)
return;
var deserializedContent = JsonConvert.DeserializeObject<IEnumerable<SkinnableInfo>>(Encoding.UTF8.GetString(newState));
var deserializedContent = JsonConvert.DeserializeObject<IEnumerable<SkinnableDrawableInfo>>(Encoding.UTF8.GetString(newState));
if (deserializedContent == null)
return;
SkinnableInfo[] skinnableInfo = deserializedContent.ToArray();
SkinnableDrawableInfo[] skinnableInfo = deserializedContent.ToArray();
Drawable[] targetComponents = firstTarget.Components.OfType<Drawable>().ToArray();
if (!skinnableInfo.Select(s => s.Type).SequenceEqual(targetComponents.Select(d => d.GetType())))

View File

@ -29,7 +29,7 @@ namespace osu.Game.Skinning
/// Serialise all children as <see cref="SkinnableInfo"/>.
/// </summary>
/// <returns>The serialised content.</returns>
IEnumerable<SkinnableInfo> CreateSkinnableInfo() => Components.Select(d => ((Drawable)d).CreateSkinnableInfo());
IEnumerable<SkinnableDrawableInfo> CreateSkinnableInfo() => Components.Select(d => ((Drawable)d).CreateSkinnableInfo());
/// <summary>
/// Reload this target from the current skin.
@ -39,7 +39,7 @@ namespace osu.Game.Skinning
/// <summary>
/// Reload this target from the provided skinnable information.
/// </summary>
void Reload(SkinnableInfo[] skinnableInfo);
void Reload(SkinnableDrawableInfo[] skinnableInfo);
/// <summary>
/// Add a new skinnable component to this target.

View File

@ -44,7 +44,7 @@ namespace osu.Game.Skinning
private readonly Container counterContainer;
/// <summary>
/// Hides the combo counter internally without affecting its <see cref="SkinnableInfo"/>.
/// Hides the combo counter internally without affecting its <see cref="SkinnableDrawableInfo"/>.
/// </summary>
/// <remarks>
/// This is used for rulesets that provide their own combo counter and don't want this HUD one to be visible,

View File

@ -22,7 +22,7 @@ namespace osu.Game.Skinning
/// Serialised information governing custom changes to an <see cref="ISkinnableDrawable"/>.
/// </summary>
[Serializable]
public class SkinnableInfo
public sealed class SkinnableDrawableInfo
{
public Type Type { get; set; }
@ -41,10 +41,10 @@ namespace osu.Game.Skinning
public Dictionary<string, object> Settings { get; set; } = new Dictionary<string, object>();
public List<SkinnableInfo> Children { get; } = new List<SkinnableInfo>();
public List<SkinnableDrawableInfo> Children { get; } = new List<SkinnableDrawableInfo>();
[JsonConstructor]
public SkinnableInfo()
public SkinnableDrawableInfo()
{
}
@ -52,7 +52,7 @@ namespace osu.Game.Skinning
/// Construct a new instance populating all attributes from the provided drawable.
/// </summary>
/// <param name="component">The drawable which attributes should be sourced from.</param>
public SkinnableInfo(Drawable component)
public SkinnableDrawableInfo(Drawable component)
{
Type = component.GetType();

View File

@ -33,7 +33,7 @@ namespace osu.Game.Skinning
Target = target;
}
public void Reload(SkinnableInfo[] skinnableInfo)
public void Reload(SkinnableDrawableInfo[] skinnableInfo)
{
var drawables = new List<Drawable>();