2022-09-22 09:50:19 +00:00
|
|
|
// 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 System;
|
|
|
|
using osu.Framework.Audio.Sample;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Textures;
|
|
|
|
using osu.Game.Audio;
|
|
|
|
|
|
|
|
namespace osu.Game.Skinning
|
|
|
|
{
|
2023-02-15 06:14:38 +00:00
|
|
|
/// <summary>
|
|
|
|
/// A default skin transformer, which falls back to the provided skin by default.
|
|
|
|
/// </summary>
|
|
|
|
/// <remarks>
|
|
|
|
/// Implementations of skin transformers should generally derive this class and override
|
|
|
|
/// individual lookup methods, modifying the lookup flow as required.
|
|
|
|
/// </remarks>
|
2022-09-22 09:50:19 +00:00
|
|
|
public abstract class SkinTransformer : ISkinTransformer
|
|
|
|
{
|
|
|
|
public ISkin Skin { get; }
|
|
|
|
|
|
|
|
protected SkinTransformer(ISkin skin)
|
|
|
|
{
|
|
|
|
Skin = skin ?? throw new ArgumentNullException(nameof(skin));
|
|
|
|
}
|
|
|
|
|
2022-11-09 07:04:56 +00:00
|
|
|
public virtual Drawable? GetDrawableComponent(ISkinComponentLookup lookup) => Skin.GetDrawableComponent(lookup);
|
2022-09-22 09:50:19 +00:00
|
|
|
|
|
|
|
public virtual Texture? GetTexture(string componentName) => GetTexture(componentName, default, default);
|
|
|
|
|
|
|
|
public virtual Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => Skin.GetTexture(componentName, wrapModeS, wrapModeT);
|
|
|
|
|
|
|
|
public virtual ISample? GetSample(ISampleInfo sampleInfo) => Skin.GetSample(sampleInfo);
|
|
|
|
|
2023-09-06 08:37:17 +00:00
|
|
|
public virtual IBindable<TValue>? GetConfig<TLookup, TValue>(TLookup lookup) where TLookup : notnull where TValue : notnull
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Skinning.Skin.LogLookupDebug(this, lookup, Skinning.Skin.LookupDebugType.Enter);
|
|
|
|
return Skin.GetConfig<TLookup, TValue>(lookup);
|
|
|
|
}
|
|
|
|
finally
|
|
|
|
{
|
|
|
|
Skinning.Skin.LogLookupDebug(this, lookup, Skinning.Skin.LookupDebugType.Exit);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-06 15:46:42 +00:00
|
|
|
public override string ToString() => $"{nameof(SkinTransformer)} {{ Skin: {Skin} }}";
|
2022-09-22 09:50:19 +00:00
|
|
|
}
|
|
|
|
}
|