1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 12:42:54 +08:00
osu-lazer/osu.Game/Skinning/SkinnableSprite.cs
Dean Herbert a15828ab25 Introduce the concept of SkinComponents
Removes reliance on string lookups and better defines elements for introduction into database
2019-08-30 14:55:52 +09:00

30 lines
1.0 KiB
C#

// 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.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
namespace osu.Game.Skinning
{
/// <summary>
/// A skinnable element which uses a stable sprite and can therefore share implementation logic.
/// </summary>
public class SkinnableSprite : SkinnableDrawable
{
protected override bool ApplySizeRestrictionsToDefault => true;
[Resolved]
private TextureStore textures { get; set; }
public SkinnableSprite(ISkinComponent component, Func<ISkinSource, bool> allowFallback = null, ConfineMode confineMode = ConfineMode.ScaleDownToFit)
: base(component, allowFallback, confineMode)
{
}
protected override Drawable CreateDefault(ISkinComponent component) => new Sprite { Texture = textures.Get(component.LookupName) };
}
}