mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 08:27:49 +08:00
Avoid making non-ruleset transformers in Ruleset.CreateSkinTransformer
This didn't make any sense, so let's do it a better way.
This commit is contained in:
parent
3c572abaa7
commit
60d383448f
@ -6,7 +6,7 @@ using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.Skinning.Argon
|
||||
{
|
||||
public class CatchArgonSkinTransformer : ArgonSkinTransformer
|
||||
public class CatchArgonSkinTransformer : SkinTransformer
|
||||
{
|
||||
public CatchArgonSkinTransformer(ISkin skin)
|
||||
: base(skin)
|
||||
|
@ -40,7 +40,7 @@ namespace osu.Game.Rulesets.Catch.Skinning.Legacy
|
||||
return base.GetDrawableComponent(lookup) as Container;
|
||||
|
||||
// Skin has configuration.
|
||||
if (base.GetDrawableComponent(lookup) is Drawable d)
|
||||
if (base.GetDrawableComponent(lookup) is UserConfiguredLayoutContainer d)
|
||||
return d;
|
||||
|
||||
// Our own ruleset components default.
|
||||
|
@ -7,7 +7,7 @@ using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Skinning.Argon
|
||||
{
|
||||
public class OsuArgonSkinTransformer : ArgonSkinTransformer
|
||||
public class OsuArgonSkinTransformer : SkinTransformer
|
||||
{
|
||||
public OsuArgonSkinTransformer(ISkin skin)
|
||||
: base(skin)
|
||||
|
@ -50,7 +50,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
||||
return base.GetDrawableComponent(lookup);
|
||||
|
||||
// Skin has configuration.
|
||||
if (base.GetDrawableComponent(lookup) is Drawable d)
|
||||
if (base.GetDrawableComponent(lookup) is UserConfiguredLayoutContainer d)
|
||||
return d;
|
||||
|
||||
// Our own ruleset components default.
|
||||
@ -74,6 +74,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new LegacyComboCounter(),
|
||||
new LegacyKeyCounterDisplay(),
|
||||
}
|
||||
};
|
||||
|
@ -7,7 +7,7 @@ using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Skinning.Argon
|
||||
{
|
||||
public class TaikoArgonSkinTransformer : ArgonSkinTransformer
|
||||
public class TaikoArgonSkinTransformer : SkinTransformer
|
||||
{
|
||||
public TaikoArgonSkinTransformer(ISkin skin)
|
||||
: base(skin)
|
||||
|
@ -212,19 +212,7 @@ namespace osu.Game.Rulesets
|
||||
/// <param name="skin">The source skin.</param>
|
||||
/// <param name="beatmap">The current beatmap.</param>
|
||||
/// <returns>A skin with a transformer applied, or null if no transformation is provided by this ruleset.</returns>
|
||||
public virtual ISkin? CreateSkinTransformer(ISkin skin, IBeatmap beatmap)
|
||||
{
|
||||
switch (skin)
|
||||
{
|
||||
case LegacySkin:
|
||||
return new LegacySkinTransformer(skin);
|
||||
|
||||
case ArgonSkin:
|
||||
return new ArgonSkinTransformer(skin);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public virtual ISkin? CreateSkinTransformer(ISkin skin, IBeatmap beatmap) => null;
|
||||
|
||||
protected Ruleset()
|
||||
{
|
||||
|
@ -7,6 +7,7 @@ using JetBrains.Annotations;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Beatmaps.Formats;
|
||||
@ -93,15 +94,12 @@ namespace osu.Game.Skinning
|
||||
// Temporary until default skin has a valid hit lighting.
|
||||
if ((lookup as SkinnableSprite.SpriteComponentLookup)?.LookupName == @"lighting") return Drawable.Empty();
|
||||
|
||||
if (base.GetDrawableComponent(lookup) is Drawable c)
|
||||
if (base.GetDrawableComponent(lookup) is UserConfiguredLayoutContainer c)
|
||||
return c;
|
||||
|
||||
switch (lookup)
|
||||
{
|
||||
case SkinComponentsContainerLookup containerLookup:
|
||||
// Only handle global level defaults for now.
|
||||
if (containerLookup.Ruleset != null)
|
||||
return null;
|
||||
|
||||
switch (containerLookup.Target)
|
||||
{
|
||||
@ -114,6 +112,21 @@ namespace osu.Game.Skinning
|
||||
return songSelectComponents;
|
||||
|
||||
case SkinComponentsContainerLookup.TargetArea.MainHUDComponents:
|
||||
if (containerLookup.Ruleset != null)
|
||||
{
|
||||
return new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = new ArgonComboCounter
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Position = new Vector2(36, -66),
|
||||
Scale = new Vector2(1.3f),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
var mainHUDComponents = new DefaultSkinComponentsContainer(container =>
|
||||
{
|
||||
var health = container.OfType<ArgonHealthDisplay>().FirstOrDefault();
|
||||
|
@ -1,40 +0,0 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Skinning
|
||||
{
|
||||
public class ArgonSkinTransformer : SkinTransformer
|
||||
{
|
||||
public ArgonSkinTransformer(ISkin skin)
|
||||
: base(skin)
|
||||
{
|
||||
}
|
||||
|
||||
public override Drawable? GetDrawableComponent(ISkinComponentLookup lookup)
|
||||
{
|
||||
if (lookup is SkinComponentsContainerLookup containerLookup
|
||||
&& containerLookup.Target == SkinComponentsContainerLookup.TargetArea.MainHUDComponents
|
||||
&& containerLookup.Ruleset != null)
|
||||
{
|
||||
return base.GetDrawableComponent(lookup) ?? new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = new ArgonComboCounter
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Position = new Vector2(36, -66),
|
||||
Scale = new Vector2(1.3f),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return base.GetDrawableComponent(lookup);
|
||||
}
|
||||
}
|
||||
}
|
@ -13,6 +13,7 @@ using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.ObjectExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.IO.Stores;
|
||||
using osu.Game.Audio;
|
||||
@ -349,19 +350,24 @@ namespace osu.Game.Skinning
|
||||
|
||||
public override Drawable? GetDrawableComponent(ISkinComponentLookup lookup)
|
||||
{
|
||||
if (base.GetDrawableComponent(lookup) is Drawable c)
|
||||
if (base.GetDrawableComponent(lookup) is UserConfiguredLayoutContainer c)
|
||||
return c;
|
||||
|
||||
switch (lookup)
|
||||
{
|
||||
case SkinComponentsContainerLookup containerLookup:
|
||||
// Only handle global level defaults for now.
|
||||
if (containerLookup.Ruleset != null)
|
||||
return null;
|
||||
|
||||
switch (containerLookup.Target)
|
||||
{
|
||||
case SkinComponentsContainerLookup.TargetArea.MainHUDComponents:
|
||||
if (containerLookup.Ruleset != null)
|
||||
{
|
||||
return new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = new LegacyComboCounter(),
|
||||
};
|
||||
}
|
||||
|
||||
return new DefaultSkinComponentsContainer(container =>
|
||||
{
|
||||
var score = container.OfType<LegacyScoreCounter>().FirstOrDefault();
|
||||
|
@ -2,42 +2,24 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Rulesets.Objects.Legacy;
|
||||
using static osu.Game.Skinning.SkinConfiguration;
|
||||
|
||||
namespace osu.Game.Skinning
|
||||
{
|
||||
public class LegacySkinTransformer : SkinTransformer
|
||||
public abstract class LegacySkinTransformer : SkinTransformer
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether the skin being transformed is able to provide legacy resources for the ruleset.
|
||||
/// </summary>
|
||||
public virtual bool IsProvidingLegacyResources => this.HasFont(LegacyFont.Combo);
|
||||
|
||||
public LegacySkinTransformer(ISkin skin)
|
||||
protected LegacySkinTransformer(ISkin skin)
|
||||
: base(skin)
|
||||
{
|
||||
}
|
||||
|
||||
public override Drawable? GetDrawableComponent(ISkinComponentLookup lookup)
|
||||
{
|
||||
if (lookup is SkinComponentsContainerLookup containerLookup
|
||||
&& containerLookup.Target == SkinComponentsContainerLookup.TargetArea.MainHUDComponents
|
||||
&& containerLookup.Ruleset != null)
|
||||
{
|
||||
return base.GetDrawableComponent(lookup) ?? new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = new LegacyComboCounter(),
|
||||
};
|
||||
}
|
||||
|
||||
return base.GetDrawableComponent(lookup);
|
||||
}
|
||||
|
||||
public override ISample? GetSample(ISampleInfo sampleInfo)
|
||||
{
|
||||
if (!(sampleInfo is ConvertHitObjectParser.LegacyHitSampleInfo legacySample))
|
||||
|
@ -14,7 +14,6 @@ using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.TypeExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.IO.Stores;
|
||||
using osu.Framework.Logging;
|
||||
@ -26,7 +25,7 @@ using osu.Game.Screens.Play.HUD;
|
||||
|
||||
namespace osu.Game.Skinning
|
||||
{
|
||||
public abstract class Skin : IDisposable, ISkin
|
||||
public abstract partial class Skin : IDisposable, ISkin
|
||||
{
|
||||
private readonly IStorageResourceProvider? resources;
|
||||
|
||||
@ -195,7 +194,7 @@ namespace osu.Game.Skinning
|
||||
if (!LayoutInfos.TryGetValue(containerLookup.Target, out var layoutInfo)) return null;
|
||||
if (!layoutInfo.TryGetDrawableInfo(containerLookup.Ruleset, out var drawableInfos)) return null;
|
||||
|
||||
return new Container
|
||||
return new UserConfiguredLayoutContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
ChildrenEnumerable = drawableInfos.Select(i => i.CreateInstance())
|
||||
|
@ -64,7 +64,7 @@ namespace osu.Game.Skinning
|
||||
// Temporary until default skin has a valid hit lighting.
|
||||
if ((lookup as SkinnableSprite.SpriteComponentLookup)?.LookupName == @"lighting") return Drawable.Empty();
|
||||
|
||||
if (base.GetDrawableComponent(lookup) is Drawable c)
|
||||
if (base.GetDrawableComponent(lookup) is UserConfiguredLayoutContainer c)
|
||||
return c;
|
||||
|
||||
switch (lookup)
|
||||
|
15
osu.Game/Skinning/UserConfiguredLayoutContainer.cs
Normal file
15
osu.Game/Skinning/UserConfiguredLayoutContainer.cs
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Graphics.Containers;
|
||||
|
||||
namespace osu.Game.Skinning
|
||||
{
|
||||
/// <summary>
|
||||
/// This signifies that a <see cref="Skin.GetDrawableComponent"/> call resolved a configuration created
|
||||
/// by a user in their skin. Generally this should be given priority over any local defaults or overrides.
|
||||
/// </summary>
|
||||
public partial class UserConfiguredLayoutContainer : Container
|
||||
{
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user