1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-28 01:32:55 +08:00
osu-lazer/osu.Game/Screens/Edit/EditorBeatmapSkin.cs

65 lines
2.1 KiB
C#
Raw Normal View History

2021-08-15 22:13:59 +08: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.
2022-06-17 15:37:17 +08:00
#nullable disable
2021-08-15 22:13:59 +08:00
using System;
using System.Linq;
using osu.Framework.Audio.Sample;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.OpenGL.Textures;
using osu.Framework.Graphics.Textures;
using osu.Game.Audio;
using osu.Game.Skinning;
using osuTK.Graphics;
namespace osu.Game.Screens.Edit
{
/// <summary>
/// A beatmap skin which is being edited.
/// </summary>
public class EditorBeatmapSkin : ISkin
{
public event Action BeatmapSkinChanged;
/// <summary>
/// The underlying beatmap skin.
2021-08-15 22:13:59 +08:00
/// </summary>
protected internal readonly Skin Skin;
2021-08-15 22:13:59 +08:00
/// <summary>
/// The combo colours of this skin.
/// If empty, the default combo colours will be used.
/// </summary>
public BindableList<Colour4> ComboColours { get; }
2021-08-15 22:13:59 +08:00
public EditorBeatmapSkin(Skin skin)
{
Skin = skin;
2021-08-15 22:13:59 +08:00
ComboColours = new BindableList<Colour4>();
if (Skin.Configuration.ComboColours != null)
ComboColours.AddRange(Skin.Configuration.ComboColours.Select(c => (Colour4)c));
2022-06-24 20:25:23 +08:00
ComboColours.BindCollectionChanged((_, _) => updateColours());
2021-08-15 22:13:59 +08:00
}
private void invokeSkinChanged() => BeatmapSkinChanged?.Invoke();
private void updateColours()
{
Skin.Configuration.CustomComboColours = ComboColours.Select(c => (Color4)c).ToList();
2021-08-15 22:13:59 +08:00
invokeSkinChanged();
}
#region Delegated ISkin implementation
public Drawable GetDrawableComponent(ISkinComponent component) => Skin.GetDrawableComponent(component);
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => Skin.GetTexture(componentName, wrapModeS, wrapModeT);
public ISample GetSample(ISampleInfo sampleInfo) => Skin.GetSample(sampleInfo);
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => Skin.GetConfig<TLookup, TValue>(lookup);
2021-08-15 22:13:59 +08:00
#endregion
}
}