1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 17:32:54 +08:00

Standardise naming of methods related to SkinnableInfo

This commit is contained in:
Dean Herbert 2021-05-13 13:14:49 +09:00
parent 581e7940c7
commit 3b862798e9
4 changed files with 10 additions and 7 deletions

View File

@ -46,9 +46,9 @@ 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 CreateSerialisedInformation(this Drawable component) => new SkinnableInfo(component); public static SkinnableInfo CreateSkinnableInfo(this Drawable component) => new SkinnableInfo(component);
public static void ApplySerialisedInformation(this Drawable component, SkinnableInfo info) public static void ApplySkinnableInfo(this Drawable component, SkinnableInfo info)
{ {
// 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 = info.Position;

View File

@ -56,7 +56,7 @@ namespace osu.Game.Screens.Play.HUD
if (component is Container<Drawable> container) if (component is Container<Drawable> container)
{ {
foreach (var child in container.OfType<ISkinSerialisable>().OfType<Drawable>()) foreach (var child in container.OfType<ISkinSerialisable>().OfType<Drawable>())
Children.Add(child.CreateSerialisedInformation()); Children.Add(child.CreateSkinnableInfo());
} }
} }
@ -67,7 +67,7 @@ namespace osu.Game.Screens.Play.HUD
public Drawable CreateInstance() public Drawable CreateInstance()
{ {
Drawable d = (Drawable)Activator.CreateInstance(Type); Drawable d = (Drawable)Activator.CreateInstance(Type);
d.ApplySerialisedInformation(this); d.ApplySkinnableInfo(this);
return d; return d;
} }
} }

View File

@ -76,7 +76,7 @@ namespace osu.Game.Skinning
/// <param name="targetContainer">The target container to serialise to this skin.</param> /// <param name="targetContainer">The target container to serialise to this skin.</param>
public void UpdateDrawableTarget(SkinnableElementTargetContainer targetContainer) public void UpdateDrawableTarget(SkinnableElementTargetContainer targetContainer)
{ {
DrawableComponentInfo[targetContainer.Target] = targetContainer.CreateSerialisedChildren().ToArray(); DrawableComponentInfo[targetContainer.Target] = targetContainer.CreateSkinnableInfo().ToArray();
} }
public virtual Drawable GetDrawableComponent(ISkinComponent component) public virtual Drawable GetDrawableComponent(ISkinComponent component)

View File

@ -64,8 +64,11 @@ namespace osu.Game.Skinning
components.Add(component); components.Add(component);
} }
public IEnumerable<SkinnableInfo> CreateSerialisedChildren() => /// <summary>
components.Select(d => ((Drawable)d).CreateSerialisedInformation()); /// Serialise all children as <see cref="SkinnableInfo"/>.
/// </summary>
/// <returns>The serialised content.</returns>
public IEnumerable<SkinnableInfo> CreateSkinnableInfo() => components.Select(d => ((Drawable)d).CreateSkinnableInfo());
protected override void SkinChanged(ISkinSource skin, bool allowFallback) protected override void SkinChanged(ISkinSource skin, bool allowFallback)
{ {