// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. 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 { /// /// A beatmap skin which is being edited. /// public class EditorBeatmapSkin : ISkin { public event Action BeatmapSkinChanged; /// /// The underlying beatmap skin. /// protected internal ISkin Skin => skin; private readonly Skin skin; /// /// The combo colours of this skin. /// If empty, the default combo colours will be used. /// public BindableList ComboColours { get; } public EditorBeatmapSkin(Skin skin) { this.skin = skin; ComboColours = new BindableList(); if (skin.Configuration.ComboColours != null) ComboColours.AddRange(skin.Configuration.ComboColours.Select(c => (Colour4)c)); ComboColours.BindCollectionChanged((_, __) => updateColours()); } private void invokeSkinChanged() => BeatmapSkinChanged?.Invoke(); private void updateColours() { skin.Configuration.CustomComboColours = ComboColours.Select(c => (Color4)c).ToList(); 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 GetConfig(TLookup lookup) => skin.GetConfig(lookup); #endregion } }