mirror of https://github.com/ppy/osu
Add serialization support via SkinnableInfo
This commit is contained in:
parent
c9f5808bf2
commit
11b1b8c633
|
@ -60,6 +60,7 @@ public static void ApplySkinnableInfo(this Drawable component, SkinnableInfo inf
|
||||||
component.Scale = info.Scale;
|
component.Scale = info.Scale;
|
||||||
component.Anchor = info.Anchor;
|
component.Anchor = info.Anchor;
|
||||||
component.Origin = info.Origin;
|
component.Origin = info.Origin;
|
||||||
|
component.IsUsingClosestAnchor().Value = !info.IsNotUsingClosestAnchor;
|
||||||
|
|
||||||
if (component is Container container)
|
if (component is Container container)
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,6 +32,13 @@ public class SkinnableInfo : IJsonSerializable
|
||||||
|
|
||||||
public Anchor Origin { get; set; }
|
public Anchor Origin { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// <see langword="false"/> if this <see cref="ISkinnableDrawable"/>'s <see cref="Drawable.Anchor"/> is
|
||||||
|
/// automatically determined by proximity, <see langword="true"/> if the user has overridden it.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>Stored this way because <c>default(bool)</c> is <see langword="false"/> and we want the default behaviour to be "closest".</remarks>
|
||||||
|
public bool IsNotUsingClosestAnchor { get; set; }
|
||||||
|
|
||||||
public List<SkinnableInfo> Children { get; } = new List<SkinnableInfo>();
|
public List<SkinnableInfo> Children { get; } = new List<SkinnableInfo>();
|
||||||
|
|
||||||
[JsonConstructor]
|
[JsonConstructor]
|
||||||
|
@ -52,6 +59,7 @@ public SkinnableInfo(Drawable component)
|
||||||
Scale = component.Scale;
|
Scale = component.Scale;
|
||||||
Anchor = component.Anchor;
|
Anchor = component.Anchor;
|
||||||
Origin = component.Origin;
|
Origin = component.Origin;
|
||||||
|
IsNotUsingClosestAnchor = !component.IsUsingClosestAnchor().Value;
|
||||||
|
|
||||||
if (component is Container<Drawable> container)
|
if (component is Container<Drawable> container)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue