Add serialization support via SkinnableInfo

This commit is contained in:
Robin Avery 2021-06-06 07:18:08 -04:00
parent c9f5808bf2
commit 11b1b8c633
No known key found for this signature in database
GPG Key ID: 0496DF10CEF7E226
2 changed files with 9 additions and 0 deletions

View File

@ -60,6 +60,7 @@ namespace osu.Game.Extensions
component.Scale = info.Scale;
component.Anchor = info.Anchor;
component.Origin = info.Origin;
component.IsUsingClosestAnchor().Value = !info.IsNotUsingClosestAnchor;
if (component is Container container)
{

View File

@ -32,6 +32,13 @@ namespace osu.Game.Screens.Play.HUD
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>();
[JsonConstructor]
@ -52,6 +59,7 @@ namespace osu.Game.Screens.Play.HUD
Scale = component.Scale;
Anchor = component.Anchor;
Origin = component.Origin;
IsNotUsingClosestAnchor = !component.IsUsingClosestAnchor().Value;
if (component is Container<Drawable> container)
{