osu/osu.Game/Skinning/SkinnableSprite.cs

30 lines
1.0 KiB
C#
Raw Normal View History

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