mirror of
https://github.com/ppy/osu.git
synced 2025-02-05 07:12:54 +08:00
Rename SkinnableInfo
to SkinnableDrawableInfo
This commit is contained in:
parent
6010dde86e
commit
9e651a7ca2
@ -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));
|
Assert.That(instantiatedTypes, Is.EquivalentTo(editableTypes));
|
||||||
}
|
}
|
||||||
|
@ -90,15 +90,15 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
return almostEqual(actualInfo, expectedInfo);
|
return almostEqual(actualInfo, expectedInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool almostEqual(SkinnableInfo info, SkinnableInfo? other) =>
|
private static bool almostEqual(SkinnableDrawableInfo drawableInfo, SkinnableDrawableInfo? other) =>
|
||||||
other != null
|
other != null
|
||||||
&& info.Type == other.Type
|
&& drawableInfo.Type == other.Type
|
||||||
&& info.Anchor == other.Anchor
|
&& drawableInfo.Anchor == other.Anchor
|
||||||
&& info.Origin == other.Origin
|
&& drawableInfo.Origin == other.Origin
|
||||||
&& Precision.AlmostEquals(info.Position, other.Position, 1)
|
&& Precision.AlmostEquals(drawableInfo.Position, other.Position, 1)
|
||||||
&& Precision.AlmostEquals(info.Scale, other.Scale)
|
&& Precision.AlmostEquals(drawableInfo.Scale, other.Scale)
|
||||||
&& Precision.AlmostEquals(info.Rotation, other.Rotation)
|
&& Precision.AlmostEquals(drawableInfo.Rotation, other.Rotation)
|
||||||
&& info.Children.SequenceEqual(other.Children, new FuncEqualityComparer<SkinnableInfo>(almostEqual));
|
&& drawableInfo.Children.SequenceEqual(other.Children, new FuncEqualityComparer<SkinnableDrawableInfo>(almostEqual));
|
||||||
|
|
||||||
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard? storyboard = null)
|
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard? storyboard = null)
|
||||||
=> new CustomSkinWorkingBeatmap(beatmap, storyboard, Clock, Audio, currentBeatmapSkin);
|
=> new CustomSkinWorkingBeatmap(beatmap, storyboard, Clock, Audio, currentBeatmapSkin);
|
||||||
|
@ -48,26 +48,26 @@ namespace osu.Game.Extensions
|
|||||||
public static Vector2 ScreenSpaceDeltaToParentSpace(this Drawable drawable, Vector2 delta) =>
|
public static Vector2 ScreenSpaceDeltaToParentSpace(this Drawable drawable, Vector2 delta) =>
|
||||||
drawable.Parent.ToLocalSpace(drawable.Parent.ToScreenSpace(Vector2.Zero) + 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.
|
// todo: can probably make this better via deserialisation directly using a common interface.
|
||||||
component.Position = info.Position;
|
component.Position = drawableInfo.Position;
|
||||||
component.Rotation = info.Rotation;
|
component.Rotation = drawableInfo.Rotation;
|
||||||
component.Scale = info.Scale;
|
component.Scale = drawableInfo.Scale;
|
||||||
component.Anchor = info.Anchor;
|
component.Anchor = drawableInfo.Anchor;
|
||||||
component.Origin = info.Origin;
|
component.Origin = drawableInfo.Origin;
|
||||||
|
|
||||||
if (component is ISkinnableDrawable skinnable)
|
if (component is ISkinnableDrawable skinnable)
|
||||||
{
|
{
|
||||||
skinnable.UsesFixedAnchor = info.UsesFixedAnchor;
|
skinnable.UsesFixedAnchor = drawableInfo.UsesFixedAnchor;
|
||||||
|
|
||||||
foreach (var (_, property) in component.GetSettingsSourceProperties())
|
foreach (var (_, property) in component.GetSettingsSourceProperties())
|
||||||
{
|
{
|
||||||
var bindable = ((IBindable)property.GetValue(component)!);
|
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.
|
// 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.
|
// 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)
|
if (component is Container container)
|
||||||
{
|
{
|
||||||
foreach (var child in info.Children)
|
foreach (var child in drawableInfo.Children)
|
||||||
container.Add(child.CreateInstance());
|
container.Add(child.CreateInstance());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ namespace osu.Game.Overlays.SkinEditor
|
|||||||
{
|
{
|
||||||
fill.Clear();
|
fill.Clear();
|
||||||
|
|
||||||
var skinnableTypes = SkinnableInfo.GetAllAvailableDrawables();
|
var skinnableTypes = SkinnableDrawableInfo.GetAllAvailableDrawables(target?.Ruleset);
|
||||||
foreach (var type in skinnableTypes)
|
foreach (var type in skinnableTypes)
|
||||||
attemptAddComponent(type);
|
attemptAddComponent(type);
|
||||||
}
|
}
|
||||||
|
@ -52,12 +52,12 @@ namespace osu.Game.Overlays.SkinEditor
|
|||||||
if (firstTarget == null)
|
if (firstTarget == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var deserializedContent = JsonConvert.DeserializeObject<IEnumerable<SkinnableInfo>>(Encoding.UTF8.GetString(newState));
|
var deserializedContent = JsonConvert.DeserializeObject<IEnumerable<SkinnableDrawableInfo>>(Encoding.UTF8.GetString(newState));
|
||||||
|
|
||||||
if (deserializedContent == null)
|
if (deserializedContent == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SkinnableInfo[] skinnableInfo = deserializedContent.ToArray();
|
SkinnableDrawableInfo[] skinnableInfo = deserializedContent.ToArray();
|
||||||
Drawable[] targetComponents = firstTarget.Components.OfType<Drawable>().ToArray();
|
Drawable[] targetComponents = firstTarget.Components.OfType<Drawable>().ToArray();
|
||||||
|
|
||||||
if (!skinnableInfo.Select(s => s.Type).SequenceEqual(targetComponents.Select(d => d.GetType())))
|
if (!skinnableInfo.Select(s => s.Type).SequenceEqual(targetComponents.Select(d => d.GetType())))
|
||||||
|
@ -29,7 +29,7 @@ namespace osu.Game.Skinning
|
|||||||
/// Serialise all children as <see cref="SkinnableInfo"/>.
|
/// Serialise all children as <see cref="SkinnableInfo"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>The serialised content.</returns>
|
/// <returns>The serialised content.</returns>
|
||||||
IEnumerable<SkinnableInfo> CreateSkinnableInfo() => Components.Select(d => ((Drawable)d).CreateSkinnableInfo());
|
IEnumerable<SkinnableDrawableInfo> CreateSkinnableInfo() => Components.Select(d => ((Drawable)d).CreateSkinnableInfo());
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reload this target from the current skin.
|
/// Reload this target from the current skin.
|
||||||
@ -39,7 +39,7 @@ namespace osu.Game.Skinning
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reload this target from the provided skinnable information.
|
/// Reload this target from the provided skinnable information.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void Reload(SkinnableInfo[] skinnableInfo);
|
void Reload(SkinnableDrawableInfo[] skinnableInfo);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add a new skinnable component to this target.
|
/// Add a new skinnable component to this target.
|
||||||
|
@ -44,7 +44,7 @@ namespace osu.Game.Skinning
|
|||||||
private readonly Container counterContainer;
|
private readonly Container counterContainer;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Hides the combo counter internally without affecting its <see cref="SkinnableInfo"/>.
|
/// Hides the combo counter internally without affecting its <see cref="SkinnableDrawableInfo"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// This is used for rulesets that provide their own combo counter and don't want this HUD one to be visible,
|
/// This is used for rulesets that provide their own combo counter and don't want this HUD one to be visible,
|
||||||
|
@ -22,7 +22,7 @@ namespace osu.Game.Skinning
|
|||||||
/// Serialised information governing custom changes to an <see cref="ISkinnableDrawable"/>.
|
/// Serialised information governing custom changes to an <see cref="ISkinnableDrawable"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class SkinnableInfo
|
public sealed class SkinnableDrawableInfo
|
||||||
{
|
{
|
||||||
public Type Type { get; set; }
|
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 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]
|
[JsonConstructor]
|
||||||
public SkinnableInfo()
|
public SkinnableDrawableInfo()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ namespace osu.Game.Skinning
|
|||||||
/// Construct a new instance populating all attributes from the provided drawable.
|
/// Construct a new instance populating all attributes from the provided drawable.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="component">The drawable which attributes should be sourced from.</param>
|
/// <param name="component">The drawable which attributes should be sourced from.</param>
|
||||||
public SkinnableInfo(Drawable component)
|
public SkinnableDrawableInfo(Drawable component)
|
||||||
{
|
{
|
||||||
Type = component.GetType();
|
Type = component.GetType();
|
||||||
|
|
@ -33,7 +33,7 @@ namespace osu.Game.Skinning
|
|||||||
Target = target;
|
Target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Reload(SkinnableInfo[] skinnableInfo)
|
public void Reload(SkinnableDrawableInfo[] skinnableInfo)
|
||||||
{
|
{
|
||||||
var drawables = new List<Drawable>();
|
var drawables = new List<Drawable>();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user