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;
|
2024-02-23 21:49:46 +08:00
|
|
|
using System.Collections.Generic;
|
2021-08-15 22:13:59 +08:00
|
|
|
using osu.Framework.Audio.Sample;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
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>
|
2022-04-18 11:42:06 +08:00
|
|
|
/// The underlying beatmap skin.
|
2021-08-15 22:13:59 +08:00
|
|
|
/// </summary>
|
2022-04-18 12:32:37 +08:00
|
|
|
protected internal readonly Skin Skin;
|
2021-08-15 22:13:59 +08:00
|
|
|
|
2022-04-18 11:42:06 +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)
|
|
|
|
{
|
2022-04-18 12:32:37 +08:00
|
|
|
Skin = skin;
|
2021-08-15 22:13:59 +08:00
|
|
|
|
|
|
|
ComboColours = new BindableList<Colour4>();
|
2024-02-23 21:49:46 +08:00
|
|
|
|
|
|
|
if (Skin.Configuration.ComboColours is IReadOnlyList<Color4> comboColours)
|
|
|
|
{
|
|
|
|
// due to the foibles of how `IHasComboInformation` / `ComboIndexWithOffsets` work,
|
|
|
|
// the actual effective first combo colour that will be used on the beatmap is the one with index 1, not 0.
|
|
|
|
// see also: `IHasComboInformation.UpdateComboInformation`,
|
|
|
|
// https://github.com/peppy/osu-stable-reference/blob/46cd3a10af7cc6cc96f4eba92ef1812dc8c3a27e/osu!/GameModes/Edit/Forms/SongSetup.cs#L233-L234.
|
|
|
|
for (int i = 0; i < comboColours.Count; ++i)
|
|
|
|
ComboColours.Add(comboColours[(i + 1) % comboColours.Count]);
|
|
|
|
}
|
|
|
|
|
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()
|
|
|
|
{
|
2024-02-23 21:49:46 +08:00
|
|
|
// performs the inverse of the index rotation operation described in the ctor.
|
|
|
|
Skin.Configuration.CustomComboColours.Clear();
|
|
|
|
for (int i = 0; i < ComboColours.Count; ++i)
|
|
|
|
Skin.Configuration.CustomComboColours.Add(ComboColours[(ComboColours.Count + i - 1) % ComboColours.Count]);
|
2021-08-15 22:13:59 +08:00
|
|
|
invokeSkinChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
#region Delegated ISkin implementation
|
|
|
|
|
2022-11-09 15:04:56 +08:00
|
|
|
public Drawable GetDrawableComponent(ISkinComponentLookup lookup) => Skin.GetDrawableComponent(lookup);
|
2022-04-18 12:32:37 +08:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|