Return default combo colours if none provided

This commit is contained in:
iiSaLMaN
2019-10-09 21:08:07 +03:00
parent 281671a213
commit 5e3f0f6c95
3 changed files with 14 additions and 10 deletions

View File

@ -77,8 +77,6 @@ namespace osu.Game.Beatmaps.Formats
return line; return line;
} }
private bool hasComboColours;
private void handleColours(T output, string line) private void handleColours(T output, string line)
{ {
var pair = SplitKeyVal(line); var pair = SplitKeyVal(line);
@ -105,13 +103,6 @@ namespace osu.Game.Beatmaps.Formats
{ {
if (!(output is IHasComboColours tHasComboColours)) return; if (!(output is IHasComboColours tHasComboColours)) return;
if (!hasComboColours)
{
// remove default colours.
tHasComboColours.ComboColours.Clear();
hasComboColours = true;
}
tHasComboColours.ComboColours.Add(colour); tHasComboColours.ComboColours.Add(colour);
} }
else else

View File

@ -9,6 +9,9 @@ namespace osu.Game.Skinning
{ {
public class LegacyBeatmapSkin : LegacySkin public class LegacyBeatmapSkin : LegacySkin
{ {
// Null should be returned in the case of no colours provided to fallback into current skin's colours.
protected override bool AllowDefaultColoursFallback => false;
public LegacyBeatmapSkin(BeatmapInfo beatmap, IResourceStore<byte[]> storage, AudioManager audioManager) public LegacyBeatmapSkin(BeatmapInfo beatmap, IResourceStore<byte[]> storage, AudioManager audioManager)
: base(createSkinInfo(beatmap), new LegacySkinResourceStore<BeatmapSetFileInfo>(beatmap.BeatmapSet, storage), audioManager, beatmap.Path) : base(createSkinInfo(beatmap), new LegacySkinResourceStore<BeatmapSetFileInfo>(beatmap.BeatmapSet, storage), audioManager, beatmap.Path)
{ {

View File

@ -26,6 +26,11 @@ namespace osu.Game.Skinning
[CanBeNull] [CanBeNull]
protected IResourceStore<SampleChannel> Samples; protected IResourceStore<SampleChannel> Samples;
/// <summary>
/// Whether to allow default combo colours as fallback if none provided in this skin.
/// </summary>
protected virtual bool AllowDefaultColoursFallback => true;
public LegacySkin(SkinInfo skin, IResourceStore<byte[]> storage, AudioManager audioManager) public LegacySkin(SkinInfo skin, IResourceStore<byte[]> storage, AudioManager audioManager)
: this(skin, new LegacySkinResourceStore<SkinFileInfo>(skin, storage), audioManager, "skin.ini") : this(skin, new LegacySkinResourceStore<SkinFileInfo>(skin, storage), audioManager, "skin.ini")
{ {
@ -63,7 +68,12 @@ namespace osu.Game.Skinning
switch (global) switch (global)
{ {
case GlobalSkinConfiguration.ComboColours: case GlobalSkinConfiguration.ComboColours:
return SkinUtils.As<TValue>(new Bindable<List<Color4>>(Configuration.ComboColours)); if (Configuration.ComboColours.Any())
return SkinUtils.As<TValue>(new Bindable<List<Color4>>(Configuration.ComboColours));
else if (AllowDefaultColoursFallback)
return SkinUtils.As<TValue>(new Bindable<List<Color4>>(new DefaultSkinConfiguration().ComboColours));
break;
} }
break; break;